Search in sources :

Example 1 with RelationshipTypeToken

use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldApplyRelationshipTypeTokenCommandToTheStoreInRecovery.

@Test
public void shouldApplyRelationshipTypeTokenCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord(42);
    final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord(42);
    after.setInUse(true);
    after.setNameId(323);
    final Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(before, after);
    final RelationshipTypeToken token = new RelationshipTypeToken("token", 21);
    when(relationshipTypeTokenStore.getToken((int) command.getKey())).thenReturn(token);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(relationshipTypeTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
    verify(relationshipTypeTokenStore, times(1)).updateRecord(after);
    verify(cacheAccess, times(1)).addRelationshipTypeToken(token);
}
Also used : RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) 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) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 2 with RelationshipTypeToken

use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.

the class BatchInserterImpl method createNewRelationshipType.

private int createNewRelationshipType(String name) {
    int id = (int) relationshipTypeTokenStore.nextId();
    RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
    record.setInUse(true);
    record.setCreated();
    Collection<DynamicRecord> nameRecords = relationshipTypeTokenStore.allocateNameRecords(encodeString(name));
    record.setNameId((int) Iterables.first(nameRecords).getId());
    record.addNameRecords(nameRecords);
    relationshipTypeTokenStore.updateRecord(record);
    relationshipTypeTokens.addToken(new RelationshipTypeToken(name, id));
    return id;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) UniquenessConstraint(org.neo4j.kernel.api.constraints.UniquenessConstraint)

Example 3 with RelationshipTypeToken

use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.

the class CacheInvalidationTransactionApplier method visitRelationshipTypeTokenCommand.

@Override
public boolean visitRelationshipTypeTokenCommand(RelationshipTypeTokenCommand command) throws IOException {
    RelationshipTypeToken type = relationshipTypeTokenStore.getToken((int) command.getKey());
    cacheAccess.addRelationshipTypeToken(type);
    return false;
}
Also used : RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken)

Example 4 with RelationshipTypeToken

use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.

the class NeoStoresTest method validateRelTypes.

private void validateRelTypes(int relType1, int relType2) throws IOException {
    Token data = rtStore.getToken(relType1);
    assertEquals(relType1, data.id());
    assertEquals("relationshiptype1", data.name());
    data = rtStore.getToken(relType2);
    assertEquals(relType2, data.id());
    assertEquals("relationshiptype2", data.name());
    List<RelationshipTypeToken> allData = rtStore.getTokens(Integer.MAX_VALUE);
    assertEquals(2, allData.size());
    for (int i = 0; i < 2; i++) {
        if (allData.get(i).id() == relType1) {
            assertEquals(relType1, allData.get(i).id());
            assertEquals("relationshiptype1", allData.get(i).name());
        } else if (allData.get(i).id() == relType2) {
            assertEquals(relType2, allData.get(i).id());
            assertEquals("relationshiptype2", allData.get(i).name());
        } else {
            throw new IOException();
        }
    }
}
Also used : RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException)

Aggregations

RelationshipTypeToken (org.neo4j.kernel.impl.core.RelationshipTypeToken)4 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 Test (org.junit.Test)1 UniquenessConstraint (org.neo4j.kernel.api.constraints.UniquenessConstraint)1 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)1 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)1 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)1 Token (org.neo4j.storageengine.api.Token)1