org.apache.accumulo.core.data
Class Key

java.lang.Object
  extended by org.apache.accumulo.core.data.Key
All Implemented Interfaces:
Cloneable, Comparable<Key>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<Key>

public class Key
extends Object
implements org.apache.hadoop.io.WritableComparable<Key>, Cloneable


Field Summary
protected  byte[] colFamily
           
protected  byte[] colQualifier
           
protected  byte[] colVisibility
           
protected  boolean deleted
           
protected  byte[] row
           
protected  long timestamp
           
 
Constructor Summary
Key()
          Creates a key with empty row, empty column family, empty column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.
Key(byte[] row, byte[] colFamily, byte[] colQualifier, byte[] colVisibility, long timestamp)
           
Key(byte[] row, byte[] cf, byte[] cq, byte[] cv, long ts, boolean deleted)
           
Key(byte[] row, byte[] cf, byte[] cq, byte[] cv, long ts, boolean deleted, boolean copy)
           
Key(byte[] row, int rOff, int rLen, byte[] cf, int cfOff, int cfLen, byte[] cq, int cqOff, int cqLen, byte[] cv, int cvOff, int cvLen, long ts)
           
Key(CharSequence row)
          Converts CharSequence to Text and creates a Key using Key(Text).
Key(CharSequence row, CharSequence cf)
          Converts CharSequence to Text and creates a Key using Key(Text,Text).
Key(CharSequence row, CharSequence cf, CharSequence cq)
          Converts CharSequence to Text and creates a Key using Key(Text,Text,Text).
Key(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv)
          Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,Text).
Key(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv, long ts)
          Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,Text,long).
Key(CharSequence row, CharSequence cf, CharSequence cq, ColumnVisibility cv, long ts)
          Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,ColumnVisibility,long).
Key(CharSequence row, CharSequence cf, CharSequence cq, long ts)
          Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,long).
Key(Key other)
          Creates a key with the same row, column family, column qualifier, column visibility, timestamp, and delete marker as the given key.
Key(org.apache.hadoop.io.Text row)
          Creates a key with the specified row, empty column family, empty column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.
Key(org.apache.hadoop.io.Text row, long ts)
          Creates a key with the specified row, empty column family, empty column qualifier, empty column visibility, the specified timestamp, and delete marker false.
Key(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf)
          Creates a key with the specified row, the specified column family, empty column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.
Key(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq)
          Creates a key with the specified row, the specified column family, the specified column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.
Key(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, ColumnVisibility cv, long ts)
          Creates a key with the specified row, the specified column family, the specified column qualifier, the specified column visibility, the specified timestamp, and delete marker false.
Key(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, long ts)
          Creates a key with the specified row, the specified column family, the specified column qualifier, empty column visibility, the specified timestamp, and delete marker false.
Key(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cv)
          Creates a key with the specified row, the specified column family, the specified column qualifier, the specified column visibility, timestamp Long.MAX_VALUE, and delete marker false.
Key(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cv, long ts)
          Creates a key with the specified row, the specified column family, the specified column qualifier, the specified column visibility, the specified timestamp, and delete marker false.
Key(TKey tkey)
           
 
Method Summary
static StringBuilder appendPrintableString(byte[] ba, int offset, int len, int maxLen, StringBuilder sb)
           
 Object clone()
           
 int compareColumnFamily(org.apache.hadoop.io.Text cf)
          Efficiently compare the the column family of a key w/o allocating a text object and copying the column qualifier into it.
 int compareColumnQualifier(org.apache.hadoop.io.Text cq)
          Efficiently compare the the column qualifier of a key w/o allocating a text object and copying the column qualifier into it.
 int compareRow(org.apache.hadoop.io.Text r)
          Efficiently compare the the row of a key w/o allocating a text object and copying the row into it.
 int compareTo(Key other)
          Compare all elements of a key.
 int compareTo(Key other, PartialKey part)
          Compare elements of a key given by a PartialKey.
static List<TKeyValue> compress(List<? extends KeyValue> param)
          Use this to compress a list of keys before sending them via thrift.
