From 754daa5d453666d776505c2247ebddaeddd96efc Mon Sep 17 00:00:00 2001 From: Tobias Hafner Date: Wed, 25 Dec 2024 00:19:26 +0100 Subject: [PATCH] Fix graph inserts --- .../enumerable/lpg/EnumerableLpgValues.java | 3 ++- .../org/polypheny/db/functions/Functions.java | 25 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/lpg/EnumerableLpgValues.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/lpg/EnumerableLpgValues.java index 154eb6ab36..31739bf515 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/lpg/EnumerableLpgValues.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/lpg/EnumerableLpgValues.java @@ -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; @@ -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 expressions = Stream.concat( nodes.stream().map( n -> Expressions.newArrayInit( PolyNode.class, n.asExpression() ) ), diff --git a/core/src/main/java/org/polypheny/db/functions/Functions.java b/core/src/main/java/org/polypheny/db/functions/Functions.java index 6e9d1a37c9..6eb6bbcd94 100644 --- a/core/src/main/java/org/polypheny/db/functions/Functions.java +++ b/core/src/main/java/org/polypheny/db/functions/Functions.java @@ -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; @@ -294,8 +295,8 @@ public static Enumerable batch( final DataContext context, final Enumerable

addRelIdentifiers(final Enumerable 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; } ); @@ -303,19 +304,25 @@ public static Enumerable addRelIdentifiers(final Enumerable addDocIdentifiers(final Enumerable 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 addLpgIdentifiers(final Enumerable 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; } ); }