Example #1
0
        public void ScanTableAccrossInstancesAsync()
        {
            if (IsThrift)
            {
                return; // TODO, check what is wrong
            }

            InitializeTableData(tableA);
            InitializeTableData(tableB);

            var c = 0;

            using (var asyncResult = new AsyncResult(
                       (ctx, _cells) =>
            {
                foreach (var _cell in _cells)
                {
                    Assert.IsFalse(string.IsNullOrEmpty(_cell.Key.Row));
                    Interlocked.Increment(ref c);
                }

                return(AsyncCallbackResult.Continue);
            })) {
                tableA.BeginScan(asyncResult, new ScanSpec().AddColumn("a"));
                tableB.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }

            Assert.AreEqual(CountA + CountB, c);

            c = 0;
            using (var asyncResult = new AsyncResult(
                       (ctx, _cells) =>
            {
                foreach (var _cell in _cells)
                {
                    Assert.IsFalse(string.IsNullOrEmpty(_cell.Key.Row));
                    Interlocked.Increment(ref c);
                }

                return(AsyncCallbackResult.Continue);
            })) {
                tableA.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                tableB.BeginScan(asyncResult, new ScanSpec().AddColumn("c"));
                asyncResult.Join();
                Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                Assert.IsTrue(asyncResult.IsCompleted);
            }

            Assert.AreEqual(CountB + CountC, c);
        }
        public void ScanMultipleTableColumnFamilyAsync()
        {
            if (!HasAsyncTableScanner)
            {
                return;
            }

            using (var table2 = EnsureTable("ScanMultipleTableColumnFamilyAsync", Schema)) {
                InitializeTableData(table2);

                var c = 0;
                using (var asyncResult = new AsyncResult(
                           (ctx, cells) =>
                {
                    foreach (var cell in cells)
                    {
                        Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                        Interlocked.Increment(ref c);
                    }

                    return(AsyncCallbackResult.Continue);
                })) {
                    table.BeginScan(asyncResult, new ScanSpec().AddColumn("a"));
                    table2.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                    asyncResult.Join();
                    Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                    Assert.IsTrue(asyncResult.IsCompleted);
                }

                Assert.AreEqual(CountA + CountB, c);

                c = 0;
                using (var asyncResult = new AsyncResult(
                           (ctx, cells) =>
                {
                    foreach (var cell in cells)
                    {
                        Assert.IsFalse(string.IsNullOrEmpty(cell.Key.Row));
                        Interlocked.Increment(ref c);
                    }

                    return(AsyncCallbackResult.Continue);
                })) {
                    table2.BeginScan(asyncResult, new ScanSpec().AddColumn("b"));
                    table.BeginScan(asyncResult, new ScanSpec().AddColumn("c"));
                    asyncResult.Join();
                    Assert.IsNull(asyncResult.Error, asyncResult.Error != null ? asyncResult.Error.ToString() : string.Empty);
                    Assert.IsTrue(asyncResult.IsCompleted);
                }

                Assert.AreEqual(CountB + CountC, c);
            }
        }