Class BinaryNameMatcher

All Implemented Interfaces:
Serializable

public final class BinaryNameMatcher extends HashedMatcherBase implements Serializable
Simplified static symbol table used instead of global quad-based canonicalizer when we have smaller set of symbols (like properties of a POJO class).
Since:
3.0
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • MAX_ENTRIES

      public static final int MAX_ENTRIES
      See Also:
    • MAX_LENGTH_IN_QUADS

      private static final int MAX_LENGTH_IN_QUADS
      See Also:
    • _hashArea

      private int[] _hashArea
      Primary hash information area: consists of 2 * _hashSize entries of 16 bytes (4 ints), arranged in a cascading lookup structure (details of which may be tweaked depending on expected rates of collisions).
    • _hashSize

      private int _hashSize
      Number of slots for primary entries within _hashArea; which is at most 1/8 of actual size of the underlying array (4-int slots, primary covers only half of the area; plus, additional area for longer symbols after hash area).
    • _secondaryStart

      private int _secondaryStart
      Offset within _hashArea where secondary entries start
    • _tertiaryStart

      private int _tertiaryStart
      Offset within _hashArea where tertiary entries start
    • _tertiaryShift

      private int _tertiaryShift
      Constant that determines size of buckets for tertiary entries: 1 << _tertiaryShift is the size, and shift value is also used for translating from primary offset into tertiary bucket (shift right by 4 + _tertiaryShift).

      Default value is 2, for buckets of 4 slots; grows bigger with bigger table sizes.

    • _count

      private int _count
      Total number of Strings in the symbol table
    • _spilloverEnd

      private int _spilloverEnd
      Pointer to the offset within spill-over area where there is room for more spilled over entries (if any). Spill over area is within fixed-size portion of _hashArea.
    • _longNameOffset

      private int _longNameOffset
      Offset within _hashArea that follows main slots and contains quads for longer names (13 bytes or longer), and points to the first available int that may be used for appending quads of the next long name. Note that long name area follows immediately after the fixed-size main hash area (_hashArea).
    • MULT

      private static final int MULT
      See Also:
    • MULT2

      private static final int MULT2
      See Also:
    • MULT3

      private static final int MULT3
      See Also:
  • Constructor Details

    • BinaryNameMatcher

      private BinaryNameMatcher(SimpleNameMatcher matcher, String[] nameLookup, int hashSize)
      Constructor used for creating per-TokenStreamFactory "root" symbol tables (for formats that use such approach): ones used for merging and sharing common symbols
      Parameters:
      matcher - Backup matcher used if efficient primary matching cannot be used
      nameLookup - Set of names to match
      hashSize - Estimated basic hash area size to use (slightly bigger than number of entries in nameLookup array
  • Method Details

    • _calcTertiaryShift

      static int _calcTertiaryShift(int primarySlots)
    • constructFrom

      public static BinaryNameMatcher constructFrom(List<Named> propertyNames, boolean alreadyInterned)
    • construct

      public static BinaryNameMatcher construct(List<String> symbols)
    • constructCaseInsensitive

      public static BinaryNameMatcher constructCaseInsensitive(Locale locale, List<Named> propertyNames, boolean alreadyInterned)
    • _construct

      private static BinaryNameMatcher _construct(List<String> symbols, SimpleNameMatcher base)
    • addName

      public int addName(String name)
    • addName

      private int addName(String name, int q1)
    • addName

      private int addName(String name, int q1, int q2)
    • addName

      private int addName(String name, int q1, int q2, int q3)
    • addName

      private int addName(String name, int[] q, int qlen)
    • _findOffsetForAdd

      private int _findOffsetForAdd(int hash)
      Method called to find the location within hash table to add a new symbol in.
    • _appendLongName

      private int _appendLongName(int[] quads, int qlen)
    • size

      public int size()
    • bucketCount

      public int bucketCount()
    • primaryQuadCount

      public int primaryQuadCount()
    • secondaryQuadCount

      public int secondaryQuadCount()
    • tertiaryQuadCount

      public int tertiaryQuadCount()
    • spilloverQuadCount

      public int spilloverQuadCount()
    • totalCount

      public int totalCount()
    • matchByQuad

      public int matchByQuad(int q1)
      Specified by:
      matchByQuad in class PropertyNameMatcher
    • matchByQuad

      public int matchByQuad(int q1, int q2)
      Specified by:
      matchByQuad in class PropertyNameMatcher
    • matchByQuad

      public int matchByQuad(int q1, int q2, int q3)
      Specified by:
      matchByQuad in class PropertyNameMatcher
    • matchByQuad

      public int matchByQuad(int[] q, int qlen)
      Specified by:
      matchByQuad in class PropertyNameMatcher
    • _calcOffset

      private final int _calcOffset(int hash)
    • _findTertiary

      private int _findTertiary(int origOffset, int q1)
    • _findTertiary

      private int _findTertiary(int origOffset, int q1, int q2)
    • _findTertiary

      private int _findTertiary(int origOffset, int q1, int q2, int q3)
    • _findTertiary

      private int _findTertiary(int origOffset, int hash, int[] q, int qlen)
    • _verifyLongName

      private boolean _verifyLongName(int[] q, int qlen, int spillOffset)
    • _verifyLongName2

      private boolean _verifyLongName2(int[] q, int qlen, int spillOffset)
    • calcHash

      public int calcHash(int q1)
    • calcHash

      public int calcHash(int q1, int q2)
    • calcHash

      public int calcHash(int q1, int q2, int q3)
    • calcHash

      public int calcHash(int[] q, int qlen)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • _quads

      public static int[] _quads(String name)
    • _decodeFull

      private static int _decodeFull(byte[] b, int offset)
    • _decodeLast

      private static int _decodeLast(byte[] b, int offset, int bytes)
    • _lengthAndIndex

      private int _lengthAndIndex(int qlen)
    • _spilloverStart

      private int _spilloverStart()
      Helper method that calculates start of the spillover area