コード例 #1
0
        //// Идея хорошая, но надо менять схему реализации
        //private GroupedEntities getable;
        //private Dictionary<int, object[]> geHash;

        public ColumnsStore(string path, IStringIntCoding entityCoding, PredicatesCoding predicatesCoding, NameSpaceStore nameSpaceStore, LiteralStoreAbstract literalStore)
            : base(path, entityCoding, predicatesCoding, nameSpaceStore, literalStore)

        {
            InitTypes();
            otriplets_op_filePath         = path + "otriples_op.pac";
            otriples_filePath             = path + "otriples.pac";
            dtriples_filePath             = path + "dtriples.pac";
            dataPredicatesColumn_filePath = path + "dataPredicatesColumn.pac";
            objPredicatesColumn_filePath  = path + "objPredicatesColumn.pac";
            invPredicatesColumn_filePath  = path + "invPredicatesColumn.pac";
            invSubjectsColumn_filePath    = path + "invSubjectsColumn.pac";
            objectsColumn_filePath        = path + "objectsColumn.pac";
            dataColumn_filePath           = path + "dataColumn.pac";


            Open(File.Exists(otriples_filePath));



            ewt = new EntitiesWideTable(path, 3);
            //ewtHash = new EntitiesMemoryHashTable(ewt);
            // ewtHash.Load();



            //getable = new GroupedEntities(path); // Это хорошая идея, но нужно менять схему реализации
            //getable.CheckGroupedEntities();
            //geHash = getable.GroupedEntitiesHash();
        }
コード例 #2
0
 protected RDFIntStoreAbstract(string path, IStringIntCoding entityCoding, PredicatesCoding predicatesCoding,
                               NameSpaceStore nameSpaceStore, LiteralStoreAbstract literalStore)
     : this(entityCoding, predicatesCoding, nameSpaceStore, literalStore, new ScaleCell(path))
 {
     // TODO: Complete member initialization
     this.path = path;
 }
コード例 #3
0
        public virtual void MakeIndexed()
        {
            EntityCoding.MakeIndexed();
            PredicatesCoding.MakeIndexed();
            NameSpaceStore.Flush();
            Scale.Flush();

            LiteralStore.Flush();
        }
コード例 #4
0
 public virtual void Clear()
 {
     LiteralStore.Clear();
     EntityCoding.Clear();
     PredicatesCoding.Clear();
     NameSpaceStore.Clear();
     LiteralStore.InitConstants(NameSpaceStore);
     Scale.Clear();
 }
コード例 #5
0
 public virtual void WarmUp()
 {
     LiteralStore.WarmUp();
     EntityCoding.WarmUp();
     PredicatesCoding.WarmUp();
     if (Scale.Filescale)
     {
         Scale.WarmUp();
     }
     //    NameSpaceStore.WarmUp();
 }
コード例 #6
0
 protected RDFIntStoreAbstract(IStringIntCoding entityCoding, PredicatesCoding predicatesCoding, NameSpaceStore nameSpaceStore, LiteralStoreAbstract literalStore,
                               ScaleCell scale)
 {
     this.literalStore     = literalStore;
     this.entityCoding     = entityCoding;
     this.nameSpaceStore   = nameSpaceStore;
     this.predicatesCoding = predicatesCoding;
     this.scale            = scale;
     if (!scale.Cell.IsEmpty)
     {
         scale.CalculateRange();
     }
 }
コード例 #7
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="path">директория базы данных с (обратным) слешем</param>
        /// <param name="literalStore"></param>
        /// <param name="entityCoding"></param>
        /// <param name="nameSpaceStore"></param>
        /// <param name="predicatesCoding"></param>
        public RdfTrees(string path, IStringIntCoding entityCoding, PredicatesCoding predicatesCoding, NameSpaceStore nameSpaceStore, LiteralStoreAbstract literalStore)
            : base(path, entityCoding, predicatesCoding, nameSpaceStore, literalStore)
        {
            // Построим типы
            InitTypes();
            // Создадим или откроем ячейки
            this.entitiesTree = new PxCell(tp_entitiesTree, entitiesTreePath = path + "entitiesTree.pxc", false);
            //this.literalsTree = new PxCell(tp_literalsTree, path + "literalsTree.pxc", false);
            //  this.dtriples = new PaCell(tp_dtriple_spf, path + "dtriples.pac", false); // Это вместо не работающего дерева литералов       }


            otriples = new PaCell(tp_otriple_seq, path + "otriples.pac", File.Exists(path + "otriples.pac"));

            otriples.Close();
        }
コード例 #8
0
        //// Идея хорошая, но надо менять схему реализации
        //private GroupedEntities getable;
        //private Dictionary<int, object[]> geHash;

        public TripleStoreInt(string path, IStringIntCoding entityCoding, PredicatesCoding predicatesCoding, NameSpaceStore nameSpaceStore, LiteralStoreAbstract literalStore)
            : base(path, entityCoding, predicatesCoding, nameSpaceStore, literalStore)
        {
            this.path = path;

            InitTypes();
            otriplets_op_filePath = path + "otriples_op.pac";
            otriples_filePath     = path + "otriples.pac";
            dtriples_filePath     = path + "dtriples_spf.pac";

            if (File.Exists(otriples_filePath))
            {
                Open(true);
            }
            else
            {
                otriples    = new PaCell(tp_triple_seq_two, otriples_filePath, false);
                otriples_op = new PaCell(tp_triple_seq_two, otriplets_op_filePath, false);
                dtriples_sp = new PaCell(tp_dtriple_spf_two, dtriples_filePath, false);
            }

            if (!Scale.Cell.IsEmpty)
            {
                Scale.CalculateRange();
            }


            ewt = new EntitiesWideTable(path, 3);
            //ewtHash = new EntitiesMemoryHashTable(ewt);
            // ewtHash.Load();



            //getable = new GroupedEntities(path); // Это хорошая идея, но нужно менять схему реализации
            //getable.CheckGroupedEntities();
            //geHash = getable.GroupedEntitiesHash();
        }
