Пример #1
0
    private Slices forReversePaging(
        ClusteringComparator comparator, Clustering lastReturned, boolean inclusive) {
      for (int i = slices.length - 1; i >= 0; i--) {
        Slice slice = slices[i];
        Slice newSlice = slice.forPaging(comparator, lastReturned, inclusive, true);
        if (newSlice == null) continue;

        if (slice == newSlice && i == slices.length - 1) return this;

        ArrayBackedSlices newSlices =
            new ArrayBackedSlices(comparator, Arrays.copyOfRange(slices, 0, i + 1));
        newSlices.slices[i] = newSlice;
        return newSlices;
      }
      return Slices.NONE;
    }
Пример #2
0
    private Slices forForwardPaging(
        ClusteringComparator comparator, Clustering lastReturned, boolean inclusive) {
      for (int i = 0; i < slices.length; i++) {
        Slice slice = slices[i];
        Slice newSlice = slice.forPaging(comparator, lastReturned, inclusive, false);
        if (newSlice == null) continue;

        if (slice == newSlice && i == 0) return this;

        ArrayBackedSlices newSlices =
            new ArrayBackedSlices(comparator, Arrays.copyOfRange(slices, i, slices.length));
        newSlices.slices[0] = newSlice;
        return newSlices;
      }
      return Slices.NONE;
    }