getting start and stop key

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

getting start and stop key

Rajeshkumar J
Hi,

I am running mapreduce over hbase table using java and I want to know which
is the startkey and stopkey for every region. As every mapper takes a
region as input I need to know the startkey and stopkey of a region in the
map function. Is there any function to get that or is there any way to
achieve this

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting start and stop key

Ankit Singhal-3
Hi RajeshKumar,

you can try this.(InputSplit class may vary depending upon the InputFormat
you are using,  below example is for TableInputFormat)
TableSplit tableSplit = (TableSplit)context.getInputSplit();
byte[] startRow=tableSplit.getStartRow()
byte[] endRow=tableSplit.getEndRow()

Regards,
Ankit Singhal

On Mon, Jun 5, 2017 at 5:38 AM, Rajeshkumar J <[hidden email]>
wrote:

> Hi,
>
> I am running mapreduce over hbase table using java and I want to know which
> is the startkey and stopkey for every region. As every mapper takes a
> region as input I need to know the startkey and stopkey of a region in the
> map function. Is there any function to get that or is there any way to
> achieve this
>
> Thanks
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting start and stop key

Rajeshkumar J
I am getting start rowkey as empty and stop rowkey as empty. Is this
possible?

On Mon, Jun 5, 2017 at 11:19 PM, Ankit Singhal <[hidden email]>
wrote:

> Hi RajeshKumar,
>
> you can try this.(InputSplit class may vary depending upon the InputFormat
> you are using,  below example is for TableInputFormat)
> TableSplit tableSplit = (TableSplit)context.getInputSplit();
> byte[] startRow=tableSplit.getStartRow()
> byte[] endRow=tableSplit.getEndRow()
>
> Regards,
> Ankit Singhal
>
> On Mon, Jun 5, 2017 at 5:38 AM, Rajeshkumar J <[hidden email]
> >
> wrote:
>
> > Hi,
> >
> > I am running mapreduce over hbase table using java and I want to know
> which
> > is the startkey and stopkey for every region. As every mapper takes a
> > region as input I need to know the startkey and stopkey of a region in
> the
> > map function. Is there any function to get that or is there any way to
> > achieve this
> >
> > Thanks
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting start and stop key

Ted Yu-3
Looks like your table has only one region.

> On Jun 6, 2017, at 3:14 AM, Rajeshkumar J <[hidden email]> wrote:
>
> I am getting start rowkey as empty and stop rowkey as empty. Is this
> possible?
>
> On Mon, Jun 5, 2017 at 11:19 PM, Ankit Singhal <[hidden email]>
> wrote:
>
>> Hi RajeshKumar,
>>
>> you can try this.(InputSplit class may vary depending upon the InputFormat
>> you are using,  below example is for TableInputFormat)
>> TableSplit tableSplit = (TableSplit)context.getInputSplit();
>> byte[] startRow=tableSplit.getStartRow()
>> byte[] endRow=tableSplit.getEndRow()
>>
>> Regards,
>> Ankit Singhal
>>
>> On Mon, Jun 5, 2017 at 5:38 AM, Rajeshkumar J <[hidden email]
>>>
>> wrote:
>>
>>> Hi,
>>>
>>> I am running mapreduce over hbase table using java and I want to know
>> which
>>> is the startkey and stopkey for every region. As every mapper takes a
>>> region as input I need to know the startkey and stopkey of a region in
>> the
>>> map function. Is there any function to get that or is there any way to
>>> achieve this
>>>
>>> Thanks
>>>
>>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting start and stop key

Sachin Jain
Just to add @Ted Yu's answer, you can confirm this by looking at your
HMaster UI and see the regions and their boundaries.

On Tue, Jun 6, 2017 at 3:50 PM, Ted Yu <[hidden email]> wrote:

> Looks like your table has only one region.
>
> > On Jun 6, 2017, at 3:14 AM, Rajeshkumar J <[hidden email]>
> wrote:
> >
> > I am getting start rowkey as empty and stop rowkey as empty. Is this
> > possible?
> >
> > On Mon, Jun 5, 2017 at 11:19 PM, Ankit Singhal <[hidden email]
> >
> > wrote:
> >
> >> Hi RajeshKumar,
> >>
> >> you can try this.(InputSplit class may vary depending upon the
> InputFormat
> >> you are using,  below example is for TableInputFormat)
> >> TableSplit tableSplit = (TableSplit)context.getInputSplit();
> >> byte[] startRow=tableSplit.getStartRow()
> >> byte[] endRow=tableSplit.getEndRow()
> >>
> >> Regards,
> >> Ankit Singhal
> >>
> >> On Mon, Jun 5, 2017 at 5:38 AM, Rajeshkumar J <
> [hidden email]
> >>>
> >> wrote:
> >>
> >>> Hi,
> >>>
> >>> I am running mapreduce over hbase table using java and I want to know
> >> which
> >>> is the startkey and stopkey for every region. As every mapper takes a
> >>> region as input I need to know the startkey and stopkey of a region in
> >> the
> >>> map function. Is there any function to get that or is there any way to
> >>> achieve this
> >>>
> >>> Thanks
> >>>
> >>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting start and stop key

Gokul Balakrishnan
In reply to this post by Rajeshkumar J
An alternative way that I've used in the past to determine the region
boundaries using the Connection is as follows:

RegionLocator locator =
connection.getRegionLocator(TableName.valueOf("your-table-name"));
final Pair<byte[][], byte[][]> startEndKeys = locator.getStartEndKeys();
byte[][] startKeys = startEndKeys.getFirst();
byte[][] endKeys = startEndKeys.getSecond();


On 5 June 2017 at 18:08, Rajeshkumar J <[hidden email]> wrote:

> Hi,
>
> I am running mapreduce over hbase table using java and I want to know which
> is the startkey and stopkey for every region. As every mapper takes a
> region as input I need to know the startkey and stopkey of a region in the
> map function. Is there any function to get that or is there any way to
> achieve this
>
> Thanks
>
Loading...