static void decompress(List<TKeyValue> param)
          Use this to decompress a list of keys received from thrift.
 boolean equals(Key other, PartialKey part)
          Compare part of a key.
 boolean equals(Object o)
           
 Key followingKey(PartialKey part)
          Returns a key that will sort immediately after this key.
 org.apache.hadoop.io.Text getColumnFamily()
          This method allocates a Text object and copies into it.
 org.apache.hadoop.io.Text getColumnFamily(org.apache.hadoop.io.Text cf)
          This method gives users control over allocation of Text objects by copying into the passed in text.
 ByteSequence getColumnFamilyData()
          This method returns a pointer to the keys internal data and does not copy it.
 org.apache.hadoop.io.Text getColumnQualifier()
          This method allocates a Text object and copies into it.
 org.apache.hadoop.io.Text getColumnQualifier(org.apache.hadoop.io.Text cq)
          This method gives users control over allocation of Text objects by copying into the passed in text.
 ByteSequence getColumnQualifierData()
          This method returns a pointer to the keys internal data and does not copy it.
 org.apache.hadoop.io.Text getColumnVisibility()
          This method allocates a Text object and copies into it.
 org.apache.hadoop.io.Text getColumnVisibility(org.apache.hadoop.io.Text cv)
          This method gives users control over allocation of Text objects by copying into the passed in text.
 ByteSequence getColumnVisibilityData()
          This method returns a pointer to the keys internal data and does not copy it.
 ColumnVisibility getColumnVisibilityParsed()
          This method creates a new ColumnVisibility representing the column visibility for this key WARNING: using this method may inhibit performance since a new ColumnVisibility object is created on every call.
 int getLength()
          Returns the sums of the lengths of the row, column family, column qualifier, and visibility.
 org.apache.hadoop.io.Text getRow()
          This method allocates a Text object and copies into it.
 org.apache.hadoop.io.Text getRow(org.apache.hadoop.io.Text r)
          This method gives users control over allocation of Text objects by copying into the passed in text.
 ByteSequence getRowData()
          This method returns a pointer to the keys internal data and does not copy it.
 int getSize()
          Same as getLength().
 long getTimestamp()
           
 int hashCode()
           
 boolean isDeleted()
           
 void readFields(DataInput in)
           
 void set(Key k)
          Sets this key's row, column family, column qualifier, column visibility, timestamp, and delete marker to be the same as another key's.
 void setDeleted(boolean deleted)
           
 void setTimestamp(long ts)
           
static String toPrintableString(byte[] ba, int offset, int len, int maxLen)
           
 String toString()
           
 String toStringNoTime()
           
 TKey toThrift()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

row

protected byte[] row

colFamily

protected byte[] colFamily

colQualifier

protected byte[] colQualifier

colVisibility

protected byte[] colVisibility

timestamp

protected long timestamp

deleted

protected boolean deleted
Constructor Detail

Key

public Key()
Creates a key with empty row, empty column family, empty column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row)
Creates a key with the specified row, empty column family, empty column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row,
           long ts)
Creates a key with the specified row, empty column family, empty column qualifier, empty column visibility, the specified timestamp, and delete marker false.


Key

public Key(byte[] row,
           int rOff,
           int rLen,
           byte[] cf,
           int cfOff,
           int cfLen,
           byte[] cq,
           int cqOff,
           int cqLen,
           byte[] cv,
           int cvOff,
           int cvLen,
           long ts)

Key

public Key(byte[] row,
           byte[] colFamily,
           byte[] colQualifier,
           byte[] colVisibility,
           long timestamp)

Key

public Key(byte[] row,
           byte[] cf,
           byte[] cq,
           byte[] cv,
           long ts,
           boolean deleted)

Key

public Key(byte[] row,
           byte[] cf,
           byte[] cq,
           byte[] cv,
           long ts,
           boolean deleted,
           boolean copy)

Key

public Key(org.apache.hadoop.io.Text row,
           org.apache.hadoop.io.Text cf)
Creates a key with the specified row, the specified column family, empty column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row,
           org.apache.hadoop.io.Text cf,
           org.apache.hadoop.io.Text cq)
Creates a key with the specified row, the specified column family, the specified column qualifier, empty column visibility, timestamp Long.MAX_VALUE, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row,
           org.apache.hadoop.io.Text cf,
           org.apache.hadoop.io.Text cq,
           org.apache.hadoop.io.Text cv)
