public static String readStringFromStream(InputStream inputStream) throws IOException { int length = readIntFromStream(inputStream); byte[] bytes = new byte[length]; readFully(bytes, inputStream); return new String(bytes, Charset.forName("UTF-8")); }
public static double readDouble(byte[] bytes, int offset) { return Double.longBitsToDouble(readLong(bytes, offset)); }
return Longs.zigzagDecode(Bytes.readLongOnOneByte(buffer, offset)); return Longs.zigzagDecode(Bytes.readLongOnTwoBytes(buffer, offset)); return Longs.zigzagDecode(Bytes.readLongOnThreeBytes(buffer, offset)); return Longs.zigzagDecode(Bytes.readLongOnFourBytes(buffer, offset)); return Longs.zigzagDecode(Bytes.readLongOnFiveBytes(buffer, offset)); return Longs.zigzagDecode(Bytes.readLongOnSixBytes(buffer, offset)); return Longs.zigzagDecode(Bytes.readLongOnSevenBytes(buffer, offset)); return Longs.zigzagDecode(Bytes.readLong(buffer, offset));
private void loadNextMiniBlock() { currentIndex = 0; int bitWidth = Bytes.readInt(buffer, getAndIncrementPosition(4)); int minDelta = Bytes.readInt(buffer, getAndIncrementPosition(4)); int numValuesToRead = Bytes.readInt(buffer, getAndIncrementPosition(4)); totalValueCount -= numValuesToRead; int strideSize = Bytes.sizeInBytes(8, bitWidth); Int32BytePacker packer = Packers.LITTLE_ENDIAN.packer32(bitWidth); for (int i = 0; i < numValuesToRead; i += 8) { packer.unpack8Values(buffer, getAndIncrementPosition(strideSize), intBuffer, i); } for (int i = 0; i < numValuesToRead; i++) { intBuffer[i] += ((i == 0) ? firstValue : intBuffer[i - 1]) + minDelta; } }
private void loadNextPage() { try { currentPageHeader = new PageHeader(); currentPageHeader.setLastPage(Bytes.readBoolFromStream(inputStream)); currentPageHeader.setPageSize(Bytes.readIntFromStream(inputStream)); int mapSize = Bytes.readIntFromStream(inputStream); for (int i = 0; i < mapSize; i++) { Class<?> clazz = Class.forName(Bytes.readStringFromStream(inputStream)); int value = Bytes.readIntFromStream(inputStream); currentPageHeader.getValueToClassMap().put(value, clazz); } if (conf.isReferenceTrackingEnabled()) { context = new References.ReferenceTrackingReadContext(conf); } else { context = new Contexts.ReadContextImpl( conf ); } serializerContext.finish((Contexts.ReadContextImpl) context); recordCount = currentPageHeader.getPageSize(); context.setPageHeader(currentPageHeader); context.loadFromInputStream(inputStream); } catch (Exception e) { throw new SidneyException(e); } }
public static float readFloat(byte[] bytes, int offset) { return Float.intBitsToFloat(readInt(bytes, offset)); }
public char readChar() { require(2); return Bytes.readChar(buffer, getAndIncrementPosition(2)); }
@Override public void load(InputStream inputStream) { try { int num = Bytes.readIntFromStream(inputStream); if (num > 0) { index = 0; nextTrueBit = -1; bitmap.deserialize(new DataInputStream(inputStream)); intIterator = bitmap.intIterator(); if (intIterator.hasNext()) { nextTrueBit = intIterator.next(); } } } catch (Exception e) { throw new RuntimeException(e); } } }
private void loadNextMiniBlock() { currentIndex = 0; int bitWidth = Bytes.readInt(buffer, getAndIncrementPosition(4)); int minDelta = Bytes.readInt(buffer, getAndIncrementPosition(4)); int numValuesToRead = Bytes.readInt(buffer, getAndIncrementPosition(4)); totalValueCount -= numValuesToRead; int strideSize = Bytes.sizeInBytes(8, bitWidth); Int32BytePacker packer = Packers.LITTLE_ENDIAN.packer32(bitWidth); for (int i = 0; i < numValuesToRead; i += 8) { packer.unpack8Values(buffer, getAndIncrementPosition(strideSize), intBuffer, i); } for (int i = 0; i < numValuesToRead; i++) { intBuffer[i] += ((i == 0) ? firstValue : intBuffer[i - 1]) + minDelta; } }
public int readInt() { require(4); return Bytes.readInt(buffer, getAndIncrementPosition(4)); }
@Override public void load(InputStream inputStream) { try { currentIndex = 0; isFirstValue = true; position = 0; totalValueCount = readIntFromStream(inputStream); firstValue = readIntFromStream(inputStream); if (totalValueCount <= 1) { return; } int size = readIntFromStream(inputStream); resizeIfNecessary(size); Bytes.readFully(buffer, inputStream, size); loadNextMiniBlock(); } catch (Exception e) { throw new RuntimeException(e); } }
private void loadNextMiniBlock() { currentIndex = 0; int bitWidth = Bytes.readInt(buffer, getAndIncrementPosition(4)); int minDelta = Bytes.readInt(buffer, getAndIncrementPosition(4)); int numValuesToRead = Bytes.readInt(buffer, getAndIncrementPosition(4)); totalValueCount -= numValuesToRead; int strideSize = Bytes.sizeInBytes(8, bitWidth); Int32BytePacker packer = Packers.LITTLE_ENDIAN.packer32(bitWidth); for (int i = 0; i < numValuesToRead; i += 8) { packer.unpack8Values(buffer, getAndIncrementPosition(strideSize), intBuffer, i); } for (int i = 0; i < numValuesToRead; i++) { intBuffer[i] += ((i == 0) ? firstValue : intBuffer[i - 1]) + minDelta; } }
public long readLong() { require(8); return Bytes.readLong(buffer, getAndIncrementPosition(8)); }
@Override public void load(InputStream inputStream) { try { currentIndex = 0; isFirstValue = true; position = 0; totalValueCount = readIntFromStream(inputStream); firstValue = readIntFromStream(inputStream); if (totalValueCount <= 1) { return; } int size = readIntFromStream(inputStream); resizeIfNecessary(size); Bytes.readFully(buffer, inputStream, size); loadNextMiniBlock(); } catch (Exception e) { throw new RuntimeException(e); } }
private void loadNextMiniBlock() { currentIndex = 0; require(8); int numValuesToRead = Bytes.readInt(buffer, getAndIncrementPosition(4)); int bitWidth = Bytes.readInt(buffer, getAndIncrementPosition(4)); if (numValuesToRead > 0) { int strideSize = Bytes.sizeInBytes(8, bitWidth); Int32BytePacker packer = Packers.LITTLE_ENDIAN.packer32(bitWidth); for (int i = 0; i < numValuesToRead; i += 8) { packer.unpack8Values(buffer, getAndIncrementPosition(strideSize), currentMiniBlock, i); } } }
@Override public void load(InputStream inputStream) { try { currentIndex = 0; isFirstValue = true; position = 0; totalValueCount = readIntFromStream(inputStream); firstValue = readIntFromStream(inputStream); if (totalValueCount <= 1) { return; } int size = readIntFromStream(inputStream); resizeIfNecessary(size); Bytes.readFully(buffer, inputStream, size); loadNextMiniBlock(); } catch (Exception e) { throw new RuntimeException(e); } }
private void loadNextMiniBlock() { currentIndex = 0; require(8); int numValuesToRead = Bytes.readInt(buffer, getAndIncrementPosition(4)); int bitWidth = Bytes.readInt(buffer, getAndIncrementPosition(4)); if (numValuesToRead > 0) { int strideSize = Bytes.sizeInBytes(8, bitWidth); Int32BytePacker packer = Packers.LITTLE_ENDIAN.packer32(bitWidth); for (int i = 0; i < numValuesToRead; i += 8) { packer.unpack8Values(buffer, getAndIncrementPosition(strideSize), currentMiniBlock, i); } } }
public void initialize(InputStream inputStream) { try { setPosition(0); int size = Bytes.readIntFromStream(inputStream); resizeIfNecessary(size); Bytes.readFully(buffer, inputStream, size); } catch (Exception e) { throw new RuntimeException(e); } }
private void loadNextMiniBlock() { currentIndex = 0; require(8); int numValuesToRead = Bytes.readInt(buffer, getAndIncrementPosition(4)); int bitWidth = Bytes.readInt(buffer, getAndIncrementPosition(4)); if (numValuesToRead > 0) { int strideSize = Bytes.sizeInBytes(8, bitWidth); Int32BytePacker packer = Packers.LITTLE_ENDIAN.packer32(bitWidth); for (int i = 0; i < numValuesToRead; i += 8) { packer.unpack8Values(buffer, getAndIncrementPosition(strideSize), currentMiniBlock, i); } } }