You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by Vlad-Storona <gi...@git.apache.org> on 2017/05/11 14:12:12 UTC
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
GitHub user Vlad-Storona opened a pull request:
https://github.com/apache/drill/pull/831
DRILL-5432: Added pcap-format support
See DRILL-5432 for details.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mapr-demos/drill pcap-format
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/drill/pull/831.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #831
----
commit 10f4caa983be7ec44e3db51de0fe760566ac2881
Author: Vlad Storona <vs...@cybervisiontech.com>
Date: 2017-05-11T13:53:08Z
Added pcap-format support
----
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118107316
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
+ // pcap header
+ // typedef struct pcaprec_hdr_s {
+ // guint32 ts_sec; // timestamp seconds
+ // guint32 ts_usec; // timestamp microseconds */
+ // guint32 incl_len; // number of octets of packet saved in file */
+ // guint32 orig_len; // actual length of packet */
+ // } pcaprec_hdr_t;
+ private long timestamp;
+ private int originalLength;
+
+ private byte[] raw;
+
+ private int etherOffset;
+ private int ipOffset;
+
+ private int packetLength;
+ private int etherProtocol;
+ private int protocol;
+
+ private boolean isRoutingV6;
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean readPcap(final InputStream in, final boolean byteOrder, final int maxLength) throws IOException {
+ byte[] pcapHeader = new byte[PacketConstants.PCAP_HEADER_SIZE];
+ int n = in.read(pcapHeader);
+ if (n < pcapHeader.length) {
+ return false;
+ }
+ decodePcapHeader(pcapHeader, byteOrder, maxLength, 0);
+
+ raw = new byte[originalLength];
+ n = in.read(raw);
+ if (n < 0) {
+ return false;
+ }
+ etherOffset = 0;
+
+ decodeEtherPacket();
+ return true;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public int decodePcap(final byte[] buffer, final int offset, final boolean byteOrder, final int maxLength) {
+ raw = buffer;
+ etherOffset = offset + PacketConstants.PCAP_HEADER_SIZE;
+ decodePcapHeader(raw, byteOrder, maxLength, offset);
+ decodeEtherPacket();
+ return offset + PacketConstants.PCAP_HEADER_SIZE + originalLength;
+ }
+
+ public String getPacketType() {
+ if (isTcpPacket()) {
+ return "TCP";
+ } else if (isUdpPacket()) {
+ return "UDP";
+ } else if (isArpPacket()) {
+ return "ARP";
+ } else if (isIcmpPacket()) {
+ return "ICMP";
+ } else {
+ return "unknown";
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV4Packet() {
+ return etherProtocol == PacketConstants.IPv4_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV6Packet() {
+ return etherProtocol == PacketConstants.IPv6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isPPPoV6Packet() {
+ return etherProtocol == PacketConstants.PPPoV6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isTcpPacket() {
+ return protocol == PacketConstants.TCP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isUdpPacket() {
+ return protocol == PacketConstants.UDP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isArpPacket() {
+ return protocol == PacketConstants.ARP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIcmpPacket() {
+ return protocol == PacketConstants.ICMP_PROTOCOL;
+ }
+
+ public long getSessionHash() {
+ if (isTcpPacket()) {
+ Murmur128 h1 = new Murmur128(1, 2);
+ byte[] buf = getIpAddressBytes(true);
+ assert buf != null;
+ h1.hash(buf, 0, buf.length);
+ h1.hash(getSrc_port());
+
+ Murmur128 h2 = new Murmur128(1, 2);
+ buf = getIpAddressBytes(false);
+ assert buf != null;
+ h2.hash(buf, 0, buf.length);
+ h2.hash(getDst_port());
+
+ return h1.digest64() ^ h2.digest64();
+ } else {
+ return 0;
+ }
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public int getPacketLength() {
+ return packetLength;
+ }
+
+ public InetAddress getSrc_ip() {
+ return getIPAddress(true);
+ }
+
+ public InetAddress getDst_ip() {
+ return getIPAddress(false);
+ }
+
+ public String getEthernetSource() {
+ return getEthernetAddress(PacketConstants.ETHER_SRC_OFFSET);
+ }
+
+ public String getEthernetDestination() {
+ return getEthernetAddress(PacketConstants.ETHER_DST_OFFSET);
+ }
+
+ public int getSequenceNumber() {
+ if (isTcpPacket()) {
+ int sequenceOffset = PacketConstants.ETHER_HEADER_LENGTH + getIPHeaderLength() + getTCPHeaderLength(raw) + 4;
+ return Math.abs(convertInt(raw, sequenceOffset));
+ } else {
+ return 0;
+ }
+ }
+
+ public int getSrc_port() {
+ if (isPPPoV6Packet()) {
+ return getPort(64);
+ }
+ if (isIpV6Packet()) {
+ if (isRoutingV6) {
+ return getPort(136);
+ }
+ return getPort(40);
+ }
+ return getPort(0);
+ }
+
+ public int getDst_port() {
+ if (isPPPoV6Packet()) {
+ return getPort(66);
+ }
+ if (isIpV6Packet()) {
+ if (isRoutingV6) {
+ return getPort(138);
+ }
+ return getPort(42);
+ }
+ return getPort(2);
+ }
+
+ public byte[] getData() {
+ int payloadDataStart = getIPHeaderLength();
+ if (isTcpPacket()) {
+ payloadDataStart += this.getTCPHeaderLength(raw);
+ } else if (isUdpPacket()) {
+ payloadDataStart += this.getUDPHeaderLength();
+ } else {
+ return null;
+ }
+ byte[] data = null;
+ if (packetLength >= payloadDataStart) {
+ data = new byte[packetLength - payloadDataStart];
+ System.arraycopy(raw, ipOffset + payloadDataStart, data, 0, data.length);
+ }
+ return data;
+ }
+
+ private InetAddress getIPAddress(final boolean src) {
+ byte[] ipBuffer = getIpAddressBytes(src);
+ if (ipBuffer == null) {
+ return null;
+ }
+ try {
+ return InetAddress.getByAddress(ipBuffer);
+ } catch (UnknownHostException e) {
+ return null;
+ }
+ }
+
+ private byte[] getIpAddressBytes(final boolean src) {
+ int srcPos;
+ byte[] ipBuffer;
+ if (isIpV4Packet()) {
+ ipBuffer = new byte[4];
+ srcPos = src ? PacketConstants.IP4_SRC_OFFSET : PacketConstants.IP4_DST_OFFSET;
+ } else if (isIpV6Packet()) {
+ ipBuffer = new byte[16];
+ if (isRoutingV6) {
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET + 96 : PacketConstants.IP6_DST_OFFSET + 96;
+ } else {
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET : PacketConstants.IP6_DST_OFFSET;
+ }
+ } else if (isPPPoV6Packet()) {
+ ipBuffer = new byte[16];
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET + PacketConstants.PPPoV6_IP_OFFSET : PacketConstants.IP6_DST_OFFSET + PacketConstants.PPPoV6_IP_OFFSET;
+ } else {
+ return null;
--- End diff --
What does a null value returned from here mean? An unsupported packet type? If so, caller should throw an UnsupportedXYZ exception, perhaps?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118615907
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapFormatPlugin.java ---
@@ -0,0 +1,115 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.exec.ops.FragmentContext;
+import org.apache.drill.exec.planner.logical.DrillTable;
+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.BasicFormatMatcher;
+import org.apache.drill.exec.store.dfs.DrillFileSystem;
+import org.apache.drill.exec.store.dfs.FileSelection;
+import org.apache.drill.exec.store.dfs.FileSystemPlugin;
+import org.apache.drill.exec.store.dfs.FormatMatcher;
+import org.apache.drill.exec.store.dfs.FormatSelection;
+import org.apache.drill.exec.store.dfs.MagicString;
+import org.apache.drill.exec.store.dfs.NamedFormatPluginConfig;
+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.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class PcapFormatPlugin extends EasyFormatPlugin<PcapFormatConfig> {
+
+ private final PcapFormatMatcher matcher;
+
+ public PcapFormatPlugin(String name, DrillbitContext context, Configuration fsConf,
+ StoragePluginConfig storagePluginConfig) {
+ this(name, context, fsConf, storagePluginConfig, new PcapFormatConfig());
+ }
+
+ public PcapFormatPlugin(String name, DrillbitContext context, Configuration fsConf, StoragePluginConfig config, PcapFormatConfig formatPluginConfig) {
+ super(name, context, fsConf, config, formatPluginConfig, true, false, true, false, Lists.newArrayList("pcap"), "pcap");
+ this.matcher = new PcapFormatMatcher(this);
+ }
+
+ @Override
+ public boolean supportsPushDown() {
+ return true;
+ }
+
+ @Override
+ public RecordReader getRecordReader(FragmentContext context, DrillFileSystem dfs, FileWork fileWork, List<SchemaPath> columns, String userName) throws ExecutionSetupException {
+ String path = dfs.makeQualified(new Path(fileWork.getPath())).toUri().getPath();
+ return new PcapRecordReader(path, columns);
+ }
+
+ @Override
+ public RecordWriter getRecordWriter(FragmentContext context, EasyWriter writer) throws IOException {
+ return null;
+ }
+
+ @Override
+ public int getReaderOperatorType() {
+ return 0;
--- End diff --
Seems akward, but it seems that other format plugins add a type to a protobuf, then return that here:
```
return CoreOperatorType.JSON_SUB_SCAN_VALUE;
```
And `UserBitShared.proto`:
```
JSON_SUB_SCAN = 29;
```
The next available number is 37.
This seems rather brittle. Seems we should have a more general solution. But, until we do, I'd guess you'll need to add the enum value.
As an alternative, `SequenceFileForamtPlugin` just makes up a number:
```
public int getReaderOperatorType() {
return 4001;
}
```
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118619502
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
+ final String name,
+ final MinorType minorType) {
+ TypeProtos.MajorType majorType = getMajorType(minorType);
+
+ MaterializedField field =
+ MaterializedField.create(name, majorType);
+
+ ValueVector vector =
+ getValueVector(minorType, majorType, field);
+
+ return getProjectedColumnInfo(column, vector);
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column, final ValueVector vector) {
+ ProjectedColumnInfo pci = new ProjectedColumnInfo();
+ pci.vv = vector;
+ pci.pcapColumn = column;
+ return pci;
+ }
+
+ private MajorType getMajorType(final MinorType minorType) {
+ return Types.optional(minorType);
+ }
+
+ private ValueVector getValueVector(final MinorType minorType,
+ final MajorType majorType,
+ final MaterializedField field) {
+ try {
+
+ final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(
+ minorType, majorType.getMode());
+ ValueVector vector = output.addField(field, clazz);
+ vector.allocateNew();
+ return vector;
+
+ } catch (SchemaChangeException sce) {
+ throw new NullPointerException("The addition of this field is incompatible with this OutputMutator's capabilities");
+ }
+ }
+
+ private int parsePcapFilesAndPutItToTable() throws IOException {
+ Packet packet = new Packet();
+ while (offset < validBytes) {
+
+ if (validBytes - offset < 9000) {
+ System.arraycopy(buffer, offset, buffer, 0, validBytes - offset);
+ validBytes = validBytes - offset;
+ offset = 0;
+
+ int n = in.read(buffer, validBytes, buffer.length - validBytes);
+ if (n > 0) {
+ validBytes += n;
+ }
+ }
+
+ offset = decoder.decodePacket(buffer, offset, packet);
+
+ if (addDataToTable(packet, decoder.getNetwork())) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ private boolean addDataToTable(final Packet packet, final int networkType) {
+ for (ProjectedColumnInfo pci : projectedCols) {
+ switch (pci.pcapColumn.getColumnName()) {
+ case "type":
+ setStringColumnValue(packet.getPacketType(), pci);
+ break;
+ case "timestamp":
+ setTimestampColumnValue(packet.getTimestamp(), pci);
+ break;
+ case "network":
+ setIntegerColumnValue(networkType, pci);
+ break;
+ case "src_mac_address":
+ setStringColumnValue(packet.getEthernetSource(), pci);
+ break;
+ case "dst_mac_address":
+ setStringColumnValue(packet.getEthernetDestination(), pci);
+ break;
+ case "dst_ip":
+ if (packet.getDst_ip() != null) {
+ setStringColumnValue(packet.getDst_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_ip":
+ if (packet.getSrc_ip() != null) {
+ setStringColumnValue(packet.getSrc_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_port":
+ setIntegerColumnValue(packet.getSrc_port(), pci);
+ break;
+ case "dst_port":
+ setIntegerColumnValue(packet.getDst_port(), pci);
+ break;
+ case "tcp_session":
+ if (packet.isTcpPacket()) {
+ setLongColumnValue(packet.getSessionHash(), pci);
+ }
+ break;
+ case "tcp_sequence":
+ if (packet.isTcpPacket()) {
+ setIntegerColumnValue(packet.getSequenceNumber(), pci);
+ }
+ break;
+ case "packet_length":
+ setIntegerColumnValue(packet.getPacketLength(), pci);
+ break;
+ case "data":
+ if (packet.getData() != null) {
+ setStringColumnValue(parseBytesToASCII(packet.getData()), pci);
+ } else {
+ setStringColumnValue("[]", pci);
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ private void setLongColumnValue(long data, ProjectedColumnInfo pci) {
+ ((NullableBigIntVector.Mutator) pci.vv.getMutator())
+ .setSafe(0, data);
--- End diff --
This works only for a single row. As noted above, you want to put more than one row per batch. So, you'll need to keep track of the row index and pass that as the first argument rather than 0.
Again, soon all this will be handled for you, you'll just be able to say:
```
writer.column("dst_ip").setString(value);
```
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on the issue:
https://github.com/apache/drill/pull/831
It seems to me that others (Ted, Charles) also contributed to this. Would be nice if the PR acknowledged their contribution.
Also, we should document limitations and what is not (yet) supported.
Perhaps a README?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118618438
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
--- End diff --
This part of reading is a bit complex. Again, we are working in simplifying it, but that work is not available yet.
You need to handle two cases:
```
SELECT * ...
SELECT `type`, `dst_ip`, ...
```
The first says to select all available columns, the other provides an explicit list of columns to select. The code earlier said that this plugin supports push-down, (that is, `supportsPushDown` returned true) so you've got to handle projection for both cases.
The code handle the second type: a list of columns. It does not seem to handle `SELECT *`, however.
I noticed, however, that the test case does include `SELECT *`. Maybe a comment or two about how that case is handled?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
Looking at the big picture, Drill should allow specialized plugins such as this one to exist as independent projects. Users should be able to download the plugin jar, add it to Drill, and go.
As we've discussed, Drill has a bit of work before we get there. We can't hold up this work waiting for a better solution.
So, please fix the two minor issues you identified. The code will then be ready for a final quick review and approval.
Later, once Drill provides the correct framework, I'd suggest that this code move into a separate Github repo to be maintained by experts in pcap. Frankly, most Drill developers are familiar with query engines, not pcap (or other specialized formats.)
The same is true, for example, of the "indexr" and TSDB plugins which are (slowly) working their way through the review process.
Summary: please add the package-info file and the comments in utils. We can then give approval.
Can we do this by, say, July 10? If so, we can likely get this PR into 1.11, if the Release Manager agrees.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
Looks like we're good to go. Will be working on pulling the PR into Apache master today and will post any issues that arise as I run the code through the detailed tests used in that process.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118399621
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
+ // pcap header
+ // typedef struct pcaprec_hdr_s {
+ // guint32 ts_sec; // timestamp seconds
+ // guint32 ts_usec; // timestamp microseconds */
+ // guint32 incl_len; // number of octets of packet saved in file */
+ // guint32 orig_len; // actual length of packet */
+ // } pcaprec_hdr_t;
+ private long timestamp;
+ private int originalLength;
+
+ private byte[] raw;
+
+ private int etherOffset;
+ private int ipOffset;
+
+ private int packetLength;
+ private int etherProtocol;
+ private int protocol;
+
+ private boolean isRoutingV6;
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean readPcap(final InputStream in, final boolean byteOrder, final int maxLength) throws IOException {
+ byte[] pcapHeader = new byte[PacketConstants.PCAP_HEADER_SIZE];
+ int n = in.read(pcapHeader);
+ if (n < pcapHeader.length) {
+ return false;
+ }
+ decodePcapHeader(pcapHeader, byteOrder, maxLength, 0);
+
+ raw = new byte[originalLength];
+ n = in.read(raw);
+ if (n < 0) {
+ return false;
+ }
+ etherOffset = 0;
+
+ decodeEtherPacket();
+ return true;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public int decodePcap(final byte[] buffer, final int offset, final boolean byteOrder, final int maxLength) {
+ raw = buffer;
+ etherOffset = offset + PacketConstants.PCAP_HEADER_SIZE;
+ decodePcapHeader(raw, byteOrder, maxLength, offset);
+ decodeEtherPacket();
+ return offset + PacketConstants.PCAP_HEADER_SIZE + originalLength;
+ }
+
+ public String getPacketType() {
+ if (isTcpPacket()) {
+ return "TCP";
+ } else if (isUdpPacket()) {
+ return "UDP";
+ } else if (isArpPacket()) {
+ return "ARP";
+ } else if (isIcmpPacket()) {
+ return "ICMP";
+ } else {
+ return "unknown";
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV4Packet() {
+ return etherProtocol == PacketConstants.IPv4_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV6Packet() {
+ return etherProtocol == PacketConstants.IPv6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isPPPoV6Packet() {
+ return etherProtocol == PacketConstants.PPPoV6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isTcpPacket() {
+ return protocol == PacketConstants.TCP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isUdpPacket() {
+ return protocol == PacketConstants.UDP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isArpPacket() {
+ return protocol == PacketConstants.ARP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIcmpPacket() {
+ return protocol == PacketConstants.ICMP_PROTOCOL;
+ }
+
+ public long getSessionHash() {
--- End diff --
This is very useful. It is the way that TCP sessions are reassembled (which is a big deal).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/drill/pull/831
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r124219513
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/Utils.java ---
@@ -0,0 +1,65 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.primitives.Ints;
+import com.google.common.primitives.Shorts;
+
+public class Utils {
+
+ public static int getIntFileOrder(boolean byteOrder, final byte[] buf, final int offset) {
+ if (byteOrder) {
--- End diff --
Comment will be added here, explaining this case
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
Filed DRILL-5618 to describe the `bootstrap-storage-plugin.json` issue.
There are one or two remaining open comments. Will those be addressed, or should we do a final review based on the code as it stands now?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r124220475
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapDrillTable.java ---
@@ -0,0 +1,73 @@
+/*
--- End diff --
I think a link to a JIRA can be added. All needed information about already listed there.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118620276
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
--- End diff --
Can this just be done in setup rather than checking the pointer on every call to `next()`?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118615528
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapFormatPlugin.java ---
@@ -0,0 +1,115 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.exec.ops.FragmentContext;
+import org.apache.drill.exec.planner.logical.DrillTable;
+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.BasicFormatMatcher;
+import org.apache.drill.exec.store.dfs.DrillFileSystem;
+import org.apache.drill.exec.store.dfs.FileSelection;
+import org.apache.drill.exec.store.dfs.FileSystemPlugin;
+import org.apache.drill.exec.store.dfs.FormatMatcher;
+import org.apache.drill.exec.store.dfs.FormatSelection;
+import org.apache.drill.exec.store.dfs.MagicString;
+import org.apache.drill.exec.store.dfs.NamedFormatPluginConfig;
+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.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class PcapFormatPlugin extends EasyFormatPlugin<PcapFormatConfig> {
+
+ private final PcapFormatMatcher matcher;
+
+ public PcapFormatPlugin(String name, DrillbitContext context, Configuration fsConf,
+ StoragePluginConfig storagePluginConfig) {
+ this(name, context, fsConf, storagePluginConfig, new PcapFormatConfig());
+ }
+
+ public PcapFormatPlugin(String name, DrillbitContext context, Configuration fsConf, StoragePluginConfig config, PcapFormatConfig formatPluginConfig) {
+ super(name, context, fsConf, config, formatPluginConfig, true, false, true, false, Lists.newArrayList("pcap"), "pcap");
+ this.matcher = new PcapFormatMatcher(this);
+ }
+
+ @Override
+ public boolean supportsPushDown() {
+ return true;
+ }
+
+ @Override
+ public RecordReader getRecordReader(FragmentContext context, DrillFileSystem dfs, FileWork fileWork, List<SchemaPath> columns, String userName) throws ExecutionSetupException {
+ String path = dfs.makeQualified(new Path(fileWork.getPath())).toUri().getPath();
+ return new PcapRecordReader(path, columns);
+ }
+
+ @Override
+ public RecordWriter getRecordWriter(FragmentContext context, EasyWriter writer) throws IOException {
+ return null;
+ }
+
+ @Override
+ public int getReaderOperatorType() {
+ return 0;
+ }
+
+ @Override
+ public int getWriterOperatorType() {
+ return 0;
--- End diff --
Other format plugins do the following when a writer is not supported:
```
throw new UnsupportedOperationException("unimplemented");
```
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on the issue:
https://github.com/apache/drill/pull/831
@paul-rogers , is anything else we can do for this PR ?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
> That only works if Drill has an autoloading capability that allows storage
> formats to be loaded and authenticated easily.
Why? To get pcap in 1.11, one must install a new Drill version, which requires a restart. Assuming that pcap were a separate project, you'd install a new jar, and restart. Neither provides auto loading.
Not clear on the authentication issue. If a plugin were a separate project, wouldn't that project have a way of certifying its jars?
Understanding this will help us figure out how to handle the growing set of specialized storage plugins...
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118397733
--- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/store/pcap/TestPcapDecoder.java ---
@@ -0,0 +1,230 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.io.Resources;
+import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestPcapDecoder extends BaseTestQuery {
+ private static File bigFile;
+
+ /**
+ * Creates an ephemeral file of about a GB in size
+ *
+ * @throws IOException If input file can't be read or output can't be written.
+ */
+ @BeforeClass
+ public static void buildBigTcpFile() throws IOException {
+ bigFile = File.createTempFile("tcp", ".pcap");
+ bigFile.deleteOnExit();
+ boolean first = true;
+ System.out.printf("Building large test file\n");
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(bigFile))) {
+ for (int i = 0; i < 1000e6 / (29208 - 24) + 1; i++) {
+ // might be faster to keep this open and rewind each time, but
+ // that is hard to do with a resource, especially if it comes
+ // from the class path instead of files.
+ try (InputStream in = Resources.getResource("store/pcap/tcp-2.pcap").openStream()) {
+ ConcatPcap.copy(first, in, out);
+ }
+ first = false;
+ }
+ System.out.printf("Created file is %.1f MB\n", bigFile.length() / 1e6);
--- End diff --
Sure. This good and easy to delete.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r124220049
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
--- End diff --
@paul-rogers
> The code handle the second type: a list of columns. It does not seem to handle SELECT *, however.
Why you say that this case is not working ? Or I missing something ? Both cases you listed are operational
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118619851
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
--- End diff --
Would it have been possible to use one of the existing pcap Java libraries here? Four are listed [here](https://en.wikipedia.org/wiki/Pcap).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118399899
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
+ final String name,
+ final MinorType minorType) {
+ TypeProtos.MajorType majorType = getMajorType(minorType);
+
+ MaterializedField field =
+ MaterializedField.create(name, majorType);
+
+ ValueVector vector =
+ getValueVector(minorType, majorType, field);
+
+ return getProjectedColumnInfo(column, vector);
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column, final ValueVector vector) {
+ ProjectedColumnInfo pci = new ProjectedColumnInfo();
+ pci.vv = vector;
+ pci.pcapColumn = column;
+ return pci;
+ }
+
+ private MajorType getMajorType(final MinorType minorType) {
+ return Types.optional(minorType);
+ }
+
+ private ValueVector getValueVector(final MinorType minorType,
+ final MajorType majorType,
+ final MaterializedField field) {
+ try {
+
+ final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(
+ minorType, majorType.getMode());
+ ValueVector vector = output.addField(field, clazz);
+ vector.allocateNew();
+ return vector;
+
+ } catch (SchemaChangeException sce) {
+ throw new NullPointerException("The addition of this field is incompatible with this OutputMutator's capabilities");
+ }
+ }
+
+ private int parsePcapFilesAndPutItToTable() throws IOException {
+ Packet packet = new Packet();
+ while (offset < validBytes) {
+
+ if (validBytes - offset < 9000) {
+ System.arraycopy(buffer, offset, buffer, 0, validBytes - offset);
+ validBytes = validBytes - offset;
+ offset = 0;
+
+ int n = in.read(buffer, validBytes, buffer.length - validBytes);
+ if (n > 0) {
+ validBytes += n;
+ }
+ }
+
+ offset = decoder.decodePacket(buffer, offset, packet);
+
+ if (addDataToTable(packet, decoder.getNetwork())) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ private boolean addDataToTable(final Packet packet, final int networkType) {
+ for (ProjectedColumnInfo pci : projectedCols) {
+ switch (pci.pcapColumn.getColumnName()) {
+ case "type":
+ setStringColumnValue(packet.getPacketType(), pci);
+ break;
+ case "timestamp":
+ setTimestampColumnValue(packet.getTimestamp(), pci);
+ break;
+ case "network":
+ setIntegerColumnValue(networkType, pci);
+ break;
+ case "src_mac_address":
+ setStringColumnValue(packet.getEthernetSource(), pci);
+ break;
+ case "dst_mac_address":
+ setStringColumnValue(packet.getEthernetDestination(), pci);
+ break;
+ case "dst_ip":
+ if (packet.getDst_ip() != null) {
+ setStringColumnValue(packet.getDst_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_ip":
+ if (packet.getSrc_ip() != null) {
+ setStringColumnValue(packet.getSrc_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_port":
+ setIntegerColumnValue(packet.getSrc_port(), pci);
+ break;
+ case "dst_port":
+ setIntegerColumnValue(packet.getDst_port(), pci);
+ break;
+ case "tcp_session":
+ if (packet.isTcpPacket()) {
+ setLongColumnValue(packet.getSessionHash(), pci);
+ }
+ break;
+ case "tcp_sequence":
+ if (packet.isTcpPacket()) {
+ setIntegerColumnValue(packet.getSequenceNumber(), pci);
+ }
+ break;
+ case "packet_length":
+ setIntegerColumnValue(packet.getPacketLength(), pci);
+ break;
+ case "data":
+ if (packet.getData() != null) {
+ setStringColumnValue(parseBytesToASCII(packet.getData()), pci);
--- End diff --
WIth lazy decoding, there is no cost to having multiple versions of fields.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r124427218
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapDrillTable.java ---
@@ -0,0 +1,73 @@
+/*
--- End diff --
The JIRA link is also good. Once the code is into Drill, it will be hard for future users to locate the corresponding JIRA. But, if you place a comment into a file somewhere, then future developers can find the JIRA.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on the issue:
https://github.com/apache/drill/pull/831
What is the effective difference between the contrib director and where the
plugin already is?
What sort of testing do you think is necessary?
On Tue, May 30, 2017 at 7:08 PM, Parth Chandra <no...@github.com>
wrote:
> I would recommend moving this format plugin to the contrib directory,
> since this is a new and untested implementation.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/drill/pull/831#issuecomment-304945148>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAPSejscWPF6xO5I3QMVeSitRA1qMr6vks5r_E0pgaJpZM4NYDv6>
> .
>
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118616406
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
--- End diff --
As noted above, by opening the file here, if you are scanning 1000 files, you'll have 1000 open file handles at the start of the fragment. Better to postpone opening files until setup.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by Vlad-Storona <gi...@git.apache.org>.
Github user Vlad-Storona commented on the issue:
https://github.com/apache/drill/pull/831
As a result of project transferring problems were found out. In java-exec package exists file bootstrap-storage-plugin.json from which drill takes information about supported files formats. But in contrib package, there is no such file. If to transfer pcap-reader to contrib package and not to remove information from bootstrap-storage-plugin.json about pcap format, then there will be JsonMappingException. And if you remove this information from the config file, then drill will can`t find pcap files. Maybe I have not enough info/experience about drill. Maybe you can provide any solution how to handle this ?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118397540
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Murmur128.java ---
@@ -0,0 +1,161 @@
+/*
--- End diff --
I tried to merge them, but the assumptions of working on unsafe code were very difficult to remove. I also had a difficult time figuring out a useful API.
Happy to look at specific suggestions, but the way that the existing implementation always iterates through unsafe pointers meant that there is likely to be nearly no shared code. Merging by simply moving my methods to the existing implementation is certainly doable.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118406369
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
+ // pcap header
+ // typedef struct pcaprec_hdr_s {
+ // guint32 ts_sec; // timestamp seconds
+ // guint32 ts_usec; // timestamp microseconds */
+ // guint32 incl_len; // number of octets of packet saved in file */
+ // guint32 orig_len; // actual length of packet */
+ // } pcaprec_hdr_t;
+ private long timestamp;
+ private int originalLength;
+
+ private byte[] raw;
+
+ private int etherOffset;
+ private int ipOffset;
+
+ private int packetLength;
+ private int etherProtocol;
+ private int protocol;
+
+ private boolean isRoutingV6;
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean readPcap(final InputStream in, final boolean byteOrder, final int maxLength) throws IOException {
+ byte[] pcapHeader = new byte[PacketConstants.PCAP_HEADER_SIZE];
+ int n = in.read(pcapHeader);
+ if (n < pcapHeader.length) {
+ return false;
+ }
+ decodePcapHeader(pcapHeader, byteOrder, maxLength, 0);
+
+ raw = new byte[originalLength];
+ n = in.read(raw);
+ if (n < 0) {
+ return false;
+ }
+ etherOffset = 0;
+
+ decodeEtherPacket();
+ return true;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public int decodePcap(final byte[] buffer, final int offset, final boolean byteOrder, final int maxLength) {
+ raw = buffer;
+ etherOffset = offset + PacketConstants.PCAP_HEADER_SIZE;
+ decodePcapHeader(raw, byteOrder, maxLength, offset);
+ decodeEtherPacket();
+ return offset + PacketConstants.PCAP_HEADER_SIZE + originalLength;
+ }
+
+ public String getPacketType() {
+ if (isTcpPacket()) {
+ return "TCP";
+ } else if (isUdpPacket()) {
+ return "UDP";
+ } else if (isArpPacket()) {
+ return "ARP";
+ } else if (isIcmpPacket()) {
+ return "ICMP";
+ } else {
+ return "unknown";
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV4Packet() {
+ return etherProtocol == PacketConstants.IPv4_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV6Packet() {
+ return etherProtocol == PacketConstants.IPv6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isPPPoV6Packet() {
+ return etherProtocol == PacketConstants.PPPoV6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isTcpPacket() {
+ return protocol == PacketConstants.TCP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isUdpPacket() {
+ return protocol == PacketConstants.UDP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isArpPacket() {
+ return protocol == PacketConstants.ARP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIcmpPacket() {
+ return protocol == PacketConstants.ICMP_PROTOCOL;
+ }
+
+ public long getSessionHash() {
+ if (isTcpPacket()) {
+ Murmur128 h1 = new Murmur128(1, 2);
+ byte[] buf = getIpAddressBytes(true);
+ assert buf != null;
+ h1.hash(buf, 0, buf.length);
+ h1.hash(getSrc_port());
+
+ Murmur128 h2 = new Murmur128(1, 2);
+ buf = getIpAddressBytes(false);
+ assert buf != null;
+ h2.hash(buf, 0, buf.length);
+ h2.hash(getDst_port());
+
+ return h1.digest64() ^ h2.digest64();
+ } else {
+ return 0;
+ }
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public int getPacketLength() {
+ return packetLength;
+ }
+
+ public InetAddress getSrc_ip() {
+ return getIPAddress(true);
+ }
+
+ public InetAddress getDst_ip() {
+ return getIPAddress(false);
+ }
+
+ public String getEthernetSource() {
+ return getEthernetAddress(PacketConstants.ETHER_SRC_OFFSET);
+ }
+
+ public String getEthernetDestination() {
+ return getEthernetAddress(PacketConstants.ETHER_DST_OFFSET);
+ }
+
+ public int getSequenceNumber() {
+ if (isTcpPacket()) {
+ int sequenceOffset = PacketConstants.ETHER_HEADER_LENGTH + getIPHeaderLength() + getTCPHeaderLength(raw) + 4;
+ return Math.abs(convertInt(raw, sequenceOffset));
+ } else {
+ return 0;
+ }
+ }
+
+ public int getSrc_port() {
+ if (isPPPoV6Packet()) {
+ return getPort(64);
+ }
+ if (isIpV6Packet()) {
+ if (isRoutingV6) {
+ return getPort(136);
+ }
+ return getPort(40);
+ }
+ return getPort(0);
+ }
+
+ public int getDst_port() {
+ if (isPPPoV6Packet()) {
+ return getPort(66);
+ }
+ if (isIpV6Packet()) {
+ if (isRoutingV6) {
+ return getPort(138);
+ }
+ return getPort(42);
+ }
+ return getPort(2);
+ }
+
+ public byte[] getData() {
+ int payloadDataStart = getIPHeaderLength();
+ if (isTcpPacket()) {
+ payloadDataStart += this.getTCPHeaderLength(raw);
+ } else if (isUdpPacket()) {
+ payloadDataStart += this.getUDPHeaderLength();
+ } else {
+ return null;
+ }
+ byte[] data = null;
+ if (packetLength >= payloadDataStart) {
+ data = new byte[packetLength - payloadDataStart];
+ System.arraycopy(raw, ipOffset + payloadDataStart, data, 0, data.length);
+ }
+ return data;
+ }
+
+ private InetAddress getIPAddress(final boolean src) {
+ byte[] ipBuffer = getIpAddressBytes(src);
+ if (ipBuffer == null) {
+ return null;
+ }
+ try {
+ return InetAddress.getByAddress(ipBuffer);
+ } catch (UnknownHostException e) {
+ return null;
+ }
+ }
+
+ private byte[] getIpAddressBytes(final boolean src) {
+ int srcPos;
+ byte[] ipBuffer;
+ if (isIpV4Packet()) {
+ ipBuffer = new byte[4];
+ srcPos = src ? PacketConstants.IP4_SRC_OFFSET : PacketConstants.IP4_DST_OFFSET;
+ } else if (isIpV6Packet()) {
+ ipBuffer = new byte[16];
+ if (isRoutingV6) {
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET + 96 : PacketConstants.IP6_DST_OFFSET + 96;
+ } else {
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET : PacketConstants.IP6_DST_OFFSET;
+ }
+ } else if (isPPPoV6Packet()) {
+ ipBuffer = new byte[16];
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET + PacketConstants.PPPoV6_IP_OFFSET : PacketConstants.IP6_DST_OFFSET + PacketConstants.PPPoV6_IP_OFFSET;
+ } else {
+ return null;
--- End diff --
If there are unsupported types we will end up with a null value in the output. Is that what is desired? I tried with a pcap file from here: http://www.netresec.com/?page=MACCDC and verified that is so. That would be one of the reasons I feel we should at least document what might not be supported? Your call on this one. I am not an expert on the matter.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r124218971
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
--- End diff --
This java libraries uses JNI to work with existing libpicap c library. So they are just wrappers above. This plugin uses only java code to process pcap.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118617811
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
--- End diff --
Drill's error message system can use work, but you can help. Rather than throw a generic Java exception, please throw a so-called `UserException`:
```
throw UserException.dataReadError(io)
.addContext("Trouble with reading packets in file!")
.build();
```
Even better:
```
.addContext("File name:", inputPath)
```
Where `inputPath` is the file name passed to the ctor that you save, and the above line is added to those above (you can have multiple `addContext()` calls.)
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on the issue:
https://github.com/apache/drill/pull/831
On Fri, Jun 30, 2017 at 5:34 PM, Paul Rogers <no...@github.com>
wrote:
> That only works if Drill has an autoloading capability that allows storage
> formats to be loaded and authenticated easily.
>
> Why? To get pcap in 1.11, one must install a new Drill version, which
> requires a restart. Assuming that pcap were a separate project, you'd
> install a new jar, and restart. Neither provides auto loading.
>
No. But if I have 1.11 already and decide that I want pcap (or any similar
data format), it would be nice if I could do the equivalent of pip (for
python) or install.packages("...") (for R) or mvn test (for Java) and get
whatever cool capability I like.
This may be described as "just install a new jar" but the convenience level
is a proven Big Deal (tm). It would even be possible to leverage Maven
central to make it happen, but there needs to be convenience sugar around
the process to make it consumable.
> Not clear on the authentication issue. If a plugin were a separate
> project, wouldn't that project have a way of certifying its jars?
>
Dunno. Not some random project.
If Drill requires it, then yes. And I am saying that Drill should require
resolution back to some level of trust.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on the issue:
https://github.com/apache/drill/pull/831
The contrib directory is where we have, in the past, added new storage and format plugins that are new and may not have been sufficiently tested.
For this plugin, I think testing with pcap files from different sources would be useful. [1,2] are useful sources for data that will test boundary conditions. I tried on a file from [2] and got an NPE (didn't investigate the cause). A random sample of files from [1] worked very nicely indeed, though I didn't validate the output.
You might have already done this level of testing; if so, I will withdraw the suggestion.
[1] https://wiki.wireshark.org/SampleCaptures#Captures_used_in_Wireshark_testing
[2] http://www.netresec.com/?page=PcapFiles
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118616911
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
+ final String name,
+ final MinorType minorType) {
+ TypeProtos.MajorType majorType = getMajorType(minorType);
+
+ MaterializedField field =
+ MaterializedField.create(name, majorType);
+
+ ValueVector vector =
+ getValueVector(minorType, majorType, field);
+
+ return getProjectedColumnInfo(column, vector);
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column, final ValueVector vector) {
+ ProjectedColumnInfo pci = new ProjectedColumnInfo();
+ pci.vv = vector;
+ pci.pcapColumn = column;
+ return pci;
+ }
+
+ private MajorType getMajorType(final MinorType minorType) {
+ return Types.optional(minorType);
+ }
+
+ private ValueVector getValueVector(final MinorType minorType,
+ final MajorType majorType,
+ final MaterializedField field) {
+ try {
+
+ final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(
+ minorType, majorType.getMode());
+ ValueVector vector = output.addField(field, clazz);
+ vector.allocateNew();
+ return vector;
+
+ } catch (SchemaChangeException sce) {
+ throw new NullPointerException("The addition of this field is incompatible with this OutputMutator's capabilities");
--- End diff --
`NullPointerException` --> `IllegalStateException`
This is not really a null pointer, but it is an illegal state...
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r123397439
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,307 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+ private static final Logger logger = LoggerFactory.getLogger(PcapRecordReader.class);
+
+ private static final int BATCH_SIZE = 40_000;
+
+ private OutputMutator output;
+
+ private PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer;
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private String inputPath;
+ private List<SchemaPath> projectedColumns;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ this.inputPath = inputPath;
+ this.projectedColumns = projectedColumns;
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ try {
+
+ this.output = output;
+ this.buffer = new byte[100000];
+ this.in = new FileInputStream(inputPath);
+ this.decoder = new PacketDecoder(in);
+ this.validBytes = in.read(buffer);
+ this.projectedCols = getProjectedColsIfItNull();
+ setColumns(projectedColumns);
+ } catch (IOException io) {
+ throw UserException.dataReadError(io)
+ .addContext("File name:", inputPath)
+ .build(logger);
+ }
+ }
+
+ @Override
+ public int next() {
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw UserException.dataReadError(io)
+ .addContext("Trouble with reading packets in file!")
+ .build(logger);
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+// buffer = null;
+// in.close();
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
--- End diff --
The column name passed in from Drill will have the case that the user typed. For example:
```
SELECT DST_IP ...
SELECT DsT_iP ...
SELECT dst_ip ...
```
Drill is supposed to be case insensitive: all the above should match the same "dst_ip" column.
But, the code later code a case-insensitive switch. So, a simple solution here is to do:
```
final String name = column.getColumnName().toLowerCase();
```
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118108814
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
+ final String name,
+ final MinorType minorType) {
+ TypeProtos.MajorType majorType = getMajorType(minorType);
+
+ MaterializedField field =
+ MaterializedField.create(name, majorType);
+
+ ValueVector vector =
+ getValueVector(minorType, majorType, field);
+
+ return getProjectedColumnInfo(column, vector);
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column, final ValueVector vector) {
+ ProjectedColumnInfo pci = new ProjectedColumnInfo();
+ pci.vv = vector;
+ pci.pcapColumn = column;
+ return pci;
+ }
+
+ private MajorType getMajorType(final MinorType minorType) {
+ return Types.optional(minorType);
+ }
+
+ private ValueVector getValueVector(final MinorType minorType,
+ final MajorType majorType,
+ final MaterializedField field) {
+ try {
+
+ final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(
+ minorType, majorType.getMode());
+ ValueVector vector = output.addField(field, clazz);
+ vector.allocateNew();
+ return vector;
+
+ } catch (SchemaChangeException sce) {
+ throw new NullPointerException("The addition of this field is incompatible with this OutputMutator's capabilities");
+ }
+ }
+
+ private int parsePcapFilesAndPutItToTable() throws IOException {
+ Packet packet = new Packet();
+ while (offset < validBytes) {
+
+ if (validBytes - offset < 9000) {
+ System.arraycopy(buffer, offset, buffer, 0, validBytes - offset);
+ validBytes = validBytes - offset;
+ offset = 0;
+
+ int n = in.read(buffer, validBytes, buffer.length - validBytes);
+ if (n > 0) {
+ validBytes += n;
+ }
+ }
+
+ offset = decoder.decodePacket(buffer, offset, packet);
+
+ if (addDataToTable(packet, decoder.getNetwork())) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ private boolean addDataToTable(final Packet packet, final int networkType) {
+ for (ProjectedColumnInfo pci : projectedCols) {
+ switch (pci.pcapColumn.getColumnName()) {
+ case "type":
+ setStringColumnValue(packet.getPacketType(), pci);
+ break;
+ case "timestamp":
+ setTimestampColumnValue(packet.getTimestamp(), pci);
+ break;
+ case "network":
+ setIntegerColumnValue(networkType, pci);
+ break;
+ case "src_mac_address":
+ setStringColumnValue(packet.getEthernetSource(), pci);
+ break;
+ case "dst_mac_address":
+ setStringColumnValue(packet.getEthernetDestination(), pci);
+ break;
+ case "dst_ip":
+ if (packet.getDst_ip() != null) {
+ setStringColumnValue(packet.getDst_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_ip":
+ if (packet.getSrc_ip() != null) {
+ setStringColumnValue(packet.getSrc_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_port":
+ setIntegerColumnValue(packet.getSrc_port(), pci);
+ break;
+ case "dst_port":
+ setIntegerColumnValue(packet.getDst_port(), pci);
+ break;
+ case "tcp_session":
+ if (packet.isTcpPacket()) {
+ setLongColumnValue(packet.getSessionHash(), pci);
+ }
+ break;
+ case "tcp_sequence":
+ if (packet.isTcpPacket()) {
+ setIntegerColumnValue(packet.getSequenceNumber(), pci);
+ }
+ break;
+ case "packet_length":
+ setIntegerColumnValue(packet.getPacketLength(), pci);
+ break;
+ case "data":
+ if (packet.getData() != null) {
+ setStringColumnValue(parseBytesToASCII(packet.getData()), pci);
--- End diff --
We want to print this in ASCII? Is the packet data always printable as ASCII characters?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on the issue:
https://github.com/apache/drill/pull/831
This is really good. Will do this immediately.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118406626
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/dto/ColumnDto.java ---
@@ -0,0 +1,63 @@
+/*
+ * 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.pcap.dto;
+
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+
+import java.util.Objects;
+
+public class ColumnDto {
+
+ private final String columnName;
+ private final PcapTypes columnType;
+
+ public ColumnDto(String columnName, PcapTypes columnType) {
+ this.columnName = columnName;
+ this.columnType = columnType;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public PcapTypes getColumnType() {
+ return columnType;
+ }
+
+ public boolean isNullable() {
+ return true;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ColumnDto columnDto = (ColumnDto) o;
+ return Objects.equals(columnName, columnDto.columnName) &&
--- End diff --
OK, my mistake. The code is `Objects.equals` and not `Object.equals` so is in fact correct.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r124427466
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
--- End diff --
I stand corrected. Couldn't find that functionality when reviewing; should have downloaded the code and tried it.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118399867
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
+ // pcap header
+ // typedef struct pcaprec_hdr_s {
+ // guint32 ts_sec; // timestamp seconds
+ // guint32 ts_usec; // timestamp microseconds */
+ // guint32 incl_len; // number of octets of packet saved in file */
+ // guint32 orig_len; // actual length of packet */
+ // } pcaprec_hdr_t;
+ private long timestamp;
+ private int originalLength;
+
+ private byte[] raw;
+
+ private int etherOffset;
+ private int ipOffset;
+
+ private int packetLength;
+ private int etherProtocol;
+ private int protocol;
+
+ private boolean isRoutingV6;
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean readPcap(final InputStream in, final boolean byteOrder, final int maxLength) throws IOException {
+ byte[] pcapHeader = new byte[PacketConstants.PCAP_HEADER_SIZE];
+ int n = in.read(pcapHeader);
+ if (n < pcapHeader.length) {
+ return false;
+ }
+ decodePcapHeader(pcapHeader, byteOrder, maxLength, 0);
+
+ raw = new byte[originalLength];
+ n = in.read(raw);
+ if (n < 0) {
+ return false;
+ }
+ etherOffset = 0;
+
+ decodeEtherPacket();
+ return true;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public int decodePcap(final byte[] buffer, final int offset, final boolean byteOrder, final int maxLength) {
+ raw = buffer;
+ etherOffset = offset + PacketConstants.PCAP_HEADER_SIZE;
+ decodePcapHeader(raw, byteOrder, maxLength, offset);
+ decodeEtherPacket();
+ return offset + PacketConstants.PCAP_HEADER_SIZE + originalLength;
+ }
+
+ public String getPacketType() {
+ if (isTcpPacket()) {
+ return "TCP";
+ } else if (isUdpPacket()) {
+ return "UDP";
+ } else if (isArpPacket()) {
+ return "ARP";
+ } else if (isIcmpPacket()) {
+ return "ICMP";
+ } else {
+ return "unknown";
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV4Packet() {
+ return etherProtocol == PacketConstants.IPv4_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV6Packet() {
+ return etherProtocol == PacketConstants.IPv6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isPPPoV6Packet() {
+ return etherProtocol == PacketConstants.PPPoV6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isTcpPacket() {
+ return protocol == PacketConstants.TCP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isUdpPacket() {
+ return protocol == PacketConstants.UDP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isArpPacket() {
+ return protocol == PacketConstants.ARP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIcmpPacket() {
+ return protocol == PacketConstants.ICMP_PROTOCOL;
+ }
+
+ public long getSessionHash() {
+ if (isTcpPacket()) {
+ Murmur128 h1 = new Murmur128(1, 2);
+ byte[] buf = getIpAddressBytes(true);
+ assert buf != null;
+ h1.hash(buf, 0, buf.length);
+ h1.hash(getSrc_port());
+
+ Murmur128 h2 = new Murmur128(1, 2);
+ buf = getIpAddressBytes(false);
+ assert buf != null;
+ h2.hash(buf, 0, buf.length);
+ h2.hash(getDst_port());
+
+ return h1.digest64() ^ h2.digest64();
+ } else {
+ return 0;
+ }
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public int getPacketLength() {
+ return packetLength;
+ }
+
+ public InetAddress getSrc_ip() {
+ return getIPAddress(true);
+ }
+
+ public InetAddress getDst_ip() {
+ return getIPAddress(false);
+ }
+
+ public String getEthernetSource() {
+ return getEthernetAddress(PacketConstants.ETHER_SRC_OFFSET);
+ }
+
+ public String getEthernetDestination() {
+ return getEthernetAddress(PacketConstants.ETHER_DST_OFFSET);
+ }
+
+ public int getSequenceNumber() {
+ if (isTcpPacket()) {
+ int sequenceOffset = PacketConstants.ETHER_HEADER_LENGTH + getIPHeaderLength() + getTCPHeaderLength(raw) + 4;
+ return Math.abs(convertInt(raw, sequenceOffset));
+ } else {
+ return 0;
+ }
+ }
+
+ public int getSrc_port() {
+ if (isPPPoV6Packet()) {
+ return getPort(64);
+ }
+ if (isIpV6Packet()) {
+ if (isRoutingV6) {
+ return getPort(136);
+ }
+ return getPort(40);
+ }
+ return getPort(0);
+ }
+
+ public int getDst_port() {
+ if (isPPPoV6Packet()) {
+ return getPort(66);
+ }
+ if (isIpV6Packet()) {
+ if (isRoutingV6) {
+ return getPort(138);
+ }
+ return getPort(42);
+ }
+ return getPort(2);
+ }
+
+ public byte[] getData() {
+ int payloadDataStart = getIPHeaderLength();
+ if (isTcpPacket()) {
+ payloadDataStart += this.getTCPHeaderLength(raw);
+ } else if (isUdpPacket()) {
+ payloadDataStart += this.getUDPHeaderLength();
+ } else {
+ return null;
+ }
+ byte[] data = null;
+ if (packetLength >= payloadDataStart) {
+ data = new byte[packetLength - payloadDataStart];
+ System.arraycopy(raw, ipOffset + payloadDataStart, data, 0, data.length);
+ }
+ return data;
+ }
+
+ private InetAddress getIPAddress(final boolean src) {
+ byte[] ipBuffer = getIpAddressBytes(src);
+ if (ipBuffer == null) {
+ return null;
+ }
+ try {
+ return InetAddress.getByAddress(ipBuffer);
+ } catch (UnknownHostException e) {
+ return null;
+ }
+ }
+
+ private byte[] getIpAddressBytes(final boolean src) {
+ int srcPos;
+ byte[] ipBuffer;
+ if (isIpV4Packet()) {
+ ipBuffer = new byte[4];
+ srcPos = src ? PacketConstants.IP4_SRC_OFFSET : PacketConstants.IP4_DST_OFFSET;
+ } else if (isIpV6Packet()) {
+ ipBuffer = new byte[16];
+ if (isRoutingV6) {
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET + 96 : PacketConstants.IP6_DST_OFFSET + 96;
+ } else {
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET : PacketConstants.IP6_DST_OFFSET;
+ }
+ } else if (isPPPoV6Packet()) {
+ ipBuffer = new byte[16];
+ srcPos = src ? PacketConstants.IP6_SRC_OFFSET + PacketConstants.PPPoV6_IP_OFFSET : PacketConstants.IP6_DST_OFFSET + PacketConstants.PPPoV6_IP_OFFSET;
+ } else {
+ return null;
--- End diff --
I don't think that an exception is warranted. There may be other packet types than IP.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on the issue:
https://github.com/apache/drill/pull/831
Can we move this to contrib? I think we should get this one into the next release even as the rough edges (if any) are being smoothed out.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118619596
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/Utils.java ---
@@ -0,0 +1,65 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.primitives.Ints;
+import com.google.common.primitives.Shorts;
+
+public class Utils {
+
+ public static int getIntFileOrder(boolean byteOrder, final byte[] buf, final int offset) {
+ if (byteOrder) {
--- End diff --
Maybe an explanation of mapping byte order to booleans? true/false = which/which endian?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118102624
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Packet.java ---
@@ -0,0 +1,371 @@
+/*
+ * 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.pcap.decoder;
+
+import com.google.common.base.Preconditions;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.apache.drill.exec.store.pcap.Utils.convertInt;
+import static org.apache.drill.exec.store.pcap.Utils.convertShort;
+import static org.apache.drill.exec.store.pcap.Utils.getByte;
+import static org.apache.drill.exec.store.pcap.Utils.getIntFileOrder;
+import static org.apache.drill.exec.store.pcap.Utils.getShort;
+
+public class Packet {
+ // pcap header
+ // typedef struct pcaprec_hdr_s {
+ // guint32 ts_sec; // timestamp seconds
+ // guint32 ts_usec; // timestamp microseconds */
+ // guint32 incl_len; // number of octets of packet saved in file */
+ // guint32 orig_len; // actual length of packet */
+ // } pcaprec_hdr_t;
+ private long timestamp;
+ private int originalLength;
+
+ private byte[] raw;
+
+ private int etherOffset;
+ private int ipOffset;
+
+ private int packetLength;
+ private int etherProtocol;
+ private int protocol;
+
+ private boolean isRoutingV6;
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean readPcap(final InputStream in, final boolean byteOrder, final int maxLength) throws IOException {
+ byte[] pcapHeader = new byte[PacketConstants.PCAP_HEADER_SIZE];
+ int n = in.read(pcapHeader);
+ if (n < pcapHeader.length) {
+ return false;
+ }
+ decodePcapHeader(pcapHeader, byteOrder, maxLength, 0);
+
+ raw = new byte[originalLength];
+ n = in.read(raw);
+ if (n < 0) {
+ return false;
+ }
+ etherOffset = 0;
+
+ decodeEtherPacket();
+ return true;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public int decodePcap(final byte[] buffer, final int offset, final boolean byteOrder, final int maxLength) {
+ raw = buffer;
+ etherOffset = offset + PacketConstants.PCAP_HEADER_SIZE;
+ decodePcapHeader(raw, byteOrder, maxLength, offset);
+ decodeEtherPacket();
+ return offset + PacketConstants.PCAP_HEADER_SIZE + originalLength;
+ }
+
+ public String getPacketType() {
+ if (isTcpPacket()) {
+ return "TCP";
+ } else if (isUdpPacket()) {
+ return "UDP";
+ } else if (isArpPacket()) {
+ return "ARP";
+ } else if (isIcmpPacket()) {
+ return "ICMP";
+ } else {
+ return "unknown";
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV4Packet() {
+ return etherProtocol == PacketConstants.IPv4_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIpV6Packet() {
+ return etherProtocol == PacketConstants.IPv6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isPPPoV6Packet() {
+ return etherProtocol == PacketConstants.PPPoV6_TYPE;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isTcpPacket() {
+ return protocol == PacketConstants.TCP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isUdpPacket() {
+ return protocol == PacketConstants.UDP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isArpPacket() {
+ return protocol == PacketConstants.ARP_PROTOCOL;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public boolean isIcmpPacket() {
+ return protocol == PacketConstants.ICMP_PROTOCOL;
+ }
+
+ public long getSessionHash() {
--- End diff --
Is this useful? We are introducing a copy of murmur hash just for this.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on the issue:
https://github.com/apache/drill/pull/831
On Fri, Jun 30, 2017 at 9:55 AM, Paul Rogers <no...@github.com>
wrote:
> Later, once Drill provides the correct framework, I'd suggest that this
> code move into a separate Github repo to be maintained by experts in pcap.
> Frankly, most Drill developers are familiar with query engines, not pcap
> (or other specialized formats.)
>
>
That only works if Drill has an autoloading capability that allows storage
formats to be loaded and authenticated easily.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
Trying to figure out where we are on this PR. Looking at the review comments, some were addressed (thanks!), others are open. The question is: what is the resolution of the open issues? Anything to fix? Is the comment based on a misunderstanding? Is the requested work beyond the scope of this particular PR? Is there a disagreement?
Perhaps respond to each open comment saying something like "will fix", "won't fix", "beyond scope" or something so we know if we're ready to move ahead with this PR, or if we are waiting for a few more improvements.
Thanks!
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on the issue:
https://github.com/apache/drill/pull/831
I would recommend moving this format plugin to the contrib directory, since this is a new and untested implementation.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118397652
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ private PacketDecoder getPacketDecoder() {
+ try {
+ return new PacketDecoder(in);
+ } catch (IOException io) {
+ throw new RuntimeException("File Not Found or some I/O issue");
+ }
+ }
+
+ private ImmutableList<ProjectedColumnInfo> getProjectedColsIfItNull() {
+ return projectedCols != null ? projectedCols : initCols(new Schema());
+ }
+
+ private ImmutableList<ProjectedColumnInfo> initCols(final Schema schema) {
+ ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
+ ColumnDto column;
+
+ for (int i = 0; i < schema.getNumberOfColumns(); i++) {
+ column = schema.getColumnByIndex(i);
+
+ final String name = column.getColumnName();
+ final PcapTypes type = column.getColumnType();
+ TypeProtos.MinorType minorType = TYPES.get(type);
+
+ ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
+ pciBuilder.add(pci);
+ }
+ return pciBuilder.build();
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column,
+ final String name,
+ final MinorType minorType) {
+ TypeProtos.MajorType majorType = getMajorType(minorType);
+
+ MaterializedField field =
+ MaterializedField.create(name, majorType);
+
+ ValueVector vector =
+ getValueVector(minorType, majorType, field);
+
+ return getProjectedColumnInfo(column, vector);
+ }
+
+ private ProjectedColumnInfo getProjectedColumnInfo(final ColumnDto column, final ValueVector vector) {
+ ProjectedColumnInfo pci = new ProjectedColumnInfo();
+ pci.vv = vector;
+ pci.pcapColumn = column;
+ return pci;
+ }
+
+ private MajorType getMajorType(final MinorType minorType) {
+ return Types.optional(minorType);
+ }
+
+ private ValueVector getValueVector(final MinorType minorType,
+ final MajorType majorType,
+ final MaterializedField field) {
+ try {
+
+ final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(
+ minorType, majorType.getMode());
+ ValueVector vector = output.addField(field, clazz);
+ vector.allocateNew();
+ return vector;
+
+ } catch (SchemaChangeException sce) {
+ throw new NullPointerException("The addition of this field is incompatible with this OutputMutator's capabilities");
+ }
+ }
+
+ private int parsePcapFilesAndPutItToTable() throws IOException {
+ Packet packet = new Packet();
+ while (offset < validBytes) {
+
+ if (validBytes - offset < 9000) {
+ System.arraycopy(buffer, offset, buffer, 0, validBytes - offset);
+ validBytes = validBytes - offset;
+ offset = 0;
+
+ int n = in.read(buffer, validBytes, buffer.length - validBytes);
+ if (n > 0) {
+ validBytes += n;
+ }
+ }
+
+ offset = decoder.decodePacket(buffer, offset, packet);
+
+ if (addDataToTable(packet, decoder.getNetwork())) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ private boolean addDataToTable(final Packet packet, final int networkType) {
+ for (ProjectedColumnInfo pci : projectedCols) {
+ switch (pci.pcapColumn.getColumnName()) {
+ case "type":
+ setStringColumnValue(packet.getPacketType(), pci);
+ break;
+ case "timestamp":
+ setTimestampColumnValue(packet.getTimestamp(), pci);
+ break;
+ case "network":
+ setIntegerColumnValue(networkType, pci);
+ break;
+ case "src_mac_address":
+ setStringColumnValue(packet.getEthernetSource(), pci);
+ break;
+ case "dst_mac_address":
+ setStringColumnValue(packet.getEthernetDestination(), pci);
+ break;
+ case "dst_ip":
+ if (packet.getDst_ip() != null) {
+ setStringColumnValue(packet.getDst_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_ip":
+ if (packet.getSrc_ip() != null) {
+ setStringColumnValue(packet.getSrc_ip().getHostAddress(), pci);
+ } else {
+ setStringColumnValue(null, pci);
+ }
+ break;
+ case "src_port":
+ setIntegerColumnValue(packet.getSrc_port(), pci);
+ break;
+ case "dst_port":
+ setIntegerColumnValue(packet.getDst_port(), pci);
+ break;
+ case "tcp_session":
+ if (packet.isTcpPacket()) {
+ setLongColumnValue(packet.getSessionHash(), pci);
+ }
+ break;
+ case "tcp_sequence":
+ if (packet.isTcpPacket()) {
+ setIntegerColumnValue(packet.getSequenceNumber(), pci);
+ }
+ break;
+ case "packet_length":
+ setIntegerColumnValue(packet.getPacketLength(), pci);
+ break;
+ case "data":
+ if (packet.getData() != null) {
+ setStringColumnValue(parseBytesToASCII(packet.getData()), pci);
--- End diff --
No. I don't want to always do this. I want the ASCII version of the packet to be an optional field that you can pull, likewise with the binary version.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118097440
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/dto/ColumnDto.java ---
@@ -0,0 +1,63 @@
+/*
+ * 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.pcap.dto;
+
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+
+import java.util.Objects;
+
+public class ColumnDto {
+
+ private final String columnName;
+ private final PcapTypes columnType;
+
+ public ColumnDto(String columnName, PcapTypes columnType) {
+ this.columnName = columnName;
+ this.columnType = columnType;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public PcapTypes getColumnType() {
+ return columnType;
+ }
+
+ public boolean isNullable() {
+ return true;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ColumnDto columnDto = (ColumnDto) o;
+ return Objects.equals(columnName, columnDto.columnName) &&
--- End diff --
Are you sure `Object.equals` is what you want here, and not `String.equals` ?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118616240
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
--- End diff --
Do you want to do this at construct time? If you scan 1000 pcap files in a single fragment, Drill will create 1000 record readers at the start of execution. Each will allocate a 100K buffer. You'll have 100MB of heap in buffers, of which only one will ever be used.
Suggestion: allocate the buffer in setup, clear it in close, so that only one buffer is used per fragment.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118406754
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Murmur128.java ---
@@ -0,0 +1,161 @@
+/*
--- End diff --
I was thinking of simply moving the code to the existing implementation.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118109637
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/decoder/Murmur128.java ---
@@ -0,0 +1,161 @@
+/*
--- End diff --
We already have a Murmur Hash implementation for use with Direct buffers. (see `org.apache.drill.exec.expr.fn.impl.MurmurHash3` ). Can we merge these two and have only one copy?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118616554
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
+ } catch (IOException io) {
+ throw new RuntimeException("Trouble with reading packets in file!");
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
--- End diff --
Close your file handle? Set buffer to null to hasten its reclamation?
Note that `close()` is called both for normal completion and when the fragment fails. So, any resources used by the reader must be released here.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118617482
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapRecordReader.java ---
@@ -0,0 +1,295 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.ops.OperatorContext;
+import org.apache.drill.exec.physical.impl.OutputMutator;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.AbstractRecordReader;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.apache.drill.exec.store.pcap.dto.ColumnDto;
+import org.apache.drill.exec.store.pcap.schema.PcapTypes;
+import org.apache.drill.exec.store.pcap.schema.Schema;
+import org.apache.drill.exec.vector.NullableBigIntVector;
+import org.apache.drill.exec.vector.NullableIntVector;
+import org.apache.drill.exec.vector.NullableTimeStampVector;
+import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.apache.drill.exec.vector.ValueVector;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.drill.exec.store.pcap.Utils.parseBytesToASCII;
+
+public class PcapRecordReader extends AbstractRecordReader {
+
+ private OutputMutator output;
+
+ private final PacketDecoder decoder;
+ private ImmutableList<ProjectedColumnInfo> projectedCols;
+
+ private byte[] buffer = new byte[100000];
+ private int offset = 0;
+ private InputStream in;
+ private int validBytes;
+
+ private static final Map<PcapTypes, MinorType> TYPES;
+
+ private static class ProjectedColumnInfo {
+ ValueVector vv;
+ ColumnDto pcapColumn;
+ }
+
+ static {
+ TYPES = ImmutableMap.<PcapTypes, TypeProtos.MinorType>builder()
+ .put(PcapTypes.STRING, MinorType.VARCHAR)
+ .put(PcapTypes.INTEGER, MinorType.INT)
+ .put(PcapTypes.LONG, MinorType.BIGINT)
+ .put(PcapTypes.TIMESTAMP, MinorType.TIMESTAMP)
+ .build();
+ }
+
+ public PcapRecordReader(final String inputPath,
+ final List<SchemaPath> projectedColumns) {
+ try {
+ this.in = new FileInputStream(inputPath);
+ this.decoder = getPacketDecoder();
+ validBytes = in.read(buffer);
+ } catch (IOException e) {
+ throw new RuntimeException("File " + inputPath + " not Found");
+ }
+ setColumns(projectedColumns);
+ }
+
+ @Override
+ public void setup(final OperatorContext context, final OutputMutator output) throws ExecutionSetupException {
+ this.output = output;
+ }
+
+ @Override
+ public int next() {
+ projectedCols = getProjectedColsIfItNull();
+ try {
+ return parsePcapFilesAndPutItToTable();
--- End diff --
Drill has certain protocols that are not entirely obvious, but that are needed here. Each call to `next()` produces a batch of rows. Drill requires that the batch contain no more than 64K rows. (Bad things happen if the batch has more.) So, the trick for a record reader is to read up to some maximum number of records into each batch, return, and wait to be called again for the next batch.
Depending on the size of the data, 64K may be to large and 8K or some other number may be better. Try to avoid causing any vector to be larger than 16 MB. (We're working on a project to enforce this, and the result will make it much easier to write a record reader. Too bad your project is just a bit too early to benefit.)
If I read this code correctly, each call to `next()` returns just one record, until EOF at which time it returns 0.
You'll find that the rest of Drill will be *very* slow with a batch size of 1 record. So, perhaps put this into a loop to read 8K or so rows into a single batch, then return the total record count. You should see a nice execution speed-up.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118614384
--- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/PcapDrillTable.java ---
@@ -0,0 +1,73 @@
+/*
--- End diff --
Would be very helpful if this PR can include a package-info.java file to describe this work. For example, what is pcap? Links to good sources? What features of Drill does it use (push-downs)? Etc.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by parthchandra <gi...@git.apache.org>.
Github user parthchandra commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118098082
--- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/store/pcap/TestPcapDecoder.java ---
@@ -0,0 +1,230 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.io.Resources;
+import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestPcapDecoder extends BaseTestQuery {
+ private static File bigFile;
+
+ /**
+ * Creates an ephemeral file of about a GB in size
+ *
+ * @throws IOException If input file can't be read or output can't be written.
+ */
+ @BeforeClass
+ public static void buildBigTcpFile() throws IOException {
+ bigFile = File.createTempFile("tcp", ".pcap");
+ bigFile.deleteOnExit();
+ boolean first = true;
+ System.out.printf("Building large test file\n");
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(bigFile))) {
+ for (int i = 0; i < 1000e6 / (29208 - 24) + 1; i++) {
+ // might be faster to keep this open and rewind each time, but
+ // that is hard to do with a resource, especially if it comes
+ // from the class path instead of files.
+ try (InputStream in = Resources.getResource("store/pcap/tcp-2.pcap").openStream()) {
+ ConcatPcap.copy(first, in, out);
+ }
+ first = false;
+ }
+ System.out.printf("Created file is %.1f MB\n", bigFile.length() / 1e6);
--- End diff --
Can we not use System.out in a test? We're trying to get the output from a full build to be smaller.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by dmitriyHavrilovich <gi...@git.apache.org>.
Github user dmitriyHavrilovich commented on the issue:
https://github.com/apache/drill/pull/831
We will not move this to contrib because of issue. Request for package-info.java will be satisfied. Also comment in utils will be added. If I did not miss something, that is all ?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
Re: [GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by Parth Chandra <pa...@apache.org>.
I didn't realize this and, to be honest, I don't know how the other format
plugins are handling this. Leave this as it is?
On Tue, Jun 27, 2017 at 5:11 PM, paul-rogers <gi...@git.apache.org> wrote:
> Github user paul-rogers commented on the issue:
>
> https://github.com/apache/drill/pull/831
>
> Regarding bootstrap-storage-plugin.json, this is a generic issue.
> Drill must provide a solution that allows each module to provide its own
> file, as is done for drill-module.conf. I did not file a JIRA for this
> issue, feel free to file one.
>
>
> ---
> 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 infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
Regarding bootstrap-storage-plugin.json, this is a generic issue. Drill must provide a solution that allows each module to provide its own file, as is done for drill-module.conf. I did not file a JIRA for this issue, feel free to file one.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #831: DRILL-5432: Added pcap-format support
Posted by tdunning <gi...@git.apache.org>.
Github user tdunning commented on a diff in the pull request:
https://github.com/apache/drill/pull/831#discussion_r118399563
--- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/store/pcap/TestPcapDecoder.java ---
@@ -0,0 +1,230 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.pcap;
+
+import com.google.common.io.Resources;
+import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.store.pcap.decoder.Packet;
+import org.apache.drill.exec.store.pcap.decoder.PacketDecoder;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestPcapDecoder extends BaseTestQuery {
+ private static File bigFile;
+
+ /**
+ * Creates an ephemeral file of about a GB in size
+ *
+ * @throws IOException If input file can't be read or output can't be written.
+ */
+ @BeforeClass
+ public static void buildBigTcpFile() throws IOException {
+ bigFile = File.createTempFile("tcp", ".pcap");
+ bigFile.deleteOnExit();
+ boolean first = true;
+ System.out.printf("Building large test file\n");
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(bigFile))) {
+ for (int i = 0; i < 1000e6 / (29208 - 24) + 1; i++) {
+ // might be faster to keep this open and rewind each time, but
+ // that is hard to do with a resource, especially if it comes
+ // from the class path instead of files.
+ try (InputStream in = Resources.getResource("store/pcap/tcp-2.pcap").openStream()) {
+ ConcatPcap.copy(first, in, out);
+ }
+ first = false;
+ }
+ System.out.printf("Created file is %.1f MB\n", bigFile.length() / 1e6);
--- End diff --
I changed those methods to be called from a public static void main(). That allows them to be used to get information about speeds, but doesn't include their output in the test.
I think that addresses this comment.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #831: DRILL-5432: Added pcap-format support
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/831
Squashed commits and committed to Apache master. Congratulations!
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---