Refine search
@Override protected List<String> create(String[] elements) { List<String> fromList = Lists.newArrayList(); for (String element : elements) { fromList.add("q" + checkNotNull(element)); } return Lists.transform(fromList, removeFirst); } })
@Override protected List<String> create(String[] elements) { List<String> fromList = Lists.newLinkedList(); for (String element : elements) { fromList.add("q" + checkNotNull(element)); } return Lists.transform(fromList, removeFirst); } })
@Override protected ArrayList<LockGraphNode> initialValue() { return Lists.<LockGraphNode>newArrayListWithCapacity(3); } };
@Override protected List<String> create(String[] elements) { List<String> list = Lists.newLinkedList(); for (int i = elements.length - 1; i >= 0; i--) { list.add(elements[i]); } return Lists.reverse(list); } })
private LookupEnabledTestExprMacroTable() { super( Lists.newArrayList( Iterables.concat( TestExprMacroTable.INSTANCE.getMacros(), Collections.singletonList( new LookupExprMacro(createTestLookupReferencesManager(ImmutableMap.of("foo", "xfoo"))) ) ) ) ); }
.intervals(QueryRunnerTestHelper.fullOnIntervalSpec) .aggregators( Lists.newArrayList( Iterables.concat( commonAggregators, Lists.newArrayList( new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index") new TopNResultValue( Arrays.<Map<String, Object>>asList( ImmutableMap.<String, Object>builder() .put("market", "spot") .put("rows", 837L) .put("minIndex", 59.02102279663086D) .build(), ImmutableMap.<String, Object>builder() .put("market", "total_market") .put("rows", 186L) .put("minIndex", 792.3260498046875D) .build(), ImmutableMap.<String, Object>builder() .put("market", "upfront") .put("rows", 186L)
Sets.newHashSet("1200", "1400", "1600"), true ); .intervals(QueryRunnerTestHelper.fullOnIntervalSpec) .aggregators( Lists.newArrayList( Iterables.concat( commonAggregators, Lists.newArrayList( new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index") new TopNResultValue( Arrays.<Map<String, Object>>asList( ImmutableMap.<String, Object>builder() .put("ql_alias", 1400L) .put(QueryRunnerTestHelper.indexMetric, 217725.41940800005D) .put("minIndex", 91.270553D) .build(), ImmutableMap.<String, Object>builder() .put("ql_alias", 1600L) .put(QueryRunnerTestHelper.indexMetric, 210865.67977600006D)
/** * 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")))); }
@Test public void testUnion() throws IOException { Properties props = new Properties(); props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "1", ContainsARetentionPolicy.class.getCanonicalName()); props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "2", ContainsBRetentionPolicy.class.getCanonicalName()); props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "3", ContainsCRetentionPolicy.class.getCanonicalName()); props.setProperty(CombineRetentionPolicy.DELETE_SETS_COMBINE_OPERATION, CombineRetentionPolicy.DeletableCombineOperation.UNION.name()); CombineRetentionPolicy policy = new CombineRetentionPolicy(props); Collection<DatasetVersion> deletableVersions = policy.listDeletableVersions(Lists .<DatasetVersion>newArrayList(new StringDatasetVersion("a", new Path("/")), new StringDatasetVersion("abc", new Path("/")), new StringDatasetVersion("abcd", new Path("/")), new StringDatasetVersion("bc", new Path("/")), new StringDatasetVersion("d", new Path("/")))); Set<String> actualDeletableVersions = Sets .newHashSet(Iterables.transform(deletableVersions, new Function<DatasetVersion, String>() { @Nullable @Override public String apply(DatasetVersion input) { return ((StringDatasetVersion) input).getVersion(); } })); Assert.assertEquals(deletableVersions.size(), 4); Assert.assertEquals(actualDeletableVersions, Sets.newHashSet("abcd", "abc", "a", "bc")); }
final Set<String> workerNodeIds = Sets.newHashSet( workerConfig.getAutoScaler().ipToIdLookup( Lists.newArrayList( Iterables.transform( runner.getLazyWorkers(), new Function<Worker, String>() .terminate(ImmutableList.copyOf(laziestWorkerIps)); if (terminated != null) { currentlyTerminating.addAll(terminated.getNodeIds());
.intervals(QueryRunnerTestHelper.fullOnIntervalSpec) .aggregators( Lists.newArrayList( Iterables.concat( commonAggregators, Lists.newArrayList( new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index") ImmutableList.of( new ExpressionPostAggregator( "dimPostAgg", new TopNResultValue( Arrays.<Map<String, Object>>asList( ImmutableMap.<String, Object>builder() .put(QueryRunnerTestHelper.marketDimension, "upfront") .put("dimPostAgg", "upfrontx") .put("minIndex", 545.9906005859375D) .build(), ImmutableMap.<String, Object>builder() .put(QueryRunnerTestHelper.marketDimension, "total_market") .put("dimPostAgg", "total_marketx")
public static RecordReader<?, ?> createRecordReader(Configuration configuration, Path path, long start, long length, Properties schema, List<HiveColumnHandle> columns) List<HiveColumnHandle> readColumns = ImmutableList.copyOf(filter(columns, column -> column.getColumnType() == REGULAR)); List<Integer> readHiveColumnIndexes = ImmutableList.copyOf(transform(readColumns, HiveColumnHandle::getHiveColumnIndex)); List<String> codecs = newArrayList(Splitter.on(",").trimResults().omitEmptyStrings().split(jobConf.get("io.compression.codecs", ""))); if (!codecs.contains(LzoCodec.class.getName())) { codecs.add(0, LzoCodec.class.getName());
dims = config.getParser().getParseSpec().getDimensionsSpec().getDimensionNames(); } else { Set<String> dimSet = Sets.newHashSet( Iterables.concat( Iterables.transform( segments, new Function<WindowedDataSegment, Iterable<String>>() dims = Lists.newArrayList( Sets.difference( dimSet, config.getParser() updatedIngestionSpec = updatedIngestionSpec.withMetrics(Lists.newArrayList(metrics));
private ImmutableList<IndexItem<?, Object>> loadSezpozIndices(ClassLoader classLoader) { List<IndexItem<?,Object>> indices = Lists.newArrayList(); for (GuiceExtensionAnnotation<?> gea : extensionAnnotations.values()) { Iterables.addAll(indices, Index.load(gea.annotationType, Object.class, classLoader)); } return ImmutableList.copyOf(indices); }
Element element = Iterables.getOnlyElement(baseElements); if (element instanceof PrivateElements) { PrivateElements privateElements = (PrivateElements) element; Elements.getElements( currentStage(), ImmutableList.<Module>builder().addAll(overrides).add(scannersModule).build()); final Set<Key<?>> overriddenKeys = Sets.newHashSet(); final Map<Class<? extends Annotation>, ScopeBinding> overridesScopeAnnotations = Maps.newHashMap(); final List<ScopeBinding> scopeBindings = Lists.newArrayList(); new ModuleWriter(binder) { @Override
@Test public void testListLogEntriesEmpty() { String cursor = "cursor"; EasyMock.replay(rpcFactoryMock); logging = options.getService(); ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build(); List<LogEntry> entriesList = ImmutableList.of(); ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder() .setNextPageToken(cursor) .addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))) .build(); ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response); EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse); EasyMock.replay(loggingRpcMock); Page<LogEntry> page = logging.listLogEntries(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class)); }
public Builder entities(final Iterable<Entity> entities) { if (Iterables.isEmpty(entities)) { return this; } if (Iterables.size(entities) == 1) { return entity(entities.iterator().next()); } if (distinct(Streams.toStream(entities).map(EntityId::getVertex).collect(toList()))) { throw new IllegalArgumentException("Entities must all have the same vertex."); } final Entity entity = entities.iterator().next(); if (!edges.isEmpty()) { final Object root = edges.getLast().stream().findAny().orElseThrow(RuntimeException::new).getAdjacentMatchedVertexValue(); verifyEntity(root, entity); } if (!this.entities.isEmpty()) { final Entry<Object, Set<Entity>> entry = this.entities.getLast(); final Object root = entry.getKey(); verifyEntity(root, entity); final Set<Entity> currentEntities = entry.getValue(); currentEntities.addAll(Lists.newArrayList(entities)); entry.setValue(currentEntities); } else { this.entities.push(new AbstractMap.SimpleEntry<>(entity.getVertex(), Sets.newHashSet(entities))); } return this; }
public void testLimit() { Iterable<String> iterable = newArrayList("foo", "bar", "baz"); Iterable<String> limited = Iterables.limit(iterable, 2); List<String> expected = ImmutableList.of("foo", "bar"); List<String> actual = newArrayList(limited); assertEquals(expected, actual); assertCanIterateAgain(limited); assertEquals("[foo, bar]", limited.toString()); }
private static Sequence<Result<SearchResultValue>> makeReturnResult( Segment segment, int limit, Object2IntRBTreeMap<SearchHit> retVal ) { Iterable<SearchHit> source = Iterables.transform( retVal.object2IntEntrySet(), new Function<Object2IntMap.Entry<SearchHit>, SearchHit>() { @Override public SearchHit apply(Object2IntMap.Entry<SearchHit> input) { SearchHit hit = input.getKey(); return new SearchHit(hit.getDimension(), hit.getValue(), input.getIntValue()); } } ); return Sequences.simple( ImmutableList.of( new Result<>( segment.getDataInterval().getStart(), new SearchResultValue( Lists.newArrayList(new FunctionalIterable<>(source).limit(limit)) ) ) ) ); } }