Package com.aerospike.client
Class Key
java.lang.Object
com.aerospike.client.Key
Unique record identifier. Records can be identified using a specified namespace,
an optional set name, and a user defined key which must be unique within a set.
Records can also be identified by namespace/digest which is the combination used
on the server.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitialize key from namespace, digest, optional set name and optional userKey.Initialize key from namespace, optional set name and user key.Initialize key from namespace, optional set name and user key.Initialize key from namespace, optional set name and user key.Initialize key from namespace, optional set name and user key.Initialize key from namespace, optional set name and user key.Initialize key from namespace, optional set name and user key. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
computeDigest
(String setName, Value key) Generate unique server hash value from set name, key type and user defined key.boolean
Equality uses namespace and digest.int
hashCode()
Hash lookup uses namespace and digest.toString()
-
Field Details
-
namespace
Namespace. Equivalent to database name. -
setName
Optional set name. Equivalent to database table. -
digest
public final byte[] digestUnique server hash value generated from set name and user key. -
userKey
Original user key. This key is immediately converted to a hash digest. This key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
-
-
Constructor Details
-
Key
Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The user key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
The key is converted to bytes to compute the digest. The key's byte size is limited to the current thread's buffer size (min 8KB). To store keys > 8KB, do one of the following:
- Set once:
ThreadLocalData.DefaultBufferSize = maxKeySize + maxSetNameSize + 1;
- Or for every key:
int len = key.length() + setName.length() + 1; if (len > ThreadLocalData.getBuffer().length)) ThreadLocalData.resizeBuffer(len);
- Parameters:
namespace
- namespacesetName
- optional set name, enter null when set does not existkey
- user defined unique identifier within set.- Throws:
AerospikeException
- if digest computation fails
-
Key
Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The user key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
The key's byte size is limited to the current thread's buffer size (min 8KB). To store keys > 8KB, do one of the following:
- Set once:
ThreadLocalData.DefaultBufferSize = maxKeySize + maxSetNameSize + 1;
- Or for every key:
int len = key.length + setName.length() + 1; if (len > ThreadLocalData.getBuffer().length)) ThreadLocalData.resizeBuffer(len);
- Parameters:
namespace
- namespacesetName
- optional set name, enter null when set does not existkey
- user defined unique identifier within set.- Throws:
AerospikeException
- if digest computation fails
-
Key
public Key(String namespace, String setName, byte[] key, int offset, int length) throws AerospikeException Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The user key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
The key's byte size is limited to the current thread's buffer size (min 8KB). To store keys > 8KB, do one of the following:
- Set once:
ThreadLocalData.DefaultBufferSize = maxKeySize + maxSetNameSize + 1;
- Or for every key:
int len = length + setName.length() + 1; if (len > ThreadLocalData.getBuffer().length)) ThreadLocalData.resizeBuffer(len);
- Parameters:
namespace
- namespacesetName
- optional set name, enter null when set does not existkey
- user defined unique identifier within set.offset
- byte array segment offsetlength
- byte array segment length- Throws:
AerospikeException
- if digest computation fails
-
Key
Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The user key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
- Parameters:
namespace
- namespacesetName
- optional set name, enter null when set does not existkey
- user defined unique identifier within set.- Throws:
AerospikeException
- if digest computation fails
-
Key
Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The user key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
- Parameters:
namespace
- namespacesetName
- optional set name, enter null when set does not existkey
- user defined unique identifier within set.- Throws:
AerospikeException
- if digest computation fails
-
Key
Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The user key is not used or returned by the server by default. If the user key needs to persist on the server, use one of the following methods:- Set "WritePolicy.sendKey" to true. In this case, the key will be sent to the server for storage on writes and retrieved on multi-record scans and queries.
- Explicitly store and retrieve the key in a bin.
- Parameters:
namespace
- namespacesetName
- optional set name, enter null when set does not existkey
- user defined unique identifier within set.- Throws:
AerospikeException
- if digest computation fails
-
Key
Initialize key from namespace, digest, optional set name and optional userKey.- Parameters:
namespace
- namespacedigest
- unique server hash valuesetName
- optional set name, enter null when set does not existuserKey
- optional original user key (not hash digest).
-
-
Method Details
-
hashCode
public int hashCode()Hash lookup uses namespace and digest. -
equals
Equality uses namespace and digest. -
computeDigest
Generate unique server hash value from set name, key type and user defined key. The hash function is RIPEMD-160 (a 160 bit hash).- Parameters:
setName
- optional set name, enter null when set does not existkey
- record identifier, unique within set- Returns:
- unique server hash value
- Throws:
AerospikeException
- if digest computation fails
-
toString
-