Class TokenMapFileAPIService

java.lang.Object
io.nosqlbench.datamappers.functions.rainbow.TokenMapFileAPIService

public class TokenMapFileAPIService extends Object

This class provides cursor-like access to a set of data from a binary file using Java nio buffers. Calling next() causes the next record to be loaded, after which the getter methods return the loaded values. You must call next before access each record's fields.

The next(int) method may be used for absolute offset access. In this mode, no thread safety is imposed, as there is no chance of the internal buffer's position to affect the result.

Buffers may be accessed as shared or not. If

  • Constructor Summary

    Constructors
    Constructor
    Description
    TokenMapFileAPIService(String datafile, boolean loopdata, boolean instanced, boolean ascending)
    Create a new binary cursor for data in a binary file which consists of a (long,long) tuple of token values (murmur3 partitioner tokens) and cycle values that correspond to them.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
     
    long
     
    void
     
    void
    next(int position)
    Do a read of [token,cycle] record without incremental read state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TokenMapFileAPIService

      public TokenMapFileAPIService(String datafile, boolean loopdata, boolean instanced, boolean ascending)
      Create a new binary cursor for data in a binary file which consists of a (long,long) tuple of token values (murmur3 partitioner tokens) and cycle values that correspond to them. The cycles are the ones responsible for producing the associated token values.
      Parameters:
      datafile - The data file to read from
      loopdata - Whether or not to loop around to the beginning of the data. For positional reads this is also modulo-based, such that relatively prime sizes and increments will loop not simply repeat values at the start of the buffer
      instanced - Whether or not to provide an instanced view into the byte buffer, where each thread can have its own read tracking state
      ascending - Whether to reverse the order othe long,long tuples when the file is read.
  • Method Details

    • next

      public void next()
    • next

      public void next(int position)
      Do a read of [token,cycle] record without incremental read state.
      Parameters:
      position - The logical record within the buffer to read
    • getToken

      public long getToken()
    • getCycle

      public long getCycle()