Updated Branches:
  refs/heads/master 238ca97d5 -> ce3f1c603

DRILL-21: demo improvements


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/ce3f1c60
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/ce3f1c60
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/ce3f1c60

Branch: refs/heads/master
Commit: ce3f1c603838c9fd0ba8b40f44c33fe30f9af5b1
Parents: 238ca97
Author: Gera Shegalov <[email protected]>
Authored: Thu Jan 24 11:47:00 2013 -0800
Committer: Gera Shegalov <[email protected]>
Committed: Thu Jan 24 11:47:00 2013 -0800

----------------------------------------------------------------------
 .../drill/exec/ref/ReferenceInterpreter.java       |    4 +-
 .../org/apache/drill/exec/ref/rops/JSONWriter.java |   18 +++++++++++-
 .../exec/ref/src/test/resources/donuts.json        |   10 +++---
 .../exec/ref/src/test/resources/simple_plan.json   |   22 +++++++-------
 4 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ce3f1c60/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/ReferenceInterpreter.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/ReferenceInterpreter.java
 
b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/ReferenceInterpreter.java
index 1c6d0b8..7621b7f 100644
--- 
a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/ReferenceInterpreter.java
+++ 
b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/ReferenceInterpreter.java
@@ -81,7 +81,7 @@ public class ReferenceInterpreter {
   
   public static void main(String[] args) throws Exception{
 
-    
+    final String jsonFile = args[0];
     ObjectMapper mapper = new ObjectMapper();
     
     mapper.enable(SerializationFeature.INDENT_OUTPUT);
@@ -92,7 +92,7 @@ public class ReferenceInterpreter {
     mapper.registerSubtypes(DataSource.SUB_TYPES);
     mapper.registerSubtypes(RecordMaker.SUB_TYPES);
 
-    String externalPlan = Files.toString(new 
File("src/test/resources/simple_plan.json"), Charsets.UTF_8);
+    String externalPlan = Files.toString(new File(jsonFile), Charsets.UTF_8);
     LogicalPlan plan = mapper.readValue(externalPlan, LogicalPlan.class);
     IteratorRegistry ir = new IteratorRegistry();
     ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new 
BasicEvaluatorFactory(ir));

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ce3f1c60/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JSONWriter.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JSONWriter.java
 
b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JSONWriter.java
index 5dd30d4..23b4e79 100644
--- 
a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JSONWriter.java
+++ 
b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/JSONWriter.java
@@ -38,8 +38,22 @@ public class JSONWriter extends BaseSinkROP<Write> {
 
   @Override
   protected void setupSink() throws IOException {
-    FileSystem fs = FileSystem.get(new Configuration());
-    output = fs.create(new Path(config.getFileName()));
+    final Path sinkPath = new Path(config.getFileName());
+    final String sinkScheme = sinkPath.toUri().getScheme();
+
+    if ("console".equals(sinkScheme)) {
+      final String std = sinkPath.getName();
+      if ("stdout".equals(std)) {
+        output = new FSDataOutputStream(System.out);
+      } else if ("stderr".equals(std)) {
+        output = new FSDataOutputStream(System.err);
+      } else {
+        throw new IOException(std + ": Invalid console sink");
+      }
+    } else {
+      final FileSystem fs = FileSystem.get(new Configuration());
+      output = fs.create(new Path(config.getFileName()));
+    }
     writer = new JSONDataWriter(output);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ce3f1c60/sandbox/prototype/exec/ref/src/test/resources/donuts.json
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/resources/donuts.json 
b/sandbox/prototype/exec/ref/src/test/resources/donuts.json
index d9d69fe..2d98b59 100644
--- a/sandbox/prototype/exec/ref/src/test/resources/donuts.json
+++ b/sandbox/prototype/exec/ref/src/test/resources/donuts.json
@@ -55,7 +55,7 @@
                "name": "Old Fashioned",
                "ppu": 0.55,
                "sales": 300,
-               
+
                "batters":
                        {
                                "batter":
@@ -78,7 +78,7 @@
                "name": "Filled",
                "ppu": 0.69,
                "sales": 14,
-               
+
                "batters":
                        {
                                "batter":
@@ -106,7 +106,7 @@
                                { "id": "6003", "type": "Lemon" },
                                { "id": "6004", "type": "Chocolate" },
                                { "id": "6005", "type": "Kreme" }
-                       ]                       
+                       ]
        }
                {
                "id": "0005",
@@ -114,7 +114,7 @@
                "name": "Apple Fritter",
                "ppu": 1.00,
                "sales": 700,
-               
+
                "batters":
                        {
                                "batter":
@@ -126,4 +126,4 @@
                        [
                                { "id": "5002", "type": "Glazed" }
                        ]
-       }
\ No newline at end of file
+       }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/ce3f1c60/sandbox/prototype/exec/ref/src/test/resources/simple_plan.json
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/resources/simple_plan.json 
b/sandbox/prototype/exec/ref/src/test/resources/simple_plan.json
index f4f6b5b..f1cea95 100644
--- a/sandbox/prototype/exec/ref/src/test/resources/simple_plan.json
+++ b/sandbox/prototype/exec/ref/src/test/resources/simple_plan.json
@@ -10,7 +10,7 @@
   sources:[
     {
       type:"json",
-      name:"local-logs",
+      name:"donuts-json",
       files:[
         "src/test/resources/donuts.json"
       ]
@@ -24,16 +24,16 @@
              op: "scan",
              memo: "initial_scan",
              ref: "donuts",
-             source: "local-logs",
+             source: "donuts-json",
              selection: {data: "activity"}
            },
            {
              op: "transform",
              transforms: [
-               { ref: "donuts.quanity", expr: "donuts.sales"}
+               { ref: "donuts.quantity", expr: "donuts.sales"}
              ]
            },
-           { 
+           {
              op: "filter",
              expr: "donuts.ppu < 1.00"
            },
@@ -53,24 +53,24 @@
                { ref: "donuts.sales",  expr: "sum(donuts.ppu * donuts.sales)" }
              ]
            },
-           { 
+           {
              op: "order",
              orderings: [
                {order: "desc", expr: "donuts.ppu" }
              ]
-           },      
+           },
            {
              op: "project",
              projections: [
                { ref: "output", expr: "donuts" }
              ]
-           },      
+           },
            {
              op: "write",
-             memo: "save file",
-             file: "file:///opt/data/out.json"
-           }     
+             memo: "output sink",
+             file: "console:///stdout"
+           }
       ]
     }
   ]
-}
\ No newline at end of file
+}

Reply via email to