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


C# HBaseClient.StoreCells方法代码示例

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


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

示例1: 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

示例2: StoreTestData

        private void StoreTestData(HBaseClient hBaseClient)
        {
            // we are going to insert the keys 0 to 100 and then do some range queries on that
            const string testValue = "the force is strong in this column";
            var set = new CellSet();
            for (int i = 0; i < 100; i++)
            {
                var row = new CellSet.Row { key = BitConverter.GetBytes(i) };
                var value = new Cell { column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue) };
                row.values.Add(value);
                set.rows.Add(row);
            }

            hBaseClient.StoreCells(_testTableName, set);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:15,代码来源:HBaseClientTests.cs

示例3: TestStoreSingleCell

        public void TestStoreSingleCell()
        {
            const string testKey = "content";
            const string testValue = "the force is strong in this column";
            var client = new HBaseClient(_credentials);
            var set = new CellSet();
            var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(testKey) };
            set.rows.Add(row);

            var value = new Cell { column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue) };
            row.values.Add(value);

            client.StoreCells(_testTableName, set);

            CellSet cells = client.GetCells(_testTableName, testKey);
            Assert.AreEqual(1, cells.rows.Count);
            Assert.AreEqual(1, cells.rows[0].values.Count);
            Assert.AreEqual(testValue, Encoding.UTF8.GetString(cells.rows[0].values[0].data));
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:19,代码来源:HBaseClientTests.cs

示例4: Main

            private static void Main(string[] args)
            {
                const string clusterURL = "http://localhost:5555";
                const string hadoopUsername = "root";
                const string hadoopUserPassword = "hadoop";
                var serializer = new JsonDotNetSerializer();
                // Create a new instance of an HBase client.
                var hbaseClient = new HBaseClient(new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword));
                var itemMapper = new ItemMapper(serializer);
                hbaseClient.DeleteTable("Items");
                var tableSchema = itemMapper.CreateTableSchema("Items");
                hbaseClient.CreateTable(tableSchema);

                //var perfCheck = new PerformanceChecksManager(hbaseClient, "Items", itemMapper, new ItemsGenerator(),50,100);
                //perfCheck.RunPerformanceLoad();
                
                //Generating item.
                var itemsGenerator = new ItemsGenerator();
                var item = itemsGenerator.CreateItem("mycode");

                //Generating cells relevant to the generate item and saving the entity to Hbae.
                var itemCellSet = itemMapper.GetCells(item, "en-US");
                var stausCell = itemCellSet.rows.Single().values.Single(cell => Encoding.UTF8.GetString(cell.column).Equals("CF1:Status"));
                stausCell.data = new byte[0];
                hbaseClient.StoreCells("Items", itemCellSet);

                //making sure item stored well.
                var originalItemCells = hbaseClient.GetCells("Items", item.Code);
                var originalItemFetchedFromDb = itemMapper.GetDto(originalItemCells, "en-US");

                if (!string.IsNullOrEmpty(originalItemFetchedFromDb.Status))
                    throw new Exception();

                //Describing the conditional update expression.
                var cellToCheck = new Cell { column = Encoding.UTF8.GetBytes("CF1:Status"), data = new byte[0] };

                //manipulating original item.
                stausCell = itemCellSet.rows.Single().values.Single(cell => Encoding.UTF8.GetString(cell.column).Equals("CF1:Status"));
                var newStatusValue = Encoding.UTF8.GetBytes("new");
                stausCell.data = newStatusValue;
                
                //Testing new functionality...

                hbaseClient.CheckAndPutCells("Items", itemCellSet, cellToCheck);
                //Thread.Sleep(1);
                itemCellSet = hbaseClient.GetCells("Items", item.Code);
                var itemFromDb = itemMapper.GetDto(itemCellSet, "en-US");

                if (!itemFromDb.Status.Equals(Encoding.UTF8.GetString(newStatusValue)))
                    throw new Exception();


                #region Old-Helper
                //string clusterURL = "http://localhost:5555";
                //string hadoopUsername = "root";
                //string hadoopUserPassword = "hadoop";
                //string hbaseTableName = "MyCoolTable";

                //// Create a new instance of an HBase client.
                //ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword);
                //HBaseClient hbaseClient = new HBaseClient(creds);

                //var hbaseHelper = new Helper(hbaseClient, "ThisIsJustATableForShirly1", "DummyKey1ForShirly1");
                //hbaseHelper.CreateTable();
                //var myClass = new Dto()
                //{
                //    Field1 = "1",
                //    Field2 = "2",
                //    Field3 = "3",
                //    Field4 = "4",
                //    Field5 = "5",
                //    NestedData = new NestedDto() { Field1 = "n1", Field2 = "n2" }
                //};

                //hbaseHelper.SaveMyDto(myClass);

                //var dto = hbaseHelper.GetMyDto();
#endregion
            }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:79,代码来源:Program.cs

示例5: TestCellsDeletion

        public async Task TestCellsDeletion()
        {
            const string testKey = "content";
            const string testValue = "the force is strong in this column";
            var client = new HBaseClient(_credentials);
            var set = new CellSet();
            var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(testKey) };
            set.rows.Add(row);

            var value = new Cell { column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue) };
            row.values.Add(value);

            client.StoreCells(_testTableName, set);
            CellSet cell = await client.GetCellsAsync(_testTableName, testKey);
            // make sure the cell is in the table
            Assert.AreEqual(Encoding.UTF8.GetString(cell.rows[0].key), testKey);
            // delete cell
            await client.DeleteCellsAsync(_testTableName, testKey);
            // get cell again, 404 exception expected
            await client.GetCellsAsync(_testTableName, testKey);

        }
开发者ID:juvchan,项目名称:hbase-sdk-for-net,代码行数:22,代码来源:HBaseClientTests.cs

示例6: PopulateTable

        private void PopulateTable()
        {
            var client = new HBaseClient(_credentials);
            var cellSet = new CellSet();

            string id = Guid.NewGuid().ToString("N");
            for (int lineNumber = 0; lineNumber < 10; ++lineNumber)
            {
                string rowKey = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", id, lineNumber);

                // add to expected records
                var rec = new FilterTestRecord(rowKey, lineNumber, Guid.NewGuid().ToString("N"), Guid.NewGuid().ToString("D"));
                _allExpectedRecords.Add(rec);

                // add to row
                var row = new CellSet.Row { key = _encoding.GetBytes(rec.RowKey) };

                var lineColumnValue = new Cell
                {
                    column = BuildCellColumn(ColumnFamilyName1, LineNumberColumnName),
                    data = BitConverter.GetBytes(rec.LineNumber)
                };
                row.values.Add(lineColumnValue);

                var paragraphColumnValue = new Cell { column = BuildCellColumn(ColumnFamilyName1, ColumnNameA), data = _encoding.GetBytes(rec.A) };
                row.values.Add(paragraphColumnValue);

                var columnValueB = new Cell { column = BuildCellColumn(ColumnFamilyName2, ColumnNameB), data = Encoding.UTF8.GetBytes(rec.B) };
                row.values.Add(columnValueB);

                cellSet.rows.Add(row);
            }

            client.StoreCells(_tableName, cellSet);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:35,代码来源:FilterTests.cs


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