public void Infinity() { using var log = Log(); using LevelDB.DB <string, string> db = GetTestDb(); Assert.Equal( "y=25;z=26", string.Join(";", db.GetIterable().Range("y", null).Select(kv => $"{kv.Key}={kv.Value}"))); Assert.Equal( "z=26;y=25", string.Join(";", db.GetIterable().Reverse().Range(null, "x").Select(kv => $"{kv.Key}={kv.Value}"))); }
public void GetIterableRangeReverse() { using var log = Log(); using LevelDB.DB <string, string> db = GetTestDb(); Assert.Equal( "y=25;x=24;n=14;m=13;l=12", string.Join(";", db.GetIterable().Range("c", "y").Reverse().Select(kv => $"{kv.Key}={kv.Value}"))); }
public void GetIterable() { using var log = Log(); using LevelDB.DB <string, string> db = GetTestDb(); Assert.Equal( "a=1;b=2;c=3;l=12;m=13;n=14;x=24;y=25;z=26", string.Join(";", db.GetIterable().Select(kv => $"{kv.Key}={kv.Value}"))); }
public void Delete() { using var log = Log(); using LevelDB.DB <string, string> db = GetTestDb(); db.Delete("a").Delete("c").Delete("m").Delete("n"); Assert.Equal( "b=2;l=12;x=24;y=25;z=26", string.Join(";", db.GetIterable().Select(kv => $"{kv.Key}={kv.Value}"))); }
public void Integers() { using var log = Log(); LevelDB.Options options = new LevelDB.Options(); options.CreateIfMissing = true; using LevelDB.DB <int, string> db = new LevelDB.DB(options, $"/tmp/DBTests-Integers").Cast <int, string>(); db.Put(1, "aaa").Put(2, "bbb").Put(3, "ccc"); db.Put(7, "ggg").Put(8, "hhh").Put(9, "iii"); db.Put(6, "fff").Put(5, "eee").Put(4, "ddd"); Assert.Equal( "4=ddd;5=eee;6=fff;7=ggg", string.Join(";", db.GetIterable().Range(4, 8).Select(kv => $"{kv.Key}={kv.Value}"))); }
public void Prefix() { using var log = Log(); LevelDB.Options options = new LevelDB.Options(); options.CreateIfMissing = true; using var db = new LevelDB.DB(options, $"/tmp/DBTests-Prefix").Cast <string, int>(); db .Put("a", 1) .Put("aa", 2) .Put("ab", 3) .Put("b", 4) .Put("ba", 5) .Put("bb", 6) .Put("c", 7); Assert.Equal( "a=1;aa=2;ab=3", string.Join(";", db.GetIterable().Prefix("a").Select(kv => $"{kv.Key}={kv.Value}"))); Assert.Equal( "b=4;ab=3;aa=2", string.Join(";", db.GetIterable().Reverse().Prefix("a").Select(kv => $"{kv.Key}={kv.Value}"))); Assert.Equal( "b=4;ab=3;aa=2", string.Join(";", db.GetIterable().Prefix("a").Reverse().Select(kv => $"{kv.Key}={kv.Value}"))); }
public void Snapshot() { using var log = Log(); using LevelDB.DB <string, string> db = GetTestDb(); IIterable <string, string> it = db.GetIterable().Snapshot(); db.Delete("a").Delete("c").Delete("m").Delete("n"); Assert.Equal( "a=1;b=2;c=3;l=12;m=13;n=14;x=24;y=25;z=26", string.Join(";", it.Select(kv => $"{kv.Key}={kv.Value}"))); it.Snapshot(); Assert.Equal( "b=2;l=12;x=24;y=25;z=26", string.Join(";", it.Select(kv => $"{kv.Key}={kv.Value}"))); }