public final class S3Sinks extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Sink<? super T> |
s3(String bucketName,
String prefix,
Charset charset,
SupplierEx<? extends software.amazon.awssdk.services.s3.S3Client> clientSupplier,
FunctionEx<? super T,String> toStringFn)
Creates an AWS S3
Sink which writes items to files into the
given bucket. |
static <T> Sink<? super T> |
s3(String bucketName,
SupplierEx<? extends software.amazon.awssdk.services.s3.S3Client> clientSupplier)
Convenience for
s3(String, String, Charset, SupplierEx, FunctionEx)
Uses Object.toString() to convert the items to lines. |
@Nonnull public static <T> Sink<? super T> s3(@Nonnull String bucketName, @Nonnull SupplierEx<? extends software.amazon.awssdk.services.s3.S3Client> clientSupplier)
s3(String, String, Charset, SupplierEx, FunctionEx)
Uses Object.toString()
to convert the items to lines.@Nonnull public static <T> Sink<? super T> s3(@Nonnull String bucketName, @Nullable String prefix, @Nonnull Charset charset, @Nonnull SupplierEx<? extends software.amazon.awssdk.services.s3.S3Client> clientSupplier, @Nonnull FunctionEx<? super T,String> toStringFn)
Sink
which writes items to files into the
given bucket. Sink converts each item to string using given toStringFn
and writes it as a line. The sink creates a file
in the bucket for each processor instance. Name of the file will include
an user provided prefix (if defined) and processor's global index,
for example the processor having the
index 2 with prefix my-object-
will create the object
my-object-2
.
No state is saved to snapshot for this sink. If the job is restarted previously written files will be overwritten.
The default local parallelism for this sink is 1.
Here is an example which reads from a map and writes the entries
to given bucket using Object.toString()
to convert the
values to a line.
Pipeline p = Pipeline.create();
p.readFrom(Sources.map("map"))
.writeTo(S3Sinks.s3("bucket", "my-map-", StandardCharsets.UTF_8,
() -> S3Client.create(),
Object::toString
));
T
- type of the items the sink acceptsbucketName
- the name of the bucketprefix
- the prefix to be included in the file namecharset
- the charset to be used when encoding the stringsclientSupplier
- S3 client suppliertoStringFn
- the function which converts each item to its
string representationCopyright © 2023 Hazelcast, Inc.. All rights reserved.