public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _mergeFile = GetTempFilePath(); _filename = GetTempFilePath(); _map = IndexMap.FromFile(_filename, maxTablesPerLevel: 4); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 1, 0); _result = _map.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 1, 2, (streamId, hash) => hash, _ => true, _ => new System.Tuple<string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 3, 4, (streamId, hash) => hash, _ => true, _ => new System.Tuple<string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 4, 5, (streamId, hash) => hash, _ => true, _ => new System.Tuple<string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 0, 1, (streamId, hash) => hash, _ => true, _ => new System.Tuple<string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); }
public void the_file_gets_created() { var indexEntrySize = PTable.IndexEntryV3Size; if (_ptableVersion == PTableVersions.IndexV1) { indexEntrySize = PTable.IndexEntryV1Size; } else if (_ptableVersion == PTableVersions.IndexV2) { indexEntrySize = PTable.IndexEntryV2Size; } var table = new HashListMemTable(_ptableVersion, maxSize: 10); table.Add(0x010100000000, 0x0001, 0x0001); table.Add(0x010500000000, 0x0001, 0x0002); table.Add(0x010200000000, 0x0001, 0x0003); table.Add(0x010200000000, 0x0002, 0x0003); using (var sstable = PTable.FromMemtable(table, Filename)) { var fileinfo = new FileInfo(Filename); Assert.AreEqual(PTableHeader.Size + PTable.MD5Size + 4 * indexEntrySize, fileinfo.Length); var items = sstable.IterateAllInOrder().ToList(); Assert.AreEqual(GetHash(0x010500000000), items[0].Stream); Assert.AreEqual(0x0001, items[0].Version); Assert.AreEqual(GetHash(0x010200000000), items[1].Stream); Assert.AreEqual(0x0002, items[1].Version); Assert.AreEqual(GetHash(0x010200000000), items[2].Stream); Assert.AreEqual(0x0001, items[2].Version); Assert.AreEqual(GetHash(0x010100000000), items[3].Stream); Assert.AreEqual(0x0001, items[3].Version); } }
public override void SetUp() { base.SetUp(); _filename = GetFilePathFor("indexfile"); _tablename = GetTempFilePath(); _mergeFile = GetFilePathFor("outfile"); _map = IndexMap.FromFile(_filename, maxTablesPerLevel: 4); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 2, 123); var table = PTable.FromMemtable(memtable, _tablename); _result = _map.AddPTable(table, 0, 0, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); _result = _result.MergedMap.AddPTable(table, 0, 0, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); _result = _result.MergedMap.AddPTable(table, 0, 0, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); var merged = _result.MergedMap.AddPTable(table, 0, 0, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); _result = merged.MergedMap.AddPTable(table, 0, 0, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); _result = _result.MergedMap.AddPTable(table, 7, 11, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); _result.MergedMap.SaveToFile(_filename); table.Dispose(); merged.MergedMap.InOrder().ToList().ForEach(x => x.Dispose()); merged.ToDelete.ForEach(x => x.Dispose()); _result.MergedMap.InOrder().ToList().ForEach(x => x.Dispose()); _result.ToDelete.ForEach(x => x.Dispose()); }
public override async Task TestFixtureSetUp() { await base.TestFixtureSetUp(); var table = new HashListMemTable(PTableVersions.IndexV4, maxSize: 20); table.Add(0x010100000000, 0, 1); table.Add(0x010200000000, 0, 2); table.Add(0x010300000000, 0, 3); table.Add(0x010300000000, 1, 4); _oldTable = PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault); var cancellationTokenSource = new CancellationTokenSource(); long spaceSaved; Func <IndexEntry, bool> existsAt = x => { cancellationTokenSource.Cancel(); return(true); }; Func <IndexEntry, Tuple <string, bool> > readRecord = x => { throw new Exception("Should not be called"); }; Func <string, ulong, ulong> upgradeHash = (streamId, hash) => { throw new Exception("Should not be called"); }; _expectedOutputFile = GetTempFilePath(); Assert.That( () => PTable.Scavenged(_oldTable, _expectedOutputFile, upgradeHash, existsAt, readRecord, PTableVersions.IndexV4, out spaceSaved, ct: cancellationTokenSource.Token, initialReaders: Constants.PTableInitialReaderCount, maxReaders: Constants.PTableMaxReaderCountDefault), Throws.InstanceOf <OperationCanceledException>()); }
public override void SetUp() { base.SetUp(); _filename = GetFilePathFor("indexfile"); _tablename = GetTempFilePath(); _mergeFile = GetFilePathFor("outfile"); _map = IndexMap.FromFile(_filename, maxTablesPerLevel: 4); var memtable = new HashListMemTable(maxSize: 10); memtable.Add(0, 2, 123); var table = PTable.FromMemtable(memtable, _tablename); _result = _map.AddPTable(table, 0, 0, _ => true, new FakeFilenameProvider(_mergeFile)); _result = _result.MergedMap.AddPTable(table, 0, 0, _ => true, new FakeFilenameProvider(_mergeFile)); _result = _result.MergedMap.AddPTable(table, 0, 0, _ => true, new FakeFilenameProvider(_mergeFile)); var merged = _result.MergedMap.AddPTable(table, 0, 0, _ => true, new FakeFilenameProvider(_mergeFile)); _result = merged.MergedMap.AddPTable(table, 0, 0, _ => true, new FakeFilenameProvider(_mergeFile)); _result = _result.MergedMap.AddPTable(table, 7, 11, _ => true, new FakeFilenameProvider(_mergeFile)); _result.MergedMap.SaveToFile(_filename); table.Dispose(); merged.MergedMap.InOrder().ToList().ForEach(x => x.Dispose()); merged.ToDelete.ForEach(x => x.Dispose()); _result.MergedMap.InOrder().ToList().ForEach(x => x.Dispose()); _result.ToDelete.ForEach(x => x.Dispose()); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _filename = GetTempFilePath(); _mergeFile = GetTempFilePath(); _map = IndexMapTestFactory.FromFile(_filename, maxTablesPerLevel: 2); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 1, 0); _result = _map.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 123, 321, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable( PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify), 100, 400, (streamId, hash) => hash, _ => true, _ => new System.Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion, _maxAutoMergeIndexLevel, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(PTableVersions.IndexV4, maxSize: 20); table.Add(0x010100000000, 0, 1); table.Add(0x010200000000, 0, 2); table.Add(0x010300000000, 0, 3); table.Add(0x010300000000, 1, 4); _oldTable = PTable.FromMemtable(table, GetTempFilePath()); long spaceSaved; Func <IndexEntry, bool> existsAt = x => { throw new Exception("Expected exception"); }; Func <IndexEntry, Tuple <string, bool> > readRecord = x => { throw new Exception("Should not be called"); }; Func <string, ulong, ulong> upgradeHash = (streamId, hash) => { throw new Exception("Should not be called"); }; _expectedOutputFile = GetTempFilePath(); Assert.That(() => PTable.Scavenged(_oldTable, _expectedOutputFile, upgradeHash, existsAt, readRecord, PTableVersions.IndexV4, out spaceSaved), Throws.Exception.With.Message.EqualTo("Expected exception")); }
public override void SetUp() { base.SetUp(); _filename = GetFilePathFor("indexfile"); _tablename = GetTempFilePath(); _mergeFile = GetFilePathFor("outfile"); _map = IndexMap.FromFile(_filename, x => false, maxTablesPerLevel: 4); var memtable = new HashListMemTable(maxSize: 10); memtable.Add(0, 2, 123); var table = PTable.FromMemtable(memtable, _tablename); _result = _map.AddFile(table, 0, 0, new FakeFilenameProvider(_mergeFile)); _result = _result.MergedMap.AddFile(table, 0, 0, new FakeFilenameProvider(_mergeFile)); _result = _result.MergedMap.AddFile(table, 0, 0, new FakeFilenameProvider(_mergeFile)); var merged = _result.MergedMap.AddFile(table, 0, 0, new FakeFilenameProvider(_mergeFile)); _result = merged.MergedMap.AddFile(table, 0, 0, new FakeFilenameProvider(_mergeFile)); _result = _result.MergedMap.AddFile(table, 7, 11, new FakeFilenameProvider(_mergeFile)); _result.MergedMap.SaveToFile(_filename); table.Dispose(); merged.MergedMap.InOrder().ToList().ForEach(x => x.Dispose()); merged.ToDelete.ForEach(x => x.Dispose()); _result.MergedMap.InOrder().ToList().ForEach(x => x.Dispose()); _result.ToDelete.ForEach(x => x.Dispose()); }
public override void TestFixtureSetUp() { hasher = new Murmur3AUnsafe(); base.TestFixtureSetUp(); _files.Add(GetTempFilePath()); var table = new HashListMemTable(PTableVersions.Index32Bit, maxSize: 20); table.Add(0x010100000000, 0, 1); table.Add(0x010200000000, 0, 2); table.Add(0x010300000000, 0, 3); table.Add(0x010300000000, 1, 4); _tables.Add(PTable.FromMemtable(table, GetTempFilePath())); table = new HashListMemTable(PTableVersions.Index64Bit, maxSize: 20); table.Add(0x010100000000, 2, 5); table.Add(0x010200000000, 1, 6); table.Add(0x010200000000, 2, 7); table.Add(0x010400000000, 0, 8); table.Add(0x010400000000, 1, 9); _tables.Add(PTable.FromMemtable(table, GetTempFilePath())); table = new HashListMemTable(PTableVersions.Index32Bit, maxSize: 20); table.Add(0x010100000000, 1, 10); table.Add(0x010100000000, 2, 11); table.Add(0x010500000000, 1, 12); table.Add(0x010500000000, 2, 13); table.Add(0x010500000000, 3, 14); _tables.Add(PTable.FromMemtable(table, GetTempFilePath())); _newtable = PTable.MergeTo(_tables, GetTempFilePath(), (streamId, hash) => hash << 32 | hasher.Hash(streamId), x => x.Position % 2 == 0, x => new Tuple <string, bool>(x.Stream.ToString(), x.Position % 2 == 0), PTableVersions.Index64Bit); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _mergeFile = GetTempFilePath(); _filename = GetTempFilePath(); _map = IndexMap.FromFile(_filename, _ptableVersion, maxTablesPerLevel: 2); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 1, 0); _result = _map.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 10, 20, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 20, 30, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 30, 40, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 50, 60, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), new FakeFilenameProvider(_mergeFile + ".firstmerge", _mergeFile), _ptableVersion); _result.ToDelete.ForEach(x => x.MarkForDestruction()); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _mergeFile = GetTempFilePath(); _filename = GetTempFilePath(); _map = IndexMap.FromFile(_filename, maxTablesPerLevel: 4); var memtable = new HashListMemTable(maxSize: 10); memtable.Add(0, 1, 0); _result = _map.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 1, 2, _ => true, new GuidFilenameProvider(PathName)); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 3, 4, _ => true, new GuidFilenameProvider(PathName)); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 4, 5, _ => true, new GuidFilenameProvider(PathName)); _result.ToDelete.ForEach(x => x.MarkForDestruction()); _result = _result.MergedMap.AddPTable(PTable.FromMemtable(memtable, GetTempFilePath()), 0, 1, _ => true, new FakeFilenameProvider(_mergeFile)); _result.ToDelete.ForEach(x => x.MarkForDestruction()); }
public override async Task TestFixtureSetUp() { hasher = new Murmur3AUnsafe(); await base.TestFixtureSetUp(); _files.Add(GetTempFilePath()); var table = new HashListMemTable(PTableVersions.IndexV1, maxSize: 20); table.Add(0x010100000000, 0, 1); table.Add(0x010200000000, 0, 2); table.Add(0x010300000000, 0, 3); table.Add(0x010300000000, 1, 4); _tables.Add(PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault)); table = new HashListMemTable(PTableVersions.IndexV2, maxSize: 20); table.Add(0x010100000000, 2, 5); table.Add(0x010200000000, 1, 6); table.Add(0x010200000000, 2, 7); table.Add(0x010400000000, 0, 8); table.Add(0x010400000000, 1, 9); _tables.Add(PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault)); table = new HashListMemTable(PTableVersions.IndexV1, maxSize: 20); table.Add(0x010100000000, 1, 10); table.Add(0x010100000000, 2, 11); table.Add(0x010500000000, 1, 12); table.Add(0x010500000000, 2, 13); table.Add(0x010500000000, 3, 14); _tables.Add(PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault)); _newtable = PTable.MergeTo(_tables, GetTempFilePath(), (streamId, hash) => hash << 32 | hasher.Hash(streamId), x => x.Position % 2 == 0, x => new Tuple <string, bool>(x.Stream.ToString(), x.Position % 2 == 0), PTableVersions.IndexV2, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, skipIndexVerify: _skipIndexVerify); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(_oldVersion, maxSize: 20); table.Add(0x010100000000, 0, 1); table.Add(0x010200000000, 0, 2); table.Add(0x010300000000, 0, 3); table.Add(0x010300000000, 1, 4); _oldTable = PTable.FromMemtable(table, GetTempFilePath()); long spaceSaved; Func <IndexEntry, bool> existsAt = x => true; Func <IndexEntry, Tuple <string, bool> > readRecord = x => { throw new Exception("Should not be called"); }; Func <string, ulong, ulong> upgradeHash = (streamId, hash) => { throw new Exception("Should not be called"); }; _expectedOutputFile = GetTempFilePath(); _newtable = PTable.Scavenged(_oldTable, _expectedOutputFile, upgradeHash, existsAt, readRecord, PTableVersions.IndexV4, out spaceSaved, skipIndexVerify: _skipIndexVerify); }
public override void SetUp() { base.SetUp(); _filename = GetTempFilePath(); _copiedfilename = GetTempFilePath(); var mtable = new HashListMemTable(_ptableVersion, maxSize: 1024); long logPosition = 0; long eventNumber = 1; ulong streamId = 0x010100000000; for (var i = 0; i < 1337; i++) { logPosition++; if (i % 37 == 0) { streamId -= 0x1337; eventNumber = 1; } else { eventNumber++; } mtable.Add(streamId, eventNumber, logPosition); } _table = PTable.FromMemtable(mtable, _filename, skipIndexVerify: _skipIndexVerify); _table.Dispose(); File.Copy(_filename, _copiedfilename); }
public void the_file_gets_created() { var tmp = Path.GetRandomFileName(); var table = new HashListMemTable(); table.Add(0x0101, 0x0001, 0x0001); table.Add(0x0105, 0x0001, 0x0002); table.Add(0x0102, 0x0001, 0x0003); table.Add(0x0102, 0x0002, 0x0003); using (var sstable = PTable.FromMemtable(table, tmp)) { var fileinfo = new FileInfo(tmp); Assert.AreEqual(PTableHeader.Size + PTable.MD5Size + 4 * 16, fileinfo.Length); var items = sstable.IterateAllInOrder().ToList(); Assert.AreEqual(0x0105, items[0].Stream); Assert.AreEqual(0x0001, items[0].Version); Assert.AreEqual(0x0102, items[1].Stream); Assert.AreEqual(0x0002, items[1].Version); Assert.AreEqual(0x0102, items[2].Stream); Assert.AreEqual(0x0001, items[2].Version); Assert.AreEqual(0x0101, items[3].Stream); Assert.AreEqual(0x0001, items[3].Version); } File.Delete(tmp); }
public override async Task TestFixtureSetUp() { await base.TestFixtureSetUp(); _files.Add(GetTempFilePath()); var table = new HashListMemTable(PTableVersions.IndexV1, maxSize: 20); table.Add(0x010100000000, 0, 0x010100000000); table.Add(0x010200000000, 0, 0x010200000000); table.Add(0x010300000000, 0, 0x010300000000); table.Add(0x010400000000, 0, 0x010400000000); _tables.Add(PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault)); table = new HashListMemTable(PTableVersions.IndexV1, maxSize: 20); table.Add(0x010500000000, 0, 0x010500000000); table.Add(0x010600000000, 0, 0x010600000000); table.Add(0x010700000000, 0, 0x010700000000); table.Add(0x010800000000, 0, 0x010800000000); _tables.Add(PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault)); table = new HashListMemTable(PTableVersions.IndexV2, maxSize: 20); table.Add(0x010900000000, 0, 0x010900000000); table.Add(0x101000000000, 0, 0x101000000000); table.Add(0x111000000000, 0, 0x111000000000); table.Add(0x121000000000, 0, 0x121000000000); _tables.Add(PTable.FromMemtable(table, GetTempFilePath(), Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault)); _newtable = PTable.MergeTo(_tables, GetTempFilePath(), (streamId, hash) => hash + 1, x => true, x => new Tuple <string, bool>(x.Stream.ToString(), true), PTableVersions.IndexV2, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, skipIndexVerify: _skipIndexVerify); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _files.Add(GetTempFilePath()); var table = new HashListMemTable(PTableVersions.Index32Bit, maxSize: 20); table.Add(0x010100000000, 0, 0x010100000000); table.Add(0x010200000000, 0, 0x010200000000); table.Add(0x010300000000, 0, 0x010300000000); table.Add(0x010400000000, 0, 0x010400000000); _tables.Add(PTable.FromMemtable(table, GetTempFilePath())); table = new HashListMemTable(PTableVersions.Index32Bit, maxSize: 20); table.Add(0x010500000000, 0, 0x010500000000); table.Add(0x010600000000, 0, 0x010600000000); table.Add(0x010700000000, 0, 0x010700000000); table.Add(0x010800000000, 0, 0x010800000000); _tables.Add(PTable.FromMemtable(table, GetTempFilePath())); table = new HashListMemTable(PTableVersions.Index64Bit, maxSize: 20); table.Add(0x010900000000, 0, 0x010900000000); table.Add(0x101000000000, 0, 0x101000000000); table.Add(0x111000000000, 0, 0x111000000000); table.Add(0x121000000000, 0, 0x121000000000); _tables.Add(PTable.FromMemtable(table, GetTempFilePath())); _newtable = PTable.MergeTo(_tables, GetTempFilePath(), (streamId, hash) => hash + 1, x => true, x => new Tuple <string, bool>(x.Stream.ToString(), true), PTableVersions.Index64Bit); }
protected void AddTables(int count) { var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 1, 0); var first = _map; if (_result != null) { first = _result.MergedMap; } var pTable = PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify); _result = first.AddPTable(pTable, 10, 20, UpgradeHash, ExistsAt, RecordExistsAt, _fileNameProvider, _ptableVersion, 0, 0, skipIndexVerify: _skipIndexVerify); for (int i = 3; i <= count * 2; i += 2) { pTable = PTable.FromMemtable(memtable, GetTempFilePath(), skipIndexVerify: _skipIndexVerify); _result = _result.MergedMap.AddPTable( pTable, i * 10, (i + 1) * 10, (streamId, hash) => hash, _ => true, _ => new Tuple <string, bool>("", true), _fileNameProvider, _ptableVersion, 0, 0, skipIndexVerify: _skipIndexVerify); _result.ToDelete.ForEach(x => x.MarkForDestruction()); } }
public void wait_for_destroy_will_timeout() { var tmp = Path.GetRandomFileName(); var table = new HashListMemTable(); table.Add(0x0101, 0x0001, 0x0001); var stable = PTable.FromMemtable(table, tmp); Assert.Throws<TimeoutException>(() => stable.WaitForDestroy(1)); }
public void Setup() { var mtable = new HashListMemTable(maxSize: 10); mtable.Add(0x0101, 0x0001, 0x0001); mtable.Add(0x0105, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, Filename); _table.MarkForDestruction(); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(maxSize: 2000); table.Add(0x0101, 0x0001, 0x0001); _ptable = PTable.FromMemtable(table, Filename, cacheDepth: 0); }
public void Setup() { _filename = Path.GetRandomFileName(); var mtable = new HashListMemTable(); mtable.Add(0x0101, 0x0001, 0x0001); mtable.Add(0x0105, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, _filename); _table.MarkForDestruction(); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(maxSize: 10); table.Add(0x0101, 0x0001, 0x0001); _ptable = PTable.FromMemtable(table, Filename, cacheDepth: 0); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(_ptableVersion, maxSize: 10); table.Add(0x010100000000, 0x0001, 0x0001); _ptable = PTable.FromMemtable(table, Filename, cacheDepth: 0, skipIndexVerify: _skipIndexVerify); }
public void Setup() { var mtable = new HashListMemTable(_ptableVersion, maxSize: 10); mtable.Add(0x010100000000, 0x0001, 0x0001); mtable.Add(0x010500000000, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, Filename, skipIndexVerify: _skipIndexVerify); _table.MarkForDestruction(); }
public void Setup() { _filename = Path.GetRandomFileName(); var table = new HashListMemTable(); AddItemsForScenario(table); PTable = PTable.FromMemtable(table, _filename, cacheDepth: _midpointCacheDepth); }
public void the_hash_of_file_is_valid() { var table = new HashListMemTable(_ptableVersion, maxSize: 10); table.Add(0x010100000000, 0x0001, 0x0001); table.Add(0x010500000000, 0x0001, 0x0002); table.Add(0x010200000000, 0x0001, 0x0003); table.Add(0x010200000000, 0x0002, 0x0003); Assert.DoesNotThrow(() => {using (var sstable = PTable.FromMemtable(table, Filename)) {}}); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(_ptableVersion, maxSize: 10); table.Add(0x010100000000, 0x0001, 0x0001); _ptable = PTable.FromMemtable(table, Filename, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, cacheDepth: 0, skipIndexVerify: _skipIndexVerify); }
public void Setup() { var mtable = new HashListMemTable(_ptableVersion, maxSize: 10); mtable.Add(0x010100000000, 0x0001, 0x0001); mtable.Add(0x010500000000, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, Filename, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, skipIndexVerify: _skipIndexVerify); _table.MarkForDestruction(); }
public void Setup() { _filename = Path.GetRandomFileName(); var table = new HashListMemTable(maxSize: 2000); AddItemsForScenario(table); PTable = PTable.FromMemtable(table, _filename, cacheDepth: _midpointCacheDepth); }
public override void SetUp() { base.SetUp(); var table = new HashListMemTable(maxSize: 50); AddItemsForScenario(table); PTable = PTable.FromMemtable(table, Filename, cacheDepth: _midpointCacheDepth); }
public void wait_for_destroy_will_timeout() { var tmp = Path.GetRandomFileName(); var table = new HashListMemTable(); table.Add(0x0101, 0x0001, 0x0001); var stable = PTable.FromMemtable(table, tmp); Assert.Throws <TimeoutException>(() => stable.WaitForDestroy(1)); }
public override void SetUp() { base.SetUp(); var table = new HashListMemTable(_ptableVersion, maxSize: 50); AddItemsForScenario(table); PTable = PTable.FromMemtable(table, Filename, cacheDepth: _midpointCacheDepth, skipIndexVerify: _skipIndexVerify); }
public void nothing_is_found_on_empty_stream() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xffff); using (var ptable = PTable.FromMemtable(memTable, Filename)) { IndexEntry entry; Assert.IsFalse(ptable.TryGetLatestEntry(0x12, out entry)); } }
public void nothing_is_found_on_empty_stream() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xffff); using (var ptable = PTable.FromMemtable(memTable, Filename, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, skipIndexVerify: _skipIndexVerify)) { IndexEntry entry; Assert.IsFalse(ptable.TryGetLatestEntry(0x12, out entry)); } }
public void nothing_is_found_on_empty_stream() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xffff); using (var ptable = PTable.FromMemtable(memTable, Filename, skipIndexVerify: _skipIndexVerify)) { IndexEntry entry; Assert.IsFalse(ptable.TryGetOldestEntry(0x12, out entry)); } }
public void the_hash_of_file_is_valid() { var table = new HashListMemTable(_ptableVersion, maxSize: 10); table.Add(0x010100000000, 0x0001, 0x0001); table.Add(0x010500000000, 0x0001, 0x0002); table.Add(0x010200000000, 0x0001, 0x0003); table.Add(0x010200000000, 0x0002, 0x0003); Assert.DoesNotThrow(() => { using (var sstable = PTable.FromMemtable(table, Filename)) {} }); }
public void nothing_is_found_on_empty_stream() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xffff); using (var ptable = ConstructPTable(memTable)) { IndexEntry entry; Assert.IsFalse(ptable.TryGetLatestEntry(0x12, out entry)); } }
private PTable ConstructPTable(string file, int count, Random rnd) { var memTable = new HashListMemTable(_ptableVersion, 20000); for (int i = 0; i < count; ++i) { memTable.Add((uint)rnd.Next(), rnd.Next(0, 1<<20), Math.Abs(rnd.Next() * rnd.Next())); } var ptable = PTable.FromMemtable(memTable, file, 0); return ptable; }
public void wait_for_destroy_will_timeout() { var table = new HashListMemTable(maxSize: 10); table.Add(0x0101, 0x0001, 0x0001); var ptable = PTable.FromMemtable(table, Filename); Assert.Throws<TimeoutException>(() => ptable.WaitForDestroy(1)); // tear down ptable.MarkForDestruction(); ptable.WaitForDestroy(1000); }
public void the_hash_of_file_is_valid() { var table = new HashListMemTable(maxSize: 10); table.Add(0x0101, 0x0001, 0x0001); table.Add(0x0105, 0x0001, 0x0002); table.Add(0x0102, 0x0001, 0x0003); table.Add(0x0102, 0x0002, 0x0003); using (var sstable = PTable.FromMemtable(table, Filename)) { Assert.DoesNotThrow(() => sstable.VerifyFileHash()); } }
public override void SetUp() { base.SetUp(); _indexMapFileName = GetFilePathFor("index.map"); _ptableFileName = GetFilePathFor("ptable"); _emptyIndexMap = IndexMap.FromFile(_indexMapFileName, _ptableVersion); var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0, 1, 2); _ptable = PTable.FromMemtable(memTable, _ptableFileName, _ptableVersion); }
public override void SetUp() { base.SetUp(); _indexMapFileName = Path.Combine(PathName, "index.map"); _ptableFileName = Path.Combine(PathName, "ptable"); _emptyIndexMap = IndexMap.FromFile(_indexMapFileName, x => false); var memTable = new HashListMemTable(); memTable.Add(0, 1, 2); _ptable = PTable.FromMemtable(memTable, _ptableFileName); }
public void single_item_is_latest() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xffff); using (var ptable = PTable.FromMemtable(memTable, Filename)) { IndexEntry entry; Assert.IsTrue(ptable.TryGetLatestEntry(0x010100000000, out entry)); Assert.AreEqual(GetHash(0x010100000000), entry.Stream); Assert.AreEqual(0x01, entry.Version); Assert.AreEqual(0xffff, entry.Position); } }
public void correct_entry_is_returned() { var memTable = new HashListMemTable(maxSize: 2000); memTable.Add(0x11, 0x01, 0xffff); memTable.Add(0x11, 0x02, 0xfff2); using (var ptable = PTable.FromMemtable(memTable, Filename)) { IndexEntry entry; Assert.IsTrue(ptable.TryGetLatestEntry(0x11, out entry)); Assert.AreEqual(0x11, entry.Stream); Assert.AreEqual(0x02, entry.Version); Assert.AreEqual(0xfff2, entry.Position); } }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var table = new HashListMemTable(); table.Add(0x0101, 0x0001, 0x0001); table.Add(0x0105, 0x0001, 0x0002); table.Add(0x0102, 0x0001, 0x0003); table.Add(0x0102, 0x0002, 0x0004); table.Add(0x0103, 0x0001, 0xFFF1); table.Add(0x0103, 0x0003, 0xFFF3); table.Add(0x0103, 0x0005, 0xFFF5); _ptable = PTable.FromMemtable(table, Filename, cacheDepth: 0); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _filename = GetTempFilePath(); _tablename = GetTempFilePath(); _mergeFile = Path.Combine(PathName, "mergefile"); _map = IndexMap.FromFile(_filename, x => false); var memtable = new HashListMemTable(); memtable.Add(0, 1, 0); var table = PTable.FromMemtable(memtable, _tablename); _result = _map.AddFile(table, 7, 11, new FakeFilenameProvider(_mergeFile)); table.MarkForDestruction(); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _filename = GetTempFilePath(); _tablename = GetTempFilePath(); _mergeFile = GetFilePathFor("mergefile"); _map = IndexMap.FromFile(_filename); var memtable = new HashListMemTable(maxSize: 10); memtable.Add(0, 1, 0); var table = PTable.FromMemtable(memtable, _tablename); _result = _map.AddPTable(table, 7, 11, _ => true, new FakeFilenameProvider(_mergeFile)); table.MarkForDestruction(); }
public void only_entry_with_largest_position_is_returned_when_triduplicated() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xfff1); memTable.Add(0x010100000000, 0x01, 0xfff3); memTable.Add(0x010100000000, 0x01, 0xfff5); using (var ptable = PTable.FromMemtable(memTable, Filename)) { IndexEntry entry; Assert.IsTrue(ptable.TryGetLatestEntry(0x010100000000, out entry)); Assert.AreEqual(GetHash(0x010100000000), entry.Stream); Assert.AreEqual(0x01, entry.Version); Assert.AreEqual(0xfff5, entry.Position); } }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); _filename = GetTempFilePath(); _tablename = GetTempFilePath(); _mergeFile = GetFilePathFor("mergefile"); _map = IndexMap.FromFile(_filename, _ptableVersion); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0, 1, 0); var table = PTable.FromMemtable(memtable, _tablename); _result = _map.AddPTable(table, 7, 11, (streamId, hash) => hash, _ => true, _ => new System.Tuple<string, bool>("", true), new FakeFilenameProvider(_mergeFile), _ptableVersion); table.MarkForDestruction(); }
public void when_duplicated_entries_exist_the_one_with_oldest_position_is_returned() { var memTable = new HashListMemTable(_ptableVersion, maxSize: 10); memTable.Add(0x010100000000, 0x01, 0xfff1); memTable.Add(0x010100000000, 0x02, 0xfff2); memTable.Add(0x010100000000, 0x01, 0xfff3); memTable.Add(0x010100000000, 0x02, 0xfff4); using (var ptable = PTable.FromMemtable(memTable, Filename)) { IndexEntry entry; Assert.IsTrue(ptable.TryGetOldestEntry(0x010100000000, out entry)); Assert.AreEqual(GetHash(0x010100000000), entry.Stream); Assert.AreEqual(0x01, entry.Version); Assert.AreEqual(0xfff1, entry.Position); } }
public override void SetUp() { base.SetUp(); _indexMapFileName = GetFilePathFor("index.map"); _ptableFileName = GetFilePathFor("ptable"); var indexMap = IndexMap.FromFile(_indexMapFileName, maxTablesPerLevel: 2); var memtable = new HashListMemTable(maxSize: 10); memtable.Add(0,0,0); memtable.Add(1,1,100); _ptable = PTable.FromMemtable(memtable, _ptableFileName); indexMap = indexMap.AddPTable(_ptable, 0, 0, _ => true, new GuidFilenameProvider(PathName)).MergedMap; indexMap.SaveToFile(_indexMapFileName); }
public override void SetUp() { base.SetUp(); _indexMapFileName = Path.Combine(PathName, "index.map"); _ptableFileName = Path.Combine(PathName, "ptable"); var indexMap = IndexMap.FromFile(_indexMapFileName, x => false, maxTablesPerLevel: 2); var memtable = new HashListMemTable(maxSize: 2000); memtable.Add(0,0,0); memtable.Add(1,1,100); _ptable = PTable.FromMemtable(memtable, _ptableFileName); indexMap = indexMap.AddFile(_ptable, 0, 0, new GuidFilenameProvider(PathName)).MergedMap; indexMap.SaveToFile(_indexMapFileName); }
public override void SetUp() { base.SetUp(); _indexMapFileName = GetFilePathFor("index.map"); _ptableFileName = GetFilePathFor("ptable"); var indexMap = IndexMap.FromFile(_indexMapFileName, maxTablesPerLevel: 2); var memtable = new HashListMemTable(_ptableVersion, maxSize: 10); memtable.Add(0,0,0); memtable.Add(1,1,100); _ptable = PTable.FromMemtable(memtable, _ptableFileName); indexMap = indexMap.AddPTable(_ptable, 0, 0, (streamId, hash) => hash, _ => true, _ => new Tuple<string, bool>("", true), new GuidFilenameProvider(PathName), _ptableVersion).MergedMap; indexMap.SaveToFile(_indexMapFileName); }
public void Setup() { for (int i = 0; i < 2; i++) { _files.Add(Path.GetRandomFileName()); var table = new HashListMemTable(); for (int j = 0; j < 10; j++) { table.Add((UInt32)j + 1, i + 1, i * j); } _tables.Add(PTable.FromMemtable(table, _files[i])); } _files.Add(Path.GetRandomFileName()); _newtable = PTable.MergeTo(_tables, _files[2], x => false); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); for (int i = 0; i < 2; i++) { _files.Add(GetTempFilePath()); var table = new HashListMemTable(maxSize: 20); for (int j = 0; j < 10; j++) { table.Add((UInt32)j + 1, i + 1, i * j); } _tables.Add(PTable.FromMemtable(table, _files[i])); } _files.Add(GetTempFilePath()); _newtable = PTable.MergeTo(_tables, _files[2], x => true); }
public void Setup() { _filename = GetTempFilePath(); _copiedfilename = GetTempFilePath(); var mtable = new HashListMemTable(_ptableVersion, maxSize: 10); mtable.Add(0x010100000000, 0x0001, 0x0001); mtable.Add(0x010500000000, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, _filename); _table.Dispose(); File.Copy(_filename, _copiedfilename); using (var f = new FileStream(_copiedfilename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { f.Seek(22, SeekOrigin.Begin); f.WriteByte(0x22); } }