本文整理汇总了C#中Index.FetchIndexes方法的典型用法代码示例。如果您正苦于以下问题:C# Index.FetchIndexes方法的具体用法?C# Index.FetchIndexes怎么用?C# Index.FetchIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index.FetchIndexes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexReorganizes
public void IndexReorganizes()
{
_testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();
Cleanup();
var formatter = TestResourceFactory.CreateJsonFormatterWithoutArrayFormatting();
var core = new FileCore<int, long>() { IdSeed = new Seed32(999), SegmentSeed = new Seed64(), Stride = 512 };
var objs = TestResourceFactory.GetMockClassAObjects(100).ToDictionary(d => d.Id = core.IdSeed.Increment());
IDictionary<int, long> segs = null;
using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core, formatter))
{
using (var index = new Index<int, MockClassA, long>(_testName + ".index", "Id", true, 8, new BinConverter32(), new BinConverter64(), new RowSynchronizer<long>(new BinConverter64()), new RowSynchronizer<int>(new BinConverter32())))
{
afm.Load<int>();
index.Load();
segs = AtomicFileManagerHelper.SaveSegments(afm, objs);
//should trigger re-org.
index.Register(afm);
Assert.AreEqual(objs.Count, segs.Count);
afm.SaveCore();
long seg;
var f = index.FetchIndex(segs[objs.First().Key], out seg);
Assert.AreEqual(objs.First().Key, f);
long[] segList;
var all = index.FetchIndexes(segs.Values.ToArray(), out segList);
Assert.AreEqual(objs.Count, all.Count());
var many = index.FetchIndexes(segs[objs.First().Key], out segList);
Assert.AreEqual(1, many.Count());
}
}
using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core, formatter))
{
using (var index = new Index<int, MockClassA, long>(_testName + ".index", "Id", true))
{
afm.Load<int>();
index.Load();
index.Register(afm);
var f = index.FetchSegment(objs.First().Key);
Assert.AreEqual(segs[objs.First().Key], f);
var all = index.FetchSegments(objs.First().Key, objs.Last().Key);
Assert.AreEqual(objs.Count, all.Count());
var many = index.FetchSegments(new int[] { objs.First().Key, objs.Last().Key });
Assert.AreEqual(2, many.Count());
}
}
}