paul-rogers commented on a change in pull request #1500: DRILL-6820: Msgpack format reader URL: https://github.com/apache/drill/pull/1500#discussion_r230654602
########## File path: contrib/format-msgpack/src/main/java/org/apache/drill/exec/store/msgpack/MsgpackReader.java ########## @@ -0,0 +1,192 @@ +/* + * 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.io.InputStream; +import java.util.BitSet; +import java.util.EnumMap; +import java.util.List; + +import org.apache.drill.common.expression.PathSegment; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.exec.record.MaterializedField; +import org.apache.drill.exec.store.msgpack.valuewriter.AbstractValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.ArrayValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.BinaryValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.BooleanValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.ExtensionValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.FloatValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.IntegerValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.MapValueWriter; +import org.apache.drill.exec.store.msgpack.valuewriter.StringValueWriter; +import org.apache.drill.exec.vector.complex.fn.FieldSelection; +import org.apache.drill.exec.vector.complex.writer.BaseWriter; +import org.apache.drill.exec.vector.complex.writer.BaseWriter.ComplexWriter; +import org.apache.drill.exec.vector.complex.writer.BaseWriter.ListWriter; +import org.apache.drill.shaded.guava.com.google.common.collect.Lists; +import org.msgpack.core.MessageInsufficientBufferException; +import org.msgpack.core.MessagePack; +import org.msgpack.core.MessageUnpacker; +import org.msgpack.value.MapValue; +import org.msgpack.value.Value; +import org.msgpack.value.ValueType; + +import io.netty.buffer.DrillBuf; + +public class MsgpackReader { + + static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MsgpackReader.class); + private final List<SchemaPath> columns; + private final FieldSelection rootSelection; + protected MessageUnpacker unpacker; + protected MsgpackReaderContext context; + private final boolean skipQuery; + + /** + * Collection for tracking empty array writers during reading and storing them + * for initializing empty arrays + */ + private final List<ListWriter> emptyArrayWriters = Lists.newArrayList(); + private boolean allTextMode = false; + private MapValueWriter mapValueWriter; + + public MsgpackReader(InputStream stream, MsgpackReaderContext context, DrillBuf managedBuf, List<SchemaPath> columns, + boolean skipQuery) { Review comment: Note also that in a Hadoop system, your reader should handle file blocks. Are MsgPack files splittable? If not, then each file will be read by a single reader; if the file is large, that read will entail remote reads for blocks other than the first. If MsgPack is splittable, then `FileWork` gives the block offset and you'll need code to handle any file header/footer along with the requested block. There is a field somewhere that says whether data of this type is splittable; I think in the plugin constuctor. ---------------------------------------------------------------- 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
