Search in sources :

Example 1 with ColumnDto

use of org.apache.drill.exec.store.pcap.dto.ColumnDto in project drill by axbaretto.

the class PcapDrillTable method convertToRelDataType.

private void convertToRelDataType(RelDataTypeFactory typeFactory, List<String> names, List<RelDataType> types) {
    for (ColumnDto column : schema.getColumns()) {
        names.add(column.getColumnName());
        RelDataType type = getSqlTypeFromPcapType(typeFactory, column.getColumnType());
        type = typeFactory.createTypeWithNullability(type, column.isNullable());
        types.add(type);
    }
}
Also used : RelDataType(org.apache.calcite.rel.type.RelDataType) ColumnDto(org.apache.drill.exec.store.pcap.dto.ColumnDto)

Example 2 with ColumnDto

use of org.apache.drill.exec.store.pcap.dto.ColumnDto in project drill by axbaretto.

the class PcapRecordReader method initCols.

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().toLowerCase();
        final PcapTypes type = column.getColumnType();
        TypeProtos.MinorType minorType = TYPES.get(type);
        ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
        pciBuilder.add(pci);
    }
    return pciBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) PcapTypes(org.apache.drill.exec.store.pcap.schema.PcapTypes) TypeProtos(org.apache.drill.common.types.TypeProtos) ColumnDto(org.apache.drill.exec.store.pcap.dto.ColumnDto)

Example 3 with ColumnDto

use of org.apache.drill.exec.store.pcap.dto.ColumnDto in project drill by axbaretto.

the class Schema method setupStructure.

private void setupStructure() {
    columns.add(new ColumnDto("type", PcapTypes.STRING));
    columns.add(new ColumnDto("network", PcapTypes.INTEGER));
    columns.add(new ColumnDto("timestamp", PcapTypes.TIMESTAMP));
    columns.add(new ColumnDto("src_ip", PcapTypes.STRING));
    columns.add(new ColumnDto("dst_ip", PcapTypes.STRING));
    columns.add(new ColumnDto("src_port", PcapTypes.INTEGER));
    columns.add(new ColumnDto("dst_port", PcapTypes.INTEGER));
    columns.add(new ColumnDto("src_mac_address", PcapTypes.STRING));
    columns.add(new ColumnDto("dst_mac_address", PcapTypes.STRING));
    columns.add(new ColumnDto("tcp_session", PcapTypes.LONG));
    columns.add(new ColumnDto("tcp_ack", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_ns", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_cwr", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_ece ", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_ece_ecn_capable", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_ece_congestion_experienced", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_urg", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_ack", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_psh", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_rst", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_syn", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_flags_fin", PcapTypes.INTEGER));
    columns.add(new ColumnDto("tcp_parsed_flags", PcapTypes.STRING));
    columns.add(new ColumnDto("packet_length", PcapTypes.INTEGER));
    columns.add(new ColumnDto("data", PcapTypes.STRING));
}
Also used : ColumnDto(org.apache.drill.exec.store.pcap.dto.ColumnDto)

Example 4 with ColumnDto

use of org.apache.drill.exec.store.pcap.dto.ColumnDto in project drill by apache.

the class Schema method setupStructure.

private void setupStructure() {
    typeMap[PcapTypes.BOOLEAN.ordinal()] = MinorType.BIT;
    typeMap[PcapTypes.INTEGER.ordinal()] = MinorType.INT;
    typeMap[PcapTypes.STRING.ordinal()] = MinorType.VARCHAR;
    typeMap[PcapTypes.LONG.ordinal()] = MinorType.BIGINT;
    typeMap[PcapTypes.TIMESTAMP.ordinal()] = MinorType.TIMESTAMP;
    typeMap[PcapTypes.DURATION.ordinal()] = MinorType.INTERVAL;
    // Common columns
    columns.add(new ColumnDto("src_ip", PcapTypes.STRING));
    columns.add(new ColumnDto("dst_ip", PcapTypes.STRING));
    columns.add(new ColumnDto("src_port", PcapTypes.INTEGER));
    columns.add(new ColumnDto("dst_port", PcapTypes.INTEGER));
    columns.add(new ColumnDto("src_mac_address", PcapTypes.STRING));
    columns.add(new ColumnDto("dst_mac_address", PcapTypes.STRING));
    // Columns specific for Sessionized TCP Sessions
    if (sessionizeTCPStreams) {
        columns.add(new ColumnDto("session_start_time", PcapTypes.TIMESTAMP));
        columns.add(new ColumnDto("session_end_time", PcapTypes.TIMESTAMP));
        columns.add(new ColumnDto("session_duration", PcapTypes.DURATION));
        columns.add(new ColumnDto("total_packet_count", PcapTypes.INTEGER));
        columns.add(new ColumnDto("data_volume_from_origin", PcapTypes.INTEGER));
        columns.add(new ColumnDto("data_volume_from_remote", PcapTypes.INTEGER));
        columns.add(new ColumnDto("packet_count_from_origin", PcapTypes.INTEGER));
        columns.add(new ColumnDto("packet_count_from_remote", PcapTypes.INTEGER));
        columns.add(new ColumnDto("connection_time", PcapTypes.DURATION));
        columns.add(new ColumnDto("tcp_session", PcapTypes.LONG));
        columns.add(new ColumnDto("is_corrupt", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("data_from_originator", PcapTypes.STRING));
        columns.add(new ColumnDto("data_from_remote", PcapTypes.STRING));
    } else {
        // Columns for Regular Packets
        columns.add(new ColumnDto("type", PcapTypes.STRING));
        columns.add(new ColumnDto("network", PcapTypes.INTEGER));
        columns.add(new ColumnDto("packet_timestamp", PcapTypes.TIMESTAMP));
        columns.add(new ColumnDto("timestamp_micro", PcapTypes.LONG));
        columns.add(new ColumnDto("tcp_session", PcapTypes.LONG));
        columns.add(new ColumnDto("tcp_sequence", PcapTypes.INTEGER));
        columns.add(new ColumnDto("tcp_ack", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags", PcapTypes.INTEGER));
        columns.add(new ColumnDto("tcp_flags_ns", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_cwr", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_ece", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_ece_ecn_capable", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_ece_congestion_experienced", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_urg", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_ack", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_psh", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_rst", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_syn", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_flags_fin", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("tcp_parsed_flags", PcapTypes.STRING));
        columns.add(new ColumnDto("packet_length", PcapTypes.INTEGER));
        columns.add(new ColumnDto("is_corrupt", PcapTypes.BOOLEAN));
        columns.add(new ColumnDto("data", PcapTypes.STRING));
    }
}
Also used : ColumnDto(org.apache.drill.exec.store.pcap.dto.ColumnDto)

Aggregations

ColumnDto (org.apache.drill.exec.store.pcap.dto.ColumnDto)4 ImmutableList (com.google.common.collect.ImmutableList)1 RelDataType (org.apache.calcite.rel.type.RelDataType)1 TypeProtos (org.apache.drill.common.types.TypeProtos)1 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)1 PcapTypes (org.apache.drill.exec.store.pcap.schema.PcapTypes)1