You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@accumulo.apache.org by David Medinets <da...@gmail.com> on 2012/02/23 03:50:40 UTC
Question About Table Design in User Manual
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()));
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?
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);
Re: Question About Table Design in User Manual
Posted by Billie J Rinaldi <bi...@ugov.gov>.
On Thursday, February 23, 2012 2:07:58 PM, "David Medinets" <da...@gmail.com>:
> Does the accumulo project keep release-specific versions of the
> documentation? Is it a goal that the documentation on the trunk should
> reflect the code in the trunk?
Yes. We are currently more focused on making sure the docs in 1.4 reflect the code in 1.4, since it is soon to be released.
Billie
Re: Question About Table Design in User Manual
Posted by David Medinets <da...@gmail.com>.
Does the accumulo project keep release-specific versions of the
documentation? Is it a goal that the documentation on the trunk should
reflect the code in the trunk?
Re: Question About Table Design in User Manual
Posted by Aaron Cordova <aa...@cordovas.org>.
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 <jo...@gmail.com> 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
>
Re: Question About Table Design in User Manual
Posted by Adam Fuchs <sc...@gmail.com>.
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 <jo...@gmail.com> 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
>
Re: Question About Table Design in User Manual
Posted by Josh Elser <jo...@gmail.com>.
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()));
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