From 8d37e3438d8caec5ec2342cb9d59a6ce4c7c0a08 Mon Sep 17 00:00:00 2001 From: Tobias Hafner Date: Wed, 4 Dec 2024 15:04:28 +0100 Subject: [PATCH] Implement interval based identifier tracking --- .../locking/EntityIdentifierGenerator.java | 129 ------------------ .../locking/IdentifierInterval.java | 55 ++++++++ .../locking/IdentifierRegistry.java | 83 +++++++++++ ...ntifierUtils.java => IdentifierUtils.java} | 2 +- .../locking/IdentifierIntervalTest.java | 96 +++++++++++++ .../locking/IdentifierRegistryTest.java | 121 ++++++++++++++++ .../db/cypher/clause/CypherCreate.java | 8 +- .../polypheny/db/languages/mql/MqlInsert.java | 9 +- .../org/polypheny/db/sql/SqlProcessor.java | 10 +- .../db/sql/language/ddl/SqlCreateTable.java | 13 +- 10 files changed, 370 insertions(+), 156 deletions(-) delete mode 100644 core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierGenerator.java create mode 100644 core/src/main/java/org/polypheny/db/transaction/locking/IdentifierInterval.java create mode 100644 core/src/main/java/org/polypheny/db/transaction/locking/IdentifierRegistry.java rename core/src/main/java/org/polypheny/db/transaction/locking/{EntityIdentifierUtils.java => IdentifierUtils.java} (97%) create mode 100644 core/src/test/java/org/polypheny/db/transaction/locking/IdentifierIntervalTest.java create mode 100644 core/src/test/java/org/polypheny/db/transaction/locking/IdentifierRegistryTest.java diff --git a/core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierGenerator.java b/core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierGenerator.java deleted file mode 100644 index 6a7bc705b1..0000000000 --- a/core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierGenerator.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.polypheny.db.transaction.locking; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicLong; -import org.apache.commons.lang3.NotImplementedException; - -public class EntityIdentifierGenerator { - - private static final int QUEUE_SIZE = 10000; - private static final int MAX_IDENTIFIER = 100000; - - public static final EntityIdentifierGenerator INSTANCE = new EntityIdentifierGenerator(); - private static final String GENERATOR_LOG = "entry_identifier_counter.dat"; - - private final AtomicLong identifierCounter; - private final BlockingQueue identifierQueue = new LinkedBlockingQueue<>( QUEUE_SIZE ); - private boolean scanForIds = false; - - - private EntityIdentifierGenerator() { - long initialCounterValue = loadState(); - this.identifierCounter = new AtomicLong( initialCounterValue ); - fillQueue(); - } - - - public long getEntryIdentifier() { - try { - long entryIdentifier = identifierQueue.take(); - if ( identifierQueue.isEmpty() ) { - fillQueue(); - } - return entryIdentifier; - } catch ( InterruptedException e ) { - Thread.currentThread().interrupt(); - throw new RuntimeException( "Interrupted while fetching an entry identifier", e ); - } - } - - - private void fillQueue() { - if ( scanForIds ) { - fillQueueFromScan(); - return; - } - fillQueueFromCounter(); - } - - - private void fillQueueFromCounter() { - try { - while ( identifierQueue.remainingCapacity() > 0 && identifierCounter.get() < MAX_IDENTIFIER ) { - identifierQueue.put( identifierCounter.incrementAndGet() ); - } - if ( identifierCounter.get() >= MAX_IDENTIFIER ) { - scanForIds = true; - } - if ( identifierQueue.remainingCapacity() > 0 ) { - fillQueueFromScan(); - } - } catch ( InterruptedException e ) { - Thread.currentThread().interrupt(); - throw new RuntimeException( "Error filling the queue", e ); - } - } - - - private void fillQueueFromScan() { - try { - List unassignedIdentifiers = findUnassignedIdentifiers( QUEUE_SIZE ); - if ( unassignedIdentifiers.isEmpty() ) { - throw new RuntimeException( "No more unassigned identifiers available" ); - } - for ( Long identifier : unassignedIdentifiers ) { - if (identifierQueue.remainingCapacity() == 0 ) { - break; - } - identifierQueue.put( identifier ); - } - } catch ( InterruptedException e ) { - Thread.currentThread().interrupt(); - throw new RuntimeException( "Error filling the queue in Mode B", e ); - } - } - - - private List findUnassignedIdentifiers( int count ) { - // ToDo TH: Run a scan on the database to find unassigned identifiers - throw new NotImplementedException( "Unassigned Entry Id Scanning not implemented yet" ); - } - - - public void shutdown() { - try ( DataOutputStream dataOutputStream = new DataOutputStream( new FileOutputStream( GENERATOR_LOG ) ) ) { - dataOutputStream.writeLong( identifierCounter.get() ); - dataOutputStream.writeBoolean( scanForIds ); - } catch ( IOException e ) { - System.err.println( "Error saving state: " + e.getMessage() ); - } - } - - - private long loadState() { - File file = new File( GENERATOR_LOG ); - if ( !file.exists() ) { - this.scanForIds = false; - return 0; - } - - try ( DataInputStream DataInputStream = new DataInputStream( new FileInputStream( file ) ) ) { - long counterValue = DataInputStream.readLong(); - this.scanForIds = DataInputStream.readBoolean(); - return counterValue; - } catch ( IOException e ) { - System.err.println( "Error loading state, starting from 0: " + e.getMessage() ); - scanForIds = false; - return 0; - } - } - -} diff --git a/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierInterval.java b/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierInterval.java new file mode 100644 index 0000000000..c5fbfe866f --- /dev/null +++ b/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierInterval.java @@ -0,0 +1,55 @@ +/* + * Copyright 2019-2024 The Polypheny Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.polypheny.db.transaction.locking; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class IdentifierInterval implements Comparable { + private long lowerBound; + private long upperBound; + + IdentifierInterval(long lowerBound, long upperBound) { + if (upperBound < lowerBound) { + throw new IllegalArgumentException("Upper bound must be greater or equal than lower bound"); + } + this.lowerBound = lowerBound; + this.upperBound = upperBound; + } + + @Override + public int compareTo( IdentifierInterval other ) { + return Long.compare( this.lowerBound, other.lowerBound ); + } + + @Override + public String toString() { + return "IdentifierInterval{" + lowerBound + ", " + upperBound + "}"; + } + + public long getNextIdentifier() { + long identifier = lowerBound; + lowerBound++; + return identifier; + } + + public boolean hasNextIdentifier() { + return lowerBound < upperBound; + } +} diff --git a/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierRegistry.java b/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierRegistry.java new file mode 100644 index 0000000000..1a1363cc6d --- /dev/null +++ b/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierRegistry.java @@ -0,0 +1,83 @@ +package org.polypheny.db.transaction.locking; + +import java.util.Set; +import java.util.TreeSet; + +public class IdentifierRegistry { + + private static final Long MAX_IDENTIFIER_VALUE = Long.MAX_VALUE; + public static final IdentifierRegistry INSTANCE = new IdentifierRegistry(MAX_IDENTIFIER_VALUE); + + private final TreeSet availableIdentifiers; + + IdentifierRegistry( long maxIdentifierValue ) { + this.availableIdentifiers = new TreeSet<>(); + this.availableIdentifiers.add( new IdentifierInterval( 0, maxIdentifierValue ) ); + } + + + public long getEntryIdentifier() { + while ( !availableIdentifiers.first().hasNextIdentifier() ) { + availableIdentifiers.pollFirst(); + if ( availableIdentifiers.isEmpty() ) { + throw new IllegalStateException( "No identifiers available" ); + } + } + return availableIdentifiers.first().getNextIdentifier(); + } + + + public void releaseEntryIdentifiers( Set identifiers ) { + if ( identifiers.isEmpty() ) { + return; + } + + for ( long currentIdentifier : identifiers ) { + IdentifierInterval newInterval = new IdentifierInterval( currentIdentifier, currentIdentifier + 1 ); + + IdentifierInterval lowerAdjacentInterval = availableIdentifiers.floor( newInterval ); + IdentifierInterval upperAdjacentInterval = availableIdentifiers.ceiling( newInterval ); + + boolean isMergedWithLower = mergeWithLowerInterval( lowerAdjacentInterval, currentIdentifier ); + boolean isMergedWithUpper = mergeWithUpperInterval( lowerAdjacentInterval, upperAdjacentInterval, currentIdentifier, isMergedWithLower ); + + if ( isMergedWithLower || isMergedWithUpper ) { + continue; + } + availableIdentifiers.add( newInterval ); + } + } + + + private boolean mergeWithLowerInterval( IdentifierInterval lowerInterval, long currentIdentifier ) { + if ( lowerInterval == null ) { + return false; + } + if ( lowerInterval.getUpperBound() != currentIdentifier ) { + return false; + } + lowerInterval.setUpperBound( currentIdentifier + 1 ); + return true; + } + + + private boolean mergeWithUpperInterval( IdentifierInterval lowerInterval, IdentifierInterval upperInterval, long currentIdentifier, boolean isMergedWithLower ) { + if ( upperInterval == null ) { + return false; + } + if ( upperInterval.getLowerBound() != currentIdentifier + 1 ) { + return false; + } + if ( !isMergedWithLower ) { + upperInterval.setLowerBound( currentIdentifier ); + return true; + } + if ( lowerInterval == null ) { + return true; + } + lowerInterval.setUpperBound( upperInterval.getUpperBound() ); + availableIdentifiers.remove( upperInterval ); + return true; + } + +} diff --git a/core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierUtils.java b/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierUtils.java similarity index 97% rename from core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierUtils.java rename to core/src/main/java/org/polypheny/db/transaction/locking/IdentifierUtils.java index 16f3c2380f..c2ed2d58a9 100644 --- a/core/src/main/java/org/polypheny/db/transaction/locking/EntityIdentifierUtils.java +++ b/core/src/main/java/org/polypheny/db/transaction/locking/IdentifierUtils.java @@ -21,7 +21,7 @@ import org.polypheny.db.ddl.DdlManager.FieldInformation; import org.polypheny.db.type.PolyType; -public class EntityIdentifierUtils { +public class IdentifierUtils { public static final String IDENTIFIER_KEY = "_eid"; diff --git a/core/src/test/java/org/polypheny/db/transaction/locking/IdentifierIntervalTest.java b/core/src/test/java/org/polypheny/db/transaction/locking/IdentifierIntervalTest.java new file mode 100644 index 0000000000..7f3db3fa67 --- /dev/null +++ b/core/src/test/java/org/polypheny/db/transaction/locking/IdentifierIntervalTest.java @@ -0,0 +1,96 @@ +/* + * Copyright 2019-2024 The Polypheny Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.polypheny.db.transaction.locking; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +public class IdentifierIntervalTest { + + @Test + void testCreatingIntervalLowerBound() { + IdentifierInterval interval = new IdentifierInterval(10, 20); + assertEquals(10, interval.getLowerBound()); + } + + @Test + void testCreatingIntervalUpperBound() { + IdentifierInterval interval = new IdentifierInterval(10, 20); + assertEquals(20, interval.getUpperBound()); + } + + @Test + void testCreatingIntervalInvalidBounds() { + Exception exception = assertThrows(IllegalArgumentException.class, () -> { + new IdentifierInterval(20, 10); + }); + assertTrue(exception.getMessage().contains("Upper bound must be greater or equal than lower bound")); + } + + @Test + void testHasNextIdentifier() { + IdentifierInterval interval = new IdentifierInterval(10, 20); + assertTrue(interval.hasNextIdentifier()); + } + + @Test + void testRetrievingIdentifiersUntilEmpty() { + IdentifierInterval interval = new IdentifierInterval(10, 12); + assertEquals(10, interval.getNextIdentifier()); + assertEquals(11, interval.getNextIdentifier()); + assertFalse(interval.hasNextIdentifier()); + } + + @Test + void testIntervalComparisonLess() { + IdentifierInterval interval1 = new IdentifierInterval(5, 10); + IdentifierInterval interval2 = new IdentifierInterval(10, 15); + assertTrue(interval1.compareTo(interval2) < 0, "Interval1 should be less than Interval2"); + } + + @Test + void testIntervalComparisonGreater() { + IdentifierInterval interval1 = new IdentifierInterval(5, 10); + IdentifierInterval interval2 = new IdentifierInterval(1, 5); + assertTrue(interval1.compareTo(interval2) > 0, "Interval1 should be greater than Interval2"); + } + + @Test + void testIntervalComparisonEquals() { + IdentifierInterval interval1 = new IdentifierInterval(5, 10); + IdentifierInterval interval2 = new IdentifierInterval(5, 10); + assertEquals(0, interval1.compareTo(interval2)); + } + + @Test + void testIntervalComparisonIncludes() { + IdentifierInterval interval1 = new IdentifierInterval(5, 10); + IdentifierInterval interval2 = new IdentifierInterval(1, 20); + assertTrue( interval1.compareTo( interval2 ) > 0, "Interval1 should be greater than Interval2"); + } + + @Test + void testIntervalToString() { + IdentifierInterval interval1 = new IdentifierInterval(5, 10); + assertEquals("IdentifierInterval{5, 10}", interval1.toString()); + } + +} diff --git a/core/src/test/java/org/polypheny/db/transaction/locking/IdentifierRegistryTest.java b/core/src/test/java/org/polypheny/db/transaction/locking/IdentifierRegistryTest.java new file mode 100644 index 0000000000..2a1ee63354 --- /dev/null +++ b/core/src/test/java/org/polypheny/db/transaction/locking/IdentifierRegistryTest.java @@ -0,0 +1,121 @@ +/* + * Copyright 2019-2024 The Polypheny Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.polypheny.db.transaction.locking; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.HashSet; +import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class IdentifierRegistryTest { + + private IdentifierRegistry registry; + + + @BeforeEach + void setUp() { + registry = new IdentifierRegistry( 100 ); + } + + + @Test + void testGetEntryIdentifierSequential() { + long firstId = registry.getEntryIdentifier(); + long secondId = registry.getEntryIdentifier(); + + assertEquals( 0, firstId ); + assertEquals( 1, secondId ); + } + + + @Test + void testGetEntryIdentifierUntilOverflow() { + for ( int i = 0; i < 100; i++ ) { + registry.getEntryIdentifier(); + } + Exception exception = assertThrows( IllegalStateException.class, registry::getEntryIdentifier ); + assertEquals( "No identifiers available", exception.getMessage() ); + } + + + @Test + void testReleaseSingleIdentifierBeginning() { + long firstIdentifier = registry.getEntryIdentifier(); + registry.getEntryIdentifier(); + + registry.releaseEntryIdentifiers( Set.of( firstIdentifier ) ); + assertEquals( 0, registry.getEntryIdentifier() ); + } + + + @Test + void testReleaseSingleIdentifierMiddle() { + for ( int i = 0; i < 25; i++ ) { + registry.getEntryIdentifier(); + } + long middleIdentifier = registry.getEntryIdentifier(); + for ( int i = 0; i < 25; i++ ) { + registry.getEntryIdentifier(); + } + registry.releaseEntryIdentifiers( Set.of( middleIdentifier ) ); + assertEquals( 25, registry.getEntryIdentifier() ); + } + + + @Test + void testReleaseMultipleIdentifiersConsequtive() { + Set identifiers = new HashSet<>(); + for ( int i = 0; i < 20; i++ ) { + registry.getEntryIdentifier(); + } + for ( int i = 0; i < 20; i++ ) { + identifiers.add( registry.getEntryIdentifier() ); + } + for ( int i = 0; i < 20; i++ ) { + registry.getEntryIdentifier(); + } + registry.releaseEntryIdentifiers( identifiers ); + for ( int i = 20; i < 40; i++ ) { + assertEquals( i, registry.getEntryIdentifier() ); + } + } + + + @Test + void testReleaseMultipleIdentifiersInterleaved() { + Set evenIdentifiers = new HashSet<>(); + Set oddIdentifiers = new HashSet<>(); + + for ( int i = 0; i < 60; i++ ) { + if ( i % 2 == 0 ) { + evenIdentifiers.add( registry.getEntryIdentifier() ); + continue; + } + oddIdentifiers.add( registry.getEntryIdentifier() ); + } + + registry.releaseEntryIdentifiers( evenIdentifiers ); + + for ( int i = 0; i < 30; i++ ) { + assertEquals( 0, registry.getEntryIdentifier() % 2 ); + } + } + +} diff --git a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/clause/CypherCreate.java b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/clause/CypherCreate.java index ecdcd5be12..a41d235004 100644 --- a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/clause/CypherCreate.java +++ b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/clause/CypherCreate.java @@ -26,8 +26,8 @@ import org.polypheny.db.cypher.pattern.CypherPattern; import org.polypheny.db.cypher.pattern.CypherRelPattern; import org.polypheny.db.languages.ParserPos; -import org.polypheny.db.transaction.locking.EntityIdentifierGenerator; -import org.polypheny.db.transaction.locking.EntityIdentifierUtils; +import org.polypheny.db.transaction.locking.IdentifierRegistry; +import org.polypheny.db.transaction.locking.IdentifierUtils; @Getter @@ -53,11 +53,11 @@ private void addEntryIdentifiers() { ).forEach( pattern -> { CypherLiteral properties = extractProperties( pattern ); properties.getMapValue().put( - EntityIdentifierUtils.IDENTIFIER_KEY, + IdentifierUtils.IDENTIFIER_KEY, new CypherLiteral( ParserPos.ZERO, Literal.DECIMAL, - String.valueOf( EntityIdentifierGenerator.INSTANCE.getEntryIdentifier() ), + String.valueOf( IdentifierRegistry.INSTANCE.getEntryIdentifier() ), false ) ); diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlInsert.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlInsert.java index d4c9dc5948..d9e2871348 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlInsert.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlInsert.java @@ -19,7 +19,6 @@ import java.util.Collections; import lombok.Getter; import org.bson.BsonArray; -import org.bson.BsonBinary; import org.bson.BsonDocument; import org.bson.BsonInt64; import org.bson.BsonValue; @@ -27,8 +26,8 @@ import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.languages.ParserPos; import org.polypheny.db.languages.mql.Mql.Type; -import org.polypheny.db.transaction.locking.EntityIdentifierGenerator; -import org.polypheny.db.transaction.locking.EntityIdentifierUtils; +import org.polypheny.db.transaction.locking.IdentifierRegistry; +import org.polypheny.db.transaction.locking.IdentifierUtils; @Getter @@ -56,8 +55,8 @@ private void insertEntryIdentifiers() { .stream() .map(BsonValue::asDocument) .forEach(doc -> doc.put( - EntityIdentifierUtils.IDENTIFIER_KEY, - new BsonInt64(EntityIdentifierGenerator.INSTANCE.getEntryIdentifier()) + IdentifierUtils.IDENTIFIER_KEY, + new BsonInt64( IdentifierRegistry.INSTANCE.getEntryIdentifier()) )); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/SqlProcessor.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/SqlProcessor.java index bb08541189..715bbb73df 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/SqlProcessor.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/SqlProcessor.java @@ -70,12 +70,10 @@ import org.polypheny.db.tools.AlgBuilder; import org.polypheny.db.transaction.Statement; import org.polypheny.db.transaction.Transaction; -import org.polypheny.db.transaction.locking.EntityIdentifierGenerator; -import org.polypheny.db.transaction.locking.EntityIdentifierUtils; +import org.polypheny.db.transaction.locking.IdentifierRegistry; +import org.polypheny.db.transaction.locking.IdentifierUtils; import org.polypheny.db.transaction.locking.Lockable.LockType; import org.polypheny.db.transaction.locking.LockablesRegistry; -import org.polypheny.db.type.entity.PolyBinary; -import org.polypheny.db.type.entity.numerical.PolyLong; import org.polypheny.db.util.Casing; import org.polypheny.db.util.Conformance; import org.polypheny.db.util.DeadlockException; @@ -299,7 +297,7 @@ private void processColumns(LogicalTable catalogTable, SqlNodeList oldColumnList SqlBasicCall call = (SqlBasicCall) sqlNode; int position = getPositionInSqlNodeList(oldColumnList, column.name); - if (column.name.equals( EntityIdentifierUtils.IDENTIFIER_KEY )) { + if (column.name.equals( IdentifierUtils.IDENTIFIER_KEY )) { newValues[i][pos] = createEntityIdentifierLiteral(); } else if (position >= 0) { newValues[i][pos] = call.getOperands()[position]; @@ -349,7 +347,7 @@ private SqlNode createDefaultValueLiteral(LogicalColumn column, LogicalDefaultVa private SqlNode createEntityIdentifierLiteral() { return SqlLiteral.createExactNumeric( - String.valueOf(EntityIdentifierGenerator.INSTANCE.getEntryIdentifier()), // ToDo TH: is there no better way to do this? + String.valueOf( IdentifierRegistry.INSTANCE.getEntryIdentifier()), // ToDo TH: is there no better way to do this? ParserPos.ZERO ); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateTable.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateTable.java index 79bd743741..6b2fb27dc0 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateTable.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateTable.java @@ -19,11 +19,9 @@ import com.google.common.collect.ImmutableList; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import lombok.EqualsAndHashCode; import lombok.Value; import lombok.extern.slf4j.Slf4j; @@ -33,10 +31,7 @@ import org.polypheny.db.adapter.DataStore; import org.polypheny.db.algebra.constant.Kind; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.logical.LogicalColumn; -import org.polypheny.db.catalog.entity.logical.LogicalNamespace; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; -import org.polypheny.db.catalog.logistic.Collation; import org.polypheny.db.catalog.logistic.PlacementType; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.ddl.DdlManager; @@ -50,7 +45,6 @@ import org.polypheny.db.nodes.Node; import org.polypheny.db.partition.raw.RawPartitionInformation; import org.polypheny.db.prepare.Context; -import org.polypheny.db.prepare.Prepare; import org.polypheny.db.processing.QueryContext.ParsedQueryContext; import org.polypheny.db.sql.language.SqlCreate; import org.polypheny.db.sql.language.SqlIdentifier; @@ -61,12 +55,9 @@ import org.polypheny.db.sql.language.SqlSpecialOperator; import org.polypheny.db.sql.language.SqlWriter; import org.polypheny.db.transaction.Statement; -import org.polypheny.db.transaction.locking.EntityIdentifierUtils; +import org.polypheny.db.transaction.locking.IdentifierUtils; import org.polypheny.db.transaction.locking.Lockable; import org.polypheny.db.transaction.locking.Lockable.LockType; -import org.polypheny.db.transaction.locking.LockableUtils; -import org.polypheny.db.type.PolyType; -import org.polypheny.db.type.entity.PolyBinary; import org.polypheny.db.type.entity.PolyValue; import org.polypheny.db.util.Pair; @@ -282,7 +273,7 @@ private Pair, List> separateColumn List fieldInformation = new ArrayList<>(); List constraintInformation = new ArrayList<>(); - fieldInformation.add( EntityIdentifierUtils.IDENTIFIER_FIELD_INFORMATION); + fieldInformation.add( IdentifierUtils.IDENTIFIER_FIELD_INFORMATION); int position = 2; // first column is entry identifier for ( Ord c : Ord.zip( columns.getSqlList() ) ) {