当前位置: 首页>>代码示例>>C#>>正文


C# HBaseClient.CreateScanner方法代码示例

本文整理汇总了C#中HBaseClient.CreateScanner方法的典型用法代码示例。如果您正苦于以下问题:C# HBaseClient.CreateScanner方法的具体用法?C# HBaseClient.CreateScanner怎么用?C# HBaseClient.CreateScanner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HBaseClient的用法示例。


在下文中一共展示了HBaseClient.CreateScanner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_I_Scan_all_I_get_the_expected_results

        public void When_I_Scan_all_I_get_the_expected_results()
        {
            var client = new HBaseClient(_credentials);
            var scan = new Scanner();

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

            actualRecords.ShouldContainOnly(_allExpectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:10,代码来源:FilterTests.cs

示例2: Main

        static void Main(string[] args)
        {

            while (true)
            {
                Random rnd = new Random();
                Console.Clear();

                string clusterURL = "https://hb12345.azurehdinsight.net";
                string userName = "HDUser";
                string password = "HDPa$$w0rd";

                // Connect to HBase cluster
                ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL),
                                                                  userName, password);
                HBaseClient hbaseClient = new HBaseClient(creds);

                // Get all stocks
                Scanner scanSettings = new Scanner()
                {
                    batch = 10,
                    startRow = Encoding.UTF8.GetBytes("AAA"),
                    endRow = Encoding.UTF8.GetBytes("ZZZ")
                };

                ScannerInformation stockScanner = hbaseClient.CreateScanner("Stocks", scanSettings);
                CellSet stockCells = null;
                while ((stockCells = hbaseClient.ScannerGetNext(stockScanner)) != null)
                {
                    foreach (var row in stockCells.rows)
                    {
                        string stock = Encoding.UTF8.GetString(row.key);
                        Double currentPrice = Double.Parse(Encoding.UTF8.GetString(row.values[1].data));
                        Double newPrice = currentPrice + (rnd.NextDouble() * (1 - -1) + -1);
                        Cell c = new Cell
                        {
                            column = Encoding.UTF8.GetBytes("Current:Price"),
                            data =
                           Encoding.UTF8.GetBytes(newPrice.ToString())
                        };
                        row.values.Insert(2, c);
                        Console.WriteLine(stock + ": " + currentPrice.ToString() + " := "
                                                       + newPrice.ToString());
                    }
                    hbaseClient.StoreCells("Stocks", stockCells);
                }
            }

        }
开发者ID:TomLous,项目名称:edx-dat202.2x-rt-analytics-hadoop-azure,代码行数:49,代码来源:Program.cs

示例3: TestFullScan

        public void TestFullScan()
        {
            var client = new HBaseClient(_credentials);

            StoreTestData(client);

            // full range scan
            var scanSettings = new Scanner { batch = 10 };
            ScannerInformation scannerInfo = client.CreateScanner(_testTableName, scanSettings);

            CellSet next;
            var expectedSet = new HashSet<int>(Enumerable.Range(0, 100));
            while ((next = client.ScannerGetNext(scannerInfo)) != null)
            {
                Assert.AreEqual(10, next.rows.Count);
                foreach (CellSet.Row row in next.rows)
                {
                    int k = BitConverter.ToInt32(row.key, 0);
                    expectedSet.Remove(k);
                }
            }
            Assert.AreEqual(0, expectedSet.Count, "The expected set wasn't empty! Items left {0}!", string.Join(",", expectedSet));
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:23,代码来源:HBaseClientTests.cs

示例4: When_I_Scan_with_a_QualifierFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_QualifierFilter_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords select r.WithAValue(null).WithBValue(null)).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new QualifierFilter(CompareFilter.CompareOp.Equal, new BinaryComparator(Encoding.UTF8.GetBytes(LineNumberColumnName)));
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:14,代码来源:FilterTests.cs

示例5: When_I_Scan_with_a_TimestampsFilter_I_get_the_expected_results

        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);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:20,代码来源:FilterTests.cs

