本文整理汇总了C#中Lucene.Net.Index.RawPostingList类的典型用法代码示例。如果您正苦于以下问题:C# RawPostingList类的具体用法?C# RawPostingList怎么用?C# RawPostingList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RawPostingList类属于Lucene.Net.Index命名空间,在下文中一共展示了RawPostingList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTerm
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);
}
}
}
示例2: getPostings
public void getPostings(RawPostingList[] postings)
{
lock (this)
{
System.Diagnostics.Debug.Assert(docWriter.writer.TestPoint("TermsHash.getPostings start"));
System.Diagnostics.Debug.Assert(postingsFreeCount <= postingsFreeList.Length);
System.Diagnostics.Debug.Assert(postingsFreeCount <= postingsAllocCount, "postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount);
int numToCopy;
if (postingsFreeCount < postings.Length)
numToCopy = postingsFreeCount;
else
numToCopy = postings.Length;
int start = postingsFreeCount - numToCopy;
System.Diagnostics.Debug.Assert(start >= 0);
System.Diagnostics.Debug.Assert(start + numToCopy <= postingsFreeList.Length);
System.Diagnostics.Debug.Assert(numToCopy <= postings.Length);
System.Array.Copy(postingsFreeList, start, postings, 0, numToCopy);
// Directly allocate the remainder if any
if (numToCopy != postings.Length)
{
int extra = postings.Length - numToCopy;
int newPostingsAllocCount = postingsAllocCount + extra;
consumer.createPostings(postings, numToCopy, extra);
System.Diagnostics.Debug.Assert(docWriter.writer.TestPoint("TermsHash.getPostings after create"));
postingsAllocCount += extra;
if (trackAllocations)
docWriter.BytesAllocated(extra * bytesPerPosting);
if (newPostingsAllocCount > postingsFreeList.Length)
// Pre-allocate the postingsFreeList so it's large
// enough to hold all postings we've given out
postingsFreeList = new RawPostingList[ArrayUtil.GetNextSize(newPostingsAllocCount)];
}
postingsFreeCount -= numToCopy;
if (trackAllocations)
docWriter.BytesUsed(postings.Length * bytesPerPosting);
}
}
示例3: addTerm
internal override void addTerm(Token t, RawPostingList p0)
{
System.Diagnostics.Debug.Assert(docState.TestPoint("TermVectorsTermsWriterPerField.addTerm start"));
TermVectorsTermsWriter.PostingList p = (TermVectorsTermsWriter.PostingList)p0;
p.freq++;
if (doVectorOffsets)
{
int startOffset = fieldState.offset + t.StartOffset();
int endOffset = fieldState.offset + t.EndOffset();
termsHashPerField.writeVInt(1, startOffset - p.lastOffset);
termsHashPerField.writeVInt(1, endOffset - startOffset);
p.lastOffset = endOffset;
}
if (doVectorPositions)
{
termsHashPerField.writeVInt(0, fieldState.position - p.lastPosition);
p.lastPosition = fieldState.position;
}
}
示例4: CreatePostings
internal abstract void CreatePostings(RawPostingList[] postings, int start, int count);
示例5: ShrinkFreePostings
internal void ShrinkFreePostings(IDictionary<InvertedDocConsumerPerThread, IList<InvertedDocConsumerPerField>> threadsAndFields, SegmentWriteState state)
{
System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, "Thread.currentThread().getName()" + ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount + " consumer=" + consumer);
int newSize = 1;
if (newSize != postingsFreeList.Length)
{
if (postingsFreeCount > newSize)
{
if (trackAllocations)
{
docWriter.BytesAllocated(-(postingsFreeCount - newSize) * bytesPerPosting);
}
postingsFreeCount = newSize;
postingsAllocCount = newSize;
}
RawPostingList[] newArray = new RawPostingList[newSize];
Array.Copy(postingsFreeList, 0, newArray, 0, postingsFreeCount);
postingsFreeList = newArray;
}
}
示例6: RehashPostings
/// <summary>Called when postings hash is too small (> 50%
/// occupied) or too large (< 20% occupied).
/// </summary>
internal void RehashPostings(int newSize)
{
int newMask = newSize - 1;
RawPostingList[] newHash = new RawPostingList[newSize];
for (int i = 0; i < postingsHashSize; i++)
{
RawPostingList p0 = postingsHash[i];
if (p0 != null)
{
int code;
if (perThread.primary)
{
int start = p0.textStart & DocumentsWriter.CHAR_BLOCK_MASK;
char[] text = charPool.buffers[p0.textStart >> DocumentsWriter.CHAR_BLOCK_SHIFT];
int pos = start;
while (text[pos] != 0xffff)
pos++;
code = 0;
while (pos > start)
code = (code * 31) + text[--pos];
}
else
code = p0.textStart;
int hashPos = code & newMask;
System.Diagnostics.Debug.Assert(hashPos >= 0);
if (newHash[hashPos] != null)
{
int inc = ((code >> 8) + code) | 1;
do
{
code += inc;
hashPos = code & newMask;
}
while (newHash[hashPos] != null);
}
newHash[hashPos] = p0;
}
}
postingsHashMask = newMask;
postingsHash = newHash;
postingsHashSize = newSize;
postingsHashHalfSize = newSize >> 1;
}
示例7: quickSort
void quickSort(RawPostingList[] postings, int lo, int hi)
{
if (lo >= hi)
return;
else if (hi == 1 + lo)
{
if (comparePostings(postings[lo], postings[hi]) > 0)
{
RawPostingList tmp = postings[lo];
postings[lo] = postings[hi];
postings[hi] = tmp;
}
return;
}
int mid = (int)((uint)(lo + hi) >> 1);
if (comparePostings(postings[lo], postings[mid]) > 0)
{
RawPostingList tmp = postings[lo];
postings[lo] = postings[mid];
postings[mid] = tmp;
}
if (comparePostings(postings[mid], postings[hi]) > 0)
{
RawPostingList tmp = postings[mid];
postings[mid] = postings[hi];
postings[hi] = tmp;
if (comparePostings(postings[lo], postings[mid]) > 0)
{
RawPostingList tmp2 = postings[lo];
postings[lo] = postings[mid];
postings[mid] = tmp2;
}
}
int left = lo + 1;
int right = hi - 1;
if (left >= right)
return;
RawPostingList partition = postings[mid];
for (; ; )
{
while (comparePostings(postings[right], partition) > 0)
--right;
while (left < right && comparePostings(postings[left], partition) <= 0)
++left;
if (left < right)
{
RawPostingList tmp = postings[left];
postings[left] = postings[right];
postings[right] = tmp;
--right;
}
else
{
break;
}
}
quickSort(postings, lo, left);
quickSort(postings, left + 1, hi);
}
示例8: ShrinkFreePostings
internal void ShrinkFreePostings(System.Collections.IDictionary threadsAndFields, SegmentWriteState state)
{
System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, "Thread.currentThread().getName()" + ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount + " consumer=" + consumer);
int newSize = ArrayUtil.GetShrinkSize(postingsFreeList.Length, postingsAllocCount);
if (newSize != postingsFreeList.Length)
{
RawPostingList[] newArray = new RawPostingList[newSize];
Array.Copy(postingsFreeList, 0, newArray, 0, postingsFreeCount);
postingsFreeList = newArray;
}
}
示例9: AddTerm
internal abstract void AddTerm(RawPostingList p);
示例10: QuickSort
internal void QuickSort(RawPostingList[] postings, int lo, int hi)
{
if (lo >= hi)
return ;
else if (hi == 1 + lo)
{
if (ComparePostings(postings[lo], postings[hi]) > 0)
{
RawPostingList tmp = postings[lo];
postings[lo] = postings[hi];
postings[hi] = tmp;
}
return ;
}
int mid = Number.URShift((lo + hi), 1);
if (ComparePostings(postings[lo], postings[mid]) > 0)
{
RawPostingList tmp = postings[lo];
postings[lo] = postings[mid];
postings[mid] = tmp;
}
if (ComparePostings(postings[mid], postings[hi]) > 0)
{
RawPostingList tmp = postings[mid];
postings[mid] = postings[hi];
postings[hi] = tmp;
if (ComparePostings(postings[lo], postings[mid]) > 0)
{
RawPostingList tmp2 = postings[lo];
postings[lo] = postings[mid];
postings[mid] = tmp2;
}
}
int left = lo + 1;
int right = hi - 1;
if (left >= right)
return ;
RawPostingList partition = postings[mid];
for (; ; )
{
while (ComparePostings(postings[right], partition) > 0)
--right;
while (left < right && ComparePostings(postings[left], partition) <= 0)
++left;
if (left < right)
{
RawPostingList tmp = postings[left];
postings[left] = postings[right];
postings[right] = tmp;
--right;
}
else
{
break;
}
}
QuickSort(postings, lo, left);
QuickSort(postings, left + 1, hi);
}
示例11: InitReader
public void InitReader(ByteSliceReader reader, RawPostingList p, int stream)
{
System.Diagnostics.Debug.Assert(stream < streamCount);
int[] ints = intPool.buffers[p.intStart >> DocumentsWriter.INT_BLOCK_SHIFT];
int upto = p.intStart & DocumentsWriter.INT_BLOCK_MASK;
reader.Init(bytePool, p.byteStart + stream * ByteBlockPool.FIRST_LEVEL_SIZE, ints[upto + stream]);
}
示例12: noNullPostings
private static bool noNullPostings(RawPostingList[] postings, int count, System.String details)
{
for (int i = 0; i < count; i++)
System.Diagnostics.Debug.Assert(postings[i] != null, "postings[" + i + "] of " + count + " is null: " + details);
return true;
}
示例13: shrinkFreePostings
internal void shrinkFreePostings(IDictionary<object, ICollection<object>> threadsAndFields, DocumentsWriter.FlushState state)
{
System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, System.Threading.Thread.CurrentThread.Name + ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount + " consumer=" + consumer);
int newSize = ArrayUtil.GetShrinkSize(postingsFreeList.Length, postingsAllocCount);
if (newSize != postingsFreeList.Length)
{
RawPostingList[] newArray = new RawPostingList[newSize];
System.Array.Copy(postingsFreeList, 0, newArray, 0, postingsFreeCount);
postingsFreeList = newArray;
}
}
示例14: newTerm
internal abstract void newTerm(Token t, RawPostingList p);
示例15: NewTerm
internal override void NewTerm(RawPostingList p0)
{
System.Diagnostics.Debug.Assert(docState.TestPoint("TermVectorsTermsWriterPerField.newTerm start"));
TermVectorsTermsWriter.PostingList p = (TermVectorsTermsWriter.PostingList) p0;
p.freq = 1;
if (doVectorOffsets)
{
int startOffset = fieldState.offset + offsetAttribute.StartOffset; ;
int endOffset = fieldState.offset + offsetAttribute.EndOffset;
termsHashPerField.WriteVInt(1, startOffset);
termsHashPerField.WriteVInt(1, endOffset - startOffset);
p.lastOffset = endOffset;
}
if (doVectorPositions)
{
termsHashPerField.WriteVInt(0, fieldState.position);
p.lastPosition = fieldState.position;
}
}