return isEmpty() ? ImmutableSet.<Entry<K, V>>of() : new EntrySet();
@Override public Entry<K, V> firstEntry() { return isEmpty() ? null : entrySet().asList().get(0); }
@Override public Entry<K, V> lastEntry() { return isEmpty() ? null : entrySet().asList().get(size() - 1); }
return isEmpty() ? ImmutableSet.<Entry<K, V>>of() : new EntrySet();
@Override public Entry<K, V> firstEntry() { return isEmpty() ? null : entrySet().asList().get(0); }
@Override public Entry<K, V> lastEntry() { return isEmpty() ? null : entrySet().asList().get(size() - 1); }
@Override public ImmutableSortedMap<K, V> descendingMap() { // TODO(kevinb): the descendingMap is never actually cached at all. Either it should be or the // code below simplified. ImmutableSortedMap<K, V> result = descendingMap; if (result == null) { if (isEmpty()) { return result = emptyMap(Ordering.from(comparator()).reverse()); } else { return result = new ImmutableSortedMap<>( (RegularImmutableSortedSet<K>) keySet.descendingSet(), valueList.reverse(), this); } } return result; }
/** * A builder for creating immutable sorted map instances, especially {@code public static final} * maps ("constant maps"). Example: * * <pre>{@code * static final ImmutableSortedMap<Integer, String> INT_TO_WORD = * new ImmutableSortedMap.Builder<Integer, String>(Ordering.natural()) * .put(1, "one") * .put(2, "two") * .put(3, "three") * .build(); * }</pre> * * <p>For <i>small</i> immutable sorted maps, the {@code ImmutableSortedMap.of()} methods are even * more convenient. * * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build * multiple maps in series. Each map is a superset of the maps created before it. * * @since 2.0 */ public static class Builder<K, V> extends ImmutableMap.Builder<K, V> { private transient Object[] keys; private transient Object[] values; private final Comparator<? super K> comparator; /** * Creates a new builder. The returned builder is equivalent to the builder generated by {@link * ImmutableSortedMap#orderedBy}. */
@Override public ImmutableSortedMap<K, V> descendingMap() { // TODO(kevinb): the descendingMap is never actually cached at all. Either it should be or the // code below simplified. ImmutableSortedMap<K, V> result = descendingMap; if (result == null) { if (isEmpty()) { return result = emptyMap(Ordering.from(comparator()).reverse()); } else { return result = new ImmutableSortedMap<>( (RegularImmutableSortedSet<K>) keySet.descendingSet(), valueList.reverse(), this); } } return result; }
if (!frame.corDefOutputs.isEmpty()) {
/** Fallback if none of the other {@code decorrelateRel} methods match. */ public Frame decorrelateRel(RelNode rel) { RelNode newRel = rel.copy(rel.getTraitSet(), rel.getInputs()); if (rel.getInputs().size() > 0) { List<RelNode> oldInputs = rel.getInputs(); List<RelNode> newInputs = Lists.newArrayList(); for (int i = 0; i < oldInputs.size(); ++i) { final Frame frame = getInvoke(oldInputs.get(i), rel); if (frame == null || !frame.corDefOutputs.isEmpty()) { // if input is not rewritten, or if it produces correlated // variables, terminate rewrite return null; } newInputs.add(frame.r); newRel.replaceInput(i, frame.r); } if (!Util.equalShallow(oldInputs, newInputs)) { newRel = rel.copy(rel.getTraitSet(), newInputs); } } // the output position should not change since there are no corVars // coming from below. return register(rel, newRel, identityMap(rel.getRowType().getFieldCount()), ImmutableSortedMap.<CorDef, Integer>of()); }
if (!frame.corDefOutputs.isEmpty()) {
/** * Returns <code>true</code> if locks were acquired. Note that if the lock * request specified {@link BlockingMode#BLOCK_INDEFINITELY} (the default * behavior) or {@link BlockingMode#BLOCK_INDEFINITELY_THEN_RELEASE}, * then this method is guaranteed to return <code>true</code>. */ public boolean success() { if (isBlockAndRelease) { return lockHolders.isEmpty(); } return token != null; }
if (!frame.oldToNewOutputs.isEmpty()) { newLocalOrdinal = frame.oldToNewOutputs.get(oldLocalOrdinal);
/** * This should only get created by the Lock Service. */ public LockResponse(@Nullable HeldLocksToken token, Map<LockDescriptor, LockClient> lockHolders) { this.token = token; this.lockHolders = ImmutableSortedMap.copyOf(lockHolders); isBlockAndRelease = false; Preconditions.checkArgument(token != null || !this.lockHolders.isEmpty()); }
/** * This should only get created by the Lock Service. * * This constructor is for {@link BlockingMode#BLOCK_INDEFINITELY_THEN_RELEASE} */ public LockResponse(Map<LockDescriptor, LockClient> lockHolders) { this.token = null; this.lockHolders = ImmutableSortedMap.copyOf(lockHolders); assert this.lockHolders.isEmpty(); isBlockAndRelease = true; }
if (rightFrame.corDefOutputs.isEmpty()) { return null;
private Optional<RowResult<Value>> getCurrentRowResult() { ImmutableSortedMap<byte[], Value> cells = currentRowCells.build(); if (cells.isEmpty()) { return Optional.empty(); } else { return Optional.of(RowResult.create(currentRowName, cells)); } }
ProjectionEntity projectionEntity = keyProjectionResult.next(); assertEquals(KEY1, projectionEntity.getKey()); assertTrue(projectionEntity.getProperties().isEmpty()); assertFalse(keyProjectionResult.hasNext());
LockResponse response = server.lockWithFullLockResponse(client, request); Assert.assertTrue(response.success()); Assert.assertTrue(response.getLockHolders().isEmpty()); HeldLocksToken token1 = response.getToken(); Assert.assertNotNull(token1);