public NumericHistogram(Slice serialized, int buffer) { requireNonNull(serialized, "serialized is null"); checkArgument(buffer >= 1, "buffer must be >= 1"); SliceInput input = serialized.getInput(); checkArgument(input.readByte() == FORMAT_TAG, "Unsupported format tag"); maxBuckets = input.readInt(); nextIndex = input.readInt(); values = new double[maxBuckets + buffer]; weights = new double[maxBuckets + buffer]; input.readBytes(Slices.wrappedDoubleArray(values), nextIndex * SizeOf.SIZE_OF_DOUBLE); input.readBytes(Slices.wrappedDoubleArray(weights), nextIndex * SizeOf.SIZE_OF_DOUBLE); }
public Slice serialize() { compact(); int requiredBytes = SizeOf.SIZE_OF_BYTE + // format SizeOf.SIZE_OF_INT + // max buckets SizeOf.SIZE_OF_INT + // entry count SizeOf.SIZE_OF_DOUBLE * nextIndex + // values SizeOf.SIZE_OF_DOUBLE * nextIndex; // weights return Slices.allocate(requiredBytes) .getOutput() .appendByte(FORMAT_TAG) .appendInt(maxBuckets) .appendInt(nextIndex) .appendBytes(Slices.wrappedDoubleArray(values, 0, nextIndex)) .appendBytes(Slices.wrappedDoubleArray(weights, 0, nextIndex)) .getUnderlyingSlice(); }
case "double": double[] doubleBase = (double[]) base; slices[i] = wrappedDoubleArray(doubleBase, 0, doubleBase.length); break; case "long":
singleState.setInt(4); singleState.setSlice(utf8Slice("test")); singleState.setAnotherSlice(wrappedDoubleArray(1.0, 2.0, 3.0)); singleState.setYetAnotherSlice(null); Block array = createLongsBlock(45);
retainedSize += slice.getRetainedSize(); groupedState.setSlice(slice); slice = wrappedDoubleArray(1.0, 2.0, 3.0); retainedSize += slice.getRetainedSize(); groupedState.setAnotherSlice(slice); retainedSize += slice.getRetainedSize(); groupedState.setSlice(slice); slice = wrappedDoubleArray(1.0, 2.0, 3.0); retainedSize += slice.getRetainedSize(); groupedState.setAnotherSlice(slice);
/** * Creates a slice over the specified array. */ public static Slice wrappedDoubleArray(double... array) { return wrappedDoubleArray(array, 0, array.length); }
/** * Creates a slice over the specified array. */ public static Slice wrappedDoubleArray(double... array) { return wrappedDoubleArray(array, 0, array.length); }
public NumericHistogram(Slice serialized, int buffer) { requireNonNull(serialized, "serialized is null"); checkArgument(buffer >= 1, "buffer must be >= 1"); SliceInput input = serialized.getInput(); checkArgument(input.readByte() == FORMAT_TAG, "Unsupported format tag"); maxBuckets = input.readInt(); nextIndex = input.readInt(); values = new double[maxBuckets + buffer]; weights = new double[maxBuckets + buffer]; input.readBytes(Slices.wrappedDoubleArray(values), nextIndex * SizeOf.SIZE_OF_DOUBLE); input.readBytes(Slices.wrappedDoubleArray(weights), nextIndex * SizeOf.SIZE_OF_DOUBLE); }
public NumericHistogram(Slice serialized, int buffer) { requireNonNull(serialized, "serialized is null"); checkArgument(buffer >= 1, "buffer must be >= 1"); SliceInput input = serialized.getInput(); checkArgument(input.readByte() == FORMAT_TAG, "Unsupported format tag"); maxBuckets = input.readInt(); nextIndex = input.readInt(); values = new double[maxBuckets + buffer]; weights = new double[maxBuckets + buffer]; input.readBytes(Slices.wrappedDoubleArray(values), nextIndex * SizeOf.SIZE_OF_DOUBLE); input.readBytes(Slices.wrappedDoubleArray(weights), nextIndex * SizeOf.SIZE_OF_DOUBLE); }
public NumericHistogram(Slice serialized, int buffer) { requireNonNull(serialized, "serialized is null"); checkArgument(buffer >= 1, "buffer must be >= 1"); SliceInput input = serialized.getInput(); checkArgument(input.readByte() == FORMAT_TAG, "Unsupported format tag"); maxBuckets = input.readInt(); nextIndex = input.readInt(); values = new double[maxBuckets + buffer]; weights = new double[maxBuckets + buffer]; input.readBytes(Slices.wrappedDoubleArray(values), nextIndex * SizeOf.SIZE_OF_DOUBLE); input.readBytes(Slices.wrappedDoubleArray(weights), nextIndex * SizeOf.SIZE_OF_DOUBLE); }
public Slice serialize() { compact(); int requiredBytes = SizeOf.SIZE_OF_BYTE + // format SizeOf.SIZE_OF_INT + // max buckets SizeOf.SIZE_OF_INT + // entry count SizeOf.SIZE_OF_DOUBLE * nextIndex + // values SizeOf.SIZE_OF_DOUBLE * nextIndex; // weights return Slices.allocate(requiredBytes) .getOutput() .appendByte(FORMAT_TAG) .appendInt(maxBuckets) .appendInt(nextIndex) .appendBytes(Slices.wrappedDoubleArray(values, 0, nextIndex)) .appendBytes(Slices.wrappedDoubleArray(weights, 0, nextIndex)) .getUnderlyingSlice(); }
public Slice serialize() { compact(); int requiredBytes = SizeOf.SIZE_OF_BYTE + // format SizeOf.SIZE_OF_INT + // max buckets SizeOf.SIZE_OF_INT + // entry count SizeOf.SIZE_OF_DOUBLE * nextIndex + // values SizeOf.SIZE_OF_DOUBLE * nextIndex; // weights return Slices.allocate(requiredBytes) .getOutput() .appendByte(FORMAT_TAG) .appendInt(maxBuckets) .appendInt(nextIndex) .appendBytes(Slices.wrappedDoubleArray(values, 0, nextIndex)) .appendBytes(Slices.wrappedDoubleArray(weights, 0, nextIndex)) .getUnderlyingSlice(); }
public Slice serialize() { compact(); int requiredBytes = SizeOf.SIZE_OF_BYTE + // format SizeOf.SIZE_OF_INT + // max buckets SizeOf.SIZE_OF_INT + // entry count SizeOf.SIZE_OF_DOUBLE * nextIndex + // values SizeOf.SIZE_OF_DOUBLE * nextIndex; // weights return Slices.allocate(requiredBytes) .getOutput() .appendByte(FORMAT_TAG) .appendInt(maxBuckets) .appendInt(nextIndex) .appendBytes(Slices.wrappedDoubleArray(values, 0, nextIndex)) .appendBytes(Slices.wrappedDoubleArray(weights, 0, nextIndex)) .getUnderlyingSlice(); }
block.setRawSlice(wrappedDoubleArray(vector));
block.setRawSlice(wrappedDoubleArray(vector));
block.setRawSlice(wrappedDoubleArray(vector));
assertEquals(wrappedDoubleArray(doubleArray).getDouble(0), doubleArray[0]); assertEquals(wrappedDoubleArray(doubleArray, 1, 4).getDouble(0), doubleArray[1]); assertEquals(wrappedDoubleArray(doubleArray, 1, 4).length(), 4 * SIZE_OF_DOUBLE); assertEquals(wrappedDoubleArray(doubleArray).getDouble(5 * SIZE_OF_DOUBLE), doubleArray[5]);
assertEquals(wrappedDoubleArray(doubleArray).getDouble(0), doubleArray[0]); assertEquals(wrappedDoubleArray(doubleArray, 1, 4).getDouble(0), doubleArray[1]); assertEquals(wrappedDoubleArray(doubleArray, 1, 4).length(), 4 * SIZE_OF_DOUBLE); assertEquals(wrappedDoubleArray(doubleArray).getDouble(5 * SIZE_OF_DOUBLE), doubleArray[5]);
singleState.setInt(4); singleState.setSlice(utf8Slice("test")); singleState.setAnotherSlice(wrappedDoubleArray(1.0, 2.0, 3.0)); singleState.setYetAnotherSlice(null); Block array = createLongsBlock(45);
singleState.setInt(4); singleState.setSlice(utf8Slice("test")); singleState.setAnotherSlice(wrappedDoubleArray(1.0, 2.0, 3.0)); singleState.setYetAnotherSlice(null); Block array = createLongsBlock(45);