private static void allocateFromString( Collection<DynamicRecord> target, String[] array, DynamicRecordAllocator recordAllocator ) { byte[][] stringsAsBytes = new byte[array.length][]; int totalBytesRequired = STRING_HEADER_SIZE; // 1b type + 4b array length for ( int i = 0; i < array.length; i++ ) { String string = array[i]; byte[] bytes = PropertyStore.encodeString( string ); stringsAsBytes[i] = bytes; totalBytesRequired += 4/*byte[].length*/ + bytes.length; } ByteBuffer buf = ByteBuffer.allocate( totalBytesRequired ); buf.put( PropertyType.STRING.byteValue() ); buf.putInt( array.length ); for ( byte[] stringAsBytes : stringsAsBytes ) { buf.putInt( stringAsBytes.length ); buf.put( stringAsBytes ); } allocateRecordsFromBytes( target, buf.array(), recordAllocator ); }
public PropertyBlock encodeValue( PropertyBlock block, int propertyKey, Value value ) { PropertyStore.encodeValue( block, propertyKey, value, stringRecordAllocator, arrayRecordAllocator, allowStorePointsAndTemporal ); return block; }
public PropertyCreator( PropertyStore propertyStore, PropertyTraverser traverser ) { this( propertyStore.getStringStore(), propertyStore.getArrayStore(), propertyStore, traverser, propertyStore.allowStorePointsAndTemporal() ); }
Value getArrayFor( PropertyBlock propertyBlock ) { ensureHeavy( propertyBlock ); return getArrayFor( propertyBlock.getValueRecords() ); }
private void encodeProperty( PropertyBlock block, int key, Object value ) { PropertyStore.encodeValue( block, key, ValueUtils.asValue( value ), dynamicStringRecordAllocator, dynamicArrayRecordAllocator, propertyStore.allowStorePointsAndTemporal() ); }
new PropertyStore( storeFile, idFile, config, new JumpingIdGeneratorFactory( 1 ), pageCache, NullLogProvider.getInstance(), stringPropertyStore, mock( PropertyKeyTokenStore.class ), mock( DynamicArrayStore.class ), RecordFormatSelector.defaultFormat() ); store.initialise( true ); store.makeStoreOk(); final long propertyRecordId = store.nextId(); PropertyRecord recordBeforeWrite = store.getRecord( propertyRecordId, store.newRecord(), FORCE ); assertFalse( recordBeforeWrite.inUse() ); return null; store.updateRecord( record ); store.close();
@SuppressWarnings( {"unchecked", "rawtypes"} ) public static NeoStores basicMockedNeoStores() { NeoStores neoStores = mock( NeoStores.class ); // NodeStore - DynamicLabelStore NodeStore nodeStore = mock( NodeStore.class ); when( neoStores.getNodeStore() ).thenReturn( nodeStore ); // NodeStore - DynamicLabelStore DynamicArrayStore dynamicLabelStore = mock( DynamicArrayStore.class ); when( nodeStore.getDynamicLabelStore() ).thenReturn( dynamicLabelStore ); // RelationshipStore RelationshipStore relationshipStore = mock( RelationshipStore.class ); when( neoStores.getRelationshipStore() ).thenReturn( relationshipStore ); // RelationshipGroupStore RelationshipGroupStore relationshipGroupStore = mock( RelationshipGroupStore.class ); when( neoStores.getRelationshipGroupStore() ).thenReturn( relationshipGroupStore ); // PropertyStore PropertyStore propertyStore = mock( PropertyStore.class ); when( neoStores.getPropertyStore() ).thenReturn( propertyStore ); // PropertyStore -- DynamicStringStore DynamicStringStore propertyStringStore = mock( DynamicStringStore.class ); when( propertyStore.getStringStore() ).thenReturn( propertyStringStore ); // PropertyStore -- DynamicArrayStore DynamicArrayStore propertyArrayStore = mock( DynamicArrayStore.class ); when( propertyStore.getArrayStore() ).thenReturn( propertyArrayStore ); return neoStores; }
PropertyRecord propertyRecord = propertyStore.newRecord(); try ( PageCursor cursor = nodeStore.openPageCursorForReading( 0 ); PageCursor propertyCursor = propertyStore.openPageCursorForReading( 0 ) ) while ( !Record.NULL_REFERENCE.is( nextProp ) ) propertyStore.getRecordByCursor( nextProp, propertyRecord, NORMAL, propertyCursor ); assert propertyRecord.inUse() : propertyRecord + " for " + nodeRecord; propertyStore.ensureHeavy( propertyRecord ); propertiesRemoved += propertyRecord.numberOfProperties(); nextProp = propertyRecord.getNextProp(); deletePropertyRecordIncludingValueRecords( propertyRecord ); propertyStore.updateRecord( propertyRecord );
record.setNextProp( AbstractBaseRecord.NO_ID ); stores.getNodeStore().updateRecord( record ); PropertyRecord propRecord = stores.getPropertyStore().getRecord( propId, stores.getPropertyStore().newRecord(), RecordLoad.NORMAL ); propRecord.setInUse( false ); stores.getPropertyStore().updateRecord( propRecord ); db.shutdown();
protected EntityImporter( BatchingNeoStores stores, Monitor monitor ) { this.propertyStore = stores.getPropertyStore(); this.propertyKeyTokenRepository = stores.getPropertyKeyRepository(); this.monitor = monitor; for ( int i = 0; i < propertyBlocks.length; i++ ) { propertyBlocks[i] = new PropertyBlock(); } this.propertyRecord = propertyStore.newRecord(); this.propertyIds = new BatchingIdGetter( propertyStore ); this.dynamicStringRecordAllocator = new StandardDynamicRecordAllocator( new BatchingIdGetter( propertyStore.getStringStore(), propertyStore.getStringStore().getRecordsPerPage() ), propertyStore.getStringStore().getRecordDataSize() ); this.dynamicArrayRecordAllocator = new StandardDynamicRecordAllocator( new BatchingIdGetter( propertyStore.getArrayStore(), propertyStore.getArrayStore().getRecordsPerPage() ), propertyStore.getStringStore().getRecordDataSize() ); }
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; }
private static long calculateNumberOfProperties( NeoStores stores ) { long count = 0; PropertyRecord record = stores.getPropertyStore().newRecord(); try ( PageCursor cursor = stores.getPropertyStore().openPageCursorForReading( 0 ) ) { long highId = stores.getPropertyStore().getHighId(); for ( long id = 0; id < highId; id++ ) { stores.getPropertyStore().getRecordByCursor( id, record, CHECK, cursor ); if ( record.inUse() ) { count += count( record ); } } } return count; }
public PropertyValueRecordSizeCalculator( PropertyStore propertyStore ) { this( propertyStore.getRecordSize(), propertyStore.getStringStore().getRecordSize(), propertyStore.getStringStore().getRecordDataSize(), propertyStore.getArrayStore().getRecordSize(), propertyStore.getArrayStore().getRecordDataSize() ); }
/** * This method exists since {@link #wrapStore(RecordStore)} might depend on the existence of a variable * that gets set in a subclass' constructor <strong>after</strong> this constructor of {@link StoreAccess} * has been executed. I.e. a correct creation of a {@link StoreAccess} instance must be the creation of the * object plus a call to {@link #initialize()}. * * @return this */ public StoreAccess initialize() { this.schemaStore = wrapStore( neoStores.getSchemaStore() ); this.nodeStore = wrapStore( neoStores.getNodeStore() ); this.relStore = wrapStore( neoStores.getRelationshipStore() ); this.propStore = wrapStore( neoStores.getPropertyStore() ); this.stringStore = wrapStore( neoStores.getPropertyStore().getStringStore() ); this.arrayStore = wrapStore( neoStores.getPropertyStore().getArrayStore() ); this.relationshipTypeTokenStore = wrapStore( neoStores.getRelationshipTypeTokenStore() ); this.labelTokenStore = wrapStore( neoStores.getLabelTokenStore() ); this.nodeDynamicLabelStore = wrapStore( wrapNodeDynamicLabelStore( neoStores.getNodeStore().getDynamicLabelStore() ) ); this.propertyKeyTokenStore = wrapStore( neoStores.getPropertyStore().getPropertyKeyTokenStore() ); this.relationshipTypeNameStore = wrapStore( neoStores.getRelationshipTypeTokenStore().getNameStore() ); this.labelNameStore = wrapStore( neoStores.getLabelTokenStore().getNameStore() ); this.propertyKeyNameStore = wrapStore( neoStores.getPropertyStore().getPropertyKeyTokenStore().getNameStore() ); this.relGroupStore = wrapStore( neoStores.getRelationshipGroupStore() ); return this; }
NodeInputIdPropertyLookup( PropertyStore propertyStore ) { this.propertyStore = propertyStore; this.propertyRecord = propertyStore.newRecord(); }
PropertyRecord record = propertyStore.newRecord(); propertyStore.updateRecord( record ); propertyStore.updateRecord( record ); propertyStore.updateRecord( record ); propertyStore.updateRecord( record );
InputIterable relationships = () -> legacyRelationshipsAsInput( legacyStore, requiresPropertyMigration ); long propertyStoreSize = storeSize( legacyStore.getPropertyStore() ) / 2 + storeSize( legacyStore.getPropertyStore().getStringStore() ) / 2 + storeSize( legacyStore.getPropertyStore().getArrayStore() ) / 2; Estimates estimates = knownEstimates( legacyStore.getNodeStore().getNumberOfIdsInUse(), legacyStore.getRelationshipStore().getNumberOfIdsInUse(), legacyStore.getPropertyStore().getNumberOfIdsInUse(), legacyStore.getPropertyStore().getNumberOfIdsInUse(), propertyStoreSize / 2, propertyStoreSize / 2, 0 /*node labels left as 0 for now*/);
@Override public boolean id( Object id, Group group ) { long nodeId = nodeIds.next(); nodeRecord.setId( nodeId ); idMapper.put( id, nodeId, group ); // also store this id as property in temp property store if ( id != null ) { idPropertyStore.encodeValue( idPropertyBlock, 0, Values.of( id ) ); idPropertyRecord.addPropertyBlock( idPropertyBlock ); idPropertyRecord.setId( nodeId ); // yes nodeId idPropertyRecord.setInUse( true ); idPropertyStore.updateRecord( idPropertyRecord ); idPropertyRecord.clear(); } return true; }
public Collection<PropertyRecord> getPropertyRecordChain( long firstRecordId ) { long nextProp = firstRecordId; List<PropertyRecord> toReturn = new LinkedList<>(); while ( nextProp != Record.NO_NEXT_PROPERTY.intValue() ) { PropertyRecord propRecord = new PropertyRecord( nextProp ); getRecord( nextProp, propRecord, RecordLoad.NORMAL ); toReturn.add( propRecord ); nextProp = propRecord.getNextProp(); } return toReturn; }