/** {@inheritDoc} */ @Override public int length() { BytesRef prefix = getPrefix(); if (prefix == null) { return 0; } return prefix.utf8ToString().length(); }
@SuppressWarnings("unused") static String brToString(BytesRef b) { try { return b.utf8ToString() + " " + b; } catch (Throwable t) { // If BytesRef isn't actually UTF8, or it's eg a // prefix of UTF8 that ends mid-unicode-char, we // fallback to hex: return b.toString(); } }
String brToString(BytesRef b) { if (b == null) { return "null"; } else { try { return b.utf8ToString() + " " + b; } catch (Throwable t) { // If BytesRef isn't actually UTF8, or it's eg a // prefix of UTF8 that ends mid-unicode-char, we // fallback to hex: return b.toString(); } } }
@SuppressWarnings("unused") static String brToString(BytesRef b) { if (b == null) { return "(null)"; } else { try { return b.utf8ToString() + " " + b; } catch (Throwable t) { // If BytesRef isn't actually UTF8, or it's eg a // prefix of UTF8 that ends mid-unicode-char, we // fallback to hex: return b.toString(); } } }
@Override public Object toObject() { assert exists || 0 == value.length(); return exists ? value.get().utf8ToString() : null; }
public void listTokens(int freq) throws IOException { IndexReader ireader = null; TermsEnum iter = null; Terms terms; try { ireader = DirectoryReader.open(indexDirectory); int numDocs = ireader.numDocs(); if (numDocs > 0) { Fields uFields = MultiFields.getFields(ireader);//reader.getTermVectors(0); terms = uFields.terms(QueryBuilder.DEFS); iter = terms.iterator(); // init uid iterator } while (iter != null && iter.term() != null) { //if (iter.term().field().startsWith("f")) { if (iter.docFreq() > 16 && iter.term().utf8ToString().length() > freq) { LOGGER.warning(iter.term().utf8ToString()); } BytesRef next = iter.next(); if (next==null) {iter=null;} } } finally { if (ireader != null) { try { ireader.close(); } catch (IOException e) { LOGGER.log(Level.WARNING, "An error occurred while closing index reader", e); } } } }
files.add(Util.uid2url(iter.term().utf8ToString())); BytesRef next = iter.next(); if (next == null) {
queue.insertWithOverflow(new LookupResultItem(term.utf8ToString(), project, score));
/** * Remove a stale file (uidIter.term().text()) from the index database and * history cache, and queue the removal of xref. * * @param removeHistory if false, do not remove history cache for this file * @throws java.io.IOException if an error occurs */ private void removeFile(boolean removeHistory) throws IOException { String path = Util.uid2url(uidIter.term().utf8ToString()); for (IndexChangedListener listener : listeners) { listener.fileRemove(path); } writer.deleteDocuments(new Term(QueryBuilder.U, uidIter.term())); removeXrefFile(path); if (removeHistory) { removeHistoryFile(path); } setDirty(); for (IndexChangedListener listener : listeners) { listener.fileRemoved(path); } }
@Override public Object valueForDisplay(Object value) { if (value == null) { return null; } // keywords are internally stored as utf8 bytes BytesRef binaryValue = (BytesRef) value; return binaryValue.utf8ToString(); }
String termPath = Util.uid2url(uidIter.term().utf8ToString()); removeFile(!termPath.equals(path));
&& uidIter.term().utf8ToString().startsWith(startuid)) {
while ( (termsRef = termsEnum.next()) != null ) sampler.include( termsRef.utf8ToString(), termsEnum.docFreq() ); checkCancellation();
@Override public Number getKeyAsNumber() { // this method is needed for scripted numeric aggregations return Double.parseDouble(termBytes.utf8ToString()); }
@Override public String getKeyAsString() { String keyAsString = super.getKeyAsString(); if (keyAsString != null) { return keyAsString; } if (key != null) { return key.utf8ToString(); } return null; }
@Override public String getKeyAsString() { String keyAsString = super.getKeyAsString(); if (keyAsString != null) { return keyAsString; } return key.utf8ToString(); }
/** * Interprets the referenced bytes as UTF8 bytes, returning the resulting string */ public String utf8ToString() { return toBytesRef().utf8ToString(); }
@Test void shouldBuildRangeSeekByStringQueryForStrings() { // given TermRangeQuery query = (TermRangeQuery) LuceneDocumentStructure .newRangeSeekByStringQuery( "foo", false, null, true ); // then assertEquals( "string", query.getField() ); assertEquals( "foo", query.getLowerTerm().utf8ToString() ); assertFalse( query.includesLower() ); assertNull( query.getUpperTerm() ); assertTrue( query.includesUpper() ); }
final String utf16 = termUTF8.utf8ToString(); termUnicode = new int[utf16.codePointCount(0, utf16.length())]; termLen = termUnicode.length;
assert savedStartTerm == null || term.compareTo(savedStartTerm) > 0: "saveStartTerm=" + savedStartTerm.utf8ToString() + " term=" + term.utf8ToString(); return term; } else {