<commit_before>// Copyright 2011 Google Inc. All Rights Reserved.

package com.google.common.hash;

import static com.google.common.base.Preconditions.checkArgument;

import java.io.Serializable;
import java.nio.ByteBuffer;

/**
 * Collections of strategies of generating the {@code k * log(M)} bits required for an element to
 * be mapped to a {@link BloomFilter} of {@code M} bits and {@code k} hash functions. These
 * strategies are part of the serialized form of the Bloom filters that use them, thus they must be
 * preserved as is (no updates allowed, only introduction of new versions).
 * 
 * @author <EMAIL> (<NAME>)
 */
final class BloomFilterStrategies {
  private BloomFilterStrategies() {}
  
  /**
   * See "Less Hashing, Same Performance: Building a Better Bloom Filter" by <NAME> and 
   * <NAME>. The paper argues that this trick doesn't significantly deteriorate the 
   * performance of a Bloom filter (yet only needs two 32bit hash functions).
   */
  static class From128ToN extends AbstractCompositeHashFunction implements Serializable {
    private final int bits;
    private final HashFunction hashFunction;
    
    private From128ToN(int longs, HashFunction hashFunction) {
      super(hashFunction);
      this.hashFunction = hashFunction;
      this.bits = longs;
    }
    
    static From128ToN withBits(int bits, HashFunction hashFunction) {
      return new From128ToN(checkPositiveAndMakeMultipleOf64(bits), hashFunction);
    }
    
    @Override
    HashCode makeHash(Hasher[] hashers) {
      ByteBuffer buf = ByteBuffer.wrap(hashers[0].hash().asBytes());
      long hash1 = buf.getLong();
      long hash2 = buf.getLong();
      return compose64(hash1, hash2, bits);
    }

    @Override
    public int bits() {
      return bits;
    }
    
    private Object writeReplace() {
      return new SerialForm(this);
    }
    
    private static class SerialForm implements Serializable {<commit_msg>Typo ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=26568675<commit_after>// Copyright 2011 Google Inc. All Rights Reserved.

package com.google.common.hash;

import static com.google.common.base.Preconditions.checkArgument;

import java.io.Serializable;
import java.nio.ByteBuffer;

/**
 * Collections of strategies of generating the {@code k * log(M)} bits required for an element to
 * be mapped to a {@link BloomFilter} of {@code M} bits and {@code k} hash functions. These
 * strategies are part of the serialized form of the Bloom filters that use them, thus they must be
 * preserved as is (no updates allowed, only introduction of new versions).
 * 
 * @author <EMAIL> (<NAME>)
 */
final class BloomFilterStrategies {
  private BloomFilterStrategies() {}
  
  /**
   * See "Less Hashing, Same Performance: Building a Better Bloom Filter" by <NAME> and 
   * <NAME>. The paper argues that this trick doesn't significantly deteriorate the 
   * performance of a Bloom filter (yet only needs two 32bit hash functions).
   */
  static class From128ToN extends AbstractCompositeHashFunction implements Serializable {
    private final int bits;
    private final HashFunction hashFunction;
    
    private From128ToN(int bits, HashFunction hashFunction) {
      super(hashFunction);
      this.hashFunction = hashFunction;
      this.bits = bits;
    }
    
    static From128ToN withBits(int bits, HashFunction hashFunction) {
      return new From128ToN(checkPositiveAndMakeMultipleOf64(bits), hashFunction);
    }
    
    @Override
    HashCode makeHash(Hasher[] hashers) {
      ByteBuffer buf = ByteBuffer.wrap(hashers[0].hash().asBytes());
      long hash1 = buf.getLong();
      long hash2 = buf.getLong();
      return compose64(hash1, hash2, bits);
    }

    @Override
    public int bits() {
      return bits;
    }
    
    private Object writeReplace() {
      return new SerialForm(this);
    }
    
    private static class SerialForm implements Serializable {
{'fraction_non_alphanumeric': 0.08929926637996459, 'fraction_numerical': 0.015684290412345054, 'mean_word_length': 3.408026755852843, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1691043', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1070, 'n_words': 387}