Github user jaltekruse commented on a diff in the pull request:

    https://github.com/apache/drill/pull/451#discussion_r58902477
  
    --- Diff: 
contrib/storage-xml/src/main/java/org/apache/drill/exec/store/easy/xml/XMLFormatPlugin.java
 ---
    @@ -0,0 +1,139 @@
    +/**
    + * 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.easy.xml;
    +
    +import java.io.IOException;
    +import java.net.URL;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.drill.common.exceptions.ExecutionSetupException;
    +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.ExecConstants;
    +import org.apache.drill.exec.ops.FragmentContext;
    +import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
    +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.FileSystemConfig;
    +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.easy.xml.XMLFormatPlugin.XMLFormatConfig;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.fs.FileSystem;
    +import org.apache.drill.exec.store.easy.xml.XMLRecordReader;
    +
    +import com.fasterxml.jackson.annotation.JsonInclude;
    +import com.fasterxml.jackson.annotation.JsonTypeName;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Maps;
    +
    +/**
    + * Created by mpierre on 15-11-04.
    + */
    +
    +public class XMLFormatPlugin extends EasyFormatPlugin<XMLFormatConfig> {
    +
    +    private static final boolean IS_COMPRESSIBLE = false;
    +    private static final String DEFAULT_NAME = "xml";
    +    private Boolean keepPrefix = true;
    +    private XMLFormatConfig xmlConfig;
    +
    +    public XMLFormatPlugin(String name, DrillbitContext context, 
Configuration fsConf, StoragePluginConfig storageConfig) {
    +        this(name, context, fsConf, storageConfig, new XMLFormatConfig());
    +    }
    +
    +    public XMLFormatPlugin(String name, DrillbitContext context, 
Configuration fsConf, StoragePluginConfig config, XMLFormatConfig 
formatPluginConfig) {
    +        super(name, context, fsConf, config, formatPluginConfig, true, 
false, false, IS_COMPRESSIBLE, formatPluginConfig.getExtensions(), 
DEFAULT_NAME);
    +        xmlConfig = formatPluginConfig;
    +    }
    +
    +    @Override
    +    public RecordReader getRecordReader(FragmentContext context, 
DrillFileSystem dfs, FileWork fileWork,
    +                                        List<SchemaPath> columns, String 
userName) throws ExecutionSetupException {
    +        return new XMLRecordReader(context, fileWork.getPath(), dfs, 
columns, xmlConfig);
    +    }
    +
    +
    +    @Override
    +    public int getReaderOperatorType() {
    +        return CoreOperatorType.JSON_SUB_SCAN_VALUE;
    --- End diff --
    
    There is a limitation in Drill that makes this hard to implement correctly. 
In the past we have been adding a new value in a Protobuf definition for each 
new storage or format plugin so that we can send information about this 
operation and report what type it is. Unfortunately this is not flexible and 
doesn't really fit the user-extensible model for format plugins. I don't expect 
you to fix this issues as part of this pull request, I'll start a thread on the 
list about this.
    
    To prevent confusion, it might be better to just return -1 here, which 
should show up on the web UI query profiles as unknown operator.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to