Refine search
private List<Set<RoutingTable>> toRoutingTableGroups(final String dataSource, final List<Set<String>> actualTableGroups) { List<Set<RoutingTable>> result = new ArrayList<>(actualTableGroups.size()); for (Set<String> each : actualTableGroups) { result.add(new HashSet<>(Lists.transform(new ArrayList<>(each), new Function<String, RoutingTable>() { @Override public RoutingTable apply(final String input) { return findRoutingTable(dataSource, input); } }))); } return result; }
@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 public void onEvent(RawMessageEvent event, long sequence, boolean endOfBatch) throws Exception { batch.add(event); log.debug("End of batch, journalling {} messages", batch.size()); final List<Journal.Entry> entries = Lists.newArrayList(transform(batch, converter));
@Override public Map<NamedKey, byte[]> getBulk(Iterable<NamedKey> keys) { totalRequestCount.incrementAndGet(); Map<NamedKey, byte[]> results = new HashMap<>(); try (Jedis jedis = pool.getResource()) { List<NamedKey> namedKeys = Lists.newArrayList(keys); List<byte[]> byteKeys = Lists.transform(namedKeys, NamedKey::toByteArray); List<byte[]> byteValues = jedis.mget(byteKeys.toArray(new byte[0][])); for (int i = 0; i < byteValues.size(); ++i) { if (byteValues.get(i) != null) { results.put(namedKeys.get(i), byteValues.get(i)); } } hitCount.addAndGet(results.size()); missCount.addAndGet(namedKeys.size() - results.size()); } catch (JedisException e) { if (e.getMessage().contains("Read timed out")) { timeoutCount.incrementAndGet(); } else { errorCount.incrementAndGet(); } log.warn(e, "Exception pulling items from cache"); } return results; }
progress.progress(); List<Metadata> metadataList = Lists.transform(adapters, IndexableAdapter::getMetadata); final Map<String, ValueType> metricsValueTypes = new TreeMap<>(Comparators.naturalNullsFirst()); final Map<String, String> metricTypeNames = new TreeMap<>(Comparators.naturalNullsFirst()); final List<ColumnCapabilitiesImpl> dimCapabilities = Lists.newArrayListWithCapacity(mergedDimensions.size()); mergeCapabilities(adapters, mergedDimensions, metricsValueTypes, metricTypeNames, dimCapabilities); for (int i = 0; i < mergedDimensions.size(); i++) { DimensionHandler handler = handlers.get(mergedDimensions.get(i)); mergers.add(handler.makeMerger(indexSpec, segmentWriteOutMedium, dimCapabilities.get(i), progress, closer)); ); for (int i = 0; i < mergedDimensions.size(); i++) { DimensionMergerV9 merger = mergers.get(i); merger.writeIndexes(rowNumConversions);
/** * Returns the list of plugins as defined in the system configuration. These are the * defined in the PLUGINS_FULL_KEY config option. * The list also includes plugins that are automatically added by gobblin. * */ public List<GobblinInstancePluginFactory> getDefaultPlugins() { List<String> pluginNames = ConfigUtils.getStringList(getSysConfig().getConfig(), PLUGINS_FULL_KEY); List<GobblinInstancePluginFactory> pluginFactories = Lists.newArrayList(); // By default email notification plugin is added. if (!ConfigUtils.getBoolean(getSysConfig().getConfig(), EmailNotificationPlugin.EMAIL_NOTIFICATIONS_DISABLED_KEY, EmailNotificationPlugin.EMAIL_NOTIFICATIONS_DISABLED_DEFAULT)) { pluginFactories.add(new EmailNotificationPlugin.Factory()); } pluginFactories.addAll(Lists.transform(pluginNames, new Function<String, GobblinInstancePluginFactory>() { @Override public GobblinInstancePluginFactory apply(String input) { Class<? extends GobblinInstancePluginFactory> factoryClass; try { factoryClass = _aliasResolver.resolveClass(input); return factoryClass.newInstance(); } catch (ClassNotFoundException|InstantiationException|IllegalAccessException e) { throw new RuntimeException("Unable to instantiate plugin factory " + input + ": " + e, e); } } })); return pluginFactories; }
private void init() { this.timeCounter = 0; this.currentTime = startTime; dimensionNames = new ArrayList<>(); for (BenchmarkColumnSchema schema : columnSchemas) { if (!schema.isMetric()) { dimensionNames.add(schema.getName()); } } columnGenerators = new ArrayList<>(); columnGenerators.addAll( Lists.transform( columnSchemas, new Function<BenchmarkColumnSchema, BenchmarkColumnValueGenerator>() { @Override public BenchmarkColumnValueGenerator apply( BenchmarkColumnSchema input ) { return input.makeGenerator(seed); } } ) ); }
private List<String> sanitizeAndValidatePermissions(final List<String> permissionsRaw) throws SecurityApiException { if (permissionsRaw == null) { return ImmutableList.<String>of(); final Collection<String> permissions = Collections2.<String>filter(Lists.<String, String>transform(permissionsRaw, new Function<String, String>() { @Override for (final String curPerm : permissions) { if ("*".equals(curPerm)) { return ImmutableList.of("*"); final Set<String> groupPermissions = groupToValues.get(group); for (final String value : groupPermissions) { sanitizedPermissions.add(String.format("%s:%s", group, value));
static InsertAllResponse fromPb(TableDataInsertAllResponse responsePb) { Map<Long, List<BigQueryError>> insertErrors = null; if (responsePb.getInsertErrors() != null) { List<InsertErrors> errorsPb = responsePb.getInsertErrors(); insertErrors = Maps.newHashMapWithExpectedSize(errorsPb.size()); for (InsertErrors errorPb : errorsPb) { insertErrors.put( errorPb.getIndex(), Lists.transform( errorPb.getErrors() != null ? errorPb.getErrors() : ImmutableList.<ErrorProto>of(), BigQueryError.FROM_PB_FUNCTION)); } } return new InsertAllResponse(insertErrors); } }
theMap.put("text", (null == text) ? "" : text); theMap.put( "htags", (hts.length > 0) ? Lists.transform( Arrays.asList(hts), new Function<HashtagEntity, String>() ) : ImmutableList.<String>of() ); List<String> contributors = new ArrayList<>(); for (long contrib : lcontrobutors) { contributors.add(StringUtils.format("%d", contrib)); List<String> dimensions = Lists.newArrayList(theMap.keySet());
int nTasks = nThreads * tasksPerThread; ExecutorService pool = Executors.newFixedThreadPool(nThreads); ImmutableList<String> keys = ImmutableList.of("a", "b", "c"); try { List<Future<int[]>> futures = Lists.newArrayListWithExpectedSize(nTasks); for (int i = 0; i < nTasks; i++) { futures.add(pool.submit(new MutateTask(multiset, keys))); Lists.transform( keys, new Function<String, Integer>() {
@VisibleForTesting protected List<String> getPrioritizedDistributedJars() { List<Map.Entry<String, Integer>> jarsWithPriority = Lists.newArrayList(this.distributedJars.entrySet()); Collections.sort(jarsWithPriority, new Comparator<Map.Entry<String, Integer>>() { @Override public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) { return Integer.compare(o1.getValue(), o2.getValue()); } }); return Lists.transform(jarsWithPriority, new Function<Map.Entry<String, Integer>, String>() { @Override public String apply(Map.Entry<String, Integer> input) { return input.getKey(); } }); }
public void testTransformPreservesIOOBEsThrownByFunction() { try { Lists.transform( ImmutableList.of("foo", "bar"), new Function<String, String>() { @Override public String apply(String input) { throw new IndexOutOfBoundsException(); } }) .toArray(); fail(); } catch (IndexOutOfBoundsException expected) { // success } }
public static HiveProject createProjectWithoutColumn(RelNode input, Set<Integer> positions) throws CalciteSemanticException { List<RexNode> originalInputRefs = Lists.transform(input.getRowType().getFieldList(), new Function<RelDataTypeField, RexNode>() { @Override public RexNode apply(RelDataTypeField input) { return new RexInputRef(input.getIndex(), input.getType()); } }); List<RexNode> copyInputRefs = new ArrayList<>(); for (int i = 0; i < originalInputRefs.size(); i++) { if (!positions.contains(i)) { copyInputRefs.add(originalInputRefs.get(i)); } } return HiveProject.create(input, copyInputRefs, null); }
List<FooterStatCollector> validColectors = Lists.newArrayList(); for (FooterStatCollector statsCollection : scs) { if (statsCollection.isValid()) { validColectors.add(statsCollection); } else { if (values.get(0).result instanceof Partition) { List<Partition> results = Lists.transform(values, FooterStatCollector.EXTRACT_RESULT_FUNCTION); db.alterPartitions(tableFullName, results, environmentContext, true); LOG.debug("Bulk updated {} partitions of {}.", results.size(), tableFullName); } else { throw new RuntimeException("inconsistent");
private static String selector( List<? extends FieldSelector> required, FieldSelector[] others, String... extraResourceFields) { Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(required.size() + others.length); fieldStrings.addAll(Lists.transform(required, FIELD_TO_STRING_FUNCTION)); fieldStrings.addAll(Lists.transform(Arrays.asList(others), FIELD_TO_STRING_FUNCTION)); fieldStrings.addAll(Arrays.asList(extraResourceFields)); return Joiner.on(',').join(fieldStrings); }
@Override public Void visitRowNumber(RowNumberNode node, Integer indent) { List<String> partitionBy = Lists.transform(node.getPartitionBy(), Functions.toStringFunction()); List<String> args = new ArrayList<>(); if (!partitionBy.isEmpty()) { args.add(format("partition by (%s)", Joiner.on(", ").join(partitionBy))); } if (node.getMaxRowCountPerPartition().isPresent()) { args.add(format("limit = %s", node.getMaxRowCountPerPartition().get())); } print(indent, "- RowNumber[%s]%s => [%s]", Joiner.on(", ").join(args), formatHash(node.getHashSymbol()), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); print(indent + 2, "%s := %s", node.getRowNumberSymbol(), "row_number()"); return processChildren(node, indent + 1); }
public static DatedEventIndex create(DB db) { List<String> dates = db.findByPrefix(DATE_PREFIX, DATE_PREFIX.length()); List<Long> earliestEventIds = Lists.newArrayList( Lists.transform(db.findByPrefix(ID_PREFIX, ID_PREFIX.length()), new Function<String, Long>() { @Override public Long apply(String s) { return Long.parseLong(s); } })); return new DatedEventIndex(db, dates, earliestEventIds, dates.isEmpty() ? "" : dates.get(dates.size() - 1)); } }