Tabnine Logo
BytesRefBuilder.setLength
Code IndexAdd Tabnine to your IDE (free)

How to use
setLength
method
in
org.apache.lucene.util.BytesRefBuilder

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

origin: org.apache.lucene/lucene-core

/**
 * Reset this builder to the empty state.
 */
public void clear() {
 setLength(0);
}
origin: org.apache.lucene/lucene-core

 private void fillTerm() {
  final int termLength = prefix + suffix;
  ste.term.setLength(termLength);
  ste.term.grow(termLength);
  System.arraycopy(suffixBytes, startBytePos, ste.term.bytes(), prefix, suffix);
 }
}
origin: org.apache.lucene/lucene-core

@Override
protected void setPivot(int i) {
 pivot.setLength(0);
 for (int o = k; o < maxLength; ++o) {
  final int b = byteAt(i, o);
  if (b == -1) {
   break;
  }
  pivot.append((byte) b);
 }
}
origin: org.apache.lucene/lucene-core

@Override
protected void setPivot(int i) {
 pivot.setLength(0);
 for (int o = d; o < maxLength; ++o) {
  final int b = byteAt(i, o);
  if (b == -1) {
   break;
  }
  pivot.append((byte) b);
 }
}
origin: org.apache.lucene/lucene-core

 /**
  * Attempts to backtrack thru the string after encountering a dead end
  * at some given position. Returns false if no more possible strings 
  * can match.
  * 
  * @param position current position in the input String
  * @return {@code position >= 0} if more possible solutions exist for the DFA
  */
 private int backtrack(int position) {
  while (position-- > 0) {
   int nextChar = seekBytesRef.byteAt(position) & 0xff;
   // if a character is 0xff it's a dead-end too,
   // because there is no higher character in binary sort order.
   if (nextChar++ != 0xff) {
    seekBytesRef.setByteAt(position, (byte) nextChar);
    seekBytesRef.setLength(position+1);
    return position;
   }
  }
  return -1; /* all solutions exhausted */
 }
}
origin: org.apache.lucene/lucene-core

@Override
public int nextDoc() throws IOException {
 int docID = docsWithField.nextDoc();
 if (docID != NO_MORE_DOCS) {
  int length = Math.toIntExact(lengthsIterator.next());
  value.setLength(length);
  bytesIterator.readBytes(value.bytes(), 0, length);
 }
 return docID;
}
origin: org.apache.lucene/lucene-core

private void readTermBytes(int prefix, int suffix) throws IOException {
 builder.grow(prefix + suffix);
 input.readBytes(builder.bytes(), prefix, suffix);
 builder.setLength(prefix + suffix);
}
origin: org.apache.lucene/lucene-core

/** Just converts IntsRef to BytesRef; you must ensure the
 *  int values fit into a byte. */
public static BytesRef toBytesRef(IntsRef input, BytesRefBuilder scratch) {
 scratch.grow(input.length);
 for(int i=0;i<input.length;i++) {
  int value = input.ints[i+input.offset];
  // NOTE: we allow -128 to 255
  assert value >= Byte.MIN_VALUE && value <= 255: "value " + value + " doesn't fit into byte";
  scratch.setByteAt(i, (byte) value);
 }
 scratch.setLength(input.length);
 return scratch.get();
}
origin: org.apache.lucene/lucene-core

public void nextLeaf() {
 //if (DEBUG) System.out.println("  frame.next ord=" + ord + " nextEnt=" + nextEnt + " entCount=" + entCount);
 assert nextEnt != -1 && nextEnt < entCount: "nextEnt=" + nextEnt + " entCount=" + entCount + " fp=" + fp;
 nextEnt++;
 suffix = suffixesReader.readVInt();
 startBytePos = suffixesReader.getPosition();
 ste.term.setLength(prefix + suffix);
 ste.term.grow(ste.term.length());
 suffixesReader.readBytes(ste.term.bytes(), prefix, suffix);
 ste.termExists = true;
}
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.lucene/lucene-core

