本文整理汇总了C#中HBaseClient.CreateScannerAsync方法的典型用法代码示例。如果您正苦于以下问题:C# HBaseClient.CreateScannerAsync方法的具体用法?C# HBaseClient.CreateScannerAsync怎么用?C# HBaseClient.CreateScannerAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HBaseClient
的用法示例。
在下文中一共展示了HBaseClient.CreateScannerAsync方法的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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
ScannerInformation scanInfo = null;
try
{
scanInfo = client.CreateScannerAsync(_tableName, scan, scanOptions).Result;
List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo, scanOptions).ToList();
actualRecords.ShouldContainOnly(_allExpectedRecords);
}
finally
{
if (scanInfo != null)
{
client.DeleteScannerAsync(_tableName, scanInfo, scanOptions).Wait();
}
}
}
示例2: When_I_Scan_with_a_RandomRowFilter_I_get_the_expected_results
public void When_I_Scan_with_a_RandomRowFilter_I_get_the_expected_results()
{
var client = new HBaseClient(_credentials);
var scanner = new Scanner();
// set this large enough so that we get all records back
var filter = new RandomRowFilter(2000.0F);
scanner.filter = filter.ToEncodedString();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
ScannerInformation scanInfo = null;
try
{
scanInfo = client.CreateScannerAsync(_tableName, scanner, scanOptions).Result;
List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo, scanOptions).ToList();
actualRecords.ShouldContainOnly(_allExpectedRecords);
}
finally
{
if (scanInfo != null)
{
client.DeleteScannerAsync(_tableName, scanInfo, scanOptions).Wait();
}
}
}
示例3: 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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例4: 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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例5: 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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
ScannerInformation scanInfo = null;
try
{
scanInfo = client.CreateScannerAsync(_tableName, scanner, scanOptions).Result;
List<FilterTestRecord> actualRecords = RetrieveResults(scanInfo, scanOptions).ToList();
actualRecords.Count.ShouldBeGreaterThanOrEqualTo(2);
}
finally
{
if (scanInfo != null)
{
client.DeleteScannerAsync(_tableName, scanInfo, scanOptions).Wait();
}
}
}
示例6: When_I_Scan_with_a_ColumnCountGetFilter_I_get_the_expected_results
public void When_I_Scan_with_a_ColumnCountGetFilter_I_get_the_expected_results()
{
// B column should not be returned, so set the value to null.
List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords select r.WithBValue(null)).ToList();
var client = new HBaseClient(_credentials);
var scanner = new Scanner();
var filter = new ColumnCountGetFilter(2);
scanner.filter = filter.ToEncodedString();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例7: StartListening
public bool StartListening()
{
Background = Task.Run(async () =>
{
while (true)
{
var clusterURL = ConfigurationManager.AppSettings["ClusterUrl"];
var hadoopUsername = ConfigurationManager.AppSettings["Username"];
var hadoopUserPassword = ConfigurationManager.AppSettings["Password"];
var hbaseTableName =ConfigurationManager.AppSettings["TableName"];
// Create a new instance of an HBase client.
var creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword);
var hbaseClient = new HBaseClient(creds);
//Scan over rows in a table. Assume the table has integer keys and you want data between keys 25 and 35.
var scanSettings = new Scanner()
{
batch = 10
};
var scannerInfo = await hbaseClient.CreateScannerAsync(hbaseTableName, scanSettings);
CellSet next = null;
var res = new List<HBaseEntry>();
var rowNum = 0;
while ((next = hbaseClient.ScannerGetNext(scannerInfo)) != null)
{
res.AddRange(from row in next.rows
let key = Encoding.UTF8.GetString(row.key)
let value = Encoding.UTF8.GetString(row.values[0].data)
let parts = key.Split(',')
where parts.Length == 3
select new HBaseEntry()
{
Type = parts[0], Date = parts[1].Replace("0000000", "000"), RoomNumber = parts[2], Reading = value
});
}
var dateRangedList =
res.Where(a => DateTime.Parse(a.Date) >= DateTime.UtcNow.AddDays(-5)).Select(a => a).ToList();
var map = new Dictionary<String, Dictionary<String, Dictionary<String, String>>> ();
var tempList = dateRangedList.Where(a => a.Type == "Temperature").ToList();
var engyList = dateRangedList.Where(a => a.Type == "Energy").ToList();
var humList = dateRangedList.Where(a => a.Type == "Humidity").ToList();
var lghtList = dateRangedList.Where(a => a.Type == "Light").ToList();
map.Add("Temperature", GetDataAsMap(tempList));
map.Add("Energy", GetDataAsMap(engyList));
map.Add("Humidity", GetDataAsMap(humList));
map.Add("Light", GetDataAsMap(lghtList));
//get data
var ctx = GlobalHost.ConnectionManager.GetHubContext<DashHub>();
ctx.Clients.All.acceptData(JsonConvert.SerializeObject(map));
Thread.Sleep(15000);
}
});
Background.Wait();
return true;
}
示例8: HBaseClient
public void When_I_Scan_with_a_DependentColumnFilter_and_a_BinaryComparator_with_the_operator_equal_I_get_the_expected_results()
{
List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords where r.LineNumber == 1 select r).ToList();
var client = new HBaseClient(_credentials);
var scanner = new Scanner();
var filter = new DependentColumnFilter(
Encoding.UTF8.GetBytes(ColumnFamilyName1),
Encoding.UTF8.GetBytes(LineNumberColumnName),
false,
CompareFilter.CompareOp.Equal,
new BinaryComparator(BitConverter.GetBytes(1)));
scanner.filter = filter.ToEncodedString();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例9: When_I_Scan_with_a_FilterList_with_OR_logic_I_get_the_expected_results
public void When_I_Scan_with_a_FilterList_with_OR_logic_I_get_the_expected_results()
{
List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords where r.LineNumber <= 2 select r).ToList();
var client = new HBaseClient(_credentials);
var scanner = new Scanner();
Filter f0 = new SingleColumnValueFilter(
Encoding.UTF8.GetBytes(ColumnFamilyName1),
Encoding.UTF8.GetBytes(LineNumberColumnName),
CompareFilter.CompareOp.Equal,
BitConverter.GetBytes(1));
Filter f1 = new SingleColumnValueFilter(
Encoding.UTF8.GetBytes(ColumnFamilyName1),
Encoding.UTF8.GetBytes(LineNumberColumnName),
CompareFilter.CompareOp.LessThanOrEqualTo,
BitConverter.GetBytes(2));
var filter = new FilterList(FilterList.Operator.MustPassOne, f0, f1);
scanner.filter = filter.ToEncodedString();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例10: 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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例11: 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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例12: 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();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例13: 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();
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();
}
}
}
示例14: When_I_Scan_with_a_RowFilter_I_get_the_expected_results
public void When_I_Scan_with_a_RowFilter_I_get_the_expected_results()
{
FilterTestRecord example = _allExpectedRecords.First();
List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords where r.RowKey == example.RowKey select r).ToList();
var client = new HBaseClient(_credentials);
var scanner = new Scanner();
var filter = new RowFilter(CompareFilter.CompareOp.Equal, new BinaryComparator(Encoding.UTF8.GetBytes(example.RowKey)));
scanner.filter = filter.ToEncodedString();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}
示例15: When_I_Scan_with_a_InclusiveStopFilter_I_get_the_expected_results
public void When_I_Scan_with_a_InclusiveStopFilter_I_get_the_expected_results()
{
FilterTestRecord example = (from r in _allExpectedRecords where r.LineNumber == 2 select r).Single();
byte[] rawRowKey = Encoding.UTF8.GetBytes(example.RowKey);
List<FilterTestRecord> expectedRecords = (from r in _allExpectedRecords where r.LineNumber <= 2 select r).ToList();
var client = new HBaseClient(_credentials);
var scanner = new Scanner();
var filter = new InclusiveStopFilter(rawRowKey);
scanner.filter = filter.ToEncodedString();
RequestOptions scanOptions = RequestOptions.GetDefaultOptions();
scanOptions.AlternativeEndpoint = Constants.RestEndpointBaseZero;
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();
}
}
}