コード例 #1
0
        public static NodeGeneratorInt Create(INametable codingTable)
        {
            var ng = new NodeGeneratorInt(codingTable);

            ng.SpecialTypes = new SpecialTypesClass(ng);
            return(ng);
        }
コード例 #2
0
        public static void TestLoad(TestContext context)
        {
            var path = "mag_data/";

            _fileStream1 = File.Open(path + "name table ids.pac", FileMode.OpenOrCreate);
            _fileStream2 = File.Open(path + "name table off.pac", FileMode.OpenOrCreate);
            _magnt       = new Mag_Nametable(_fileStream1, _fileStream2);
        }
コード例 #3
0
ファイル: Mag_Library.cs プロジェクト: Sergey303/RDF-Store
        public static void TestNameTable(INametable nt)
        {
            System.Diagnostics.Stopwatch T = new System.Diagnostics.Stopwatch();
            Random rnd    = new Random();
            string prefix = "PupkinQQUTEUJSHJDHJGFHSGDHWTYTHXCGHGCHSHSDYSTDSHSGHSG_";

            int max   = 1_000_000;
            int total = 7 * max;

            T.Restart();
            for (int i = 0; i < total; i++)
            {
                string scode = prefix + rnd.Next(max);
                var    code  = nt.GetSetCode(scode);
            }
            T.Stop();
            Console.WriteLine($" get set {total} codes for new strings time {T.ElapsedMilliseconds}. Nametable Count={nt.LongCount()}");


            int nprobes = 1_000_000;

            T.Restart();
            int unknown = 0;

            for (int j = 0; j < nprobes; j++)
            {
                string scode = prefix + rnd.Next(max);
                int    code  = nt.GetCode(scode);
                if (code == Int32.MinValue)
                {
                    unknown++;
                }
            }
            T.Stop();
            Console.WriteLine($" get {nprobes} codes. time {T.ElapsedMilliseconds}. {unknown} are unknown");

            T.Restart();
            unknown = 0;
            int maxcode = (int)nt.LongCount() * 11 / 10; // лишние для тестирования отсутствующих кодов

            for (int j = 0; j < nprobes; j++)
            {
                int    code  = rnd.Next(maxcode);
                string scode = nt.GetString(code);
                if (scode == null)
                {
                    unknown++;
                }
            }
            T.Stop();
            Console.WriteLine($" get {nprobes} string from codes. time {T.ElapsedMilliseconds}. {unknown} are unknown");
        }
コード例 #4
0
ファイル: Store.cs プロジェクト: Sergey303/RDF-Store
        // Конструктор
        public Store(Stream tab_stream, Stream index1, Stream index2, Stream index3, INametable nametable)
        {
            this.nametable = nametable;
            this.table     = new TableView(
                tab_stream,
                PolarExtension.GetPolarType <IRecord <int, int, IUnion <int, string> > >());

            IndexViewImmutable <spo> index_spo_i =
                new IndexViewImmutable <spo>(index1)
            {
                KeyProducer =
                    ob => new spo(
                        ob.CastRow <object, object>().Item2
                        .CastRow <int, int, object[]>()),
                Table = this.table,
                Scale = null,
            };

            this.index_spo = new IndexDynamic <spo, IndexViewImmutable <spo> >(true, index_spo_i);
            this.table.RegisterIndex(this.index_spo);

            IndexViewImmutable <ops> index_ops_i =
                new IndexViewImmutable <ops>(index2)
            {
                KeyProducer =
                    ob => new ops(
                        ob.CastRow <object, object>().Item2
                        .CastRow <int, int, object[]>()),
                Table = this.table,
                Scale = null,
            };

            this.index_ops = new IndexDynamic <ops, IndexViewImmutable <ops> >(true, index_ops_i);
            this.table.RegisterIndex(this.index_ops);

            IndexViewImmutable <int> index_p_i =
                new IndexViewImmutable <int>(index3)
            {
                KeyProducer =
                    ob => (int)ob.CastRow <object, object[]>().Item2[1],
                Table = this.table,
                Scale = null
            };

            this.index_p = new IndexDynamic <int, IndexViewImmutable <int> >(true, index_p_i);
            this.table.RegisterIndex(this.index_p);
            if (this.table.Count() > 0)
            {
                this.table.BuildIndexes();
            }
        }