Creates a key with the specified row, the specified column family, the specified column qualifier, the specified column visibility, timestamp Long.MAX_VALUE, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row,
           org.apache.hadoop.io.Text cf,
           org.apache.hadoop.io.Text cq,
           long ts)
Creates a key with the specified row, the specified column family, the specified column qualifier, empty column visibility, the specified timestamp, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row,
           org.apache.hadoop.io.Text cf,
           org.apache.hadoop.io.Text cq,
           org.apache.hadoop.io.Text cv,
           long ts)
Creates a key with the specified row, the specified column family, the specified column qualifier, the specified column visibility, the specified timestamp, and delete marker false.


Key

public Key(org.apache.hadoop.io.Text row,
           org.apache.hadoop.io.Text cf,
           org.apache.hadoop.io.Text cq,
           ColumnVisibility cv,
           long ts)
Creates a key with the specified row, the specified column family, the specified column qualifier, the specified column visibility, the specified timestamp, and delete marker false.


Key

public Key(CharSequence row)
Converts CharSequence to Text and creates a Key using Key(Text).


Key

public Key(CharSequence row,
           CharSequence cf)
Converts CharSequence to Text and creates a Key using Key(Text,Text).


Key

public Key(CharSequence row,
           CharSequence cf,
           CharSequence cq)
Converts CharSequence to Text and creates a Key using Key(Text,Text,Text).


Key

public Key(CharSequence row,
           CharSequence cf,
           CharSequence cq,
           CharSequence cv)
Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,Text).


Key

public Key(CharSequence row,
           CharSequence cf,
           CharSequence cq,
           long ts)
Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,long).


Key

public Key(CharSequence row,
           CharSequence cf,
           CharSequence cq,
           CharSequence cv,
           long ts)
Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,Text,long).


Key

public Key(CharSequence row,
           CharSequence cf,
           CharSequence cq,
           ColumnVisibility cv,
           long ts)
Converts CharSequence to Text and creates a Key using Key(Text,Text,Text,ColumnVisibility,long).


Key

public Key(Key other)
Creates a key with the same row, column family, column qualifier, column visibility, timestamp, and delete marker as the given key.


Key

public Key(TKey tkey)
Method Detail

equals

public boolean equals(Object o)
Overrides:
equals in class Object

followingKey

public Key followingKey(PartialKey part)
Returns a key that will sort immediately after this key.

Parameters:
part - PartialKey except PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME_DEL

getRow

public org.apache.hadoop.io.Text getRow(org.apache.hadoop.io.Text r)
This method gives users control over allocation of Text objects by copying into the passed in text.

Parameters:
r - the key's row will be copied into this Text
Returns:
the Text that was passed in

getRowData

public ByteSequence getRowData()
This method returns a pointer to the keys internal data and does not copy it.

Returns:
ByteSequence that points to the internal key row data.

getRow

public org.apache.hadoop.io.Text getRow()
This method allocates a Text object and copies into it.

Returns:
Text containing the row field

compareRow

public int compareRow(org.apache.hadoop.io.Text r)
Efficiently compare the the row of a key w/o allocating a text object and copying the row into it.

Parameters:
r - row to compare to keys row
Returns:
same as getRow().compareTo(r)

getColumnFamilyData

public ByteSequence getColumnFamilyData()
This method returns a pointer to the keys internal data and does not copy it.

Returns:
ByteSequence that points to the internal key column family data.

getColumnFamily

public org.apache.hadoop.io.Text getColumnFamily(org.apache.hadoop.io.Text cf)
This method gives users control over allocation of Text objects by copying into the passed in text.

Parameters:
cf - the key's column family will be copied into this Text
Returns:
the Text that was passed in

getColumnFamily

public org.apache.hadoop.io.Text getColumnFamily()
This method allocates a Text object and copies into it.

Returns:
Text containing the column family field

compareColumnFamily

public int compareColumnFamily(org.apache.hadoop.io.Text cf)
Efficiently compare the the column family of a key w/o allocating a text object and copying the column qualifier into it.

Parameters:
cf - column family to compare to keys column family
Returns:
same as getColumnFamily().compareTo(cf)

getColumnQualifierData

