@Override public VSizeColumnarInts apply(int[] input) { return VSizeColumnarInts.fromArray(input, 20); } }
public static VSizeColumnarInts fromArray(int[] array) { return fromArray(array, Ints.max(array)); }
Iterables.transform(rows, (Function<int[], ColumnarInts>) input -> VSizeColumnarInts.fromArray(input, 20)), bound - 1, ByteOrder.nativeOrder(), VSizeColumnarMultiInts.fromIterable(Iterables.transform(rows, input -> VSizeColumnarInts.fromArray(input, 20))) ); this.uncompressed = VSizeColumnarMultiInts.readFromByteBuffer(bufferUncompressed);
@Parameterized.Parameters public static Collection<?> constructorFeeder() { return Arrays.asList( new Object[][]{ {VSizeColumnarInts.fromArray(array)}, {new ArrayBasedIndexedInts(array)} } ); }
).get(); final ByteBuffer bufferUncompressed = serialize(VSizeColumnarInts.fromArray(vals)); this.uncompressed = VSizeColumnarInts.readFromByteBuffer(bufferUncompressed);
@Before public void setUpSimple() { closer = Closer.create(); vals = Arrays.asList( new int[1], new int[]{1, 2, 3, 4, 5}, new int[]{6, 7, 8, 9, 10}, new int[]{11, 12, 13, 14, 15, 16, 17, 18, 19, 20} ); columnarMultiIntsSupplier = CompressedVSizeColumnarMultiIntsSupplier.fromIterable( Iterables.transform(vals, input -> VSizeColumnarInts.fromArray(input, 20)), 20, ByteOrder.nativeOrder(), CompressionStrategy.LZ4, closer ); }
@Override @Before public void setUpSimple() { vals = Arrays.asList( new int[1], new int[]{1, 2, 3, 4, 5}, new int[]{6, 7, 8, 9, 10}, new int[]{11, 12, 13, 14, 15, 16, 17, 18, 19, 20} ); closer = Closer.create(); columnarMultiIntsSupplier = V3CompressedVSizeColumnarMultiIntsSupplier.fromIterable( Iterables.transform(vals, (Function<int[], ColumnarInts>) input -> VSizeColumnarInts.fromArray(input, 20)), 2, 20, ByteOrder.nativeOrder(), CompressionStrategy.LZ4, closer ); }
@Test public void testSerialization() throws Exception { final int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; VSizeColumnarInts ints = VSizeColumnarInts.fromArray(array); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ints.writeTo(Channels.newChannel(baos), null); final byte[] bytes = baos.toByteArray(); Assert.assertEquals(ints.getSerializedSize(), bytes.length); VSizeColumnarInts deserialized = VSizeColumnarInts.readFromByteBuffer(ByteBuffer.wrap(bytes)); Assert.assertEquals(1, deserialized.getNumBytes()); Assert.assertEquals(array.length, deserialized.size()); for (int i = 0; i < array.length; i++) { Assert.assertEquals(array[i], deserialized.get(i)); } } }
@Test public void testSanity() { final int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; VSizeColumnarInts ints = VSizeColumnarInts.fromArray(array); Assert.assertEquals(1, ints.getNumBytes()); Assert.assertEquals(array.length, ints.size()); for (int i = 0; i < array.length; i++) { Assert.assertEquals(array[i], ints.get(i)); } }
public static VSizeColumnarInts fromArray(int[] array) { return fromArray(array, Ints.max(array)); }