@Override protected DoubleOutputStream createValueOutputStream() { return new DoubleOutputStream(SNAPPY, COMPRESSION_BLOCK_SIZE); }
@Override protected void writeValue(DoubleOutputStream outputStream, Double value) { outputStream.writeDouble(value); }
@Override public void close() { closed = true; dataStream.close(); presentStream.close(); }
@Override public void beginRowGroup() { presentStream.recordCheckpoint(); dataStream.recordCheckpoint(); }
@Override public void reset() { closed = false; dataStream.reset(); presentStream.reset(); rowGroupColumnStatistics.clear(); statisticsBuilder = new DoubleStatisticsBuilder(); } }
@Override public long getRetainedBytes() { long retainedBytes = INSTANCE_SIZE + dataStream.getRetainedBytes() + presentStream.getRetainedBytes(); for (ColumnStatistics statistics : rowGroupColumnStatistics) { retainedBytes += statistics.getRetainedSizeInBytes(); } return retainedBytes; }
@Override public List<StreamDataOutput> getDataStreams() { checkState(closed); ImmutableList.Builder<StreamDataOutput> outputDataStreams = ImmutableList.builder(); presentStream.getStreamDataOutput(column).ifPresent(outputDataStreams::add); outputDataStreams.add(dataStream.getStreamDataOutput(column)); return outputDataStreams.build(); }
@Override public long getBufferedBytes() { return dataStream.getBufferedBytes() + presentStream.getBufferedBytes(); }
@Override public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException { checkState(closed); ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder(); List<DoubleStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints(); Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints(); for (int i = 0; i < rowGroupColumnStatistics.size(); i++) { int groupId = i; ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId); DoubleStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId); Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId)); List<Integer> positions = createDoubleColumnPositionList(compressed, dataCheckpoint, presentCheckpoint); rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics)); } Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build()); Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false); return ImmutableList.of(new StreamDataOutput(slice, stream)); }
@Override public void beginRowGroup() { presentStream.recordCheckpoint(); dataStream.recordCheckpoint(); }
@Override public void reset() { closed = false; dataStream.reset(); presentStream.reset(); rowGroupColumnStatistics.clear(); statisticsBuilder = new DoubleStatisticsBuilder(); } }
@Override public long getRetainedBytes() { long retainedBytes = INSTANCE_SIZE + dataStream.getRetainedBytes() + presentStream.getRetainedBytes(); for (ColumnStatistics statistics : rowGroupColumnStatistics) { retainedBytes += statistics.getRetainedSizeInBytes(); } return retainedBytes; }
@Override public List<StreamDataOutput> getDataStreams() { checkState(closed); ImmutableList.Builder<StreamDataOutput> outputDataStreams = ImmutableList.builder(); presentStream.getStreamDataOutput(column).ifPresent(outputDataStreams::add); outputDataStreams.add(dataStream.getStreamDataOutput(column)); return outputDataStreams.build(); }
@Override public long getBufferedBytes() { return dataStream.getBufferedBytes() + presentStream.getBufferedBytes(); }
@Override public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException { checkState(closed); ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder(); List<DoubleStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints(); Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints(); for (int i = 0; i < rowGroupColumnStatistics.size(); i++) { int groupId = i; ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId); DoubleStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId); Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId)); List<Integer> positions = createDoubleColumnPositionList(compressed, dataCheckpoint, presentCheckpoint); rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics)); } Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build()); Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false); return ImmutableList.of(new StreamDataOutput(slice, stream)); }
@Override public void writeBlock(Block block) { checkState(!closed); checkArgument(block.getPositionCount() > 0, "Block is empty"); // record nulls for (int position = 0; position < block.getPositionCount(); position++) { presentStream.writeBoolean(!block.isNull(position)); } // record values for (int position = 0; position < block.getPositionCount(); position++) { if (!block.isNull(position)) { double value = type.getDouble(block, position); statisticsBuilder.addValue(value); dataStream.writeDouble(value); } } }
public DoubleColumnWriter(int column, Type type, CompressionKind compression, int bufferSize) { checkArgument(column >= 0, "column is negative"); this.column = column; this.type = requireNonNull(type, "type is null"); this.compressed = requireNonNull(compression, "compression is null") != NONE; this.dataStream = new DoubleOutputStream(compression, bufferSize); this.presentStream = new PresentOutputStream(compression, bufferSize); }
@Override public void close() { closed = true; dataStream.close(); presentStream.close(); }
@Override protected void writeValue(DoubleOutputStream outputStream, Double value) { outputStream.writeDouble(value); }
public DoubleColumnWriter(int column, Type type, CompressionKind compression, int bufferSize) { checkArgument(column >= 0, "column is negative"); this.column = column; this.type = requireNonNull(type, "type is null"); this.compressed = requireNonNull(compression, "compression is null") != NONE; this.dataStream = new DoubleOutputStream(compression, bufferSize); this.presentStream = new PresentOutputStream(compression, bufferSize); }