Interface KVImplementation<C>
- Type Parameters:
C
- configuration object type
- All Known Implementing Classes:
ArrayKVImplementation
,BerkeleyKVImplementation
,CockroachKVImplementation
,FoundationKVImplementation
,LevelDBKVImplementation
,LMDBKVImplementation
,MemoryKVImplementation
,MSSQLKVImplementation
,MVStoreKVImplementation
,MySQLKVImplementation
,RaftKVImplementation
,SimpleKVImplementation
,SpannerKVImplementation
,SQLDriverKVImplementation
,SQLiteKVImplementation
,XMLKVImplementation
,XodusKVImplementation
KVDatabase
and/or AtomicKVStore
implementations.
Instances of this class provide information about how to configure and instantiate some
technology-specific implementation of the KVDatabase
and/or AtomicKVStore
interfaces.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addOptions
(joptsimple.OptionParser parser) Add implementation-specific command line options.buildConfig
(joptsimple.OptionSet options) Build a configuration from implementation-specific command line options, if any were given.default AtomicKVStore
createAtomicKVStore
(C config) Create anAtomicKVStore
using the specified configuration.default KVDatabase
createKVDatabase
(C config, KVDatabase kvdb, AtomicKVStore kvstore) Create anKVDatabase
using the specified configuration.Get the configuration object type for this instance.getDescription
(C config) Generate a short, human-readable description of theKVDatabase
instance configured as given.default boolean
providesAtomicKVStore
(C config) Determine whether thisKVImplementation
includes an implementation of theAtomicKVStore
interface.default boolean
providesKVDatabase
(C config) Determine whether thisKVImplementation
includes an implementation of theKVDatabase
interface.default boolean
requiresAtomicKVStore
(C config) Determine whether this instance'sKVDatabase
implementation requires an underlyingAtomicKVStore
.default boolean
requiresKVDatabase
(C config) Determine whether this instance'sKVDatabase
implementation requires some other underlyingKVDatabase
.
-
Method Details
-
getConfigType
Get the configuration object type for this instance.- Returns:
- config type
-
addOptions
void addOptions(joptsimple.OptionParser parser) Add implementation-specific command line options.All of the added options must be optional, because multiple key/value implementations will be available when the command line is parsed, and the presence of implementation-specific options determines which one(s) are chosen.
- Parameters:
parser
- command line flag parser- Throws:
IllegalArgumentException
- ifparser
is null
-
buildConfig
Build a configuration from implementation-specific command line options, if any were given.If none of this implementation's options were provided, then this method must return null.
- Parameters:
options
- parsed command line options- Returns:
- corresponding configuration, or null if this implementation was not configured
- Throws:
joptsimple.OptionException
- if invalid options were givenIllegalArgumentException
- if invalid options were givenIllegalArgumentException
- ifoptions
is null
-
providesAtomicKVStore
Determine whether thisKVImplementation
includes an implementation of theAtomicKVStore
interface.The implementation in
KVImplementation
return false.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- true if this instance can create an
AtomicKVStore
- Throws:
IllegalArgumentException
- ifconfig
is null
-
providesKVDatabase
Determine whether thisKVImplementation
includes an implementation of theKVDatabase
interface.The implementation in
KVImplementation
return false.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- true if this instance can create an
KVDatabase
- Throws:
IllegalArgumentException
- ifconfig
is null
-
createKVDatabase
Create anKVDatabase
using the specified configuration.The implementation in
KVImplementation
always throwsUnsupportedOperationException
.- Parameters:
config
- implementation configuration returned bybuildConfig()
kvdb
- requiredKVDatabase
; will be null unlessrequiresKVDatabase(C)
returned truekvstore
- requiredAtomicKVStore
; will be null unlessrequiresAtomicKVStore(C)
returned true- Returns:
- new
KVDatabase
instance - Throws:
UnsupportedOperationException
- ifprovidesKVDatabase(C)
returns falseIllegalArgumentException
- ifconfig
is null
-
createAtomicKVStore
Create anAtomicKVStore
using the specified configuration.The implementation in
KVImplementation
invokescreateKVDatabase()
and constructs anAtomicKVDatabase
from the result. Implementations that natively support theAtomicKVDatabase
interface should override this method.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- new
AtomicKVStore
instance - Throws:
IllegalArgumentException
- ifconfig
is null
-
requiresAtomicKVStore
Determine whether this instance'sKVDatabase
implementation requires an underlyingAtomicKVStore
.This method and
requiresKVDatabase()
may not both return true.The implementation in
KVImplementation
return false.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- true if the implementation relies on an underlying
AtomicKVStore
- Throws:
IllegalArgumentException
- ifconfig
is null
-
requiresKVDatabase
Determine whether this instance'sKVDatabase
implementation requires some other underlyingKVDatabase
.This method and
requiresAtomicKVStore()
may not both return true.The implementation in
KVImplementation
return false.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- true if the implementation relies on an underlying
KVDatabase
- Throws:
IllegalArgumentException
- ifconfig
is null
-
getDescription
Generate a short, human-readable description of theKVDatabase
instance configured as given.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- human-readable description
-