if ( type.equals( String.class ) ) allocateFromString( target, (String[]) array, recordAllocator ); allocateFromCompositeType( target,GeometryType.encodePointArray( (PointValue[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.POINT_PROPERTIES ); allocateFromCompositeType( target, TemporalType.encodeDateArray( (LocalDate[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.TEMPORAL_PROPERTIES ); allocateFromCompositeType( target, TemporalType.encodeLocalTimeArray( (LocalTime[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.TEMPORAL_PROPERTIES ); allocateFromCompositeType( target, TemporalType.encodeLocalDateTimeArray( (LocalDateTime[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.TEMPORAL_PROPERTIES ); allocateFromCompositeType( target, TemporalType.encodeTimeArray( (OffsetTime[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.TEMPORAL_PROPERTIES ); allocateFromCompositeType( target, TemporalType.encodeDateTimeArray( (ZonedDateTime[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.TEMPORAL_PROPERTIES ); allocateFromCompositeType( target, TemporalType.encodeDurationArray( (DurationValue[]) array ), recordAllocator, allowStorePointsAndTemporal, Capability.TEMPORAL_PROPERTIES ); allocateFromNumbers( target, array, recordAllocator );
public static long[] getDynamicLabelsArrayFromHeavyRecords( Iterable<DynamicRecord> records ) { long[] storedLongs = (long[]) DynamicArrayStore.getRightArray( readFullByteArrayFromHeavyRecords( records, PropertyType.ARRAY ) ).asObject(); return LabelIdArray.stripNodeId( storedLongs ); }
public PropertyValueRecordSizeCalculator( PropertyStore propertyStore ) { this( propertyStore.getRecordSize(), propertyStore.getStringStore().getRecordSize(), propertyStore.getStringStore().getRecordDataSize(), propertyStore.getArrayStore().getRecordSize(), propertyStore.getArrayStore().getRecordDataSize() ); }
public static void allocateFromNumbers( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator recordAllocator ) { byte[] bytes = encodeFromNumbers( array, 0 ); allocateRecordsFromBytes( target, bytes, recordAllocator ); }
private Value getArrayFor( Iterable<DynamicRecord> records ) { return getRightArray( arrayStore.readFullByteArray( records, PropertyType.ARRAY ) ); }
private Collection<DynamicRecord> storeArray( Object array ) { Collection<DynamicRecord> records = new ArrayList<>(); arrayStore.allocateRecords( records, array ); for ( DynamicRecord record : records ) { arrayStore.updateRecord( record ); } return records; }
@Test void shouldReportMissingOwnerId() { // given DynamicRecord record = new DynamicRecord( 0 ); inUse( record ) ; allocateFromNumbers( new ArrayList<>(), new long[] { }, new ReusableRecordsAllocator( 66, record ) ); // when DynamicLabelConsistencyReport report = check( record ); // then verify( report ).orphanDynamicLabelRecord(); }
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { DynamicRecord record1 = inUse( new DynamicRecord( chain.get( 0 ).getId() ) ); DynamicRecord record2 = notInUse( new DynamicRecord( chain.get( 1 ).getId() ) ); long[] data = (long[]) getRightArray( readFullByteArrayFromHeavyRecords( chain, ARRAY ) ); PreAllocatedRecords allocator = new PreAllocatedRecords( 60 ); allocateFromNumbers( new ArrayList<DynamicRecord>(), Arrays.copyOf( data, 11 ), iterator( record1 ), allocator ); NodeRecord before = inUse( new NodeRecord( data[0], false, -1, -1 ) ); NodeRecord after = inUse( new NodeRecord( data[0], false, -1, -1 ) ); before.setLabelField( dynamicPointer( asList( record1 ) ), chain ); after.setLabelField( dynamicPointer( asList( record1 ) ), asList( record1, record2 ) ); tx.update( before, after ); } } );
@Test public void testClose() { DynamicArrayStore store = createDynamicArrayStore(); Collection<DynamicRecord> records = new ArrayList<>(); store.allocateRecordsFromBytes( records, new byte[10] ); long blockId = Iterables.first( records ).getId(); for ( DynamicRecord record : records ) { store.updateRecord( record ); } neoStores.close(); neoStores = null; try { store.getArrayFor( store.getRecords( blockId, NORMAL ) ); fail( "Closed store should throw exception" ); } catch ( RuntimeException e ) { // good } try { store.getRecords( 0, NORMAL ); fail( "Closed store should throw exception" ); } catch ( RuntimeException e ) { // good } }
store.getRecords( blockId, NORMAL ); byte[] bytes = (byte[]) store.getArrayFor( store.getRecords( blockId, NORMAL ) ); validateData( bytes, byteData.remove( blockId ) ); Collection<DynamicRecord> records = store.getRecords( blockId, NORMAL ); for ( DynamicRecord record : records ) store.updateRecord( record ); set.remove( record.getId() ); store.allocateRecords( records, bytes ); for ( DynamicRecord record : records ) store.updateRecord( record ); set.add( record.getId() );
@Test public void testAddDeleteSequenceEmptyStringArray() { DynamicArrayStore store = createDynamicArrayStore(); long blockId = create( store, new String[0] ); store.getRecords( blockId, NORMAL ); String[] readBack = (String[]) store.getArrayFor( store.getRecords( blockId, NORMAL ) ); assertEquals( 0, readBack.length ); Collection<DynamicRecord> records = store.getRecords( blockId, NORMAL ); for ( DynamicRecord record : records ) { record.setInUse( false ); store.updateRecord( record ); } } }
@Test public void testSetBlockSize() throws Exception { DatabaseLayout databaseLayout = dir.databaseLayout( "small_store" ); initializeStores( databaseLayout, stringMap( "unsupported.dbms.block_size.strings", "62", "unsupported.dbms.block_size.array_properties", "302" ) ); assertEquals( 62 + DynamicRecordFormat.RECORD_HEADER_SIZE, pStore.getStringStore().getRecordSize() ); assertEquals( 302 + DynamicRecordFormat.RECORD_HEADER_SIZE, pStore.getArrayStore().getRecordSize() ); ds.stop(); }
private static void allocateArrayRecords( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator allocator, boolean allowStorePoints ) { DynamicArrayStore.allocateRecords( target, array, allocator, allowStorePoints ); }
public void updateDynamicLabelRecords( Iterable<DynamicRecord> dynamicLabelRecords ) { for ( DynamicRecord record : dynamicLabelRecords ) { dynamicLabelStore.updateRecord( record ); } } }
private static void allocateFromCompositeType( Collection<DynamicRecord> target, byte[] bytes, DynamicRecordAllocator recordAllocator, boolean allowsStorage, Capability storageCapability ) { if ( allowsStorage ) { allocateRecordsFromBytes( target, bytes, recordAllocator ); } else { throw new UnsupportedFormatCapabilityException( storageCapability ); } }
@Test public void failStoreInitializationWhenHeaderRecordCantBeRead() throws IOException { File storeFile = dir.file( "a" ); File idFile = dir.file( "idFile" ); PageCache pageCache = mock( PageCache.class ); PagedFile pagedFile = mock( PagedFile.class ); PageCursor pageCursor = mock( PageCursor.class ); when( pageCache.map( eq( storeFile ), anyInt(), any( OpenOption.class ) ) ).thenReturn( pagedFile ); when( pagedFile.io( 0L, PagedFile.PF_SHARED_READ_LOCK ) ).thenReturn( pageCursor ); when( pageCursor.next() ).thenReturn( false ); RecordFormats recordFormats = Standard.LATEST_RECORD_FORMATS; expectedException.expect( StoreNotFoundException.class ); expectedException.expectMessage( "Fail to read header record of store file: " + storeFile.getAbsolutePath() ); try ( DynamicArrayStore dynamicArrayStore = new DynamicArrayStore( storeFile, idFile, config, IdType.NODE_LABELS, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), Settings.INTEGER.apply( GraphDatabaseSettings.label_block_size.getDefaultValue() ), recordFormats ) ) { dynamicArrayStore.initialise( false ); } }
public void ensureHeavy( NodeRecord node, long firstDynamicLabelRecord ) { if ( !node.isLight() ) { return; } // Load any dynamic labels and populate the node record node.setLabelField( node.getLabelField(), dynamicLabelStore.getRecords( firstDynamicLabelRecord, RecordLoad.NORMAL ) ); }
CommonAbstractStore createDynamicArrayStore( File storeFile, File idFile, IdType idType, int blockSize ) { if ( blockSize <= 0 ) { throw new IllegalArgumentException( "Block size of dynamic array store should be positive integer." ); } return initialize( new DynamicArrayStore( storeFile, idFile, config, idType, idGeneratorFactory, pageCache, logProvider, blockSize, recordFormats, openOptions ) ); }
private Pair<byte[], byte[]> loadArray( Collection<DynamicRecord> records ) { return arrayStore.readFullByteArray( records, PropertyType.ARRAY ); } }
@Test public void shouldReadFirstFromSingleRecordDynamicLongArray() { // GIVEN Long expectedId = 12L; long[] ids = new long[]{expectedId, 23L, 42L}; DynamicRecord firstRecord = new DynamicRecord( 0L ); allocateFromNumbers( new ArrayList<>(), ids, new ReusableRecordsAllocator( 60, firstRecord ) ); // WHEN Long firstId = readOwnerFromDynamicLabelsRecord( firstRecord ); // THEN assertEquals( expectedId, firstId ); }