public bool Exists(string s, string p, TripleObject o) { var keySegments = new KeySegments(_name, s, p, o); var oPrefix = keySegments.GetOPrefix(); var start = KeyConfig.ConcatBytes(oPrefix, KeyConfig.ByteZero); var end = KeyConfig.ConcatBytes(oPrefix, KeyConfig.ByteOne); var oEnumerable = new RocksEnumerable(_db, start, end, (it) => it.Next()); return(oEnumerable.Any()); }
public IEnumerable <string> P() { var pPrefix = KeySegments.GetNamePPredicate(Name); var startP = KeyConfig.ConcatBytes(pPrefix, KeyConfig.ByteZero); var endP = KeyConfig.ConcatBytes(pPrefix, KeyConfig.ByteOne); var predicates = new RocksEnumerable(_db, startP, endP, (it) => { var key = it.Key(); var splits = KeyConfig.Split(key); var nextKey = KeyConfig.ConcatBytes(splits[0], KeyConfig.ByteZero, splits[1], KeyConfig.ByteOne); return(it.Seek(nextKey)); }).Select(x => x.Predicate); return(predicates); }
IEnumerator <IGrouping <string, TripleObject> > IEnumerable <IGrouping <string, TripleObject> > .GetEnumerator() { var predicates = new RocksEnumerable(_db, _start, _end, (it) => { var key = it.Key(); var splits = KeyConfig.Split(key); var nextKey = KeyConfig.ConcatBytes(splits[0], KeyConfig.ByteZero, splits[1], KeyConfig.ByteZero, splits[2], KeyConfig.ByteOne); return(it.Seek(nextKey)); }).Select(x => x.Predicate); foreach (var p in predicates) { yield return(new RocksPredicateGrouping(_db, _name, _s, p)); } }
public IEnumerator <TripleObject> GetEnumerator() { var sBytes = Hash($"{_name}.S"); var sh = Hash(_s); var ph = Hash(_p); var start = KeyConfig.ConcatBytes(sBytes, KeyConfig.ByteZero, sh, KeyConfig.ByteZero, ph, KeyConfig.ByteZero); var end = KeyConfig.ConcatBytes(sBytes, KeyConfig.ByteZero, sh, KeyConfig.ByteZero, ph, KeyConfig.ByteOne); var baseKey = $"{_name}.S.{Hash(_s)}.{Hash(_p)}"; IEnumerable <Triple> idEnum = new RocksEnumerable(_db, start, end, (iterator) => { return(iterator.Next()); }); foreach (var item in idEnum) { yield return(item.Object); } }
public IEnumerable <IGrouping <string, IGrouping <string, TripleObject> > > GetGroupings() { var nameBytes = KeySegments.GetNameSKey(Name); var start = KeyConfig.ConcatBytes(nameBytes, KeyConfig.ByteZero); var end = KeyConfig.ConcatBytes(nameBytes, KeyConfig.ByteOne); var subjects = new RocksEnumerable(_db, start, end, (it) => { var key = it.Key(); var splits = KeyConfig.Split(key); var nextKey = KeyConfig.ConcatBytes(splits[0], KeyConfig.ByteZero, splits[1], KeyConfig.ByteOne); return(it.Seek(nextKey)); }).Select(x => x.Subject); foreach (var s in subjects) { var sh = KeySegments.GetNameSKeySubject(Name, s); var startS = KeyConfig.ConcatBytes(sh, KeyConfig.ByteZero); var endS = KeyConfig.ConcatBytes(sh, KeyConfig.ByteOne); yield return(new RocksSubjectGrouping(_db, Name, s, startS, endS)); } }