[ https://issues.apache.org/jira/browse/DRILL-5956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17059215#comment-17059215 ]
ASF GitHub Bot commented on DRILL-5956: --------------------------------------- paul-rogers commented on pull request #1888: DRILL-5956: Add Storage Plugin for Apache Druid URL: https://github.com/apache/drill/pull/1888#discussion_r352263150 ########## File path: contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/DruidRecordReader.java ########## @@ -0,0 +1,173 @@ +/* + * 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.druid; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.apache.drill.common.exceptions.DrillRuntimeException; +import org.apache.drill.common.exceptions.ExecutionSetupException; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.exec.ops.FragmentContext; +import org.apache.drill.exec.ops.OperatorContext; +import org.apache.drill.exec.physical.impl.OutputMutator; +import org.apache.drill.exec.store.AbstractRecordReader; +import org.apache.drill.exec.store.druid.druid.DruidSelectResponse; +import org.apache.drill.exec.store.druid.druid.PagingIdentifier; +import org.apache.drill.exec.store.druid.druid.PagingSpec; +import org.apache.drill.exec.store.druid.druid.SelectQuery; +import org.apache.drill.exec.vector.complex.fn.JsonReader; +import org.apache.drill.exec.vector.complex.impl.VectorContainerWriter; +import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList; +import org.apache.drill.shaded.guava.com.google.common.collect.Sets; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +public class DruidRecordReader extends AbstractRecordReader { + + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DruidRecordReader.class); + private DruidStoragePlugin plugin; + private final DruidSubScan.DruidSubScanSpec scanSpec; + private List<String> dimensions; + private String filters; + private ArrayList<PagingIdentifier> pagingIdentifiers = new ArrayList<>(); + + private JsonReader jsonReader; + private VectorContainerWriter writer; + + private OutputMutator output; + private OperatorContext context; + private final FragmentContext fragmentContext; + + private ObjectMapper objectMapper = new ObjectMapper(); + + public DruidRecordReader(DruidSubScan.DruidSubScanSpec subScanSpec, List<SchemaPath> projectedColumns, + FragmentContext context, DruidStoragePlugin plugin) { + dimensions = new ArrayList<String>(); + setColumns(projectedColumns); + this.plugin = plugin; + scanSpec = subScanSpec; + fragmentContext = context; + this.filters = subScanSpec.getFilter(); + } + + @Override + protected Collection<SchemaPath> transformColumns(Collection<SchemaPath> projectedColumns) { + Set<SchemaPath> transformed = Sets.newLinkedHashSet(); + if (isStarQuery()) { + transformed.add(SchemaPath.STAR_COLUMN); + } else { + for (SchemaPath column : projectedColumns) { + String fieldName = column.getRootSegment().getPath(); + transformed.add(column); + this.dimensions.add(fieldName); + } + } + return transformed; + } + + @Override + public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException { + this.context = context; + this.output = output; + this.writer = new VectorContainerWriter(output); + + //Lists.newArrayList(getColumns()), true, false, false + this.jsonReader = + new JsonReader.Builder(fragmentContext.getManagedBuffer()) + .schemaPathColumns(ImmutableList.copyOf(getColumns())) + .skipOuterList(true) + .build(); + logger.debug(" Initialized JsonRecordReader. "); + } + + @Override + public int next() { Review comment: Ideally, we'd return Druid responses in Drill batches up to some maximum record count, say 1000. This means that a single Druid query might be split into multiple Drill batches, if the number of returned records is large. However, it seems here each call to `next()` executes query and returns all results. Maybe there was some partitioning to split each query (the `DruidWork`) so that each returns a fixed number of records? If so, the second call to `next()` should return 0 so that Drill knows the scan is done. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add Storage Plugin for Apache Druid > ----------------------------------- > > Key: DRILL-5956 > URL: https://issues.apache.org/jira/browse/DRILL-5956 > Project: Apache Drill > Issue Type: Wish > Components: Storage - Other > Reporter: Jiaqi Liu > Priority: Major > Labels: Enhancement, Storage-Plugin > Fix For: 1.18.0 > > > As more and more companies are using Druid for mission-critical industrial > products, Drill could gain much more popularity with Druid as one of its > supported storage plugin so that uses could easily bind Druid cluster to > running Drill instance -- This message was sent by Atlassian Jira (v8.3.4#803005)