示例6: When_I_Scan_with_a_ValueFilter_and_a_RegexStringComparator_I_get_the_expected_results

        public void When_I_Scan_with_a_ValueFilter_and_a_RegexStringComparator_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = _allExpectedRecords;
            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new ValueFilter(CompareFilter.CompareOp.Equal, new RegexStringComparator(".*"));
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:13,代码来源:FilterTests.cs

示例7: HBaseClient

        public void When_I_Scan_with_a_SingleColumnValueFilter_and_a_NullComparator_with_the_operator_not_equal_I_get_the_expected_results()
        {
            var expectedRecords = new List<FilterTestRecord>();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();

            var comparer = new NullComparator();

            var filter = new SingleColumnValueFilter(
                Encoding.UTF8.GetBytes(ColumnFamilyName1),
                Encoding.UTF8.GetBytes(LineNumberColumnName),
                CompareFilter.CompareOp.Equal,
                comparer);
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:21,代码来源:FilterTests.cs

示例8: TestSubsetScan

        public void TestSubsetScan()
        {
            var client = new HBaseClient(_credentials);
            const int startRow = 15;
            const int endRow = 15 + 13;
            StoreTestData(client);

            // subset range scan
            var scanSettings = new Scanner { batch = 10, startRow = BitConverter.GetBytes(startRow), endRow = BitConverter.GetBytes(endRow) };
            ScannerInformation scannerInfo = client.CreateScanner(_testTableName, scanSettings);

            CellSet next;
            var expectedSet = new HashSet<int>(Enumerable.Range(startRow, endRow - startRow));
            while ((next = client.ScannerGetNext(scannerInfo)) != null)
            {
                foreach (CellSet.Row row in next.rows)
                {
                    int k = BitConverter.ToInt32(row.key, 0);
                    expectedSet.Remove(k);
                }
            }
            Assert.AreEqual(0, expectedSet.Count, "The expected set wasn't empty! Items left {0}!", string.Join(",", expectedSet));
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:23,代码来源:HBaseClientTests.cs

示例9: When_I_Scan_with_a_ColumnRangeFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_ColumnRangeFilter_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords select r.WithLineNumberValue(0).WithBValue(null)).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new ColumnRangeFilter(Encoding.UTF8.GetBytes(ColumnNameA), true, Encoding.UTF8.GetBytes(ColumnNameB), false);
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:14,代码来源:FilterTests.cs

示例10: GetSessionsByTime

        /// <summary>
        /// Retrieve sessions within the given time range
        /// </summary>
        /// <param name="hbaseClient">The hbase client</param>
        /// <param name="eventType">The type of event to look for</param>
        /// <param name="start">Lower bound of the time range</param>
        /// <param name="end">Upper bound of the time range</param>
        static void GetSessionsByTime(HBaseClient hbaseClient, string eventType, DateTime start, DateTime end)
        {
            //Create filters list
            FilterList filters = new FilterList(FilterList.Operator.MustPassAll);

            //Filter to search for the event type value
            SingleColumnValueFilter valueFilter = new SingleColumnValueFilter(
                Encoding.UTF8.GetBytes("cf"),
                Encoding.UTF8.GetBytes("event"),
                CompareFilter.CompareOp.Equal,
                Encoding.UTF8.GetBytes(eventType));
            filters.AddFilter(valueFilter);

            //Create scanner, set maxVersions so we can get previous versions of rows
            //Since START events may not be the currently returned value
            var scannerSettings = new Scanner()
            {
                filter = filters.ToEncodedString(),
                maxVersions = 5,
                startTime = ToUnixTime(start),
                endTime = ToUnixTime(end)
            };

            var scanner = hbaseClient.CreateScanner(Properties.Settings.Default.HBaseTableName, scannerSettings);
            //Read data from scanner
            CellSet readSet = null;
            //While reading cell sets
            while ((readSet = hbaseClient.ScannerGetNext(scanner)) != null)
            {
                //Iterate over the rows returned
                foreach (var row in readSet.rows)
                {
                    //Get the time stored for the START event
                    var endTime = row.values.Where(v => Encoding.UTF8.GetString(v.column) == "cf:time")
                        .Select(v => BitConverter.ToInt64(v.data, 0)).ToArray()[0];

                    //Get the hbase timestamp of the row
                    var timestamp = row.values.Select(v => v.timestamp).ToArray()[0];
                    //If it's an end event type
                    if (eventType == "END")
                    {
                        //Get the duration stored between END and START events
                        var duration = new TimeSpan(
                            row.values.Where(v => Encoding.UTF8.GetString(v.column) == "cf:duration")
                                .Select(v => BitConverter.ToInt64(v.data, 0)).ToArray()[0]);
                        //Write out the session info, including duration
                        Console.WriteLine("Session {0} lasted {1} minutes, and ended at {2}",
                            Encoding.UTF8.GetString(row.key),
                            duration.Minutes,
                            FromUnixTime(endTime));
                    }
                    else
                    {
                        //If start event type, just write out when it started and the hbase timestamp for the row
                        Console.WriteLine("Session {0} started at {1}. Timestamp = {2}",
                            Encoding.UTF8.GetString(row.key),
                            FromUnixTime(endTime),
                            timestamp);
                    }
                }
            }
        }
开发者ID:Blackmist,项目名称:hdinsight-storm-dotnet-event-correlation,代码行数:69,代码来源:Program.cs

示例11: When_I_Scan_with_a_PrefixFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_PrefixFilter_I_get_the_expected_results()
        {
            FilterTestRecord example = _allExpectedRecords.First();
            byte[] rawRowkey = Encoding.UTF8.GetBytes(example.RowKey);

            const int prefixLength = 4;
            var prefix = new byte[prefixLength];
            Array.Copy(rawRowkey, prefix, prefixLength);

            List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords
                let rawKey = Encoding.UTF8.GetBytes(r.RowKey)
                where rawKey[0] == prefix[0] && rawKey[1] == prefix[1] && rawKey[2] == prefix[2] && rawKey[3] == prefix[3]
                select r).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new PrefixFilter(prefix);
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:24,代码来源:FilterTests.cs

示例12: When_I_Scan_with_a_WhileMatchFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_WhileMatchFilter_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords where r.LineNumber == 0 select r.WithBValue(null)).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new WhileMatchFilter(new ValueFilter(CompareFilter.CompareOp.NotEqual, new BinaryComparator(BitConverter.GetBytes(0))));
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:14,代码来源:FilterTests.cs

