paul-rogers commented on a change in pull request #1500: DRILL-6820: Msgpack 
format reader
URL: https://github.com/apache/drill/pull/1500#discussion_r230650798
 
 

 ##########
 File path: 
contrib/format-msgpack/src/main/java/org/apache/drill/exec/store/msgpack/MsgpackFormatPlugin.java
 ##########
 @@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.store.msgpack;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.logical.FormatPluginConfig;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.exec.ops.FragmentContext;
+import org.apache.drill.exec.proto.UserBitShared.CoreOperatorType;
+import org.apache.drill.exec.server.DrillbitContext;
+import org.apache.drill.exec.store.RecordReader;
+import org.apache.drill.exec.store.RecordWriter;
+import org.apache.drill.exec.store.dfs.DrillFileSystem;
+import org.apache.drill.exec.store.dfs.FormatMatcher;
+import org.apache.drill.exec.store.dfs.easy.EasyFormatPlugin;
+import org.apache.drill.exec.store.dfs.easy.EasyWriter;
+import org.apache.drill.exec.store.dfs.easy.FileWork;
+import 
org.apache.drill.exec.store.msgpack.MsgpackFormatPlugin.MsgpackFormatConfig;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
+import org.apache.hadoop.conf.Configuration;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+public class MsgpackFormatPlugin extends EasyFormatPlugin<MsgpackFormatConfig> 
{
+
+  private static final boolean IS_COMPRESSIBLE = true;
+  public static final String DEFAULT_NAME = "msgpack";
+
+  public MsgpackFormatPlugin(String name, DrillbitContext context, 
Configuration fsConf,
+      StoragePluginConfig storageConfig) {
+    this(name, context, fsConf, storageConfig, new MsgpackFormatConfig());
+  }
+
+  public MsgpackFormatPlugin(String name, DrillbitContext context, 
Configuration fsConf, StoragePluginConfig config,
+      MsgpackFormatConfig formatPluginConfig) {
+    super(name, context, fsConf, config, formatPluginConfig, true, false, 
false, IS_COMPRESSIBLE,
+        formatPluginConfig.getExtensions(), DEFAULT_NAME);
+  }
+
+  @Override
+  public FormatMatcher getMatcher() {
+    return super.getMatcher();
+  }
+
+  @Override
+  public RecordReader getRecordReader(FragmentContext context, DrillFileSystem 
dfs, FileWork fileWork,
+      List<SchemaPath> columns, String userName) {
+    return new MsgpackRecordReader(getConfig(), context, fileWork.getPath(), 
dfs, columns);
+  }
+
+  @Override
+  public RecordWriter getRecordWriter(FragmentContext context, EasyWriter 
writer) throws IOException {
+    throw new UnsupportedOperationException();
+  }
+
+  @JsonTypeName("msgpack")
+  public static class MsgpackFormatConfig implements FormatPluginConfig {
+
+    public List<String> extensions = ImmutableList.of("mp");
+    private boolean readBinaryAsString = false;
+    private boolean lenient = true;
+    private boolean printToConsole = true;
+    private boolean learnSchema = true;
+    private boolean useSchema = true;
 
 Review comment:
   Again, should this be a format option, or a per-query option? At present, 
session options (as described above) are the only choice.
   
   Or, this can be automatic: if the root directory (the directory that 
contains the file, or as identified in the plan for a directory scan) contains 
a file with a name you specify, read that file to obtain the schema.
   
   The ideal solution would be to use a table function, but, alas, table 
functions don't inherit values from the plugin config; if you use them, you 
must specify all options. And, when you do so, the implementation places 
Draconian restrictions on what you can do in this class. (I think all the 
members must be simple types and public, if I recall correctly.)

----------------------------------------------------------------
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