use of org.apache.parquet.internal.column.columnindex.OffsetIndexBuilder in project parquet-mr by apache.
the class TestRowRanges method buildRanges.
private static RowRanges buildRanges(long... rowIndexes) {
if (rowIndexes.length == 0) {
return RowRanges.EMPTY;
}
OffsetIndexBuilder builder = OffsetIndexBuilder.getBuilder();
for (int i = 0, n = rowIndexes.length; i < n; i += 2) {
long from = rowIndexes[i];
long to = rowIndexes[i + 1];
builder.add(0, 0, from);
builder.add(0, 0, to + 1);
}
PrimitiveIterator.OfInt pageIndexes = new PrimitiveIterator.OfInt() {
private int index = 0;
@Override
public boolean hasNext() {
return index < rowIndexes.length;
}
@Override
public int nextInt() {
int ret = index;
index += 2;
return ret;
}
};
return RowRanges.create(rowIndexes[rowIndexes.length - 1], pageIndexes, builder.build());
}
use of org.apache.parquet.internal.column.columnindex.OffsetIndexBuilder in project parquet-mr by apache.
the class TestParquetMetadataConverter method testOffsetIndexConversion.
@Test
public void testOffsetIndexConversion() {
OffsetIndexBuilder builder = OffsetIndexBuilder.getBuilder();
builder.add(1000, 10000, 0);
builder.add(22000, 12000, 100);
OffsetIndex offsetIndex = ParquetMetadataConverter.fromParquetOffsetIndex(ParquetMetadataConverter.toParquetOffsetIndex(builder.build(100000)));
assertEquals(2, offsetIndex.getPageCount());
assertEquals(101000, offsetIndex.getOffset(0));
assertEquals(10000, offsetIndex.getCompressedPageSize(0));
assertEquals(0, offsetIndex.getFirstRowIndex(0));
assertEquals(122000, offsetIndex.getOffset(1));
assertEquals(12000, offsetIndex.getCompressedPageSize(1));
assertEquals(100, offsetIndex.getFirstRowIndex(1));
}
Aggregations