Skip to content

Commit

Permalink
Fix graph inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed Dec 24, 2024
1 parent 822cd56 commit 754daa5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.polypheny.db.algebra.enumerable.EnumerableAlg;
import org.polypheny.db.algebra.enumerable.EnumerableAlgImplementor;
import org.polypheny.db.algebra.enumerable.EnumerableConvention;
import org.polypheny.db.algebra.enumerable.JavaTupleFormat;
import org.polypheny.db.algebra.enumerable.PhysType;
import org.polypheny.db.algebra.enumerable.PhysTypeImpl;
import org.polypheny.db.algebra.type.AlgDataType;
Expand Down Expand Up @@ -59,7 +60,7 @@ public Result implement( EnumerableAlgImplementor implementor, Prefer pref ) {
final PhysType physType = PhysTypeImpl.of(
implementor.getTypeFactory(),
getTupleType(),
pref.preferCustom()
pref.prefer( JavaTupleFormat.SCALAR)
);
final List<Expression> expressions = Stream.concat(
nodes.stream().map( n -> Expressions.newArrayInit( PolyNode.class, n.asExpression() ) ),
Expand Down
25 changes: 16 additions & 9 deletions core/src/main/java/org/polypheny/db/functions/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
import org.polypheny.db.type.entity.category.PolyNumber;
import org.polypheny.db.type.entity.category.PolyTemporal;
import org.polypheny.db.type.entity.document.PolyDocument;
import org.polypheny.db.type.entity.graph.GraphPropertyHolder;
import org.polypheny.db.type.entity.graph.PolyDictionary;
import org.polypheny.db.type.entity.numerical.PolyBigDecimal;
import org.polypheny.db.type.entity.numerical.PolyDouble;
Expand Down Expand Up @@ -294,28 +295,34 @@ public static Enumerable<?> batch( final DataContext context, final Enumerable<P

@SuppressWarnings("unused")
public static Enumerable<PolyValue[]> addRelIdentifiers(final Enumerable<PolyValue[]> input, long logicalId) {
LogicalEntity entity = Catalog.getInstance().getSnapshot().getLogicalEntity( logicalId ).orElseThrow();
return input.select( row -> {
LogicalEntity entity = Catalog.getInstance().getSnapshot().getLogicalEntity( logicalId ).orElseThrow();
row[0] = entity.getEntryIdentifiers().getNextEntryIdentifier().getEntryIdentifierAsPolyLong();
return row;
} );
}

@SuppressWarnings("unused")
public static Enumerable<PolyValue[]> addDocIdentifiers(final Enumerable<PolyValue[]> input, long logicalId) {
return input.select( oldRow -> {
PolyDocument document = (PolyDocument) oldRow[0];
LogicalEntity entity = Catalog.getInstance().getSnapshot().getLogicalEntity( logicalId ).orElseThrow();
document.put( IdentifierUtils.getIdentifierKeyAsPolyString(), entity.getEntryIdentifiers().getNextEntryIdentifier().getEntryIdentifierAsPolyLong());
return new PolyValue[]{document};
LogicalEntity entity = Catalog.getInstance().getSnapshot().getLogicalEntity( logicalId ).orElseThrow();
return input.select( row -> {
for ( PolyValue value : row ) {
PolyLong entryIdentifier = entity.getEntryIdentifiers().getNextEntryIdentifier().getEntryIdentifierAsPolyLong();
((PolyDocument) value).put( IdentifierUtils.getIdentifierKeyAsPolyString(), entryIdentifier );
}
return row;
} );
}

@SuppressWarnings("unused")
public static Enumerable<PolyValue[]> addLpgIdentifiers(final Enumerable<PolyValue[]> input, long logicalId) {
return input.select( oldRow -> {

return oldRow;
LogicalEntity entity = Catalog.getInstance().getSnapshot().getLogicalEntity( logicalId ).orElseThrow();
return input.select( row -> {
for ( PolyValue value : row ) {
PolyLong entryIdentifier = entity.getEntryIdentifiers().getNextEntryIdentifier().getEntryIdentifierAsPolyLong();
((GraphPropertyHolder) value).getProperties().put( IdentifierUtils.getIdentifierKeyAsPolyString(), entryIdentifier );
}
return row;
} );
}

Expand Down

0 comments on commit 754daa5

Please sign in to comment.