Package org.apache.hadoop.util.bloom
Class Key
java.lang.Object
org.apache.hadoop.util.bloom.Key
- All Implemented Interfaces:
Comparable<Key>,Writable,WritableComparable<Key>
@LimitedPrivate({"HDFS","MapReduce"})
@Unstable
public class Key
extends Object
implements WritableComparable<Key>
The general behavior of a key that must be stored in a filter.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanbyte[]getBytes()doubleinthashCode()voidIncrements the weight of this key by one.voidincrementWeight(double weight) Increments the weight of this key with a specified value.voidreadFields(DataInput in) Deserialize the fields of this object fromin.voidset(byte[] value, double weight) voidwrite(DataOutput out) Serialize the fields of this object toout.
-
Constructor Details
-
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 Details
-
set
public void set(byte[] value, double weight) - Parameters:
value- value.weight- 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
-
hashCode
public int hashCode() -
write
Description copied from interface:WritableSerialize the fields of this object toout.- Specified by:
writein interfaceWritable- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException- any other problem for write.
-
readFields
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Specified by:
readFieldsin interfaceWritable- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException- any other problem for readFields.
-
compareTo
- Specified by:
compareToin interfaceComparable<Key>
-