<tfoot id='ihbbe'></tfoot>
    1. <i id='ihbbe'><tr id='ihbbe'><dt id='ihbbe'><q id='ihbbe'><span id='ihbbe'><b id='ihbbe'><form id='ihbbe'><ins id='ihbbe'></ins><ul id='ihbbe'></ul><sub id='ihbbe'></sub></form><legend id='ihbbe'></legend><bdo id='ihbbe'><pre id='ihbbe'><center id='ihbbe'></center></pre></bdo></b><th id='ihbbe'></th></span></q></dt></tr></i><div id='ihbbe'><tfoot id='ihbbe'></tfoot><dl id='ihbbe'><fieldset id='ihbbe'></fieldset></dl></div>
      • <bdo id='ihbbe'></bdo><ul id='ihbbe'></ul>
    2. <small id='ihbbe'></small><noframes id='ihbbe'>

      1. <legend id='ihbbe'><style id='ihbbe'><dir id='ihbbe'><q id='ihbbe'></q></dir></style></legend>

        在 RIAK 上获取 MapReduce 结果(使用 Java 客户端)

        时间:2023-09-27

            <tbody id='gAjYR'></tbody>
          <legend id='gAjYR'><style id='gAjYR'><dir id='gAjYR'><q id='gAjYR'></q></dir></style></legend><tfoot id='gAjYR'></tfoot>
            • <bdo id='gAjYR'></bdo><ul id='gAjYR'></ul>
              <i id='gAjYR'><tr id='gAjYR'><dt id='gAjYR'><q id='gAjYR'><span id='gAjYR'><b id='gAjYR'><form id='gAjYR'><ins id='gAjYR'></ins><ul id='gAjYR'></ul><sub id='gAjYR'></sub></form><legend id='gAjYR'></legend><bdo id='gAjYR'><pre id='gAjYR'><center id='gAjYR'></center></pre></bdo></b><th id='gAjYR'></th></span></q></dt></tr></i><div id='gAjYR'><tfoot id='gAjYR'></tfoot><dl id='gAjYR'><fieldset id='gAjYR'></fieldset></dl></div>

              1. <small id='gAjYR'></small><noframes id='gAjYR'>

                • 本文介绍了在 RIAK 上获取 MapReduce 结果(使用 Java 客户端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在 RIAK 上存储 Person POJO(4 个字符串字段 - id、name、lastUpdate、Data),然后尝试使用 MapReduce 获取这些对象.

                  I am storing Person POJOs (4 string fields - id, name, lastUpdate, Data) on RIAK, then trying to fetch these objects with MapReduce.

                  我的做法与 Basho 文档非常相似:

                  I am doing it very similar to Basho documentation:

                      BucketMapReduce m = riakClient.mapReduce("person");
                      m.addMapPhase(new NamedJSFunction("Riak.mapByFields"), true);
                      MapReduceResult result = m.execute();
                      Collection<Person> tmp = result.getResult(Person.class);
                  

                  调用了 Person 的 String 构造函数:

                  the Person's String constructor is invoked:

                  public Person(String str){}
                  

                  (我必须有这个构造函数,否则我会因为它丢失而出现异常)在那里,我将对象作为字符串 - 一个字符串中的对象字段带有一个奇怪的分隔符.

                  (I must have this constructor, otherwise I get an exception for it is missing) In there I get the object as a String - the Object's fields in one string with a strange delimiter.

                  为什么我没有将对象自动转换为我的 POJO?我真的需要遍历字符串并反序列化它吗?我做错了什么吗?s

                  why am I not getting the object automatically converted to my POJO? do I really need to go over the string and deserialize it? am i doing something wrong?s

                  推荐答案

                  您使用的 JS 函数并没有按照您的想法执行 :) 它根据您必须提供的特定值的字段来选择对象作为相位的参数.

                  The JS function you're using doesn't do what you think it does :) It selects objects based on a field with a specific value you have to supply as an argument to the phase.

                  我认为您正在寻找的是 mapValuesJson 它将执行您似乎想要做的事情.

                  I think what you're looking for is mapValuesJson which will do what you seem to be wanting to do.

                  此外,您的 POJO 中根本不需要构造函数.

                  Also, you don't need a constructor at all in your POJO.

                  下面的代码应该为您指明正确的方向(显然这是超级简单的,POJO 中的所有公共字段都没有注释):

                  The code below should point you in the right direction (obviously this is super-simple with all public fields in the POJO and no annotations):

                  public class App {
                  
                      public static void main( String[] args ) throws IOException, RiakException
                      {
                          IRiakClient client = RiakFactory.httpClient();
                          Bucket b = client.fetchBucket("test_mr").execute();
                  
                          b.store("myobject", new Person()).execute();
                          IRiakObject o = b.fetch("myobject").execute();
                          System.out.println(o.getValueAsString());
                  
                  
                          BucketMapReduce m = client.mapReduce("test_mr");
                          m.addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true);
                          MapReduceResult result = m.execute();
                          System.out.println(result.getResultRaw());
                          Collection<Person> tmp = result.getResult(Person.class);
                  
                          for (Person p : tmp)
                          {
                              System.out.println(p.data);
                          }
                  
                  
                          client.shutdown();
                      }
                  }
                  
                  class Person 
                  {
                      public String id = "12345";
                      public String name = "my name";
                      public String lastUpdate = "some time";
                      public String data = "some data";
                  
                  
                  }
                  

                  这篇关于在 RIAK 上获取 MapReduce 结果(使用 Java 客户端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Hadoop 框架中使用的属性的完整列表 下一篇:Java MapReduce 按日期计数

                  相关文章

                  最新文章

                • <legend id='iO3XE'><style id='iO3XE'><dir id='iO3XE'><q id='iO3XE'></q></dir></style></legend>

                  <small id='iO3XE'></small><noframes id='iO3XE'>

                  • <bdo id='iO3XE'></bdo><ul id='iO3XE'></ul>

                    <tfoot id='iO3XE'></tfoot>
                      <i id='iO3XE'><tr id='iO3XE'><dt id='iO3XE'><q id='iO3XE'><span id='iO3XE'><b id='iO3XE'><form id='iO3XE'><ins id='iO3XE'></ins><ul id='iO3XE'></ul><sub id='iO3XE'></sub></form><legend id='iO3XE'></legend><bdo id='iO3XE'><pre id='iO3XE'><center id='iO3XE'></center></pre></bdo></b><th id='iO3XE'></th></span></q></dt></tr></i><div id='iO3XE'><tfoot id='iO3XE'></tfoot><dl id='iO3XE'><fieldset id='iO3XE'></fieldset></dl></div>