Skip to content

Commit

Permalink
enabled bugged neo4j
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Sep 25, 2023
1 parent 8d6b873 commit 4f32a3e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@
import org.polypheny.db.adapter.neo4j.rules.relational.NeoScan;
import org.polypheny.db.adapter.neo4j.util.NeoUtil;
import org.polypheny.db.algebra.AlgNode;
import org.polypheny.db.algebra.core.relational.RelModify;
import org.polypheny.db.algebra.core.common.Modify.Operation;
import org.polypheny.db.algebra.core.common.Modify;
import org.polypheny.db.algebra.core.common.Modify.Operation;
import org.polypheny.db.algebra.core.relational.RelModify;
import org.polypheny.db.algebra.logical.relational.LogicalRelModify;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.physical.PhysicalTable;
import org.polypheny.db.catalog.refactor.ModifiableEntity;
import org.polypheny.db.catalog.refactor.TranslatableEntity;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgOptEntity.ToAlgContext;
import org.polypheny.db.plan.AlgTraitSet;
Expand All @@ -51,13 +49,15 @@
import org.polypheny.db.schema.QueryableEntity;
import org.polypheny.db.schema.SchemaPlus;
import org.polypheny.db.schema.impl.AbstractTableQueryable;
import org.polypheny.db.schema.types.ModifiableTable;
import org.polypheny.db.schema.types.TranslatableEntity;
import org.polypheny.db.type.PolyType;
import org.polypheny.db.util.Pair;

