Beispiel #1
0
        public IEnumerable <Triple> O(TripleObject o, Triple c)
        {
            if (c == null)
            {
                return(O(o));
            }

            var oh     = KeySegments.GetNameOKeyObject(_name, o);
            var startS = KeyConfig.ConcatBytes(oh, KeyConfig.ByteZero);
            var endS   = KeyConfig.ConcatBytes(oh, KeyConfig.ByteOne);

            var(_, _, oKey) = new KeySegments(_name, c).GetKeys();
            var continuation = KeyConfig.ConcatBytes(oKey, KeyConfig.ByteOne);

            if (KeyConfig.ByteCompare(continuation, startS) < 0)
            {
                throw new InvalidOperationException("Invalid continuation token. Before range");
            }
            else if (KeyConfig.ByteCompare(continuation, endS) > 0)
            {
                return(Enumerable.Empty <Triple>());
            }

            return(new RocksEnumerable(_db, continuation, endS, (Iterator it) => { return it.Next(); }));
        }
Beispiel #2
0
        public bool MoveNext()
        {
            if (_currentKey == null)
            {
                _currentKey = _start;
                // todo: check
                _iterator = _db.NewIterator();
                _iterator.Seek(_start);
                var firstKey = _iterator.Key();
                if (KeyConfig.ByteCompare(firstKey, _start) < 0)
                {
                    return(false);
                }
            }
            else
            {
                _nextFunction(_iterator);
                _currentKey = _iterator.Key();
            }

            if (!_iterator.Valid())
            {
                return(false);
            }

            var key = _iterator.Key();

            if (KeyConfig.ByteCompare(key, _end) > 0)
            {
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        public IEnumerable <Triple> SP(string s, string p, Triple c)
        {
            var sh     = KeySegments.GetNameSKeySubjectPredicate(_name, s, p);
            var startS = KeyConfig.ConcatBytes(sh, KeyConfig.ByteZero);
            var endS   = KeyConfig.ConcatBytes(sh, KeyConfig.ByteOne);

            // todo: optimize
            var(sKey, _, _) = new KeySegments(_name, c).GetKeys();
            var continuation = KeyConfig.ConcatBytes(sKey, KeyConfig.ByteOne);

            if (KeyConfig.ByteCompare(continuation, startS) < 0)
            {
                throw new InvalidOperationException("Invalid continuation token. Before range");
            }
            else if (KeyConfig.ByteCompare(continuation, endS) > 0)
            {
                return(Enumerable.Empty <Triple>());
            }

            return(new RocksEnumerable(_db, continuation, endS, (Iterator it) => { return it.Next(); }));
        }
Beispiel #4
0
        public IEnumerable <Triple> P(string p, Triple c)
        {
            if (c == null)
            {
                return(P(p));
            }
            var ph     = KeySegments.GetNamePKeyPredicate(_name, p);
            var startS = KeyConfig.ConcatBytes(ph, KeyConfig.ByteZero);
            var endS   = KeyConfig.ConcatBytes(ph, KeyConfig.ByteOne);

            var(_, pKey, _) = new KeySegments(_name, c).GetKeys();
            var continuation = KeyConfig.ConcatBytes(pKey, KeyConfig.ByteOne);

            if (KeyConfig.ByteCompare(continuation, startS) < 0)
            {
                throw new InvalidOperationException("Invalid continuation token. Before range");
            }
            else if (KeyConfig.ByteCompare(continuation, endS) > 0)
            {
                return(Enumerable.Empty <Triple>());
            }

            return(new RocksEnumerable(_db, continuation, endS, (Iterator it) => { return it.Next(); }));
        }