com.thinkaurelius.titan.graphdb.transaction

## Class StandardTransactionBuilder

- java.lang.Object
- - com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder

- All Implemented Interfaces:
    TransactionBuilder, BaseTransactionConfig, TransactionConfiguration

      public class StandardTransactionBuilder
      extends Object
      implements TransactionConfiguration, TransactionBuilder

  Used to configure a `TitanTransaction`.
  Author:
    Matthias Bröcheler (me@matthiasb.com);
  See Also:
    `TitanTransaction`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardTransactionBuilder(GraphDatabaseConfiguration graphConfig, StandardTitanGraph graph)` Constructs a new TitanTransaction configuration with default configuration parameters.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `StandardTransactionBuilder` | `checkInternalVertexExistence()` Enables checks that verify that each vertex actually exists in the underlying data store when it is retrieved.
    `StandardTransactionBuilder` | `disableBatchLoading()` Disables batch loading by ensuring that consistency checks are applied in this transaction.
    `StandardTransactionBuilder` | `enableBatchLoading()` Enabling batch loading disables a number of consistency checks inside Titan to speed up the ingestion of data under the assumptions that inconsistencies are resolved prior to loading.
    `DefaultSchemaMaker` | `getAutoSchemaMaker()`
    `Timepoint` | `getCommitTime()` Returns the commit time of this transaction which is either a custom timestamp provided by the user, the commit time as set by the enclosing operation, or the first time this method is called.
    `<V> V` | `getCustomOption(ConfigOption<V> opt)` Get an arbitrary transaction-specific option.
    `Configuration` | `getCustomOptions()` Return any transaction-specific options.
    `int` | `getDirtyVertexSize()` The initial size of the dirty (modified) vertex map used by a transaction.
    `String` | `getGroupName()` Returns the (possibly null) group name for this transaction.
    `long` | `getIndexCacheWeight()` The maximum weight for the index cache store used in this particular transaction
    `String` | `getLogIdentifier()` The name of the log to be used for logging the mutations in this transaction.
    `int[]` | `getRestrictedPartitions()` Querying of partitioned vertices is restricted to the partitions returned by this method.
    `TimestampProvider` | `getTimestampProvider()` Returns the timestamp provider of this transaction.
    `int` | `getVertexCacheSize()` The maximum number of recently-used vertices to cache in this transaction.
    `boolean` | `hasAcquireLocks()` Whether the persistence layer should acquire locks for this transaction during persistence.
    `boolean` | `hasAssignIDsImmediately()`
    `boolean` | `hasCommitTime()` Returns true if a commit time has been set on this transaction.
    `boolean` | `hasEnabledBatchLoading()` Whether this transaction should be optimized for batch-loading, i.e.
    `boolean` | `hasForceIndexUsage()` Whether this transaction should throw an exception when a graph query is issued that cannot be answered with any existing index but instead requires a full graph-scan.
    `boolean` | `hasGroupName()` True when `BaseTransactionConfig.getGroupName()` is non-null, false when null.
    `boolean` | `hasPropertyPrefetching()` Whether this transaction loads all properties on a vertex when a single property is requested.
    `boolean` | `hasRestrictedPartitions()` Returns true of the queryied partitions should be restricted in this transaction
    `boolean` | `hasVerifyExternalVertexExistence()` Whether the graph transaction is configured to verify that a vertex with the id GIVEN BY THE USER actually exists in the database or not.
    `boolean` | `hasVerifyInternalVertexExistence()` Whether the graph transaction is configured to verify that a vertex with the id actually exists in the database or not on every retrieval.
    `boolean` | `hasVerifyUniqueness()` Whether the graph transaction is configured to verify that an added key does not yet exist in the database.
    `boolean` | `isReadOnly()` Checks whether the graph transaction is configured as read-only.
    `boolean` | `isSingleThreaded()` Whether this transaction is only accessed by a single thread.
    `boolean` | `isThreadBound()` Whether this transaction is bound to a running thread.
    `StandardTransactionBuilder` | `readOnly()` Makes the transaction read only.
    `StandardTransactionBuilder` | `setCommitTime(long timestampSinceEpoch, TimeUnit unit)` Sets the timestamp for this transaction.
    `void` | `setCommitTime(Timepoint time)` Sets the commit time of this transaction.
    `TransactionBuilder` | `setCustomOption(String k, Object v)` Configures a custom option on this transaction which will be passed through to the storage and indexing backends.
    `TransactionBuilder` | `setDirtyVertexSize(int size)` Configures the initial size of the map of modified vertices held by this transaction.
    `StandardTransactionBuilder` | `setGroupName(String p)` Sets the group name for this transaction which provides a way for gathering reporting on multiple transactions into one group.
    `StandardTransactionBuilder` | `setLogIdentifier(String logName)` Name of the log to be used for logging the mutations in this transaction.
    `TransactionBuilder` | `setRestrictedPartitions(int[] partitions)` Configures this transaction such that queries against partitioned vertices are restricted to the given partitions.
    `StandardTransactionBuilder` | `setVertexCacheSize(int size)` Configures the size of the internal caches used in the transaction.
    `TitanTransaction` | `start()` Starts and returns the transaction build by this builder
    `StandardTransactionBuilder` | `threadBound()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StandardTransactionBuilder

          public StandardTransactionBuilder(GraphDatabaseConfiguration graphConfig,
                                    StandardTitanGraph graph)

      Constructs a new TitanTransaction configuration with default configuration parameters.

  - ### Method Detail

    - #### threadBound

          public StandardTransactionBuilder threadBound()

    - #### readOnly

          public StandardTransactionBuilder readOnly()

      Description copied from interface: `TransactionBuilder`
      Makes the transaction read only. Any writes will cause an exception. Read-only transactions do not have to maintain certain data structures and can hence be more efficient.
      Specified by:
        `readOnly` in interface `TransactionBuilder`
      Returns:

    - #### enableBatchLoading

          public StandardTransactionBuilder enableBatchLoading()

      Description copied from interface: `TransactionBuilder`
      Enabling batch loading disables a number of consistency checks inside Titan to speed up the ingestion of data under the assumptions that inconsistencies are resolved prior to loading.
      Specified by:
        `enableBatchLoading` in interface `TransactionBuilder`
      Returns:

    - #### disableBatchLoading

          public StandardTransactionBuilder disableBatchLoading()

      Description copied from interface: `TransactionBuilder`
      Disables batch loading by ensuring that consistency checks are applied in this transaction. This allows an individual transaction to use consistency checks when the graph as a whole is configured to not use them, which is useful when defining schema elements in a graph with batch-loading enabled.
      Specified by:
        `disableBatchLoading` in interface `TransactionBuilder`
      Returns:

    - #### setVertexCacheSize

          public StandardTransactionBuilder setVertexCacheSize(int size)

      Description copied from interface: `TransactionBuilder`
      Configures the size of the internal caches used in the transaction.
      Specified by:
        `setVertexCacheSize` in interface `TransactionBuilder`
      Returns:

    - #### setDirtyVertexSize

          public TransactionBuilder setDirtyVertexSize(int size)

      Description copied from interface: `TransactionBuilder`
      Configures the initial size of the map of modified vertices held by this transaction. This is a performance hint, not a hard upper bound. The map will grow if the transaction ends up modifying more vertices than expected.
      Specified by:
        `setDirtyVertexSize` in interface `TransactionBuilder`
      Parameters:
        `size` - initial size of the transaction's dirty vertex collection
      Returns:

    - #### checkInternalVertexExistence

          public StandardTransactionBuilder checkInternalVertexExistence()

      Description copied from interface: `TransactionBuilder`
      Enables checks that verify that each vertex actually exists in the underlying data store when it is retrieved. This might be useful to address common data degradation issues but has adverse impacts on performance due to repeated existence checks.
      Specified by:
        `checkInternalVertexExistence` in interface `TransactionBuilder`
      Returns:

    - #### setCommitTime

          public StandardTransactionBuilder setCommitTime(long timestampSinceEpoch,
                                                 TimeUnit unit)

      Description copied from interface: `TransactionBuilder`
      Sets the timestamp for this transaction. The transaction will be recorded with this timestamp in those storage backends where the timestamp is recorded.
      Specified by:
        `setCommitTime` in interface `TransactionBuilder`
      Parameters:
        `timestampSinceEpoch` - number of units elapsed since the UNIX Epoch, that is, 00:00:00 UTC, Thursday, 1 January 1970
        `unit` - units of the `timestampSinceEpoch argument`
      Returns:

    - #### setCommitTime

          public void setCommitTime(Timepoint time)

      Description copied from interface: `BaseTransactionConfig`
      Sets the commit time of this transaction. If a commit time has already been set, this method throws an exception. Use `BaseTransactionConfig.hasCommitTime()` to check prior to setting.
      Specified by:
        `setCommitTime` in interface `BaseTransactionConfig`

    - #### setGroupName

          public StandardTransactionBuilder setGroupName(String p)

      Description copied from interface: `TransactionBuilder`
      Sets the group name for this transaction which provides a way for gathering reporting on multiple transactions into one group. By setting a group one enables Metrics for this transaction, and defines what string should start the transaction's metric names.

      If null, Metrics collection is totally disabled for this transaction.

      If empty, Metrics collection is enabled, but there will be no prefix. Where the default setting would generate metrics names in the form "prefix.x.y.z", this transaction will instead use metric names in the form "x.y.z".

      If nonempty, Metrics collection is enabled and the prefix will be used for all of this transaction's measurements.

      Note: setting this to a non-null value only partially overrides `GraphDatabaseConfiguration.BASIC_METRICS` = false in the graph database configuration. When Metrics are disabled at the graph level and enabled at the transaction level, storage backend timings and counters will remain disabled.

      The default value is `GraphDatabaseConfiguration.METRICS_PREFIX_DEFAULT`. Sets the name prefix used for Metrics recorded by this transaction. If metrics is enabled via `GraphDatabaseConfiguration.BASIC_METRICS`, this string will be prepended to all Titan metric names.

      Specified by:
        `setGroupName` in interface `TransactionBuilder`
      Parameters:
        `p` - Metric name prefix for this transaction
      Returns:

    - #### setLogIdentifier

          public StandardTransactionBuilder setLogIdentifier(String logName)

      Description copied from interface: `TransactionBuilder`
      Name of the log to be used for logging the mutations in this transaction. If no log identifier is set, then this transaction will not be logged.
      Specified by:
        `setLogIdentifier` in interface `TransactionBuilder`
      Returns:

    - #### setRestrictedPartitions

          public TransactionBuilder setRestrictedPartitions(int[] partitions)

      Description copied from interface: `TransactionBuilder`
      Configures this transaction such that queries against partitioned vertices are restricted to the given partitions.
      Specified by:
        `setRestrictedPartitions` in interface `TransactionBuilder`
      Returns:

    - #### setCustomOption

          public TransactionBuilder setCustomOption(String k,
                                           Object v)

      Description copied from interface: `TransactionBuilder`
      Configures a custom option on this transaction which will be passed through to the storage and indexing backends.
      Specified by:
        `setCustomOption` in interface `TransactionBuilder`
      Returns:

    - #### start

          public TitanTransaction start()

      Description copied from interface: `TransactionBuilder`
      Starts and returns the transaction build by this builder
      Specified by:
        `start` in interface `TransactionBuilder`
      Returns:
        A new transaction configured according to this builder

    - #### isReadOnly

          public final boolean isReadOnly()

      Description copied from interface: `TransactionConfiguration`
      Checks whether the graph transaction is configured as read-only.
      Specified by:
        `isReadOnly` in interface `TransactionConfiguration`
      Returns:
        True, if the transaction is configured as read-only, else false.

    - #### hasAssignIDsImmediately

          public final boolean hasAssignIDsImmediately()

      Specified by:
        `hasAssignIDsImmediately` in interface `TransactionConfiguration`
      Returns:
        Whether this transaction is configured to assign idAuthorities immediately.

    - #### hasForceIndexUsage

          public final boolean hasForceIndexUsage()

      Description copied from interface: `TransactionConfiguration`
      Whether this transaction should throw an exception when a graph query is issued that cannot be answered with any existing index but instead requires a full graph-scan.
      Specified by:
        `hasForceIndexUsage` in interface `TransactionConfiguration`
      Returns:

    - #### hasEnabledBatchLoading

          public boolean hasEnabledBatchLoading()

      Description copied from interface: `TransactionConfiguration`
      Whether this transaction should be optimized for batch-loading, i.e. ingestion of lots of data.
      Specified by:
        `hasEnabledBatchLoading` in interface `TransactionConfiguration`
      Returns:

    - #### hasVerifyExternalVertexExistence

          public final boolean hasVerifyExternalVertexExistence()

      Description copied from interface: `TransactionConfiguration`
      Whether the graph transaction is configured to verify that a vertex with the id GIVEN BY THE USER actually exists in the database or not. In other words, it is verified that user provided vertex ids (through public APIs) actually exist.
      Specified by:
        `hasVerifyExternalVertexExistence` in interface `TransactionConfiguration`
      Returns:
        True, if vertex existence is verified, else false

    - #### hasVerifyInternalVertexExistence

          public final boolean hasVerifyInternalVertexExistence()

      Description copied from interface: `TransactionConfiguration`
      Whether the graph transaction is configured to verify that a vertex with the id actually exists in the database or not on every retrieval. In other words, it is always verified that a vertex for a given id exists, even if that id is retrieved internally (through private APIs).

      Hence, this is a defensive setting against data degradation, where edges and/or index entries might point to no longer existing vertices. Use this setting with caution as it introduces additional overhead entailed by checking the existence.

      Unlike `TransactionConfiguration.hasVerifyExternalVertexExistence()` this is about internally verifying ids.
      Specified by:
        `hasVerifyInternalVertexExistence` in interface `TransactionConfiguration`
      Returns:
        True, if vertex existence is verified, else false

    - #### hasAcquireLocks

          public final boolean hasAcquireLocks()

      Description copied from interface: `TransactionConfiguration`
      Whether the persistence layer should acquire locks for this transaction during persistence.
      Specified by:
        `hasAcquireLocks` in interface `TransactionConfiguration`
      Returns:
        True, if locks should be acquired, else false

    - #### getAutoSchemaMaker

          public final DefaultSchemaMaker getAutoSchemaMaker()

      Specified by:
        `getAutoSchemaMaker` in interface `TransactionConfiguration`
      Returns:
        The default edge type maker used to automatically create not yet existing edge types.

    - #### hasVerifyUniqueness

          public final boolean hasVerifyUniqueness()

      Description copied from interface: `TransactionConfiguration`
      Whether the graph transaction is configured to verify that an added key does not yet exist in the database.
      Specified by:
        `hasVerifyUniqueness` in interface `TransactionConfiguration`
      Returns:
        True, if vertex existence is verified, else false

    - #### hasPropertyPrefetching

          public boolean hasPropertyPrefetching()

      Description copied from interface: `TransactionConfiguration`
      Whether this transaction loads all properties on a vertex when a single property is requested. This can be highly beneficial when additional properties are requested on the same vertex at a later time. For vertices with very many properties this might increase latencies of property fetching.
      Specified by:
        `hasPropertyPrefetching` in interface `TransactionConfiguration`
      Returns:
        True, if this transaction pre-fetches all properties

    - #### isSingleThreaded

          public final boolean isSingleThreaded()

      Description copied from interface: `TransactionConfiguration`
      Whether this transaction is only accessed by a single thread. If so, then certain data structures may be optimized for single threaded access since locking can be avoided.
      Specified by:
        `isSingleThreaded` in interface `TransactionConfiguration`
      Returns:

    - #### isThreadBound

          public final boolean isThreadBound()

      Description copied from interface: `TransactionConfiguration`
      Whether this transaction is bound to a running thread. If so, then elements in this transaction can expand their life cycle to the next transaction in the thread.
      Specified by:
        `isThreadBound` in interface `TransactionConfiguration`
      Returns:

    - #### getVertexCacheSize

          public final int getVertexCacheSize()

      Description copied from interface: `TransactionConfiguration`
      The maximum number of recently-used vertices to cache in this transaction. The recently-used vertex cache can include both clean and dirty vertices.
      Specified by:
        `getVertexCacheSize` in interface `TransactionConfiguration`
      Returns:

    - #### getDirtyVertexSize

          public final int getDirtyVertexSize()

      Description copied from interface: `TransactionConfiguration`
      The initial size of the dirty (modified) vertex map used by a transaction.
      Specified by:
        `getDirtyVertexSize` in interface `TransactionConfiguration`
      Returns:

    - #### getIndexCacheWeight

          public final long getIndexCacheWeight()

      Description copied from interface: `TransactionConfiguration`
      The maximum weight for the index cache store used in this particular transaction
      Specified by:
        `getIndexCacheWeight` in interface `TransactionConfiguration`
      Returns:

    - #### getLogIdentifier

          public String getLogIdentifier()

      Description copied from interface: `TransactionConfiguration`
      The name of the log to be used for logging the mutations in this transaction. If the identifier is NULL the mutations will not be logged.
      Specified by:
        `getLogIdentifier` in interface `TransactionConfiguration`
      Returns:

    - #### getRestrictedPartitions

          public int[] getRestrictedPartitions()

      Description copied from interface: `TransactionConfiguration`
      Querying of partitioned vertices is restricted to the partitions returned by this method. If the return value has length 0 all partitions are queried (i.e. unrestricted).
      Specified by:
        `getRestrictedPartitions` in interface `TransactionConfiguration`
      Returns:

    - #### hasRestrictedPartitions

          public boolean hasRestrictedPartitions()

      Description copied from interface: `TransactionConfiguration`
      Returns true of the queryied partitions should be restricted in this transaction
      Specified by:
        `hasRestrictedPartitions` in interface `TransactionConfiguration`

    - #### getGroupName

          public String getGroupName()

      Description copied from interface: `BaseTransactionConfig`
      Returns the (possibly null) group name for this transaction. Transactions are grouped under this name for reporting and error tracking purposes.
      Specified by:
        `getGroupName` in interface `BaseTransactionConfig`
      Returns:
        group name prefix string or null

    - #### hasGroupName

          public boolean hasGroupName()

      Description copied from interface: `BaseTransactionConfig`
      True when `BaseTransactionConfig.getGroupName()` is non-null, false when null.
      Specified by:
        `hasGroupName` in interface `BaseTransactionConfig`

    - #### getCommitTime

          public Timepoint getCommitTime()

      Description copied from interface: `BaseTransactionConfig`
      Returns the commit time of this transaction which is either a custom timestamp provided by the user, the commit time as set by the enclosing operation, or the first time this method is called.
      Specified by:
        `getCommitTime` in interface `BaseTransactionConfig`
      Returns:
        commit timestamp for this transaction

    - #### hasCommitTime

          public boolean hasCommitTime()

      Description copied from interface: `BaseTransactionConfig`
      Returns true if a commit time has been set on this transaction.
      Specified by:
        `hasCommitTime` in interface `BaseTransactionConfig`
      Returns:

    - #### getCustomOption

          public <V> V getCustomOption(ConfigOption<V> opt)

      Description copied from interface: `BaseTransactionConfig`
      Get an arbitrary transaction-specific option.
      Specified by:
        `getCustomOption` in interface `BaseTransactionConfig`
      Parameters:
        `opt` - option for which to return a value
      Returns:
        value of the option

    - #### getCustomOptions

          public Configuration getCustomOptions()

      Description copied from interface: `BaseTransactionConfig`
      Return any transaction-specific options.
      Specified by:
        `getCustomOptions` in interface `BaseTransactionConfig`
      Returns:
        options for this tx
      See Also:
        `BaseTransactionConfig.getCustomOption(ConfigOption)`

    - #### getTimestampProvider

          public TimestampProvider getTimestampProvider()

      Description copied from interface: `BaseTransactionConfig`
      Returns the timestamp provider of this transaction.
      Specified by:
        `getTimestampProvider` in interface `BaseTransactionConfig`

Copyright © 2012–2014. All rights reserved.