[
https://issues.apache.org/jira/browse/DRILL-7385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16945207#comment-16945207
]
ASF GitHub Bot commented on DRILL-7385:
---------------------------------------
paul-rogers commented on pull request #1862: DRILL-7385: Convert PCAP Format
Plugin to EVF
URL: https://github.com/apache/drill/pull/1862#discussion_r331767234
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/store/pcap/schema/Schema.java
##########
@@ -78,4 +81,23 @@ public ColumnDto getColumnByIndex(int i) {
public int getNumberOfColumns() {
return columns.size();
}
+
+ public TupleMetadata buildSchema(SchemaBuilder builder) {
+ for(ColumnDto column : columns) {
+ if(column.getColumnType() == PcapTypes.BOOLEAN) {
+ builder.addNullable(column.getColumnName(), TypeProtos.MinorType.BIT);
+ } else if(column.getColumnType() == PcapTypes.INTEGER) {
+ builder.addNullable(column.getColumnName(), TypeProtos.MinorType.INT);
+ } else if(column.getColumnType() == PcapTypes.STRING) {
+ builder.addNullable(column.getColumnName(),
TypeProtos.MinorType.VARCHAR);
+ } else if(column.getColumnType() == PcapTypes.TIMESTAMP) {
+ builder.addNullable(column.getColumnName(),
TypeProtos.MinorType.TIMESTAMP);
+ } else if(column.getColumnType() == PcapTypes.LONG) {
+ builder.addNullable(column.getColumnName(),
TypeProtos.MinorType.BIGINT);
Review comment:
Nit: would be simpler to do something like the following:
```
for (ColumnTdo column : columns) {
builder.addNullable(column.getColumnName(), convertType(column));
}
...
MinorType convertType(ColumnDto column) {
switch (column.getColumnType()) {
case PcapTypes.BOOLEAN:
return MinorType.BIT;
...
```
The above requires that we handle the case of a type that is not in the
switch: maybe throw an exception or some such.
Also, if the types are integers and configuous (which they are of PcapTypes
is an enum), then you can create a mapping table:
```
MinorType typeMap[] = new int[PcapTypes.getSize()];
typeMap[PcapTypes.BOOLEAN.getOrdinal()] = MinorType.BIT;
...
```
Then:
```
for (ColumnTdo column : columns) {
builder.addNullable(column.getColumnName(),
typeMap[column.getColumType().getOrdinal());
```
The mapping table is the fastest solution. But, this is not super critical
in a once-per-file activity.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Convert PCAP Format Plugin to EVF
> ---------------------------------
>
> Key: DRILL-7385
> URL: https://issues.apache.org/jira/browse/DRILL-7385
> Project: Apache Drill
> Issue Type: Improvement
> Affects Versions: 1.16.0
> Reporter: Charles Givre
> Assignee: Charles Givre
> Priority: Major
> Fix For: 1.17.0
>
>
> The PCAP format plugin has the possibility of extracting considerably more
> data out of PCAP files. To facilitate this, this PR updates the plugin to
> use the new Enhanced Vector Framework. No changes in functionality should
> occur.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)