Tabnine Logo
ByteBlockPool.nextBuffer
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: org.apache.lucene/lucene-core

/**
 * Allocates a new slice with the given size. 
 * @see ByteBlockPool#FIRST_LEVEL_SIZE
 */
public int newSlice(final int size) {
 if (byteUpto > BYTE_BLOCK_SIZE-size)
  nextBuffer();
 final int upto = byteUpto;
 byteUpto += size;
 buffer[byteUpto-1] = 16;
 return upto;
}
origin: org.apache.lucene/lucene-core

/**
 * Creates a new byte slice with the given starting size and 
 * returns the slices offset in the pool.
 */
public int allocSlice(final byte[] slice, final int upto) {
 final int level = slice[upto] & 15;
 final int newLevel = NEXT_LEVEL_ARRAY[level];
 final int newSize = LEVEL_SIZE_ARRAY[newLevel];
 // Maybe allocate another block
 if (byteUpto > BYTE_BLOCK_SIZE-newSize) {
  nextBuffer();
 }
 final int newUpto = byteUpto;
 final int offset = newUpto + byteOffset;
 byteUpto += newSize;
 // Copy forward the past 3 bytes (which we are about
 // to overwrite with the forwarding address):
 buffer[newUpto] = slice[upto-3];
 buffer[newUpto+1] = slice[upto-2];
 buffer[newUpto+2] = slice[upto-1];
 // Write forwarding address at end of last slice:
 slice[upto-3] = (byte) (offset >>> 24);
 slice[upto-2] = (byte) (offset >>> 16);
 slice[upto-1] = (byte) (offset >>> 8);
 slice[upto] = (byte) offset;
   
 // Write new level:
 buffer[byteUpto-1] = (byte) (16|newLevel);
 return newUpto+3;
}
origin: org.apache.lucene/lucene-core

/**
 * Appends the bytes in the provided {@link BytesRef} at
 * the current position.
 */
public void append(final BytesRef bytes) {
 int bytesLeft = bytes.length;
 int offset = bytes.offset;
 while (bytesLeft > 0) {
  int bufferLeft = BYTE_BLOCK_SIZE - byteUpto;
  if (bytesLeft < bufferLeft) {
   // fits within current buffer
   System.arraycopy(bytes.bytes, offset, buffer, byteUpto, bytesLeft);
   byteUpto += bytesLeft;
   break;
  } else {
   // fill up this buffer and move to next one
   if (bufferLeft > 0) {
    System.arraycopy(bytes.bytes, offset, buffer, byteUpto, bufferLeft);
   }
   nextBuffer();
   bytesLeft -= bufferLeft;
   offset += bufferLeft;
  }
 }
}

origin: org.apache.lucene/lucene-core

/**
 * Creates a new {@link BytesRefArray} with a counter to track allocated bytes
 */
public BytesRefArray(Counter bytesUsed) {
 this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(
   bytesUsed));
 pool.nextBuffer();
 bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER * Integer.BYTES);
 this.bytesUsed = bytesUsed;
}
origin: org.apache.lucene/lucene-core

   + (BYTE_BLOCK_SIZE - 2) + " in length; got " + bytes.length);
pool.nextBuffer();
origin: org.apache.lucene/lucene-core

public void add(int textStart) throws IOException {
 int termID = bytesHash.addByPoolOffset(textStart);
 if (termID >= 0) {      // New posting
  // First time we are seeing this token since we last
  // flushed the hash.
  // Init stream slices
  if (numPostingInt + intPool.intUpto > IntBlockPool.INT_BLOCK_SIZE) {
   intPool.nextBuffer();
  }
  if (ByteBlockPool.BYTE_BLOCK_SIZE - bytePool.byteUpto < numPostingInt*ByteBlockPool.FIRST_LEVEL_SIZE) {
   bytePool.nextBuffer();
  }
  intUptos = intPool.buffer;
  intUptoStart = intPool.intUpto;
  intPool.intUpto += streamCount;
  postingsArray.intStarts[termID] = intUptoStart + intPool.intOffset;
  for(int i=0;i<streamCount;i++) {
   final int upto = bytePool.newSlice(ByteBlockPool.FIRST_LEVEL_SIZE);
   intUptos[intUptoStart+i] = upto + bytePool.byteOffset;
  }
  postingsArray.byteStarts[termID] = intUptos[intUptoStart];
  newTerm(termID);
 } else {
  termID = (-termID)-1;
  int intStart = postingsArray.intStarts[termID];
  intUptos = intPool.buffers[intStart >> IntBlockPool.INT_BLOCK_SHIFT];
  intUptoStart = intStart & IntBlockPool.INT_BLOCK_MASK;
  addTerm(termID);
 }
}
origin: org.apache.lucene/lucene-core

bytePool.nextBuffer();
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
 * Allocates a new slice with the given size. 
 * @see ByteBlockPool#FIRST_LEVEL_SIZE
 */