public ByteSequence getColumnQualifierData()
This method returns a pointer to the keys internal data and does not copy it.

Returns:
ByteSequence that points to the internal key column qualifier data.

getColumnQualifier

public org.apache.hadoop.io.Text getColumnQualifier(org.apache.hadoop.io.Text cq)
This method gives users control over allocation of Text objects by copying into the passed in text.

Parameters:
cq - the key's column qualifier will be copied into this Text
Returns:
the Text that was passed in

getColumnQualifier

public org.apache.hadoop.io.Text getColumnQualifier()
This method allocates a Text object and copies into it.

Returns:
Text containing the column qualifier field

compareColumnQualifier

public int compareColumnQualifier(org.apache.hadoop.io.Text cq)
Efficiently compare the the column qualifier of a key w/o allocating a text object and copying the column qualifier into it.

Parameters:
cq - column family to compare to keys column qualifier
Returns:
same as getColumnQualifier().compareTo(cq)

setTimestamp

public void setTimestamp(long ts)

getTimestamp

public long getTimestamp()

isDeleted

public boolean isDeleted()

setDeleted

public void setDeleted(boolean deleted)

getColumnVisibilityData

public ByteSequence getColumnVisibilityData()
This method returns a pointer to the keys internal data and does not copy it.

Returns:
ByteSequence that points to the internal key column visibility data.

getColumnVisibility

public final org.apache.hadoop.io.Text getColumnVisibility()
This method allocates a Text object and copies into it.

Returns:
Text containing the column visibility field

getColumnVisibility

public final org.apache.hadoop.io.Text getColumnVisibility(org.apache.hadoop.io.Text cv)
This method gives users control over allocation of Text objects by copying into the passed in text.

Parameters:
cv - the key's column visibility will be copied into this Text
Returns:
the Text that was passed in

getColumnVisibilityParsed

public final ColumnVisibility getColumnVisibilityParsed()
This method creates a new ColumnVisibility representing the column visibility for this key WARNING: using this method may inhibit performance since a new ColumnVisibility object is created on every call.

Returns:
A new object representing the column visibility field
Since:
1.5.0

set

public void set(Key k)
Sets this key's row, column family, column qualifier, column visibility, timestamp, and delete marker to be the same as another key's.


readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

equals

public boolean equals(Key other,
                      PartialKey part)
Compare part of a key. For example compare just the row and column family, and if those are equal then return true.


compareTo

public int compareTo(Key other,
                     PartialKey part)
Compare elements of a key given by a PartialKey. For example, for PartialKey.ROW_COLFAM, compare just the row and column family. If the rows are not equal, return the result of the row comparison; otherwise, return the result of the column family comparison.

See Also:
compareTo(Key)

compareTo

public int compareTo(Key other)
Compare all elements of a key. The elements (row, column family, column qualifier, column visibility, timestamp, and delete marker) are compared in order until an unequal element is found. If the row is equal, then compare the column family, etc. The row, column family, column qualifier, and column visibility are compared lexographically and sorted ascending. The timestamps are compared numerically and sorted descending so that the most recent data comes first. Lastly, a delete marker of true sorts before a delete marker of false.

Specified by:
compareTo in interface Comparable<Key>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toPrintableString

public static String toPrintableString(byte[] ba,
                                       int offset,
                                       int len,
                                       int maxLen)

appendPrintableString

public static StringBuilder appendPrintableString(byte[] ba,
                                                  int offset,
                                                  int len,
                                                  int maxLen,
                                                  StringBuilder sb)

toString

public String toString()
Overrides:
toString in class Object

toStringNoTime

public String toStringNoTime()

getLength

public int getLength()
Returns the sums of the lengths of the row, column family, column qualifier, and visibility.

Returns:
row.length + colFamily.length + colQualifier.length + colVisibility.length;

getSize

public int getSize()
Same as getLength().


compress

public static List<TKeyValue> compress(List<? extends KeyValue> param)
Use this to compress a list of keys before sending them via thrift.

Parameters:
param - a list of key/value pairs

decompress

public static void decompress(List<TKeyValue> param)
Use this to decompress a list of keys received from thrift.

Parameters:
param -

toThrift

public TKey toThrift()

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2013 Apache Accumulo Project. All Rights Reserved.