Java Code Examples for org.apache.beam.sdk.options.ValueProvider#isAccessible()
The following examples show how to use
org.apache.beam.sdk.options.ValueProvider#isAccessible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayData.java From beam with Apache License 2.0 | 6 votes |
/** Create a display item for the specified key and {@link ValueProvider}. */ public static ItemSpec<?> item(String key, @Nullable ValueProvider<?> value) { if (value == null) { return item(key, Type.STRING, null); } if (value.isAccessible()) { Object got = value.get(); if (got == null) { return item(key, Type.STRING, null); } Type type = inferType(got); if (type != null) { return item(key, type, got); } } // General case: not null and type not inferable. Fall back to toString of the VP itself. return item(key, Type.STRING, String.valueOf(value)); }
Example 2
Source File: BigQueryIO.java From beam with Apache License 2.0 | 6 votes |
/** * Returns the table to write, or {@code null} if writing with {@code tableFunction}. * * <p>If the table's project is not specified, use the executing project. */ @Nullable ValueProvider<TableReference> getTableWithDefaultProject(BigQueryOptions bqOptions) { ValueProvider<TableReference> table = getTable(); if (table == null) { return table; } if (!table.isAccessible()) { LOG.info( "Using a dynamic value for table input. This must contain a project" + " in the table reference: {}", table); return table; } if (Strings.isNullOrEmpty(table.get().getProjectId())) { // If user does not specify a project we assume the table to be located in // the default project. TableReference tableRef = table.get(); tableRef.setProjectId(bqOptions.getProject()); return NestedValueProvider.of( StaticValueProvider.of(BigQueryHelpers.toJsonString(tableRef)), new JsonTableRefToTableRef()); } return table; }
Example 3
Source File: KafkaIO.java From DataflowTemplates with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void populateDisplayData(DisplayData.Builder builder) { super.populateDisplayData(builder); ValueProvider<List<String>> topics = getTopics(); List<TopicPartition> topicPartitions = getTopicPartitions(); if (topics != null) { if (topics.isAccessible()) { builder.add(DisplayData.item("topics", Joiner.on(",").join(topics.get())) .withLabel("Topic/s")); } else { builder.add(DisplayData.item("topics", topics).withLabel("Topic/s")); } } else if (topicPartitions.size() > 0) { builder.add( DisplayData.item("topicPartitions", Joiner.on(",").join(topicPartitions)) .withLabel("Topic Partition/s")); } builder.add(DisplayData.item(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, getBootstrapServers())); Set<String> ignoredConsumerPropertiesKeys = IGNORED_CONSUMER_PROPERTIES.keySet(); for (Map.Entry<String, Object> conf : getConsumerConfig().entrySet()) { String key = conf.getKey(); if (!ignoredConsumerPropertiesKeys.contains(key)) { Object value = DisplayData.inferType(conf.getValue()) != null ? conf.getValue() : String.valueOf(conf.getValue()); builder.add(DisplayData.item(key, ValueProvider.StaticValueProvider.of(value))); } } }
Example 4
Source File: DynamicDestinationsHelpers.java From beam with Apache License 2.0 | 5 votes |
ConstantTimePartitioningDestinations( DynamicDestinations<T, TableDestination> inner, ValueProvider<String> jsonTimePartitioning, ValueProvider<String> jsonClustering) { super(inner); checkArgument(jsonTimePartitioning != null, "jsonTimePartitioning provider can not be null"); if (jsonTimePartitioning.isAccessible()) { checkArgument(jsonTimePartitioning.get() != null, "jsonTimePartitioning can not be null"); } this.jsonTimePartitioning = jsonTimePartitioning; this.jsonClustering = jsonClustering; }
Example 5
Source File: PubsubIO.java From beam with Apache License 2.0 | 5 votes |
/** Like {@code subscription()} but with a {@link ValueProvider}. */ public Read<T> fromSubscription(ValueProvider<String> subscription) { if (subscription.isAccessible()) { // Validate. PubsubSubscription.fromPath(subscription.get()); } return toBuilder() .setSubscriptionProvider( NestedValueProvider.of(subscription, PubsubSubscription::fromPath)) .build(); }
Example 6
Source File: PubsubIO.java From beam with Apache License 2.0 | 5 votes |
/** Like {@code topic()} but with a {@link ValueProvider}. */ public Read<T> fromTopic(ValueProvider<String> topic) { if (topic.isAccessible()) { // Validate. PubsubTopic.fromPath(topic.get()); } return toBuilder() .setTopicProvider(NestedValueProvider.of(topic, PubsubTopic::fromPath)) .build(); }
Example 7
Source File: DatastoreV1.java From beam with Apache License 2.0 | 5 votes |
/** Same as {@link Read#withLiteralGqlQuery(String)} but with a {@link ValueProvider}. */ public DatastoreV1.Read withLiteralGqlQuery(ValueProvider<String> gqlQuery) { checkArgument(gqlQuery != null, "gqlQuery can not be null"); if (gqlQuery.isAccessible()) { checkArgument(gqlQuery.get() != null, "gqlQuery can not be null"); } return toBuilder().setLiteralGqlQuery(gqlQuery).build(); }
Example 8
Source File: DynamicOneFilePerWindow.java From dlp-dataflow-deidentification with Apache License 2.0 | 4 votes |
public DynamicOneFilePerWindow(ValueProvider<String> filenamePrefix, Integer numShards) { if (filenamePrefix.isAccessible()) this.filenamePrefix = filenamePrefix.get(); else this.filenamePrefix = "output"; this.numShards = numShards; }
Example 9
Source File: WriteOneFilePerWindow.java From dlp-dataflow-deidentification with Apache License 2.0 | 4 votes |
public WriteOneFilePerWindow(ValueProvider<String> filenamePrefix, Integer numShards) { if (filenamePrefix.isAccessible()) this.filenamePrefix = filenamePrefix.get(); else this.filenamePrefix = "output"; this.numShards = numShards; }
Example 10
Source File: BigtableIO.java From beam with Apache License 2.0 | 4 votes |
/** Returns the table being read from. */ @Nullable public String getTableId() { ValueProvider<String> tableId = getBigtableConfig().getTableId(); return tableId != null && tableId.isAccessible() ? tableId.get() : null; }