You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@accumulo.apache.org by Rukshan Chathuranga <rc...@gmail.com> on 2015/06/16 06:11:12 UTC

How to get the first key of the Tablet servers

hi,

Does anyone know how to get the first or last key of the tablet servers?

Thanks and Regards.

*Rukshan Chathuranga.*

*Department Of Computer Science & Engineering,*

*Faculty Of Engineering,*
*University Of Moratuwa. **Sri Lanka.*

*WEB: http://www.rukspot.com/ <http://rukspot.com/>*

Re: How to get the first key of the Tablet servers

Posted by Keith Turner <ke...@deenlo.com>.
You can use TableOperations.getMaxRow()[1] to find the last key in a
range.   This is not a constant time operation, its ~ O(log R) where R is
the amount of bits in your row.   There is a shell command to do this also.

[1]:
http://accumulo.apache.org/1.6/apidocs/org/apache/accumulo/core/client/admin/TableOperations.html#getMaxRow%28java.lang.String,%20org.apache.accumulo.core.security.Authorizations,%20org.apache.hadoop.io.Text,%20boolean,%20org.apache.hadoop.io.Text,%20boolean%29

On Tue, Jun 16, 2015 at 12:11 AM, Rukshan Chathuranga <rcrukshan17@gmail.com
> wrote:

> hi,
>
> Does anyone know how to get the first or last key of the tablet servers?
>
> Thanks and Regards.
>
> *Rukshan Chathuranga.*
>
> *Department Of Computer Science & Engineering,*
>
> *Faculty Of Engineering,*
> *University Of Moratuwa. **Sri Lanka.*
>
> *WEB: http://www.rukspot.com/ <http://rukspot.com/>*
>
>

Re: How to get the first key of the Tablet servers

Posted by Christopher <ct...@apache.org>.
You can get the row boundaries for the tablets from the metadata (this
is what listSplits does), but for the actual keys (or even just actual
rows, since split points do not necessarily map to actual rows which
exist in the table), you need to scan.

--
Christopher L Tubbs II
http://gravatar.com/ctubbsii


On Tue, Jun 16, 2015 at 9:53 AM, David Medinets
<da...@gmail.com> wrote:
> Can this information be read from the METADATA table or has that changed?
>
> On Tue, Jun 16, 2015 at 9:37 AM, Christopher <ct...@apache.org> wrote:
>>
>> Actually, scanning `new Range($endRow)` will only give you keys in
>> that last row (if it exists).
>>
>> You'd actually want to scan:
>>
>> [null, $endRow] :: for the first split point, $endRow
>> ($endRow, $endRow2] :: for each sequence of two split points, $endRow
>> and $endRow2
>> ($endRow, null) :: for the last split point
>>
>> You can use the constructor, `Range(Text, boolean, Text, boolean)` for
>> the startRow and stopRow (with inclusive flag set for each, when
>> appropriated).
>>
>> Optionally, you could create a simple iterator based on the provided
>> FirstEntryInRowIterator, called "FirstEntryInTablet", which just
>> returns one item and then nothing else, and then simply scan the
>> entire table with the default options. The only thing returned would
>> be the first entries in each tablet.
>>
>> Of course, all this is assuming you want the first actual (existing)
>> key for each tablet. If you want the first key a tablet could
>> theoretically contain, that's even easier... no scanning necessary.
>> That's just a key comprised of the split point + '\0' for the row, and
>> empty values for everything else (except the first tablet... in the
>> first tablet, the first possible key has a empty byte string for the
>> row).
>>
>>
>> --
>> Christopher L Tubbs II
>> http://gravatar.com/ctubbsii
>>
>>
>> On Tue, Jun 16, 2015 at 1:24 AM, Josh Elser <jo...@gmail.com> wrote:
>> > Not sure I understand your question. Do you mean of a Tablet instead of
>> > TabletServer? A TabletServer will host many Tablets.
>> >
>> > Assuming so, the easiest way to get the first key for each Tablet is to
>> > fetch the split points for a table. The split points are the end-row of
>> > each
>> > Tablet in a table.
>> >
>> > Then, to get the first keys in each Tablet, construct a `new
>> > Range($endRow)`, open a Scanner and fetch the first Key. Make sure you
>> > also
>> > do this with `new Range()` as well to get the first Key in the first
>> > Tablet
>> > for the table (the Tablet which starts at -inf).
>> >
>> > There is no easy way that I can think of to determine what the last key
>> > in a
>> > Tablet is. What is the reason that you want to explicitly know this?
>> > Maybe
>> > there is a different to do what you're trying to do?
>> >
>> > - Josh
>> >
>> >
>> > Rukshan Chathuranga wrote:
>> >>
>> >> hi,
>> >>
>> >> Does anyone know how to get the first or last key of the tablet
>> >> servers?
>> >>
>> >> Thanks and Regards.
>> >>
>> >> /Rukshan Chathuranga./
>> >> /Department Of Computer Science & Engineering,
>> >> /
>> >> /Faculty Of Engineering,
>> >> /
>> >> /University Of Moratuwa. //Sri Lanka./
>> >> /WEB: http://www.rukspot.com/ <http://rukspot.com/>
>> >> /
>> >>
>> >
>
>

