private void initializeCapacity() { if (positionCount != 0 || currentEntrySize != 0) { throw new IllegalStateException(getClass().getSimpleName() + " was used before initialization"); } int initialSliceOutputSize = (int) Math.min((long) fixedSize * initialEntryCount, MAX_ARRAY_SIZE); sliceOutput = new DynamicSliceOutput(initialSliceOutputSize); valueIsNull = new DynamicSliceOutput(initialEntryCount); initialized = true; }
private void initializeCapacity() { if (positions != 0 || currentEntrySize != 0) { throw new IllegalStateException(getClass().getSimpleName() + " was used before initialization"); } initialized = true; valueIsNull = new boolean[initialEntryCount]; offsets = new int[initialEntryCount + 1]; sliceOutput = new DynamicSliceOutput(initialSliceOutputSize); updateArraysDataSize(); }
/** * Serialize JTS {@link Geometry} shape into an ESRI shape */ public static Slice serialize(Geometry geometry) { requireNonNull(geometry, "input is null"); DynamicSliceOutput output = new DynamicSliceOutput(100); writeGeometry(geometry, output); return output.slice(); }
public static Slice serialize(OGCGeometry input) { requireNonNull(input, "input is null"); DynamicSliceOutput output = new DynamicSliceOutput(100); writeGeometry(output, input); return output.slice(); }
@Override public void serialize(Block block, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { SliceOutput output = new DynamicSliceOutput(64); writeBlock(blockEncodingSerde, output, block); String encoded = Base64.getEncoder().encodeToString(output.slice().getBytes()); jsonGenerator.writeString(encoded); } }
public Slice writePostscript(int footerLength, int metadataLength, CompressionKind compression, int compressionBlockSize) throws IOException { // postscript is not compressed DynamicSliceOutput output = new DynamicSliceOutput(64); metadataWriter.writePostscript(output, footerLength, metadataLength, compression, compressionBlockSize); return output.slice(); }
private Slice getSliceOutput() { buffer.close(); DynamicSliceOutput output = new DynamicSliceOutput(toIntExact(buffer.getOutputDataSize())); buffer.writeDataTo(output); Slice slice = output.slice(); buffer.reset(); return slice; } }
@Test public void testNoStartSync() throws Exception { SliceOutput output = new DynamicSliceOutput(10 * 1024); List<Segment> segments = ImmutableList.of( writeSegment(output, ImmutableList.of(ImmutableList.of(0, 2, 3, 4), ImmutableList.of(10, 12, 13))), writeSegment(output, ImmutableList.of(ImmutableList.of(20, 22), ImmutableList.of(30, 33), ImmutableList.of(40, 44))), writeSegment(output, ImmutableList.of(ImmutableList.of(100, 101, 102)))); assertFileSegments(output.slice(), segments); }
@Test public void testStartSync() throws Exception { SliceOutput output = new DynamicSliceOutput(10 * 1024); List<Segment> segments = ImmutableList.of( writeSegment(output, ImmutableList.of()), writeSegment(output, ImmutableList.of(ImmutableList.of(0, 2, 3, 4), ImmutableList.of(10, 12, 13))), writeSegment(output, ImmutableList.of(ImmutableList.of(20, 22), ImmutableList.of(30, 33), ImmutableList.of(40, 44))), writeSegment(output, ImmutableList.of(ImmutableList.of(100, 101, 102)))); assertFileSegments(output.slice(), segments); }
@Override public void serialize(Block block, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { SliceOutput output = new DynamicSliceOutput(64); blockEncodingSerde.writeBlock(output, block); String encoded = Base64.getEncoder().encodeToString(output.slice().getBytes()); jsonGenerator.writeString(encoded); } }
private Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(blockEncodingSerde, sliceOutput, block); return sliceOutput.slice(); }
protected static Slice createExpectedValue(int length) { DynamicSliceOutput dynamicSliceOutput = new DynamicSliceOutput(16); for (int index = 0; index < length; index++) { dynamicSliceOutput.writeByte(length * (index + 1)); } return dynamicSliceOutput.slice(); }
private Slice blockToSlice(Block block) { // This function is strictly for testing use only SliceOutput sliceOutput = new DynamicSliceOutput(1000); BlockSerdeUtil.writeBlock(blockEncodingSerde, sliceOutput, block); return sliceOutput.slice(); }
private static Slice createExpectedValue(int length) { DynamicSliceOutput dynamicSliceOutput = new DynamicSliceOutput(16); for (int index = 0; index < length; index++) { dynamicSliceOutput.writeByte(length * (index + 1)); } return dynamicSliceOutput.slice(); } }
private static Slice createGreaterValue(Slice expectedValue, int offset, int length) { DynamicSliceOutput greaterOutput = new DynamicSliceOutput(length + 1); greaterOutput.writeBytes(expectedValue, offset, length); greaterOutput.writeByte('_'); return greaterOutput.slice(); }
@Test public void testRoundTrip() { DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024); writeType(sliceOutput, BOOLEAN); Type actualType = readType(new TestingTypeManager(), sliceOutput.slice().getInput()); assertEquals(actualType, BOOLEAN); } }
private static Block createVariableWidthBlock(int entries) { int[] offsets = new int[entries + 1]; DynamicSliceOutput dynamicSliceOutput = new DynamicSliceOutput(entries); for (int i = 0; i < entries; i++) { dynamicSliceOutput.writeByte(i); offsets[i + 1] = dynamicSliceOutput.size(); } return new VariableWidthBlock(entries, dynamicSliceOutput.slice(), offsets, Optional.empty()); } }
private static Block copyBlock(Block block) { DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024); BLOCK_ENCODING_SERDE.writeBlock(sliceOutput, block); return BLOCK_ENCODING_SERDE.readBlock(sliceOutput.slice().getInput()); }
private static Block copyBlockViaBlockSerde(Block block) { DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024); BLOCK_ENCODING_SERDE.writeBlock(sliceOutput, block); return BLOCK_ENCODING_SERDE.readBlock(sliceOutput.slice().getInput()); }
public static Slice serialize(Envelope envelope) { requireNonNull(envelope, "envelope is null"); verify(!envelope.isEmpty()); DynamicSliceOutput output = new DynamicSliceOutput(100); output.appendByte(GeometrySerializationType.ENVELOPE.code()); output.appendDouble(envelope.getXMin()); output.appendDouble(envelope.getYMin()); output.appendDouble(envelope.getXMax()); output.appendDouble(envelope.getYMax()); return output.slice(); }