private static <T extends LogicalOperator> T findOnlyOperator(LogicalPlan plan, final Class<T> operatorClazz) { return Iterables.getOnlyElement(findOperator(plan, operatorClazz)); }
@Override public ProducerConsumerBatch getBatch(ExecutorFragmentContext context, ProducerConsumer config, List<RecordBatch> children) throws ExecutionSetupException { return new ProducerConsumerBatch(config, context, Iterables.getOnlyElement(children)); } }
@Override public PartitionLimitRecordBatch getBatch(ExecutorFragmentContext context, PartitionLimit config, List<RecordBatch> children) throws ExecutionSetupException { return new PartitionLimitRecordBatch(config, context, Iterables.getOnlyElement(children)); } }
@Override public Field getField(String fieldName, int index) { Field field; if (isSingleTyped()) { field = Iterables.getOnlyElement(fields, null); } else { field = index < fields.size() ? fields.get(index) : null; } return field; }
@Override public LimitRecordBatch getBatch(ExecutorFragmentContext context, Limit config, List<RecordBatch> children) throws ExecutionSetupException { return new LimitRecordBatch(config, context, Iterables.getOnlyElement(children)); } }
@Override public void addField(Field field) { if (field.getFieldType().getMode() == DataMode.REPEATED || fields.isEmpty() || !isSingleTyped() || !Iterables.getOnlyElement(fields).equals(field.getFieldType())) { fields.add(field); } }
static <K extends Enum<K>, V> ImmutableMap<K, V> asImmutable(EnumMap<K, V> map) { switch (map.size()) { case 0: return ImmutableMap.of(); case 1: Entry<K, V> entry = Iterables.getOnlyElement(map.entrySet()); return ImmutableMap.of(entry.getKey(), entry.getValue()); default: return new ImmutableEnumMap<K, V>(map); } }
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
/** * Returns a newly-created immutable table. * * @throws IllegalArgumentException if duplicate key pairs were added */ public ImmutableTable<R, C, V> build() { int size = cells.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableTable<R, C, V>(Iterables.getOnlyElement(cells)); default: return RegularImmutableTable.forCells(cells, rowComparator, columnComparator); } } }
return of(); } else if (mergedRanges.size() == 1 && Iterables.getOnlyElement(mergedRanges).equals(Range.all())) { return all(); } else {