public int newSlice(final int size) {
 if (byteUpto > BYTE_BLOCK_SIZE-size)
  nextBuffer();
 final int upto = byteUpto;
 byteUpto += size;
 buffer[byteUpto-1] = 16;
 return upto;
}
origin: org.infinispan/infinispan-embedded-query

/**
 * Allocates a new slice with the given size. 
 * @see ByteBlockPool#FIRST_LEVEL_SIZE
 */
public int newSlice(final int size) {
 if (byteUpto > BYTE_BLOCK_SIZE-size)
  nextBuffer();
 final int upto = byteUpto;
 byteUpto += size;
 buffer[byteUpto-1] = 16;
 return upto;
}
origin: harbby/presto-connectors

/**
 * Allocates a new slice with the given size. 
 * @see ByteBlockPool#FIRST_LEVEL_SIZE
 */
public int newSlice(final int size) {
 if (byteUpto > BYTE_BLOCK_SIZE-size)
  nextBuffer();
 final int upto = byteUpto;
 byteUpto += size;
 buffer[byteUpto-1] = 16;
 return upto;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
 * Creates a new byte slice with the given starting size and 
 * returns the slices offset in the pool.
 */
public int allocSlice(final byte[] slice, final int upto) {
 final int level = slice[upto] & 15;
 final int newLevel = NEXT_LEVEL_ARRAY[level];
 final int newSize = LEVEL_SIZE_ARRAY[newLevel];
 // Maybe allocate another block
 if (byteUpto > BYTE_BLOCK_SIZE-newSize) {
  nextBuffer();
 }
 final int newUpto = byteUpto;
 final int offset = newUpto + byteOffset;
 byteUpto += newSize;
 // Copy forward the past 3 bytes (which we are about
 // to overwrite with the forwarding address):
 buffer[newUpto] = slice[upto-3];
 buffer[newUpto+1] = slice[upto-2];
 buffer[newUpto+2] = slice[upto-1];
 // Write forwarding address at end of last slice:
 slice[upto-3] = (byte) (offset >>> 24);
 slice[upto-2] = (byte) (offset >>> 16);
 slice[upto-1] = (byte) (offset >>> 8);
 slice[upto] = (byte) offset;
   
 // Write new level:
 buffer[byteUpto-1] = (byte) (16|newLevel);
 return newUpto+3;
}
origin: org.infinispan/infinispan-embedded-query

/**
 * Creates a new byte slice with the given starting size and 
 * returns the slices offset in the pool.
 */
public int allocSlice(final byte[] slice, final int upto) {
 final int level = slice[upto] & 15;
 final int newLevel = NEXT_LEVEL_ARRAY[level];
 final int newSize = LEVEL_SIZE_ARRAY[newLevel];
 // Maybe allocate another block
 if (byteUpto > BYTE_BLOCK_SIZE-newSize) {
  nextBuffer();
 }
 final int newUpto = byteUpto;
 final int offset = newUpto + byteOffset;
 byteUpto += newSize;
 // Copy forward the past 3 bytes (which we are about
 // to overwrite with the forwarding address):
 buffer[newUpto] = slice[upto-3];
 buffer[newUpto+1] = slice[upto-2];
 buffer[newUpto+2] = slice[upto-1];
 // Write forwarding address at end of last slice:
 slice[upto-3] = (byte) (offset >>> 24);
 slice[upto-2] = (byte) (offset >>> 16);
 slice[upto-1] = (byte) (offset >>> 8);
 slice[upto] = (byte) offset;
   
 // Write new level:
 buffer[byteUpto-1] = (byte) (16|newLevel);
 return newUpto+3;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
 * Appends the bytes in the provided {@link BytesRef} at
 * the current position.
 */
public void append(final BytesRef bytes) {
 int bytesLeft = bytes.length;
 int offset = bytes.offset;
 while (bytesLeft > 0) {
  int bufferLeft = BYTE_BLOCK_SIZE - byteUpto;
  if (bytesLeft < bufferLeft) {
   // fits within current buffer
   System.arraycopy(bytes.bytes, offset, buffer, byteUpto, bytesLeft);
   byteUpto += bytesLeft;
   break;
  } else {
   // fill up this buffer and move to next one
   if (bufferLeft > 0) {
    System.arraycopy(bytes.bytes, offset, buffer, byteUpto, bufferLeft);
   }
   nextBuffer();
   bytesLeft -= bufferLeft;
   offset += bufferLeft;
  }
 }
}

origin: harbby/presto-connectors

/**
 * Appends the bytes in the provided {@link BytesRef} at
 * the current position.
 */
public void append(final BytesRef bytes) {
 int length = bytes.length;
 if (length == 0) {
  return;
 }
 int offset = bytes.offset;
 int overflow = (length + byteUpto) - BYTE_BLOCK_SIZE;
 do {
  if (overflow <= 0) { 
   System.arraycopy(bytes.bytes, offset, buffer, byteUpto, length);
   byteUpto += length;
   break;
  } else {
   final int bytesToCopy = length-overflow;
   if (bytesToCopy > 0) {
    System.arraycopy(bytes.bytes, offset, buffer, byteUpto, bytesToCopy);
    offset += bytesToCopy;
    length -= bytesToCopy;
   }
   nextBuffer();
   overflow = overflow - BYTE_BLOCK_SIZE;
  }
 }  while(true);
}

origin: org.infinispan/infinispan-embedded-query

/**
 * Appends the bytes in the provided {@link BytesRef} at
 * the current position.
 */
public void append(final BytesRef bytes) {
 int length = bytes.length;
 if (length == 0) {
  return;
 }
 int offset = bytes.offset;
 int overflow = (length + byteUpto) - BYTE_BLOCK_SIZE;
 do {
  if (overflow <= 0) { 
   System.arraycopy(bytes.bytes, offset, buffer, byteUpto, length);
   byteUpto += length;
   break;
  } else {
   final int bytesToCopy = length-overflow;
   if (bytesToCopy > 0) {
    System.arraycopy(bytes.bytes, offset, buffer, byteUpto, bytesToCopy);
    offset += bytesToCopy;
    length -= bytesToCopy;
   }
   nextBuffer();
   overflow = overflow - BYTE_BLOCK_SIZE;
  }
 }  while(true);
}

origin: org.apache.lucene/lucene-spellchecker

/**
 * Creates a new {@link BytesRefList}
 */
public BytesRefList() {
 this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(
   bytesUsed));
 pool.nextBuffer();
 bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER
   + RamUsageEstimator.NUM_BYTES_INT);
}
origin: harbby/presto-connectors