コード例 #9
0
        public void Compress(PaCell dtriplets, PredicatesCoding predicatesCoding)
        {
            stringsArhive.WriteCell();
            PaEntry paEntry = stringsCell.Root.Element(0);

            foreach (var dtripletElement in dtriplets.Root.Elements())
            {
                int predicateCode = (int)dtripletElement.Field(1).Get();
                if (predicatesCoding.LiteralVid[predicateCode] == LiteralVidEnumeration.text)
                {
                    PaEntry offsetElement = dtripletElement.Field(2);
                    long    offset        = (long)offsetElement.Get();
                    paEntry.offset = offset;
                    object[] stri_lang = (object[])paEntry.Get();

                    offsetElement.Set(
                        StringsArchedCell.Root.AppendElement(new object[] {
                        Enumerable.Cast <object>(stringsArhive.Compress((string)stri_lang[0])).ToArray(),
                        Enumerable.Cast <object>(stringsArhive.Compress((string)stri_lang[01])).ToArray()
                    }));
                }
            }
            StringsArchedCell.Flush();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: agmarchuk/PolarDemo
        private static void Test()
        {
            string path = (@"C:\Users\Admin\Source\Repos\PolarDemo\Databases\" + Millions + @"mln\");

            var nameSpaceStore = new NameSpaceStore(path);

            StringIntMD5RAMUnsafe stringIntMd5RamUnsafe = new StringIntMD5RAMUnsafe(path);
            PredicatesCoding      predicatesCoding      = new PredicatesCoding(path);
            RDFIntStoreAbstract   ts = new CashingTripleStoreInt(
                new RdfTrees(path,
                             // new CasheCoding(new StringIntCoding(path+"entitiesCodes")),
                             stringIntMd5RamUnsafe,
                             predicatesCoding,
                             nameSpaceStore,
                             new LiteralStore(path, nameSpaceStore)));
            //     bool load = false;

            bool load = false;

            using (StreamWriter wr = new StreamWriter(@"..\..\output.txt", true))
                wr.WriteLine("millions " + Millions);
            DateTime start = DateTime.Now;
            long     spent = 0;

            if (load)
            {
                ts.LoadTurtle(@"C:\deployed\" + Millions + "M.ttl", useBuffer: false);
            }
            else
            {
                var obj2      = stringIntMd5RamUnsafe.GetCode(nameSpaceStore.GetShortFromFullOrPrefixed("<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19>"));
                var obj1      = stringIntMd5RamUnsafe.GetCode(nameSpaceStore.GetShortFromFullOrPrefixed("<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8>"));
                var pred      = predicatesCoding.GetCode(nameSpaceStore.GetShortFromFullOrPrefixed("<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature>"));
                var triplets1 = ts.GetSubjectByObjPred(obj1, pred);
                var triplets2 = ts.GetSubjectByObjPred(obj2, pred);
                foreach (var i in triplets1.Where(i => triplets2.Contains(i)))
                {
                    Console.WriteLine("sdfg");
                }


                for (int i = 0; i < stringIntMd5RamUnsafe.Count; i++)
                {
                    if (
                        ts.GetObjBySubj(i)
                        .Any(
                            keyValuePair =>
                            !ts.GetSubjectByObjPred(keyValuePair.Key, keyValuePair.Value).Contains(i)))
                    {
                        throw new Exception();
                    }
                }
                return;

                ts.WarmUp();
                spent = (DateTime.Now - start).Ticks / 10000;
                using (StreamWriter wr = new StreamWriter(@"..\..\output.txt", true))
                    wr.WriteLine("warm up " + spent + " мс.");
                RunBerlinsWithConstants(ts);
                //   RunBerlinsParameters(ts);
            }
            spent = (DateTime.Now - start).Ticks / 10000;
            using (StreamWriter wr = new StreamWriter(@"..\..\output.txt", true))
                wr.WriteLine("total " + spent + " мс.");
            //  (ts as TracingTripleStoreInt).x.Save((ts as TracingTripleStoreInt).xPath);
        }
コード例 #11
0
 public int CodePredicateFullOrShort(string name)
 {
     return(PredicatesCoding.GetCode(NameSpaceStore.GetShortFromFullOrPrefixed(name)));
 }
コード例 #12
0
 public int CodePredicateFullName(string name)
 {
     return(PredicatesCoding.GetCode(NameSpaceStore.FromFullName(name.Substring(1, name.Length - 2))));
 }
コード例 #13
0
 public string DecodePredicateFullName(int code)
 {
     return(NameSpaceStore.DecodeNsShortName(PredicatesCoding.GetName(code)));
 }