本文整理汇总了C#中HBaseClient.GetCells方法的典型用法代码示例。如果您正苦于以下问题:C# HBaseClient.GetCells方法的具体用法?C# HBaseClient.GetCells怎么用?C# HBaseClient.GetCells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HBaseClient
的用法示例。
在下文中一共展示了HBaseClient.GetCells方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
bool quit = false;
while (!quit)
{
Console.ResetColor();
Console.WriteLine("Enter a stock code, or enter 'quit' to exit");
// Connect to HBase cluster
string clusterURL = "https://hb12345.azurehdinsight.net";
string userName = "HDUser";
string password = "HDPa$$w0rd";
ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), userName, password);
HBaseClient hbaseClient = new HBaseClient(creds);
string input = Console.ReadLine();
if (input.ToLower() == "quit")
{
quit = true;
}
else
{
CellSet cellSet = hbaseClient.GetCells("Stocks", input);
var row = cellSet.rows[0];
Double currentPrice = Double.Parse(Encoding.UTF8.GetString(row.values[1].data));
Double closingPrice = Double.Parse(Encoding.UTF8.GetString(row.values[0].data));
if (currentPrice > closingPrice)
{
Console.ForegroundColor = ConsoleColor.Green;
}
else
if (currentPrice < closingPrice)
{
Console.ForegroundColor = ConsoleColor.Red;
}
Console.WriteLine(input + ": " + currentPrice.ToString());
}
}
}
示例2: 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));
}
示例3: 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
}