private void initCols(Schema schema) throws SchemaChangeException { ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder(); for (int i = 0; i < schema.getColumnCount(); i++) { ColumnDTO column = schema.getColumnByIndex(i); final String name = column.getColumnName(); final OpenTSDBTypes type = column.getColumnType(); TypeProtos.MinorType minorType = TYPES.get(type); if (isMinorTypeNull(minorType)) { String message = String.format( "A column you queried has a data type that is not currently supported by the OpenTSDB storage plugin. " + "The column's name was %s and its OpenTSDB data type was %s. ", name, type.toString()); throw UserException.unsupportedError() .message(message) .build(log); } ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType); pciBuilder.add(pci); } projectedCols = pciBuilder.build(); }
projectedCols = pciBuilder.build();
private static <E> ImmutableSortedMultiset<E> copyOfSortedEntries( Comparator<? super E> comparator, Collection<Entry<E>> entries) { if (entries.isEmpty()) { return emptyMultiset(comparator); } ImmutableList.Builder<E> elementsBuilder = new ImmutableList.Builder<E>(entries.size()); long[] cumulativeCounts = new long[entries.size() + 1]; int i = 0; for (Entry<E> entry : entries) { elementsBuilder.add(entry.getElement()); cumulativeCounts[i + 1] = cumulativeCounts[i] + entry.getCount(); i++; } return new RegularImmutableSortedMultiset<E>( new RegularImmutableSortedSet<E>(elementsBuilder.build(), comparator), cumulativeCounts, 0, entries.size()); }
/** * Helper method to create {@link FunctionExprNode} from {@code List<String>}. * @param fieldName Name of the filed on which the like expression is applied. * @param valuesFilter a list of values * @return {@link FunctionExprNode} for given arguments. Null if the <code>valuesFilter</code> is null. */ private static FunctionExprNode createInFunctionExprNode(String fieldName, List<String> valuesFilter) { if (valuesFilter == null) { return null; } ImmutableList.Builder<ExprNode> nodes = ImmutableList.builder(); nodes.add(new FieldExprNode(fieldName)); for(String type: valuesFilter) { nodes.add(new ConstantExprNode(type)); } return new FunctionExprNode(IN_FUNCTION, nodes.build()); }
Object readResolve() { if (cellValues.length == 0) { return of(); } if (cellValues.length == 1) { return of(rowKeys[0], columnKeys[0], cellValues[0]); } ImmutableList.Builder<Cell<Object, Object, Object>> cellListBuilder = new ImmutableList.Builder<Cell<Object, Object, Object>>(cellValues.length); for (int i = 0; i < cellValues.length; i++) { cellListBuilder.add( cellOf(rowKeys[cellRowIndices[i]], columnKeys[cellColumnIndices[i]], cellValues[i])); } return RegularImmutableTable.forOrderedComponents( cellListBuilder.build(), ImmutableSet.copyOf(rowKeys), ImmutableSet.copyOf(columnKeys)); }
public RexNode go(RexNode rex) { if (rex instanceof RexCall) { ImmutableList.Builder<RexNode> builder = ImmutableList.builder(); final RexCall call = (RexCall) rex; for (RexNode operand : call.operands) { builder.add(go(operand)); } return call.clone(call.getType(), builder.build()); } else if (rex instanceof RexInputRef) { RexInputRef var = (RexInputRef) rex; int index = var.getIndex(); return rexBuilder.makeInputRef(var.getType(), inputRefMap.get(index)); } else { return rex; } } }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any of {@code elements} is null */ public static <E> ImmutableList<E> copyOf(Iterator<? extends E> elements) { // We special-case for 0 or 1 elements, but going further is madness. if (!elements.hasNext()) { return of(); } E first = elements.next(); if (!elements.hasNext()) { return of(first); } else { return new ImmutableList.Builder<E>().add(first).addAll(elements).build(); } }
/** * Returns all declared parameters of this {@code Invokable}. Note that if this is a constructor * of a non-static inner class, unlike {@link Constructor#getParameterTypes}, the hidden * {@code this} parameter of the enclosing class is excluded from the returned parameters. */ public final ImmutableList<Parameter> getParameters() { Type[] parameterTypes = getGenericParameterTypes(); Annotation[][] annotations = getParameterAnnotations(); ImmutableList.Builder<Parameter> builder = ImmutableList.builder(); for (int i = 0; i < parameterTypes.length; i++) { builder.add(new Parameter(this, i, TypeToken.of(parameterTypes[i]), annotations[i])); } return builder.build(); }
private static final Iterable<ConvertSupport> getSupportedConvertOps() { // A set would be more appropriate but it's not possible to produce // duplicates, and an iterable is all we need. ImmutableList.Builder<ConvertSupport> supportedConvertedOps = ImmutableList.builder(); for(MinorType from: MinorType.values()) { for(MinorType to: MinorType.values()) { if (TypeCastRules.isCastable(from, to)) { supportedConvertedOps.add(ConvertSupport.newBuilder().setFrom(from).setTo(to).build()); } } } return supportedConvertedOps.build(); } /**
private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) { ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder(); ColumnDto column; for (int i = 0; i < schema.getNumberOfColumns(); i++) { column = schema.getColumnByIndex(i); final String name = column.getColumnName().toLowerCase(); final PcapTypes type = column.getColumnType(); TypeProtos.MinorType minorType = TYPES.get(type); ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType); pciBuilder.add(pci); } return pciBuilder.build(); }
@SuppressWarnings("unchecked") public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> copyOf( RangeMap<K, ? extends V> rangeMap) { if (rangeMap instanceof ImmutableRangeMap) { return (ImmutableRangeMap<K, V>) rangeMap; } Map<Range<K>, ? extends V> map = rangeMap.asMapOfRanges(); ImmutableList.Builder<Range<K>> rangesBuilder = new ImmutableList.Builder<Range<K>>(map.size()); ImmutableList.Builder<V> valuesBuilder = new ImmutableList.Builder<V>(map.size()); for (Entry<Range<K>, ? extends V> entry : map.entrySet()) { rangesBuilder.add(entry.getKey()); valuesBuilder.add(entry.getValue()); } return new ImmutableRangeMap<K, V>(rangesBuilder.build(), valuesBuilder.build()); }
public LogicalPlan build() { return new LogicalPlan(this.planProperties, this.storageEngines.build(), this.operators.build()); } }
static <E> List<List<E>> create(List<? extends List<? extends E>> lists) { ImmutableList.Builder<List<E>> axesBuilder = new ImmutableList.Builder<List<E>>(lists.size()); for (List<? extends E> list : lists) { List<E> copy = ImmutableList.copyOf(list); if (copy.isEmpty()) { return ImmutableList.of(); } axesBuilder.add(copy); } return new CartesianList<E>(axesBuilder.build()); }
final ImmutableList<Type> usedInGenericType(Type[] types) { ImmutableList.Builder<Type> builder = ImmutableList.builder(); for (Type type : types) { builder.add(usedInGenericType(type)); } return builder.build(); } }
/** Returns all declared exception types of this {@code Invokable}. */ public final ImmutableList<TypeToken<? extends Throwable>> getExceptionTypes() { ImmutableList.Builder<TypeToken<? extends Throwable>> builder = ImmutableList.builder(); for (Type type : getGenericExceptionTypes()) { // getGenericExceptionTypes() will never return a type that's not exception @SuppressWarnings("unchecked") TypeToken<? extends Throwable> exceptionType = (TypeToken<? extends Throwable>) TypeToken.of(type); builder.add(exceptionType); } return builder.build(); }
@Override ImmutableList<K> collectTypes(Iterable<? extends K> types) { ImmutableList.Builder<K> builder = ImmutableList.builder(); for (K type : types) { if (!getRawType(type).isInterface()) { builder.add(type); } } return super.collectTypes(builder.build()); } };
/** * Wraps a collection of tasks. * * @throws NullPointerException if any element of {@code tasks} is null */ private final <T> ImmutableList<Callable<T>> wrapTasks(Collection<? extends Callable<T>> tasks) { ImmutableList.Builder<Callable<T>> builder = ImmutableList.builder(); for (Callable<T> task : tasks) { builder.add(wrapTask(task)); } return builder.build(); }
private ImmutableList<TypeToken<? super T>> boundsAsInterfaces(Type[] bounds) { ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder(); for (Type bound : bounds) { @SuppressWarnings("unchecked") // upper bound of T TypeToken<? super T> boundType = (TypeToken<? super T>) of(bound); if (boundType.getRawType().isInterface()) { builder.add(boundType); } } return builder.build(); }
public LogicalPlan build() { return new LogicalPlan(this.planProperties, this.storageEngines.build(), this.operators.build()); } }