Accumulo createBatchScanner范围无法按预期工作 [英] Accumulo createBatchScanner range not working as expected

查看:115
本文介绍了Accumulo createBatchScanner范围无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让批处理扫描器仅扫描特定的行,而当设置的开始和停止键指向相同的东西时,我将无任何条目返回,而当使用扫描器时,出现此异常:

I cant get a batch scanner to only scan for a specific row, when settings start and stop keys to the same thing I get no entry's back, when using an scanner I get this exception:


java.lang.IllegalArgumentException:开始键必须小于范围内的结束键(测试:[] 0否,测试:[] 0否) ...

"java.lang.IllegalArgumentException: Start key must be less than end key in range (Test : [] 0 false, Test : [] 0 false)"...

我正在Visual Studio 2010中用C#编写,并使用Thrift(0.9.1.1版)和Accumulo(1.5.0版)代理项目中的.thrift代码。

I am writing in C# in Visual Studio 2010 and using Thrift (ver 0.9.1.1) and Accumulo's (ver 1.5.0) proxy.thrift code in the project.

这是我的代码,一切正常,但我没有从 client.nextK <获得任何条目/ code>

Here is my code, everything "works" but I don't get any entries from client.nextK

class Program
{
    static byte[] GetBytes(string str)
    {
        return Encoding.ASCII.GetBytes(str);
    }

    static string GetString(byte[] bytes)
    {
        return Encoding.ASCII.GetString(bytes);
    }

    static void Main(string[] args)
    {
        try
        {
            /** connect **/
            TTransport transport = new TSocket("192.168.58.62", 42424);
            transport = new TFramedTransport(transport);
            TCompactProtocol protocol = new TCompactProtocol(transport);
            transport.Open();

            AccumuloProxy.Client client = new AccumuloProxy.Client(protocol);

            Dictionary<string, string> passwd = new Dictionary<string,string>();
            passwd.Add("password", "password");

            var login = client.login("root", passwd);
            /** connect end **/

            /** Get all data from one "Row" **/
            var bScanner = new BatchScanOptions();

            Range range = new Range();

            range.Start = new Key();
            range.Start.Row = GetBytes("Test");

            range.Stop = new Key();
            range.Stop.Row = GetBytes("Test");

            bScanner.Ranges = new List<Range>();
            bScanner.Ranges.Add(range);

            var scanId = client.createBatchScanner(login, "firstTable", bScanner);

            var more = true;
            while (more)
            {
                var scan = client.nextK(scanId, 10);
                more = scan.More;
                foreach (var entry in scan.Results)
                {
                    Console.WriteLine("{0} {1}:{2} [{3}]  {4}", GetString(entry.Key.Row), GetString(entry.Key.ColFamily), GetString(entry.Key.ColQualifier), GetString(entry.Key.ColVisibility), GetString(entry.Value));
                }
            }

            client.closeScanner(scanId);
            Console.WriteLine();
            /** Get data end **/
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }
}

Accumulo 1.5用户手册,正在显示此代码段,与我正在执行的操作相同(但在C#中):( http://accumulo.apache.org/1.5/accumulo_user_manual.html#_basic_table

The user manual for Accumulo 1.5, is showing this code snippet and that is the same as I'm doing (but in C#): (http://accumulo.apache.org/1.5/accumulo_user_manual.html#_basic_table)

Range r = new Range(userid, userid); // single row
Scanner s = conn.createScanner("userdata", auths);
s.setRange(r);
s.fetchColumnFamily(new Text("age"));

for(Entry<Key,Value> entry : s)
    System.out.println(entry.getValue().toString());


推荐答案

问题可能出在您的范围内。在Java API中,您可以为单行构造一个Range,其中包括:

The problem is likely your range. In the Java API, you can construct a Range for a single row, with:

Range r = new Range("myRow");

在thrift Proxy API中,您只能将Keys赋予Range构造函数,而不仅仅是RowIDs(这也是Java API中的一个选项,但这是Proxy API中的唯一选项)。键代表单个条目,因此扫描:

In the thrift Proxy API, you can only give Keys to the Range constructor, not just RowIDs (this is an option in the Java API, also, but it is the only option in the Proxy API). Keys represent a single entry, so scanning:

R1:CF1:CQ1:CV1 -> R1:CF1:CQ1:CV1

只会对该确切条目进行扫描(并且可能会进行扫描)的所有版本,如果您没有为表配置VersioningIterator。)

will only ever result a scan over that one exact entry (and possibly all versions of it, if you don't have the VersioningIterator configured for the table).

因此,如果您要扫描 a行中的所有条目,则不要这样扫描:

So, if you want to scan all entries in row "a", you don't scan like this:

"a":null:null:null(inclusive) -> "a":null:null:null(inclusive)

相反,您需要像这样扫描row = = a:

Rather, you scan like this for row == "a":

"a":null:null:null(inclusive) -> "a\0":null:null:null(exclusive)

或者,对于row startsWith a:

Or this, for row startsWith "a":

"a":null:null:null(inclusive) -> "b":null:null:null(exclusive)

这篇关于Accumulo createBatchScanner范围无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