Search in sources :

Example 11 with Token

use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.

the class BatchInserterImpl method createNewLabelId.

private int createNewLabelId(String stringKey) {
    int keyId = (int) labelTokenStore.nextId();
    LabelTokenRecord record = new LabelTokenRecord(keyId);
    record.setInUse(true);
    record.setCreated();
    Collection<DynamicRecord> keyRecords = labelTokenStore.allocateNameRecords(encodeString(stringKey));
    record.setNameId((int) Iterables.first(keyRecords).getId());
    record.addNameRecords(keyRecords);
    labelTokenStore.updateRecord(record);
    labelTokens.addToken(new Token(stringKey, keyId));
    return keyId;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) UniquenessConstraint(org.neo4j.kernel.api.constraints.UniquenessConstraint) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 12 with Token

use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.

the class BatchInserterImpl method createNewPropertyKeyId.

private int createNewPropertyKeyId(String stringKey) {
    int keyId = (int) propertyKeyTokenStore.nextId();
    PropertyKeyTokenRecord record = new PropertyKeyTokenRecord(keyId);
    record.setInUse(true);
    record.setCreated();
    Collection<DynamicRecord> keyRecords = propertyKeyTokenStore.allocateNameRecords(encodeString(stringKey));
    record.setNameId((int) Iterables.first(keyRecords).getId());
    record.addNameRecords(keyRecords);
    propertyKeyTokenStore.updateRecord(record);
    propertyKeyTokens.addToken(new Token(stringKey, keyId));
    return keyId;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) UniquenessConstraint(org.neo4j.kernel.api.constraints.UniquenessConstraint) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 13 with Token

use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldApplyLabelTokenCommandToTheStoreInRecovery.

@Test
public void shouldApplyLabelTokenCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    final LabelTokenRecord before = new LabelTokenRecord(42);
    final LabelTokenRecord after = new LabelTokenRecord(42);
    after.setInUse(true);
    after.setNameId(323);
    final Command.LabelTokenCommand command = new Command.LabelTokenCommand(before, after);
    final Token token = new Token("token", 21);
    when(labelTokenStore.getToken((int) command.getKey())).thenReturn(token);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(labelTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
    verify(labelTokenStore, times(1)).updateRecord(after);
    verify(cacheAccess, times(1)).addLabelToken(token);
}
Also used : LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) Test(org.junit.Test)

Example 14 with Token

use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldApplyPropertyKeyTokenCommandToTheStoreInRecovery.

@Test
public void shouldApplyPropertyKeyTokenCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    final PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
    final PropertyKeyTokenRecord after = new PropertyKeyTokenRecord(42);
    after.setInUse(true);
    after.setNameId(323);
    final Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand(before, after);
    final Token token = new Token("token", 21);
    when(propertyKeyTokenStore.getToken((int) command.getKey())).thenReturn(token);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(propertyKeyTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
    verify(propertyKeyTokenStore, times(1)).updateRecord(after);
    verify(cacheAccess, times(1)).addPropertyKeyToken(token);
}
Also used : RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) Test(org.junit.Test)

Example 15 with Token

use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.

the class AutoIndexOperationsTest method setup.

@Before
public void setup() throws TokenNotFoundException {
    when(tokens.getTokenById(nonIndexedProperty)).thenReturn(new Token(nonIndexedPropertyName, nonIndexedProperty));
    when(tokens.getTokenById(indexedProperty)).thenReturn(new Token(indexedPropertyName, indexedProperty));
    when(tokens.getTokenById(indexedProperty2)).thenReturn(new Token(indexedPropertyName, indexedProperty2));
    index.enabled(true);
}
Also used : Token(org.neo4j.storageengine.api.Token) Before(org.junit.Before)

Aggregations

Token (org.neo4j.storageengine.api.Token)19 Test (org.junit.Test)8 RelationshipTypeToken (org.neo4j.kernel.impl.core.RelationshipTypeToken)8 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Before (org.junit.Before)2 ReadOperations (org.neo4j.kernel.api.ReadOperations)2 Statement (org.neo4j.kernel.api.Statement)2 UniquenessConstraint (org.neo4j.kernel.api.constraints.UniquenessConstraint)2 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)2 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)2 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)2 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)2 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)2 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)2 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 DependencyResolver (org.neo4j.graphdb.DependencyResolver)1