HADOOP-2004 [hbase] webapp hql formatting bugs

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@582867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2007-10-08 16:25:33 +00:00
parent eb22494fb4
commit 79b3b1c6b2
3 changed files with 18 additions and 8 deletions

View File

@ -69,6 +69,7 @@ Trunk (unreleased changes)
HADOOP-1996 TestHStoreFile fails on windows if run multiple times
HADOOP-1937 When the master times out a region server's lease, it is too
aggressive in reclaiming the server's log.
HADOOP-2004 webapp hql formatting bugs
IMPROVEMENTS
HADOOP-1737 Make HColumnDescriptor data publically members settable

View File

@ -76,8 +76,8 @@ public class DescCommand extends BasicCommand {
tmp = tmp.substring(1, tmp.length() - 1);
}
columnStrs[i] = tmp;
formatter.row(new String [] {columnStrs[i]});
}
formatter.row(columnStrs);
formatter.footer();
return new ReturnMsg(1, columns.length + " columnfamily(s) in set");
} catch (IOException e) {

View File

@ -1,6 +1,7 @@
package org.apache.hadoop.hbase.shell.formatter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.apache.hadoop.hbase.shell.TableFormatter;
@ -8,14 +9,14 @@ import org.znerd.xmlenc.LineBreak;
import org.znerd.xmlenc.XMLOutputter;
/**
* Formatter that outputs data inside an HTML table.
* If only a single cell result, then no formatting is done. Presumption is
* that client manages serial access outputting tables. Does not close passed
* {@link Writer}.
* Formatter that outputs data inside an HTML table. If only a single cell
* result, then no formatting is done. Presumption is that client manages
* serial access outputting tables. Does not close passed {@link Writer}.
* Since hbase columns have no typing, the formatter presumes a type of
* UTF-8 String. If cells contain images, etc., this formatter will mangle
* their display.
* <p>TODO: Uses xmlenc. Hopefully it flushes every so often (Claims its a
* stream-based outputter). Verify.
* <p>For now, invoke it this way (until shell starts to take cmdline params);
* <code>$ HBASE_OPTS='-Dhbaseshell.formatter=org.apache.hadoop.hbase.shell.TableFormatterFactory$HtmlTableFormatter' ./bin/hbase shell</code>
*/
public class HtmlTableFormatter implements TableFormatter {
private final XMLOutputter outputter;
@ -70,7 +71,7 @@ public class HtmlTableFormatter implements TableFormatter {
public void row(String [] cells) throws IOException{
if (isNoFormatting()) {
this.outputter.pcdata(cells[0]);
getOut().write(cells[0]);
return;
}
this.outputter.startTag("tr");
@ -108,4 +109,12 @@ public class HtmlTableFormatter implements TableFormatter {
public void setNoFormatting(boolean noFormatting) {
this.noFormatting = noFormatting;
}
public static void main(String[] args) throws IOException {
HtmlTableFormatter f =
new HtmlTableFormatter(new OutputStreamWriter(System.out, "UTF-8"));
f.header(new String [] {"a", "b"});
f.row(new String [] {"a", "b"});
f.footer();
}
}