Java Code Examples for org.apache.lucene.util.BytesRefBuilder#clear()
The following examples show how to use
org.apache.lucene.util.BytesRefBuilder#clear() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuggestUtils.java From Elasticsearch with Apache License 2.0 | 5 votes |
public static BytesRef join(BytesRef separator, BytesRefBuilder result, BytesRef... toJoin) { result.clear(); for (int i = 0; i < toJoin.length - 1; i++) { result.append(toJoin[i]); result.append(separator); } result.append(toJoin[toJoin.length-1]); return result.get(); }
Example 2
Source File: DocTermsIndexDocValues.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public boolean bytesVal(int doc, BytesRefBuilder target) throws IOException { target.clear(); if (getOrdForDoc(doc) == -1) { return false; } else { target.copyBytes(termsIndex.binaryValue()); return true; } }
Example 3
Source File: FunctionValues.java From lucene-solr with Apache License 2.0 | 5 votes |
/** returns the bytes representation of the string val - TODO: should this return the indexed raw bytes not? */ public boolean bytesVal(int doc, BytesRefBuilder target) throws IOException { String s = strVal(doc); if (s==null) { target.clear(); return false; } target.copyChars(s); return true; }
Example 4
Source File: UTF8TaxonomyWriterCache.java From lucene-solr with Apache License 2.0 | 5 votes |
private BytesRef toBytes(FacetLabel label) { BytesRefBuilder bytes = this.bytes.get(); bytes.clear(); for (int i = 0; i < label.length; i++) { String part = label.components[i]; if (i > 0) { bytes.append(DELIM_CHAR); } bytes.grow(bytes.length() + UnicodeUtil.maxUTF8Length(part.length())); bytes.setLength(UnicodeUtil.UTF16toUTF8(part, 0, part.length(), bytes.bytes(), bytes.length())); } return bytes.get(); }
Example 5
Source File: Dictionary.java From lucene-solr with Apache License 2.0 | 5 votes |
static void encodeFlags(BytesRefBuilder b, char flags[]) { int len = flags.length << 1; b.grow(len); b.clear(); for (int i = 0; i < flags.length; i++) { int flag = flags[i]; b.append((byte) ((flag >> 8) & 0xff)); b.append((byte) (flag & 0xff)); } }