public final class Layout extends Object
Database
in a key/value store.
The key/value space is divided into a data area and a meta-data area. The data area contains object data as well as simple and composite index data. The meta-data area contains a recognizable signature, encoding format version, each recorded schema version, the object version index data, and a range reserved for user applications.
Modifier and Type | Field and Description |
---|---|
static int |
CURRENT_FORMAT_VERSION
The current
Database layout format version (2). |
static int |
FORMAT_VERSION_1
The original
Database layout format version #1. |
static int |
FORMAT_VERSION_2
Database layout format version #2. |
Modifier and Type | Method and Description |
---|---|
static byte[] |
buildSchemaKey(int version)
Get the key corresponding to the specified schema version.
|
static byte[] |
buildVersionIndexKey(ObjId id,
int version)
Build the key for an object version index entry.
|
static void |
copyMetaData(KVStore src,
KVStore dst)
Copy non-object meta-data from one
KVStore to another. |
static SchemaModel |
decodeSchema(byte[] value,
int formatVersion)
Decode schema XML from a schema version meta-data entry.
|
static void |
deleteObjectData(KVStore kv)
Delete all object and index data from the given
KVStore . |
static byte[] |
encodeSchema(SchemaModel schemaModel,
int formatVersion)
Encode schema XML for a schema version meta-data entry.
|
static byte[] |
getFormatVersionKey()
Get the key under which the database format version is encoded.
|
static byte[] |
getMetaDataKeyPrefix()
Get the common prefix of all meta-data keys.
|
static KeyRange |
getMetaDataKeyRange()
Get the meta-data key range.
|
static byte[] |
getObjectVersionIndexKeyPrefix()
Get the common prefix of all object version index entries.
|
static byte[] |
getSchemaKey(int version)
Get the key in the meta-data area corresponding to the schema with the given version number.
|
static byte[] |
getSchemaKeyPrefix()
Get the common prefix of all schema version keys.
|
static KeyRange |
getSchemaKeyRange()
Get the schema key range.
|
static byte[] |
getUserMetaDataKeyPrefix()
Get the common prefix of all user-defined meta-data keys.
|
static CoreIndex<Integer,ObjId> |
getVersionIndex(KVStore kv)
Get a
CoreIndex view of the object version index in a key/value database. |
public static final int FORMAT_VERSION_1
Database
layout format version #1.public static final int FORMAT_VERSION_2
Database
layout format version #2.
This version switched to compressed schema XML.
public static final int CURRENT_FORMAT_VERSION
Database
layout format version (2).public static byte[] getMetaDataKeyPrefix()
public static KeyRange getMetaDataKeyRange()
public static byte[] getFormatVersionKey()
The existence of this key also serves to identify a Permazen database.
public static byte[] getSchemaKeyPrefix()
public static KeyRange getSchemaKeyRange()
public static byte[] buildSchemaKey(int version)
version
- schema versionIllegalArgumentException
- if version
is zero or negativepublic static byte[] getObjectVersionIndexKeyPrefix()
public static byte[] getUserMetaDataKeyPrefix()
public static CoreIndex<Integer,ObjId> getVersionIndex(KVStore kv)
CoreIndex
view of the object version index in a key/value database.kv
- key/value dataIllegalArgumentException
- if kv
is nullpublic static byte[] buildVersionIndexKey(ObjId id, int version)
id
- object IDversion
- object versionIllegalArgumentException
- if id
is nullIllegalArgumentException
- if version
is non-positivepublic static SchemaModel decodeSchema(byte[] value, int formatVersion)
value
- encoded schema from key/value pairformatVersion
- database format versionInvalidSchemaException
- if schema is invalidIllegalArgumentException
- if formatVersion
is invalidIllegalArgumentException
- if value
is nullpublic static byte[] encodeSchema(SchemaModel schemaModel, int formatVersion)
schemaModel
- schemaformatVersion
- database format versionIllegalArgumentException
- if formatVersion
is invalidIllegalArgumentException
- if schemaModel
is nullpublic static byte[] getSchemaKey(int version)
version
- schema version numberIllegalArgumentException
- if version
is non-positivepublic static void deleteObjectData(KVStore kv)
KVStore
.
Upon return, the KVStore
will still contain meta-data, but not any objects.
kv
- key/value databasepublic static void copyMetaData(KVStore src, KVStore dst)
KVStore
to another.
This copies all meta-data except the object version index. Any existing key/value pairs in the destination meta-data range are not removed prior to the copy.
src
- source key/value databasedst
- destination key/value databaseCopyright © 2022. All rights reserved.