当前位置: 首页>>代码示例>>C#>>正文


C# Lucene.Net.Store.IndexOutput.WriteVInt方法代码示例

本文整理汇总了C#中Lucene.Net.Store.IndexOutput.WriteVInt方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Store.IndexOutput.WriteVInt方法的具体用法?C# Lucene.Net.Store.IndexOutput.WriteVInt怎么用?C# Lucene.Net.Store.IndexOutput.WriteVInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Store.IndexOutput的用法示例。


在下文中一共展示了Lucene.Net.Store.IndexOutput.WriteVInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteDgaps

 /// <summary>Write as a d-gaps list </summary>
 private void WriteDgaps(IndexOutput output)
 {
     output.WriteInt(- 1); // mark using d-gaps
     output.WriteInt(Size()); // write size
     output.WriteInt(Count()); // write count
     int last = 0;
     int n = Count();
     int m = bits.Length;
     for (int i = 0; i < m && n > 0; i++)
     {
         if (bits[i] != 0)
         {
             output.WriteVInt(i - last);
             output.WriteByte(bits[i]);
             last = i;
             n -= BYTE_COUNTS[bits[i] & 0xFF];
         }
     }
 }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:20,代码来源:BitVector.cs

示例2: Write

		public void  Write(IndexOutput output)
		{
			output.WriteVInt(CURRENT_FORMAT);
			output.WriteVInt(Size());
			for (int i = 0; i < Size(); i++)
			{
				FieldInfo fi = FieldInfo(i);
				byte bits = (byte) (0x0);
				if (fi.isIndexed)
					bits |= IS_INDEXED;
				if (fi.storeTermVector)
					bits |= STORE_TERMVECTOR;
				if (fi.storePositionWithTermVector)
					bits |= STORE_POSITIONS_WITH_TERMVECTOR;
				if (fi.storeOffsetWithTermVector)
					bits |= STORE_OFFSET_WITH_TERMVECTOR;
				if (fi.omitNorms)
					bits |= OMIT_NORMS;
				if (fi.storePayloads)
					bits |= STORE_PAYLOADS;
				if (fi.omitTermFreqAndPositions)
					bits |= OMIT_TERM_FREQ_AND_POSITIONS;
				
				output.WriteString(fi.name);
				output.WriteByte(bits);
			}
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:27,代码来源:FieldInfos.cs

示例3: AppendPostings


//.........这里部分代码省略.........
                        if (termStates[i].docID < minState.docID)
                            minState = termStates[i];

                    int doc = minState.docID;
                    int termDocFreq = minState.termFreq;

                    System.Diagnostics.Debug.Assert(doc < flushState.numDocsInRAM);
                    System.Diagnostics.Debug.Assert(doc > lastDoc || df == 1);

                    ByteSliceReader prox = minState.prox;

                    // Carefully copy over the prox + payload info,
                    // changing the format to match Lucene's segment
                    // format.
                    if (!currentFieldOmitTf)
                    {
                        // omitTf == false so we do write positions & payload
                        System.Diagnostics.Debug.Assert(proxOut != null);
                        for (int j = 0; j < termDocFreq; j++)
                        {
                            int code = prox.ReadVInt();
                            if (currentFieldStorePayloads)
                            {
                                int payloadLength;
                                if ((code & 1) != 0)
                                {
                                    // This position has a payload
                                    payloadLength = prox.ReadVInt();
                                }
                                else
                                    payloadLength = 0;
                                if (payloadLength != lastPayloadLength)
                                {
                                    proxOut.WriteVInt(code | 1);
                                    proxOut.WriteVInt(payloadLength);
                                    lastPayloadLength = payloadLength;
                                }
                                else
                                    proxOut.WriteVInt(code & (~1));
                                if (payloadLength > 0)
                                    copyBytes(prox, proxOut, payloadLength);
                            }
                            else
                            {
                                System.Diagnostics.Debug.Assert(0 == (code & 1));
                                proxOut.WriteVInt(code >> 1);
                            }
                        } //End for

                        int newDocCode = (doc - lastDoc) << 1;

                        if (1 == termDocFreq)
                        {
                            freqOut.WriteVInt(newDocCode | 1);
                        }
                        else
                        {
                            freqOut.WriteVInt(newDocCode);
                            freqOut.WriteVInt(termDocFreq);
                        }
                    }
                    else
                    {
                        // omitTf==true: we store only the docs, without
                        // term freq, positions, payloads
                        freqOut.WriteVInt(doc - lastDoc);
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:67,代码来源:FreqProxTermsWriter.cs

示例4: WriteSkipData

        protected override void WriteSkipData(int level, IndexOutput skipBuffer)
        {
            // To efficiently store payloads/offsets in the posting lists we do not store the length of
            // every payload/offset. Instead we omit the length if the previous lengths were the same
            //
            // However, in order to support skipping, the length at every skip point must be known.
            // So we use the same length encoding that we use for the posting lists for the skip data as well:
            // Case 1: current field does not store payloads/offsets
            //           SkipDatum                 --> DocSkip, FreqSkip, ProxSkip
            //           DocSkip,FreqSkip,ProxSkip --> VInt
            //           DocSkip records the document number before every SkipInterval th  document in TermFreqs.
            //           Document numbers are represented as differences from the previous value in the sequence.
            // Case 2: current field stores payloads/offsets
            //           SkipDatum                 --> DocSkip, PayloadLength?,OffsetLength?,FreqSkip,ProxSkip
            //           DocSkip,FreqSkip,ProxSkip --> VInt
            //           PayloadLength,OffsetLength--> VInt
            //         In this case DocSkip/2 is the difference between
            //         the current and the previous value. If DocSkip
            //         is odd, then a PayloadLength encoded as VInt follows,
            //         if DocSkip is even, then it is assumed that the
            //         current payload/offset lengths equals the lengths at the previous
            //         skip point
            int delta = CurDoc - LastSkipDoc[level];

            if (CurStorePayloads || CurStoreOffsets)
            {
                Debug.Assert(CurStorePayloads || CurPayloadLength == LastSkipPayloadLength[level]);
                Debug.Assert(CurStoreOffsets || CurOffsetLength == LastSkipOffsetLength[level]);

                if (CurPayloadLength == LastSkipPayloadLength[level] && CurOffsetLength == LastSkipOffsetLength[level])
                {
                    // the current payload/offset lengths equals the lengths at the previous skip point,
                    // so we don't store the lengths again
                    skipBuffer.WriteVInt(delta << 1);
                }
                else
                {
                    // the payload and/or offset length is different from the previous one. We shift the DocSkip,
                    // set the lowest bit and store the current payload and/or offset lengths as VInts.
                    skipBuffer.WriteVInt(delta << 1 | 1);

                    if (CurStorePayloads)
                    {
                        skipBuffer.WriteVInt(CurPayloadLength);
                        LastSkipPayloadLength[level] = CurPayloadLength;
                    }
                    if (CurStoreOffsets)
                    {
                        skipBuffer.WriteVInt(CurOffsetLength);
                        LastSkipOffsetLength[level] = CurOffsetLength;
                    }
                }
            }
            else
            {
                // current field does not store payloads or offsets
                skipBuffer.WriteVInt(delta);
            }

            skipBuffer.WriteVInt((int)(CurFreqPointer - LastSkipFreqPointer[level]));
            skipBuffer.WriteVInt((int)(CurProxPointer - LastSkipProxPointer[level]));

            LastSkipDoc[level] = CurDoc;

            LastSkipFreqPointer[level] = CurFreqPointer;
            LastSkipProxPointer[level] = CurProxPointer;
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:67,代码来源:Lucene40SkipListWriter.cs

示例5: WriteSkipData

		protected internal override void  WriteSkipData(int level, IndexOutput skipBuffer)
		{
			// To efficiently store payloads in the posting lists we do not store the length of
			// every payload. Instead we omit the length for a payload if the previous payload had
			// the same length.
			// However, in order to support skipping the payload length at every skip point must be known.
			// So we use the same length encoding that we use for the posting lists for the skip data as well:
			// Case 1: current field does not store payloads
			//           SkipDatum                 --> DocSkip, FreqSkip, ProxSkip
			//           DocSkip,FreqSkip,ProxSkip --> VInt
			//           DocSkip records the document number before every SkipInterval th  document in TermFreqs. 
			//           Document numbers are represented as differences from the previous value in the sequence.
			// Case 2: current field stores payloads
			//           SkipDatum                 --> DocSkip, PayloadLength?, FreqSkip,ProxSkip
			//           DocSkip,FreqSkip,ProxSkip --> VInt
			//           PayloadLength             --> VInt    
			//         In this case DocSkip/2 is the difference between
			//         the current and the previous value. If DocSkip
			//         is odd, then a PayloadLength encoded as VInt follows,
			//         if DocSkip is even, then it is assumed that the
			//         current payload length equals the length at the previous
			//         skip point
			if (curStorePayloads)
			{
				int delta = curDoc - lastSkipDoc[level];
				if (curPayloadLength == lastSkipPayloadLength[level])
				{
					// the current payload length equals the length at the previous skip point,
					// so we don't store the length again
					skipBuffer.WriteVInt(delta * 2);
				}
				else
				{
					// the payload length is different from the previous one. We shift the DocSkip, 
					// set the lowest bit and store the current payload length as VInt.
					skipBuffer.WriteVInt(delta * 2 + 1);
					skipBuffer.WriteVInt(curPayloadLength);
					lastSkipPayloadLength[level] = curPayloadLength;
				}
			}
			else
			{
				// current field does not store payloads
				skipBuffer.WriteVInt(curDoc - lastSkipDoc[level]);
			}
			skipBuffer.WriteVInt((int) (curFreqPointer - lastSkipFreqPointer[level]));
			skipBuffer.WriteVInt((int) (curProxPointer - lastSkipProxPointer[level]));
			
			lastSkipDoc[level] = curDoc;
			//System.out.println("write doc at level " + level + ": " + curDoc);
			
			lastSkipFreqPointer[level] = curFreqPointer;
			lastSkipProxPointer[level] = curProxPointer;
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:54,代码来源:DefaultSkipListWriter.cs

示例6: CompressingStoredFieldsIndexWriter

 internal CompressingStoredFieldsIndexWriter(IndexOutput indexOutput)
 {
     this.FieldsIndexOut = indexOutput;
     Reset();
     TotalDocs = 0;
     DocBaseDeltas = new int[BLOCK_SIZE];
     StartPointerDeltas = new long[BLOCK_SIZE];
     FieldsIndexOut.WriteVInt(PackedInts.VERSION_CURRENT);
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:9,代码来源:CompressingStoredFieldsIndexWriter.cs

示例7: WriteSkipData

        protected internal override void WriteSkipData(int level, IndexOutput skipBuffer)
        {
            int delta = CurDoc - LastSkipDoc[level];
            // if (DEBUG) {
            //   System.out.println("writeSkipData level=" + level + " lastDoc=" + curDoc + " delta=" + delta + " curDocPointer=" + curDocPointer);
            // }
            skipBuffer.WriteVInt(delta);
            LastSkipDoc[level] = CurDoc;

            skipBuffer.WriteVInt((int)(CurDocPointer - LastSkipDocPointer[level]));
            LastSkipDocPointer[level] = CurDocPointer;

            if (FieldHasPositions)
            {
                // if (DEBUG) {
                //   System.out.println("  curPosPointer=" + curPosPointer + " curPosBufferUpto=" + curPosBufferUpto);
                // }
                skipBuffer.WriteVInt((int)(CurPosPointer - LastSkipPosPointer[level]));
                LastSkipPosPointer[level] = CurPosPointer;
                skipBuffer.WriteVInt(CurPosBufferUpto);

                if (FieldHasPayloads)
                {
                    skipBuffer.WriteVInt(CurPayloadByteUpto);
                }

                if (FieldHasOffsets || FieldHasPayloads)
                {
                    skipBuffer.WriteVInt((int)(CurPayPointer - LastSkipPayPointer[level]));
                    LastSkipPayPointer[level] = CurPayPointer;
                }
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:33,代码来源:Lucene41SkipWriter.cs

示例8: AppendPostings


//.........这里部分代码省略.........
					}
					
					FieldMergeState minState = termStates[0];
					for (int i = 1; i < numToMerge; i++)
						if (termStates[i].docID < minState.docID)
							minState = termStates[i];
					
					int doc = minState.docID;
					int termDocFreq = minState.termFreq;
					
					System.Diagnostics.Debug.Assert(doc < numDocsInRAM);
					System.Diagnostics.Debug.Assert(doc > lastDoc || df == 1);
					
					int newDocCode = (doc - lastDoc) << 1;
					lastDoc = doc;
					
					ByteSliceReader prox = minState.prox;
					
					// Carefully copy over the prox + payload info,
					// changing the format to match Lucene's segment
					// format.
					for (int j = 0; j < termDocFreq; j++)
					{
						int code = prox.ReadVInt();
						if (currentFieldStorePayloads)
						{
							int payloadLength;
							if ((code & 1) != 0)
							{
								// This position has a payload
								payloadLength = prox.ReadVInt();
							}
							else
								payloadLength = 0;
							if (payloadLength != lastPayloadLength)
							{
								proxOut.WriteVInt(code | 1);
								proxOut.WriteVInt(payloadLength);
								lastPayloadLength = payloadLength;
							}
							else
								proxOut.WriteVInt(code & (~ 1));
							if (payloadLength > 0)
								CopyBytes(prox, proxOut, payloadLength);
						}
						else
						{
							System.Diagnostics.Debug.Assert(0 ==(code & 1));
							proxOut.WriteVInt(code >> 1);
						}
					}
					
					if (1 == termDocFreq)
					{
						freqOut.WriteVInt(newDocCode | 1);
					}
					else
					{
						freqOut.WriteVInt(newDocCode);
						freqOut.WriteVInt(termDocFreq);
					}
					
					if (!minState.NextDoc())
					{
						
						// Remove from termStates
						int upto = 0;
						for (int i = 0; i < numToMerge; i++)
							if (termStates[i] != minState)
								termStates[upto++] = termStates[i];
						numToMerge--;
						System.Diagnostics.Debug.Assert(upto == numToMerge);
						
						// Advance this state to the next term
						
						if (!minState.NextTerm())
						{
							// OK, no more terms, so remove from mergeStates
							// as well
							upto = 0;
							for (int i = 0; i < numFields; i++)
								if (mergeStates[i] != minState)
									mergeStates[upto++] = mergeStates[i];
							numFields--;
							System.Diagnostics.Debug.Assert(upto == numFields);
						}
					}
				}
				
				System.Diagnostics.Debug.Assert(df > 0);
				
				// Done merging this term
				
				long skipPointer = skipListWriter.WriteSkip(freqOut);
				
				// Write term
				termInfo.Set(df, freqPointer, proxPointer, (int) (skipPointer - freqPointer));
				termsOut.Add(fieldNumber, text2, start, pos - start, termInfo);
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:101,代码来源:DocumentsWriter.cs

示例9: WriteClearedDgaps

 /// <summary>
 /// Write as a d-gaps list </summary>
 private void WriteClearedDgaps(IndexOutput output)
 {
     output.WriteInt(-1); // mark using d-gaps
     output.WriteInt(Size()); // write size
     output.WriteInt(Count()); // write count
     int last = 0;
     int numCleared = Size() - Count();
     for (int i = 0; i < Bits.Length && numCleared > 0; i++)
     {
         if (Bits[i] != unchecked((byte)0xff))
         {
             output.WriteVInt(i - last);
             output.WriteByte(Bits[i]);
             last = i;
             numCleared -= (8 - BitUtil.BitCount(Bits[i]));
             Debug.Assert(numCleared >= 0 || (i == (Bits.Length - 1) && numCleared == -(8 - (Size_Renamed & 7))));
         }
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:21,代码来源:BitVector.cs


注:本文中的Lucene.Net.Store.IndexOutput.WriteVInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。