本文整理汇总了C#中Lucene.Net.Index.IndexReader.GetSequentialSubReaders方法的典型用法代码示例。如果您正苦于以下问题:C# IndexReader.GetSequentialSubReaders方法的具体用法?C# IndexReader.GetSequentialSubReaders怎么用?C# IndexReader.GetSequentialSubReaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.IndexReader
的用法示例。
在下文中一共展示了IndexReader.GetSequentialSubReaders方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFilters
public static IDictionary<string, Filter> CreateFilters(IndexReader reader, IDictionary<string, HashSet<string>> feeds)
{
var bitSetLookup = new Dictionary<string, IDictionary<string, OpenBitSet>>(StringComparer.OrdinalIgnoreCase);
foreach (var key in feeds.Keys)
{
bitSetLookup[key] = new Dictionary<string, OpenBitSet>();
foreach (SegmentReader segmentReader in reader.GetSequentialSubReaders())
{
bitSetLookup[key][segmentReader.SegmentName] = new OpenBitSet();
}
}
foreach (SegmentReader segmentReader in reader.GetSequentialSubReaders())
{
CreateOpenBitSets(segmentReader, feeds, bitSetLookup);
}
var filters = new Dictionary<string, Filter>(StringComparer.OrdinalIgnoreCase);
foreach (var key in feeds.Keys)
{
filters[key] = new OpenBitSetLookupFilter(bitSetLookup[key]);
}
return filters;
}
示例2: Process
public void Process(IndexReader indexReader)
{
var perIndexDocumentNumber = 0;
foreach (var handler in _handlers)
{
handler.Begin(indexReader);
}
if (_enumerateSubReaders && indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
ProcessReader(segmentReader, segmentReader.SegmentName, ref perIndexDocumentNumber);
}
}
else
{
ProcessReader(indexReader, string.Empty, ref perIndexDocumentNumber);
}
foreach (var handler in _handlers)
{
handler.End(indexReader);
}
}
示例3: Create
public static Filter Create(IndexReader indexReader, bool includePrerelease, bool includeUnlisted)
{
IDictionary<string, OpenBitSet> openBitSetLookup = new Dictionary<string, OpenBitSet>();
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
openBitSetLookup.Add(segmentReader.SegmentName, new OpenBitSet());
}
}
else
{
openBitSetLookup.Add(string.Empty, new OpenBitSet());
}
IDictionary<string, Tuple<NuGetVersion, string, int>> lookup = MakeLatestVersionLookup(indexReader, includePrerelease, includeUnlisted);
foreach (Tuple<NuGetVersion, string, int> entry in lookup.Values)
{
string readerName = entry.Item2;
int readerDocumentId = entry.Item3;
openBitSetLookup[readerName].Set(readerDocumentId);
}
return new OpenBitSetLookupFilter(openBitSetLookup);
}
示例4: Begin
public void Begin(IndexReader indexReader)
{
_bitSetLookup = new Dictionary<string, IDictionary<string, OpenBitSet>>(StringComparer.OrdinalIgnoreCase);
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (var key in _feeds.Keys)
{
_bitSetLookup[key] = new Dictionary<string, OpenBitSet>();
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
_bitSetLookup[key][segmentReader.SegmentName] = new OpenBitSet();
}
}
}
else
{
foreach (var key in _feeds.Keys)
{
_bitSetLookup[key] = new Dictionary<string, OpenBitSet>();
_bitSetLookup[key][string.Empty] = new OpenBitSet();
}
}
}
示例5: Begin
public void Begin(IndexReader indexReader)
{
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
_mapping[segmentReader.SegmentName] = new int[segmentReader.MaxDoc];
}
}
else
{
_mapping[string.Empty] = new int[indexReader.MaxDoc];
}
}
示例6: Begin
public void Begin(IndexReader indexReader)
{
_rankingBySegmentReaderName = new RankingBySegment();
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
_rankingBySegmentReaderName[segmentReader.SegmentName] = new Ranking[segmentReader.MaxDoc];
}
}
else
{
_rankingBySegmentReaderName[string.Empty] = new Ranking[indexReader.MaxDoc];
}
}
示例7: Begin
public void Begin(IndexReader indexReader)
{
_openBitSetLookup = new Dictionary<string, OpenBitSet>();
_lookup = new Dictionary<string, Tuple<NuGetVersion, string, int>>();
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
_openBitSetLookup.Add(segmentReader.SegmentName, new OpenBitSet());
}
}
else
{
_openBitSetLookup.Add(string.Empty, new OpenBitSet());
}
}
示例8: Begin
public void Begin(IndexReader indexReader)
{
_knownOwners = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
_ownerTuples = new Dictionary<string, IDictionary<string, DynamicDocIdSet>>();
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
_ownerTuples.Add(segmentReader.SegmentName, new Dictionary<string, DynamicDocIdSet>(StringComparer.OrdinalIgnoreCase));
}
}
else
{
_ownerTuples.Add(string.Empty, new Dictionary<string, DynamicDocIdSet>(StringComparer.OrdinalIgnoreCase));
}
}
示例9: MakeLatestVersionLookup
static IDictionary<string, Tuple<NuGetVersion, string, int>> MakeLatestVersionLookup(IndexReader indexReader, bool includePrerelease, bool includeUnlisted)
{
IDictionary<string, Tuple<NuGetVersion, string, int>> lookup = new Dictionary<string, Tuple<NuGetVersion, string, int>>();
if (indexReader.GetSequentialSubReaders() != null)
{
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
MakeLatestVersionLookupPerReader(lookup, segmentReader, segmentReader.SegmentName, includePrerelease, includeUnlisted);
}
}
else
{
MakeLatestVersionLookupPerReader(lookup, indexReader, string.Empty, includePrerelease, includeUnlisted);
}
return lookup;
}
示例10: MakeLatestVersionLookup
static IDictionary<string, Tuple<NuGetVersion, string, int>> MakeLatestVersionLookup(IndexReader indexReader, bool includePrerelease, bool includeUnlisted)
{
IDictionary<string, Tuple<NuGetVersion, string, int>> lookup = new Dictionary<string, Tuple<NuGetVersion, string, int>>();
foreach (SegmentReader segmentReader in indexReader.GetSequentialSubReaders())
{
for (int n = 0; n < segmentReader.MaxDoc; n++)
{
if (segmentReader.IsDeleted(n))
{
continue;
}
Document document = segmentReader.Document(n);
NuGetVersion version = GetVersion(document);
if (version == null)
{
continue;
}
bool isListed = GetListed(document);
if (isListed || includeUnlisted)
{
if (!version.IsPrerelease || includePrerelease)
{
string id = GetId(document);
if (id == null)
{
continue;
}
Tuple<NuGetVersion, string, int> existingVersion;
if (lookup.TryGetValue(id, out existingVersion))
{
if (version > existingVersion.Item1)
{
lookup[id] = Tuple.Create(version, segmentReader.SegmentName, n);
}
}
else
{
lookup.Add(id, Tuple.Create(version, segmentReader.SegmentName, n));
}
}
}
}
}
return lookup;
}
示例11: CreateBitSetsLookup
public static IDictionary<string, BitSetsLookupEntry> CreateBitSetsLookup(IndexReader reader, IDictionary<string, ISet<string>> frameworkCompatibility)
{
// This is a two step process because we first need to calculate the highest version across the whole data set (i.e. across every segment)
// STEP 1. Create a lookup table of compatible documents (identified by SegmentName and Doc) per entry in the framework compatibility table
// (The result include separate structures for release-only and including pre-release.)
IDictionary<string, MatchingDocsEntry> matchingDocsLookup = new Dictionary<string, MatchingDocsEntry>();
foreach (string key in frameworkCompatibility.Keys)
{
matchingDocsLookup[key] = new MatchingDocsEntry();
}
foreach (SegmentReader segmentReader in reader.GetSequentialSubReaders())
{
UpdateMatchingDocs(matchingDocsLookup, segmentReader, frameworkCompatibility);
}
// STEP 2. From the globally created MatchingDocsLookup table we create per-segment lookups
IDictionary<string, BitSetsLookupEntry> bitSetsLookup = new Dictionary<string, BitSetsLookupEntry>();
foreach (string key in frameworkCompatibility.Keys)
{
BitSetsLookupEntry newBitSetsLookupEntry = new BitSetsLookupEntry();
foreach (SegmentReader segmentReader in reader.GetSequentialSubReaders())
{
newBitSetsLookupEntry.MatchingDocs.Add(segmentReader.SegmentName, new OpenBitSet());
newBitSetsLookupEntry.MatchingDocsPre.Add(segmentReader.SegmentName, new OpenBitSet());
}
bitSetsLookup[key] = newBitSetsLookupEntry;
}
foreach (KeyValuePair<string, MatchingDocsEntry> entry in matchingDocsLookup)
{
foreach (MatchingDoc matchingDoc in entry.Value.MatchingDocs.Values)
{
bitSetsLookup[entry.Key].MatchingDocs[matchingDoc.SegmentName].Set(matchingDoc.Doc);
}
foreach (MatchingDoc matchingDocPre in entry.Value.MatchingDocsPre.Values)
{
bitSetsLookup[entry.Key].MatchingDocsPre[matchingDocPre.SegmentName].Set(matchingDocPre.Doc);
}
}
return bitSetsLookup;
}
示例12: GetOnlySegmentReader
public /*internal*/ static SegmentReader GetOnlySegmentReader(IndexReader reader)
{
if (reader is SegmentReader)
return (SegmentReader) reader;
if (reader is DirectoryReader)
{
IndexReader[] subReaders = reader.GetSequentialSubReaders();
if (subReaders.Length != 1)
{
throw new System.ArgumentException(reader + " has " + subReaders.Length + " segments instead of exactly one");
}
return (SegmentReader) subReaders[0];
}
throw new System.ArgumentException(reader + " is not a SegmentReader or a single-segment DirectoryReader");
}
示例13: AssertReaderClosed
private void AssertReaderClosed(IndexReader reader, bool checkSubReaders, bool checkNormsClosed)
{
Assert.AreEqual(0, reader.GetRefCount());
if (checkNormsClosed && reader is SegmentReader)
{
Assert.IsTrue(((SegmentReader) reader).NormsClosed());
}
if (checkSubReaders)
{
if (reader is DirectoryReader)
{
IndexReader[] subReaders = reader.GetSequentialSubReaders();
for (int i = 0; i < subReaders.Length; i++)
{
AssertReaderClosed(subReaders[i], checkSubReaders, checkNormsClosed);
}
}
if (reader is MultiReader)
{
IndexReader[] subReaders = reader.GetSequentialSubReaders();
for (int i = 0; i < subReaders.Length; i++)
{
AssertReaderClosed(subReaders[i], checkSubReaders, checkNormsClosed);
}
}
if (reader is ParallelReader)
{
IndexReader[] subReaders = ((ParallelReader) reader).GetSubReaders();
for (int i = 0; i < subReaders.Length; i++)
{
AssertReaderClosed(subReaders[i], checkSubReaders, checkNormsClosed);
}
}
}
}