AbstractIndex

AbstractIndex is the abstraction of indices that use entrySize to index offsets and timestamps of a LogSegment.

Note
Kafka mmaps index files into memory, and all the read / write operations of the index is through OS page cache. This avoids blocked disk I/O in most cases.
Tip
Use DumpLogSegments tool to review the content of indexes of a log segment.
Table 1. AbstractIndex Contract (Abstract Methods Only)
Method Description

entrySize

entrySize: Int

Used when…​FIXME

parseEntry

parseEntry(
  buffer: ByteBuffer,
  n: Int): IndexEntry

Used when…​FIXME

sanityCheck

sanityCheck(): Unit

Used when…​FIXME

truncate

truncate(): Unit

Used when…​FIXME

truncateTo

truncateTo(
  offset: Long): Unit

Used when…​FIXME

Table 2. AbstractIndexes
AbstractIndex Description

OffsetIndex

Index of the offsets

TimeIndex

Index of the timestamps and the offsets

Creating AbstractIndex Instance

AbstractIndex takes the following to be created:

  • Underlying file

  • Base offset

  • maxIndexSize (default: -1)

  • writable flag

AbstractIndex initializes the internal properties.

Note
AbstractIndex is a Scala abstract class and cannot be created directly. It is created indirectly for the concrete AbstractIndexes.

reset Method

reset(): Unit

reset truncate and then resize to the maxIndexSize.

Note
reset is used when…​FIXME

resize Method

resize(newSize: Int): Boolean

resize…​FIXME

Note
resize is used when…​FIXME

_warmEntries Method

_warmEntries: Int

_warmEntries is the number of warm entries of the size in 8192 (bytes?)

Note
_warmEntries is used when AbstractIndex is requested to indexSlotRangeFor.

largestLowerBoundSlotFor Method

largestLowerBoundSlotFor(
  idx: ByteBuffer,
  target: Long,
  searchEntity: IndexSearchEntity): Int

largestLowerBoundSlotFor…​FIXME

Note

largestLowerBoundSlotFor is used when:

smallestUpperBoundSlotFor Method

smallestUpperBoundSlotFor(
  idx: ByteBuffer,
  target: Long,
  searchEntity: IndexSearchEntity): Int

smallestUpperBoundSlotFor…​FIXME

Note
smallestUpperBoundSlotFor is used when OffsetIndex is requested to fetchUpperBoundOffset.

indexSlotRangeFor Internal Method

indexSlotRangeFor(
  idx: ByteBuffer,
  target: Long,
  searchEntity: IndexSearchEntity): (Int, Int)

indexSlotRangeFor…​FIXME

Note
indexSlotRangeFor is used when AbstractIndex is requested for the largestLowerBoundSlotFor and the smallestUpperBoundSlotFor.

compareIndexEntry Internal Method

compareIndexEntry(
  indexEntry: IndexEntry,
  target: Long,
  searchEntity: IndexSearchEntity): Int

compareIndexEntry…​FIXME

Note
compareIndexEntry is used when…​FIXME

Internal Properties

Name Description

_length

Length of the index

Used when…​FIXME

results matching ""

    No results matching ""