@Override public Iterable<Vertex> getNeighbors(final int value) { return Iterables.transform(Iterables.filter(outEdges, new Predicate<Edge>() { @Override public boolean apply(@Nullable Edge edge) { return !CHECK_VALUE || ((Integer) edge.getProperty("number")).intValue() == value; } }), new Function<Edge, Vertex>() { @Override public Vertex apply(@Nullable Edge edge) { return edge.getEnd(); } }); }
@Override public String toString() { StringBuilder builder = new StringBuilder(); if (ownerType != null && JavaVersion.CURRENT.jdkTypeDuplicatesOwnerName()) { builder.append(JavaVersion.CURRENT.typeName(ownerType)).append('.'); } return builder .append(rawType.getName()) .append('<') .append(COMMA_JOINER.join(transform(argumentsList, TYPE_NAME))) .append('>') .toString(); }
private static List<String> fieldsName(List<Field> fields){ return newArrayList(Iterables.transform(fields, new Function<Field, String>() { @Override public String apply(@Nullable Field input) { return input != null ? input.getName() : null; } })); }
/** * Generate DDL for dropping partitions of a table. * <p> * ALTER TABLE finalTableName DROP IF EXISTS PARTITION partition_spec, PARTITION partition_spec, ...; * </p> * @param finalTableName Table name where partitions are dropped * @param partitionDMLInfos list of Partition to be dropped * @return DDL to drop partitions in <code>finalTableName</code> */ public static List<String> generateDropPartitionsDDL(final String dbName, final String finalTableName, final List<Map<String, String>> partitionDMLInfos) { if (partitionDMLInfos.isEmpty()) { return Collections.emptyList(); } List<String> ddls = Lists.newArrayList(); ddls.add(String.format("USE %s %n", dbName)); // Join the partition specs ddls.add(String.format("ALTER TABLE %s DROP IF EXISTS %s", finalTableName, Joiner.on(",").join(Iterables.transform(partitionDMLInfos, PARTITION_SPEC_GENERATOR)))); return ddls; }
splitProperties.setProperty(FILE_INPUT_FORMAT, storageFormat.getInputFormat()); splitProperties.setProperty(SERIALIZATION_LIB, storageFormat.getSerDe()); splitProperties.setProperty("columns", Joiner.on(',').join(transform(filter(testColumns, not(TestColumn::isPartitionKey)), TestColumn::getName))); splitProperties.setProperty("columns.types", Joiner.on(',').join(transform(filter(testColumns, not(TestColumn::isPartitionKey)), TestColumn::getType)));
@Deprecated @JsonIgnore public List<SpatialDimensionSchema> getSpatialDimensions() { Iterable<NewSpatialDimensionSchema> filteredList = Iterables.filter(dimensions, NewSpatialDimensionSchema.class); Iterable<SpatialDimensionSchema> transformedList = Iterables.transform( filteredList, new Function<NewSpatialDimensionSchema, SpatialDimensionSchema>() { @Nullable @Override public SpatialDimensionSchema apply(NewSpatialDimensionSchema input) { return new SpatialDimensionSchema(input.getName(), input.getDims()); } } ); return Lists.newArrayList(transformedList); }
List<String> explicitColumnOrder = new ArrayList<>(ImmutableList.copyOf(transform(extras, ExtraColumnMetadata::getName))); hiddenColumns = ImmutableSet.copyOf(transform(filter(extras, ExtraColumnMetadata::isHidden), ExtraColumnMetadata::getName)); Iterables.addAll(explicitColumnOrder, filter(columnNames, not(in(explicitColumnOrder))));
@Override protected Void visitCreateTableAsSelect(final CreateTableAsSelect node, final Integer indent) { builder.append("CREATE TABLE "); if (node.isNotExists()) { builder.append("IF NOT EXISTS "); } builder.append(node.getName()); if (!node.getProperties().isEmpty()) { builder.append(" WITH ("); Joiner.on(", ") .appendTo(builder, transform( node.getProperties().entrySet(), entry -> entry.getKey() + " = " + ExpressionFormatter .formatExpression(entry.getValue()))); builder.append(")"); } builder.append(" AS "); process(node.getQuery(), indent); return null; }
public Collection<PluginUpdateAggregate> aggregate(@Nullable Collection<PluginUpdate> pluginUpdates) { if (pluginUpdates == null || pluginUpdates.isEmpty()) { return Collections.emptyList(); } Map<Plugin, PluginUpdateAggregateBuilder> builders = Maps.newHashMap(); for (PluginUpdate pluginUpdate : pluginUpdates) { Plugin plugin = pluginUpdate.getPlugin(); PluginUpdateAggregateBuilder builder = builders.get(plugin); if (builder == null) { builder = PluginUpdateAggregateBuilder.builderFor(plugin); builders.put(plugin, builder); } builder.add(pluginUpdate); } return Lists.newArrayList(transform(builders.values(), PluginUpdateAggregateBuilder::build)); }
/** * Like {@code inputs.toString()}, but with the nonsense {@code toString} representations * replaced with the name of each future from {@link #allFutures}. */ String smartToString(ImmutableSet<ListenableFuture<String>> inputs) { Iterable<String> inputNames = Iterables.transform(inputs, nameGetter); return Joiner.on(", ").join(inputNames); }
} else { List<String> suppressions = Lists.newArrayList(extantSuppressWarnings.value()); suppressions.add(checkerName); + Joiner.on(',').join(Iterables.transform(suppressions, s -> '"' + s + '"')) + "}) " + config.getAutofixSuppressionComment();
splitProperties.setProperty(FILE_INPUT_FORMAT, storageFormat.getInputFormat()); splitProperties.setProperty(SERIALIZATION_LIB, storageFormat.getSerDe()); splitProperties.setProperty("columns", Joiner.on(',').join(transform(filter(testColumns, not(TestColumn::isPartitionKey)), TestColumn::getName))); splitProperties.setProperty("columns.types", Joiner.on(',').join(transform(filter(testColumns, not(TestColumn::isPartitionKey)), TestColumn::getType)));
/** * 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))); }
@Override public String toString() { StringBuilder builder = new StringBuilder(); if (ownerType != null && JavaVersion.CURRENT.jdkTypeDuplicatesOwnerName()) { builder.append(JavaVersion.CURRENT.typeName(ownerType)).append('.'); } return builder .append(rawType.getName()) .append('<') .append(COMMA_JOINER.join(transform(argumentsList, TYPE_NAME))) .append('>') .toString(); }
@Override public Iterable<Vertex> getNeighbors(final int value) { // SortedSet<ByteEntry> set = (SortedSet<ByteEntry>) tx.get(id); return Iterables.transform(Iterables.filter(set, new Predicate<ByteEntry>() { @Override public boolean apply(@Nullable ByteEntry entry) { return !CHECK_VALUE || entry.value.getInt(0) == value; } }), new Function<ByteEntry, Vertex>() { @Override public Vertex apply(@Nullable ByteEntry entry) { return new ByteVertex(entry.key.getLong(8), tx); } }); } }
@Override protected Void visitCreateStreamAsSelect(final CreateStreamAsSelect node, final Integer indent) { builder.append("CREATE STREAM "); if (node.isNotExists()) { builder.append("IF NOT EXISTS "); } builder.append(node.getName()); if (!node.getProperties().isEmpty()) { builder.append(" WITH ("); Joiner.on(", ") .appendTo(builder, transform( node.getProperties().entrySet(), entry -> entry.getKey() + " = " + ExpressionFormatter .formatExpression(entry.getValue()))); builder.append(")"); } builder.append(" AS "); process(node.getQuery(), indent); return null; }
public void testNullFriendlyTransform() { List<Integer> input = asList(1, 2, null, 3); Iterable<String> result = Iterables.transform( input, new Function<Integer, String>() { @Override public String apply(Integer from) { return String.valueOf(from); } }); List<String> actual = newArrayList(result); List<String> expected = asList("1", "2", "null", "3"); assertEquals(expected, actual); }