Package org.apache.lucene.util
Class PagedBytes
java.lang.Object
org.apache.lucene.util.PagedBytes
- All Implemented Interfaces:
Accountable
Represents a logical byte[] as a series of pages. You can write-once into the logical byte[]
(append only), using copy, and then retrieve slices (BytesRef) into it using fill.
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Input that transparently iterates over pagesfinal class
Output that transparently spills to new pages as necessarystatic final class
Provides methods to read BytesRefs from a frozen PagedBytes. -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
ConstructorDescriptionPagedBytes
(int blockBits) 1<<blockBits must be bigger than biggest single BytesRef slice that will be pulled -
Method Summary
Modifier and TypeMethodDescriptionvoid
copy
(IndexInput in, long byteCount) Read this many bytes from invoid
Copy BytesRef in, setting BytesRef out to the result.long
copyUsingLengthPrefix
(BytesRef bytes) Copy bytes in, writing the length as a 1 or 2 byte vInt prefix.freeze
(boolean trim) Commits final byte[], trimming it if necessary and if trim=trueReturns a DataInput to read values from this PagedBytes instance.Returns a DataOutput that you may use to write into this PagedBytes instance.long
long
Return the memory usage of this object in bytes.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
-
Constructor Details
-
PagedBytes
public PagedBytes(int blockBits) 1<<blockBits must be bigger than biggest single BytesRef slice that will be pulled
-
-
Method Details
-
copy
Read this many bytes from in- Throws:
IOException
-
copy
Copy BytesRef in, setting BytesRef out to the result. Do not use this if you will use freeze(true). This only supports bytes.length <= blockSize -
freeze
Commits final byte[], trimming it if necessary and if trim=true -
getPointer
public long getPointer() -
ramBytesUsed
public long ramBytesUsed()Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsed
in interfaceAccountable
-
copyUsingLengthPrefix
Copy bytes in, writing the length as a 1 or 2 byte vInt prefix. -
getDataInput
Returns a DataInput to read values from this PagedBytes instance. -
getDataOutput
Returns a DataOutput that you may use to write into this PagedBytes instance. If you do this, you should not call the other writing methods (eg, copy); results are undefined.
-