Esempio n. 1
0
        private async Task WriteWithMappingTest(int start, int count)
        {
            var sth = new Stopwatch();

            sth.Start();

            var table = _hbaseHelper.GetTableName <Student>();

            var cancel = new CancellationToken();

            var range    = Enumerable.Range(start, count).ToList();
            var students = range
                           .Select(t => new Student {
                RowKey = t.ToString().Reverse2String(), Name = $"hsx{t}", Age = t
            })
                           .ToList();

            students.Last().Hobbies = new List <string> {
                "running", "dance"
            };
            students.Last().IsWork = true;
            Console.WriteLine($"\tcreate class,count:{students.Count}, time: {sth.Elapsed}");

            sth.Restart();
            var batchs = _HbaseParser.ToBatchMutations(students);

            Console.WriteLine($"\tParser Class To BatchMutation Async,count:{batchs.Count}, time: {sth.Elapsed}");

            sth.Restart();
            await _client.mutateRowsAsync(table.ToBytes(), batchs, null, cancel);

            Console.WriteLine($"\tmutateRowsAsync,count:{batchs.Count}, time: {sth.Elapsed}");
        }