本文整理汇总了C#中Index.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Index.Load方法的具体用法?C# Index.Load怎么用?C# Index.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index.Load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexClosesWithCorrectLength
public void IndexClosesWithCorrectLength()
{
_testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();
Cleanup();
var formatter = TestResourceFactory.CreateJsonFormatterWithoutArrayFormatting();
var core = new FileCore<string, long>() { IdSeed = new SeedString(2048), SegmentSeed = new Seed64(), Stride = 512 };
var objs = TestResourceFactory.GetMockClassAObjects(1000).ToDictionary(d => d.Name);
var additions = TestResourceFactory.GetMockClassAObjects(2).ToDictionary(d => d.Name);
IDictionary<string, long> segs = null;
using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core, formatter))
{
using (var index = new Index<string, MockClassA, long>(_testName + ".index", "Name", true, 8, new BinConverterString(2048), new BinConverter64(), new RowSynchronizer<long>(new BinConverter64()), new RowSynchronizer<int>(new BinConverter32())))
{
afm.Load<string>();
index.Load();
index.Register(afm);
segs = AtomicFileManagerHelper.SaveSegments(afm, objs);
Assert.AreEqual(1000, index.Length);
}
}
using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core, formatter))
{
using (var index = new Index<string, MockClassA, long>(_testName + ".index", "Name", true, 8, new BinConverterString(2048), new BinConverter64(), new RowSynchronizer<long>(new BinConverter64()), new RowSynchronizer<int>(new BinConverter32())))
{
afm.Load<string>();
index.Load();
Assert.AreEqual(1000, index.Length);
index.Register(afm);
Assert.AreEqual(1000, index.Length);
var idx = DynamicMemberManager.GetManager(index);
var pt = DynamicMemberManager.GetManager(idx._pTree);
Assert.AreEqual(3, pt._cache.Count);
Assert.AreEqual(400, pt._cache[0].Count);
segs = AtomicFileManagerHelper.SaveSegments(afm, additions);
}
}
using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core, formatter))
{
using (var index = new Index<string, MockClassA, long>(_testName + ".index", "Name", true, 8, new BinConverterString(2048), new BinConverter64(), new RowSynchronizer<long>(new BinConverter64()), new RowSynchronizer<int>(new BinConverter32())))
{
afm.Load<string>();
index.Load();
Assert.AreEqual(1002, index.Length);
index.Register(afm);
Assert.AreEqual(1002, index.Length);
var seg = index.FetchSegment(additions.First().Key);
Assert.IsNotNull(seg);
}
}
}
示例2: 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());
}
}
}