示例13: When_I_Scan_with_a_PageFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_PageFilter_I_get_the_expected_results()
        {
            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new PageFilter(2);
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.Count.ShouldBeGreaterThanOrEqualTo(2);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:12,代码来源:FilterTests.cs

示例14: When_I_Scan_with_a_MultipleColumnPrefixFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_MultipleColumnPrefixFilter_I_get_the_expected_results()
        {
            List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords select r.WithLineNumberValue(0)).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();

            // set this large enough so that we get all records back
            var prefixes = new List<byte[]> { Encoding.UTF8.GetBytes(ColumnNameA), Encoding.UTF8.GetBytes(ColumnNameB) };
            var filter = new MultipleColumnPrefixFilter(prefixes);
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:17,代码来源:FilterTests.cs

示例15: When_I_Scan_with_a_KeyOnlyFilter_I_get_the_expected_results

        public void When_I_Scan_with_a_KeyOnlyFilter_I_get_the_expected_results()
        {
            // a key only filter does not return column values
            List<FilterTestRecord> expectedRecords =
                (from r in _allExpectedRecords select new FilterTestRecord(r.RowKey, 0, string.Empty, string.Empty)).ToList();

            var client = new HBaseClient(_credentials);
            var scanner = new Scanner();
            var filter = new KeyOnlyFilter();
            scanner.filter = filter.ToEncodedString();

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

            actualRecords.ShouldContainOnly(expectedRecords);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:16,代码来源:FilterTests.cs


注:本文中的HBaseClient.CreateScanner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。