Search in sources :

Example 1 with ByteString

use of io.prestosql.orc.protobuf.ByteString in project hetu-core by openlookeng.

the class OrcMetadataReader method readBloomFilterIndexes.

@Override
public List<HashableBloomFilter> 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<HashableBloomFilter> 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 HashableBloomFilter(bits, orcBloomFilter.getNumHashFunctions()));
        } else {
            builder.add(new HashableBloomFilter(Longs.toArray(orcBloomFilter.getBitsetList()), orcBloomFilter.getNumHashFunctions()));
        }
    }
    return builder.build();
}
Also used : CodedInputStream(io.prestosql.orc.protobuf.CodedInputStream) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) ByteString(io.prestosql.orc.protobuf.ByteString) OrcProto(io.prestosql.orc.proto.OrcProto) HashableBloomFilter(io.prestosql.orc.metadata.statistics.HashableBloomFilter) HashableBloomFilter(io.prestosql.orc.metadata.statistics.HashableBloomFilter)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 HashableBloomFilter (io.prestosql.orc.metadata.statistics.HashableBloomFilter)1 OrcProto (io.prestosql.orc.proto.OrcProto)1 ByteString (io.prestosql.orc.protobuf.ByteString)1 CodedInputStream (io.prestosql.orc.protobuf.CodedInputStream)1