本文整理汇总了C#中Lucene.Net.Index.FieldInfos类的典型用法代码示例。如果您正苦于以下问题:C# FieldInfos类的具体用法?C# FieldInfos怎么用?C# FieldInfos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldInfos类属于Lucene.Net.Index命名空间,在下文中一共展示了FieldInfos类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SegmentTermEnum
internal SegmentTermEnum(IndexInput i, FieldInfos fis, bool isi)
{
input = i;
fieldInfos = fis;
isIndex = isi;
maxSkipLevels = 1; // use single-level skip lists for formats > -3
int firstInt = input.ReadInt();
if (firstInt >= 0)
{
// original-format file, without explicit format version number
format = 0;
size = firstInt;
// back-compatible settings
indexInterval = 128;
skipInterval = System.Int32.MaxValue; // switch off skipTo optimization
}
else
{
// we have a format version number
format = firstInt;
// check that it is a format we can understand
if (format < TermInfosWriter.FORMAT_CURRENT)
throw new CorruptIndexException("Unknown format version:" + format + " expected " + TermInfosWriter.FORMAT_CURRENT + " or higher");
size = input.ReadLong(); // read the size
if (format == - 1)
{
if (!isIndex)
{
indexInterval = input.ReadInt();
formatM1SkipInterval = input.ReadInt();
}
// switch off skipTo optimization for file format prior to 1.4rc2 in order to avoid a bug in
// skipTo implementation of these versions
skipInterval = System.Int32.MaxValue;
}
else
{
indexInterval = input.ReadInt();
skipInterval = input.ReadInt();
if (format <= TermInfosWriter.FORMAT)
{
// this new format introduces multi-level skipping
maxSkipLevels = input.ReadInt();
}
}
System.Diagnostics.Debug.Assert(indexInterval > 0, "indexInterval=" + indexInterval + " is negative; must be > 0");
System.Diagnostics.Debug.Assert(skipInterval > 0, "skipInterval=" + skipInterval + " is negative; must be > 0");
}
if (format > TermInfosWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
{
termBuffer.SetPreUTF8Strings();
scanBuffer.SetPreUTF8Strings();
prevBuffer.SetPreUTF8Strings();
}
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:60,代码来源:SegmentTermEnum.cs
示例2: Read
public void Read(IndexInput input, FieldInfos fieldInfos)
{
this.term = null; // invalidate cache
int start = input.ReadVInt();
int length = input.ReadVInt();
int totalLength = start + length;
if (preUTF8Strings)
{
text.SetLength(totalLength);
input.ReadChars(text.result, start, length);
}
else
{
if (dirty)
{
// Fully convert all bytes since bytes is dirty
UnicodeUtil.UTF16toUTF8(text.result, 0, text.length, bytes);
bytes.SetLength(totalLength);
input.ReadBytes(bytes.result, start, length);
UnicodeUtil.UTF8toUTF16(bytes.result, 0, totalLength, text);
dirty = false;
}
else
{
// Incrementally convert only the UTF8 bytes that are new:
bytes.SetLength(totalLength);
input.ReadBytes(bytes.result, start, length);
UnicodeUtil.UTF8toUTF16(bytes.result, start, length, text);
}
}
this.field = fieldInfos.FieldName(input.ReadVInt());
}
开发者ID:sinsay,项目名称:SSE,代码行数:33,代码来源:TermBuffer.cs
示例3: TermInfosReader
internal TermInfosReader(Directory dir, System.String seg, FieldInfos fis, int readBufferSize)
{
bool success = false;
try
{
directory = dir;
segment = seg;
fieldInfos = fis;
origEnum = new SegmentTermEnum(directory.OpenInput(segment + "." + IndexFileNames.TERMS_EXTENSION, readBufferSize), fieldInfos, false);
size = origEnum.size;
totalIndexInterval = origEnum.indexInterval;
indexEnum = new SegmentTermEnum(directory.OpenInput(segment + "." + IndexFileNames.TERMS_INDEX_EXTENSION, readBufferSize), fieldInfos, true);
success = true;
}
finally
{
// With lock-less commits, it's entirely possible (and
// fine) to hit a FileNotFound exception above. In
// this case, we want to explicitly close any subset
// of things that were opened so that we don't have to
// wait for a GC to do so.
if (!success)
{
Close();
}
}
}
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:31,代码来源:TermInfosReader.cs
示例4: FieldsWriter
internal FieldsWriter(IndexOutput fdx, IndexOutput fdt, FieldInfos fn)
{
fieldInfos = fn;
fieldsStream = fdt;
indexStream = fdx;
doClose = false;
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:7,代码来源:FieldsWriter.cs
示例5: FieldsReader
/*internal*/
public FieldsReader(Directory d, System.String segment, FieldInfos fn)
{
fieldInfos = fn;
fieldsStream = d.OpenInput(segment + ".fdt");
indexStream = d.OpenInput(segment + ".fdx");
size = (int) (indexStream.Length() / 8);
}
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:10,代码来源:FieldsReader.cs
示例6: SegmentReadState
/// <summary>
/// Create a {@code SegmentReadState}. </summary>
public SegmentReadState(Directory dir, SegmentInfo info, FieldInfos fieldInfos, IOContext context, int termsIndexDivisor, string segmentSuffix)
{
this.Directory = dir;
this.SegmentInfo = info;
this.FieldInfos = fieldInfos;
this.Context = context;
this.TermsIndexDivisor = termsIndexDivisor;
this.SegmentSuffix = segmentSuffix;
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:11,代码来源:SegmentReadState.cs
示例7: CompressingTermVectorsReader
/// <summary>
/// Sole constructor. </summary>
public CompressingTermVectorsReader(Directory d, SegmentInfo si, string segmentSuffix, FieldInfos fn, IOContext context, string formatName, CompressionMode compressionMode)
{
this.compressionMode = compressionMode;
string segment = si.Name;
bool success = false;
fieldInfos = fn;
numDocs = si.DocCount;
ChecksumIndexInput indexStream = null;
try
{
// Load the index into memory
string indexStreamFN = IndexFileNames.SegmentFileName(segment, segmentSuffix, CompressingTermVectorsWriter.VECTORS_INDEX_EXTENSION);
indexStream = d.OpenChecksumInput(indexStreamFN, context);
string codecNameIdx = formatName + CompressingTermVectorsWriter.CODEC_SFX_IDX;
version = CodecUtil.CheckHeader(indexStream, codecNameIdx, CompressingTermVectorsWriter.VERSION_START, CompressingTermVectorsWriter.VERSION_CURRENT);
Debug.Assert(CodecUtil.HeaderLength(codecNameIdx) == indexStream.FilePointer);
indexReader = new CompressingStoredFieldsIndexReader(indexStream, si);
if (version >= CompressingTermVectorsWriter.VERSION_CHECKSUM)
{
indexStream.ReadVLong(); // the end of the data file
CodecUtil.CheckFooter(indexStream);
}
else
{
CodecUtil.CheckEOF(indexStream);
}
indexStream.Dispose();
indexStream = null;
// Open the data file and read metadata
string vectorsStreamFN = IndexFileNames.SegmentFileName(segment, segmentSuffix, CompressingTermVectorsWriter.VECTORS_EXTENSION);
vectorsStream = d.OpenInput(vectorsStreamFN, context);
string codecNameDat = formatName + CompressingTermVectorsWriter.CODEC_SFX_DAT;
int version2 = CodecUtil.CheckHeader(vectorsStream, codecNameDat, CompressingTermVectorsWriter.VERSION_START, CompressingTermVectorsWriter.VERSION_CURRENT);
if (version != version2)
{
throw new Exception("Version mismatch between stored fields index and data: " + version + " != " + version2);
}
Debug.Assert(CodecUtil.HeaderLength(codecNameDat) == vectorsStream.FilePointer);
packedIntsVersion = vectorsStream.ReadVInt();
chunkSize = vectorsStream.ReadVInt();
decompressor = compressionMode.NewDecompressor();
this.reader = new BlockPackedReaderIterator(vectorsStream, packedIntsVersion, CompressingTermVectorsWriter.BLOCK_SIZE, 0);
success = true;
}
finally
{
if (!success)
{
IOUtils.CloseWhileHandlingException(this, indexStream);
}
}
}
开发者ID:joyanta,项目名称:lucene.net,代码行数:58,代码来源:CompressingTermVectorsReader.cs
示例8: Read
public void Read(IndexInput input, FieldInfos fieldInfos)
{
this.term = null; // invalidate cache
int start = input.ReadVInt();
int length = input.ReadVInt();
int totalLength = start + length;
SetTextLength(totalLength);
input.ReadChars(this.text, start, length);
this.field = fieldInfos.FieldName(input.ReadVInt());
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:10,代码来源:TermBuffer.cs
示例9: AddDocument
public void AddDocument(System.String segment, Document doc)
{
// write field names
fieldInfos = new FieldInfos();
fieldInfos.Add(doc);
fieldInfos.Write(directory, segment + ".fnm");
// write field values
FieldsWriter fieldsWriter = new FieldsWriter(directory, segment, fieldInfos);
try
{
fieldsWriter.AddDocument(doc);
}
finally
{
fieldsWriter.Close();
}
// invert doc into postingTable
postingTable.Clear(); // clear postingTable
fieldLengths = new int[fieldInfos.Size()]; // init fieldLengths
fieldPositions = new int[fieldInfos.Size()]; // init fieldPositions
fieldOffsets = new int[fieldInfos.Size()]; // init fieldOffsets
fieldBoosts = new float[fieldInfos.Size()]; // init fieldBoosts
float boost = doc.GetBoost();
for (int i = 0; i < fieldBoosts.Length; i++)
{
fieldBoosts[i] = boost;
}
InvertDocument(doc);
// sort postingTable into an array
Posting[] postings = SortPostingTable();
/*
for (int i = 0; i < postings.length; i++) {
Posting posting = postings[i];
System.out.print(posting.term);
System.out.print(" freq=" + posting.freq);
System.out.print(" pos=");
System.out.print(posting.positions[0]);
for (int j = 1; j < posting.freq; j++)
System.out.print("," + posting.positions[j]);
System.out.println("");
}
*/
// write postings
WritePostings(postings, segment);
// write norms of indexed fields
WriteNorms(segment);
}
开发者ID:zweib730,项目名称:beagrep,代码行数:55,代码来源:DocumentWriter.cs
示例10: TermInfosReader
public /*internal*/ TermInfosReader(Directory dir, System.String seg, FieldInfos fis)
{
directory = dir;
segment = seg;
fieldInfos = fis;
origEnum = new SegmentTermEnum(directory.OpenInput(segment + ".tis"), fieldInfos, false);
size = origEnum.size;
indexEnum = new SegmentTermEnum(directory.OpenInput(segment + ".tii"), fieldInfos, true);
}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:11,代码来源:TermInfosReader.cs
示例11: Initialize
private void Initialize(Directory directory, System.String segment, FieldInfos fis, int interval, bool isi)
{
indexInterval = interval;
fieldInfos = fis;
isIndex = isi;
output = directory.CreateOutput(segment + (isIndex ? ".tii" : ".tis"));
output.WriteInt(FORMAT); // write format
output.WriteLong(0); // leave space for size
output.WriteInt(indexInterval); // write indexInterval
output.WriteInt(skipInterval); // write skipInterval
}
开发者ID:zweib730,项目名称:beagrep,代码行数:11,代码来源:TermInfosWriter.cs
示例12: Clone
/// <summary> Returns a deep clone of this FieldInfos instance.</summary>
public System.Object Clone()
{
FieldInfos fis = new FieldInfos();
int numField = byNumber.Count;
for (int i = 0; i < numField; i++)
{
FieldInfo fi = (FieldInfo) ((FieldInfo) byNumber[i]).Clone();
fis.byNumber.Add(fi);
fis.byName[fi.name] = fi;
}
return fis;
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:13,代码来源:FieldInfos.cs
示例13: SetUp
public override void SetUp()
{
base.SetUp();
fieldInfos = new FieldInfos();
DocHelper.SetupDoc(testDoc);
fieldInfos.Add(testDoc);
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
writer.SetUseCompoundFile(false);
writer.AddDocument(testDoc);
writer.Close();
segmentName = writer.NewestSegment().name;
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:12,代码来源:TestFieldsReader.cs
示例14: TermVectorsWriter
public TermVectorsWriter(Directory directory, System.String segment, FieldInfos fieldInfos)
{
// Open files for TermVector storage
tvx = directory.CreateOutput(segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
tvx.WriteInt(TermVectorsReader.FORMAT_CURRENT);
tvd = directory.CreateOutput(segment + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
tvd.WriteInt(TermVectorsReader.FORMAT_CURRENT);
tvf = directory.CreateOutput(segment + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
tvf.WriteInt(TermVectorsReader.FORMAT_CURRENT);
this.fieldInfos = fieldInfos;
}
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:12,代码来源:TermVectorsWriter.cs
示例15: FieldsReader
// Used only by clone
private FieldsReader(FieldInfos fieldInfos, int numTotalDocs, int size, int format, int formatSize, int docStoreOffset, IndexInput cloneableFieldsStream, IndexInput cloneableIndexStream)
{
this.fieldInfos = fieldInfos;
this.numTotalDocs = numTotalDocs;
this.size = size;
this.format = format;
this.formatSize = formatSize;
this.docStoreOffset = docStoreOffset;
this.cloneableFieldsStream = cloneableFieldsStream;
this.cloneableIndexStream = cloneableIndexStream;
fieldsStream = (IndexInput) cloneableFieldsStream.Clone();
indexStream = (IndexInput) cloneableIndexStream.Clone();
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:14,代码来源:FieldsReader.cs
示例16: TermVectorsWriter
public TermVectorsWriter(Directory directory, System.String segment, FieldInfos fieldInfos)
{
// Open files for TermVector storage
tvx = directory.CreateOutput(segment + TVX_EXTENSION);
tvx.WriteInt(FORMAT_VERSION);
tvd = directory.CreateOutput(segment + TVD_EXTENSION);
tvd.WriteInt(FORMAT_VERSION);
tvf = directory.CreateOutput(segment + TVF_EXTENSION);
tvf.WriteInt(FORMAT_VERSION);
this.fieldInfos = fieldInfos;
fields = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(fieldInfos.Size()));
terms = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
}
开发者ID:karino2,项目名称:wikipediaconv,代码行数:14,代码来源:TermVectorsWriter.cs
示例17: TermVectorsReader
/*internal*/
public TermVectorsReader(Directory d, System.String segment, FieldInfos fieldInfos)
{
if (d.FileExists(segment + TermVectorsWriter.TVX_EXTENSION))
{
tvx = d.OpenInput(segment + TermVectorsWriter.TVX_EXTENSION);
CheckValidFormat(tvx);
tvd = d.OpenInput(segment + TermVectorsWriter.TVD_EXTENSION);
tvdFormat = CheckValidFormat(tvd);
tvf = d.OpenInput(segment + TermVectorsWriter.TVF_EXTENSION);
tvfFormat = CheckValidFormat(tvf);
size = (int) tvx.Length() / 8;
}
this.fieldInfos = fieldInfos;
}
开发者ID:kiichi7,项目名称:Search-Engine,代码行数:16,代码来源:TermVectorsReader.cs
示例18: CompressingStoredFieldsReader
// used by clone
private CompressingStoredFieldsReader(CompressingStoredFieldsReader reader)
{
this.Version_Renamed = reader.Version_Renamed;
this.FieldInfos = reader.FieldInfos;
this.FieldsStream = (IndexInput)reader.FieldsStream.Clone();
this.IndexReader = (CompressingStoredFieldsIndexReader)reader.IndexReader.Clone();
this.MaxPointer = reader.MaxPointer;
this.ChunkSize_Renamed = reader.ChunkSize_Renamed;
this.PackedIntsVersion = reader.PackedIntsVersion;
this.CompressionMode_Renamed = reader.CompressionMode_Renamed;
this.Decompressor = (Decompressor)reader.Decompressor.Clone();
this.NumDocs = reader.NumDocs;
this.Bytes = new BytesRef(reader.Bytes.Bytes.Length);
this.Closed = false;
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:16,代码来源:CompressingStoredFieldsReader.cs
示例19: Test
public virtual void Test()
{
//Positive test of FieldInfos
Assert.IsTrue(testDoc != null);
FieldInfos fieldInfos = new FieldInfos();
fieldInfos.Add(testDoc);
//Since the complement is stored as well in the fields map
Assert.IsTrue(fieldInfos.Size() == DocHelper.all.Count); //this is all b/c we are using the no-arg constructor
RAMDirectory dir = new RAMDirectory();
System.String name = "testFile";
IndexOutput output = dir.CreateOutput(name);
Assert.IsTrue(output != null);
//Use a RAMOutputStream
try
{
fieldInfos.Write(output);
output.Close();
Assert.IsTrue(output.Length() > 0);
FieldInfos readIn = new FieldInfos(dir, name);
Assert.IsTrue(fieldInfos.Size() == readIn.Size());
FieldInfo info = readIn.FieldInfo("textField1");
Assert.IsTrue(info != null);
Assert.IsTrue(info.storeTermVector_ForNUnit == false);
Assert.IsTrue(info.omitNorms_ForNUnit == false);
info = readIn.FieldInfo("textField2");
Assert.IsTrue(info != null);
Assert.IsTrue(info.storeTermVector_ForNUnit == true);
Assert.IsTrue(info.omitNorms_ForNUnit == false);
info = readIn.FieldInfo("textField3");
Assert.IsTrue(info != null);
Assert.IsTrue(info.storeTermVector_ForNUnit == false);
Assert.IsTrue(info.omitNorms_ForNUnit == true);
info = readIn.FieldInfo("omitNorms");
Assert.IsTrue(info != null);
Assert.IsTrue(info.storeTermVector_ForNUnit == false);
Assert.IsTrue(info.omitNorms_ForNUnit == true);
dir.Close();
}
catch (System.IO.IOException e)
{
Assert.IsTrue(false);
}
}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:48,代码来源:TestFieldInfos.cs
示例20: SetUp
protected virtual void SetUp()
{
fieldInfos = new FieldInfos();
DocHelper.SetupDoc(testDoc);
fieldInfos.Add(testDoc);
DocumentWriter writer = new DocumentWriter(dir, new WhitespaceAnalyzer(), Similarity.GetDefault(), 50);
Assert.IsTrue(writer != null);
try
{
writer.AddDocument("test", testDoc);
}
catch (System.IO.IOException e)
{
}
}
开发者ID:runefs,项目名称:Marvin,代码行数:16,代码来源:TestFieldsReader.cs
注:本文中的Lucene.Net.Index.FieldInfos类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论