keith-turner closed pull request #818: Fix #810
URL: https://github.com/apache/accumulo/pull/818
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java 
b/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java
index 2d88103740..bc94b06678 100644
--- a/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java
+++ b/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java
@@ -60,6 +60,7 @@
   private Text textPrevEndRow;
 
   private static final Table.ID EMPTY_ID = Table.ID.of("");
+  private static final Text EMPTY_TEXT = new Text("");
 
   private void check() {
 
@@ -495,11 +496,9 @@ public Range toDataRange() {
   }
 
   public Range toMetadataRange() {
-    Text metadataPrevRow = new Text(getTableId().getUtf8());
-    metadataPrevRow.append(new byte[] {';'}, 0, 1);
-    if (getPrevEndRow() != null) {
-      metadataPrevRow.append(getPrevEndRow().getBytes(), 0, 
getPrevEndRow().getLength());
-    }
+
+    Text metadataPrevRow = TabletsSection.getRow(getTableId(),
+        getPrevEndRow() == null ? EMPTY_TEXT : getPrevEndRow());
 
     return new Range(metadataPrevRow, getPrevEndRow() == null, 
getMetadataEntry(), true);
   }
diff --git 
a/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
 
b/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
index e8e14b86c8..a15fb2333c 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
@@ -51,6 +51,15 @@
     }
   }
 
+  public static class ValueSummarizer extends CountingSummarizer<String> {
+    @Override
+    protected Converter<String> converter() {
+      return (k, v, c) -> {
+        c.accept("vp:" + v.toString().subSequence(0, 2));
+      };
+    }
+  }
+
   @Test
   public void testMultipleEmit() {
     SummarizerConfiguration sc = 
SummarizerConfiguration.builder(MultiSummarizer.class).build();
@@ -255,4 +264,39 @@ public void testCountDeletes() {
     expected.put("f2", 1L);
     assertEquals(expected, csum.getCounters());
   }
+
+  @Test
+  public void testConvertValue() {
+
+    SummarizerConfiguration sc = 
SummarizerConfiguration.builder(ValueSummarizer.class).build();
+    ValueSummarizer countSum = new ValueSummarizer();
+
+    Summarizer.Collector collector = countSum.collector(sc);
+
+    HashMap<String,Long> expected = new HashMap<>();
+
+    for (String row : new String[] {"ask", "asleep", "some", "soul"}) {
+      for (String fam : new String[] {"hop", "hope", "nope", "noop"}) {
+        for (String qual : new String[] {"mad", "lad", "lab", "map"})
+          for (Value value : new Value[] {new Value("ask"), new 
Value("asleep"), new Value("some"),
+              new Value("soul")}) {
+            collector.accept(new Key(row, fam, qual), value);
+            expected.merge("vp:" + value.toString().substring(0, 2), 1L, 
Long::sum);
+
+          }
+      }
+    }
+
+    HashMap<String,Long> stats = new HashMap<>();
+    collector.summarize(stats::put);
+
+    CounterSummary csum = new CounterSummary(stats);
+    assertEquals(expected, csum.getCounters());
+    assertEquals(256, csum.getSeen());
+    assertEquals(256, csum.getEmitted());
+    assertEquals(0, csum.getIgnored());
+    assertEquals(0, csum.getDeletesIgnored());
+
+  }
+
 }
diff --git 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
index fb4a3aaa2c..732a443c3b 100644
--- 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
+++ 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
@@ -19,13 +19,7 @@
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static 
org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.URI;
@@ -88,7 +82,6 @@
 import org.apache.accumulo.server.init.Initialize;
 import org.apache.accumulo.server.util.AccumuloStatus;
 import org.apache.accumulo.server.util.PortUtils;
-import org.apache.accumulo.server.util.time.SimpleTimer;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory;
 import org.apache.accumulo.start.Main;
 import org.apache.accumulo.start.classloader.vfs.MiniDFSUtil;
@@ -128,19 +121,6 @@
     private BufferedReader in;
     private BufferedWriter out;
 
-    public LogWriter(InputStream stream, File logFile) throws IOException {
-      this.in = new BufferedReader(new InputStreamReader(stream));
-      out = new BufferedWriter(new FileWriter(logFile));
-
-      SimpleTimer.getInstance(null).schedule(() -> {
-        try {
-          flush();
-        } catch (IOException e) {
-          log.error("Exception while attempting to flush.", e);
-        }
-      }, 1000, 1000);
-    }
-
     public synchronized void flush() throws IOException {
       if (out != null)
         out.flush();
@@ -333,17 +313,13 @@ private Process _exec(Class<?> clazz, List<String> 
extraJvmOpts, String... args)
     log.debug("Starting MiniAccumuloCluster process with class: " + 
clazz.getSimpleName()
         + "\n, jvmOpts: " + extraJvmOpts + "\n, classpath: " + classpath + 
"\n, args: " + argList
         + "\n, environment: " + builder.environment());
-    Process process = builder.start();
 
-    LogWriter lw;
-    lw = new LogWriter(process.getErrorStream(),
-        new File(config.getLogDir(), clazz.getSimpleName() + "_" + 
process.hashCode() + ".err"));
-    logWriters.add(lw);
-    lw.start();
-    lw = new LogWriter(process.getInputStream(),
-        new File(config.getLogDir(), clazz.getSimpleName() + "_" + 
process.hashCode() + ".out"));
-    logWriters.add(lw);
-    lw.start();
+    builder = builder.redirectError(
+        new File(config.getLogDir(), clazz.getSimpleName() + "_" + 
builder.hashCode() + ".err"));
+    builder = builder.redirectOutput(
+        new File(config.getLogDir(), clazz.getSimpleName() + "_" + 
builder.hashCode() + ".out"));
+
+    Process process = builder.start();
 
     cleanup.add(process);
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to