Example #1
0
        protected string GenerateSelectQuery(bool single = true, int operationCase = 1)
        {
            int    a = single ? rand.Next(0, single_size) : rand.Next(single_size, single_size + multiple_size / conf.multiple);
            string operation;

            switch (operationCase)
            {
            case 2:
                operation = "a + b";
                break;

            case 3:
                operation = "a * c";
                break;

            case 4:
                operation = "a + a * c + b";
                break;

            default:
                operation = "a";
                break;
            }
            return(QueryConstructor.ConstructSelectQuery(operation, a));
        }
Example #2
0
        protected string GenerateUpdateQuery(bool single = true)
        {
            int       a    = single ? rand.Next(0, single_size) : rand.Next(single_size, single_size + multiple_size / conf.multiple);
            ArrayList data = DataGenerator.GetDataRows(1)[0]; // get from random range as we update a to the same value

            return(QueryConstructor.ConstructUpdateQuery(a, data));
        }
Example #3
0
        protected string GenerateInsertQuery(int numberOfRecords)
        {
            List <ArrayList> data  = DataGenerator.GetDataRows(numberOfRecords);
            string           query = QueryConstructor.ConstructInsertQuery("t1", data);

            return(query);
        }
Example #4
0
        protected string GenerateSelectJoinQuery(int size, bool single = true)
        {
            int single_size   = 4 * size / 10;
            int multiple_size = 4 * size / 10;
            int a             = single ? rand.Next(0, single_size) : rand.Next(single_size, single_size + multiple_size / conf.multiple);

            return(QueryConstructor.ConstructSelectJoinQuery(a));
        }
Example #5
0
        protected string GenerateSelectWithoutQuery(bool single = true)
        {
            int a = single ? rand.Next(0, single_size) : rand.Next(single_size, single_size + multiple_size / conf.multiple);

            switch (conf.ServerType)
            {
            case MSSQL:
                return(QueryConstructor.ConstructMsSelectWithoutQuery(a));

            case MYSQL:
            case PGSQL:
                return(QueryConstructor.ConstructMySelectWithoutQuery(a));
            }
            return(null);
        }
Example #6
0
        protected string GenerateEncryptQuery(bool check = false, int typeCase = 1)
        {
            string type;

            switch (typeCase)
            {
            case 1:
                type = "STORE";
                break;

            case 2:
                type = "SEARCH";
                break;

            case 3:
                type = "RANGE";
                break;

            case 4:
                type = "ADDITION";
                break;

            case 5:
                type = "MULTIPLICATION";
                break;

            case 6:
                type = "SEARCH, STORE, RANGE, ADDITION, MULTIPLICATION";
                break;

            case 7:
                type = "WILDCARD";
                break;

            default:
                type = "STORE";
                break;
            }
            return(QueryConstructor.ConstructEncryptQuery(check, type));
        }
Example #7
0
 protected string GenerateUpdateKeyQuery(bool check = false)
 {
     return(QueryConstructor.ConstructUpdateKeyQuery(check));
 }
Example #8
0
 protected string GenerateDecryptQuery(bool check = false, bool str = false)
 {
     return(QueryConstructor.ConstructDecryptQuery(check, str));
 }
Example #9
0
        protected string GenerateDeleteQuery(bool single = true)
        {
            int a = single ? rand.Next(0, single_size) : rand.Next(single_size, single_size + multiple_size / conf.multiple);

            return(QueryConstructor.ConstructDeleteQuery(a));
        }
Example #10
0
        protected void SetupForSelect(int size, string table = "t1")
        // populate tables with 500M rows
        {
            single_size   = 4 * size / 10;
            multiple_size = 6 * size / 10;
            ConcurrentQueue <string> cq = new ConcurrentQueue <string>();

            // populate single range
            int batch_size = 1000;

            while (size % batch_size != 0)
            {
                batch_size /= 10;
            }

            for (int i = 0; i < single_size / batch_size; i++)
            {
                string query = QueryConstructor.ConstructInsertQuery(table,
                                                                     DataGenerator.GetDataRowsForSelect(i * batch_size, batch_size: batch_size));
                // execute query
                cq.Enqueue(query);
            }

            while ((multiple_size / conf.multiple) % batch_size != 0)
            {
                batch_size /= 10;
            }
            // populate multiple range
            for (int m = 0; m < conf.multiple; m++)
            {
                for (int i = 0; i < multiple_size / (conf.multiple * batch_size); i++)
                {
                    string query = QueryConstructor.ConstructInsertQuery(table,
                                                                         DataGenerator.GetDataRowsForSelect(single_size + i * batch_size, batch_size: batch_size));
                    // execute query
                    cq.Enqueue(query);
                }
            }

            var watch       = Stopwatch.StartNew();
            var insertCount = 0;

            void startWorker()
            {
                DataBase database = new DataBase();

                while (cq.TryDequeue(out string query))
                {
                    database.ExecuteNonQuery(query);
                    insertCount++;

                    // To keep alive the terminal
                    if (insertCount % 50 == 0)
                    {
                        Console.WriteLine("-");
                    }
                }
                database.Close();
            }

            Parallel.For(0, 5, i => startWorker());

            watch.Stop();
            Console.WriteLine("====Time of INSERT {0} records: {1}====\n", size, watch.Elapsed.ToString(@"hh\:mm\:ss\.fff"));
        }