paul-rogers commented on a change in pull request #1500: DRILL-6820: Msgpack format reader URL: https://github.com/apache/drill/pull/1500#discussion_r230650119
########## 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; Review comment: This seems like an odd option for a distributed system. If your plugin runs on a dozen hosts, where does the data go? There is another way to handle this: using a config (not session) option. Just define a new option in your `drill-module.conf` file and set a default value of `false`. Then, at runtime, you can set it to `true` in your `drill-override.conf` file. I believe this is an area you want to get right the first time. I believe Drill will simply fail to start if you have stored configs that use this field, but your format object is modified to remove this field. Sadly, Drill provides no versioning of these plugin configs, so AFAIK, you can't change them once they are released. ---------------------------------------------------------------- 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
