private static IntArray readIntArray( ByteBuffer bb, int offset ) { final int len = bb.getInt( offset ); offset += Integer.BYTES; final int[] array = new int[len]; for ( int i = 0; i < len; i++ ) { array[i] = bb.getInt( offset ); offset += Integer.BYTES; } return intArray( array ); }
@Override public ArrayValue createArray( int length, Bits bits, int requiredBits ) { if ( length == 0 ) { return Values.EMPTY_INT_ARRAY; } final int[] result = new int[length]; for ( int i = 0; i < length; i++ ) { result[i] = bits.getInt( requiredBits ); } return Values.intArray( result ); }
/** * @see RandomValues */ public IntArray nextIntArray() { int[] array = nextIntArrayRaw( minArray(), maxArray() ); return Values.intArray( array ); }
public static Test shouldNotMatch( int[] propertyValue, Object value ) { return new Test( Values.intArray( propertyValue ), value, false ); }
private static Test shouldMatch( int[] propertyValue, Object value ) { return new Test( Values.intArray( propertyValue ), value, true ); }
return Values.intArray( intArray ); case RawBits.LONG: return Values.longArray( Arrays.copyOf( state.long0Array, state.arrayLength ) );
@Test void shouldProvideDirectIntArrayAsPublic() { int[] inStore = {1}; Value value = Values.intArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return int[]" ); int[] arr = (int[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = -1; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (int[])value.asObjectCopy() ), "should still generate inStore array" ); }
list( booleanArray( new boolean[]{true, false} ), intArray( new int[]{1, 2} ), stringArray( "Hello", "World" ) ), list( booleanArray( new boolean[]{true, false} ), intArray( new int[]{1, 2} ), stringArray( "Hello", "World" ) ) ); list( booleanArray( new boolean[]{true, false} ), intArray( new int[]{5, 2} ), stringArray( "Hello", "World" ) ), list( booleanArray( new boolean[]{true, false} ), intArray( new int[]{1, 2} ), stringArray( "Hello", "World" ) ) ); intArray( new int[]{1, 2} ), booleanArray( new boolean[]{true, false} ), stringArray( "Hello", "World" ) ), list( booleanArray( new boolean[]{true, false} ), intArray( new int[]{1, 2} ), stringArray( "Hello", "World" ) ) );
return intArray( ((int[]) value).clone() );
return intArray( copy( value, new int[value.length] ) );
assertEqualValues( list(), doubleArray( new double[]{} ) ); assertEqualValues( list(), floatArray( new float[]{} ) ); assertEqualValues( list(), intArray( new int[]{} ) ); assertEqualValues( list(), longArray( new long[]{} ) ); assertEqualValues( list(), shortArray( new short[]{} ) ); assertEqualValues( list( 1.5f ), floatArray( new float[]{1.5f} ) ); assertEqualValues( list( 1.5f, -5f ), floatArray( new float[]{1.5f, -5f} ) ); assertEqualValues( list( 1 ), intArray( new int[]{1} ) ); assertEqualValues( list( 1, -3 ), intArray( new int[]{1, -3} ) ); assertEqualValues( list( 2L ), longArray( new long[]{2L} ) ); assertEqualValues( list( 2L, -3L ), longArray( new long[]{2L, -3L} ) );
assertEqual( byteArray( new byte[]{} ), byteArray( new byte[]{} ) ); assertEqual( shortArray( new short[]{} ), shortArray( new short[]{} ) ); assertEqual( intArray( new int[]{} ), intArray( new int[]{} ) ); assertEqual( longArray( new long[]{} ), longArray( new long[]{} ) ); assertEqual( floatArray( new float[]{} ), floatArray( new float[]{} ) ); assertEqual( byteArray( new byte[]{1} ), byteArray( new byte[]{1} ) ); assertEqual( shortArray( new short[]{1} ), shortArray( new short[]{1} ) ); assertEqual( intArray( new int[]{1} ), intArray( new int[]{1} ) ); assertEqual( longArray( new long[]{1} ), longArray( new long[]{1} ) ); assertEqual( floatArray( new float[]{1.0f} ), floatArray( new float[]{1.0f} ) );
list( intArray( new int[]{3, 4, 50} ) ) ); assertNotEqual( list( true, true ), intArray( new int[]{0, 0} ) ); assertNotEqual( list( true, true ), longArray( new long[]{0L, 0L} ) ); assertNotEqual( list( true, true ), shortArray( new short[]{(short) 0, (short) 0} ) ); assertNotEqual( list( 1.5f ), floatArray( new float[]{1.5f, -5f} ) ); assertNotEqual( list( 1.5f, 5f ), floatArray( new float[]{1.5f, -5f} ) ); assertNotEqual( list( 1, 3 ), intArray( new int[]{1, -3} ) ); assertNotEqual( list( -3 ), intArray( new int[]{1, -3} ) ); assertNotEqual( list( 2L, 3L ), longArray( new long[]{2L, -3L} ) ); assertNotEqual( list( 2L ), longArray( new long[]{2L, -3L} ) );
shortArray( new short[] {1337, (short) 0xcafe, (short) 0xbabe} ), intValue( 987654321 ), intArray( new int[] {42, 11} ), longValue( 9876543210L ), longArray( new long[] {0xcafebabe, 0x1ee7} ),
private static IntArray readIntArray( ByteBuffer bb, int offset ) { final int len = bb.getInt( offset ); offset += Integer.BYTES; final int[] array = new int[len]; for ( int i = 0; i < len; i++ ) { array[i] = bb.getInt( offset ); offset += Integer.BYTES; } return intArray( array ); }
@Override public ArrayValue createArray( int length, Bits bits, int requiredBits ) { if ( length == 0 ) { return Values.EMPTY_INT_ARRAY; } final int[] result = new int[length]; for ( int i = 0; i < length; i++ ) { result[i] = bits.getInt( requiredBits ); } return Values.intArray( result ); }
/** * @see RandomValues */ public IntArray nextIntArray() { int[] array = nextIntArrayRaw( minArray(), maxArray() ); return Values.intArray( array ); }
return Values.intArray( intArray ); case RawBits.LONG: return Values.longArray( Arrays.copyOf( state.long0Array, state.arrayLength ) );
@Override public void run() { acceptInTransaction(statement -> { final Write dataWriteOperations = statement.dataWrite(); for(PrimitiveIntIterator it = iterable.iterator(); it.hasNext(); ) { final int id = it.next(); // build int array final int[] data = new int[communities.length]; for (int i = 0; i < data.length; i++) { try { data[i] = communities[i][id]; } catch (Exception e) { throw e; // TODO } } dataWriteOperations.nodeSetProperty( mapping.toOriginalNodeId(id), propertyId, Values.intArray(data)); } }); } }
private void writeEverything() { acceptInTransaction(statement -> { final Write dataWriteOperations = statement.dataWrite(); for(PrimitiveIntIterator it = iterable.iterator(); it.hasNext(); ) { final int id = it.next(); // build int array final int[] data = new int[allCommunities.length]; for (int i = 0; i < data.length; i++) { try { data[i] = allCommunities[i][id]; } catch (Exception e) { throw e; // TODO } } dataWriteOperations.nodeSetProperty( mapping.toOriginalNodeId(id), propertyId, Values.intValue(finalCommunities[id])); dataWriteOperations.nodeSetProperty( mapping.toOriginalNodeId(id), intermediateCommunitiesPropertyId, Values.intArray(data)); } }); }