示例#1
0
 public Builder add(Slice slice) {
   assert comparator.compare(slice.start(), slice.end()) <= 0;
   if (slices.size() > 0
       && comparator.compare(slices.get(slices.size() - 1).end(), slice.start()) > 0)
     needsNormalizing = true;
   slices.add(slice);
   return this;
 }
示例#2
0
    public boolean selects(Clustering clustering) {
      for (int i = 0; i < slices.length; i++) {
        Slice slice = slices[i];
        if (comparator.compare(clustering, slice.start()) < 0) return false;

        if (comparator.compare(clustering, slice.end()) <= 0) return true;
      }
      return false;
    }
示例#3
0
  /**
   * Creates a {@code Slices} object that contains a single slice.
   *
   * @param comparator the comparator for the table {@code slice} is a slice of.
   * @param slice the single slice that the return object should contains.
   * @return the newly created {@code Slices} object.
   */
  public static Slices with(ClusteringComparator comparator, Slice slice) {
    if (slice.start() == Slice.Bound.BOTTOM && slice.end() == Slice.Bound.TOP) return Slices.ALL;

    assert comparator.compare(slice.start(), slice.end()) <= 0;
    return new ArrayBackedSlices(comparator, new Slice[] {slice});
  }