You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Pete Haidinyak <ja...@cox.net> on 2011/02/03 09:00:42 UTC

doing a scan that will return random columns in a table's family

Hi,
	If I have a table:family where I add new columns with computer generated  
column name (I won't know what they are to add them to a scan) is it  
possible to do a scan that returns every column in a row?

Thanks

-Pete


RE: doing a scan that will return random columns in a table's family

Posted by Peter Haidinyak <ph...@local.com>.
Thanks 

-----Original Message-----
From: Jonathan Gray [mailto:jgray@fb.com] 
Sent: Thursday, February 03, 2011 10:19 AM
To: user@hbase.apache.org
Subject: RE: doing a scan that will return random columns in a table's family

Result is just the client-side class which wraps whatever the server returns.  The ability to do this query is not really about whether Result has the methods to get at this data, but rather whether Scan supports this type of query (it does).

Scan.addFamily(family) will make it so that every column in the specified family is returned.

The Result that gets returned can be used in many different ways, including those described by David.  However, I generally recommend using Result.raw() and just operating directly on the KeyValues that are returned.  There is a non-zero cost to generating the maps via the convenience methods in Result.  Some of the more recent javadoc is a bit more explicit about that.

JG

> -----Original Message-----
> From: Peter Haidinyak [mailto:phaidinyak@local.com]
> Sent: Thursday, February 03, 2011 8:59 AM
> To: user@hbase.apache.org
> Subject: RE: doing a scan that will return random columns in a table's family
> 
> Thanks
> 
> -----Original Message-----
> From: Buttler, David [mailto:buttler1@llnl.gov]
> Sent: Thursday, February 03, 2011 8:53 AM
> To: user@hbase.apache.org
> Subject: RE: doing a scan that will return random columns in a table's family
> 
> By default that is what you get.  You do have to navigate through the results:
> 
> Result.getFamilyMap():
> 
> /**
>    * Map of qualifiers to values.
>    * <p>
>    * Returns a Map of the form: <code>Map&lt;qualifier,value></code>
>    * @param family column family to get
>    * @return map of qualifiers to values
>    */
>   public NavigableMap<byte[], byte[]> getFamilyMap(byte [] family)
> 
> 
> Or if you don't know the family name even, use the Result.getMap() function
> 
> /**
>    * Map of families to all versions of its qualifiers and values.
>    * <p>
>    * Returns a three level Map of the form:
>    *
> <code>Map<family,Map&lt;qualifier,Map&lt;timestamp,value>>></code>
>    * <p>
>    * Note: All other map returning methods make use of this map internally.
>    * @return map from families to qualifiers to versions
>    */
>   public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long,
> byte[]>>> getMap()
> 
> -----Original Message-----
> From: Pete Haidinyak [mailto:javamann@cox.net]
> Sent: Thursday, February 03, 2011 12:01 AM
> To: user@hbase.apache.org
> Subject: doing a scan that will return random columns in a table's family
> 
> Hi,
> 	If I have a table:family where I add new columns with computer
> generated column name (I won't know what they are to add them to a scan)
> is it possible to do a scan that returns every column in a row?
> 
> Thanks
> 
> -Pete


RE: doing a scan that will return random columns in a table's family

Posted by Jonathan Gray <jg...@fb.com>.
Result is just the client-side class which wraps whatever the server returns.  The ability to do this query is not really about whether Result has the methods to get at this data, but rather whether Scan supports this type of query (it does).

Scan.addFamily(family) will make it so that every column in the specified family is returned.

The Result that gets returned can be used in many different ways, including those described by David.  However, I generally recommend using Result.raw() and just operating directly on the KeyValues that are returned.  There is a non-zero cost to generating the maps via the convenience methods in Result.  Some of the more recent javadoc is a bit more explicit about that.

JG

> -----Original Message-----
> From: Peter Haidinyak [mailto:phaidinyak@local.com]
> Sent: Thursday, February 03, 2011 8:59 AM
> To: user@hbase.apache.org
> Subject: RE: doing a scan that will return random columns in a table's family
> 
> Thanks
> 
> -----Original Message-----
> From: Buttler, David [mailto:buttler1@llnl.gov]
> Sent: Thursday, February 03, 2011 8:53 AM
> To: user@hbase.apache.org
> Subject: RE: doing a scan that will return random columns in a table's family
> 
> By default that is what you get.  You do have to navigate through the results:
> 
> Result.getFamilyMap():
> 
> /**
>    * Map of qualifiers to values.
>    * <p>
>    * Returns a Map of the form: <code>Map&lt;qualifier,value></code>
>    * @param family column family to get
>    * @return map of qualifiers to values
>    */
>   public NavigableMap<byte[], byte[]> getFamilyMap(byte [] family)
> 
> 
> Or if you don't know the family name even, use the Result.getMap() function
> 
> /**
>    * Map of families to all versions of its qualifiers and values.
>    * <p>
>    * Returns a three level Map of the form:
>    *
> <code>Map<family,Map&lt;qualifier,Map&lt;timestamp,value>>></code>
>    * <p>
>    * Note: All other map returning methods make use of this map internally.
>    * @return map from families to qualifiers to versions
>    */
>   public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long,
> byte[]>>> getMap()
> 
> -----Original Message-----
> From: Pete Haidinyak [mailto:javamann@cox.net]
> Sent: Thursday, February 03, 2011 12:01 AM
> To: user@hbase.apache.org
> Subject: doing a scan that will return random columns in a table's family
> 
> Hi,
> 	If I have a table:family where I add new columns with computer
> generated column name (I won't know what they are to add them to a scan)
> is it possible to do a scan that returns every column in a row?
> 
> Thanks
> 
> -Pete


RE: doing a scan that will return random columns in a table's family

Posted by Peter Haidinyak <ph...@local.com>.
Thanks

-----Original Message-----
From: Buttler, David [mailto:buttler1@llnl.gov] 
Sent: Thursday, February 03, 2011 8:53 AM
To: user@hbase.apache.org
Subject: RE: doing a scan that will return random columns in a table's family

By default that is what you get.  You do have to navigate through the results:

Result.getFamilyMap():

/**
   * Map of qualifiers to values.
   * <p>
   * Returns a Map of the form: <code>Map&lt;qualifier,value></code>
   * @param family column family to get
   * @return map of qualifiers to values
   */
  public NavigableMap<byte[], byte[]> getFamilyMap(byte [] family)


Or if you don't know the family name even, use the Result.getMap() function

/**
   * Map of families to all versions of its qualifiers and values.
   * <p>
   * Returns a three level Map of the form:
   * <code>Map<family,Map&lt;qualifier,Map&lt;timestamp,value>>></code>
   * <p>
   * Note: All other map returning methods make use of this map internally.
   * @return map from families to qualifiers to versions
   */
  public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> getMap()

-----Original Message-----
From: Pete Haidinyak [mailto:javamann@cox.net] 
Sent: Thursday, February 03, 2011 12:01 AM
To: user@hbase.apache.org
Subject: doing a scan that will return random columns in a table's family

Hi,
	If I have a table:family where I add new columns with computer generated  
column name (I won't know what they are to add them to a scan) is it  
possible to do a scan that returns every column in a row?

Thanks

-Pete


RE: doing a scan that will return random columns in a table's family

Posted by "Buttler, David" <bu...@llnl.gov>.
By default that is what you get.  You do have to navigate through the results:

Result.getFamilyMap():

/**
   * Map of qualifiers to values.
   * <p>
   * Returns a Map of the form: <code>Map&lt;qualifier,value></code>
   * @param family column family to get
   * @return map of qualifiers to values
   */
  public NavigableMap<byte[], byte[]> getFamilyMap(byte [] family)


Or if you don't know the family name even, use the Result.getMap() function

/**
   * Map of families to all versions of its qualifiers and values.
   * <p>
   * Returns a three level Map of the form:
   * <code>Map<family,Map&lt;qualifier,Map&lt;timestamp,value>>></code>
   * <p>
   * Note: All other map returning methods make use of this map internally.
   * @return map from families to qualifiers to versions
   */
  public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> getMap()

-----Original Message-----
From: Pete Haidinyak [mailto:javamann@cox.net] 
Sent: Thursday, February 03, 2011 12:01 AM
To: user@hbase.apache.org
Subject: doing a scan that will return random columns in a table's family

Hi,
	If I have a table:family where I add new columns with computer generated  
column name (I won't know what they are to add them to a scan) is it  
possible to do a scan that returns every column in a row?

Thanks

-Pete