public abstract static class MongoDbIO.Read extends PTransform<PBegin,PCollection<org.bson.Document>>
PTransform
to read data from MongoDB.name
Constructor and Description |
---|
Read() |
Modifier and Type | Method and Description |
---|---|
PCollection<org.bson.Document> |
expand(PBegin input)
Override this method to specify how this
PTransform should be expanded
on the given InputT . |
void |
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
|
void |
validate(PipelineOptions options)
Called before running the Pipeline to verify this transform is fully and correctly
specified.
|
MongoDbIO.Read |
withCollection(java.lang.String collection)
Sets the collection to consider in the database.
|
MongoDbIO.Read |
withDatabase(java.lang.String database)
Sets the database to use.
|
MongoDbIO.Read |
withFilter(java.lang.String filter)
Sets a filter on the documents in a collection.
|
MongoDbIO.Read |
withKeepAlive(boolean keepAlive)
Sets whether socket keep alive is enabled.
|
MongoDbIO.Read |
withMaxConnectionIdleTime(int maxConnectionIdleTime)
Sets the maximum idle time for a pooled connection.
|
MongoDbIO.Read |
withNumSplits(int numSplits)
Sets the user defined number of splits.
|
MongoDbIO.Read |
withUri(java.lang.String uri)
Define the location of the MongoDB instances using an URI.
|
getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, toString
public MongoDbIO.Read withUri(java.lang.String uri)
The format of the URI is:
mongodb://[username:password@]host1[:port1]...[,hostN[:portN]]][/[database][?options]]
Where:
mongodb://
is a required prefix to identify that this is a string in the
standard connection format.username:password@
are optional. If given, the driver will attempt to
login to a database after connecting to a database server. For some authentication
mechanisms, only the username is specified and the password is not, in which case
the ":" after the username is left off as well.host1
is the only required part of the URI. It identifies a server
address to connect to.:portX
is optional and defaults to :27017
if not provided./database
is the name of the database to login to and thus is only
relevant if the username:password@
syntax is used. If not specified, the
"admin" database will be used by default. It has to be equivalent with the database
you specific with withDatabase(String)
.?options
are connection options. Note that if database
is absent
there is still a /
required between the last host
and the ?
introducing the options. Options are name=value pairs and the pairs are separated by
"&
". The KeepAlive
connection option can't be passed via the URI,
instead you have to use withKeepAlive(boolean)
. Same for the
MaxConnectionIdleTime
connection option via
withMaxConnectionIdleTime(int)
.
public MongoDbIO.Read withKeepAlive(boolean keepAlive)
public MongoDbIO.Read withMaxConnectionIdleTime(int maxConnectionIdleTime)
public MongoDbIO.Read withDatabase(java.lang.String database)
public MongoDbIO.Read withCollection(java.lang.String collection)
public MongoDbIO.Read withFilter(java.lang.String filter)
public MongoDbIO.Read withNumSplits(int numSplits)
public PCollection<org.bson.Document> expand(PBegin input)
PTransform
PTransform
should be expanded
on the given InputT
.
NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to the InputT
using the apply
method.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
expand
in class PTransform<PBegin,PCollection<org.bson.Document>>
public void validate(PipelineOptions options)
PTransform
By default, does nothing.
validate
in class PTransform<PBegin,PCollection<org.bson.Document>>
public void populateDisplayData(DisplayData.Builder builder)
PTransform
populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect
display data via DisplayData.from(HasDisplayData)
. Implementations may call
super.populateDisplayData(builder)
in order to register display data in the current
namespace, but should otherwise use subcomponent.populateDisplayData(builder)
to use
the namespace of the subcomponent.
By default, does not register any display data. Implementors may override this method to provide their own display data.
populateDisplayData
in interface HasDisplayData
populateDisplayData
in class PTransform<PBegin,PCollection<org.bson.Document>>
builder
- The builder to populate with display data.HasDisplayData