/** * Similar to {@link #withSchema(TableSchema)} but takes in a JSON-serialized {@link * TableSchema}. */ public Write<T> withJsonSchema(String jsonSchema) { checkArgument(jsonSchema != null, "jsonSchema can not be null"); return withJsonSchema(StaticValueProvider.of(jsonSchema)); }
@Override public ValueProvider<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonDeserializer dser = ctxt.findRootValueDeserializer( checkNotNull( innerType, "Invalid %s: innerType is null. Serialization error?", getClass())); Object o = dser.deserialize(jp, ctxt); return StaticValueProvider.of(o); } }
@Test public void testStaticValueProvider() { ValueProvider<String> provider = StaticValueProvider.of("foo"); assertEquals("foo", provider.get()); assertTrue(provider.isAccessible()); assertEquals("foo", provider.toString()); }
static Write create() { BigtableConfig config = BigtableConfig.builder() .setTableId(ValueProvider.StaticValueProvider.of("")) .setValidate(true) .setBigtableOptionsConfigurator(enableBulkApiConfigurator(null)) .build(); return new AutoValue_BigtableIO_Write.Builder().setBigtableConfig(config).build(); }
/** * Returns a new {@link BigtableIO.Read} that will read from the Cloud Bigtable project * indicated by given parameter, requires {@link #withInstanceId} to be called to determine the * instance. * * <p>Does not modify this object. */ public Read withProjectId(String projectId) { return withProjectId(ValueProvider.StaticValueProvider.of(projectId)); }
/** * Writes to the given table, specified in the format described in {@link * BigQueryHelpers#parseTableSpec}. */ public Write<T> to(String tableSpec) { return to(StaticValueProvider.of(tableSpec)); }
/** * Specifies the project ID for the Cloud Bigtable instance. * @param projectId The project ID for the instance. * @return The {@link CloudBigtableConfiguration.Builder} for chaining convenience. */ public Builder withProjectId(String projectId) { return withProjectId(StaticValueProvider.of(projectId)); }
/** * Returns a transform for reading TFRecord files that reads from the file(s) with the given * filename or filename pattern. This can be a local path (if running locally), or a Google * Cloud Storage filename or filename pattern of the form {@code "gs://<bucket>/<filepath>"} (if * running locally or using remote execution). Standard <a * href="http://docs.oracle.com/javase/tutorial/essential/io/find.html" >Java Filesystem glob * patterns</a> ("*", "?", "[..]") are supported. */ public Read from(String filepattern) { return from(StaticValueProvider.of(filepattern)); }
@Override public FileBasedSource<T> apply(String input) { return Read.createSource( StaticValueProvider.of(input), EmptyMatchTreatment.DISALLOW, recordClass, schemaSupplier.get()); } }
@Override public void populateDisplayData(DisplayData.Builder builder) { builder.add(DisplayData.item("foo", StaticValueProvider.of("bar"))); } });
/** * Create a new WriteOperation. * * @param sink the FileBasedSink that will be used to configure this write operation. * @param tempDirectory the base directory to be used for temporary output files. */ @Experimental(Kind.FILESYSTEM) public WriteOperation(FileBasedSink<?, DestinationT, OutputT> sink, ResourceId tempDirectory) { this(sink, StaticValueProvider.of(tempDirectory)); }
/** * Specifies to use a given fixed number of shards per window. 0 means runner-determined * sharding. Specifying a non-zero value may hurt performance, because it will limit the * parallelism of writing and will introduce an extra {@link GroupByKey} operation. */ public Write<DestinationT, UserT> withNumShards(int numShards) { checkArgument(numShards >= 0, "numShards must be non-negative, but was: %s", numShards); if (numShards == 0) { return withNumShards(null); } return withNumShards(StaticValueProvider.of(numShards)); }
/** * Specifies a common suffix to use for all generated filenames, if using the default file * naming. Incompatible with {@link #withNaming}. */ public Write<DestinationT, UserT> withSuffix(String suffix) { checkArgument(suffix != null, "suffix can not be null"); return withSuffix(StaticValueProvider.of(suffix)); }
/** * Specifies the Cloud Bigtable instanceId. * @param instanceId The Cloud Bigtable instanceId. * @return The {@link CloudBigtableConfiguration.Builder} for chaining convenience. */ public Builder withInstanceId(String instanceId) { return withInstanceId(StaticValueProvider.of(instanceId)); }
/** * Returns a new {@link BigtableIO.Write} that will write to the specified table. * * <p>Does not modify this object. */ public Write withTableId(String tableId) { return withTableId(ValueProvider.StaticValueProvider.of(tableId)); }
/** * Returns a new {@link BigtableIO.Read} that will read from the Cloud Bigtable instance * indicated by given parameter, requires {@link #withProjectId} to be called to determine the * project. * * <p>Does not modify this object. */ public Read withInstanceId(String instanceId) { return withInstanceId(ValueProvider.StaticValueProvider.of(instanceId)); }
@Test public void testNullTopic() { String subscription = "projects/project/subscriptions/subscription"; PubsubIO.Read<String> read = PubsubIO.readStrings().fromSubscription(StaticValueProvider.of(subscription)); assertNull(read.getTopicProvider()); assertNotNull(read.getSubscriptionProvider()); assertNotNull(DisplayData.from(read)); }
@Override public FilenamePolicy getFilenamePolicy(String destination) { return DefaultFilenamePolicy.fromStandardParameters( StaticValueProvider.of(baseDir.resolve("file_" + destination, RESOLVE_FILE)), "-SSSSS-of-NNNNN", ".avro", false); } }
/** Set the base directory used to generate temporary files. */ @Experimental(Kind.FILESYSTEM) public TypedWrite<UserT, DestinationT, OutputT> withTempDirectory(ResourceId tempDirectory) { return withTempDirectory(StaticValueProvider.of(tempDirectory)); }
/** * Creates a {@code BlockBasedSource} based on a file name or pattern. Subclasses must call this * constructor when creating a {@code BlockBasedSource} for a file pattern. See {@link * FileBasedSource} for more information. */ public BlockBasedSource( String fileOrPatternSpec, EmptyMatchTreatment emptyMatchTreatment, long minBundleSize) { this(StaticValueProvider.of(fileOrPatternSpec), emptyMatchTreatment, minBundleSize); }