Re: How to get the first key of the Tablet servers

Posted by David Medinets <da...@gmail.com>.
Can this information be read from the METADATA table or has that changed?

On Tue, Jun 16, 2015 at 9:37 AM, Christopher <ct...@apache.org> wrote:

> Actually, scanning `new Range($endRow)` will only give you keys in
> that last row (if it exists).
>
> You'd actually want to scan:
>
> [null, $endRow] :: for the first split point, $endRow
> ($endRow, $endRow2] :: for each sequence of two split points, $endRow
> and $endRow2
> ($endRow, null) :: for the last split point
>
> You can use the constructor, `Range(Text, boolean, Text, boolean)` for
> the startRow and stopRow (with inclusive flag set for each, when
> appropriated).
>
> Optionally, you could create a simple iterator based on the provided
> FirstEntryInRowIterator, called "FirstEntryInTablet", which just
> returns one item and then nothing else, and then simply scan the
> entire table with the default options. The only thing returned would
> be the first entries in each tablet.
>
> Of course, all this is assuming you want the first actual (existing)
> key for each tablet. If you want the first key a tablet could
> theoretically contain, that's even easier... no scanning necessary.
> That's just a key comprised of the split point + '\0' for the row, and
> empty values for everything else (except the first tablet... in the
> first tablet, the first possible key has a empty byte string for the
> row).
>
>
> --
> Christopher L Tubbs II
> http://gravatar.com/ctubbsii
>
>
> On Tue, Jun 16, 2015 at 1:24 AM, Josh Elser <jo...@gmail.com> wrote:
> > Not sure I understand your question. Do you mean of a Tablet instead of
> > TabletServer? A TabletServer will host many Tablets.
> >
> > Assuming so, the easiest way to get the first key for each Tablet is to
> > fetch the split points for a table. The split points are the end-row of
> each
> > Tablet in a table.
> >
> > Then, to get the first keys in each Tablet, construct a `new
> > Range($endRow)`, open a Scanner and fetch the first Key. Make sure you
> also
> > do this with `new Range()` as well to get the first Key in the first
> Tablet
> > for the table (the Tablet which starts at -inf).
> >
> > There is no easy way that I can think of to determine what the last key
> in a
> > Tablet is. What is the reason that you want to explicitly know this?
> Maybe
> > there is a different to do what you're trying to do?
> >
> > - Josh
> >
> >
> > Rukshan Chathuranga wrote:
> >>
> >> hi,
> >>
> >> Does anyone know how to get the first or last key of the tablet servers?
> >>
> >> Thanks and Regards.
> >>
> >> /Rukshan Chathuranga./
> >> /Department Of Computer Science & Engineering,
> >> /
> >> /Faculty Of Engineering,
> >> /
> >> /University Of Moratuwa. //Sri Lanka./
> >> /WEB: http://www.rukspot.com/ <http://rukspot.com/>
> >> /
> >>
> >
>

Re: How to get the first key of the Tablet servers

Posted by Christopher <ct...@apache.org>.
Actually, scanning `new Range($endRow)` will only give you keys in
that last row (if it exists).

You'd actually want to scan:

