Example #1
0
        public IndexDynamicTest()
        {
            var uniqPath = Path+DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace(":"," ")+ DateTime.Now.Second.ToString()+ @"/";

            Directory.CreateDirectory(uniqPath);
            tableView = new TableView(uniqPath+ "table", TpTableElement);

            tableView.Fill(Enumerable.Range(0, NumberOfRecords).Select(i =>
                (object) (new object[] {i.ToString(), i })));
            // Делаем индекс
            var ha = new IndexHalfkeyImmutable<string>(uniqPath + "dyna_index_str_half")
            {
                Table = tableView,
                KeyProducer = va => (string) ((object[]) (((object[]) va)[1]))[0],
                HalfProducer = k => k.GetHashModifiedBernstein()
            };
            ha.Scale = new ScaleCell(uniqPath + "dyna_index_str_half") {IndexCell = ha.IndexCell};
            ha.Build();
            sIndex = new IndexDynamic<string, IndexHalfkeyImmutable<string>>(true)
            {
                Table = tableView,
                KeyProducer = va => (string) ((object[]) (((object[]) va)[1]))[0],
                IndexArray = ha
            };
            iIndex = new IndexDynamic<int, IIndexImmutable<int>>(true,
                new IndexKeyImmutable<int>(uniqPath + "int", tableView,
                    va => (int) ((object[]) (((object[]) va)[1]))[1],
                    new ScaleCell(uniqPath + "iisndexScale")));

            iIndex.Build();
        }
Example #2
0
 // Построение индексов
 public void BuildIndexes()
 {
     index_person.Build();
     index_photo_doc.Build();
     index_reflected.Build();
     index_in_doc.Build();
     index_person_name.Build();
 }
Example #3
0
        public void Build(IGenerator <List <TripleStrOV> > generator)
        {
            table.Clear();
            table.Fill(new object[0]);

            ng.Build();
            generator.Start(list =>
            {
                IEnumerable <string> ids = list.SelectMany(tri =>
                {
                    IEnumerable <string> iris = new string[] { tri.Subject, tri.Predicate };
                    if (tri.Object.Variant == ObjectVariantEnum.Iri)
                    {
                        iris = iris.Concat(new string[] { ((OV_iri)tri.Object).UriString });
                    }
                    if (tri.Object.Variant == ObjectVariantEnum.OtherIntType)
                    {
                        iris = iris.Concat(new string[] { ((OV_typed)tri.Object).DataType });
                    }
                    return(iris);
                });
                var dictionary = ng.coding_table.InsertPortion(ids);
                foreach (var tri in list)
                {
                    int isubj         = dictionary[tri.Subject];
                    int ipred         = dictionary[tri.Predicate];
                    ObjectVariants ov = tri.Object;
                    if (ov.Variant == ObjectVariantEnum.Iri)
                    {
                        int iobj = dictionary[((OV_iri)ov).UriString];
                        ov       = new OV_iriint(iobj, ng.coding_table.GetStringByCode);
                    }
                    table.TableCell.Root.AppendElement(new object[] { false, new object[] { isubj, ipred, ov.ToWritable() } });
                }
            });

            ng.coding_table.BuildScale();
            table.TableCell.Flush();
            spo_ind.IndexArray.Build();
            po_ind.IndexArray.Build();
            so_ind.IndexArray.Build();
            sp_ind.IndexArray.Build();
            s_ind.IndexArray.Build();
            p_ind.IndexArray.Build();
            o_ind.IndexArray.Build();
            spo_ind.Build();
            po_ind.Build();
            so_ind.Build();
            sp_ind.Build();
            s_ind.Build();
            p_ind.Build();
            o_ind.Build();
        }
Example #4
0
        protected virtual void CreateCoding(int node, int code, Dictionary <int, HashSet <int> > direct)
        {
            codingIndex.Build();
            codingIndex.Table.AppendValue(new object[] { node, code });
            decodingIndex.Table.AppendValue(new object[] { node, code });


            int i = 1;

            if (direct.ContainsKey(node))
            {
                foreach (var child in direct[node])
                {
                    CreateCoding(child, code * maxChildrenCount + (i++), direct);
                }
            }
        }