Class HeapPointWriter

java.lang.Object
org.apache.lucene.util.bkd.HeapPointWriter
All Implemented Interfaces:
Closeable, AutoCloseable, PointWriter

public final class HeapPointWriter extends Object implements PointWriter
Utility class to write new points into in-heap arrays.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Reusable implementation for a point value on-heap
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
     
    private boolean
     
    private final BKDConfig
     
    private final int
     
     
    private int
     
     
    private final byte[]
     
    (package private) final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    HeapPointWriter(BKDConfig config, int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(byte[] packedValue, int docID)
    Add a new point from the packed value and docId
    void
    append(PointValue pointValue)
    Add a new point from a PointValue
    (package private) int
    byteAt(int i, int k)
    Return the byte at position k of the point at position i
    void
     
    private int
    compareDataDimsAndDoc(byte[] blockI, int offsetI, byte[] blockJ, int offsetJ)
     
    (package private) int
    compareDataDimsAndDoc(int j, byte[] dataDimsAndDocs, int offset)
    Compares the data dimensions and doc values of the point at position j with the provided value
    (package private) int
    compareDataDimsAndDoc(int i, int j)
    Compares the data dimensions and doc values of the point at position i with the point at position j
    private int
    compareDim(byte[] blockI, int offsetI, byte[] blockJ, int offsetJ)
     
    (package private) int
    compareDim(int j, byte[] dimValue, int offset, int dim)
    Compares the dimension dim value of the point at position j with the provided value
    (package private) int
    compareDim(int i, int j, int dim)
    Compares the dimension dim value of the point at position i with the point at position j
    int
    computeCardinality(int from, int to, int[] commonPrefixLengths)
    Computes the cardinality of the points between from tp to
    (package private) void
    copyDataDimsAndDoc(int i, byte[] bytes, int offset)
    Copy the data dimensions and doc value of the point at position i in the provided bytes at the given offset
    (package private) void
    copyDim(int i, int dim, byte[] bytes, int offset)
    Copy the dimension dim of the point at position i in the provided bytes at the given offset
    long
    Return the number of points in this writer
    void
    Removes any temp files behind this writer
    Returns a reference, in result, to the byte[] slice holding this value
    getReader(long start, long length)
    Returns a PointReader iterator to step through all previously added points
    (package private) void
    swap(int i, int j)
    Swaps the point at point i with the point at position j
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • block

      private final byte[] block
    • size

      final int size
    • config

      private final BKDConfig config
    • scratch

      private final byte[] scratch
    • dimComparator

      private final ArrayUtil.ByteArrayComparator dimComparator
    • dataDimsAndDocLength

      private final int dataDimsAndDocLength
    • nextWrite

      private int nextWrite
    • closed

      private boolean closed
    • pointValue

      private final HeapPointWriter.HeapPointValue pointValue
  • Constructor Details

    • HeapPointWriter

      public HeapPointWriter(BKDConfig config, int size)
  • Method Details

    • getPackedValueSlice

      public PointValue getPackedValueSlice(int index)
      Returns a reference, in result, to the byte[] slice holding this value
    • append

      public void append(byte[] packedValue, int docID)
      Description copied from interface: PointWriter
      Add a new point from the packed value and docId
      Specified by:
      append in interface PointWriter
    • append

      public void append(PointValue pointValue)
      Description copied from interface: PointWriter
      Add a new point from a PointValue
      Specified by:
      append in interface PointWriter
    • swap

      void swap(int i, int j)
      Swaps the point at point i with the point at position j
    • byteAt

      int byteAt(int i, int k)
      Return the byte at position k of the point at position i
    • copyDim

      void copyDim(int i, int dim, byte[] bytes, int offset)
      Copy the dimension dim of the point at position i in the provided bytes at the given offset
    • copyDataDimsAndDoc

      void copyDataDimsAndDoc(int i, byte[] bytes, int offset)
      Copy the data dimensions and doc value of the point at position i in the provided bytes at the given offset
    • compareDim

      int compareDim(int i, int j, int dim)
      Compares the dimension dim value of the point at position i with the point at position j
    • compareDim

      int compareDim(int j, byte[] dimValue, int offset, int dim)
      Compares the dimension dim value of the point at position j with the provided value
    • compareDim

      private int compareDim(byte[] blockI, int offsetI, byte[] blockJ, int offsetJ)
    • compareDataDimsAndDoc

      int compareDataDimsAndDoc(int i, int j)
      Compares the data dimensions and doc values of the point at position i with the point at position j
    • compareDataDimsAndDoc

      int compareDataDimsAndDoc(int j, byte[] dataDimsAndDocs, int offset)
      Compares the data dimensions and doc values of the point at position j with the provided value
    • compareDataDimsAndDoc

      private int compareDataDimsAndDoc(byte[] blockI, int offsetI, byte[] blockJ, int offsetJ)
    • computeCardinality

      public int computeCardinality(int from, int to, int[] commonPrefixLengths)
      Computes the cardinality of the points between from tp to
    • count

      public long count()
      Description copied from interface: PointWriter
      Return the number of points in this writer
      Specified by:
      count in interface PointWriter
    • getReader

      public PointReader getReader(long start, long length)
      Description copied from interface: PointWriter
      Returns a PointReader iterator to step through all previously added points
      Specified by:
      getReader in interface PointWriter
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • destroy

      public void destroy()
      Description copied from interface: PointWriter
      Removes any temp files behind this writer
      Specified by:
      destroy in interface PointWriter
    • toString

      public String toString()
      Overrides:
      toString in class Object