Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-24901

Create versatile hbase-shell table formatter

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.0-alpha-1
    • None
    • shell
    • None

    Description

      As a user, I would like a simple interface for shell output that can be expressed as a table (ie. output with a fixed number of columns and potentially many rows). To be clear, this new formatter is not specifically for HBase "tables." Table is used in the broader sense here.

      Goals

      • Do not require more than one output cell loaded in memory at a time
      • Support many implementations like aligned human-friendly tables, unaligned delimited, and JSON

      Non-goals

      • Don't load all the headers into memory at once.
        • This may seem like a goal with merit, but we are unlikely to find a use case for this formatter with many columns. For example: since HBase tables aren't relational, our scan output will not have an output column for every HBase column. Instead, each output row will correspond to an HBase cell.
        • It's also really useful to have the headers ahead of time, because it allows us to do things like JSON object output (where each row is represented with key-value pairs).

      Implementation

      This patch was implemented as a stateful output formatter for data with a fixed number of output columns. Tracking state inside the formatter is an important design feature so that we don't have to feed the formatter all the data at once.

      This patch comes with three implementations of the table formatter: Aligned, Unaligned, and JSON.

      Formatter Usage Pattern

      The verbose way to use the formatter to print a table is as follows:
      1. call start_table to reset the formatter's state and pass configuration options
      2. call start_row to start writing a row
      3. call cell to write a single cell
      4. call close_row
      5. call close_table

      Sometimes, it will feel like this is a lot of method calls, but these calls act as "hooks"
      and give each of the formatter implementations a chance to fill out all the content necessary
      between cells. To cut down on boilerplate, there are shortcut methods like row and single_value_table.

      Attachments

        1. HBase Shell Default TableFormatter hb9e903.png
          390 kB
          Elliot Miller
        2. HBASE-24901_scan_output_comparison.png
          226 kB
          Elliot Miller

        Issue Links

          Activity

            People

              bitoffdev Elliot Miller
              bitoffdev Elliot Miller
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: