congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ByteBlockPool.readBytes
Code IndexAdd Tabnine to your IDE (free)

How to use
readBytes
method
in
org.apache.lucene.util.ByteBlockPool

Best Java code snippets using org.apache.lucene.util.ByteBlockPool.readBytes (Showing top 8 results out of 315)

origin: org.apache.lucene/lucene-core

/**
 * Set the given {@link BytesRef} so that its content is equal to the
 * {@code ref.length} bytes starting at {@code offset}. Most of the time this
 * method will set pointers to internal data-structures. However, in case a
 * value crosses a boundary, a fresh copy will be returned.
 * On the contrary to {@link #setBytesRef(BytesRef, int)}, this does not
 * expect the length to be encoded with the data.
 */
public void setRawBytesRef(BytesRef ref, final long offset) {
 int bufferIndex = (int) (offset >> BYTE_BLOCK_SHIFT);
 int pos = (int) (offset & BYTE_BLOCK_MASK);
 if (pos + ref.length <= BYTE_BLOCK_SIZE) {
  ref.bytes = buffers[bufferIndex];
  ref.offset = pos;
 } else {
  ref.bytes = new byte[ref.length];
  ref.offset = 0;
  readBytes(offset, ref.bytes, 0, ref.length);
 }
}
origin: org.apache.lucene/lucene-core

/** Fill the provided {@link BytesRef} with the bytes at the specified offset/length slice.
 *  This will avoid copying the bytes, if the slice fits into a single block; otherwise, it uses
 *  the provided {@link BytesRefBuilder} to copy bytes over. */
void setBytesRef(BytesRefBuilder builder, BytesRef result, long offset, int length) {
 result.length = length;
 int bufferIndex = (int) (offset >> BYTE_BLOCK_SHIFT);
 byte[] buffer = buffers[bufferIndex];
 int pos = (int) (offset & BYTE_BLOCK_MASK);
 if (pos + length <= BYTE_BLOCK_SIZE) {
  // common case where the slice lives in a single block: just reference the buffer directly without copying
  result.bytes = buffer;
  result.offset = pos;
 } else {
  // uncommon case: the slice spans at least 2 blocks, so we must copy the bytes:
  builder.grow(length);
  result.bytes = builder.get().bytes;
  result.offset = 0;
  readBytes(offset, result.bytes, 0, length);
 }
}
origin: org.apache.lucene/lucene-core

/**
 * Returns the <i>n'th</i> element of this {@link BytesRefArray}
 * @param spare a spare {@link BytesRef} instance
 * @param index the elements index to retrieve 
 * @return the <i>n'th</i> element of this {@link BytesRefArray}
 */
