@Override public void copyTo(AttributeImpl target) { BytesTermAttributeImpl other = (BytesTermAttributeImpl) target; other.bytes = bytes == null ? null : BytesRef.deepCopyOf(bytes); }
/** Constructs a Term with the given field and bytes. * <p>Note that a null field or null bytes value results in undefined * behavior for most Lucene APIs that accept a Term parameter. * * <p>The provided BytesRef is copied when it is non null. */ public Term(String fld, BytesRef bytes) { field = fld; this.bytes = bytes == null ? null : BytesRef.deepCopyOf(bytes); }
private boolean setSavedStartTerm(BytesRef startTerm) { savedStartTerm = startTerm == null ? null : BytesRef.deepCopyOf(startTerm); return true; }
/** * Gets an integer id for a given term and saves the position increment if needed. */ private int getTermID(int incr, int prevIncr, BytesRef term) { assert term != null; boolean isStackedGap = incr == 0 && prevIncr > 1; int id = idToTerm.size(); idToTerm.put(id, BytesRef.deepCopyOf(term)); // stacked token should have the same increment as original token at this position if (isStackedGap) { idToInc.put(id, prevIncr); } else if (incr > 1) { idToInc.put(id, incr); } return id; }
@Override public PayloadAttributeImpl clone() { PayloadAttributeImpl clone = (PayloadAttributeImpl) super.clone(); if (payload != null) { clone.payload = BytesRef.deepCopyOf(payload); } return clone; }
@Override public void copyTo(AttributeImpl target) { PayloadAttribute t = (PayloadAttribute) target; t.setPayload((payload == null) ? null : BytesRef.deepCopyOf(payload)); }
TermAndState(String field, TermsEnum termsEnum) throws IOException { this.field = field; this.termsEnum = termsEnum; this.term = BytesRef.deepCopyOf(termsEnum.term()); this.state = termsEnum.termState(); this.docFreq = termsEnum.docFreq(); this.totalTermFreq = termsEnum.totalTermFreq(); } }
+ this + " and input \"" + text + "\""); final BytesRef term = BytesRef.deepCopyOf(termAtt.getBytesRef()); if (ts.incrementToken()) { throw new IllegalStateException("The normalization token stream is "
/** Try to collect terms from the given terms enum and return true iff all * terms could be collected. If {@code false} is returned, the enum is * left positioned on the next term. */ private boolean collectTerms(LeafReaderContext context, TermsEnum termsEnum, List<TermAndState> terms) throws IOException { final int threshold = Math.min(BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD, BooleanQuery.getMaxClauseCount()); for (int i = 0; i < threshold; ++i) { final BytesRef term = termsEnum.next(); if (term == null) { return true; } TermState state = termsEnum.termState(); terms.add(new TermAndState(BytesRef.deepCopyOf(term), state, termsEnum.docFreq(), termsEnum.totalTermFreq())); } return termsEnum.next() == null; }
@Override public Query rewrite(IndexReader reader) throws IOException { final int threshold = Math.min(BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD, BooleanQuery.getMaxClauseCount()); if (termData.size() <= threshold) { BooleanQuery.Builder bq = new BooleanQuery.Builder(); TermIterator iterator = termData.iterator(); for (BytesRef term = iterator.next(); term != null; term = iterator.next()) { bq.add(new TermQuery(new Term(iterator.field(), BytesRef.deepCopyOf(term))), Occur.SHOULD); } return new ConstantScoreQuery(bq.build()); } return super.rewrite(reader); }
lastValue = BytesRef.deepCopyOf(term);
termBounds.add(BytesRef.deepCopyOf(term)); lastTermAdded = termCount; if (termBounds.size() == 5) {
private SortingLeafReader.CachedBinaryDVs sortDocValues(int maxDoc, Sorter.DocMap sortMap, BinaryDocValues oldValues) throws IOException { FixedBitSet docsWithField = new FixedBitSet(maxDoc); BytesRef[] values = new BytesRef[maxDoc]; while (true) { int docID = oldValues.nextDoc(); if (docID == NO_MORE_DOCS) { break; } int newDocID = sortMap.oldToNew(docID); docsWithField.set(newDocID); values[newDocID] = BytesRef.deepCopyOf(oldValues.binaryValue()); } return new SortingLeafReader.CachedBinaryDVs(values, docsWithField); }
lastValue = BytesRef.deepCopyOf(term);
@Override public BinaryDocValues getBinaryDocValues(String field) throws IOException { final BinaryDocValues oldDocValues = in.getBinaryDocValues(field); if (oldDocValues == null) return null; CachedBinaryDVs dvs; synchronized (cachedBinaryDVs) { dvs = cachedBinaryDVs.get(field); if (dvs == null) { FixedBitSet docsWithField = new FixedBitSet(maxDoc()); BytesRef[] values = new BytesRef[maxDoc()]; while (true) { int docID = oldDocValues.nextDoc(); if (docID == NO_MORE_DOCS) { break; } int newDocID = docMap.oldToNew(docID); docsWithField.set(newDocID); values[newDocID] = BytesRef.deepCopyOf(oldDocValues.binaryValue()); } dvs = new CachedBinaryDVs(values, docsWithField); cachedBinaryDVs.put(field, dvs); } } return new SortingBinaryDocValues(dvs); }
queuedBottom = BytesRef.deepCopyOf(term);
if (bb != null) { assert bb.isValid(); minTerm = BytesRef.deepCopyOf(bb); } else { minTerm = null; if (bb != null) { assert bb.isValid(); maxTerm = BytesRef.deepCopyOf(bb); if (minTerm == null) { throw new RuntimeException("field \"" + field + "\" has null minTerm but non-null maxTerm"); throw new RuntimeException("seek to ord " + ord + " returned ord " + actualOrd); seekTerms[i] = BytesRef.deepCopyOf(termsEnum.term());
/** * Returns a compact array from the given BytesReference. The returned array won't be copied unless necessary. If you need * to modify the returned array use {@code BytesRef.deepCopyOf(reference.toBytesRef()} instead */ public static byte[] toBytes(BytesReference reference) { final BytesRef bytesRef = reference.toBytesRef(); if (bytesRef.offset == 0 && bytesRef.length == bytesRef.bytes.length) { return bytesRef.bytes; } return BytesRef.deepCopyOf(bytesRef).bytes; }
@Override public BytesRef copyValue() { BytesRef value = currentValue(); if (value == null) { return null; } else { return BytesRef.deepCopyOf(value); } }
@Override public void nextToken() { Term term = new Term(field, BytesRef.deepCopyOf(fillBytesRef(new BytesRefBuilder()))); result.add(new Token(term, offsetAttr.startOffset(), offsetAttr.endOffset())); } }, spare);