hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Busbey (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (HBASE-15611) add examples to shell docs
Date Wed, 20 Sep 2017 13:20:00 GMT

    [ https://issues.apache.org/jira/browse/HBASE-15611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16173164#comment-16173164
] 

Sean Busbey edited comment on HBASE-15611 at 9/20/17 1:19 PM:
--------------------------------------------------------------

h3. How can I find tables that are marked with my own custom metadata?

If you have tables that are annotated with some identifying key, e.g.

HBase 1.y Java Admin API:
{code}
try (Admin admin = connection.getAdmin()) {
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(“my_example_table”) );
  htd.addFamily(new HColumnDescriptor(“family1”));
  htd.setValue(“my.custom.table.metadata”, “value that only means something to me.”)

  admin.createTable(htd);
}
{code}

HBase 2.y Java Admin API:
{code}
try (Admin admin = connection.getAdmin() {
  TableDescriptor td = TableDescriptorBuilder.newBuilder(TableName.valueOf(“my_example_table”))
     .addColumnFamily(ColumnFamilyDescriptorBuilder.of(“family1”))
     .setValue(“my.custom.table.metadata”, “value that only means something to me.”)
     .build();
  admin.createTable(td);
}
{code}

HBase Shell:
{code}
hbase(main):001:0> create 'some_table', 'family', {METADATA => {"my.custom.table.metadata"
=> "value that only means something to me."} }
{code}

You can retrieve a list of those tables that have your custom metadata set in the shell via:

{code}
hbase(main):002:0> @hbase.admin(@formatter).list().select do |table|
hbase(main):003:1*  not get_table(table).table.get_table_descriptor.get_value('my.custom.table.metadata').nil?
hbase(main):004:1> end
{code}




was (Author: busbey):
h3. How can I find tables that are marked with my own custom metadata?

If you have tables that are annotated with some identifying key, e.g.

HBase 1.y Java Admin API:
{code}
try (Admin admin = connection.getAdmin()) {
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(“my_example_table”) );
  htd.addFamily(new HColumnDescriptor(“family1”));
  htd.setValue(“my.custom.table.metadata”, “value that only means something to me.”)

  admin.createTable(htd);
}
{code}

HBase 2.y Java Admin API:
{code}
try (Admin admin = connection.getAdmin() {
  TableDescriptor td = TableDescriptorBuilder.newBuilder(TableName.valueOf(“my_example_table”))
     .addColumnFamily(ColumnFamilyDescriptorBuilder.of(“family1”))
     .setValue(“my.custom.table.metadata”, “value that only means something to me.”)
     .build();
  admin.createTable(td);
}
{code}

HBase Shell:
{code}
hbase(main):001:0> create 'some_table', 'family', {METADATA => {"my.custom.table.metadata"
=> "value that only means something to me."} }
{code}

You can retrieve a list of those tables that have your custom metadata set in the shell via:

{code}
hbase(main):002:0> @hbase.admin(@formatter).list().select do |table|
hbase(main):003:1*  not get_table(table).table.get_table_descriptor.get_value(‘my.custom.table.metadata’).nil?
hbase(main):004:1> end
{code}



> add examples to shell docs 
> ---------------------------
>
>                 Key: HBASE-15611
>                 URL: https://issues.apache.org/jira/browse/HBASE-15611
>             Project: HBase
>          Issue Type: Improvement
>          Components: documentation, shell
>            Reporter: Sean Busbey
>              Labels: beginner
>             Fix For: 2.0.0
>
>
> It would be nice if our shell documentation included some additional examples of operational
tasks one can perform.
> things to include to come in comments. when we have a patch to submit we can update the
jira summary to better reflect what scope we end up with.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message