com.aerospike.client
Class Key

java.lang.Object
  extended by com.aerospike.client.Key

public final class Key
extends Object

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
 byte[] digest
          Unique server hash value generated from set name and user key.
 String namespace
          Namespace.
 String setName
          Optional set name.
 Object userKey
          Original user key.
 
Constructor Summary
Key(String namespace, byte[] digest)
          Initialize key from namespace and digest.
Key(String namespace, byte[] digest, String setName)
          Initialize key from namespace, digest and optional set name.
Key(String namespace, String setName, byte[] key)
          Initialize key from namespace, optional set name and user key.
Key(String namespace, String setName, byte[] key, int offset, int length)
          Initialize key from namespace, optional set name and user key.
Key(String namespace, String setName, int key)
          Initialize key from namespace, optional set name and user key.
Key(String namespace, String setName, long key)
          Initialize key from namespace, optional set name and user key.
Key(String namespace, String setName, String key)
          Initialize key from namespace, optional set name and user key.
Key(String namespace, String setName, Value key)
          Initialize key from namespace, optional set name and user key.
 
Method Summary
static byte[] computeDigest(String setName, Value key)
          Generate unique server hash value from set name, key type and user defined key.
 boolean equals(Object obj)
          Equality uses namespace and digest.
 int hashCode()
          Hash lookup uses namespace and digest.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namespace

public final String namespace
Namespace. Equivalent to database name.


setName

public final String setName
Optional set name. Equivalent to database table.


digest

public final byte[] digest
Unique server hash value generated from set name and user key.


userKey

public final Object userKey
Original user key. This key is immediately converted to a hash digest. This key is not used or returned by the server. If the user key needs to persist on the server, the key should be explicitly stored in a bin.

Constructor Detail

Key

public Key(String namespace,
           String setName,
           String key)
    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 server handles record identifiers by digest only.

Parameters:
namespace - namespace
setName - optional set name, enter null when set does not exist
key - user defined unique identifier within set.
Throws:
AerospikeException - if digest computation fails

Key

public Key(String namespace,
           String setName,
           byte[] key)
    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 server handles record identifiers by digest only. If the user key needs to be stored on the server, the key should be stored in a bin.

Parameters:
namespace - namespace
setName - optional set name, enter null when set does not exist
key - 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 server handles record identifiers by digest only. If the user key needs to be stored on the server, the key should be stored in a bin.

Parameters:
namespace - namespace
setName - optional set name, enter null when set does not exist
key - user defined unique identifier within set.
offset - byte array segment offset
length - byte array segment length
Throws:
AerospikeException - if digest computation fails

Key

public Key(String namespace,
           String setName,
           int key)
    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 server handles record identifiers by digest only. If the user key needs to be stored on the server, the key should be stored in a bin.

Parameters:
namespace - namespace
setName - optional set name, enter null when set does not exist
key - user defined unique identifier within set.
Throws:
AerospikeException - if digest computation fails

Key

public Key(String namespace,
           String setName,
           long key)
    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 server handles record identifiers by digest only. If the user key needs to be stored on the server, the key should be stored in a bin.

Parameters:
namespace - namespace
setName - optional set name, enter null when set does not exist
key - user defined unique identifier within set.
Throws:
AerospikeException - if digest computation fails

Key

public Key(String namespace,
           String setName,
           Value key)
    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 server handles record identifiers by digest only. If the user key needs to be stored on the server, the key should be stored in a bin.

Parameters:
namespace - namespace
setName - optional set name, enter null when set does not exist
key - user defined unique identifier within set.
Throws:
AerospikeException - if digest computation fails

Key

public Key(String namespace,
           byte[] digest,
           String setName)
Initialize key from namespace, digest and optional set name.

Parameters:
namespace - namespace
digest - unique server hash value
setName - optional set name, enter null when set does not exist

Key

public Key(String namespace,
           byte[] digest)
Initialize key from namespace and digest. This constructor exists for the legacy CitrusleafClient compatibility layer only. Do not use.

Parameters:
namespace - namespace
digest - unique server hash value
Method Detail

hashCode

public int hashCode()
Hash lookup uses namespace and digest.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Equality uses namespace and digest.

Overrides:
equals in class Object

computeDigest

public static byte[] computeDigest(String setName,
                                   Value key)
                            throws AerospikeException
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 exist
key - record identifier, unique within set
Returns:
unique server hash value
Throws:
AerospikeException - if digest computation fails


Copyright © 2012–2014 Aerospike, Inc. All rights reserved.