All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.chronos.chronodb.api.builder.database.ChronoDBFinalizableBuilder Maven / Gradle / Ivy

The newest version!
package org.chronos.chronodb.api.builder.database;

import org.chronos.chronodb.api.ChronoDB;
import org.chronos.chronodb.api.ChronoDBTransaction;
import org.chronos.chronodb.api.CommitMetadataFilter;
import org.chronos.chronodb.api.conflict.ConflictResolutionStrategy;
import org.chronos.chronodb.internal.api.ChronoDBConfiguration;
import org.chronos.common.builder.ChronoBuilder;

/**
 * A builder for instances of {@link ChronoDB}.
 *
 * 

* When an instance of this interface is returned by the fluent builder API, then all information required for building * the database is complete, and {@link #build()} can be called to finalize the buildLRU process. * *

* Even though the {@link #build()} method becomes available at this stage, it is still possible to set properties * defined by the concrete implementations. * * @author [email protected] -- Initial Contribution and API * * @param * The dynamic type of this to return for method chaining. */ public interface ChronoDBFinalizableBuilder> extends ChronoBuilder { /** * Enables Least-Recently-Used caching on the new {@link ChronoDB} instance. * *

* If this operation is called several times on the same builder instance, the last setting wins. * * @param maxSize * The maximum number of elements to be contained in the LRU cache. If this number is less than or equal * to zero, the caching is disabled instead. * * @return this, for method chaining. */ public SELF withLruCacheOfSize(int maxSize); /** * Enables or disables the assumption that values in the cache of this {@link ChronoDB} instance are immutable. * *

* By default, this is set to false. Enabling this setting can greatly increase the speed of the cache, * however cache state may be corrupted if cached values are changed by client code. This setting is only viable if * the client ensures that the objects passed to the key-value store are effectively immutable. * * @param value * Set this to true to enable the assumption that cached value objects are immutable * (optimistic, faster, see above), otherwise use false (pessimistic, default). * * @return this, for method chaining. */ public SELF assumeCachedValuesAreImmutable(boolean value); /** * Enables Least-Recently-Used caching on the new {@link ChronoDB} instance for query results. * * @param maxSize * The maximum number of elements to be contained in the LRU Query Result Cache. If this number is less * than or equal to zero, the caching is disabled instead. * * @return this, for method chaining. */ public SELF withLruQueryCacheOfSize(int maxSize); /** * Enables or disables duplicate version elimination on commit. * *

* If this is enabled, every changed key-value pair will be checked for identity with the previous version. * Key-value pairs that are identical to their predecessors will be filtered out and will not be committed. This * does not alter the semantics of the store in any way, but it eliminates the duplicates, reducing overall store * size on disk and enhancing read performance. * *

* This setting is enabled by default and it is recommended to keep this setting enabled, unless the caller can * guarantee that each version is different from the predecessor. In general, this feature will cause some overhead * on the {@linkplain ChronoDBTransaction#commit() commit} operation. * *

* Corresponds to {@link ChronoDBConfiguration#DUPLICATE_VERSION_ELIMINATION_MODE}. * * @param useDuplicateVersionElimination * true to enable this feature, or false to disable it. Default is * true. * @return this, for method chaining. */ public SELF withDuplicateVersionElimination(final boolean useDuplicateVersionElimination); /** * Specifies the {@link ConflictResolutionStrategy} to use for this database by default. * *

* This setting can be overruled on a per-transaction basis. * * @param strategy * The strategy to apply, unless specified otherwise explicitly in a transaction. Must not be * null. * @return this, for method chaining. */ public SELF withConflictResolutionStrategy(final ConflictResolutionStrategy strategy); /** * Specifies the {@link CommitMetadataFilter} to use for this database. * * @param filterClass The filter class to use. May be null to specify "no filter" (default). Otherwise, must be a class instantiable via reflection. * @return this, for method chaining. */ public SELF withCommitMetadataFilter(final Class filterClass); /** * Builds the {@link ChronoDB} instance, using the properties specified by the fluent API. * *

* This method finalizes the buildLRU process. Afterwards, the builder should be discarded. * * @return The new {@link ChronoDB} instance. Never null. */ public ChronoDB build(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy