Class HeapPointWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, PointWriter

    public final class HeapPointWriter
    extends java.lang.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  HeapPointWriter.HeapPointValue
      Reusable implementation for a point value on-heap
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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 close()  
      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 count()
      Return the number of points in this writer
      void destroy()
      Removes any temp files behind this writer
      PointValue getPackedValueSlice​(int index)
      Returns a reference, in result, to the byte[] slice holding this value
      PointReader 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
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • block

        private final byte[] block
      • size

        final int size
      • scratch

        private final byte[] scratch
      • dataDimsAndDocLength

        private final int dataDimsAndDocLength
      • nextWrite

        private int nextWrite
      • closed

        private boolean closed
    • Constructor Detail

      • HeapPointWriter

        public HeapPointWriter​(BKDConfig config,
                               int size)
    • Method Detail

      • 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
      • 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
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object