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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations