Class CounterContext.ContextState

java.lang.Object
org.apache.cassandra.db.context.CounterContext.ContextState
Enclosing class:
CounterContext

public static class CounterContext.ContextState extends Object
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 Details

    • context

      public final ByteBuffer context
    • headerLength

      public final int headerLength
  • Method Details

    • wrap

      public static CounterContext.ContextState wrap(ByteBuffer context)
    • 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

      public void copyTo(CounterContext.ContextState other)
    • compareIdTo

      public int compareIdTo(CounterContext.ContextState other)
    • reset

      public void reset()
    • getElementIndex

      public int getElementIndex()
    • getCounterId

      public CounterId getCounterId()
    • getClock

      public long getClock()
    • getCount

      public long getCount()
    • writeGlobal

      public void writeGlobal(CounterId id, long clock, long count)
    • writeLocal

      public void writeLocal(CounterId id, long clock, long count)
    • writeRemote

      public void writeRemote(CounterId id, long clock, long count)