internal void WriteProx(FreqProxTermsWriter.PostingList p, int proxCode) { Payload payload; if (payloadAttribute == null) { payload = null; } else { payload = payloadAttribute.Payload; } if (payload != null && payload.internalLength > 0) { termsHashPerField.WriteVInt(1, (proxCode << 1) | 1); termsHashPerField.WriteVInt(1, payload.internalLength); termsHashPerField.WriteBytes(1, payload.data, payload.internalOffset, payload.internalLength); hasPayloads = true; } else { termsHashPerField.WriteVInt(1, proxCode << 1); } p.lastPosition = fieldState.position; }
internal bool NextTerm(IState state) { postingUpto++; if (postingUpto == numPostings) { return(false); } p = (FreqProxTermsWriter.PostingList)postings[postingUpto]; docID = 0; text = charPool.buffers[p.textStart >> DocumentsWriter.CHAR_BLOCK_SHIFT]; textOffset = p.textStart & DocumentsWriter.CHAR_BLOCK_MASK; field.termsHashPerField.InitReader(freq, p, 0); if (!field.fieldInfo.omitTermFreqAndPositions) { field.termsHashPerField.InitReader(prox, p, 1); } // Should always be true bool result = NextDoc(state); System.Diagnostics.Debug.Assert(result); return(true); }
internal override void AddTerm(RawPostingList p0) { System.Diagnostics.Debug.Assert(docState.TestPoint("FreqProxTermsWriterPerField.addTerm start")); FreqProxTermsWriter.PostingList p = (FreqProxTermsWriter.PostingList)p0; System.Diagnostics.Debug.Assert(omitTermFreqAndPositions || p.docFreq > 0); if (omitTermFreqAndPositions) { if (docState.docID != p.lastDocID) { System.Diagnostics.Debug.Assert(docState.docID > p.lastDocID); termsHashPerField.WriteVInt(0, p.lastDocCode); p.lastDocCode = docState.docID - p.lastDocID; p.lastDocID = docState.docID; } } else { if (docState.docID != p.lastDocID) { System.Diagnostics.Debug.Assert(docState.docID > p.lastDocID); // Term not yet seen in the current doc but previously // seen in other doc(s) since the last flush // Now that we know doc freq for previous doc, // write it & lastDocCode if (1 == p.docFreq) { termsHashPerField.WriteVInt(0, p.lastDocCode | 1); } else { termsHashPerField.WriteVInt(0, p.lastDocCode); termsHashPerField.WriteVInt(0, p.docFreq); } p.docFreq = 1; p.lastDocCode = (docState.docID - p.lastDocID) << 1; p.lastDocID = docState.docID; WriteProx(p, fieldState.position); } else { p.docFreq++; WriteProx(p, fieldState.position - p.lastPosition); } } }
internal void writeProx(Token t, FreqProxTermsWriter.PostingList p, int proxCode) { Payload payload = t.GetPayload(); if (payload != null && payload.length > 0) { termsHashPerField.writeVInt(1, (proxCode << 1) | 1); termsHashPerField.writeVInt(1, payload.length); termsHashPerField.writeBytes(1, payload.data, payload.offset, payload.length); hasPayloads = true; } else { termsHashPerField.writeVInt(1, proxCode << 1); } p.lastPosition = fieldState.position; }
internal override void NewTerm(RawPostingList p0) { // First time we're seeing this term since the last // flush System.Diagnostics.Debug.Assert(docState.TestPoint("FreqProxTermsWriterPerField.newTerm start")); FreqProxTermsWriter.PostingList p = (FreqProxTermsWriter.PostingList)p0; p.lastDocID = docState.docID; if (omitTermFreqAndPositions) { p.lastDocCode = docState.docID; } else { p.lastDocCode = docState.docID << 1; p.docFreq = 1; WriteProx(p, fieldState.position); } }
internal bool NextTerm() { postingUpto++; if (postingUpto == numPostings) return false; p = (FreqProxTermsWriter.PostingList) postings[postingUpto]; docID = 0; text = charPool.buffers[p.textStart >> DocumentsWriter.CHAR_BLOCK_SHIFT]; textOffset = p.textStart & DocumentsWriter.CHAR_BLOCK_MASK; field.termsHashPerField.InitReader(freq, p, 0); if (!field.fieldInfo.omitTermFreqAndPositions) field.termsHashPerField.InitReader(prox, p, 1); // Should always be true bool result = NextDoc(); System.Diagnostics.Debug.Assert(result); return true; }