Exemplo n.º 1
0
        public void When_I_Scan_with_a_TimestampsFilter_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = _allExpectedRecords;

            // scan all and retrieve timestamps
            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
            scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
            ScannerInformation scanAll = null;
            List<long> timestamps = null;
            try
            {
                scanAll = client.CreateScannerAsync(_tableName, scanner, scanOptions).Result;
                timestamps = RetrieveTimestamps(scanAll, scanOptions).ToList();
            }
            finally
            {
                if (scanAll != null)
                {
                    client.DeleteScannerAsync(_tableName, scanAll, scanOptions).Wait();
                }
            }

            Assert.IsNotNull(timestamps);

            // timestamps scan
            scanner = new Scanner();
            var filter = new TimestampsFilter(timestamps);
            scanner.filter = filter.ToEncodedString();
            ScannerInformation scanInfo = null;
            try
            {
                scanInfo = client.CreateScannerAsync(_tableName, scanner, scanOptions).Result;
                List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo, scanOptions).ToList();

                actualRecords.ShouldContainOnly(expectedRecords);
            }
            finally
            {
                if (scanInfo != null)
                {
                    client.DeleteScannerAsync(_tableName, scanInfo, scanOptions).Wait();
                }
            }
        }
        public void When_I_Scan_with_a_TimestampsFilter_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = _allExpectedRecords;

            // scan all and retrieve timestamps
            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            ScannerInformation scanAll = client.CreateScanner(_tableName, scanner);
            List<long> timestamps = RetrieveTimestamps(scanAll).ToList();

            // timestamps scan
            scanner = new Scanner();
            var filter = new TimestampsFilter(timestamps);
            scanner.filter = filter.ToEncodedString();

            ScannerInformation scanInfo = client.CreateScanner(_tableName, scanner);
            List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo).ToList();

            actualRecords.ShouldContainOnly(expectedRecords);
        }