Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Accumulo >> mail # user >> Question About Table Design in User Manual


Copy link to this message
-
Re: Question About Table Design in User Manual
Is there already a ticket to update the manual to the 1.4 API?

On Feb 23, 2012, at 1:47 PM, Adam Fuchs wrote:

> There's definitely something missing, and the rest of the example implies it is the column qualifier. This really ought to use the most easily understood API method for the put (which didn't exist when the manual was written. I would change the code to:
>
> Mutation m = new Mutation(userid);
> m.put("age","",age);
> m.put("address","",address);
> m.put("balance","",account_balance);
>
> Adam
>
>
> On Wed, Feb 22, 2012 at 10:39 PM, Josh Elser <[EMAIL PROTECTED]> wrote:
> On 2/22/2012 9:50 PM, David Medinets wrote:
> At the start of the Table Design chapter created from the svn trunk, I
> see this code:
>
> Mutation m = new Mutation(new Text(userid));
> m.put(new Text("age"), age);
> m.put(new Text("address"), address);
>
> However, when I try to write working code, I need to use this:
>
> Mutation m = new Mutation(new Text("medined"));
> m.put(new Text("age"), new Text("COLFAMILY"), 48, new Value(new
> Integer(age).toString().getBytes()));
> m.put(new Text("height"), new Text("COLFAMILY"), 49, new Value(new
> Integer(height).toString().getBytes()));
> I think you have one too many arguments to put(). Either of the following would make sense to me:
>
> 1)
>
> Mutation m = new Mutation(new Text("medined"));
> m.put(new Text("age"), new Text(""), new Value(new Integer(age).toString().getBytes()));
> m.put(new Text("height"), new Text(""), new Value(new Integer(height).toString().getBytes()));
>
> 2)
>
> Mutation m = new Mutation(new Text("medined"));
> m.put(new Text("age"), 48, new Value("".getBytes()));
> m.put(new Text("height"), 49, new Value("".getBytes()));
>
> How about:
> m.put("age","",age.toString());
> m.put("height","",height.toString());
>
>  
> Which is correct? IMO, it comes down to what is appropriate for how you want to structure your data (read as, how you want to fetch your data). Accumulo is very non-rigid when it comes to how you store you data in the Key/Value format.
>
> In the code in the user manual intended to be pseudo-code? Is there a
> version of put that provides a default column family? Does it make
> sense to provide alternate constructors for a Value object?
> Accumulo doesn't have a concept of a default column family, so no to that. I believe the original semantics of the Value class was meant to be a simple byte array container, being why there is no String convenience constructor You can easily put the bytes of a String in the Value; however, you could also do fancy things like put serialized data structures inside the Value.
>
> I also see this code in the Table Design chapter which I don't find
> when looking at actual code. Maybe this line should be removed. At
> this stage of the chapter, simply creating the Mutation is good
> enough?
>
> writer.add(m);
> A Mutation is simply a local object which encapsulates Key/Values to be written to Accumulo. Simply instantiating Mutations (as above) does not insert them into Accumulo. You need to write the Mutation into a BatchWriter; that line is necessary.
>
>  - Josh
>