Ejemplo n.º 1
0
        public override IEnumerable <Literal> GetDataBySubjPred(int subj, int pred)
        {
            if (subj == Int32.MinValue || pred == Int32.MinValue)
            {
                return(Enumerable.Empty <Literal>());
            }
            var offsets = TakeValuesByPrevaricate <long>(subj, pred, 2, dataPredicates, data);

            return(offsets
                   .Select(offset => LiteralStore.Read(offset, PredicatesCoding.LiteralVid[pred]))
                   .ToArray());
        }
Ejemplo n.º 2
0
        public IEnumerable <Literal> GetDatInDiapason(Diapason di, int pred)
        {
            Diapason internal_diap = dtriples_sp.Root.BinarySearchDiapason(di.start, di.numb, ent =>
            {
                return(((int)ent.Field(1).Get()).CompareTo(pred));
            });

            return(dtriples_sp.Root.ElementValues(internal_diap.start, internal_diap.numb)
                   .Cast <object[]>()
                   .Select(en => (long)en[1])
                   .Select(offset => LiteralStore.Read(offset, PredicatesCoding.LiteralVid[pred])));
        }
Ejemplo n.º 3
0
        public override IEnumerable <KeyValuePair <Literal, int> > GetDataBySubj(int subj)
        {
            if (subj == Int32.MinValue)
            {
                return(Enumerable.Empty <KeyValuePair <Literal, int> >());
            }


            object[] diapason = GetDiapasonFromHash(subj, 2);

            return(diapason == null
                ? new KeyValuePair <Literal, int> [0]
                : dtriples_sp.Root.ElementValues((long)diapason[0], (long)diapason[1])
                   .Cast <object[]>()
                   .Select(row => new KeyValuePair <Literal, int>(LiteralStore.Read((long)row[1], PredicatesCoding.LiteralVid[(int)row[0]]), (int)row[0])).ToArray());
        }
Ejemplo n.º 4
0
        public override IEnumerable <KeyValuePair <Literal, int> > GetDataBySubj(int subj)
        {
            if (subj == Int32.MinValue)
            {
                return(Enumerable.Empty <KeyValuePair <Literal, int> >());
            }


            object[] diapason = GetDiapasonFromHash(subj, 2);

            var values = data.Root.ElementValues((long)diapason[0], (long)diapason[1])
                         .Cast <long>()
                         .ToArray();

            return(dataPredicates.Root.ElementValues((long)diapason[0], (long)diapason[1])
                   .Cast <int>()
                   .Select((pred, i) => new KeyValuePair <long, int>(values[i], pred))
                   .ToArray()
                   .Select(pair => new KeyValuePair <Literal, int>(LiteralStore.Read(pair.Key, PredicatesCoding.LiteralVid[pair.Value]), pair.Value)));
        }
Ejemplo n.º 5
0
        public override IEnumerable <Literal> GetDataBySubjPred(int subj, int pred)
        {
            if (subj == Int32.MinValue || pred == Int32.MinValue)
            {
                return(Enumerable.Empty <Literal>());
            }


            object[] diapason = GetDiapasonFromHash(subj, 2);

            return(diapason == null
                ? new Literal[0]
                : dtriples_sp.Root.ElementValues((long)diapason[0], (long)diapason[1])
                   .Cast <object[]>()
                   .SkipWhile(entry => pred != (int)entry[0])
                   .TakeWhile(entry => pred == (int)entry[0])
                   .Select(en => (long)en[1])
                   .Select(offset => LiteralStore.Read(offset, PredicatesCoding.LiteralVid[pred]))
                   .ToArray());
        }
Ejemplo n.º 6
0
        public override IEnumerable <Literal> GetDataBySubjPred(int subj, int pred)
        {
            if (subj == Int32.MinValue || pred == Int32.MinValue)
            {
                return(new Literal[0]);
            }
            var rec_ent = this.entitiesTree.Root.Element(subj);

            ; //.BinarySearchFirst(ent => ((int) ent.Field(0).Get()).CompareTo(subj));
            if (rec_ent.IsEmpty)
            {
                return(new Literal[0]);
            }
            var pairs = (object[])rec_ent.Field(1).Get();
            var literalVidEnumeration = PredicatesCoding.LiteralVid[pred];

            return(pairs.Cast <object[]>()
                   .Where(pair => (int)pair[0] == pred)
                   .Select(pair => (long)pair[1])
                   .Select(l => LiteralStore.Read(l, literalVidEnumeration))
                   .ToArray());
        }
Ejemplo n.º 7
0
        public override IEnumerable <KeyValuePair <Literal, int> > GetDataBySubj(int subj)
        {
            if (subj == Int32.MinValue)
            {
                return(new KeyValuePair <Literal, int> [0]);
            }
            var rec_ent = this.entitiesTree.Root.Element(subj);

            //BinarySearchFirst(ent => ((int) ent.Field(0).Get()).CompareTo(subj));
            //if (rec_ent.IsEmpty) pd = new KeyValuePair<Literal, int>[0];else

            object[] pairs = (object[])rec_ent.Field(1).Get();
            //   PaEntry dtriple_entry = dtriples.Root.Element(0);
            return(pairs.Cast <object[]>()
                   .Select(pair =>
            {
                var offset1 = (long)pair[1];
                var literalObj = LiteralStore.Read(offset1, PredicatesCoding.LiteralVid[(int)pair[0]]);
                return new KeyValuePair <Literal, int>(literalObj, (int)pair[0]);
            })
                   .ToArray());
        }