orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omalley <...@git.apache.org>
Subject [GitHub] orc pull request #60: ORC-101 fix broken encoding for string and decimal blo...
Date Fri, 16 Sep 2016 03:19:32 GMT
Github user omalley commented on a diff in the pull request:

    https://github.com/apache/orc/pull/60#discussion_r79101377
  
    --- Diff: java/core/src/java/org/apache/orc/util/BloomFilterIO.java ---
    @@ -0,0 +1,71 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.orc.util;
    +
    +import org.apache.orc.OrcProto;
    +
    +public class BloomFilterIO  {
    +
    +  private BloomFilterIO() {
    +    // never called
    +  }
    +
    +  /**
    +   * Deserialize a bloom filter from the ORC file.
    +   */
    +  public static BloomFilter deserialize(OrcProto.Stream.Kind kind,
    +                                        OrcProto.BloomFilter bloomFilter) {
    +    if (bloomFilter == null) {
    +      return null;
    +    }
    +    long values[] = new long[bloomFilter.getBitsetCount()];
    +    for(int i=0; i < values.length; ++i) {
    +      values[i] = bloomFilter.getBitset(i);
    +    }
    +    int numFuncs = bloomFilter.getNumHashFunctions();
    +    switch (kind) {
    +      case BLOOM_FILTER:
    +        return new BloomFilter(values, numFuncs);
    +      case BLOOM_FILTER_UTF8:
    +        return new BloomFilterUtf8(values, numFuncs);
    +    }
    +    throw new IllegalArgumentException("Unknown bloom filter kind " + kind);
    +  }
    +
    +  /**
    +   * Serialize the BloomFilter to the ORC file.
    +   * @param builder the builder to write to
    +   * @param bloomFilter the bloom filter to serialize
    +   */
    +  public static void serialize(OrcProto.BloomFilter.Builder builder,
    +                               BloomFilter bloomFilter) {
    +    long[] bitset = bloomFilter.getBitSet();
    +    if (builder.getBitsetCount() != bitset.length) {
    +      builder.clear();
    +      for(int i=0; i < bitset.length; ++i) {
    +        builder.addBitset(bitset[i]);
    --- End diff --
    
    We'd need to change the protobuf, which won't be backwards compatible. I guess we could
do that for the new bloom_filter_utf8 stream.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message