/**
* Relational Neo4j representation of a {@link org.polypheny.db.schema.PolyphenyDbSchema} entity
*/
public class NeoEntity extends PhysicalTable implements TranslatableEntity, ModifiableEntity {
public class NeoEntity extends PhysicalTable implements TranslatableEntity, ModifiableTable {


private final AlgDataType rowType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,35 @@
import org.polypheny.db.adapter.neo4j.rules.graph.NeoLpgScan;
import org.polypheny.db.adapter.neo4j.util.NeoUtil;
import org.polypheny.db.algebra.AlgNode;
import org.polypheny.db.algebra.core.relational.RelModify;
import org.polypheny.db.algebra.core.common.Modify;
import org.polypheny.db.algebra.core.common.Modify.Operation;
import org.polypheny.db.algebra.core.lpg.LpgModify;
import org.polypheny.db.algebra.core.relational.RelModify;
import org.polypheny.db.algebra.logical.lpg.LogicalLpgModify;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.entity.CatalogEntity;
import org.polypheny.db.catalog.entity.physical.PhysicalGraph;
import org.polypheny.db.catalog.refactor.ModifiableEntity;
import org.polypheny.db.catalog.refactor.TranslatableEntity;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgOptEntity.ToAlgContext;
import org.polypheny.db.plan.AlgTraitSet;
import org.polypheny.db.plan.Convention;
import org.polypheny.db.rex.RexNode;
import org.polypheny.db.runtime.PolyCollections.PolyMap;
import org.polypheny.db.schema.ModelTrait;
import org.polypheny.db.schema.graph.PolyEdge;
import org.polypheny.db.schema.graph.PolyGraph;
import org.polypheny.db.schema.graph.PolyNode;
import org.polypheny.db.schema.graph.QueryableGraph;
import org.polypheny.db.schema.trait.ModelTrait;
import org.polypheny.db.schema.types.ModifiableGraph;
import org.polypheny.db.schema.types.TranslatableEntity;
import org.polypheny.db.type.PolyType;
import org.polypheny.db.type.entity.PolyString;
import org.polypheny.db.type.entity.graph.PolyEdge;
import org.polypheny.db.type.entity.graph.PolyNode;
import org.polypheny.db.util.Pair;


/**
* Graph entity in the Neo4j representation.
*/
public class NeoGraph extends PhysicalGraph implements TranslatableEntity, ModifiableEntity {
public class NeoGraph extends PhysicalGraph implements TranslatableEntity, ModifiableGraph {

public final TransactionProvider transactionProvider;
public final Driver db;
Expand All @@ -94,15 +95,14 @@ public NeoGraph( PhysicalGraph graph, TransactionProvider transactionProvider, D
* @param operation the modify operation
*/
@Override
public LpgModify<CatalogEntity> toModificationAlg(
public Modify<?> toModificationAlg(
AlgOptCluster cluster,
AlgTraitSet traits,
CatalogEntity physicalEntity,
AlgNode child,
Operation operation,
List<String> targets,
List<PolyString> targets,
List<? extends RexNode> sources ) {
NeoConvention.INSTANCE.register( cluster.getPlanner() );
return new LogicalLpgModify(
cluster,
traits.replace( Convention.NONE ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.polypheny.db.adapter.neo4j.util;

import static org.polypheny.db.adapter.neo4j.util.NeoStatements.edge_;
import static org.polypheny.db.adapter.neo4j.util.NeoStatements.node_;

import java.math.BigDecimal;
import java.sql.Date;
Expand Down Expand Up @@ -49,14 +48,15 @@
import org.polypheny.db.rex.RexLiteral;
import org.polypheny.db.rex.RexNode;
import org.polypheny.db.rex.RexVisitorImpl;
import org.polypheny.db.runtime.PolyCollections.PolyDictionary;
import org.polypheny.db.runtime.PolyCollections.PolyList;
import org.polypheny.db.schema.ModelTrait;
import org.polypheny.db.schema.graph.PolyEdge;
import org.polypheny.db.schema.graph.PolyEdge.EdgeDirection;
import org.polypheny.db.schema.graph.PolyNode;
import org.polypheny.db.schema.graph.PolyPath;
import org.polypheny.db.type.PolyType;
import org.polypheny.db.type.entity.PolyList;
import org.polypheny.db.type.entity.PolyString;
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.type.entity.graph.PolyDictionary;
import org.polypheny.db.type.entity.graph.PolyEdge;
import org.polypheny.db.type.entity.graph.PolyEdge.EdgeDirection;
import org.polypheny.db.type.entity.graph.PolyNode;
import org.polypheny.db.type.entity.graph.PolyPath;
import org.polypheny.db.util.DateString;
import org.polypheny.db.util.Pair;
import org.polypheny.db.util.TimeString;
Expand Down Expand Up @@ -171,12 +171,12 @@ static PolyPath asPolyPath( Path path ) {
}

return PolyPath.create(
nodes.stream().map( n -> Pair.of( (String) null, n ) ).collect( Collectors.toList() ),
edges.stream().map( e -> Pair.of( (String) null, e ) ).collect( Collectors.toList() ) );
nodes.stream().map( n -> Pair.of( (PolyString) null, n ) ).collect( Collectors.toList() ),
edges.stream().map( e -> Pair.of( (PolyString) null, e ) ).collect( Collectors.toList() ) );
}

static PolyNode asPolyNode( Node node ) {
Map<String, Comparable<?>> map = new HashMap<>( node.asMap( NeoUtil::getComparableOrString ) );
Map<String, PolyValue> map = new HashMap<>( node.asMap( NeoUtil::getComparableOrString ) );
String id = map.remove( "_id" ).toString();
List<String> labels = new ArrayList<>();
node.labels().forEach( e -> {
Expand All @@ -189,27 +189,27 @@ static PolyNode asPolyNode( Node node ) {


static PolyEdge asPolyEdge( Relationship relationship ) {
Map<String, Comparable<?>> map = new HashMap<>( relationship.asMap( NeoUtil::getComparableOrString ) );
Map<String, PolyValue> map = new HashMap<>( relationship.asMap( NeoUtil::getComparableOrString ) );
String id = map.remove( "_id" ).toString();
String sourceId = map.remove( "__sourceId__" ).toString();
String targetId = map.remove( "__targetId__" ).toString();
return new PolyEdge( id, new PolyDictionary( map ), List.of( relationship.type() ), sourceId, targetId, EdgeDirection.LEFT_TO_RIGHT, null );
}

static Comparable<?> getComparableOrString( Value e ) {
static PolyValue getComparableOrString( Value e ) {
if ( e.isNull() ) {
return null;
}
Object obj = e.asObject();
if ( obj instanceof List<?> ) {
return new PolyList<>( (List<Comparable<?>>) obj );
return new PolyList<>( (List<PolyValue>) obj );
}

if ( obj instanceof Comparable<?> ) {
return (Comparable<?>) obj;
if ( obj instanceof PolyValue ) {
return (PolyValue) obj;
}

return e.toString();
return e;
}

static Function1<Record, Object> getTypesFunction( List<PolyType> types, List<PolyType> componentTypes ) {
Expand Down Expand Up @@ -264,16 +264,16 @@ static String rexAsString( RexLiteral literal, String mappingLabel, boolean isLi
if ( ob == null ) {
return null;
}
switch ( literal.getTypeName() ) {
switch ( literal.getPolyType() ) {
case BOOLEAN:
return literal.getValueAs( Boolean.class ).toString();
return literal.value.asBoolean().toString();
case TINYINT:
case SMALLINT:
case INTEGER:
case DATE:
case TIME:
case TIME_WITH_LOCAL_TIME_ZONE:
return literal.getValueAs( Integer.class ).toString();
return literal.value.asNumber().toString();
case BIGINT:
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
Expand Down Expand Up @@ -301,11 +301,11 @@ static String rexAsString( RexLiteral literal, String mappingLabel, boolean isLi
if ( isLiteral ) {
return "'" + literal.getValueAs( String.class ) + "'";
}
return literal.getValueAs( String.class );
return literal.value.asString().value;
case MAP:
case DOCUMENT:
case ARRAY:
return literal.getValueAs( String.class );
return literal.value.asList().toString());
case BINARY:
case VARBINARY:
case FILE:
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ include 'plugins:http-interface'

// adapters plugins
include 'plugins:hsqldb-adapter'
//include 'plugins:neo4j-adapter'
include 'plugins:neo4j-adapter'
//include 'plugins:cottontail-adapter'
//include 'plugins:ethereum-adapter'
//include 'plugins:cassandra-adapter'
Expand Down

0 comments on commit 4f32a3e

Please sign in to comment.