Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill, mail # dev - [03/29] DRILL-221 Add license header to all files


Copy link to this message
-
[03/29] DRILL-221 Add license header to all files
jacques@... 2013-09-11, 02:04
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/479ddad7/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/ScalarAggregate.java
----------------------------------------------------------------------
diff --git a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/ScalarAggregate.java b/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/ScalarAggregate.java
deleted file mode 100644
index 0d6f4ad..0000000
--- a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/ScalarAggregate.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.apache.drill.plan.json;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-
-/**
- * Created with IntelliJ IDEA.
- * User: tdunning
- * Date: 11/20/12
- * Time: 4:16 PM
- * To change this template use File | Settings | File Templates.
- */
-public class ScalarAggregate extends Consumer {
-    private static final Map<String, Class<? extends AggregationFunction>> aggregators = ImmutableMap.of("sum", Sum.class, "count", Count.class);
-
-    private double result = 0;
-    private AggregationFunction f;
-    private final String sourceVariable;
-
-
-    public ScalarAggregate(JsonObject spec) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
-        f = aggregators.get(spec.get("update").getAsString()).newInstance();
-        sourceVariable = spec.get("source").getAsString();
-    }
-
-    @Override
-    public void push(Tuple t) throws InvocationTargetException, IOException {
-        Object v = t.get(sourceVariable);
-        if (v instanceof Double) {
-            f.update((Double) v);
-        } else if (v instanceof Integer) {
-            f.update((Integer) v);
-        } else {
-            throw new IllegalArgumentException("Wanted a number in " + sourceVariable + " but got a " + v.getClass());
-        }
-    }
-
-    @Override
-    public Object getAggregate() {
-        return f.value();
-    }
-
-    private static abstract class AggregationFunction {
-        protected double value;
-
-        abstract void update(double x);
-
-        protected double value() {
-            return value;
-        }
-    }
-
-    private static class Sum extends AggregationFunction {
-        @Override
-        void update(double x) {
-            value += x;
-        }
-    }
-
-    private static class Count extends AggregationFunction {
-        @Override
-        void update(double x) {
-            value += 1;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/479ddad7/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Scan.java
----------------------------------------------------------------------
diff --git a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Scan.java b/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Scan.java
deleted file mode 100644
index 77dbc46..0000000
--- a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Scan.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.apache.drill.plan.json;
-
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Charsets;
-import com.google.common.base.Splitter;
-import com.google.common.io.*;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Reads CSV data.  Note that quotes are not handled correctly just yet.
- */
-@JsonTypeName("scan")
-public class Scan extends Consumer {
-    private static Splitter onComma = Splitter.on(",").trimResults(CharMatcher.anyOf(" \"'"));
-
-    private Consumer out;
-    private File file;
-    private String resource;
-    private final InputSupplier<InputStreamReader> input;
-
-    public Scan(JsonObject spec) {
-        JsonElement filename = spec.get("file");
-        if (filename != null) {
-            file = new File(filename.getAsString());
-            input = Files.newReaderSupplier(file, Charsets.UTF_8);
-        } else {
-            resource = spec.get("resource").getAsString();
-            input = Resources.newReaderSupplier(Resources.getResource(resource), Charsets.UTF_8);
-        }
-    }
-
-    @Override
-    public void connect(Consumer out) {
-        this.out = out;
-    }
-
-    public void start() throws IOException {
-        CharStreams.readLines(input, new LineProcessor<Object>() {
-            boolean first = true;
-            Iterable<String> header;
-
-            @Override
-            public boolean processLine(String s) throws IOException {
-                if (first) {
-                    header = onComma.split(s);
-                    first = false;
-                } else {
-                    try {
-                        out.push(new MapTuple(header, onComma.split(s)));
-                    } catch (InvocationTargetException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-                return true;
-            }
-
-            @Override
-            public Object getResult() {
-                return null;
-            }
-        });
-    }
-
-    @Override
-    public void push(Tuple t) throws InvocationTargetException {
-        throw new UnsupportedOperationException("Scanner can't process tuples");
-    }
-
-    public File getFile() {
-        return file;
-    }
-
-    public String getResource() {
-        return resource;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/479ddad7/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Sequence.java
diff --git a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Sequence.java b/sandbox/plan-parser/src/main/java/org/apache/drill/plan/json/Sequence.java
del