Skip to content

Commit

Permalink
Add delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed May 2, 2024
1 parent e56271d commit f986ca6
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import java.net.URL;
import java.util.List;
import java.util.Map;
import lombok.experimental.Delegate;
import org.pf4j.Extension;
import org.polypheny.db.adapter.DataSource;
import org.polypheny.db.adapter.DeployMode;
import org.polypheny.db.adapter.DocumentScanDelegate;
import org.polypheny.db.adapter.annotations.AdapterProperties;
import org.polypheny.db.adapter.annotations.AdapterSettingDirectory;
import org.polypheny.db.catalog.catalogs.AdapterCatalog;
Expand Down Expand Up @@ -56,6 +58,8 @@
public class JsonSource extends DataSource<DocAdapterCatalog> {

private static final Logger log = LoggerFactory.getLogger( JsonSource.class );
@Delegate(excludes = Excludes.class)
private final DocumentScanDelegate delegate;
private JsonNamespace namespace;

private URL jsonFile;
Expand All @@ -66,6 +70,7 @@ public JsonSource( final long storeId, final String uniqueName, final Map<String
//this.jsonFile = getJsonFileUrl( settings );
URL url = getJsonFileUrl( "classpath://articles.json" );
this.jsonFile = url;
this.delegate = new DocumentScanDelegate( this, getAdapterCatalog() );
}


Expand Down Expand Up @@ -146,6 +151,11 @@ public void restoreCollection( AllocationCollection allocation, List<PhysicalEnt
adapterCatalog.addPhysical( allocation, physicalCollection );
}

@Override
public List<PhysicalEntity> createTable( Context context, LogicalTableWrapper logical, AllocationTableWrapper allocation ) {
log.debug( "NOT SUPPORTED: JSON source does not support method createTable()." );
return null;
}

@Override
public List<PhysicalEntity> createCollection( Context context, LogicalCollection logical, AllocationCollection allocation ) {
Expand Down Expand Up @@ -207,14 +217,6 @@ public void rollback( PolyXid xid ) {
log.debug( "NOT SUPPORTED: JSON source does not support method rollback()." );
}


@Override
public List<PhysicalEntity> createTable( Context context, LogicalTableWrapper logical, AllocationTableWrapper allocation ) {
log.debug( "NOT SUPPORTED: JSON source does not support method createTable()." );
return null;
}


@Override
public void dropTable( Context context, long allocId ) {
log.debug( "NOT SUPPORTED: JSON source does not support method dropTable()" );
Expand Down Expand Up @@ -246,6 +248,14 @@ public void restoreGraph( AllocationGraph alloc, List<PhysicalEntity> entities,
}


private interface Excludes {

void refreshCollection( long allocId );

void createCollection( Context context, LogicalTableWrapper logical, AllocationTableWrapper allocation );

void restoreCollection( AllocationTable alloc, List<PhysicalEntity> entities );
}
}


0 comments on commit f986ca6

Please sign in to comment.