private int getOrCreatePropertyKeyId( String name ) { return tokenHolders.propertyKeyTokens().getOrCreateId( name ); }
private int getOrCreateRelationshipTypeId( String name ) { return tokenHolders.relationshipTypeTokens().getOrCreateId( name ); }
private int getOrCreateLabelId( String name ) { return tokenHolders.labelTokens().getOrCreateId( name ); }
private int index( String key ) { return propertyKeyTokenHolder.getOrCreateId( key ); }
@Override public int propertyKey() { return propertyKeyTokenHolder.getOrCreateId( current.getKey() ); }
private int getOrCreateForName( TokenHolder tokens, String name ) throws IllegalTokenNameException { ktx.assertOpen(); int id = tokens.getIdByName( checkValidTokenName( name ) ); if ( id != NO_TOKEN ) { return id; } ktx.assertAllows( AccessMode::allowsTokenCreates, "Token create" ); return tokens.getOrCreateId( name ); }
@Test public void mustCreateAndCacheNewTokens() throws Exception { when( creator.createToken( "token" ) ).thenReturn( 42 ); assertThat( holder.getOrCreateId( "token" ), is( 42 ) ); assertThat( holder.getOrCreateId( "token" ), is( 42 ) ); // Verify implies that the call only happens once. verify( creator ).createToken( "token" ); verifyNoMoreInteractions( creator ); }
private void initialTokensABC() throws KernelException { holder.setInitialTokens( asList( token( "a", 1 ), token( "b", 2 ) ) ); when( creator.createToken( "c" ) ).thenReturn( 3 ); assertThat( holder.getOrCreateId( "c" ), is( 3 ) ); }
@Test public void shouldListRemovedNodeProperties() throws Exception { // Given int propertyKeyId = ops.propertyKeyTokenHolder().getOrCreateId( "theKey" ); Value prevValue = Values.of( "prevValue" ); state.nodeDoRemoveProperty( 1L, propertyKeyId ); ops.withNode( 1, NO_LABELS, genericMap( "theKey", prevValue ) ); // When Iterable<PropertyEntry<Node>> propertyEntries = snapshot().removedNodeProperties(); // Then PropertyEntry<Node> entry = single( propertyEntries ); assertThat( entry.key(), equalTo( "theKey" ) ); assertThat( entry.previouslyCommitedValue(), equalTo( "prevValue" ) ); assertThat( entry.entity().getId(), equalTo( 1L ) ); }
@Test public void shouldListRemovedRelationshipProperties() throws Exception { // Given int propertyKeyId = ops.propertyKeyTokenHolder().getOrCreateId( "theKey" ); Value prevValue = Values.of( "prevValue" ); state.relationshipDoRemoveProperty( 1L, propertyKeyId ); ops.withRelationship( 1, 0, 0, 0, genericMap( "theKey", prevValue ) ); // When Iterable<PropertyEntry<Relationship>> propertyEntries = snapshot().removedRelationshipProperties(); // Then PropertyEntry<Relationship> entry = single( propertyEntries ); assertThat( entry.key(), equalTo( "theKey" ) ); assertThat( entry.previouslyCommitedValue(), equalTo( "prevValue" ) ); assertThat( entry.entity().getId(), equalTo( 1L ) ); }
@Test public void shouldListAddedNodePropertiesProperties() throws Exception { // Given int propertyKeyId = ops.propertyKeyTokenHolder().getOrCreateId( "theKey" ); Value prevValue = Values.of( "prevValue" ); state.nodeDoChangeProperty( 1L, propertyKeyId, Values.of( "newValue" ) ); ops.withNode( 1, NO_LABELS, genericMap( "theKey", prevValue ) ); // When Iterable<PropertyEntry<Node>> propertyEntries = snapshot().assignedNodeProperties(); // Then PropertyEntry<Node> entry = single( propertyEntries ); assertThat( entry.key(), equalTo( "theKey" ) ); assertThat( entry.value(), equalTo( "newValue" ) ); assertThat( entry.previouslyCommitedValue(), equalTo( "prevValue" ) ); assertThat( entry.entity().getId(), equalTo( 1L ) ); }
@Test public void shouldListAddedRelationshipProperties() throws Exception { // Given Value prevValue = Values.of( "prevValue" ); int propertyKeyId = ops.propertyKeyTokenHolder().getOrCreateId( "theKey" ); state.relationshipDoReplaceProperty( 1L, propertyKeyId, prevValue, Values.of( "newValue" ) ); ops.withRelationship( 1, 0, 0, 0, genericMap( "theKey", prevValue ) ); // When Iterable<PropertyEntry<Relationship>> propertyEntries = snapshot().assignedRelationshipProperties(); // Then PropertyEntry<Relationship> entry = single( propertyEntries ); assertThat( entry.key(), equalTo( "theKey" ) ); assertThat( entry.value(), equalTo( "newValue" ) ); assertThat( entry.previouslyCommitedValue(), equalTo( "prevValue" ) ); assertThat( entry.entity().getId(), equalTo( 1L ) ); }
private int getOrCreatePropertyKeyId( String name ) { return tokenHolders.propertyKeyTokens().getOrCreateId( name ); }
private int getOrCreateRelationshipTypeId( String name ) { return tokenHolders.relationshipTypeTokens().getOrCreateId( name ); }
private int getOrCreateLabelId( String name ) { return tokenHolders.labelTokens().getOrCreateId( name ); }
private int getOrCreateForName( TokenHolder tokens, String name ) throws IllegalTokenNameException { ktx.assertOpen(); int id = tokens.getIdByName( checkValidTokenName( name ) ); if ( id != NO_TOKEN ) { return id; } ktx.assertAllows( AccessMode::allowsTokenCreates, "Token create" ); return tokens.getOrCreateId( name ); }