Class MongoDbIO.Read
- All Implemented Interfaces:
Serializable
,HasDisplayData
- Enclosing class:
MongoDbIO
PTransform
to read data from MongoDB.- See Also:
-
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOverride this method to specify how thisPTransform
should be expanded on the givenInputT
.long
void
populateDisplayData
(DisplayData.Builder builder) Register display data for the given transform or component.withBucketAuto
(boolean bucketAuto) Sets weather to use $bucketAuto or not.withCollection
(String collection) Sets the collection to consider in the database.withDatabase
(String database) Sets the database to use.withIgnoreSSLCertificate
(boolean ignoreSSLCertificate) Enable ignoreSSLCertificate for ssl for connection (allow for self signed certificates).withMaxConnectionIdleTime
(int maxConnectionIdleTime) Sets the maximum idle time for a pooled connection.withNumSplits
(int numSplits) Sets the user defined number of splits.withQueryFn
(SerializableFunction<MongoCollection<Document>, MongoCursor<Document>> queryBuilderFn) Sets a queryFn.withSSLEnabled
(boolean sslEnabled) Enable ssl for connection.withSSLInvalidHostNameAllowed
(boolean invalidHostNameAllowed) Enable invalidHostNameAllowed for ssl for connection.Define the location of the MongoDB instances using an URI.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setDisplayData, setResourceHints, toString, validate, validate
-
Constructor Details
-
Read
public Read()
-
-
Method Details
-
withUri
Define the location of the MongoDB instances using an URI. The URI describes the hosts to be used and some options.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 theusername: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 withwithDatabase(String)
.?options
are connection options. Note that ifdatabase
is absent there is still a/
required between the lasthost
and the?
introducing the options. Options are name=value pairs and the pairs are separated by "&
". You can pass theMaxConnectionIdleTime
connection option viawithMaxConnectionIdleTime(int)
.
-
withMaxConnectionIdleTime
Sets the maximum idle time for a pooled connection. -
withSSLEnabled
Enable ssl for connection. -
withSSLInvalidHostNameAllowed
Enable invalidHostNameAllowed for ssl for connection. -
withIgnoreSSLCertificate
Enable ignoreSSLCertificate for ssl for connection (allow for self signed certificates). -
withDatabase
Sets the database to use. -
withCollection
Sets the collection to consider in the database. -
withNumSplits
Sets the user defined number of splits. -
withBucketAuto
Sets weather to use $bucketAuto or not. -
withQueryFn
public MongoDbIO.Read withQueryFn(SerializableFunction<MongoCollection<Document>, MongoCursor<Document>> queryBuilderFn) Sets a queryFn. The provided queryFn must be one of the predefined classes in the MongoDbIO package such asFindQuery()
orAggregationQuery()
. -
expand
Description copied from class:PTransform
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
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).
- Specified by:
expand
in classPTransform<PBegin,
PCollection<Document>>
-
getDocumentCount
public long getDocumentCount() -
populateDisplayData
Description copied from class:PTransform
Register display data for the given transform or component.populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect display data viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.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.
- Specified by:
populateDisplayData
in interfaceHasDisplayData
- Overrides:
populateDisplayData
in classPTransform<PBegin,
PCollection<Document>> - Parameters:
builder
- The builder to populate with display data.- See Also:
-