public static int[] keys( PropertyRecord property ) { int[] toStartWith = new int[ MAX_BLOCK_PER_RECORD_COUNT ]; int index = 0; for ( PropertyBlock propertyBlock : property ) { toStartWith[index++] = propertyBlock.getKeyIndexId(); } return Arrays.copyOf( toStartWith, index ); } }
public PropertyBlock getPropertyBlock( int keyIndex ) { ensureBlocksLoaded(); for ( int i = 0; i < blockRecordsCursor; i++ ) { PropertyBlock block = blockRecords[i]; if ( block.getKeyIndexId() == keyIndex ) { return block; } } return null; }
private void mapBlocks( PropertyRecord record, MutableIntObjectMap<PropertyBlock> blocks ) { for ( PropertyBlock block : record ) { blocks.put( block.getKeyIndexId(), block ); } }
@Override public boolean visit( PropertyRecord element ) throws RuntimeException { for ( PropertyBlock block : element ) { if ( block.getKeyIndexId() == propertyKeyId ) { foundPropertyValue = propertyValue( block ); return true; } } return false; } }
public PropertyBlock removePropertyBlock( int keyIndex ) { ensureBlocksLoaded(); for ( int i = 0; i < blockRecordsCursor; i++ ) { if ( blockRecords[i].getKeyIndexId() == keyIndex ) { PropertyBlock block = blockRecords[i]; if ( --blockRecordsCursor > i ) { blockRecords[i] = blockRecords[blockRecordsCursor]; } return block; } } return null; }
public void setPropertyBlock( PropertyBlock block ) { removePropertyBlock( block.getKeyIndexId() ); addPropertyBlock( block ); }
static IntObjectMap<PropertyBlock> properties( List<PropertyBlock> propertyBlocks ) { final MutableIntObjectMap<PropertyBlock> propertyIds = new IntObjectHashMap<>(); for ( PropertyBlock propertyBlock : propertyBlocks ) { propertyIds.put( propertyBlock.getKeyIndexId(), propertyBlock ); } return propertyIds; }
public PropertyKeyValue newPropertyKeyValue( PropertyStore propertyStore ) { int propertyKeyId = getKeyIndexId(); return new PropertyKeyValue( propertyKeyId, getType().value( this, propertyStore ) ); }
result.append( "key=" ).append( valueBlocks == null ? "?" : Integer.toString( getKeyIndexId() ) ); if ( type != null )
private Map<String, Object> getPropertyChain( long nextProp ) { final Map<String, Object> map = new HashMap<>(); propertyTraverser.getPropertyChain( nextProp, recordAccess.getPropertyRecords(), propBlock -> { try { String key = tokenHolders.propertyKeyTokens().getTokenById( propBlock.getKeyIndexId() ).name(); Value propertyValue = propBlock.newPropertyValue( propertyStore ); map.put( key, propertyValue.asObject() ); } catch ( TokenNotFoundException e ) { throw new RuntimeException( e ); } } ); return map; }
private void removeProperty( PrimitiveRecord primitive, PropertyRecord host, PropertyBlock block ) { host.removePropertyBlock( block.getKeyIndexId() ); host.setChanged( primitive ); for ( DynamicRecord record : block.getValueRecords() ) { assert record.inUse(); record.setInUse( false, block.getType().intValue() ); host.addDeletedRecord( record ); } }
@Test public void addLoadedBlock() { PropertyRecord record = new PropertyRecord( 42 ); addBlock( record, 1, 2 ); addBlock( record, 3, 4 ); List<PropertyBlock> blocks = Iterables.asList( record ); assertEquals( 2, blocks.size() ); assertEquals( 1, blocks.get( 0 ).getKeyIndexId() ); assertEquals( 2, blocks.get( 0 ).getSingleValueInt() ); assertEquals( 3, blocks.get( 1 ).getKeyIndexId() ); assertEquals( 4, blocks.get( 1 ).getSingleValueInt() ); }
private void assertBlocksEquals( PropertyBlock written, PropertyBlock read ) { assertEquals( written.getKeyIndexId(), read.getKeyIndexId() ); assertEquals( written.getSize(), read.getSize() ); assertTrue( written.hasSameContentsAs( read ) ); assertArrayEquals( written.getValueBlocks(), read.getValueBlocks() ); } };
private List<Pair<String, Object>> getPropertiesFromRecord( long recordId ) { final PropertyRecord record = propertyStore().getRecord( recordId, propertyStore().newRecord(), RecordLoad.FORCE ); final List<Pair<String, Object>> props = new ArrayList<>(); record.forEach( block -> { final Object value = propertyStore().getValue( block ).asObject(); final String name = propertyStore().getPropertyKeyTokenStore().getToken( block.getKeyIndexId() ).name(); props.add( pair( name, value ) ); } ); return props; }
RecordAccess records ) if ( block.getKeyIndexId() < 0 ) engine.comparativeCheck( records.propertyKey( block.getKeyIndexId() ), propertyKey( block ) );
private static void assertPropertyBlocksEqual( int index, PropertyBlock actualBlock, PropertyBlock expectedBlock ) assertThat( "[" + index + "]getKeyIndexId", actualBlock.getKeyIndexId(), is( expectedBlock.getKeyIndexId() ) ); assertThat( "[" + index + "]getSingleValueBlock", actualBlock.getSingleValueBlock(), is( expectedBlock.getSingleValueBlock() ) );
int currentPropertyId = block.getKeyIndexId(); if ( propertyIds.remove( currentPropertyId ) )
@Override public EntityUpdates nodeAsUpdates( long nodeId ) { NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), FORCE ); if ( !node.inUse() ) { return null; } long firstPropertyId = node.getNextProp(); if ( firstPropertyId == Record.NO_NEXT_PROPERTY.intValue() ) { return null; // no properties => no updates (it's not going to be in any index) } long[] labels = parseLabelsField( node ).get( nodeStore ); if ( labels.length == 0 ) { return null; // no labels => no updates (it's not going to be in any index) } EntityUpdates.Builder update = EntityUpdates.forEntity( nodeId ).withTokens( labels ); for ( PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain( firstPropertyId ) ) { for ( PropertyBlock property : propertyRecord ) { Value value = property.getType().value( property, propertyStore ); update.added( property.getKeyIndexId(), value ); } } return update.build(); }
public PropertyBlock getPropertyBlock( int keyIndex ) { ensureBlocksLoaded(); for ( int i = 0; i < blockRecordsCursor; i++ ) { PropertyBlock block = blockRecords[i]; if ( block.getKeyIndexId() == keyIndex ) { return block; } } return null; }
private PropertyReader nodeHasProperty( NodeRecord nodeRecord, String propertyValue ) { PropertyReader propertyReader = mock( PropertyReader.class ); PropertyBlock propertyBlock = mock( PropertyBlock.class ); when( propertyBlock.getKeyIndexId() ) .thenReturn( propertyKeyId ); when( propertyReader.propertyBlocks( nodeRecord ) ) .thenReturn( asList( propertyBlock ) ); when( propertyReader.propertyValue( any( PropertyBlock.class ) ) ) .thenReturn( stringProperty( propertyKeyId, propertyValue ) ); return propertyReader; }