Skip to content

Commit

Permalink
fixing statistics, runtimeExceptions, reformatting of new parts, adju…
Browse files Browse the repository at this point in the history
…stment to untyped json serialization, removed unused classes, renaming of catalog classes, fix for ui pagination
  • Loading branch information
datomo committed Nov 5, 2023
1 parent 675cfeb commit 36dba7e
Show file tree
Hide file tree
Showing 253 changed files with 1,014 additions and 2,248 deletions.
10 changes: 0 additions & 10 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ dependencies {
api project(":config")
api project(":information")

//javacc group: "net.java.dev.javacc", name: "javacc", version: javacc_version // BSD 2-clause

implementation(group: "org.pf4j", name: "pf4j", version: pf4j_version) {
exclude group: "org.slf4j"
}
Expand Down Expand Up @@ -75,11 +73,6 @@ dependencies {
implementation group: "com.github.docker-java", name: "docker-java", version: java_docker_version // Apache 2.0
implementation group: "com.github.docker-java", name: "docker-java-transport-httpclient5", version: java_docker_version // TODO: should probably be independent version in future

// uses config internally...
/*implementation(group: "com.datastax.oss", name: "java-driver-core", version: cassandra_driver_core_version) { // Apache 2.0
exclude group: "com.github.spotbugs"
}*/

api group: "io.activej", name: "activej-serializer", version: activej_serializer_version // Apache 2.0

// --- Test Compile ---
Expand Down Expand Up @@ -157,9 +150,6 @@ javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
// Exclude build dir
// exclude "fmpp/sql/javacc/**"
// exclude "fmpp/mql/javacc/**"
}


Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/polypheny/db/PolyImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ private ResultIterator( Iterator<PolyValue[]> iterator, Statement statement, int
}


public List<List<PolyValue>> getRows() {
public List<List<PolyValue>> getNextBatch() {

StopWatch stopWatch = null;
try {
Expand All @@ -396,7 +396,7 @@ public List<List<PolyValue>> getRows() {
}
List<List<PolyValue>> res = new ArrayList<>();
int i = 0;
while ( i++ < batch && iterator.hasNext() ) {
while ( (batch < 0 || i++ < batch) && iterator.hasNext() ) {
res.add( Lists.newArrayList( iterator.next() ) );
}

Expand Down Expand Up @@ -426,7 +426,7 @@ public List<List<PolyValue>> getRows() {


public List<List<PolyValue>> getAllRowsAndClose() {
List<List<PolyValue>> result = getRows();
List<List<PolyValue>> result = getNextBatch();
try {
close();
} catch ( Exception e ) {
Expand All @@ -437,12 +437,12 @@ public List<List<PolyValue>> getAllRowsAndClose() {


public List<PolyValue> getSingleRows() {
return getRows( null );
return getNextBatch( null );
}


@NotNull
private <D> List<D> getRows( @Nullable Function<PolyValue[], D> transformer ) {
private <D> List<D> getNextBatch( @Nullable Function<PolyValue[], D> transformer ) {
final Iterable<PolyValue[]> iterable = () -> iterator;

if ( transformer == null ) {
Expand All @@ -459,7 +459,7 @@ private <D> List<D> getRows( @Nullable Function<PolyValue[], D> transformer ) {

public List<PolyValue[]> getArrayRows() {

return getRows( rowType.getFieldCount() == 1 ? e -> (PolyValue[]) e : null );
return getNextBatch( rowType.getFieldCount() == 1 ? e -> (PolyValue[]) e : null );

}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/polypheny/db/StatisticsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class StatisticsManager implements PropertyChangeListener {

public static StatisticsManager setAndGetInstance( StatisticsManager transaction ) {
if ( INSTANCE != null ) {
throw new RuntimeException( "Overwriting the MaterializedViewManager is not permitted." );
throw new GenericRuntimeException( "Overwriting the MaterializedViewManager is not permitted." );
}
INSTANCE = transaction;
return INSTANCE;
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/org/polypheny/db/adapter/Modifiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.polypheny.db.algebra.type.DocumentType;
import org.polypheny.db.algebra.type.GraphType;
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.catalog.entity.allocation.AllocationCollection;
import org.polypheny.db.catalog.entity.allocation.AllocationGraph;
import org.polypheny.db.catalog.entity.allocation.AllocationTable;
Expand All @@ -73,7 +73,7 @@
public interface Modifiable extends Scannable {


static AlgNode attachRelationalGraphUpdate( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder builder, CatalogEntity nodesTable, CatalogEntity nodePropertiesTable, CatalogEntity edgesTable, CatalogEntity edgePropertiesTable ) {
static AlgNode attachRelationalGraphUpdate( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder builder, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable ) {
AlgNode project = new LogicalLpgProject( alg.getCluster(), alg.getTraitSet(), alg.getInput(), alg.operations, alg.ids );

List<AlgNode> inputs = new ArrayList<>();
Expand All @@ -96,7 +96,7 @@ static AlgNode attachRelationalGraphUpdate( Modifiable modifiable, AlgNode provi

}

static AlgNode attachRelationalGraphDelete( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, CatalogEntity nodesTable, CatalogEntity nodePropertiesTable, CatalogEntity edgesTable, CatalogEntity edgePropertiesTable ) {
static AlgNode attachRelationalGraphDelete( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable ) {
AlgNode project = new LogicalLpgProject( alg.getCluster(), alg.getTraitSet(), alg.getInput(), alg.operations, alg.ids );

List<AlgNode> inputs = new ArrayList<>();
Expand All @@ -117,7 +117,7 @@ static AlgNode attachRelationalGraphDelete( Modifiable modifiable, AlgNode provi

}

static List<AlgNode> attachPreparedGraphNodeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, CatalogEntity nodesTable, CatalogEntity nodePropertiesTable, AlgBuilder algBuilder ) {
static List<AlgNode> attachPreparedGraphNodeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, AlgBuilder algBuilder ) {
RexBuilder rexBuilder = algBuilder.getRexBuilder();
AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory();

Expand Down Expand Up @@ -146,7 +146,7 @@ static List<AlgNode> attachPreparedGraphNodeModifyDelete( Modifiable modifiable,
return inputs;
}

static AlgNode attachRelationalRelatedInsert( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, CatalogEntity nodesTable, CatalogEntity nodePropertiesTable, CatalogEntity edgesTable, CatalogEntity edgePropertiesTable ) {
static AlgNode attachRelationalRelatedInsert( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable ) {

List<AlgNode> inputs = new ArrayList<>();
List<PolyType> sequence = new ArrayList<>();
Expand All @@ -165,7 +165,7 @@ static AlgNode attachRelationalRelatedInsert( Modifiable modifiable, AlgNode pro
return new LogicalStreamer( alg.getCluster(), alg.getTraitSet(), provider, transformer );
}

static List<AlgNode> attachPreparedGraphNodeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, CatalogEntity nodesTable, CatalogEntity nodePropertiesTable, AlgBuilder algBuilder ) {
static List<AlgNode> attachPreparedGraphNodeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, AlgBuilder algBuilder ) {
RexBuilder rexBuilder = algBuilder.getRexBuilder();
AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory();

Expand All @@ -192,7 +192,7 @@ static List<AlgNode> attachPreparedGraphNodeModifyInsert( Modifiable modifiable,
return inputs;
}

static List<AlgNode> attachPreparedGraphEdgeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, CatalogEntity edgesTable, CatalogEntity edgePropertiesTable, AlgBuilder algBuilder ) {
static List<AlgNode> attachPreparedGraphEdgeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable, AlgBuilder algBuilder ) {
RexBuilder rexBuilder = algBuilder.getRexBuilder();
AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory();

Expand All @@ -218,7 +218,7 @@ static List<AlgNode> attachPreparedGraphEdgeModifyDelete( Modifiable modifiable,
return inputs;
}

static List<AlgNode> attachPreparedGraphEdgeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, CatalogEntity edgesTable, CatalogEntity edgePropertiesTable, AlgBuilder algBuilder ) {
static List<AlgNode> attachPreparedGraphEdgeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable, AlgBuilder algBuilder ) {
RexBuilder rexBuilder = algBuilder.getRexBuilder();
AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory();

Expand Down Expand Up @@ -248,7 +248,7 @@ static List<AlgNode> attachPreparedGraphEdgeModifyInsert( Modifiable modifiable,

}

static Modify<?> getModify( CatalogEntity table, AlgNode input, Operation operation, List<String> updateList, List<RexNode> sourceList ) {
static Modify<?> getModify( LogicalEntity table, AlgNode input, Operation operation, List<String> updateList, List<RexNode> sourceList ) {
return table.unwrap( ModifiableTable.class ).toModificationTable( input.getCluster(), input.getTraitSet(), table, input, operation, updateList, sourceList );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
import org.polypheny.db.algebra.AlgReferentialConstraint;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.algebra.type.AlgDataTypeFactory;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.catalog.entity.logical.LogicalTable;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.catalog.logistic.EntityType;
import org.polypheny.db.schema.Function;
import org.polypheny.db.schema.Namespace;
Expand All @@ -76,7 +77,7 @@ public class ReflectiveSchema extends AbstractNamespace implements Schema {

private final Class clazz;
private Object target;
private Map<String, CatalogEntity> tableMap;
private Map<String, LogicalEntity> tableMap;
private Multimap<String, Function> functionMap;


Expand Down Expand Up @@ -110,33 +111,33 @@ public Object getTarget() {


@Override
public Map<String, CatalogEntity> getTables() {
public Map<String, LogicalEntity> getTables() {
if ( tableMap == null ) {
tableMap = createTableMap();
}
return tableMap;
}


private Map<String, CatalogEntity> createTableMap() {
final ImmutableMap.Builder<String, CatalogEntity> builder = ImmutableMap.builder();
private Map<String, LogicalEntity> createTableMap() {
final ImmutableMap.Builder<String, LogicalEntity> builder = ImmutableMap.builder();
for ( Field field : clazz.getFields() ) {
final String fieldName = field.getName();
final CatalogEntity entity = fieldRelation( field );
final LogicalEntity entity = fieldRelation( field );
if ( entity == null ) {
continue;
}
builder.put( fieldName, entity );
}
Map<String, CatalogEntity> tableMap = builder.build();
Map<String, LogicalEntity> tableMap = builder.build();
// Unique-Key - Foreign-Key
for ( Field field : clazz.getFields() ) {
if ( AlgReferentialConstraint.class.isAssignableFrom( field.getType() ) ) {
AlgReferentialConstraint rc;
try {
rc = (AlgReferentialConstraint) field.get( target );
} catch ( IllegalAccessException e ) {
throw new RuntimeException( "Error while accessing field " + field, e );
throw new GenericRuntimeException( "Error while accessing field " + field, e );
}
// CatalogEntity table = (FieldEntity) tableMap.get( Util.last( rc.getSourceQualifiedName() ) );
// assert table != null;
Expand Down Expand Up @@ -176,7 +177,7 @@ private Multimap<String, Function> createFunctionMap() {
/**
* Returns a table based on a particular field of this schema. If the field is not of the right type to be a relation, returns null.
*/
private <T> CatalogEntity fieldRelation( final Field field ) {
private <T> LogicalEntity fieldRelation( final Field field ) {
final Type elementType = getElementType( field.getType() );
if ( elementType == null ) {
return null;
Expand All @@ -185,7 +186,7 @@ private <T> CatalogEntity fieldRelation( final Field field ) {
try {
o = field.get( target );
} catch ( IllegalAccessException e ) {
throw new RuntimeException( "Error while accessing field " + field, e );
throw new GenericRuntimeException( "Error while accessing field " + field, e );
}
final Enumerable<T> enumerable = (Enumerable<T>) toEnumerable( o );
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.polypheny.db.algebra.metadata.Metadata;
import org.polypheny.db.algebra.metadata.MetadataFactory;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgOptCost;
import org.polypheny.db.plan.AlgOptPlanner;
Expand Down Expand Up @@ -389,7 +389,7 @@ public final String getDescription() {


@Override
public CatalogEntity getEntity() {
public LogicalEntity getEntity() {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/polypheny/db/algebra/AlgInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

import java.util.List;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgTraitSet;
import org.polypheny.db.util.ImmutableBitSet;
Expand All @@ -51,7 +51,7 @@ public interface AlgInput {

AlgTraitSet getTraitSet();

CatalogEntity getEntity( String entity );
LogicalEntity getEntity( String entity );

/**
* Returns the input relational expression. Throws if there is not precisely one input.
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/polypheny/db/algebra/AlgNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.polypheny.db.algebra.metadata.AlgMetadataQuery;
import org.polypheny.db.algebra.metadata.Metadata;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.catalog.logistic.NamespaceType;
import org.polypheny.db.plan.AlgImplementor;
import org.polypheny.db.plan.AlgOptCluster;
Expand Down Expand Up @@ -262,7 +262,7 @@ public interface AlgNode extends AlgOptNode, Cloneable {
*
* @return If this relational expression represents an access to a table, returns that table, otherwise returns null
*/
CatalogEntity getEntity();
LogicalEntity getEntity();

/**
* Returns the name of this relational expression's class, sans package name, for use in explain. For example, for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import org.polypheny.db.algebra.logical.relational.LogicalUnion;
import org.polypheny.db.algebra.logical.relational.LogicalValues;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.catalog.logistic.EntityType;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgOptEntity.ToAlgContext;
Expand Down Expand Up @@ -538,7 +538,7 @@ public interface ScanFactory {
/**
* Creates a {@link RelScan}.
*/
AlgNode createScan( AlgOptCluster cluster, CatalogEntity entity );
AlgNode createScan( AlgOptCluster cluster, LogicalEntity entity );

}

Expand All @@ -549,7 +549,7 @@ public interface ScanFactory {
private static class ScanFactoryImpl implements ScanFactory {

@Override
public AlgNode createScan( AlgOptCluster cluster, CatalogEntity entity ) {
public AlgNode createScan( AlgOptCluster cluster, LogicalEntity entity ) {
// Check if RelOptTable contains a View, in this case a LogicalViewScan needs to be created
if ( entity.entityType == EntityType.VIEW ) {
return LogicalRelViewScan.create( cluster, entity );
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import lombok.experimental.SuperBuilder;
import org.polypheny.db.algebra.AlgNode;
import org.polypheny.db.algebra.SingleAlg;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.LogicalEntity;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgTraitSet;

@SuperBuilder(toBuilder = true)
public abstract class Modify<E extends CatalogEntity> extends SingleAlg {
public abstract class Modify<E extends LogicalEntity> extends SingleAlg {

@Getter
public final E entity;
Expand Down
Loading

0 comments on commit 36dba7e

Please sign in to comment.