public final class Key<T extends Keyed> extends Iced<Key<T>> implements java.lang.Comparable
Value
somewhere in
the Cloud, to cache it locally, to allow globally consistent updates to a
Value
. Keys have a *home*, a specific Node in the Cloud, which is
computable from the Key itself. The Key's home node breaks ties on racing
updates, and tracks caching copies (via a hardware-like MESI protocol), but
otherwise is not involved in the DKV. All operations on the DKV, including
Gets and Puts, are found in DKV
.
Keys are defined as a simple byte-array, plus a hashCode and a small cache of Cloud-specific information. The first byte of the byte-array determines if this is a user-visible Key or an internal system Key; an initial byte of <32 is a system Key. User keys are generally externally visible, system keys are generally limited to things kept internal to the H2O Cloud. Keys might be a high-count item, hence we care about the size.
System keys for Job
, Vec
, Chunk
and Vec.VectorGroup
have special initial bytes; Keys for these classes can be
determined without loading the underlying Value. Layout for Vec
and
Chunk
is further restricted, so there is an efficient mapping
between a numbered Chunk and it's associated Vec.
System keys (other than the restricted Vec and Chunk keys) can have their home node forced, by setting the desired home node in the first few Key bytes. Otherwise home nodes are selected by pseudo-random hash. Selecting a home node is sometimes useful for Keys with very high update rates coming from a specific Node.
Modifier and Type | Field and Description |
---|---|
byte[] |
_kb |
static byte |
CHK |
static byte |
GRP |
static byte |
HIDDEN_USER_KEY |
static byte |
JOB |
static byte |
USER_KEY |
static byte |
VEC |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o)
Lexically ordered Key comparison, so Keys can be sorted.
|
boolean |
equals(java.lang.Object o) |
T |
get()
Convenience function to fetch key contents from the DKV.
|
Key |
getVecKey()
|
int |
hashCode() |
H2ONode |
home_node()
The home node for this Key.
|
boolean |
home()
True if the
home_node() is the current node. |
boolean |
isChunkKey()
True is this is a
Chunk Key. |
boolean |
isVec()
True is this is a
Vec Key. |
static Key |
make()
Factory making a random Key
|
static Key |
make(byte[] kb)
Factory making a Key from a byte[]
|
static Key |
make(byte rf,
byte systemType,
boolean hint,
H2ONode... replicas)
Factory making a homed system Key.
|
static Key |
make(H2ONode node)
Make a random key, homed to a given node.
|
static Key |
make(java.lang.String s)
Factory making a Key from a String
|
static Key |
make(java.lang.String s,
byte rf,
byte systemType,
boolean hint,
H2ONode... replicas)
Factory making a homed system Key.
|
static Key |
makeSystem(java.lang.String s) |
static Key |
makeUserHidden(Key orig) |
static java.lang.String |
rand()
A random string, useful as a Key name or partial Key suffix.
|
Key |
read_impl(AutoBuffer ab)
Implementation of the
Iced serialization protocol, only called by
auto-genned code. |
void |
remove()
Remove a Key from the DKV, including any embedded Keys.
|
Futures |
remove(Futures fs) |
java.lang.String |
toString()
Converts the key to HTML displayable string.
|
int |
type()
System type/byte of a Key, or the constant
USER_KEY |
boolean |
user_allowed()
True if a
USER_KEY and not a system key. |
java.lang.String |
valueClass()
Return the classname for the Value that this Key points to, if any (e.g., "water.fvec.Frame").
|
java.lang.String |
valueClassSimple()
Return the base classname (not including the package) for the Value that this Key points to, if any (e.g., "Frame").
|
AutoBuffer |
write_impl(AutoBuffer ab)
Implementation of the
Iced serialization protocol, only called by
auto-genned code. |
DocGen.HTML |
writeHTML_impl(DocGen.HTML ab)
Implementation of the
Iced serialization protocol, only called by
auto-genned code. |
AutoBuffer |
writeJSON_impl(AutoBuffer ab)
Implementation of the
Iced serialization protocol, only called by
auto-genned code. |
clone, frozenType, read, readExternal, readJSON_impl, readJSON, toJsonString, write, writeExternal, writeHTML, writeJSON
public final byte[] _kb
public static final byte JOB
public static final byte VEC
public static final byte CHK
public static final byte GRP
public static final byte HIDDEN_USER_KEY
public static final byte USER_KEY
public final boolean isChunkKey()
Chunk
Key.Chunk
Keypublic final T get()
Keyed
public boolean home()
home_node()
is the current node.home_node()
is the current nodepublic H2ONode home_node()
public static java.lang.String rand()
public static Key make(byte[] kb)
public static Key make(java.lang.String s)
public static Key makeSystem(java.lang.String s)
public static Key make(H2ONode node)
node
- a node at which the new key is homed.public static Key make()
public static Key make(java.lang.String s, byte rf, byte systemType, boolean hint, H2ONode... replicas)
public static Key make(byte rf, byte systemType, boolean hint, H2ONode... replicas)
rand()
for the remaining bytes. Requires a list of exactly
one H2ONode to home at. The hint specifies if it is an error to name an
H2ONode that is NOT in the Cloud, or if some other H2ONode can be
substituted. The rf parameter and passing more than 1 H2ONode are both
depreciated.public void remove()
public boolean user_allowed()
USER_KEY
and not a system key.USER_KEY
and not a system keypublic int type()
USER_KEY
public java.lang.String valueClass()
public java.lang.String valueClassSimple()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public final AutoBuffer write_impl(AutoBuffer ab)
Iced
serialization protocol, only called by
auto-genned code. Not intended to be called by user code.write_impl
in interface Freezable<Key<T extends Keyed>>
write_impl
in class Iced<Key<T extends Keyed>>
ab
- AutoBuffer
to write this object to.AutoBuffer
for flow-coding.public final Key read_impl(AutoBuffer ab)
Iced
serialization protocol, only called by
auto-genned code. Not intended to be called by user code.public final DocGen.HTML writeHTML_impl(DocGen.HTML ab)
Iced
serialization protocol, only called by
auto-genned code. Not intended to be called by user code.writeHTML_impl
in interface Freezable<Key<T extends Keyed>>
writeHTML_impl
in class Iced<Key<T extends Keyed>>
ab
- html to write object to.public final AutoBuffer writeJSON_impl(AutoBuffer ab)
Iced
serialization protocol, only called by
auto-genned code. Not intended to be called by user code.writeJSON_impl
in interface Freezable<Key<T extends Keyed>>
writeJSON_impl
in class Iced<Key<T extends Keyed>>
ab
- AutoBuffer
to write this object to.AutoBuffer
for flow-coding.