Package com.influxdb.v3.client.write
Class WriteOptions
java.lang.Object
com.influxdb.v3.client.write.WriteOptions
Write options.
Supports to specify:
database
- specifies the database to be used for InfluxDB operationsorganization
- specifies the organization to be used for InfluxDB operationsprecision
- specifies the precision to use for the timestamp of pointsdefaultTags
- specifies tags to be added by default to all write operations using points.headers
- specifies the headers to be added to write request
To add custom headers to the write request, use the following code:
WriteOptions options = new WriteOptions(Map.of("X-Tracing-Id", "123")); client.writeRecord(options, point);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A builder forWriteOptions
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Integer
Default GZIP threshold.static final boolean
Default NoSync.static final WritePrecision
Default WritePrecision.static final WriteOptions
Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionWriteOptions
(String database, WritePrecision precision, Integer gzipThreshold) Construct WriteAPI options.WriteOptions
(String database, WritePrecision precision, Integer gzipThreshold, Boolean noSync) Construct WriteAPI options.WriteOptions
(String database, WritePrecision precision, Integer gzipThreshold, Boolean noSync, Map<String, String> defaultTags, Map<String, String> headers) Construct WriteAPI options.WriteOptions
(String database, WritePrecision precision, Integer gzipThreshold, Map<String, String> defaultTags) Construct WriteAPI options.WriteOptions
(String database, WritePrecision precision, Integer gzipThreshold, Map<String, String> defaultTags, Map<String, String> headers) Construct WriteAPI options.WriteOptions
(Map<String, String> headers) Construct WriteAPI options. -
Method Summary
Modifier and TypeMethodDescriptiondatabaseSafe
(ClientConfig config) defaultTagsSafe
(ClientConfig config) static WriteOptions
Creates a default instance ofWriteOptions
configured with standard values.boolean
gzipThresholdSafe
(ClientConfig config) int
hashCode()
boolean
noSyncSafe
(ClientConfig config) precisionSafe
(ClientConfig config)
-
Field Details
-
DEFAULT_WRITE_PRECISION
Default WritePrecision. -
DEFAULT_GZIP_THRESHOLD
Default GZIP threshold. -
DEFAULT_NO_SYNC
public static final boolean DEFAULT_NO_SYNCDefault NoSync.- See Also:
-
DEFAULTS
Deprecated, for removal: This API element is subject to removal in a future version.Default WriteOptions. Deprecated usedefaultWriteOptions()
instead
-
-
Constructor Details
-
WriteOptions
public WriteOptions(@Nullable String database, @Nullable WritePrecision precision, @Nullable Integer gzipThreshold) Construct WriteAPI options.- Parameters:
database
- The database to be used for InfluxDB operations. If it is not specified then useClientConfig.getDatabase()
.precision
- The precision to use for the timestamp of points. If it is not specified then useClientConfig.getWritePrecision()
.gzipThreshold
- The threshold for compressing request body. If it is not specified then useDEFAULT_GZIP_THRESHOLD
.
-
WriteOptions
public WriteOptions(@Nullable String database, @Nullable WritePrecision precision, @Nullable Integer gzipThreshold, @Nullable Map<String, String> defaultTags) Construct WriteAPI options.- Parameters:
database
- The database to be used for InfluxDB operations. If it is not specified then useClientConfig.getDatabase()
.precision
- The precision to use for the timestamp of points. If it is not specified then useClientConfig.getWritePrecision()
.gzipThreshold
- The threshold for compressing request body. If it is not specified then useDEFAULT_GZIP_THRESHOLD
.defaultTags
- Default tags to be added when writing points.
-
WriteOptions
public WriteOptions(@Nullable String database, @Nullable WritePrecision precision, @Nullable Integer gzipThreshold, @Nullable Boolean noSync) Construct WriteAPI options.- Parameters:
database
- The database to be used for InfluxDB operations. If it is not specified then useClientConfig.getDatabase()
.precision
- The precision to use for the timestamp of points. If it is not specified then useClientConfig.getWritePrecision()
.gzipThreshold
- The threshold for compressing request body. If it is not specified then useDEFAULT_GZIP_THRESHOLD
.noSync
- Skip waiting for WAL persistence on write. If it is not specified then useDEFAULT_NO_SYNC
.
-
WriteOptions
Construct WriteAPI options.- Parameters:
headers
- The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration.
-
WriteOptions
public WriteOptions(@Nullable String database, @Nullable WritePrecision precision, @Nullable Integer gzipThreshold, @Nullable Map<String, String> defaultTags, @Nullable Map<String, String> headers) Construct WriteAPI options.- Parameters:
database
- The database to be used for InfluxDB operations. If it is not specified then useClientConfig.getDatabase()
.precision
- The precision to use for the timestamp of points. If it is not specified then useClientConfig.getWritePrecision()
.gzipThreshold
- The threshold for compressing request body. If it is not specified then useDEFAULT_GZIP_THRESHOLD
.defaultTags
- Default tags to be added when writing points.headers
- The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration.
-
WriteOptions
public WriteOptions(@Nullable String database, @Nullable WritePrecision precision, @Nullable Integer gzipThreshold, @Nullable Boolean noSync, @Nullable Map<String, String> defaultTags, @Nullable Map<String, String> headers) Construct WriteAPI options.- Parameters:
database
- The database to be used for InfluxDB operations. If it is not specified then useClientConfig.getDatabase()
.precision
- The precision to use for the timestamp of points. If it is not specified then useClientConfig.getWritePrecision()
.gzipThreshold
- The threshold for compressing request body. If it is not specified then useDEFAULT_GZIP_THRESHOLD
.noSync
- Skip waiting for WAL persistence on write. If it is not specified then useDEFAULT_NO_SYNC
.defaultTags
- Default tags to be added when writing points.headers
- The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration.
-
-
Method Details
-
defaultWriteOptions
Creates a default instance ofWriteOptions
configured with standard values.- Returns:
- A
WriteOptions
object with the default settings for write precision, compression threshold, and no specified database.
-
databaseSafe
- Parameters:
config
- with default value- Returns:
- The destination database for writes.
-
precisionSafe
- Parameters:
config
- with default value- Returns:
- Precision for unix timestamps in the line protocol of the request payload.
-
defaultTagsSafe
- Parameters:
config
- with/without defaultTags defined- Returns:
- defaultTags - can be an empty map if none are defined.
-
gzipThresholdSafe
- Parameters:
config
- with default value- Returns:
- Payload size threshold for compressing it.
-
noSyncSafe
- Parameters:
config
- with default value- Returns:
- Skip waiting for WAL persistence on write.
-
headersSafe
- Returns:
- The headers to be added to write request.
-
equals
-
hashCode
public int hashCode()
-