/**
 * Creates a new {@link BytesRefArray} with a counter to track allocated bytes
 */
public BytesRefArray(Counter bytesUsed) {
 this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(
   bytesUsed));
 pool.nextBuffer();
 bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER
   + RamUsageEstimator.NUM_BYTES_INT);
 this.bytesUsed = bytesUsed;
}
origin: org.infinispan/infinispan-embedded-query

/**
 * Creates a new {@link BytesRefArray} with a counter to track allocated bytes
 */
public BytesRefArray(Counter bytesUsed) {
 this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(
   bytesUsed));
 pool.nextBuffer();
 bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER
   + RamUsageEstimator.NUM_BYTES_INT);
 this.bytesUsed = bytesUsed;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
 * Creates a new {@link BytesRefArray} with a counter to track allocated bytes
 */
public BytesRefArray(Counter bytesUsed) {
 this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(
   bytesUsed));
 pool.nextBuffer();
 bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER * Integer.BYTES);
 this.bytesUsed = bytesUsed;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

public void add(int textStart) throws IOException {
 int termID = bytesHash.addByPoolOffset(textStart);
 if (termID >= 0) {      // New posting
  // First time we are seeing this token since we last
  // flushed the hash.
  // Init stream slices
  if (numPostingInt + intPool.intUpto > IntBlockPool.INT_BLOCK_SIZE) {
   intPool.nextBuffer();
  }
  if (ByteBlockPool.BYTE_BLOCK_SIZE - bytePool.byteUpto < numPostingInt*ByteBlockPool.FIRST_LEVEL_SIZE) {
   bytePool.nextBuffer();
  }
  intUptos = intPool.buffer;
  intUptoStart = intPool.intUpto;
  intPool.intUpto += streamCount;
  postingsArray.intStarts[termID] = intUptoStart + intPool.intOffset;
  for(int i=0;i<streamCount;i++) {
   final int upto = bytePool.newSlice(ByteBlockPool.FIRST_LEVEL_SIZE);
   intUptos[intUptoStart+i] = upto + bytePool.byteOffset;
  }
  postingsArray.byteStarts[termID] = intUptos[intUptoStart];
  newTerm(termID);
 } else {
  termID = (-termID)-1;
  int intStart = postingsArray.intStarts[termID];
  intUptos = intPool.buffers[intStart >> IntBlockPool.INT_BLOCK_SHIFT];
  intUptoStart = intStart & IntBlockPool.INT_BLOCK_MASK;
  addTerm(termID);
 }
}
org.apache.lucene.utilByteBlockPoolnextBuffer

Javadoc

Advances the pool to its next buffer. This method should be called once after the constructor to initialize the pool. In contrast to the constructor a ByteBlockPool#reset() call will advance the pool to its first buffer immediately.

Popular methods of ByteBlockPool

  • <init>
  • reset
    Expert: Resets the pool to its initial state reusing the first buffer. Calling ByteBlockPool#nextBuf
  • 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.
  • readBytes
    Reads bytes bytes out of the pool starting at the given offset with the given length into the given
  • 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

  • Parsing JSON documents to java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • CodeWhisperer alternatives
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