[null, $endRow] :: for the first split point, $endRow
($endRow, $endRow2] :: for each sequence of two split points, $endRow
and $endRow2
($endRow, null) :: for the last split point

You can use the constructor, `Range(Text, boolean, Text, boolean)` for
the startRow and stopRow (with inclusive flag set for each, when
appropriated).

Optionally, you could create a simple iterator based on the provided
FirstEntryInRowIterator, called "FirstEntryInTablet", which just
returns one item and then nothing else, and then simply scan the
entire table with the default options. The only thing returned would
be the first entries in each tablet.

Of course, all this is assuming you want the first actual (existing)
key for each tablet. If you want the first key a tablet could
theoretically contain, that's even easier... no scanning necessary.
That's just a key comprised of the split point + '\0' for the row, and
empty values for everything else (except the first tablet... in the
first tablet, the first possible key has a empty byte string for the
row).


--
Christopher L Tubbs II
http://gravatar.com/ctubbsii


On Tue, Jun 16, 2015 at 1:24 AM, Josh Elser <jo...@gmail.com> wrote:
> Not sure I understand your question. Do you mean of a Tablet instead of
> TabletServer? A TabletServer will host many Tablets.
>
> Assuming so, the easiest way to get the first key for each Tablet is to
> fetch the split points for a table. The split points are the end-row of each
> Tablet in a table.
>
> Then, to get the first keys in each Tablet, construct a `new
> Range($endRow)`, open a Scanner and fetch the first Key. Make sure you also
> do this with `new Range()` as well to get the first Key in the first Tablet
> for the table (the Tablet which starts at -inf).
>
> There is no easy way that I can think of to determine what the last key in a
> Tablet is. What is the reason that you want to explicitly know this? Maybe
> there is a different to do what you're trying to do?
>
> - Josh
>
>
> Rukshan Chathuranga wrote:
>>
>> hi,
>>
>> Does anyone know how to get the first or last key of the tablet servers?
>>
>> Thanks and Regards.
>>
>> /Rukshan Chathuranga./
>> /Department Of Computer Science & Engineering,
>> /
>> /Faculty Of Engineering,
>> /
>> /University Of Moratuwa. //Sri Lanka./
>> /WEB: http://www.rukspot.com/ <http://rukspot.com/>
>> /
>>
>

Re: How to get the first key of the Tablet servers

Posted by Christopher <ct...@apache.org>.
The exception you're seeing are because you specified some
authorizations in the scanner at scan time, which are not set on the
user. The way the scan API works is that users are allowed to query
with any subset of their authorizations. To grant auths to the user,
use connector.tableOperations().changeUserAuthorizations(username,
...).

Since you're using mini, you're probably going to use "root" for the
username, unless you've created a separate user. Regardless of the
target user, though, you'll have to use the root user's connector to
perform this operation, since other users won't have permission to
grant themselves authorizations.

--
Christopher L Tubbs II
http://gravatar.com/ctubbsii


On Tue, Jun 16, 2015 at 2:33 AM, Rukshan Chathuranga
<rc...@gmail.com> wrote:
> Hi,
>
> yes i mean the tablets.
>
> And i need the Key object for some implementation on Geowave.
>
> I tried as you said. But i get the Exception
> "org.apache.accumulo.core.client.AccumuloSecurityException: Error
> BAD_AUTHORIZATIONS for user root on table t1(ID:1) - The user does not have
> the specified authorizations assigned"
>
> I am using miniAccumuloCluster. Do you know how to set the authorization?
>
> Thanks and Regards.
>
>
>
> Rukshan Chathuranga.
> Department Of Computer Science & Engineering,
> Faculty Of Engineering,
> University Of Moratuwa. Sri Lanka.
> WEB: http://www.rukspot.com/
>
>
> On Tue, Jun 16, 2015 at 10:54 AM, Josh Elser <jo...@gmail.com> wrote:
>>
>> Not sure I understand your question. Do you mean of a Tablet instead of
>> TabletServer? A TabletServer will host many Tablets.
>>
>> Assuming so, the easiest way to get the first key for each Tablet is to
>> fetch the split points for a table. The split points are the end-row of each
>> Tablet in a table.
>>
>> Then, to get the first keys in each Tablet, construct a `new
>> Range($endRow)`, open a Scanner and fetch the first Key. Make sure you also
>> do this with `new Range()` as well to get the first Key in the first Tablet
>> for the table (the Tablet which starts at -inf).
>>
>> There is no easy way that I can think of to determine what the last key in
>> a Tablet is. What is the reason that you want to explicitly know this? Maybe
>> there is a different to do what you're trying to do?
>>
>> - Josh
>>
>>
>> Rukshan Chathuranga wrote:
>>>
>>> hi,
>>>
>>> Does anyone know how to get the first or last key of the tablet servers?
>>>
>>> Thanks and Regards.
>>>
>>> /Rukshan Chathuranga./
>>> /Department Of Computer Science & Engineering,
>>> /
>>> /Faculty Of Engineering,
>>> /
>>> /University Of Moratuwa. //Sri Lanka./
>>> /WEB: http://www.rukspot.com/ <http://rukspot.com/>
>>> /
>>>
>