/**
 * Reads the next entry into the provided {@link BytesRef}. The internal
 * storage is resized if needed.
 * 
 * @return Returns <code>false</code> if EOF occurred when trying to read
 * the header of the next sequence. Returns <code>true</code> otherwise.
 * @throws EOFException if the file ends before the full sequence is read.
 */
public BytesRef next() throws IOException {
 if (in.getFilePointer() >= end) {
  return null;
 }
 short length = in.readShort();
 ref.grow(length);
 ref.setLength(length);
 in.readBytes(ref.bytes(), 0, length);
 return ref.get();
}
origin: org.apache.lucene/lucene-core

output.setLength(input.length);
if (numTransitions == 0) {
 assert runAutomaton.isAccept(state);
 output.setLength(idx);
   output.setLength(idx);
origin: org.apache.lucene/lucene-core

@Override
public int nextPosition() throws IOException {
 assert posLeft > 0;
 posLeft--;
 int code = posReader.readVInt();
 pos += code >>> 1;
 if ((code & 1) != 0) {
  hasPayload = true;
  // has a payload
  payload.setLength(posReader.readVInt());
  payload.grow(payload.length());
  posReader.readBytes(payload.bytes(), 0, payload.length());
 } else {
  hasPayload = false;
 }
 if (readOffsets) {
  startOffset += posReader.readVInt();
  endOffset = startOffset + posReader.readVInt();
 }
 return pos;
}
origin: org.apache.lucene/lucene-core

suffix = code >>> 1;
startBytePos = suffixesReader.getPosition();
ste.term.setLength(prefix + suffix);
ste.term.grow(ste.term.length());
suffixesReader.readBytes(ste.term.bytes(), prefix, suffix);
origin: org.apache.lucene/lucene-core

   scratch.setLength(scratch.length() - 1);
   return scratch.get();
scratch.setLength(scratch.length() + 1);
scratch.grow(scratch.length());
origin: org.apache.lucene/lucene-core

 payload.setLength(payloadLength);
 thisPayload = payload.get();
} else {
origin: org.apache.lucene/lucene-core

term.setLength(idx);
origin: org.apache.lucene/lucene-core

seekBytesRef.setLength(position);
visited[state] = curGen;
origin: org.apache.lucene/lucene-core

  termExists = false;
  term.setByteAt(targetUpto, (byte) targetLabel);
  term.setLength(1+targetUpto);
term.setLength(targetUpto);
origin: org.elasticsearch/elasticsearch

/**
 * Computes a strong hash value for small files. Note that this method should only be used for files &lt; 1MB
 */
public static void hashFile(BytesRefBuilder fileHash, InputStream in, long size) throws IOException {
  final int len = (int) Math.min(1024 * 1024, size); // for safety we limit this to 1MB
  fileHash.grow(len);
  fileHash.setLength(len);
  final int readBytes = Streams.readFully(in, fileHash.bytes(), 0, len);
  assert readBytes == len : Integer.toString(readBytes) + " != " + Integer.toString(len);
  assert fileHash.length() == len : Integer.toString(fileHash.length()) + " != " + Integer.toString(len);
}
org.apache.lucene.utilBytesRefBuildersetLength

Javadoc

Set the length.

Popular methods of BytesRefBuilder

  • <init>
    Sole constructor.
  • get
    Return a BytesRef that points to the internal content of this builder. Any update to the content of
  • toBytesRef
    Build a new BytesRef that has the same content as this buffer.
  • append
    Append the provided bytes to this builder.
  • copyBytes
    Replace the content of this builder with the provided bytes. Equivalent to calling #clear() and then
  • bytes
    Return a reference to the bytes of this builder.
  • grow
    Ensure that this builder can hold at least capacity bytes without resizing.
  • length
    Return the number of bytes in this buffer.
  • clear
    Reset this builder to the empty state.
  • copyChars
    Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.
  • setByteAt
    Set a byte.
  • byteAt
    Return the byte at the given offset.
  • setByteAt,
  • byteAt,
  • equals

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • getResourceAsStream (ClassLoader)
  • setContentView (Activity)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Path (java.nio.file)
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • 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