public BytesRef get(BytesRefBuilder spare, int index) {
 FutureObjects.checkIndex(index, lastElement);
 int offset = offsets[index];
 int length = index == lastElement - 1 ? currentOffset - offset
   : offsets[index + 1] - offset;
 spare.grow(length);
 spare.setLength(length);
 pool.readBytes(offset, spare.bytes(), 0, spare.length());
 return spare.get();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
 * Set the given {@link BytesRef} so that its content is equal to the
 * {@code ref.length} bytes starting at {@code offset}. Most of the time this
 * method will set pointers to internal data-structures. However, in case a
 * value crosses a boundary, a fresh copy will be returned.
 * On the contrary to {@link #setBytesRef(BytesRef, int)}, this does not
 * expect the length to be encoded with the data.
 */
public void setRawBytesRef(BytesRef ref, final long offset) {
 int bufferIndex = (int) (offset >> BYTE_BLOCK_SHIFT);
 int pos = (int) (offset & BYTE_BLOCK_MASK);
 if (pos + ref.length <= BYTE_BLOCK_SIZE) {
  ref.bytes = buffers[bufferIndex];
  ref.offset = pos;
 } else {
  ref.bytes = new byte[ref.length];
  ref.offset = 0;
  readBytes(offset, ref.bytes, 0, ref.length);
 }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** Fill the provided {@link BytesRef} with the bytes at the specified offset/length slice.
 *  This will avoid copying the bytes, if the slice fits into a single block; otherwise, it uses
 *  the provided {@link BytesRefBuilder} to copy bytes over. */
void setBytesRef(BytesRefBuilder builder, BytesRef result, long offset, int length) {
 result.length = length;
 int bufferIndex = (int) (offset >> BYTE_BLOCK_SHIFT);
 byte[] buffer = buffers[bufferIndex];
 int pos = (int) (offset & BYTE_BLOCK_MASK);
 if (pos + length <= BYTE_BLOCK_SIZE) {
  // common case where the slice lives in a single block: just reference the buffer directly without copying
  result.bytes = buffer;
  result.offset = pos;
 } else {
  // uncommon case: the slice spans at least 2 blocks, so we must copy the bytes:
  builder.grow(length);
  result.bytes = builder.get().bytes;
  result.offset = 0;
  readBytes(offset, result.bytes, 0, length);
 }
}
origin: org.infinispan/infinispan-embedded-query

/**
 * Returns the <i>n'th</i> element of this {@link BytesRefArray}
 * @param spare a spare {@link BytesRef} instance
 * @param index the elements index to retrieve 
 * @return the <i>n'th</i> element of this {@link BytesRefArray}
 */
public BytesRef get(BytesRefBuilder spare, int index) {
 if (lastElement > index) {
  int offset = offsets[index];
  int length = index == lastElement - 1 ? currentOffset - offset
    : offsets[index + 1] - offset;
  spare.grow(length);
  spare.setLength(length);
  pool.readBytes(offset, spare.bytes(), 0, spare.length());
  return spare.get();
 }
 throw new IndexOutOfBoundsException("index " + index
   + " must be less than the size: " + lastElement);
 
}

origin: harbby/presto-connectors

/**
 * Returns the <i>n'th</i> element of this {@link BytesRefArray}
 * @param spare a spare {@link BytesRef} instance
 * @param index the elements index to retrieve 
 * @return the <i>n'th</i> element of this {@link BytesRefArray}
 */
public BytesRef get(BytesRefBuilder spare, int index) {
 if (lastElement > index) {
  int offset = offsets[index];
  int length = index == lastElement - 1 ? currentOffset - offset
    : offsets[index + 1] - offset;
  spare.grow(length);
  spare.setLength(length);
  pool.readBytes(offset, spare.bytes(), 0, spare.length());
  return spare.get();
 }
 throw new IndexOutOfBoundsException("index " + index
   + " must be less than the size: " + lastElement);
 
}

origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
 * Returns the <i>n'th</i> element of this {@link BytesRefArray}
 * @param spare a spare {@link BytesRef} instance
 * @param index the elements index to retrieve 
 * @return the <i>n'th</i> element of this {@link BytesRefArray}
 */
public BytesRef get(BytesRefBuilder spare, int index) {
 FutureObjects.checkIndex(index, lastElement);
 int offset = offsets[index];
 int length = index == lastElement - 1 ? currentOffset - offset
   : offsets[index + 1] - offset;
 spare.grow(length);
 spare.setLength(length);
 pool.readBytes(offset, spare.bytes(), 0, spare.length());
 return spare.get();
}
org.apache.lucene.utilByteBlockPoolreadBytes

Javadoc

Reads bytes bytes out of the pool starting at the given offset with the given length into the given byte array at offset off.

Note: this method allows to copy across block boundaries.

Popular methods of ByteBlockPool

  • <init>
  • reset
    Expert: Resets the pool to its initial state reusing the first buffer. Calling ByteBlockPool#nextBuf
  • nextBuffer
    Advances the pool to its next buffer. This method should be called once after the constructor to ini
  • allocSlice
    Creates a new byte slice with the given starting size and returns the slices offset in the pool.
  • append
    Appends the bytes in the provided BytesRef at the current position.
  • newSlice
    Allocates a new slice with the given size.
  • setBytesRef
    Fill the provided BytesRef with the bytes at the specified offset/length slice. This will avoid copy
  • readByte
    Read a single byte at the given offset.
  • setRawBytesRef
    Set the given BytesRef so that its content is equal to the ref.length bytes starting at offset. Most
  • copy
  • copyFrom
  • copyFrom

Popular in Java

  • Running tasks concurrently on multiple threads
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • notifyDataSetChanged (ArrayAdapter)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Menu (java.awt)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now