Re: How to get the first key of the Tablet servers

Posted by Rukshan Chathuranga <rc...@gmail.com>.
Hi,

yes i mean the tablets.

And i need the Key object for some implementation on Geowave.

I tried as you said. But i get the Exception
"org.apache.accumulo.core.client.AccumuloSecurityException: Error
BAD_AUTHORIZATIONS for user root on table t1(ID:1) - The user does not have
the specified authorizations assigned"

I am using miniAccumuloCluster. Do you know how to set the authorization?

Thanks and Regards.



*Rukshan Chathuranga.*

*Department Of Computer Science & Engineering,*

*Faculty Of Engineering,*
*University Of Moratuwa. **Sri Lanka.*

*WEB: http://www.rukspot.com/ <http://rukspot.com/>*


On Tue, Jun 16, 2015 at 10:54 AM, Josh Elser <jo...@gmail.com> wrote:

> Not sure I understand your question. Do you mean of a Tablet instead of
> TabletServer? A TabletServer will host many Tablets.
>
> Assuming so, the easiest way to get the first key for each Tablet is to
> fetch the split points for a table. The split points are the end-row of
> each Tablet in a table.
>
> Then, to get the first keys in each Tablet, construct a `new
> Range($endRow)`, open a Scanner and fetch the first Key. Make sure you also
> do this with `new Range()` as well to get the first Key in the first Tablet
> for the table (the Tablet which starts at -inf).
>
> There is no easy way that I can think of to determine what the last key in
> a Tablet is. What is the reason that you want to explicitly know this?
> Maybe there is a different to do what you're trying to do?
>
> - Josh
>
>
> Rukshan Chathuranga wrote:
>
>> hi,
>>
>> Does anyone know how to get the first or last key of the tablet servers?
>>
>> Thanks and Regards.
>>
>> /Rukshan Chathuranga./
>> /Department Of Computer Science & Engineering,
>> /
>> /Faculty Of Engineering,
>> /
>> /University Of Moratuwa. //Sri Lanka./
>> /WEB: http://www.rukspot.com/ <http://rukspot.com/>
>> /
>>
>>

Re: How to get the first key of the Tablet servers

Posted by Josh Elser <jo...@gmail.com>.
Not sure I understand your question. Do you mean of a Tablet instead of 
TabletServer? A TabletServer will host many Tablets.

Assuming so, the easiest way to get the first key for each Tablet is to 
fetch the split points for a table. The split points are the end-row of 
each Tablet in a table.

Then, to get the first keys in each Tablet, construct a `new 
Range($endRow)`, open a Scanner and fetch the first Key. Make sure you 
also do this with `new Range()` as well to get the first Key in the 
first Tablet for the table (the Tablet which starts at -inf).

There is no easy way that I can think of to determine what the last key 
in a Tablet is. What is the reason that you want to explicitly know 
this? Maybe there is a different to do what you're trying to do?

- Josh


Rukshan Chathuranga wrote:
> hi,
>
> Does anyone know how to get the first or last key of the tablet servers?
>
> Thanks and Regards.
>
> /Rukshan Chathuranga./
> /Department Of Computer Science & Engineering,
> /
> /Faculty Of Engineering,
> /
> /University Of Moratuwa. //Sri Lanka./
> /WEB: http://www.rukspot.com/ <http://rukspot.com/>
> /
>