• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BitArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.common.hash.BloomFilterStrategies.BitArray的典型用法代码示例。如果您正苦于以下问题:Java BitArray类的具体用法?Java BitArray怎么用?Java BitArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BitArray类属于com.google.common.hash.BloomFilterStrategies包,在下文中一共展示了BitArray类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
@VisibleForTesting
static <T> BloomFilter<T> create(
    Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
  checkNotNull(funnel);
  checkArgument(
      expectedInsertions >= 0, "Expected insertions (%s) must be >= 0", expectedInsertions);
  checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
  checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
  checkNotNull(strategy);

  if (expectedInsertions == 0) {
    expectedInsertions = 1;
  }
  /*
   * TODO(user): Put a warning in the javadoc about tiny fpp values, since the resulting size
   * is proportional to -log(p), but there is not much of a point after all, e.g.
   * optimalM(1000, 0.0000000000000001) = 76680 which is less than 10kb. Who cares!
   */
  long numBits = optimalNumOfBits(expectedInsertions, fpp);
  int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
  try {
    return new BloomFilter<T>(new BitArray(numBits), numHashFunctions, funnel, strategy);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:27,代码来源:BloomFilter.java


示例2: create

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
@VisibleForTesting
static <T> BloomFilter<T> create(Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
  checkNotNull(funnel);
  checkArgument(expectedInsertions >= 0, "Expected insertions (%s) must be >= 0", expectedInsertions);
  checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
  checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
  checkNotNull(strategy);
  if (expectedInsertions == 0) {
    expectedInsertions = 1;
  }
  /*
   * TODO(user): Put a warning in the javadoc about tiny fpp values, since the resulting size
   * is proportional to -log(p), but there is not much of a point after all, e.g.
   * optimalM(1000, 0.0000000000000001) = 76680 which is less than 10kb. Who cares!
   */
  long numBits = optimalNumOfBits(expectedInsertions, fpp);
  int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
  try {
    return new BloomFilter<T>(new BitArray(numBits), numHashFunctions, funnel, strategy);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:24,代码来源:BloomFilter.java


示例3: create

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Creates a {@link BloomFilter BloomFilter<T>} with the expected number of
 * insertions and expected false positive probability.
 *
 * <p>Note that overflowing a {@code BloomFilter} with significantly more elements
 * than specified, will result in its saturation, and a sharp deterioration of its
 * false positive probability.
 *
 * <p>The constructed {@code BloomFilter<T>} will be serializable if the provided
 * {@code Funnel<T>} is.
 *
 * <p>It is recommended that the funnel be implemented as a Java enum. This has the
 * benefit of ensuring proper serialization and deserialization, which is important
 * since {@link #equals} also relies on object identity of funnels.
 *
 * @param funnel the funnel of T's that the constructed {@code BloomFilter<T>} will use
 * @param expectedInsertions the number of expected insertions to the constructed
 *     {@code BloomFilter<T>}; must be positive
 * @param fpp the desired false positive probability (must be positive and less than 1.0)
 * @return a {@code BloomFilter}
 */
public static <T> BloomFilter<T> create(
    Funnel<T> funnel, int expectedInsertions /* n */, double fpp) {
  checkNotNull(funnel);
  checkArgument(expectedInsertions >= 0, "Expected insertions (%s) must be >= 0",
      expectedInsertions);
  checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
  checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
  if (expectedInsertions == 0) {
    expectedInsertions = 1;
  }
  /*
   * TODO(user): Put a warning in the javadoc about tiny fpp values,
   * since the resulting size is proportional to -log(p), but there is not
   * much of a point after all, e.g. optimalM(1000, 0.0000000000000001) = 76680
   * which is less than 10kb. Who cares!
   */
  long numBits = optimalNumOfBits(expectedInsertions, fpp);
  int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
  try {
    return new BloomFilter<T>(new BitArray(numBits), numHashFunctions, funnel,
        BloomFilterStrategies.MURMUR128_MITZ_32);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
  }
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:BloomFilter.java


示例4: create

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Creates a {@code Builder} of a {@link BloomFilter BloomFilter<T>}, with the expected number
 * of insertions and expected false positive probability.
 *
 * <p>Note that overflowing a {@code BloomFilter} with significantly more elements
 * than specified, will result in its saturation, and a sharp deterioration of its
 * false positive probability.
 *
 * <p>The constructed {@code BloomFilter<T>} will be serializable if the provided
 * {@code Funnel<T>} is.
 *
 * <p>It is recommended the funnel is implemented as a Java enum. This has the benefit of ensuring
 * proper serialization and deserialization, which is important since {@link #equals} also relies
 * on object identity of funnels.
 *
 * @param funnel the funnel of T's that the constructed {@code BloomFilter<T>} will use
 * @param expectedInsertions the number of expected insertions to the constructed
 *     {@code BloomFilter<T>}; must be positive
 * @param fpp the desired false positive probability (must be positive and less than 1.0)
 * @return a {@code BloomFilter}
 */
public static <T> BloomFilter<T> create(
    Funnel<T> funnel, int expectedInsertions /* n */, double fpp) {
  checkNotNull(funnel);
  checkArgument(expectedInsertions >= 0, "Expected insertions (%s) must be >= 0",
      expectedInsertions);
  checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
  checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
  if (expectedInsertions == 0) {
    expectedInsertions = 1;
  }
  /*
   * TODO(user): Put a warning in the javadoc about tiny fpp values,
   * since the resulting size is proportional to -log(p), but there is not
   * much of a point after all, e.g. optimalM(1000, 0.0000000000000001) = 76680
   * which is less that 10kb. Who cares!
   */
  long numBits = optimalNumOfBits(expectedInsertions, fpp);
  int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
  try {
    return new BloomFilter<T>(new BitArray(numBits), numHashFunctions, funnel,
        BloomFilterStrategies.MURMUR128_MITZ_32);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
  }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:47,代码来源:BloomFilter.java


示例5: BloomFilter

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Creates a BloomFilter.
 */
private BloomFilter(
    BitArray bits, int numHashFunctions, Funnel<? super T> funnel, Strategy strategy) {
  checkArgument(numHashFunctions > 0, "numHashFunctions (%s) must be > 0", numHashFunctions);
  checkArgument(
      numHashFunctions <= 255, "numHashFunctions (%s) must be <= 255", numHashFunctions);
  this.bits = checkNotNull(bits);
  this.numHashFunctions = numHashFunctions;
  this.funnel = checkNotNull(funnel);
  this.strategy = checkNotNull(strategy);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:14,代码来源:BloomFilter.java


示例6: readFrom

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a
 * {@code BloomFilter<T>}.
 *
 * The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
 * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to populate
 * the original Bloom filter!
 *
 * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
 *     appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
 */
public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<? super T> funnel)
    throws IOException {
  checkNotNull(in, "InputStream");
  checkNotNull(funnel, "Funnel");
  int strategyOrdinal = -1;
  int numHashFunctions = -1;
  int dataLength = -1;
  try {
    DataInputStream din = new DataInputStream(in);
    // currently this assumes there is no negative ordinal; will have to be updated if we
    // add non-stateless strategies (for which we've reserved negative ordinals; see
    // Strategy.ordinal()).
    strategyOrdinal = din.readByte();
    numHashFunctions = UnsignedBytes.toInt(din.readByte());
    dataLength = din.readInt();

    Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];
    long[] data = new long[dataLength];
    for (int i = 0; i < data.length; i++) {
      data[i] = din.readLong();
    }
    return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
  } catch (RuntimeException e) {
    String message =
        "Unable to deserialize BloomFilter from InputStream."
            + " strategyOrdinal: "
            + strategyOrdinal
            + " numHashFunctions: "
            + numHashFunctions
            + " dataLength: "
            + dataLength;
    throw new IOException(message, e);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:46,代码来源:BloomFilter.java


示例7: readFrom

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a
 * {@code BloomFilter<T>}.
 *
 * The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
 * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to populate
 * the original Bloom filter!
 *
 * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
 *     appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
 */
public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel) throws IOException {
  checkNotNull(in, "InputStream");
  checkNotNull(funnel, "Funnel");
  int strategyOrdinal = -1;
  int numHashFunctions = -1;
  int dataLength = -1;
  try {
    DataInputStream din = new DataInputStream(in);
    // currently this assumes there is no negative ordinal; will have to be updated if we
    // add non-stateless strategies (for which we've reserved negative ordinals; see
    // Strategy.ordinal()).
    strategyOrdinal = din.readByte();
    numHashFunctions = UnsignedBytes.toInt(din.readByte());
    dataLength = din.readInt();

    Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];
    long[] data = new long[dataLength];
    for (int i = 0; i < data.length; i++) {
      data[i] = din.readLong();
    }
    return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
  } catch (RuntimeException e) {
    String message =
        "Unable to deserialize BloomFilter from InputStream."
            + " strategyOrdinal: "
            + strategyOrdinal
            + " numHashFunctions: "
            + numHashFunctions
            + " dataLength: "
            + dataLength;
    throw new IOException(message, e);
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:45,代码来源:BloomFilter.java


示例8: BloomFilter

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Creates a BloomFilter.
 */
private BloomFilter(BitArray bits, int numHashFunctions, Funnel<? super T> funnel, Strategy strategy) {
  checkArgument(numHashFunctions > 0, "numHashFunctions (%s) must be > 0", numHashFunctions);
  checkArgument(numHashFunctions <= 255, "numHashFunctions (%s) must be <= 255", numHashFunctions);
  this.bits = checkNotNull(bits);
  this.numHashFunctions = numHashFunctions;
  this.funnel = checkNotNull(funnel);
  this.strategy = checkNotNull(strategy);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:12,代码来源:BloomFilter.java


示例9: readFrom

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
   * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a
   * {@code BloomFilter<T>}.
   *
   * The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
   * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to populate
   * the original Bloom filter!
   *
   * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
   *     appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
   */


  public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel)
throws IOException {
    checkNotNull(in, "InputStream");
    checkNotNull(funnel, "Funnel");
    int strategyOrdinal = -1;
    int numHashFunctions = -1;
    int dataLength = -1;
    try {
      DataInputStream din = new DataInputStream(in);
      // currently this assumes there is no negative ordinal; will have to be updated if we
      // add non-stateless strategies (for which we've reserved negative ordinals; see
      // Strategy.ordinal()).
      strategyOrdinal = din.readByte();
      numHashFunctions = UnsignedBytes.toInt(din.readByte());
      dataLength = din.readInt();
      Strategy strategy = BloomFilterStrategies.values() [strategyOrdinal];
      long[] data = new long[dataLength];
      for (int i = 0; i < data.length; i++) {
        data[i] = din.readLong();
      }
      return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
    } catch (RuntimeException e) {
      IOException ioException = new IOException("Unable to deserialize BloomFilter from InputStream." + " strategyOrdinal: "
+ strategyOrdinal
+ " numHashFunctions: "
+ numHashFunctions + " dataLength: " + dataLength);
      ioException.initCause(e);
      throw ioException;
    }
  }
 
开发者ID:antlr,项目名称:codebuff,代码行数:44,代码来源:BloomFilter.java


示例10: readFrom

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a
 * {@code BloomFilter<T>}.
 *
 * The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
 * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to populate
 * the original Bloom filter!
 *
 * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
 *     appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
 */


public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel)
throws IOException {
  checkNotNull(in, "InputStream");
  checkNotNull(funnel, "Funnel");
  int strategyOrdinal = -1;
  int numHashFunctions = -1;
  int dataLength = -1;
  try {
    DataInputStream din = new DataInputStream(in);
    // currently this assumes there is no negative ordinal; will have to be updated if we
    // add non-stateless strategies (for which we've reserved negative ordinals; see
    // Strategy.ordinal()).
    strategyOrdinal = din.readByte();
    numHashFunctions = UnsignedBytes.toInt(din.readByte());
    dataLength = din.readInt();
    Strategy strategy = BloomFilterStrategies.values() [strategyOrdinal];
    long[] data = new long[dataLength];
    for (int i = 0; i < data.length; i++) {
      data[i] = din.readLong();
    }
    return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
  } catch (RuntimeException e) {
    IOException ioException = new IOException("Unable to deserialize BloomFilter from InputStream." + " strategyOrdinal: "
    + strategyOrdinal
    + " numHashFunctions: "
    + numHashFunctions + " dataLength: " + dataLength);
    ioException.initCause(e);
    throw ioException;
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:44,代码来源:BloomFilter.java


示例11: readFrom

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a
 * {@code BloomFilter<T>}.
 *
 * The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
 * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to populate
 * the original Bloom filter!
 *
 * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
 *     appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
 */
public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel) throws IOException {
  checkNotNull(in, "InputStream");
  checkNotNull(funnel, "Funnel");
  int strategyOrdinal = -1;
  int numHashFunctions = -1;
  int dataLength = -1;
  try {
    DataInputStream din = new DataInputStream(in);
    // currently this assumes there is no negative ordinal; will have to be updated if we
    // add non-stateless strategies (for which we've reserved negative ordinals; see
    // Strategy.ordinal()).
    strategyOrdinal = din.readByte();
    numHashFunctions = UnsignedBytes.toInt(din.readByte());
    dataLength = din.readInt();

    Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];
    long[] data = new long[dataLength];
    for (int i = 0; i < data.length; i++) {
      data[i] = din.readLong();
    }
    return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
  } catch (RuntimeException e) {
    IOException ioException =
        new IOException(
            "Unable to deserialize BloomFilter from InputStream."
                + " strategyOrdinal: "
                + strategyOrdinal
                + " numHashFunctions: "
                + numHashFunctions
                + " dataLength: "
                + dataLength);
    ioException.initCause(e);
    throw ioException;
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:47,代码来源:BloomFilter.java


示例12: BloomFilter

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Creates a BloomFilter.
 */
private BloomFilter(BitArray bits, int numHashFunctions, Funnel<T> funnel,
    Strategy strategy) {
  checkArgument(numHashFunctions > 0,
      "numHashFunctions (%s) must be > 0", numHashFunctions);
  checkArgument(numHashFunctions <= 255,
      "numHashFunctions (%s) must be <= 255", numHashFunctions);
  this.bits = checkNotNull(bits);
  this.numHashFunctions = numHashFunctions;
  this.funnel = checkNotNull(funnel);
  this.strategy = checkNotNull(strategy);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:BloomFilter.java


示例13: BloomFilter

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Creates a BloomFilter.
 */
private BloomFilter(BitArray bits, int numHashFunctions, Funnel<? super T> funnel,
    Strategy strategy) {
  checkArgument(numHashFunctions > 0,
      "numHashFunctions (%s) must be > 0", numHashFunctions);
  checkArgument(numHashFunctions <= 255,
      "numHashFunctions (%s) must be <= 255", numHashFunctions);
  this.bits = checkNotNull(bits);
  this.numHashFunctions = numHashFunctions;
  this.funnel = checkNotNull(funnel);
  this.strategy = checkNotNull(strategy);
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:15,代码来源:BloomFilter.java


示例14: create

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
@VisibleForTesting
static <T> BloomFilter<T> create(
    Funnel<? super T> funnel, int expectedInsertions /* n */, double fpp, Strategy strategy) {
  checkNotNull(funnel);
  checkArgument(expectedInsertions >= 0, "Expected insertions (%s) must be >= 0",
      expectedInsertions);
  checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
  checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
  checkNotNull(strategy);

  if (expectedInsertions == 0) {
    expectedInsertions = 1;
  }
  /*
   * TODO(user): Put a warning in the javadoc about tiny fpp values,
   * since the resulting size is proportional to -log(p), but there is not
   * much of a point after all, e.g. optimalM(1000, 0.0000000000000001) = 76680
   * which is less than 10kb. Who cares!
   */
  long numBits = optimalNumOfBits(expectedInsertions, fpp);
  int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
  try {
    return new BloomFilter<T>(new BitArray(numBits), numHashFunctions, funnel, strategy);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
  }
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:28,代码来源:BloomFilter.java


示例15: readFrom

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
/**
 * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into
 * a {@code BloomFilter<T>}.
 *
 * The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
 * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to
 * populate the original Bloom filter!
 *
 * @throws IOException if the InputStream throws an {@code IOException}, or if its data does
 *     not appear to be a BloomFilter serialized using the
 *     {@linkplain #writeTo(OutputStream)} method.
 */
public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel) throws IOException {
  checkNotNull(in, "InputStream");
  checkNotNull(funnel, "Funnel");
  int strategyOrdinal = -1;
  int numHashFunctions = -1;
  int dataLength = -1;
  try {
    DataInputStream din = new DataInputStream(in);
    // currently this assumes there is no negative ordinal; will have to be updated if we
    // add non-stateless strategies (for which we've reserved negative ordinals; see
    // Strategy.ordinal()).
    strategyOrdinal = din.readByte();
    numHashFunctions = UnsignedBytes.toInt(din.readByte());
    dataLength = din.readInt();

    Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];
    long[] data = new long[dataLength];
    for (int i = 0; i < data.length; i++) {
      data[i] = din.readLong();
    }
    return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
  } catch (RuntimeException e) {
    IOException ioException = new IOException(
        "Unable to deserialize BloomFilter from InputStream."
        + " strategyOrdinal: " + strategyOrdinal
        + " numHashFunctions: " + numHashFunctions
        + " dataLength: " + dataLength);
    ioException.initCause(e);
    throw ioException;
  }
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:44,代码来源:BloomFilter.java


示例16: create

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
@VisibleForTesting
static <T> BloomFilter<T> create(
    Funnel<T> funnel, int expectedInsertions /* n */, double fpp, Strategy strategy) {
  checkNotNull(funnel);
  checkArgument(expectedInsertions >= 0, "Expected insertions (%s) must be >= 0",
      expectedInsertions);
  checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
  checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
  checkNotNull(strategy);

  if (expectedInsertions == 0) {
    expectedInsertions = 1;
  }
  /*
   * TODO(user): Put a warning in the javadoc about tiny fpp values,
   * since the resulting size is proportional to -log(p), but there is not
   * much of a point after all, e.g. optimalM(1000, 0.0000000000000001) = 76680
   * which is less than 10kb. Who cares!
   */
  long numBits = optimalNumOfBits(expectedInsertions, fpp);
  int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
  try {
    return new BloomFilter<T>(new BitArray(numBits), numHashFunctions, funnel, strategy);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
  }
}
 
开发者ID:ketao1989,项目名称:cnGuava,代码行数:28,代码来源:BloomFilter.java


示例17: readResolve

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
Object readResolve() {
  return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:4,代码来源:BloomFilter.java


示例18: PackageSanityTests

import com.google.common.hash.BloomFilterStrategies.BitArray; //导入依赖的package包/类
public PackageSanityTests() {
  setDefault(BitArray.class, new BitArray(1));
  setDefault(HashCode.class, HashCode.fromInt(1));
  setDefault(String.class, "MD5");
  setDefault(int.class, 32);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:7,代码来源:PackageSanityTests.java



注:本文中的com.google.common.hash.BloomFilterStrategies.BitArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StaticMethodMatcherPointcutAdvisor类代码示例发布时间:2022-05-22
下一篇:
Java VersionIterator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap