Package org.apache.hadoop.util
Class SequentialNumber
java.lang.Object
org.apache.hadoop.util.SequentialNumber
- All Implemented Interfaces:
IdGenerator
Sequential number generator.
This class is thread safe.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSequentialNumber(long initialValue) Create a new instance with the given initial value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanlonginthashCode()longIncrement and then return the next value.voidsetCurrentValue(long value) Set current value.booleansetIfGreater(long value) voidskipTo(long newValue) Skip to the new value.
-
Constructor Details
-
SequentialNumber
protected SequentialNumber(long initialValue) Create a new instance with the given initial value.- Parameters:
initialValue- initialValue.
-
-
Method Details
-
getCurrentValue
public long getCurrentValue()- Returns:
- the current value.
-
setCurrentValue
public void setCurrentValue(long value) Set current value.- Parameters:
value- value.
-
setIfGreater
public boolean setIfGreater(long value) -
nextValue
public long nextValue()Increment and then return the next value.- Specified by:
nextValuein interfaceIdGenerator- Returns:
- long value.
-
skipTo
Skip to the new value.- Parameters:
newValue- newValue.- Throws:
IllegalStateException- Cannot skip to less than the current value.
-
equals
-
hashCode
public int hashCode()
-