You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2007/10/08 18:25:34 UTC

svn commit: r582867 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/java/org/apache/hadoop/hbase/shell/DescCommand.java src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java

Author: stack
Date: Mon Oct  8 09:25:33 2007
New Revision: 582867

URL: http://svn.apache.org/viewvc?rev=582867&view=rev
Log:
HADOOP-2004 [hbase] webapp hql formatting bugs

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=582867&r1=582866&r2=582867&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Mon Oct  8 09:25:33 2007
@@ -69,6 +69,7 @@
     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

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java?rev=582867&r1=582866&r2=582867&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java Mon Oct  8 09:25:33 2007
@@ -76,8 +76,8 @@
           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) {

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java?rev=582867&r1=582866&r2=582867&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java Mon Oct  8 09:25:33 2007
@@ -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.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 void row(String [] cells) throws IOException{
     if (isNoFormatting()) {
-      this.outputter.pcdata(cells[0]);
+      getOut().write(cells[0]);
       return;
     }
     this.outputter.startTag("tr");
@@ -107,5 +108,13 @@
 
   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();
   }
 }