Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT Conflicts: core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/ab4ecfc2 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/ab4ecfc2 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/ab4ecfc2 Branch: refs/heads/ACCUMULO-378 Commit: ab4ecfc252d3a634f4e266819c4226a6fc30212c Parents: b65035a 3d469eb Author: Josh Elser <els...@apache.org> Authored: Thu Jun 12 22:35:09 2014 -0400 Committer: Josh Elser <els...@apache.org> Committed: Thu Jun 12 22:35:09 2014 -0400 ---------------------------------------------------------------------- .../apache/accumulo/core/iterators/Combiner.java | 10 +++++----- .../accumulo/core/util/format/DefaultFormatter.java | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/ab4ecfc2/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/ab4ecfc2/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java ---------------------------------------------------------------------- diff --cc core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java index acd4ba1,2b8a88c..931b59f --- a/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java +++ b/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java @@@ -92,55 -56,33 +92,55 @@@ public class DefaultFormatter implement if (!expectInitialized && si != null) throw new IllegalStateException("Already initialized"); } - + // this should be replaced with something like Record.toString(); public static String formatEntry(Entry<Key,Value> entry, boolean showTimestamps) { + DateFormat timestampFormat = null; + + if(showTimestamps) { + timestampFormat = formatter.get(); + } + + return formatEntry(entry, timestampFormat); + } + + /* so a new date object doesn't get created for every record in the scan result */ + private static ThreadLocal<Date> tmpDate = new ThreadLocal<Date>() { + @Override + protected Date initialValue() { + return new Date(); + } + }; + + public static String formatEntry(Entry<Key,Value> entry, DateFormat timestampFormat) { StringBuilder sb = new StringBuilder(); - Key key = entry.getKey(); + Text buffer = new Text(); - + // append row - appendText(sb, key.getRow()).append(" "); - + appendText(sb, key.getRow(buffer)).append(" "); + // append column family - appendText(sb, key.getColumnFamily()).append(":"); - + appendText(sb, key.getColumnFamily(buffer)).append(":"); + // append column qualifier - appendText(sb, key.getColumnQualifier()).append(" "); - + appendText(sb, key.getColumnQualifier(buffer)).append(" "); + // append visibility expression - sb.append(new ColumnVisibility(key.getColumnVisibility())); + sb.append(new ColumnVisibility(key.getColumnVisibility(buffer))); // append timestamp - if (showTimestamps) - sb.append(" ").append(key.getTimestamp()); - + if (timestampFormat != null) { + tmpDate.get().setTime(entry.getKey().getTimestamp()); + sb.append(" ").append(timestampFormat.format(tmpDate.get())); + } + + Value value = entry.getValue(); + // append value - if (entry.getValue() != null && entry.getValue().getSize() > 0) { + if (value != null && value.getSize() > 0) { sb.append("\t"); - appendValue(sb, entry.getValue()); + appendValue(sb, value); } return sb.toString();