- java.lang.Object
-
- org.apache.lucene.util.bkd.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
-
Field Summary
Fields Modifier and Type Field Description private byte[]
block
private boolean
closed
private BKDConfig
config
private int
dataDimsAndDocLength
private ArrayUtil.ByteArrayComparator
dimComparator
private int
nextWrite
private HeapPointWriter.HeapPointValue
pointValue
private byte[]
scratch
(package private) int
size
-
Constructor Summary
Constructors Constructor Description HeapPointWriter(BKDConfig config, int size)
-
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 docIdvoid
append(PointValue pointValue)
Add a new point from aPointValue
(package private) int
byteAt(int i, int k)
Return the byte at positionk
of the point at positioni
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 positionj
with the provided value(package private) int
compareDataDimsAndDoc(int i, int j)
Compares the data dimensions and doc values of the point at positioni
with the point at positionj
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 dimensiondim
value of the point at positionj
with the provided value(package private) int
compareDim(int i, int j, int dim)
Compares the dimensiondim
value of the point at positioni
with the point at positionj
int
computeCardinality(int from, int to, int[] commonPrefixLengths)
Computes the cardinality of the points betweenfrom
tpto
(package private) void
copyDataDimsAndDoc(int i, byte[] bytes, int offset)
Copy the data dimensions and doc value of the point at positioni
in the providedbytes
at the given offset(package private) void
copyDim(int i, int dim, byte[] bytes, int offset)
Copy the dimensiondim
of the point at positioni
in the providedbytes
at the given offsetlong
count()
Return the number of points in this writervoid
destroy()
Removes any temp files behind this writerPointValue
getPackedValueSlice(int index)
Returns a reference, inresult
, to the byte[] slice holding this valuePointReader
getReader(long start, long length)
Returns aPointReader
iterator to step through all previously added points(package private) void
swap(int i, int j)
Swaps the point at pointi
with the point at positionj
java.lang.String
toString()
-
-
-
Field Detail
-
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 Detail
-
HeapPointWriter
public HeapPointWriter(BKDConfig config, int size)
-
-
Method Detail
-
getPackedValueSlice
public PointValue getPackedValueSlice(int index)
Returns a reference, inresult
, 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 interfacePointWriter
-
append
public void append(PointValue pointValue)
Description copied from interface:PointWriter
Add a new point from aPointValue
- Specified by:
append
in interfacePointWriter
-
swap
void swap(int i, int j)
Swaps the point at pointi
with the point at positionj
-
byteAt
int byteAt(int i, int k)
Return the byte at positionk
of the point at positioni
-
copyDim
void copyDim(int i, int dim, byte[] bytes, int offset)
Copy the dimensiondim
of the point at positioni
in the providedbytes
at the given offset
-
copyDataDimsAndDoc
void copyDataDimsAndDoc(int i, byte[] bytes, int offset)
Copy the data dimensions and doc value of the point at positioni
in the providedbytes
at the given offset
-
compareDim
int compareDim(int i, int j, int dim)
Compares the dimensiondim
value of the point at positioni
with the point at positionj
-
compareDim
int compareDim(int j, byte[] dimValue, int offset, int dim)
Compares the dimensiondim
value of the point at positionj
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 positioni
with the point at positionj
-
compareDataDimsAndDoc
int compareDataDimsAndDoc(int j, byte[] dataDimsAndDocs, int offset)
Compares the data dimensions and doc values of the point at positionj
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 betweenfrom
tpto
-
count
public long count()
Description copied from interface:PointWriter
Return the number of points in this writer- Specified by:
count
in interfacePointWriter
-
getReader
public PointReader getReader(long start, long length)
Description copied from interface:PointWriter
Returns aPointReader
iterator to step through all previously added points- Specified by:
getReader
in interfacePointWriter
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
destroy
public void destroy()
Description copied from interface:PointWriter
Removes any temp files behind this writer- Specified by:
destroy
in interfacePointWriter
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-