@Override public Collection<HStoreFile> getFilesForScan(byte[] startRow, boolean includeStartRow, byte[] stopRow, boolean includeStopRow) { if (state.stripeFiles.isEmpty()) { return state.level0Files; // There's just L0. } int firstStripe = findStripeForRow(startRow, true); int lastStripe = findStripeForRow(stopRow, false); assert firstStripe <= lastStripe; if (firstStripe == lastStripe && state.level0Files.isEmpty()) { return state.stripeFiles.get(firstStripe); // There's just one stripe we need. } if (firstStripe == 0 && lastStripe == (state.stripeFiles.size() - 1)) { return state.allFilesCached; // We need to read all files. } ConcatenatedLists<HStoreFile> result = new ConcatenatedLists<>(); result.addAllSublists(state.stripeFiles.subList(firstStripe, lastStripe + 1)); result.addSublist(state.level0Files); return result; }
int delta = stateLocal.level0Files.isEmpty() ? 0 : 1; double max = 0.0; for (ImmutableList<HStoreFile> stripeFile : stateLocal.stripeFiles) {
@Override public boolean isEmpty() { return ranges.isEmpty(); }
@Override public Range<K> span() { if (ranges.isEmpty()) { throw new NoSuchElementException(); } Range<K> firstRange = ranges.get(0); Range<K> lastRange = ranges.get(ranges.size() - 1); return Range.create(firstRange.lowerBound, lastRange.upperBound); }
@Override public Range<C> span() { if (ranges.isEmpty()) { throw new NoSuchElementException(); } return Range.create(ranges.get(0).lowerBound, ranges.get(ranges.size() - 1).upperBound); }
@Override public ImmutableSet<Range<C>> asRanges() { if (ranges.isEmpty()) { return ImmutableSet.of(); } return new RegularImmutableSortedSet<Range<C>>(ranges, Range.<C>rangeLexOrdering()); }
@Override public ImmutableMap<Range<K>, V> asMapOfRanges() { if (ranges.isEmpty()) { return ImmutableMap.of(); } RegularImmutableSortedSet<Range<K>> rangeSet = new RegularImmutableSortedSet<Range<K>>(ranges, Range.<K>rangeLexOrdering()); return new ImmutableSortedMap<Range<K>, V>(rangeSet, values); }
@Override public ImmutableSet<Range<C>> asDescendingSetOfRanges() { if (ranges.isEmpty()) { return ImmutableSet.of(); } return new RegularImmutableSortedSet<Range<C>>( ranges.reverse(), Range.<C>rangeLexOrdering().reverse()); }
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) { this.rowList = ImmutableList.copyOf(rowKeys); this.columnList = ImmutableList.copyOf(columnKeys); checkArgument(!rowList.isEmpty()); checkArgument(!columnList.isEmpty()); /* * TODO(jlevy): Support empty rowKeys or columnKeys? If we do, when * columnKeys is empty but rowKeys isn't, the table is empty but * containsRow() can return true and rowKeySet() isn't empty. */ rowKeyToIndex = Maps.indexMap(rowList); columnKeyToIndex = Maps.indexMap(columnList); @SuppressWarnings("unchecked") V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()]; array = tmpArray; // Necessary because in GWT the arrays are initialized with "undefined" instead of null. eraseAll(); }
/** * Returns an immutable sorted set containing the elements of a sorted set, * sorted by the same {@code Comparator}. That behavior differs from {@link * #copyOf(Iterable)}, which always uses the natural ordering of the * elements. * * <p>Despite the method name, this method attempts to avoid actually copying * the data when it is safe to do so. The exact circumstances under which a * copy will or will not be performed are undocumented and subject to change. * * <p>This method is safe to use even when {@code sortedSet} is a synchronized * or concurrent collection that is currently being modified by another * thread. * * @throws NullPointerException if {@code sortedSet} or any of its elements * is null */ public static <E> ImmutableSortedSet<E> copyOfSorted(SortedSet<E> sortedSet) { Comparator<? super E> comparator = SortedIterables.comparator(sortedSet); ImmutableList<E> list = ImmutableList.copyOf(sortedSet); if (list.isEmpty()) { return emptySet(comparator); } else { return new RegularImmutableSortedSet<E>(list, comparator); } }
Object readResolve() { if (ranges.isEmpty()) { return of(); } else if (ranges.equals(ImmutableList.of(Range.all()))) { return all(); } else { return new ImmutableRangeSet<C>(ranges); } } }
@Override public ImmutableMap<Range<K>, V> asDescendingMapOfRanges() { if (ranges.isEmpty()) { return ImmutableMap.of(); } RegularImmutableSortedSet<Range<K>> rangeSet = new RegularImmutableSortedSet<Range<K>>( ranges.reverse(), Range.<K>rangeLexOrdering().reverse()); return new ImmutableSortedMap<Range<K>, V>(rangeSet, values.reverse()); }
multimap.asMap().entrySet()) { ImmutableList<V> list = ImmutableList.copyOf(entry.getValue()); if (!list.isEmpty()) { builder.put(entry.getKey(), list); size += list.size();
@Override public ImmutableRangeSet<C> complement() { ImmutableRangeSet<C> result = complement; if (result != null) { return result; } else if (ranges.isEmpty()) { return complement = all(); } else if (ranges.size() == 1 && ranges.get(0).equals(Range.all())) { return complement = of(); } else { ImmutableList<Range<C>> complementRanges = new ComplementRanges(); result = complement = new ImmutableRangeSet<C>(complementRanges, this); } return result; }
if (mergedRanges.isEmpty()) { return of(); } else if (mergedRanges.size() == 1
if (checkNotNull(range).isEmpty()) { return ImmutableRangeMap.of(); } else if (ranges.isEmpty() || range.encloses(span())) { return this;
if (ranges.isEmpty() || range.isEmpty()) { return ImmutableList.of(); } else if (range.encloses(span())) {