org.apache.lucene.codecs.uniformsplit

## Class TermBytes

- java.lang.Object
- - org.apache.lucene.codecs.uniformsplit.TermBytes

- All Implemented Interfaces:
    Accountable

      public class TermBytes
      extends Object
      implements Accountable

  Term of a block line.

  Contains the term bytes and the minimal distinguishing prefix (MDP) length of this term.

  The MDP is the minimal prefix that distinguishes a term from its immediate previous term (terms are alphabetically sorted).

  The incremental encoding suffix is the suffix starting at the last byte of the MDP (inclusive).

  Example: For the block

       client
       color
       company
       companies

  "color" - MDP is "co" - incremental encoding suffix is "olor".
  "company" - MDP is "com" - incremental encoding suffix is "mpany".
  "companies" - MDP is "compani" - incremental encoding suffix is "ies".
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `mdpLength`
    `protected BytesRef` | `term`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TermBytes(int mdpLength, BytesRef term)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `computeMdpLength(BytesRef previousTerm, BytesRef currentTerm)` Computes the length of the minimal distinguishing prefix (MDP) between a current term and its previous term (terms are alphabetically sorted).
    `int` | `getMdpLength()`
    `int` | `getSuffixLength()`
    `int` | `getSuffixOffset()`
    `BytesRef` | `getTerm()`
    `long` | `ramBytesUsed()`
    `TermBytes` | `reset(int mdpLength, BytesRef term)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.lucene.util.Accountable

      `getChildResources`

- - ### Field Detail

    - #### mdpLength

          protected int mdpLength

    - #### term

          protected BytesRef term

  - ### Constructor Detail

    - #### TermBytes

          public TermBytes(int mdpLength,
                           BytesRef term)

  - ### Method Detail

    - #### reset

          public TermBytes reset(int mdpLength,
                                 BytesRef term)

    - #### getMdpLength

          public int getMdpLength()

      Returns:
        This term MDP length.
      See Also:
        `TermBytes`

    - #### getTerm

          public BytesRef getTerm()

      Returns:
        This term bytes.

    - #### getSuffixOffset

          public int getSuffixOffset()

      Returns:
        The offset of this term incremental encoding suffix.
      See Also:
        `TermBytes`

    - #### getSuffixLength

          public int getSuffixLength()

      Returns:
        The length of this term incremental encoding suffix.
      See Also:
        `TermBytes`

    - #### computeMdpLength

          public static int computeMdpLength(BytesRef previousTerm,
                                             BytesRef currentTerm)

      Computes the length of the minimal distinguishing prefix (MDP) between a current term and its previous term (terms are alphabetically sorted).

      Example: If previous="car" and current="cartridge", then MDP length is 4. It is the length of the minimal prefix distinguishing "cartridge" from "car", that is, the length of "cart".

      See Also:
        `TermBytes`

    - #### ramBytesUsed

          public long ramBytesUsed()

      Specified by:
        `ramBytesUsed` in interface `Accountable`

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.