public void allocateRecords( Collection<DynamicRecord> target, Object array ) { allocateRecords( target, array, this, allowStorePointsAndTemporal ); }
private static void allocateArrayRecords( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator allocator, boolean allowStorePoints ) { DynamicArrayStore.allocateRecords( target, array, allocator, allowStorePoints ); }
public static Collection<DynamicRecord> allocateRecordsForDynamicLabels( long nodeId, long[] labels, DynamicRecordAllocator allocator ) { long[] storedLongs = LabelIdArray.prependNodeId( nodeId, labels ); Collection<DynamicRecord> records = new ArrayList<>(); // since we can't store points in long array we passing false as possibility to store points DynamicArrayStore.allocateRecords( records, storedLongs, allocator, false ); return records; }
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( expected = IllegalArgumentException.class ) public void pointArraysOfMixedDimension() { PointValue[] array = new PointValue[]{ Values.pointValue( CoordinateReferenceSystem.Cartesian, Double.longBitsToDouble( 0x1L ), Double.longBitsToDouble( 0x7L ) ), Values.pointValue( CoordinateReferenceSystem.Cartesian, Double.longBitsToDouble( 0x1L ), Double.longBitsToDouble( 0x1L ), Double.longBitsToDouble( 0x4L ) )}; Collection<DynamicRecord> records = new ArrayList<>(); arrayStore.allocateRecords( records, array ); }
@Test( expected = IllegalArgumentException.class ) public void pointArraysOfMixedCRS() { PointValue[] array = new PointValue[]{ Values.pointValue( CoordinateReferenceSystem.Cartesian, Double.longBitsToDouble( 0x1L ), Double.longBitsToDouble( 0x7L ) ), Values.pointValue( CoordinateReferenceSystem.WGS84, Double.longBitsToDouble( 0x1L ), Double.longBitsToDouble( 0x1L ) )}; Collection<DynamicRecord> records = new ArrayList<>(); arrayStore.allocateRecords( records, array ); }
@Test public void testStoreGetCharsFromString() { final String STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; DynamicArrayStore store = createDynamicArrayStore(); char[] chars = new char[STR.length()]; STR.getChars( 0, STR.length(), chars, 0 ); Collection<DynamicRecord> records = new ArrayList<>(); store.allocateRecords( records, chars ); for ( DynamicRecord record : records ) { store.updateRecord( record ); } // assertEquals( STR, new String( store.getChars( blockId ) ) ); }
private long create( DynamicArrayStore store, Object arrayToStore ) { Collection<DynamicRecord> records = new ArrayList<>(); store.allocateRecords( records, arrayToStore ); for ( DynamicRecord record : records ) { store.updateRecord( record ); } return Iterables.first( records ).getId(); }
@Test public void stringArrayGetsStoredAsUtf8() { String[] array = new String[] { "first", "second" }; Collection<DynamicRecord> records = new ArrayList<>(); arrayStore.allocateRecords( records, array ); Pair<byte[], byte[]> loaded = loadArray( records ); assertStringHeader( loaded.first(), array.length ); ByteBuffer buffer = ByteBuffer.wrap( loaded.other() ); for ( String item : array ) { byte[] expectedData = UTF8.encode( item ); assertEquals( expectedData.length, buffer.getInt() ); byte[] loadedItem = new byte[expectedData.length]; buffer.get( loadedItem ); assertTrue( Arrays.equals( expectedData, loadedItem ) ); } }
store.allocateRecords( records, bytes ); for ( DynamicRecord record : records )
private void assertPointArrayHasCorrectFormat( PointValue[] array, int numberOfBitsUsedForDoubles ) { Collection<DynamicRecord> records = new ArrayList<>(); arrayStore.allocateRecords( records, array ); Pair<byte[],byte[]> loaded = loadArray( records ); assertGeometryHeader( loaded.first(), GeometryType.GEOMETRY_POINT.getGtype(), 2, array[0].getCoordinateReferenceSystem().getTable().getTableId(), array[0].getCoordinateReferenceSystem().getCode() ); final int dimension = array[0].coordinate().length; double[] pointDoubles = new double[array.length * dimension]; for ( int i = 0; i < pointDoubles.length; i++ ) { pointDoubles[i] = array[i / dimension].coordinate()[i % dimension]; } byte[] doubleHeader = Arrays.copyOf( loaded.other(), DynamicArrayStore.NUMBER_HEADER_SIZE ); byte[] doubleBody = Arrays.copyOfRange( loaded.other(), DynamicArrayStore.NUMBER_HEADER_SIZE, loaded.other().length ); assertNumericArrayHeaderAndContent( pointDoubles, PropertyType.DOUBLE, numberOfBitsUsedForDoubles, Pair.of( doubleHeader, doubleBody ) ); }
private static void allocateArrayRecords( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator allocator, boolean allowStorePoints ) { DynamicArrayStore.allocateRecords( target, array, allocator, allowStorePoints ); }
public void allocateRecords( Collection<DynamicRecord> target, Object array ) { allocateRecords( target, array, this, allowStorePointsAndTemporal ); }
public static Collection<DynamicRecord> allocateRecordsForDynamicLabels( long nodeId, long[] labels, DynamicRecordAllocator allocator ) { long[] storedLongs = LabelIdArray.prependNodeId( nodeId, labels ); Collection<DynamicRecord> records = new ArrayList<>(); // since we can't store points in long array we passing false as possibility to store points DynamicArrayStore.allocateRecords( records, storedLongs, allocator, false ); return records; }