/** * Replace the content of this buffer with UTF-8 encoded bytes that would * represent the provided text. */ public void copyChars(CharSequence text) { copyChars(text, 0, text.length()); }
@Override public BytesRef getBytesRef() { builder.copyChars(termBuffer, 0, termLength); return builder.get(); }
public static BytesRef toBytesRef(Object value, BytesRefBuilder spare) { if (value == null) { return null; } if (value instanceof BytesRef) { return (BytesRef) value; } spare.copyChars(value.toString()); return spare.get(); } }
protected BytesRef fillBytesRef(BytesRefBuilder spare) { spare.copyChars(charTermAttr); return spare.get(); }
private void set(int i, Object o) { if (o == null) { values[i].clear(); } else { CollectionUtils.ensureNoSelfReferences(o); values[i].copyChars(o.toString()); } }
public static byte[] toUTF8Bytes(CharSequence charSequence, BytesRefBuilder spare) { spare.copyChars(charSequence); return Arrays.copyOf(spare.bytes(), spare.length()); }
/** * Adds an input string and its stemmer override output to this builder. * * @param input the input char sequence * @param output the stemmer override output char sequence * @return <code>false</code> iff the input has already been added to this builder otherwise <code>true</code>. */ public boolean add(CharSequence input, CharSequence output) { final int length = input.length(); if (ignoreCase) { // convert on the fly to lowercase charsSpare.grow(length); final char[] buffer = charsSpare.chars(); for (int i = 0; i < length; ) { i += Character.toChars( Character.toLowerCase( Character.codePointAt(input, i)), buffer, i); } spare.copyChars(buffer, 0, length); } else { spare.copyChars(input, 0, length); } if (hash.add(spare.get()) >= 0) { outputValues.add(output); return true; } return false; }
@Override public boolean advanceExact(int docID) throws IOException { if (toStringValues.advanceExact(docID) == false) { return false; } list.clear(); toStringValues.get(list); count = list.size(); grow(); for (int i = 0; i < count; ++i) { final CharSequence s = list.get(i); values[i].copyChars(s); } sort(); return true; }
public static BytesRef[] createUidsForTypesAndIds(Collection<String> types, Collection<?> ids) { BytesRef[] uids = new BytesRef[types.size() * ids.size()]; BytesRefBuilder typeBytes = new BytesRefBuilder(); BytesRefBuilder idBytes = new BytesRefBuilder(); int index = 0; for (String type : types) { typeBytes.copyChars(type); for (Object id : ids) { uids[index++] = Uid.createUidAsBytes(typeBytes.get(), BytesRefs.toBytesRef(id, idBytes)); } } return uids; }
utf8Scratch.copyChars(output.chars, output.offset, output.length);
b = new BytesRef((CharBuffer) o); } else { builder.copyChars(o.toString()); b = builder.get();
private static Query parseQueryString(ExtendedCommonTermsQuery query, Object queryString, String field, Analyzer analyzer, String lowFreqMinimumShouldMatch, String highFreqMinimumShouldMatch) throws IOException { // Logic similar to QueryParser#getFieldQuery try (TokenStream source = analyzer.tokenStream(field, queryString.toString())) { source.reset(); CharTermAttribute termAtt = source.addAttribute(CharTermAttribute.class); BytesRefBuilder builder = new BytesRefBuilder(); while (source.incrementToken()) { // UTF-8 builder.copyChars(termAtt); query.add(new Term(field, builder.toBytesRef())); } } query.setLowFreqMinimumNumberShouldMatch(lowFreqMinimumShouldMatch); query.setHighFreqMinimumNumberShouldMatch(highFreqMinimumShouldMatch); return query; }
@Override public boolean advanceExact(int doc) throws IOException { if (bytesValues.advanceExact(doc)) { count = bytesValues.docValueCount(); grow(); for (int i = 0; i < count; ++i) { final BytesRef value = bytesValues.nextValue(); script.setNextAggregationValue(value.utf8ToString()); Object run = script.run(); CollectionUtils.ensureNoSelfReferences(run); values[i].copyChars(run.toString()); } sort(); return true; } else { count = 0; grow(); return false; } } }
public void writeText(Text text) throws IOException { if (!text.hasBytes()) { final String string = text.string(); spare.copyChars(string); writeInt(spare.length()); write(spare.bytes(), 0, spare.length()); } else { BytesReference bytes = text.bytes(); writeInt(bytes.length()); bytes.writeTo(this); } }
/** * Replace the content of this buffer with UTF-8 encoded bytes that would * represent the provided text. */ public void copyChars(CharSequence text) { copyChars(text, 0, text.length()); }
previous.copyChars(termAtt); BytesRef bytes = previous.get(); if (inDocTerms.add(bytes) >= 0) {
public static BytesRef toBytesRef(Object value, BytesRefBuilder spare) { if (value == null) { return null; } if (value instanceof BytesRef) { return (BytesRef) value; } spare.copyChars(value.toString()); return spare.get(); } }
@Override public void setDocument(int docID) { list.clear(); toStringValues.get(docID, list); count = list.size(); grow(); for (int i = 0; i < count; ++i) { final CharSequence s = list.get(i); values[i].copyChars(s); } sort(); }
public void writeText(Text text) throws IOException { if (!text.hasBytes()) { final String string = text.string(); spare.copyChars(string); writeInt(spare.length()); write(spare.bytes(), 0, spare.length()); } else { BytesReference bytes = text.bytes(); writeInt(bytes.length()); bytes.writeTo(this); } }
public void writeText(Text text) throws IOException { if (!text.hasBytes()) { final String string = text.string(); spare.copyChars(string); writeInt(spare.length()); write(spare.bytes(), 0, spare.length()); } else { BytesReference bytes = text.bytes(); writeInt(bytes.length()); bytes.writeTo(this); } }