public void try_read_does_not_cache_anything_and_returns_record_once_it_is_written_later() { var writerchk = new InMemoryCheckpoint(0); var db = new TFChunkDb(new TFChunkDbConfig(PathName, new VersionedPatternFileNamingStrategy(PathName, "chunk-"), 10000, 0, writerchk, new InMemoryCheckpoint())); db.OpenVerifyAndClean(); var writer = new TFChunkWriter(db); writer.Open(); var reader = new TFChunkSequentialReader(db, writerchk, 0); LogRecord record; Assert.IsFalse(reader.TryReadNext(out record)); var rec = LogRecord.SingleWrite(0, Guid.NewGuid(), Guid.NewGuid(), "ES", -1, "ET", new byte[] { 7 }, null); long tmp; Assert.IsTrue(writer.Write(rec, out tmp)); writer.Flush(); writer.Close(); Assert.IsTrue(reader.TryReadNext(out record)); Assert.AreEqual(rec, record); reader.Close(); db.Close(); }
public void all_records_could_be_read_doing_forward_backward_pass() { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, 0); SeqReadResult res; int count1 = 0; while ((res = seqReader.TryReadNext()).Success) { var rec = _keptRecords[count1]; Assert.AreEqual(rec, res.LogRecord); //Assert.AreEqual(rec.Position + rec.GetSizeWithLengthPrefixAndSuffix(), seqReader.Position); ++count1; } Assert.AreEqual(_keptRecords.Length, count1); int count2 = 0; while ((res = seqReader.TryReadPrev()).Success) { var rec = _keptRecords[_keptRecords.Length - count2 - 1]; Assert.AreEqual(rec, res.LogRecord); //Assert.AreEqual(rec.Position, seqReader.Position); ++count2; } Assert.AreEqual(_keptRecords.Length, count2); }
public void all_records_could_be_read_with_forward_pass() { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, 0); SeqReadResult res; int count = 0; while ((res = seqReader.TryReadNext()).Success) { var rec = _keptRecords[count]; Assert.AreEqual(rec, res.LogRecord); ++count; } Assert.AreEqual(_keptRecords.Length, count); }
public void all_records_could_be_read_with_forward_pass() { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, 0); SeqReadResult res; int count = 0; while ((res = seqReader.TryReadNext()).Success) { var rec = _records[count]; Assert.AreEqual(rec, res.LogRecord); Assert.AreEqual(rec.Position, res.RecordPrePosition); Assert.AreEqual(rec.Position + rec.GetSizeWithLengthPrefixAndSuffix(), res.RecordPostPosition); ++count; } Assert.AreEqual(RecordsCount, count); }
public void records_can_be_read_forward_starting_from_any_position() { for (int i = 0; i < RecordsCount; ++i) { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, _records[i].Position); SeqReadResult res; int count = 0; while ((res = seqReader.TryReadNext()).Success) { var rec = _keptRecords[i/2 + count]; Assert.AreEqual(rec, res.LogRecord); //Assert.AreEqual(rec.Position + rec.GetSizeWithLengthPrefixAndSuffix(), seqReader.Position); ++count; } Assert.AreEqual(_keptRecords.Length - i/2, count); } }
public void try_read_returns_false_when_writer_checksum_is_zero() { var writerchk = new InMemoryCheckpoint(0); var db = new TFChunkDb(new TFChunkDbConfig(PathName, new VersionedPatternFileNamingStrategy(PathName, "chunk-"), 10000, 0, writerchk, new InMemoryCheckpoint())); db.OpenVerifyAndClean(); var reader = new TFChunkSequentialReader(db, writerchk, 0); LogRecord record; Assert.IsFalse(reader.TryReadNext(out record)); db.Close(); }