public void testConcatIterable() { List<Integer> list1 = newArrayList(1); List<Integer> list2 = newArrayList(4); @SuppressWarnings("unchecked") List<List<Integer>> input = newArrayList(list1, list2); Iterable<Integer> result = Iterables.concat(input); assertEquals(asList(1, 4), newArrayList(result)); // Now change the inputs and see result dynamically change as well list1.add(2); List<Integer> list3 = newArrayList(3); input.add(1, list3); assertEquals(asList(1, 2, 3, 4), newArrayList(result)); assertEquals("[1, 2, 3, 4]", result.toString()); }
if (beforeTemplates.isEmpty() && afterTemplates.isEmpty()) { return ImmutableList.of(); } else { if (annotationMap.containsKey(AllowCodeBetweenLines.class)) { if (!stmtsWithBlanks.isEmpty()) { UBlank blank = UBlank.create(); blanks.add(blank); stmtsWithBlanks.add(blank); stmtsWithBlanks.add(stmt); afterTemplates.set( i, afterBlock.withStatements(Iterables.concat(blanks, afterBlock.templateStatements()))); negatedAfterTemplates, annotationMap); return ImmutableList.of(rule, negation); return ImmutableList.of(rule);
allColumns.add(LEGACY_TIMESTAMP_KEY); } else { final Set<String> availableColumns = Sets.newLinkedHashSet( Iterables.concat( Collections.singleton(legacy ? LEGACY_TIMESTAMP_KEY : ColumnHolder.TIME_COLUMN_NAME), Iterables.transform( Arrays.asList(query.getVirtualColumns().getVirtualColumns()), VirtualColumn::getOutputName
@Nullable Instrumentation instrumentation, File tmpDir) throws Exception { List<Advice> pluginAdvisors = Lists.newArrayList(); List<ShimType> shimTypes = Lists.newArrayList(); List<MixinType> mixinTypes = Lists.newArrayList(); Map<Advice, LazyDefinedClass> lazyAdvisors = Maps.newHashMap(); for (PluginDescriptor pluginDescriptor : pluginDescriptors) { pluginAdvisors.add(entry.getKey()); this.pluginAdvisors = ImmutableList.copyOf(pluginAdvisors); this.shimTypes = ImmutableList.copyOf(shimTypes); this.mixinTypes = ImmutableList.copyOf(mixinTypes); this.instrumentation = instrumentation; this.tmpDir = tmpDir; createReweavableAdvisors(reweavableConfigs, instrumentation, tmpDir, true); reweavableConfigVersions = createReweavableConfigVersions(reweavableConfigs); allAdvisors = ImmutableList.copyOf(Iterables.concat(pluginAdvisors, reweavableAdvisors));
final Set<String> allExprsDigests = new HashSet<>(this.allExprsDigests); final JoinRelType joinType = joinRel.getJoinType(); final List<RexNode> leftPreds = ImmutableList.copyOf(RelOptUtil.conjunctions(leftChildPredicates)); final List<RexNode> rightPreds = ImmutableList.copyOf(RelOptUtil.conjunctions(rightChildPredicates)); final RexBuilder rexBuilder = joinRel.getCluster().getRexBuilder(); switch (joinType) { ImmutableBitSet iPBitSet = RelOptUtil.InputFinder.bits(iP); if (leftFieldsBitSet.contains(iPBitSet)) { leftInferredPredicates.add(iP.accept(leftPermute)); } else if (rightFieldsBitSet.contains(iPBitSet)) { rightInferredPredicates.add(iP.accept(rightPermute)); for (RexNode iP : nonFieldsPredicates) { if (!leftPredsSet.contains(iP.toString())) { leftInferredPredicates.add(iP); Iterable<RexNode> pulledUpPredicates; if (isSemiJoin) { pulledUpPredicates = Iterables.concat(leftPreds, leftInferredPredicates); } else { pulledUpPredicates = Iterables.concat(leftPreds, rightPreds, RelOptUtil.conjunctions(joinRel.getCondition()), inferredPredicates);
final Iterable<SegmentToMergeHolder> segmentsToMerge = Iterables.concat( Iterables.transform( timeline.lookup(Intervals.of("1000-01-01/3000-01-01")), new Function<TimelineObjectHolder<String, DataSegment>, Iterable<SegmentToMergeHolder>>() adapters.add( new RowFilteringIndexAdapter( new QueryableIndexIndexableAdapter(toolbox.getIndexIO().loadIndex(holder.getFile())),
importsBuilder.addImport(importCandidate.preparedImport); contentParts.add(content.subSequence(nextPartFrom, importCandidate.importFrom)); nextPartFrom = importCandidate.packageTo; contentParts.add(content.subSequence(nextPartFrom, content.length())); headerParts.add(header); headerParts.add(imports); return JOINER.join(Iterables.concat(headerParts, contentParts));
public void testConcatNullPointerException() { List<Integer> list1 = newArrayList(1); List<Integer> list2 = newArrayList(4); try { Iterables.concat(list1, null, list2); fail(); } catch (NullPointerException expected) { } }
/** * Split each element of an Iterable<String> at commas. * @param input Iterable over strings. * @return An Iterable over string which breaks down each input element at comma boundaries */ @Nonnull public static List<String> splitAtCommasAndTrim(Iterable<String> input) { if(input==null) { return Collections.emptyList(); } Iterable<String> nonEmptyInputs = Iterables.filter(input, Predicates.notNull()); return Lists.newArrayList(Iterables.concat(Iterables.transform(nonEmptyInputs, COMMA_SPLITTER))); }
@Test public void testStringStrideDictionary() throws Exception { tester.testRoundTrip(VARCHAR, newArrayList(concat(ImmutableList.of("a"), nCopies(9999, "123"), ImmutableList.of("b"), nCopies(9999, "123")))); }
@Override public List<String> complete(final CommandSource src, final CommandArgs args, final CommandContext context) { return ImmutableList.copyOf(Iterables.concat(Iterables.transform(this.elements, input -> { if (input == null) { return ImmutableList.of(); } CommandArgs.Snapshot snapshot = args.getSnapshot(); List<String> ret = input.complete(src, args, context); args.applySnapshot(snapshot); return ret; }))); }
public Iterable<InternalRelationType> getRelationIndexes() { return Iterables.concat(ImmutableList.of(this),Iterables.transform(getRelated(TypeDefinitionCategory.RELATIONTYPE_INDEX,Direction.OUT),new Function<Entry, InternalRelationType>() { @Nullable @Override public InternalRelationType apply(@Nullable Entry entry) { assert entry.getSchemaType() instanceof InternalRelationType; return (InternalRelationType)entry.getSchemaType(); } })); }
final List<Class<? extends ResourceFilter>> baseResourceFilters = clazz.getAnnotation(ResourceFilters.class) == null ? Collections.emptyList() : ImmutableList.copyOf(((ResourceFilters) clazz.getAnnotation(ResourceFilters.class)).value()); return ImmutableList.copyOf( Iterables.concat( Iterables.transform(
private List<ColumnDesc> listSourceColumns() { ProjectManager mgr = ProjectManager.getInstance(olapSchema.getConfig()); List<ColumnDesc> tableColumns = mgr.listExposedColumns(olapSchema.getProjectName(), sourceTable, exposeMore); List<ColumnDesc> metricColumns = Lists.newArrayList(); List<MeasureDesc> countMeasures = mgr.listEffectiveRewriteMeasures(olapSchema.getProjectName(), sourceTable.getIdentity()); HashSet<String> metFields = new HashSet<String>(); for (MeasureDesc m : countMeasures) { FunctionDesc func = m.getFunction(); String fieldName = func.getRewriteFieldName(); if (!metFields.contains(fieldName)) { metFields.add(fieldName); ColumnDesc fakeCountCol = func.newFakeRewriteColumn(sourceTable); metricColumns.add(fakeCountCol); } } Collections.sort(tableColumns, new Comparator<ColumnDesc>() { @Override public int compare(ColumnDesc o1, ColumnDesc o2) { return o1.getZeroBasedIndex() - o2.getZeroBasedIndex(); } }); return Lists.newArrayList(Iterables.concat(tableColumns, metricColumns)); }
@Override public Iterable<EntityRef> getEntitiesWith(Class<? extends Component>... componentClasses) { List<Iterable<EntityRef>> entityIterables = new ArrayList<>(); for (EntityPool pool : pools) { entityIterables.add(pool.getEntitiesWith(componentClasses)); } return Iterables.concat(entityIterables); }