org.apache.hadoop.util.bloom
Class Key

java.lang.Object
  extended by org.apache.hadoop.util.bloom.Key
All Implemented Interfaces:
Comparable<Key>, Writable, WritableComparable<Key>

public class Key
extends Object
implements WritableComparable<Key>

The general behavior of a key that must be stored in a filter.

See Also:
The general behavior of a filter

Constructor Summary
Key()
          default constructor - use with readFields
Key(byte[] value)
          Constructor.
Key(byte[] value, double weight)
          Constructor.
 
Method Summary
 int compareTo(Key other)
           
 boolean equals(Object o)
           
 byte[] getBytes()
           
 double getWeight()
           
 int hashCode()
           
 void incrementWeight()
          Increments the weight of this key by one.
 void incrementWeight(double weight)
          Increments the weight of this key with a specified value.
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 void set(byte[] value, double weight)
           
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Key

public Key()
default constructor - use with readFields


Key

public Key(byte[] value)
Constructor.

Builds a key with a default weight.

Parameters:
value - The byte value of this key.

Key

public Key(byte[] value,
           double weight)
Constructor.

Builds a key with a specified weight.

Parameters:
value - The value of this key.
weight - The weight associated to this key.
Method Detail

set

public void set(byte[] value,
                double weight)
Parameters:
value -
weight -

getBytes

public byte[] getBytes()
Returns:
byte[] The value of this key.

getWeight

public double getWeight()
Returns:
Returns the weight associated to this key.

incrementWeight

public void incrementWeight(double weight)
Increments the weight of this key with a specified value.

Parameters:
weight - The increment.

incrementWeight

public void incrementWeight()
Increments the weight of this key by one.


equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

compareTo

public int compareTo(Key other)
Specified by:
compareTo in interface Comparable<Key>


Copyright © 2009 The Apache Software Foundation