use of io.trino.orc.protobuf.ByteString in project trino by trinodb.
the class OrcMetadataReader method readBloomFilterIndexes.
@Override
public List<BloomFilter> readBloomFilterIndexes(InputStream inputStream) throws IOException {
CodedInputStream input = CodedInputStream.newInstance(inputStream);
OrcProto.BloomFilterIndex bloomFilter = OrcProto.BloomFilterIndex.parseFrom(input);
List<OrcProto.BloomFilter> bloomFilterList = bloomFilter.getBloomFilterList();
ImmutableList.Builder<BloomFilter> builder = ImmutableList.builder();
for (OrcProto.BloomFilter orcBloomFilter : bloomFilterList) {
if (orcBloomFilter.hasUtf8Bitset()) {
ByteString utf8Bitset = orcBloomFilter.getUtf8Bitset();
long[] bits = new long[utf8Bitset.size() / 8];
utf8Bitset.asReadOnlyByteBuffer().order(ByteOrder.LITTLE_ENDIAN).asLongBuffer().get(bits);
builder.add(new BloomFilter(bits, orcBloomFilter.getNumHashFunctions()));
} else {
builder.add(new BloomFilter(Longs.toArray(orcBloomFilter.getBitsetList()), orcBloomFilter.getNumHashFunctions()));
}
}
return builder.build();
}
Aggregations