Package org.apache.cassandra.db.context
Class CounterContext.ContextState
java.lang.Object
org.apache.cassandra.db.context.CounterContext.ContextState
- Enclosing class:
- CounterContext
Helper class to work on contexts (works by iterating over them).
A context being abstractly a list of tuple (counterid, clock, count), a
ContextState encapsulate a context and a position to one of the tuple.
It also allow to create new context iteratively.
Note: this is intrinsically a private class intended for use by the
methods of CounterContext only. It is however public because it is
convenient to create handcrafted context for unit tests.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic CounterContext.ContextStateallocate(int globalCount, int localCount, int remoteCount) Allocate a new context big enough for globalCount + localCount + remoteCount elements and return the initial corresponding ContextState.intvoidlonggetClock()longgetCount()intbooleanbooleanisGlobal()booleanisLocal()booleanisRemote()voidvoidreset()static CounterContext.ContextStatewrap(ByteBuffer context) voidwriteGlobal(CounterId id, long clock, long count) voidwriteLocal(CounterId id, long clock, long count) voidwriteRemote(CounterId id, long clock, long count)
-
Field Details
-
context
-
headerLength
public final int headerLength
-
-
Method Details
-
wrap
-
allocate
public static CounterContext.ContextState allocate(int globalCount, int localCount, int remoteCount) Allocate a new context big enough for globalCount + localCount + remoteCount elements and return the initial corresponding ContextState. -
isGlobal
public boolean isGlobal() -
isLocal
public boolean isLocal() -
isRemote
public boolean isRemote() -
hasRemaining
public boolean hasRemaining() -
moveToNext
public void moveToNext() -
copyTo
-
compareIdTo
-
reset
public void reset() -
getElementIndex
public int getElementIndex() -
getCounterId
-
getClock
public long getClock() -
getCount
public long getCount() -
writeGlobal
-
writeLocal
-
writeRemote
-