本文整理汇总了C#中Lucene.Net.Index.SegmentInfos.GetVersion方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentInfos.GetVersion方法的具体用法?C# SegmentInfos.GetVersion怎么用?C# SegmentInfos.GetVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentInfos
的用法示例。
在下文中一共展示了SegmentInfos.GetVersion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadCurrentVersion
/// <summary> Current version number from segments file.</summary>
public static long ReadCurrentVersion(Directory directory)
{
IndexInput input = directory.OpenInput(IndexFileNames.SEGMENTS);
int format = 0;
long version = 0;
try
{
format = input.ReadInt();
if (format < 0)
{
if (format < FORMAT)
throw new System.IO.IOException("Unknown format version: " + format);
version = input.ReadLong(); // read version
}
}
finally
{
input.Close();
}
if (format < 0)
return version;
// We cannot be sure about the format of the file.
// Therefore we have to read the whole file and cannot simply seek to the version entry.
SegmentInfos sis = new SegmentInfos();
sis.Read(directory);
return sis.GetVersion();
}
示例2: DoBody
protected internal override object DoBody(System.String segmentFileName)
{
IndexInput input = directory.OpenInput(segmentFileName);
int format = 0;
long version = 0;
try
{
format = input.ReadInt();
if (format < 0)
{
if (format < Lucene.Net.Index.SegmentInfos.CURRENT_FORMAT)
throw new CorruptIndexException("Unknown format version: " + format);
version = input.ReadLong(); // read version
}
}
finally
{
input.Close();
}
if (format < 0)
return (long) version;
// We cannot be sure about the format of the file.
// Therefore we have to read the whole file and cannot simply seek to the version entry.
SegmentInfos sis = new SegmentInfos();
sis.Read(directory, segmentFileName);
return (long) sis.GetVersion();
}
示例3: CommitPoint
public CommitPoint(IndexFileDeleter enclosingInstance, System.Collections.ICollection commitsToDelete, Directory directory, SegmentInfos segmentInfos)
{
InitBlock(enclosingInstance);
this.directory = directory;
this.commitsToDelete = commitsToDelete;
userData = segmentInfos.GetUserData();
segmentsFileName = segmentInfos.GetCurrentSegmentFileName();
version = segmentInfos.GetVersion();
generation = segmentInfos.GetGeneration();
files = segmentInfos.Files(directory, true);
gen = segmentInfos.GetGeneration();
isOptimized = segmentInfos.Count == 1 && !segmentInfos.Info(0).HasDeletions();
System.Diagnostics.Debug.Assert(!segmentInfos.HasExternalSegments(directory));
}
示例4: ReaderCommit
internal ReaderCommit(SegmentInfos infos, Directory dir)
{
segmentsFileName = infos.GetCurrentSegmentFileName();
this.dir = dir;
int size = infos.Count;
files = new List<string>(size);
files.Add(segmentsFileName);
for (int i = 0; i < size; i++)
{
SegmentInfo info = infos.Info(i);
if (info.dir == dir)
SupportClass.CollectionsSupport.AddAll(info.Files(), files);
}
version = infos.GetVersion();
generation = infos.GetGeneration();
isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions();
}
示例5: ReaderCommit
internal ReaderCommit(SegmentInfos infos, Directory dir)
{
segmentsFileName = infos.GetCurrentSegmentFileName();
this.dir = dir;
userData = infos.GetUserData();
files = infos.Files(dir, true);
version = infos.GetVersion();
generation = infos.GetGeneration();
isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions();
}
示例6: CommitPoint
public CommitPoint(IndexFileDeleter enclosingInstance, ICollection<IndexCommitPoint> commitsToDelete, Directory directory, SegmentInfos segmentInfos)
{
InitBlock(enclosingInstance);
this.directory = directory;
this.commitsToDelete = commitsToDelete;
segmentsFileName = segmentInfos.GetCurrentSegmentFileName();
version = segmentInfos.GetVersion();
generation = segmentInfos.GetGeneration();
int size = segmentInfos.Count;
files = new List<string>(size);
files.Add(segmentsFileName);
gen = segmentInfos.GetGeneration();
for (int i = 0; i < size; i++)
{
SegmentInfo segmentInfo = segmentInfos.Info(i);
if (segmentInfo.dir == Enclosing_Instance.directory)
{
SupportClass.CollectionsSupport.AddAll(segmentInfo.Files(), files);
}
}
isOptimized = segmentInfos.Count == 1 && !segmentInfos.Info(0).HasDeletions();
}