setValue() public method

public setValue ( RecordKey key, RecordUpdate update ) : void
key RecordKey
update RecordUpdate
return void
Exemplo n.º 1
0
        public void T000_TestBasic_SnapshotTombstones()
        {
            var raw_db = new LayerManager(InitMode.NEW_REGION, "c:\\BENDtst\\snapts");
            var snap_db = new StepsStageSnapshot(
               new StepsStageSubset(
                   new RecordKeyType_String("snapdb"),
                   raw_db));

            snap_db.setValue(new RecordKey().appendParsedKey("b/1"), RecordUpdate.DeletionTombstone());
            snap_db.setValue(new RecordKey().appendParsedKey("a/1"), RecordUpdate.WithPayload("data1"));

            var snapshot = snap_db.getSnapshot();

            snap_db.setValue(new RecordKey().appendParsedKey("a/1"), RecordUpdate.DeletionTombstone());

            raw_db.debugDump();

            int count = 0;
            foreach (var row in snap_db.scanForward(ScanRange<RecordKey>.All())) {
                Console.WriteLine("found record: " + row);
                count++;
            }
            Assert.AreEqual(0, count, "deletion tombstones didn't work in snapshot");
        }
Exemplo n.º 2
0
        public void T000_TestBasic_SnapshotScanAll()
        {
            // TODO: right now we have to make a subset stage, because otherwise
            //   we see the .ROOT keyspace. Perhaps we should make prefixes
            //   an automatic part of stage instantiation!?!?

            var snap_db = new StepsStageSnapshot(
                new StepsStageSubset(
                    new RecordKeyType_String("snapdb"),
                    new LayerManager(InitMode.NEW_REGION, "c:\\BENDtst\\snap")));

            string[] keys = new string[] { "1/2/3", "1/3/4", "1/5/3" };

            foreach (var key in keys) {
                snap_db.setValue(new RecordKey().appendParsedKey(key), RecordUpdate.WithPayload("snap1 data:" + key));
            }

            // TODO: check the data contents also to make sure we actually saw the right rows
            {
                int count = 0;
                foreach (var row in snap_db.scanForward(ScanRange<RecordKey>.All())) {
                    var match_key = new RecordKey().appendParsedKey(keys[count]);
                    Assert.True(match_key.CompareTo(row.Key) == 0, "scan key mismatch");
                    Console.WriteLine("scanned: " + row);
                    count++;
                }
                Assert.AreEqual(keys.Length, count, "incorrect number of keys in stage1 scan");
            }

            var snap1 = snap_db.getSnapshot();

            foreach (var key in keys) {
                var newkey = new RecordKey().appendParsedKey(key).appendParsedKey("snap2");
                snap_db.setValue(newkey, RecordUpdate.WithPayload("snap2 data:" + key));
            }

            {
                int count = 0;
                foreach (var row in snap1.scanForward(ScanRange<RecordKey>.All())) {
                    var match_key = new RecordKey().appendParsedKey(keys[count]);
                    Assert.True(match_key.CompareTo(row.Key) == 0, "scan key mismatch");
                    Console.WriteLine("scanned: " + row);
                    count++;
                }
                Assert.AreEqual(keys.Length, count, "incorrect number of keys in snap scan");
            }
        }