コード例 #5
0
        public void IntegerSequenceCreateSearch()
        {
            var uniqPath = Path+DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace(":"," ")+DateTime.Now.Millisecond+"/";
            Directory.CreateDirectory(uniqPath);

            nameTable = new NametableLinearBuffered(uniqPath);

            Stopwatch timer = new Stopwatch();
            timer.Start();

            nameTable.Load(NumberOfRecords, Enumerable.Range(0, NumberOfRecords).Select(i => i.ToString()));
            timer.Stop();
            Console.WriteLine(timer.Elapsed.TotalSeconds);
            var random = new Random();
            var r = random.Next(NumberOfRecords);
            timer.Restart();
            nameTable.GetCode(r.ToString());
            timer.Stop();
            Console.WriteLine("search " + r +" "+ timer.Elapsed.TotalMilliseconds);

              //  SearchIntSequence();

            //nameTable.Clear();
            ////nameTable.Load(NumberOfRecords, Enumerable.Empty<string>());

            //nameTable.InsertPortion(Enumerable.Range(0, NumberOfRecords/2).Select(i => i.ToString()));
            //Console.WriteLine("df");
            //nameTable.InsertPortion(Enumerable.Range(NumberOfRecords / 2, NumberOfRecords).Select(i => i.ToString()));
            ////foreach (var s in Enumerable.Range(0, NumberOfRecords).Select(i => i.ToString()))
            //{
            //    nameTable.GetSetCode(s);
            //}

            SearchIntSequence();

            //     nameTable.Clear();

            //   SearchIntSequence();
        }
コード例 #6
0
 public NodeGeneratorInt(INametable codingTable)
 {
     coding_table = codingTable;
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: Sergey303/RDF-Store
        static void TestNameTable(INametable nt)
        {
            // int startCapacity=1000*1000;
            int allCount = 10 * 1000 * 1000;//startCapacity+1000;//1001000
            //int firstPortionSize = 1000;
            //int portionSize = 100*1000;
            //int portionsCount = 10;
            int lastPortionAddByGetset = allCount;//1000;

            var allStrings = new List <string>(allCount);

            List <string> RandomStringsList(int count)
            {
                return(Enumerable.Repeat(0, count).Select(i => Guid.NewGuid().ToString())
                       .ToList());
            }

            var newstrings = RandomStringsList(lastPortionAddByGetset);

            allStrings.AddRange(newstrings);
            T.Restart();
            foreach (var newstring in newstrings)
            {
                var code = nt.GetSetCode(newstring);
            }
            T.Stop();
            Console.WriteLine($" get set {newstrings.Count} codes for new strings time {T.ElapsedMilliseconds}");


            //get code test
            int getCodeCalls          = 1000 * 1000;
            var randomExistingStrings = Enumerable.Range(0, getCodeCalls)
                                        .Select(j => Random.Next(getCodeCalls))
                                        .Select(randomI => allStrings[randomI])
                                        .ToList();

            T.Restart();
            for (int j = 0; j < getCodeCalls; j++)
            {
                nt.GetCode(randomExistingStrings[j]);
            }
            T.Stop();
            Console.WriteLine($" get {getCodeCalls} existing codes time {T.ElapsedMilliseconds}");

            var randomNotExistingStrings = RandomStringsList(getCodeCalls);

            T.Restart();
            for (int j = 0; j < getCodeCalls; j++)
            {
                nt.GetCode(randomNotExistingStrings[j]);
            }
            T.Stop();
            Console.WriteLine($" get {getCodeCalls} not existing codes time {T.ElapsedMilliseconds}");


            //get string test
            //int getStringCalls = 1000 * 1000;
            var randomExistingCodes = Enumerable.Range(0, getCodeCalls)
                                      .Select(j => Random.Next(getCodeCalls))
                                      .Select(randomI => allStrings[randomI])
                                      .Select(nt.GetCode)
                                      .ToList();

            T.Restart();
            for (int j = 0; j < getCodeCalls; j++)
            {
                nt.GetCode(randomExistingStrings[j]);
            }
            T.Stop();
            Console.WriteLine($" get {getCodeCalls} existing strings time {T.ElapsedMilliseconds}");
        }
コード例 #8
0
 public NodeGeneratorInt(string path)
 {     
     coding_table=new NametableLinearBuffered(path);
     
 }