public void Build(IEnumerable <Tuple <int, string, string> > tripleFlow)
        {
            table.Clear();
            table.Fill(new object[0]);

            File.Delete(predicatemappingPath);
            int portionConter = 0;

            object[] buffer = new object[portion];
            ps_index.index_arr.FillInit();
            po_index.index_arr.FillInit();
            TableRow[] tableRows;
            foreach (var triple in tripleFlow)
            {
                if (portionConter == portion)
                {
                    tableRows = table.Add(buffer).ToArray();
                    ps_index.index_arr.FillPortion(tableRows);
                    po_index.index_arr.FillPortion(tableRows);
                    Array.Clear(buffer, 0, portion);
                    portionConter = 0;
                }
                int pCode;
                if (!predicatemapping.TryGetValue(triple.Item2, out pCode))
                {
                    predicatemapping.Add(triple.Item2, pCode = predicatemapping.Count);
                }
                buffer[portionConter] = new object[] { triple.Item1, pCode, triple.Item3 };
                portionConter++;
            }
            tableRows = table.Add(buffer).ToArray();
            ps_index.index_arr.FillPortion(tableRows);
            po_index.index_arr.FillPortion(tableRows);
            table.TableCell.Flush();
            ps_index.index_arr.FillFinish();
            po_index.index_arr.FillFinish();
            ps_index.Build();
            po_index.Build();
            using (StreamWriter file = new StreamWriter(predicatemappingPath))
                foreach (var i in predicatemapping)
                {
                    file.WriteLine(i.Key);
                }
            po_index.CreateDiscaleDictionary();
            ps_index.CreateDiscaleDictionary();
        }
Exemple #2
0
        public CascadingTest()
        {
            var uniqPath = Path+DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace(":"," ")+DateTime.Now.Millisecond+"/";//      Directory.CreateDirectory(uniqPath);
            Directory.CreateDirectory(uniqPath);
            tableView = new TableView(uniqPath + "table", TpTableElement);
             index = new IndexCascadingDynamic<string>(uniqPath + "cascading index", tableView,
                    row => (int) ((object[])((object[])row)[1])[0],
                    row => (string)((object[])((object[])row)[1])[1],
                    i => i.GetHashModifiedBernstein());

                tableView.Fill(
                    Enumerable.Range(0, NumberOfRecords).SelectMany(i =>
                    Enumerable.Range(0, NumberOfRecords).Select(j =>
                        (object) (new object[] {i, j.ToString()}))));

                index.Build();

            index.CreateDiscaleDictionary();
        }
        public SimpleTripleStore(string path, int portion)
        {
            this.portion = portion;

            table = new TableView(path + "table.pac", new PTypeRecord(new NamedType("s", new PType(PTypeEnumeration.integer)),
                                                                      new NamedType("p", new PType(PTypeEnumeration.integer)),
                                                                      new NamedType("o", new PType(PTypeEnumeration.sstring))));
            ps_index = new IndexCascadingDynamic <int>(path + "ps_index",
                                                       table,
                                                       ob => (int)((object[])((object[])ob)[1])[1],
                                                       ob => (int)((object[])((object[])ob)[1])[0],
                                                       i => i);
            po_index = new IndexCascadingDynamic <string>(path + "po_index",
                                                          table,
                                                          ob => (int)((object[])((object[])ob)[1])[1],
                                                          ob => (string)((object[])((object[])ob)[1])[2],
                                                          s => s.GetHashSpooky());
            predicatemappingPath = path + "predicates";
            if (File.Exists(predicatemappingPath))
            {
                using (StreamReader file = new StreamReader(predicatemappingPath))
                    while (!file.EndOfStream)
                    {
                        predicatemapping.Add(file.ReadLine(), predicatemapping.Count);
                    }
            }
            if (table.TableCell.IsEmpty)
            {
                return;
            }
            po_index.CreateDiscaleDictionary();
            ps_index.CreateDiscaleDictionary();
            table.Warmup();
            po_index.Warmup();
            ps_index.Warmup();
        }
Exemple #4
0
 public void Start()
 {
     ps_index.CreateDiscaleDictionary();
     po_index.CreateDiscaleDictionary();
 }