LazyIndex — Deferred Loading Of Index Files

LazyIndex is a thin wrapper over an AbstractIndex instance (of type T) that allows to defer loading (i.e. memory mapping) the underlying index file until it is accessed for the first time (via the get method).

LazyIndex is used as an optimization of broker start-up time with a large number of segments.

LazyIndex defines utilities to create lazy indexes for OffsetIndex and TimeIndex.

Creating TimeIndex Instance

TimeIndex takes the following to be created:

  • IndexWrapper

  • Load index function that creates an AbstractIndex for a given underlying index file (File ⇒ T)

get Method

get: T

get…​FIXME

Note
get is used when…​FIXME

forOffset Utility

forOffset(
  file: File,
  baseOffset: Long,
  maxIndexSize: Int = -1,
  writable: Boolean = true): LazyIndex[OffsetIndex]

forOffset simply creates a new LazyIndex with an IndexFile (for the given file) and a load index function that creates a new OffsetIndex.

Note
forOffset is used when LogSegment utility is used to open a log segment.

forTime Utility

forTime(
  file: File,
  baseOffset: Long,
  maxIndexSize: Int = -1,
  writable: Boolean = true): LazyIndex[TimeIndex]

forTime simply creates a new LazyIndex with an IndexFile (for the given file) and a load index function that creates a new TimeIndex.

Note
forTime is used when LogSegment utility is used to open a log segment.

results matching ""

    No results matching ""