浅谈序列化之protobuf与avro对比(Java)

最近在做socket通信中用到了关于序列化工具选型的问题,在调研过程中开始趋向于用protobuf,可以省去了编解码的过程。能够实现快速开发,且只需要维护一份协议文件即可。

但是调研过程中发现了protobuf的一些弊端,比如需要生成相应的文件类,和业务绑定太紧密,所以在看了AVRO之后发现它完美解决了这个问题。

下面记录下对这两种序列化工具的入门与测评。

一、protobuf基本操作

protobuf简介:

Protocol Buffers (a.k.a., protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. 

protobuf是google提供的一种跨语言、跨平台、可扩展的序列化工具。

1.1定义协议文件(部分字段)(TCPLog.proto):

syntax = "proto2";
message TCPLog{
     optional int32  total_byteps = 1;
     optional int64 flow_start_time =2;
     optional int64 date =3;
}

1.2生成对应的Java类:

生成过程可以使用ecplise 的插件 或者 直接在控制台中使用命令生成。

命令行中生成规则如下:

protoc.exe -I=proto的输入目录 --java_out=java类输出目录 proto的输入目录包括包括proto文件

生成java类如下:

// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: TCPLog.proto

public final class TCPLogOuterClass {
 private TCPLogOuterClass() {}
 public static void registerAllExtensions(
   com.google.protobuf.ExtensionRegistryLite registry) {
 }

 public static void registerAllExtensions(
   com.google.protobuf.ExtensionRegistry registry) {
  registerAllExtensions(
    (com.google.protobuf.ExtensionRegistryLite) registry);
 }
 public interface TCPLogOrBuilder extends
   // @@protoc_insertion_point(interface_extends:TCPLog)
   com.google.protobuf.MessageOrBuilder {

  /**
   * <code>optional int32 total_byteps = 1;</code>
   */
  boolean hasTotalByteps();
  /**
   * <code>optional int32 total_byteps = 1;</code>
   */
  int getTotalByteps();

  /**
   * <code>optional int64 flow_start_time = 2;</code>
   */
  boolean hasFlowStartTime();
  /**
   * <code>optional int64 flow_start_time = 2;</code>
   */
  long getFlowStartTime();

  /**
   * <code>optional int64 date = 3;</code>
   */
  boolean hasDate();
  /**
   * <code>optional int64 date = 3;</code>
   */
  long getDate();

  /**
   * <code>optional int64 server_total_packet = 4;</code>
   */
  boolean hasServerTotalPacket();
  /**
   * <code>optional int64 server_total_packet = 4;</code>
   */
  long getServerTotalPacket();

  /**
   * <code>optional int64 client_total_byte = 5;</code>
   */
  boolean hasClientTotalByte();
  /**
   * <code>optional int64 client_total_byte = 5;</code>
   */
  long getClientTotalByte();

  /**
   * <code>optional int32 link_id = 6;</code>
   */
  boolean hasLinkId();
  /**
   * <code>optional int32 link_id = 6;</code>
   */
  int getLinkId();

  /**
   * <code>optional int64 total_byte = 7;</code>
   */
  boolean hasTotalByte();
  /**
   * <code>optional int64 total_byte = 7;</code>
   */
  long getTotalByte();

  /**
   * <code>optional int64 flow_end_time = 8;</code>
   */
  boolean hasFlowEndTime();
  /**
   * <code>optional int64 flow_end_time = 8;</code>
   */
  long getFlowEndTime();

  /**
   * <code>optional int32 client_port = 9;</code>
   */
  boolean hasClientPort();
  /**
   * <code>optional int32 client_port = 9;</code>
   */
  int getClientPort();

  /**
   * <code>optional int32 protocol = 10;</code>
   */
  boolean hasProtocol();
  /**
   * <code>optional int32 protocol = 10;</code>
   */
  int getProtocol();

  /**
   * <code>optional int64 total_packet = 11;</code>
   */
  boolean hasTotalPacket();
  /**
   * <code>optional int64 total_packet = 11;</code>
   */
  long getTotalPacket();

  /**
   * <code>optional int64 flow_duration = 12;</code>
   */
  boolean hasFlowDuration();
  /**
   * <code>optional int64 flow_duration = 12;</code>
   */
  long getFlowDuration();

  /**
   * <code>optional string id = 13;</code>
   */
  boolean hasId();
  /**
   * <code>optional string id = 13;</code>
   */
  java.lang.String getId();
  /**
   * <code>optional string id = 13;</code>
   */
  com.google.protobuf.ByteString
    getIdBytes();

  /**
   * <code>optional string server_ip_addr = 14;</code>
   */
  boolean hasServerIpAddr();
  /**
   * <code>optional string server_ip_addr = 14;</code>
   */
  java.lang.String getServerIpAddr();
  /**
   * <code>optional string server_ip_addr = 14;</code>
   */
  com.google.protobuf.ByteString
    getServerIpAddrBytes();

  /**
   * <code>optional string direction_mask = 15;</code>
   */
  boolean hasDirectionMask();
  /**
   * <code>optional string direction_mask = 15;</code>
   */
  java.lang.String getDirectionMask();
  /**
   * <code>optional string direction_mask = 15;</code>
   */
  com.google.protobuf.ByteString
    getDirectionMaskBytes();

  /**
   * <code>optional int32 app = 16;</code>
   */
  boolean hasApp();
  /**
   * <code>optional int32 app = 16;</code>
   */
  int getApp();

  /**
   * <code>optional int32 client_country_id = 17;</code>
   */
  boolean hasClientCountryId();
  /**
   * <code>optional int32 client_country_id = 17;</code>
   */
  int getClientCountryId();

  /**
   * <code>optional int32 client_netsegment_id = 18;</code>
   */
  boolean hasClientNetsegmentId();
  /**
   * <code>optional int32 client_netsegment_id = 18;</code>
   */
  int getClientNetsegmentId();

  /**
   * <code>optional int64 client_total_packet = 19;</code>
   */
  boolean hasClientTotalPacket();
  /**
   * <code>optional int64 client_total_packet = 19;</code>
   */
  long getClientTotalPacket();

  /**
   * <code>optional string client_ip_addr = 20;</code>
   */
  boolean hasClientIpAddr();
  /**
   * <code>optional string client_ip_addr = 20;</code>
   */
  java.lang.String getClientIpAddr();
  /**
   * <code>optional string client_ip_addr = 20;</code>
   */
  com.google.protobuf.ByteString
    getClientIpAddrBytes();

  /**
   * <code>optional int32 tcp_status = 21;</code>
   */
  boolean hasTcpStatus();
  /**
   * <code>optional int32 tcp_status = 21;</code>
   */
  int getTcpStatus();

  /**
   * <code>optional int32 server_country_id = 22;</code>
   */
  boolean hasServerCountryId();
  /**
   * <code>optional int32 server_country_id = 22;</code>
   */
  int getServerCountryId();

  /**
   * <code>optional int32 server_netsegment_id = 23;</code>
   */
  boolean hasServerNetsegmentId();
  /**
   * <code>optional int32 server_netsegment_id = 23;</code>
   */
  int getServerNetsegmentId();

  /**
   * <code>optional int64 avg_pkt_size = 24;</code>
   */
  boolean hasAvgPktSize();
  /**
   * <code>optional int64 avg_pkt_size = 24;</code>
   */
  long getAvgPktSize();

  /**
   * <code>optional int32 server_port = 25;</code>
   */
  boolean hasServerPort();
  /**
   * <code>optional int32 server_port = 25;</code>
   */
  int getServerPort();

  /**
   * <code>optional int64 server_total_byte = 26;</code>
   */
  boolean hasServerTotalByte();
  /**
   * <code>optional int64 server_total_byte = 26;</code>
   */
  long getServerTotalByte();

  /**
   * <code>optional int32 total_packetps = 27;</code>
   */
  boolean hasTotalPacketps();
  /**
   * <code>optional int32 total_packetps = 27;</code>
   */
  int getTotalPacketps();
 }
 /**
  * Protobuf type {@code TCPLog}
  */
 public static final class TCPLog extends
   com.google.protobuf.GeneratedMessageV3 implements
   // @@protoc_insertion_point(message_implements:TCPLog)
   TCPLogOrBuilder {
  // Use TCPLog.newBuilder() to construct.
  private TCPLog(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
   super(builder);
  }
  private TCPLog() {
   totalByteps_ = 0;
   flowStartTime_ = 0L;
   date_ = 0L;
   serverTotalPacket_ = 0L;
   clientTotalByte_ = 0L;
   linkId_ = 0;
   totalByte_ = 0L;
   flowEndTime_ = 0L;
   clientPort_ = 0;
   protocol_ = 0;
   totalPacket_ = 0L;
   flowDuration_ = 0L;
   id_ = "";
   serverIpAddr_ = "";
   directionMask_ = "";
   app_ = 0;
   clientCountryId_ = 0;
   clientNetsegmentId_ = 0;
   clientTotalPacket_ = 0L;
   clientIpAddr_ = "";
   tcpStatus_ = 0;
   serverCountryId_ = 0;
   serverNetsegmentId_ = 0;
   avgPktSize_ = 0L;
   serverPort_ = 0;
   serverTotalByte_ = 0L;
   totalPacketps_ = 0;
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
   return this.unknownFields;
  }
  private TCPLog(
    com.google.protobuf.CodedInputStream input,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws com.google.protobuf.InvalidProtocolBufferException {
   this();
   int mutable_bitField0_ = 0;
   com.google.protobuf.UnknownFieldSet.Builder unknownFields =
     com.google.protobuf.UnknownFieldSet.newBuilder();
   try {
    boolean done = false;
    while (!done) {
     int tag = input.readTag();
     switch (tag) {
      case 0:
       done = true;
       break;
      default: {
       if (!parseUnknownField(input, unknownFields,
                   extensionRegistry, tag)) {
        done = true;
       }
       break;
      }
      case 8: {
       bitField0_ |= 0x00000001;
       totalByteps_ = input.readInt32();
       break;
      }
      case 16: {
       bitField0_ |= 0x00000002;
       flowStartTime_ = input.readInt64();
       break;
      }
      case 24: {
       bitField0_ |= 0x00000004;
       date_ = input.readInt64();
       break;
      }
      case 32: {
       bitField0_ |= 0x00000008;
       serverTotalPacket_ = input.readInt64();
       break;
      }
      case 40: {
       bitField0_ |= 0x00000010;
       clientTotalByte_ = input.readInt64();
       break;
      }
      case 48: {
       bitField0_ |= 0x00000020;
       linkId_ = input.readInt32();
       break;
      }
      case 56: {
       bitField0_ |= 0x00000040;
       totalByte_ = input.readInt64();
       break;
      }
      case 64: {
       bitField0_ |= 0x00000080;
       flowEndTime_ = input.readInt64();
       break;
      }
      case 72: {
       bitField0_ |= 0x00000100;
       clientPort_ = input.readInt32();
       break;
      }
      case 80: {
       bitField0_ |= 0x00000200;
       protocol_ = input.readInt32();
       break;
      }
      case 88: {
       bitField0_ |= 0x00000400;
       totalPacket_ = input.readInt64();
       break;
      }
      case 96: {
       bitField0_ |= 0x00000800;
       flowDuration_ = input.readInt64();
       break;
      }
      case 106: {
       com.google.protobuf.ByteString bs = input.readBytes();
       bitField0_ |= 0x00001000;
       id_ = bs;
       break;
      }
      case 114: {
       com.google.protobuf.ByteString bs = input.readBytes();
       bitField0_ |= 0x00002000;
       serverIpAddr_ = bs;
       break;
      }
      case 122: {
       com.google.protobuf.ByteString bs = input.readBytes();
       bitField0_ |= 0x00004000;
       directionMask_ = bs;
       break;
      }
      case 128: {
       bitField0_ |= 0x00008000;
       app_ = input.readInt32();
       break;
      }
      case 136: {
       bitField0_ |= 0x00010000;
       clientCountryId_ = input.readInt32();
       break;
      }
      case 144: {
       bitField0_ |= 0x00020000;
       clientNetsegmentId_ = input.readInt32();
       break;
      }
      case 152: {
       bitField0_ |= 0x00040000;
       clientTotalPacket_ = input.readInt64();
       break;
      }
      case 162: {
       com.google.protobuf.ByteString bs = input.readBytes();
       bitField0_ |= 0x00080000;
       clientIpAddr_ = bs;
       break;
      }
      case 168: {
       bitField0_ |= 0x00100000;
       tcpStatus_ = input.readInt32();
       break;
      }
      case 176: {
       bitField0_ |= 0x00200000;
       serverCountryId_ = input.readInt32();
       break;
      }
      case 184: {
       bitField0_ |= 0x00400000;
       serverNetsegmentId_ = input.readInt32();
       break;
      }
      case 192: {
       bitField0_ |= 0x00800000;
       avgPktSize_ = input.readInt64();
       break;
      }
      case 200: {
       bitField0_ |= 0x01000000;
       serverPort_ = input.readInt32();
       break;
      }
      case 208: {
       bitField0_ |= 0x02000000;
       serverTotalByte_ = input.readInt64();
       break;
      }
      case 216: {
       bitField0_ |= 0x04000000;
       totalPacketps_ = input.readInt32();
       break;
      }
     }
    }
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
    throw e.setUnfinishedMessage(this);
   } catch (java.io.IOException e) {
    throw new com.google.protobuf.InvalidProtocolBufferException(
      e).setUnfinishedMessage(this);
   } finally {
    this.unknownFields = unknownFields.build();
    makeExtensionsImmutable();
   }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
    getDescriptor() {
   return TCPLogOuterClass.internal_static_TCPLog_descriptor;
  }

  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
    internalGetFieldAccessorTable() {
   return TCPLogOuterClass.internal_static_TCPLog_fieldAccessorTable
     .ensureFieldAccessorsInitialized(
       TCPLogOuterClass.TCPLog.class, TCPLogOuterClass.TCPLog.Builder.class);
  }

  private int bitField0_;
  public static final int TOTAL_BYTEPS_FIELD_NUMBER = 1;
  private int totalByteps_;
  /**
   * <code>optional int32 total_byteps = 1;</code>
   */
  public boolean hasTotalByteps() {
   return ((bitField0_ & 0x00000001) == 0x00000001);
  }
  /**
   * <code>optional int32 total_byteps = 1;</code>
   */
  public int getTotalByteps() {
   return totalByteps_;
  }

  public static final int FLOW_START_TIME_FIELD_NUMBER = 2;
  private long flowStartTime_;
  /**
   * <code>optional int64 flow_start_time = 2;</code>
   */
  public boolean hasFlowStartTime() {
   return ((bitField0_ & 0x00000002) == 0x00000002);
  }
  /**
   * <code>optional int64 flow_start_time = 2;</code>
   */
  public long getFlowStartTime() {
   return flowStartTime_;
  }

  public static final int DATE_FIELD_NUMBER = 3;
  private long date_;
  /**
   * <code>optional int64 date = 3;</code>
   */
  public boolean hasDate() {
   return ((bitField0_ & 0x00000004) == 0x00000004);
  }
  /**
   * <code>optional int64 date = 3;</code>
   */
  public long getDate() {
   return date_;
  }

  public static final int SERVER_TOTAL_PACKET_FIELD_NUMBER = 4;
  private long serverTotalPacket_;
  /**
   * <code>optional int64 server_total_packet = 4;</code>
   */
  public boolean hasServerTotalPacket() {
   return ((bitField0_ & 0x00000008) == 0x00000008);
  }
  /**
   * <code>optional int64 server_total_packet = 4;</code>
   */
  public long getServerTotalPacket() {
   return serverTotalPacket_;
  }

  public static final int CLIENT_TOTAL_BYTE_FIELD_NUMBER = 5;
  private long clientTotalByte_;
  /**
   * <code>optional int64 client_total_byte = 5;</code>
   */
  public boolean hasClientTotalByte() {
   return ((bitField0_ & 0x00000010) == 0x00000010);
  }
  /**
   * <code>optional int64 client_total_byte = 5;</code>
   */
  public long getClientTotalByte() {
   return clientTotalByte_;
  }

  public static final int LINK_ID_FIELD_NUMBER = 6;
  private int linkId_;
  /**
   * <code>optional int32 link_id = 6;</code>
   */
  public boolean hasLinkId() {
   return ((bitField0_ & 0x00000020) == 0x00000020);
  }
  /**
   * <code>optional int32 link_id = 6;</code>
   */
  public int getLinkId() {
   return linkId_;
  }

  public static final int TOTAL_BYTE_FIELD_NUMBER = 7;
  private long totalByte_;
  /**
   * <code>optional int64 total_byte = 7;</code>
   */
  public boolean hasTotalByte() {
   return ((bitField0_ & 0x00000040) == 0x00000040);
  }
  /**
   * <code>optional int64 total_byte = 7;</code>
   */
  public long getTotalByte() {
   return totalByte_;
  }

  public static final int FLOW_END_TIME_FIELD_NUMBER = 8;
  private long flowEndTime_;
  /**
   * <code>optional int64 flow_end_time = 8;</code>
   */
  public boolean hasFlowEndTime() {
   return ((bitField0_ & 0x00000080) == 0x00000080);
  }
  /**
   * <code>optional int64 flow_end_time = 8;</code>
   */
  public long getFlowEndTime() {
   return flowEndTime_;
  }

  public static final int CLIENT_PORT_FIELD_NUMBER = 9;
  private int clientPort_;
  /**
   * <code>optional int32 client_port = 9;</code>
   */
  public boolean hasClientPort() {
   return ((bitField0_ & 0x00000100) == 0x00000100);
  }
  /**
   * <code>optional int32 client_port = 9;</code>
   */
  public int getClientPort() {
   return clientPort_;
  }

  public static final int PROTOCOL_FIELD_NUMBER = 10;
  private int protocol_;
  /**
   * <code>optional int32 protocol = 10;</code>
   */
  public boolean hasProtocol() {
   return ((bitField0_ & 0x00000200) == 0x00000200);
  }
  /**
   * <code>optional int32 protocol = 10;</code>
   */
  public int getProtocol() {
   return protocol_;
  }

  public static final int TOTAL_PACKET_FIELD_NUMBER = 11;
  private long totalPacket_;
  /**
   * <code>optional int64 total_packet = 11;</code>
   */
  public boolean hasTotalPacket() {
   return ((bitField0_ & 0x00000400) == 0x00000400);
  }
  /**
   * <code>optional int64 total_packet = 11;</code>
   */
  public long getTotalPacket() {
   return totalPacket_;
  }

  public static final int FLOW_DURATION_FIELD_NUMBER = 12;
  private long flowDuration_;
  /**
   * <code>optional int64 flow_duration = 12;</code>
   */
  public boolean hasFlowDuration() {
   return ((bitField0_ & 0x00000800) == 0x00000800);
  }
  /**
   * <code>optional int64 flow_duration = 12;</code>
   */
  public long getFlowDuration() {
   return flowDuration_;
  }

  public static final int ID_FIELD_NUMBER = 13;
  private volatile java.lang.Object id_;
  /**
   * <code>optional string id = 13;</code>
   */
  public boolean hasId() {
   return ((bitField0_ & 0x00001000) == 0x00001000);
  }
  /**
   * <code>optional string id = 13;</code>
   */
  public java.lang.String getId() {
   java.lang.Object ref = id_;
   if (ref instanceof java.lang.String) {
    return (java.lang.String) ref;
   } else {
    com.google.protobuf.ByteString bs =
      (com.google.protobuf.ByteString) ref;
    java.lang.String s = bs.toStringUtf8();
    if (bs.isValidUtf8()) {
     id_ = s;
    }
    return s;
   }
  }
  /**
   * <code>optional string id = 13;</code>
   */
  public com.google.protobuf.ByteString
    getIdBytes() {
   java.lang.Object ref = id_;
   if (ref instanceof java.lang.String) {
    com.google.protobuf.ByteString b =
      com.google.protobuf.ByteString.copyFromUtf8(
        (java.lang.String) ref);
    id_ = b;
    return b;
   } else {
    return (com.google.protobuf.ByteString) ref;
   }
  }

  public static final int SERVER_IP_ADDR_FIELD_NUMBER = 14;
  private volatile java.lang.Object serverIpAddr_;
  /**
   * <code>optional string server_ip_addr = 14;</code>
   */
  public boolean hasServerIpAddr() {
   return ((bitField0_ & 0x00002000) == 0x00002000);
  }
  /**
   * <code>optional string server_ip_addr = 14;</code>
   */
  public java.lang.String getServerIpAddr() {
   java.lang.Object ref = serverIpAddr_;
   if (ref instanceof java.lang.String) {
    return (java.lang.String) ref;
   } else {
    com.google.protobuf.ByteString bs =
      (com.google.protobuf.ByteString) ref;
    java.lang.String s = bs.toStringUtf8();
    if (bs.isValidUtf8()) {
     serverIpAddr_ = s;
    }
    return s;
   }
  }
  /**
   * <code>optional string server_ip_addr = 14;</code>
   */
  public com.google.protobuf.ByteString
    getServerIpAddrBytes() {
   java.lang.Object ref = serverIpAddr_;
   if (ref instanceof java.lang.String) {
    com.google.protobuf.ByteString b =
      com.google.protobuf.ByteString.copyFromUtf8(
        (java.lang.String) ref);
    serverIpAddr_ = b;
    return b;
   } else {
    return (com.google.protobuf.ByteString) ref;
   }
  }

  public static final int DIRECTION_MASK_FIELD_NUMBER = 15;
  private volatile java.lang.Object directionMask_;
  /**
   * <code>optional string direction_mask = 15;</code>
   */
  public boolean hasDirectionMask() {
   return ((bitField0_ & 0x00004000) == 0x00004000);
  }
  /**
   * <code>optional string direction_mask = 15;</code>
   */
  public java.lang.String getDirectionMask() {
   java.lang.Object ref = directionMask_;
   if (ref instanceof java.lang.String) {
    return (java.lang.String) ref;
   } else {
    com.google.protobuf.ByteString bs =
      (com.google.protobuf.ByteString) ref;
    java.lang.String s = bs.toStringUtf8();
    if (bs.isValidUtf8()) {
     directionMask_ = s;
    }
    return s;
   }
  }
  /**
   * <code>optional string direction_mask = 15;</code>
   */
  public com.google.protobuf.ByteString
    getDirectionMaskBytes() {
   java.lang.Object ref = directionMask_;
   if (ref instanceof java.lang.String) {
    com.google.protobuf.ByteString b =
      com.google.protobuf.ByteString.copyFromUtf8(
        (java.lang.String) ref);
    directionMask_ = b;
    return b;
   } else {
    return (com.google.protobuf.ByteString) ref;
   }
  }

  public static final int APP_FIELD_NUMBER = 16;
  private int app_;
  /**
   * <code>optional int32 app = 16;</code>
   */
  public boolean hasApp() {
   return ((bitField0_ & 0x00008000) == 0x00008000);
  }
  /**
   * <code>optional int32 app = 16;</code>
   */
  public int getApp() {
   return app_;
  }

  public static final int CLIENT_COUNTRY_ID_FIELD_NUMBER = 17;
  private int clientCountryId_;
  /**
   * <code>optional int32 client_country_id = 17;</code>
   */
  public boolean hasClientCountryId() {
   return ((bitField0_ & 0x00010000) == 0x00010000);
  }
  /**
   * <code>optional int32 client_country_id = 17;</code>
   */
  public int getClientCountryId() {
   return clientCountryId_;
  }

  public static final int CLIENT_NETSEGMENT_ID_FIELD_NUMBER = 18;
  private int clientNetsegmentId_;
  /**
   * <code>optional int32 client_netsegment_id = 18;</code>
   */
  public boolean hasClientNetsegmentId() {
   return ((bitField0_ & 0x00020000) == 0x00020000);
  }
  /**
   * <code>optional int32 client_netsegment_id = 18;</code>
   */
  public int getClientNetsegmentId() {
   return clientNetsegmentId_;
  }

  public static final int CLIENT_TOTAL_PACKET_FIELD_NUMBER = 19;
  private long clientTotalPacket_;
  /**
   * <code>optional int64 client_total_packet = 19;</code>
   */
  public boolean hasClientTotalPacket() {
   return ((bitField0_ & 0x00040000) == 0x00040000);
  }
  /**
   * <code>optional int64 client_total_packet = 19;</code>
   */
  public long getClientTotalPacket() {
   return clientTotalPacket_;
  }

  public static final int CLIENT_IP_ADDR_FIELD_NUMBER = 20;
  private volatile java.lang.Object clientIpAddr_;
  /**
   * <code>optional string client_ip_addr = 20;</code>
   */
  public boolean hasClientIpAddr() {
   return ((bitField0_ & 0x00080000) == 0x00080000);
  }
  /**
   * <code>optional string client_ip_addr = 20;</code>
   */
  public java.lang.String getClientIpAddr() {
   java.lang.Object ref = clientIpAddr_;
   if (ref instanceof java.lang.String) {
    return (java.lang.String) ref;
   } else {
    com.google.protobuf.ByteString bs =
      (com.google.protobuf.ByteString) ref;
    java.lang.String s = bs.toStringUtf8();
    if (bs.isValidUtf8()) {
     clientIpAddr_ = s;
    }
    return s;
   }
  }
  /**
   * <code>optional string client_ip_addr = 20;</code>
   */
  public com.google.protobuf.ByteString
    getClientIpAddrBytes() {
   java.lang.Object ref = clientIpAddr_;
   if (ref instanceof java.lang.String) {
    com.google.protobuf.ByteString b =
      com.google.protobuf.ByteString.copyFromUtf8(
        (java.lang.String) ref);
    clientIpAddr_ = b;
    return b;
   } else {
    return (com.google.protobuf.ByteString) ref;
   }
  }

  public static final int TCP_STATUS_FIELD_NUMBER = 21;
  private int tcpStatus_;
  /**
   * <code>optional int32 tcp_status = 21;</code>
   */
  public boolean hasTcpStatus() {
   return ((bitField0_ & 0x00100000) == 0x00100000);
  }
  /**
   * <code>optional int32 tcp_status = 21;</code>
   */
  public int getTcpStatus() {
   return tcpStatus_;
  }

  public static final int SERVER_COUNTRY_ID_FIELD_NUMBER = 22;
  private int serverCountryId_;
  /**
   * <code>optional int32 server_country_id = 22;</code>
   */
  public boolean hasServerCountryId() {
   return ((bitField0_ & 0x00200000) == 0x00200000);
  }
  /**
   * <code>optional int32 server_country_id = 22;</code>
   */
  public int getServerCountryId() {
   return serverCountryId_;
  }

  public static final int SERVER_NETSEGMENT_ID_FIELD_NUMBER = 23;
  private int serverNetsegmentId_;
  /**
   * <code>optional int32 server_netsegment_id = 23;</code>
   */
  public boolean hasServerNetsegmentId() {
   return ((bitField0_ & 0x00400000) == 0x00400000);
  }
  /**
   * <code>optional int32 server_netsegment_id = 23;</code>
   */
  public int getServerNetsegmentId() {
   return serverNetsegmentId_;
  }

  public static final int AVG_PKT_SIZE_FIELD_NUMBER = 24;
  private long avgPktSize_;
  /**
   * <code>optional int64 avg_pkt_size = 24;</code>
   */
  public boolean hasAvgPktSize() {
   return ((bitField0_ & 0x00800000) == 0x00800000);
  }
  /**
   * <code>optional int64 avg_pkt_size = 24;</code>
   */
  public long getAvgPktSize() {
   return avgPktSize_;
  }

  public static final int SERVER_PORT_FIELD_NUMBER = 25;
  private int serverPort_;
  /**
   * <code>optional int32 server_port = 25;</code>
   */
  public boolean hasServerPort() {
   return ((bitField0_ & 0x01000000) == 0x01000000);
  }
  /**
   * <code>optional int32 server_port = 25;</code>
   */
  public int getServerPort() {
   return serverPort_;
  }

  public static final int SERVER_TOTAL_BYTE_FIELD_NUMBER = 26;
  private long serverTotalByte_;
  /**
   * <code>optional int64 server_total_byte = 26;</code>
   */
  public boolean hasServerTotalByte() {
   return ((bitField0_ & 0x02000000) == 0x02000000);
  }
  /**
   * <code>optional int64 server_total_byte = 26;</code>
   */
  public long getServerTotalByte() {
   return serverTotalByte_;
  }

  public static final int TOTAL_PACKETPS_FIELD_NUMBER = 27;
  private int totalPacketps_;
  /**
   * <code>optional int32 total_packetps = 27;</code>
   */
  public boolean hasTotalPacketps() {
   return ((bitField0_ & 0x04000000) == 0x04000000);
  }
  /**
   * <code>optional int32 total_packetps = 27;</code>
   */
  public int getTotalPacketps() {
   return totalPacketps_;
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
   byte isInitialized = memoizedIsInitialized;
   if (isInitialized == 1) return true;
   if (isInitialized == 0) return false;

   memoizedIsInitialized = 1;
   return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
            throws java.io.IOException {
   if (((bitField0_ & 0x00000001) == 0x00000001)) {
    output.writeInt32(1, totalByteps_);
   }
   if (((bitField0_ & 0x00000002) == 0x00000002)) {
    output.writeInt64(2, flowStartTime_);
   }
   if (((bitField0_ & 0x00000004) == 0x00000004)) {
    output.writeInt64(3, date_);
   }
   if (((bitField0_ & 0x00000008) == 0x00000008)) {
    output.writeInt64(4, serverTotalPacket_);
   }
   if (((bitField0_ & 0x00000010) == 0x00000010)) {
    output.writeInt64(5, clientTotalByte_);
   }
   if (((bitField0_ & 0x00000020) == 0x00000020)) {
    output.writeInt32(6, linkId_);
   }
   if (((bitField0_ & 0x00000040) == 0x00000040)) {
    output.writeInt64(7, totalByte_);
   }
   if (((bitField0_ & 0x00000080) == 0x00000080)) {
    output.writeInt64(8, flowEndTime_);
   }
   if (((bitField0_ & 0x00000100) == 0x00000100)) {
    output.writeInt32(9, clientPort_);
   }
   if (((bitField0_ & 0x00000200) == 0x00000200)) {
    output.writeInt32(10, protocol_);
   }
   if (((bitField0_ & 0x00000400) == 0x00000400)) {
    output.writeInt64(11, totalPacket_);
   }
   if (((bitField0_ & 0x00000800) == 0x00000800)) {
    output.writeInt64(12, flowDuration_);
   }
   if (((bitField0_ & 0x00001000) == 0x00001000)) {
    com.google.protobuf.GeneratedMessageV3.writeString(output, 13, id_);
   }
   if (((bitField0_ & 0x00002000) == 0x00002000)) {
    com.google.protobuf.GeneratedMessageV3.writeString(output, 14, serverIpAddr_);
   }
   if (((bitField0_ & 0x00004000) == 0x00004000)) {
    com.google.protobuf.GeneratedMessageV3.writeString(output, 15, directionMask_);
   }
   if (((bitField0_ & 0x00008000) == 0x00008000)) {
    output.writeInt32(16, app_);
   }
   if (((bitField0_ & 0x00010000) == 0x00010000)) {
    output.writeInt32(17, clientCountryId_);
   }
   if (((bitField0_ & 0x00020000) == 0x00020000)) {
    output.writeInt32(18, clientNetsegmentId_);
   }
   if (((bitField0_ & 0x00040000) == 0x00040000)) {
    output.writeInt64(19, clientTotalPacket_);
   }
   if (((bitField0_ & 0x00080000) == 0x00080000)) {
    com.google.protobuf.GeneratedMessageV3.writeString(output, 20, clientIpAddr_);
   }
   if (((bitField0_ & 0x00100000) == 0x00100000)) {
    output.writeInt32(21, tcpStatus_);
   }
   if (((bitField0_ & 0x00200000) == 0x00200000)) {
    output.writeInt32(22, serverCountryId_);
   }
   if (((bitField0_ & 0x00400000) == 0x00400000)) {
    output.writeInt32(23, serverNetsegmentId_);
   }
   if (((bitField0_ & 0x00800000) == 0x00800000)) {
    output.writeInt64(24, avgPktSize_);
   }
   if (((bitField0_ & 0x01000000) == 0x01000000)) {
    output.writeInt32(25, serverPort_);
   }
   if (((bitField0_ & 0x02000000) == 0x02000000)) {
    output.writeInt64(26, serverTotalByte_);
   }
   if (((bitField0_ & 0x04000000) == 0x04000000)) {
    output.writeInt32(27, totalPacketps_);
   }
   unknownFields.writeTo(output);
  }

  public int getSerializedSize() {
   int size = memoizedSize;
   if (size != -1) return size;

   size = 0;
   if (((bitField0_ & 0x00000001) == 0x00000001)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(1, totalByteps_);
   }
   if (((bitField0_ & 0x00000002) == 0x00000002)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(2, flowStartTime_);
   }
   if (((bitField0_ & 0x00000004) == 0x00000004)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(3, date_);
   }
   if (((bitField0_ & 0x00000008) == 0x00000008)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(4, serverTotalPacket_);
   }
   if (((bitField0_ & 0x00000010) == 0x00000010)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(5, clientTotalByte_);
   }
   if (((bitField0_ & 0x00000020) == 0x00000020)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(6, linkId_);
   }
   if (((bitField0_ & 0x00000040) == 0x00000040)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(7, totalByte_);
   }
   if (((bitField0_ & 0x00000080) == 0x00000080)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(8, flowEndTime_);
   }
   if (((bitField0_ & 0x00000100) == 0x00000100)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(9, clientPort_);
   }
   if (((bitField0_ & 0x00000200) == 0x00000200)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(10, protocol_);
   }
   if (((bitField0_ & 0x00000400) == 0x00000400)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(11, totalPacket_);
   }
   if (((bitField0_ & 0x00000800) == 0x00000800)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(12, flowDuration_);
   }
   if (((bitField0_ & 0x00001000) == 0x00001000)) {
    size += com.google.protobuf.GeneratedMessageV3.computeStringSize(13, id_);
   }
   if (((bitField0_ & 0x00002000) == 0x00002000)) {
    size += com.google.protobuf.GeneratedMessageV3.computeStringSize(14, serverIpAddr_);
   }
   if (((bitField0_ & 0x00004000) == 0x00004000)) {
    size += com.google.protobuf.GeneratedMessageV3.computeStringSize(15, directionMask_);
   }
   if (((bitField0_ & 0x00008000) == 0x00008000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(16, app_);
   }
   if (((bitField0_ & 0x00010000) == 0x00010000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(17, clientCountryId_);
   }
   if (((bitField0_ & 0x00020000) == 0x00020000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(18, clientNetsegmentId_);
   }
   if (((bitField0_ & 0x00040000) == 0x00040000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(19, clientTotalPacket_);
   }
   if (((bitField0_ & 0x00080000) == 0x00080000)) {
    size += com.google.protobuf.GeneratedMessageV3.computeStringSize(20, clientIpAddr_);
   }
   if (((bitField0_ & 0x00100000) == 0x00100000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(21, tcpStatus_);
   }
   if (((bitField0_ & 0x00200000) == 0x00200000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(22, serverCountryId_);
   }
   if (((bitField0_ & 0x00400000) == 0x00400000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(23, serverNetsegmentId_);
   }
   if (((bitField0_ & 0x00800000) == 0x00800000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(24, avgPktSize_);
   }
   if (((bitField0_ & 0x01000000) == 0x01000000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(25, serverPort_);
   }
   if (((bitField0_ & 0x02000000) == 0x02000000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt64Size(26, serverTotalByte_);
   }
   if (((bitField0_ & 0x04000000) == 0x04000000)) {
    size += com.google.protobuf.CodedOutputStream
     .computeInt32Size(27, totalPacketps_);
   }
   size += unknownFields.getSerializedSize();
   memoizedSize = size;
   return size;
  }

  private static final long serialVersionUID = 0L;
  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
   if (obj == this) {
    return true;
   }
   if (!(obj instanceof TCPLogOuterClass.TCPLog)) {
    return super.equals(obj);
   }
   TCPLogOuterClass.TCPLog other = (TCPLogOuterClass.TCPLog) obj;

   boolean result = true;
   result = result && (hasTotalByteps() == other.hasTotalByteps());
   if (hasTotalByteps()) {
    result = result && (getTotalByteps()
      == other.getTotalByteps());
   }
   result = result && (hasFlowStartTime() == other.hasFlowStartTime());
   if (hasFlowStartTime()) {
    result = result && (getFlowStartTime()
      == other.getFlowStartTime());
   }
   result = result && (hasDate() == other.hasDate());
   if (hasDate()) {
    result = result && (getDate()
      == other.getDate());
   }
   result = result && (hasServerTotalPacket() == other.hasServerTotalPacket());
   if (hasServerTotalPacket()) {
    result = result && (getServerTotalPacket()
      == other.getServerTotalPacket());
   }
   result = result && (hasClientTotalByte() == other.hasClientTotalByte());
   if (hasClientTotalByte()) {
    result = result && (getClientTotalByte()
      == other.getClientTotalByte());
   }
   result = result && (hasLinkId() == other.hasLinkId());
   if (hasLinkId()) {
    result = result && (getLinkId()
      == other.getLinkId());
   }
   result = result && (hasTotalByte() == other.hasTotalByte());
   if (hasTotalByte()) {
    result = result && (getTotalByte()
      == other.getTotalByte());
   }
   result = result && (hasFlowEndTime() == other.hasFlowEndTime());
   if (hasFlowEndTime()) {
    result = result && (getFlowEndTime()
      == other.getFlowEndTime());
   }
   result = result && (hasClientPort() == other.hasClientPort());
   if (hasClientPort()) {
    result = result && (getClientPort()
      == other.getClientPort());
   }
   result = result && (hasProtocol() == other.hasProtocol());
   if (hasProtocol()) {
    result = result && (getProtocol()
      == other.getProtocol());
   }
   result = result && (hasTotalPacket() == other.hasTotalPacket());
   if (hasTotalPacket()) {
    result = result && (getTotalPacket()
      == other.getTotalPacket());
   }
   result = result && (hasFlowDuration() == other.hasFlowDuration());
   if (hasFlowDuration()) {
    result = result && (getFlowDuration()
      == other.getFlowDuration());
   }
   result = result && (hasId() == other.hasId());
   if (hasId()) {
    result = result && getId()
      .equals(other.getId());
   }
   result = result && (hasServerIpAddr() == other.hasServerIpAddr());
   if (hasServerIpAddr()) {
    result = result && getServerIpAddr()
      .equals(other.getServerIpAddr());
   }
   result = result && (hasDirectionMask() == other.hasDirectionMask());
   if (hasDirectionMask()) {
    result = result && getDirectionMask()
      .equals(other.getDirectionMask());
   }
   result = result && (hasApp() == other.hasApp());
   if (hasApp()) {
    result = result && (getApp()
      == other.getApp());
   }
   result = result && (hasClientCountryId() == other.hasClientCountryId());
   if (hasClientCountryId()) {
    result = result && (getClientCountryId()
      == other.getClientCountryId());
   }
   result = result && (hasClientNetsegmentId() == other.hasClientNetsegmentId());
   if (hasClientNetsegmentId()) {
    result = result && (getClientNetsegmentId()
      == other.getClientNetsegmentId());
   }
   result = result && (hasClientTotalPacket() == other.hasClientTotalPacket());
   if (hasClientTotalPacket()) {
    result = result && (getClientTotalPacket()
      == other.getClientTotalPacket());
   }
   result = result && (hasClientIpAddr() == other.hasClientIpAddr());
   if (hasClientIpAddr()) {
    result = result && getClientIpAddr()
      .equals(other.getClientIpAddr());
   }
   result = result && (hasTcpStatus() == other.hasTcpStatus());
   if (hasTcpStatus()) {
    result = result && (getTcpStatus()
      == other.getTcpStatus());
   }
   result = result && (hasServerCountryId() == other.hasServerCountryId());
   if (hasServerCountryId()) {
    result = result && (getServerCountryId()
      == other.getServerCountryId());
   }
   result = result && (hasServerNetsegmentId() == other.hasServerNetsegmentId());
   if (hasServerNetsegmentId()) {
    result = result && (getServerNetsegmentId()
      == other.getServerNetsegmentId());
   }
   result = result && (hasAvgPktSize() == other.hasAvgPktSize());
   if (hasAvgPktSize()) {
    result = result && (getAvgPktSize()
      == other.getAvgPktSize());
   }
   result = result && (hasServerPort() == other.hasServerPort());
   if (hasServerPort()) {
    result = result && (getServerPort()
      == other.getServerPort());
   }
   result = result && (hasServerTotalByte() == other.hasServerTotalByte());
   if (hasServerTotalByte()) {
    result = result && (getServerTotalByte()
      == other.getServerTotalByte());
   }
   result = result && (hasTotalPacketps() == other.hasTotalPacketps());
   if (hasTotalPacketps()) {
    result = result && (getTotalPacketps()
      == other.getTotalPacketps());
   }
   result = result && unknownFields.equals(other.unknownFields);
   return result;
  }

  @java.lang.Override
  public int hashCode() {
   if (memoizedHashCode != 0) {
    return memoizedHashCode;
   }
   int hash = 41;
   hash = (19 * hash) + getDescriptor().hashCode();
   if (hasTotalByteps()) {
    hash = (37 * hash) + TOTAL_BYTEPS_FIELD_NUMBER;
    hash = (53 * hash) + getTotalByteps();
   }
   if (hasFlowStartTime()) {
    hash = (37 * hash) + FLOW_START_TIME_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getFlowStartTime());
   }
   if (hasDate()) {
    hash = (37 * hash) + DATE_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getDate());
   }
   if (hasServerTotalPacket()) {
    hash = (37 * hash) + SERVER_TOTAL_PACKET_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getServerTotalPacket());
   }
   if (hasClientTotalByte()) {
    hash = (37 * hash) + CLIENT_TOTAL_BYTE_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getClientTotalByte());
   }
   if (hasLinkId()) {
    hash = (37 * hash) + LINK_ID_FIELD_NUMBER;
    hash = (53 * hash) + getLinkId();
   }
   if (hasTotalByte()) {
    hash = (37 * hash) + TOTAL_BYTE_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getTotalByte());
   }
   if (hasFlowEndTime()) {
    hash = (37 * hash) + FLOW_END_TIME_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getFlowEndTime());
   }
   if (hasClientPort()) {
    hash = (37 * hash) + CLIENT_PORT_FIELD_NUMBER;
    hash = (53 * hash) + getClientPort();
   }
   if (hasProtocol()) {
    hash = (37 * hash) + PROTOCOL_FIELD_NUMBER;
    hash = (53 * hash) + getProtocol();
   }
   if (hasTotalPacket()) {
    hash = (37 * hash) + TOTAL_PACKET_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getTotalPacket());
   }
   if (hasFlowDuration()) {
    hash = (37 * hash) + FLOW_DURATION_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getFlowDuration());
   }
   if (hasId()) {
    hash = (37 * hash) + ID_FIELD_NUMBER;
    hash = (53 * hash) + getId().hashCode();
   }
   if (hasServerIpAddr()) {
    hash = (37 * hash) + SERVER_IP_ADDR_FIELD_NUMBER;
    hash = (53 * hash) + getServerIpAddr().hashCode();
   }
   if (hasDirectionMask()) {
    hash = (37 * hash) + DIRECTION_MASK_FIELD_NUMBER;
    hash = (53 * hash) + getDirectionMask().hashCode();
   }
   if (hasApp()) {
    hash = (37 * hash) + APP_FIELD_NUMBER;
    hash = (53 * hash) + getApp();
   }
   if (hasClientCountryId()) {
    hash = (37 * hash) + CLIENT_COUNTRY_ID_FIELD_NUMBER;
    hash = (53 * hash) + getClientCountryId();
   }
   if (hasClientNetsegmentId()) {
    hash = (37 * hash) + CLIENT_NETSEGMENT_ID_FIELD_NUMBER;
    hash = (53 * hash) + getClientNetsegmentId();
   }
   if (hasClientTotalPacket()) {
    hash = (37 * hash) + CLIENT_TOTAL_PACKET_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getClientTotalPacket());
   }
   if (hasClientIpAddr()) {
    hash = (37 * hash) + CLIENT_IP_ADDR_FIELD_NUMBER;
    hash = (53 * hash) + getClientIpAddr().hashCode();
   }
   if (hasTcpStatus()) {
    hash = (37 * hash) + TCP_STATUS_FIELD_NUMBER;
    hash = (53 * hash) + getTcpStatus();
   }
   if (hasServerCountryId()) {
    hash = (37 * hash) + SERVER_COUNTRY_ID_FIELD_NUMBER;
    hash = (53 * hash) + getServerCountryId();
   }
   if (hasServerNetsegmentId()) {
    hash = (37 * hash) + SERVER_NETSEGMENT_ID_FIELD_NUMBER;
    hash = (53 * hash) + getServerNetsegmentId();
   }
   if (hasAvgPktSize()) {
    hash = (37 * hash) + AVG_PKT_SIZE_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getAvgPktSize());
   }
   if (hasServerPort()) {
    hash = (37 * hash) + SERVER_PORT_FIELD_NUMBER;
    hash = (53 * hash) + getServerPort();
   }
   if (hasServerTotalByte()) {
    hash = (37 * hash) + SERVER_TOTAL_BYTE_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
      getServerTotalByte());
   }
   if (hasTotalPacketps()) {
    hash = (37 * hash) + TOTAL_PACKETPS_FIELD_NUMBER;
    hash = (53 * hash) + getTotalPacketps();
   }
   hash = (29 * hash) + unknownFields.hashCode();
   memoizedHashCode = hash;
   return hash;
  }

  public static TCPLogOuterClass.TCPLog parseFrom(
    java.nio.ByteBuffer data)
    throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    java.nio.ByteBuffer data,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    com.google.protobuf.ByteString data)
    throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    com.google.protobuf.ByteString data,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(byte[] data)
    throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    byte[] data,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(java.io.InputStream input)
    throws java.io.IOException {
   return com.google.protobuf.GeneratedMessageV3
     .parseWithIOException(PARSER, input);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    java.io.InputStream input,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws java.io.IOException {
   return com.google.protobuf.GeneratedMessageV3
     .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static TCPLogOuterClass.TCPLog parseDelimitedFrom(java.io.InputStream input)
    throws java.io.IOException {
   return com.google.protobuf.GeneratedMessageV3
     .parseDelimitedWithIOException(PARSER, input);
  }
  public static TCPLogOuterClass.TCPLog parseDelimitedFrom(
    java.io.InputStream input,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws java.io.IOException {
   return com.google.protobuf.GeneratedMessageV3
     .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    com.google.protobuf.CodedInputStream input)
    throws java.io.IOException {
   return com.google.protobuf.GeneratedMessageV3
     .parseWithIOException(PARSER, input);
  }
  public static TCPLogOuterClass.TCPLog parseFrom(
    com.google.protobuf.CodedInputStream input,
    com.google.protobuf.ExtensionRegistryLite extensionRegistry)
    throws java.io.IOException {
   return com.google.protobuf.GeneratedMessageV3
     .parseWithIOException(PARSER, input, extensionRegistry);
  }

  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
   return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(TCPLogOuterClass.TCPLog prototype) {
   return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  public Builder toBuilder() {
   return this == DEFAULT_INSTANCE
     ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
    com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
   Builder builder = new Builder(parent);
   return builder;
  }
  /**
   * Protobuf type {@code TCPLog}
   */
  public static final class Builder extends
    com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
    // @@protoc_insertion_point(builder_implements:TCPLog)
    TCPLogOuterClass.TCPLogOrBuilder {
   public static final com.google.protobuf.Descriptors.Descriptor
     getDescriptor() {
    return TCPLogOuterClass.internal_static_TCPLog_descriptor;
   }

   protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
     internalGetFieldAccessorTable() {
    return TCPLogOuterClass.internal_static_TCPLog_fieldAccessorTable
      .ensureFieldAccessorsInitialized(
        TCPLogOuterClass.TCPLog.class, TCPLogOuterClass.TCPLog.Builder.class);
   }

   // Construct using TCPLogOuterClass.TCPLog.newBuilder()
   private Builder() {
    maybeForceBuilderInitialization();
   }

   private Builder(
     com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    super(parent);
    maybeForceBuilderInitialization();
   }
   private void maybeForceBuilderInitialization() {
    if (com.google.protobuf.GeneratedMessageV3
        .alwaysUseFieldBuilders) {
    }
   }
   public Builder clear() {
    super.clear();
    totalByteps_ = 0;
    bitField0_ = (bitField0_ & ~0x00000001);
    flowStartTime_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000002);
    date_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000004);
    serverTotalPacket_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000008);
    clientTotalByte_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000010);
    linkId_ = 0;
    bitField0_ = (bitField0_ & ~0x00000020);
    totalByte_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000040);
    flowEndTime_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000080);
    clientPort_ = 0;
    bitField0_ = (bitField0_ & ~0x00000100);
    protocol_ = 0;
    bitField0_ = (bitField0_ & ~0x00000200);
    totalPacket_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000400);
    flowDuration_ = 0L;
    bitField0_ = (bitField0_ & ~0x00000800);
    id_ = "";
    bitField0_ = (bitField0_ & ~0x00001000);
    serverIpAddr_ = "";
    bitField0_ = (bitField0_ & ~0x00002000);
    directionMask_ = "";
    bitField0_ = (bitField0_ & ~0x00004000);
    app_ = 0;
    bitField0_ = (bitField0_ & ~0x00008000);
    clientCountryId_ = 0;
    bitField0_ = (bitField0_ & ~0x00010000);
    clientNetsegmentId_ = 0;
    bitField0_ = (bitField0_ & ~0x00020000);
    clientTotalPacket_ = 0L;
    bitField0_ = (bitField0_ & ~0x00040000);
    clientIpAddr_ = "";
    bitField0_ = (bitField0_ & ~0x00080000);
    tcpStatus_ = 0;
    bitField0_ = (bitField0_ & ~0x00100000);
    serverCountryId_ = 0;
    bitField0_ = (bitField0_ & ~0x00200000);
    serverNetsegmentId_ = 0;
    bitField0_ = (bitField0_ & ~0x00400000);
    avgPktSize_ = 0L;
    bitField0_ = (bitField0_ & ~0x00800000);
    serverPort_ = 0;
    bitField0_ = (bitField0_ & ~0x01000000);
    serverTotalByte_ = 0L;
    bitField0_ = (bitField0_ & ~0x02000000);
    totalPacketps_ = 0;
    bitField0_ = (bitField0_ & ~0x04000000);
    return this;
   }

   public com.google.protobuf.Descriptors.Descriptor
     getDescriptorForType() {
    return TCPLogOuterClass.internal_static_TCPLog_descriptor;
   }

   public TCPLogOuterClass.TCPLog getDefaultInstanceForType() {
    return TCPLogOuterClass.TCPLog.getDefaultInstance();
   }

   public TCPLogOuterClass.TCPLog build() {
    TCPLogOuterClass.TCPLog result = buildPartial();
    if (!result.isInitialized()) {
     throw newUninitializedMessageException(result);
    }
    return result;
   }

   public TCPLogOuterClass.TCPLog buildPartial() {
    TCPLogOuterClass.TCPLog result = new TCPLogOuterClass.TCPLog(this);
    int from_bitField0_ = bitField0_;
    int to_bitField0_ = 0;
    if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
     to_bitField0_ |= 0x00000001;
    }
    result.totalByteps_ = totalByteps_;
    if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
     to_bitField0_ |= 0x00000002;
    }
    result.flowStartTime_ = flowStartTime_;
    if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
     to_bitField0_ |= 0x00000004;
    }
    result.date_ = date_;
    if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
     to_bitField0_ |= 0x00000008;
    }
    result.serverTotalPacket_ = serverTotalPacket_;
    if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
     to_bitField0_ |= 0x00000010;
    }
    result.clientTotalByte_ = clientTotalByte_;
    if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
     to_bitField0_ |= 0x00000020;
    }
    result.linkId_ = linkId_;
    if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
     to_bitField0_ |= 0x00000040;
    }
    result.totalByte_ = totalByte_;
    if (((from_bitField0_ & 0x00000080) == 0x00000080)) {
     to_bitField0_ |= 0x00000080;
    }
    result.flowEndTime_ = flowEndTime_;
    if (((from_bitField0_ & 0x00000100) == 0x00000100)) {
     to_bitField0_ |= 0x00000100;
    }
    result.clientPort_ = clientPort_;
    if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
     to_bitField0_ |= 0x00000200;
    }
    result.protocol_ = protocol_;
    if (((from_bitField0_ & 0x00000400) == 0x00000400)) {
     to_bitField0_ |= 0x00000400;
    }
    result.totalPacket_ = totalPacket_;
    if (((from_bitField0_ & 0x00000800) == 0x00000800)) {
     to_bitField0_ |= 0x00000800;
    }
    result.flowDuration_ = flowDuration_;
    if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
     to_bitField0_ |= 0x00001000;
    }
    result.id_ = id_;
    if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
     to_bitField0_ |= 0x00002000;
    }
    result.serverIpAddr_ = serverIpAddr_;
    if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
     to_bitField0_ |= 0x00004000;
    }
    result.directionMask_ = directionMask_;
    if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
     to_bitField0_ |= 0x00008000;
    }
    result.app_ = app_;
    if (((from_bitField0_ & 0x00010000) == 0x00010000)) {
     to_bitField0_ |= 0x00010000;
    }
    result.clientCountryId_ = clientCountryId_;
    if (((from_bitField0_ & 0x00020000) == 0x00020000)) {
     to_bitField0_ |= 0x00020000;
    }
    result.clientNetsegmentId_ = clientNetsegmentId_;
    if (((from_bitField0_ & 0x00040000) == 0x00040000)) {
     to_bitField0_ |= 0x00040000;
    }
    result.clientTotalPacket_ = clientTotalPacket_;
    if (((from_bitField0_ & 0x00080000) == 0x00080000)) {
     to_bitField0_ |= 0x00080000;
    }
    result.clientIpAddr_ = clientIpAddr_;
    if (((from_bitField0_ & 0x00100000) == 0x00100000)) {
     to_bitField0_ |= 0x00100000;
    }
    result.tcpStatus_ = tcpStatus_;
    if (((from_bitField0_ & 0x00200000) == 0x00200000)) {
     to_bitField0_ |= 0x00200000;
    }
    result.serverCountryId_ = serverCountryId_;
    if (((from_bitField0_ & 0x00400000) == 0x00400000)) {
     to_bitField0_ |= 0x00400000;
    }
    result.serverNetsegmentId_ = serverNetsegmentId_;
    if (((from_bitField0_ & 0x00800000) == 0x00800000)) {
     to_bitField0_ |= 0x00800000;
    }
    result.avgPktSize_ = avgPktSize_;
    if (((from_bitField0_ & 0x01000000) == 0x01000000)) {
     to_bitField0_ |= 0x01000000;
    }
    result.serverPort_ = serverPort_;
    if (((from_bitField0_ & 0x02000000) == 0x02000000)) {
     to_bitField0_ |= 0x02000000;
    }
    result.serverTotalByte_ = serverTotalByte_;
    if (((from_bitField0_ & 0x04000000) == 0x04000000)) {
     to_bitField0_ |= 0x04000000;
    }
    result.totalPacketps_ = totalPacketps_;
    result.bitField0_ = to_bitField0_;
    onBuilt();
    return result;
   }

   public Builder clone() {
    return (Builder) super.clone();
   }
   public Builder setField(
     com.google.protobuf.Descriptors.FieldDescriptor field,
     Object value) {
    return (Builder) super.setField(field, value);
   }
   public Builder clearField(
     com.google.protobuf.Descriptors.FieldDescriptor field) {
    return (Builder) super.clearField(field);
   }
   public Builder clearOneof(
     com.google.protobuf.Descriptors.OneofDescriptor oneof) {
    return (Builder) super.clearOneof(oneof);
   }
   public Builder setRepeatedField(
     com.google.protobuf.Descriptors.FieldDescriptor field,
     int index, Object value) {
    return (Builder) super.setRepeatedField(field, index, value);
   }
   public Builder addRepeatedField(
     com.google.protobuf.Descriptors.FieldDescriptor field,
     Object value) {
    return (Builder) super.addRepeatedField(field, value);
   }
   public Builder mergeFrom(com.google.protobuf.Message other) {
    if (other instanceof TCPLogOuterClass.TCPLog) {
     return mergeFrom((TCPLogOuterClass.TCPLog)other);
    } else {
     super.mergeFrom(other);
     return this;
    }
   }

   public Builder mergeFrom(TCPLogOuterClass.TCPLog other) {
    if (other == TCPLogOuterClass.TCPLog.getDefaultInstance()) return this;
    if (other.hasTotalByteps()) {
     setTotalByteps(other.getTotalByteps());
    }
    if (other.hasFlowStartTime()) {
     setFlowStartTime(other.getFlowStartTime());
    }
    if (other.hasDate()) {
     setDate(other.getDate());
    }
    if (other.hasServerTotalPacket()) {
     setServerTotalPacket(other.getServerTotalPacket());
    }
    if (other.hasClientTotalByte()) {
     setClientTotalByte(other.getClientTotalByte());
    }
    if (other.hasLinkId()) {
     setLinkId(other.getLinkId());
    }
    if (other.hasTotalByte()) {
     setTotalByte(other.getTotalByte());
    }
    if (other.hasFlowEndTime()) {
     setFlowEndTime(other.getFlowEndTime());
    }
    if (other.hasClientPort()) {
     setClientPort(other.getClientPort());
    }
    if (other.hasProtocol()) {
     setProtocol(other.getProtocol());
    }
    if (other.hasTotalPacket()) {
     setTotalPacket(other.getTotalPacket());
    }
    if (other.hasFlowDuration()) {
     setFlowDuration(other.getFlowDuration());
    }
    if (other.hasId()) {
     bitField0_ |= 0x00001000;
     id_ = other.id_;
     onChanged();
    }
    if (other.hasServerIpAddr()) {
     bitField0_ |= 0x00002000;
     serverIpAddr_ = other.serverIpAddr_;
     onChanged();
    }
    if (other.hasDirectionMask()) {
     bitField0_ |= 0x00004000;
     directionMask_ = other.directionMask_;
     onChanged();
    }
    if (other.hasApp()) {
     setApp(other.getApp());
    }
    if (other.hasClientCountryId()) {
     setClientCountryId(other.getClientCountryId());
    }
    if (other.hasClientNetsegmentId()) {
     setClientNetsegmentId(other.getClientNetsegmentId());
    }
    if (other.hasClientTotalPacket()) {
     setClientTotalPacket(other.getClientTotalPacket());
    }
    if (other.hasClientIpAddr()) {
     bitField0_ |= 0x00080000;
     clientIpAddr_ = other.clientIpAddr_;
     onChanged();
    }
    if (other.hasTcpStatus()) {
     setTcpStatus(other.getTcpStatus());
    }
    if (other.hasServerCountryId()) {
     setServerCountryId(other.getServerCountryId());
    }
    if (other.hasServerNetsegmentId()) {
     setServerNetsegmentId(other.getServerNetsegmentId());
    }
    if (other.hasAvgPktSize()) {
     setAvgPktSize(other.getAvgPktSize());
    }
    if (other.hasServerPort()) {
     setServerPort(other.getServerPort());
    }
    if (other.hasServerTotalByte()) {
     setServerTotalByte(other.getServerTotalByte());
    }
    if (other.hasTotalPacketps()) {
     setTotalPacketps(other.getTotalPacketps());
    }
    this.mergeUnknownFields(other.unknownFields);
    onChanged();
    return this;
   }

   public final boolean isInitialized() {
    return true;
   }

   public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
    TCPLogOuterClass.TCPLog parsedMessage = null;
    try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage = (TCPLogOuterClass.TCPLog) e.getUnfinishedMessage();
     throw e.unwrapIOException();
    } finally {
     if (parsedMessage != null) {
      mergeFrom(parsedMessage);
     }
    }
    return this;
   }
   private int bitField0_;

   private int totalByteps_ ;
   /**
    * <code>optional int32 total_byteps = 1;</code>
    */
   public boolean hasTotalByteps() {
    return ((bitField0_ & 0x00000001) == 0x00000001);
   }
   /**
    * <code>optional int32 total_byteps = 1;</code>
    */
   public int getTotalByteps() {
    return totalByteps_;
   }
   /**
    * <code>optional int32 total_byteps = 1;</code>
    */
   public Builder setTotalByteps(int value) {
    bitField0_ |= 0x00000001;
    totalByteps_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 total_byteps = 1;</code>
    */
   public Builder clearTotalByteps() {
    bitField0_ = (bitField0_ & ~0x00000001);
    totalByteps_ = 0;
    onChanged();
    return this;
   }

   private long flowStartTime_ ;
   /**
    * <code>optional int64 flow_start_time = 2;</code>
    */
   public boolean hasFlowStartTime() {
    return ((bitField0_ & 0x00000002) == 0x00000002);
   }
   /**
    * <code>optional int64 flow_start_time = 2;</code>
    */
   public long getFlowStartTime() {
    return flowStartTime_;
   }
   /**
    * <code>optional int64 flow_start_time = 2;</code>
    */
   public Builder setFlowStartTime(long value) {
    bitField0_ |= 0x00000002;
    flowStartTime_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 flow_start_time = 2;</code>
    */
   public Builder clearFlowStartTime() {
    bitField0_ = (bitField0_ & ~0x00000002);
    flowStartTime_ = 0L;
    onChanged();
    return this;
   }

   private long date_ ;
   /**
    * <code>optional int64 date = 3;</code>
    */
   public boolean hasDate() {
    return ((bitField0_ & 0x00000004) == 0x00000004);
   }
   /**
    * <code>optional int64 date = 3;</code>
    */
   public long getDate() {
    return date_;
   }
   /**
    * <code>optional int64 date = 3;</code>
    */
   public Builder setDate(long value) {
    bitField0_ |= 0x00000004;
    date_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 date = 3;</code>
    */
   public Builder clearDate() {
    bitField0_ = (bitField0_ & ~0x00000004);
    date_ = 0L;
    onChanged();
    return this;
   }

   private long serverTotalPacket_ ;
   /**
    * <code>optional int64 server_total_packet = 4;</code>
    */
   public boolean hasServerTotalPacket() {
    return ((bitField0_ & 0x00000008) == 0x00000008);
   }
   /**
    * <code>optional int64 server_total_packet = 4;</code>
    */
   public long getServerTotalPacket() {
    return serverTotalPacket_;
   }
   /**
    * <code>optional int64 server_total_packet = 4;</code>
    */
   public Builder setServerTotalPacket(long value) {
    bitField0_ |= 0x00000008;
    serverTotalPacket_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 server_total_packet = 4;</code>
    */
   public Builder clearServerTotalPacket() {
    bitField0_ = (bitField0_ & ~0x00000008);
    serverTotalPacket_ = 0L;
    onChanged();
    return this;
   }

   private long clientTotalByte_ ;
   /**
    * <code>optional int64 client_total_byte = 5;</code>
    */
   public boolean hasClientTotalByte() {
    return ((bitField0_ & 0x00000010) == 0x00000010);
   }
   /**
    * <code>optional int64 client_total_byte = 5;</code>
    */
   public long getClientTotalByte() {
    return clientTotalByte_;
   }
   /**
    * <code>optional int64 client_total_byte = 5;</code>
    */
   public Builder setClientTotalByte(long value) {
    bitField0_ |= 0x00000010;
    clientTotalByte_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 client_total_byte = 5;</code>
    */
   public Builder clearClientTotalByte() {
    bitField0_ = (bitField0_ & ~0x00000010);
    clientTotalByte_ = 0L;
    onChanged();
    return this;
   }

   private int linkId_ ;
   /**
    * <code>optional int32 link_id = 6;</code>
    */
   public boolean hasLinkId() {
    return ((bitField0_ & 0x00000020) == 0x00000020);
   }
   /**
    * <code>optional int32 link_id = 6;</code>
    */
   public int getLinkId() {
    return linkId_;
   }
   /**
    * <code>optional int32 link_id = 6;</code>
    */
   public Builder setLinkId(int value) {
    bitField0_ |= 0x00000020;
    linkId_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 link_id = 6;</code>
    */
   public Builder clearLinkId() {
    bitField0_ = (bitField0_ & ~0x00000020);
    linkId_ = 0;
    onChanged();
    return this;
   }

   private long totalByte_ ;
   /**
    * <code>optional int64 total_byte = 7;</code>
    */
   public boolean hasTotalByte() {
    return ((bitField0_ & 0x00000040) == 0x00000040);
   }
   /**
    * <code>optional int64 total_byte = 7;</code>
    */
   public long getTotalByte() {
    return totalByte_;
   }
   /**
    * <code>optional int64 total_byte = 7;</code>
    */
   public Builder setTotalByte(long value) {
    bitField0_ |= 0x00000040;
    totalByte_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 total_byte = 7;</code>
    */
   public Builder clearTotalByte() {
    bitField0_ = (bitField0_ & ~0x00000040);
    totalByte_ = 0L;
    onChanged();
    return this;
   }

   private long flowEndTime_ ;
   /**
    * <code>optional int64 flow_end_time = 8;</code>
    */
   public boolean hasFlowEndTime() {
    return ((bitField0_ & 0x00000080) == 0x00000080);
   }
   /**
    * <code>optional int64 flow_end_time = 8;</code>
    */
   public long getFlowEndTime() {
    return flowEndTime_;
   }
   /**
    * <code>optional int64 flow_end_time = 8;</code>
    */
   public Builder setFlowEndTime(long value) {
    bitField0_ |= 0x00000080;
    flowEndTime_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 flow_end_time = 8;</code>
    */
   public Builder clearFlowEndTime() {
    bitField0_ = (bitField0_ & ~0x00000080);
    flowEndTime_ = 0L;
    onChanged();
    return this;
   }

   private int clientPort_ ;
   /**
    * <code>optional int32 client_port = 9;</code>
    */
   public boolean hasClientPort() {
    return ((bitField0_ & 0x00000100) == 0x00000100);
   }
   /**
    * <code>optional int32 client_port = 9;</code>
    */
   public int getClientPort() {
    return clientPort_;
   }
   /**
    * <code>optional int32 client_port = 9;</code>
    */
   public Builder setClientPort(int value) {
    bitField0_ |= 0x00000100;
    clientPort_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 client_port = 9;</code>
    */
   public Builder clearClientPort() {
    bitField0_ = (bitField0_ & ~0x00000100);
    clientPort_ = 0;
    onChanged();
    return this;
   }

   private int protocol_ ;
   /**
    * <code>optional int32 protocol = 10;</code>
    */
   public boolean hasProtocol() {
    return ((bitField0_ & 0x00000200) == 0x00000200);
   }
   /**
    * <code>optional int32 protocol = 10;</code>
    */
   public int getProtocol() {
    return protocol_;
   }
   /**
    * <code>optional int32 protocol = 10;</code>
    */
   public Builder setProtocol(int value) {
    bitField0_ |= 0x00000200;
    protocol_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 protocol = 10;</code>
    */
   public Builder clearProtocol() {
    bitField0_ = (bitField0_ & ~0x00000200);
    protocol_ = 0;
    onChanged();
    return this;
   }

   private long totalPacket_ ;
   /**
    * <code>optional int64 total_packet = 11;</code>
    */
   public boolean hasTotalPacket() {
    return ((bitField0_ & 0x00000400) == 0x00000400);
   }
   /**
    * <code>optional int64 total_packet = 11;</code>
    */
   public long getTotalPacket() {
    return totalPacket_;
   }
   /**
    * <code>optional int64 total_packet = 11;</code>
    */
   public Builder setTotalPacket(long value) {
    bitField0_ |= 0x00000400;
    totalPacket_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 total_packet = 11;</code>
    */
   public Builder clearTotalPacket() {
    bitField0_ = (bitField0_ & ~0x00000400);
    totalPacket_ = 0L;
    onChanged();
    return this;
   }

   private long flowDuration_ ;
   /**
    * <code>optional int64 flow_duration = 12;</code>
    */
   public boolean hasFlowDuration() {
    return ((bitField0_ & 0x00000800) == 0x00000800);
   }
   /**
    * <code>optional int64 flow_duration = 12;</code>
    */
   public long getFlowDuration() {
    return flowDuration_;
   }
   /**
    * <code>optional int64 flow_duration = 12;</code>
    */
   public Builder setFlowDuration(long value) {
    bitField0_ |= 0x00000800;
    flowDuration_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 flow_duration = 12;</code>
    */
   public Builder clearFlowDuration() {
    bitField0_ = (bitField0_ & ~0x00000800);
    flowDuration_ = 0L;
    onChanged();
    return this;
   }

   private java.lang.Object id_ = "";
   /**
    * <code>optional string id = 13;</code>
    */
   public boolean hasId() {
    return ((bitField0_ & 0x00001000) == 0x00001000);
   }
   /**
    * <code>optional string id = 13;</code>
    */
   public java.lang.String getId() {
    java.lang.Object ref = id_;
    if (!(ref instanceof java.lang.String)) {
     com.google.protobuf.ByteString bs =
       (com.google.protobuf.ByteString) ref;
     java.lang.String s = bs.toStringUtf8();
     if (bs.isValidUtf8()) {
      id_ = s;
     }
     return s;
    } else {
     return (java.lang.String) ref;
    }
   }
   /**
    * <code>optional string id = 13;</code>
    */
   public com.google.protobuf.ByteString
     getIdBytes() {
    java.lang.Object ref = id_;
    if (ref instanceof String) {
     com.google.protobuf.ByteString b =
       com.google.protobuf.ByteString.copyFromUtf8(
         (java.lang.String) ref);
     id_ = b;
     return b;
    } else {
     return (com.google.protobuf.ByteString) ref;
    }
   }
   /**
    * <code>optional string id = 13;</code>
    */
   public Builder setId(
     java.lang.String value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00001000;
    id_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional string id = 13;</code>
    */
   public Builder clearId() {
    bitField0_ = (bitField0_ & ~0x00001000);
    id_ = getDefaultInstance().getId();
    onChanged();
    return this;
   }
   /**
    * <code>optional string id = 13;</code>
    */
   public Builder setIdBytes(
     com.google.protobuf.ByteString value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00001000;
    id_ = value;
    onChanged();
    return this;
   }

   private java.lang.Object serverIpAddr_ = "";
   /**
    * <code>optional string server_ip_addr = 14;</code>
    */
   public boolean hasServerIpAddr() {
    return ((bitField0_ & 0x00002000) == 0x00002000);
   }
   /**
    * <code>optional string server_ip_addr = 14;</code>
    */
   public java.lang.String getServerIpAddr() {
    java.lang.Object ref = serverIpAddr_;
    if (!(ref instanceof java.lang.String)) {
     com.google.protobuf.ByteString bs =
       (com.google.protobuf.ByteString) ref;
     java.lang.String s = bs.toStringUtf8();
     if (bs.isValidUtf8()) {
      serverIpAddr_ = s;
     }
     return s;
    } else {
     return (java.lang.String) ref;
    }
   }
   /**
    * <code>optional string server_ip_addr = 14;</code>
    */
   public com.google.protobuf.ByteString
     getServerIpAddrBytes() {
    java.lang.Object ref = serverIpAddr_;
    if (ref instanceof String) {
     com.google.protobuf.ByteString b =
       com.google.protobuf.ByteString.copyFromUtf8(
         (java.lang.String) ref);
     serverIpAddr_ = b;
     return b;
    } else {
     return (com.google.protobuf.ByteString) ref;
    }
   }
   /**
    * <code>optional string server_ip_addr = 14;</code>
    */
   public Builder setServerIpAddr(
     java.lang.String value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00002000;
    serverIpAddr_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional string server_ip_addr = 14;</code>
    */
   public Builder clearServerIpAddr() {
    bitField0_ = (bitField0_ & ~0x00002000);
    serverIpAddr_ = getDefaultInstance().getServerIpAddr();
    onChanged();
    return this;
   }
   /**
    * <code>optional string server_ip_addr = 14;</code>
    */
   public Builder setServerIpAddrBytes(
     com.google.protobuf.ByteString value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00002000;
    serverIpAddr_ = value;
    onChanged();
    return this;
   }

   private java.lang.Object directionMask_ = "";
   /**
    * <code>optional string direction_mask = 15;</code>
    */
   public boolean hasDirectionMask() {
    return ((bitField0_ & 0x00004000) == 0x00004000);
   }
   /**
    * <code>optional string direction_mask = 15;</code>
    */
   public java.lang.String getDirectionMask() {
    java.lang.Object ref = directionMask_;
    if (!(ref instanceof java.lang.String)) {
     com.google.protobuf.ByteString bs =
       (com.google.protobuf.ByteString) ref;
     java.lang.String s = bs.toStringUtf8();
     if (bs.isValidUtf8()) {
      directionMask_ = s;
     }
     return s;
    } else {
     return (java.lang.String) ref;
    }
   }
   /**
    * <code>optional string direction_mask = 15;</code>
    */
   public com.google.protobuf.ByteString
     getDirectionMaskBytes() {
    java.lang.Object ref = directionMask_;
    if (ref instanceof String) {
     com.google.protobuf.ByteString b =
       com.google.protobuf.ByteString.copyFromUtf8(
         (java.lang.String) ref);
     directionMask_ = b;
     return b;
    } else {
     return (com.google.protobuf.ByteString) ref;
    }
   }
   /**
    * <code>optional string direction_mask = 15;</code>
    */
   public Builder setDirectionMask(
     java.lang.String value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00004000;
    directionMask_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional string direction_mask = 15;</code>
    */
   public Builder clearDirectionMask() {
    bitField0_ = (bitField0_ & ~0x00004000);
    directionMask_ = getDefaultInstance().getDirectionMask();
    onChanged();
    return this;
   }
   /**
    * <code>optional string direction_mask = 15;</code>
    */
   public Builder setDirectionMaskBytes(
     com.google.protobuf.ByteString value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00004000;
    directionMask_ = value;
    onChanged();
    return this;
   }

   private int app_ ;
   /**
    * <code>optional int32 app = 16;</code>
    */
   public boolean hasApp() {
    return ((bitField0_ & 0x00008000) == 0x00008000);
   }
   /**
    * <code>optional int32 app = 16;</code>
    */
   public int getApp() {
    return app_;
   }
   /**
    * <code>optional int32 app = 16;</code>
    */
   public Builder setApp(int value) {
    bitField0_ |= 0x00008000;
    app_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 app = 16;</code>
    */
   public Builder clearApp() {
    bitField0_ = (bitField0_ & ~0x00008000);
    app_ = 0;
    onChanged();
    return this;
   }

   private int clientCountryId_ ;
   /**
    * <code>optional int32 client_country_id = 17;</code>
    */
   public boolean hasClientCountryId() {
    return ((bitField0_ & 0x00010000) == 0x00010000);
   }
   /**
    * <code>optional int32 client_country_id = 17;</code>
    */
   public int getClientCountryId() {
    return clientCountryId_;
   }
   /**
    * <code>optional int32 client_country_id = 17;</code>
    */
   public Builder setClientCountryId(int value) {
    bitField0_ |= 0x00010000;
    clientCountryId_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 client_country_id = 17;</code>
    */
   public Builder clearClientCountryId() {
    bitField0_ = (bitField0_ & ~0x00010000);
    clientCountryId_ = 0;
    onChanged();
    return this;
   }

   private int clientNetsegmentId_ ;
   /**
    * <code>optional int32 client_netsegment_id = 18;</code>
    */
   public boolean hasClientNetsegmentId() {
    return ((bitField0_ & 0x00020000) == 0x00020000);
   }
   /**
    * <code>optional int32 client_netsegment_id = 18;</code>
    */
   public int getClientNetsegmentId() {
    return clientNetsegmentId_;
   }
   /**
    * <code>optional int32 client_netsegment_id = 18;</code>
    */
   public Builder setClientNetsegmentId(int value) {
    bitField0_ |= 0x00020000;
    clientNetsegmentId_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 client_netsegment_id = 18;</code>
    */
   public Builder clearClientNetsegmentId() {
    bitField0_ = (bitField0_ & ~0x00020000);
    clientNetsegmentId_ = 0;
    onChanged();
    return this;
   }

   private long clientTotalPacket_ ;
   /**
    * <code>optional int64 client_total_packet = 19;</code>
    */
   public boolean hasClientTotalPacket() {
    return ((bitField0_ & 0x00040000) == 0x00040000);
   }
   /**
    * <code>optional int64 client_total_packet = 19;</code>
    */
   public long getClientTotalPacket() {
    return clientTotalPacket_;
   }
   /**
    * <code>optional int64 client_total_packet = 19;</code>
    */
   public Builder setClientTotalPacket(long value) {
    bitField0_ |= 0x00040000;
    clientTotalPacket_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 client_total_packet = 19;</code>
    */
   public Builder clearClientTotalPacket() {
    bitField0_ = (bitField0_ & ~0x00040000);
    clientTotalPacket_ = 0L;
    onChanged();
    return this;
   }

   private java.lang.Object clientIpAddr_ = "";
   /**
    * <code>optional string client_ip_addr = 20;</code>
    */
   public boolean hasClientIpAddr() {
    return ((bitField0_ & 0x00080000) == 0x00080000);
   }
   /**
    * <code>optional string client_ip_addr = 20;</code>
    */
   public java.lang.String getClientIpAddr() {
    java.lang.Object ref = clientIpAddr_;
    if (!(ref instanceof java.lang.String)) {
     com.google.protobuf.ByteString bs =
       (com.google.protobuf.ByteString) ref;
     java.lang.String s = bs.toStringUtf8();
     if (bs.isValidUtf8()) {
      clientIpAddr_ = s;
     }
     return s;
    } else {
     return (java.lang.String) ref;
    }
   }
   /**
    * <code>optional string client_ip_addr = 20;</code>
    */
   public com.google.protobuf.ByteString
     getClientIpAddrBytes() {
    java.lang.Object ref = clientIpAddr_;
    if (ref instanceof String) {
     com.google.protobuf.ByteString b =
       com.google.protobuf.ByteString.copyFromUtf8(
         (java.lang.String) ref);
     clientIpAddr_ = b;
     return b;
    } else {
     return (com.google.protobuf.ByteString) ref;
    }
   }
   /**
    * <code>optional string client_ip_addr = 20;</code>
    */
   public Builder setClientIpAddr(
     java.lang.String value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00080000;
    clientIpAddr_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional string client_ip_addr = 20;</code>
    */
   public Builder clearClientIpAddr() {
    bitField0_ = (bitField0_ & ~0x00080000);
    clientIpAddr_ = getDefaultInstance().getClientIpAddr();
    onChanged();
    return this;
   }
   /**
    * <code>optional string client_ip_addr = 20;</code>
    */
   public Builder setClientIpAddrBytes(
     com.google.protobuf.ByteString value) {
    if (value == null) {
  throw new NullPointerException();
 }
 bitField0_ |= 0x00080000;
    clientIpAddr_ = value;
    onChanged();
    return this;
   }

   private int tcpStatus_ ;
   /**
    * <code>optional int32 tcp_status = 21;</code>
    */
   public boolean hasTcpStatus() {
    return ((bitField0_ & 0x00100000) == 0x00100000);
   }
   /**
    * <code>optional int32 tcp_status = 21;</code>
    */
   public int getTcpStatus() {
    return tcpStatus_;
   }
   /**
    * <code>optional int32 tcp_status = 21;</code>
    */
   public Builder setTcpStatus(int value) {
    bitField0_ |= 0x00100000;
    tcpStatus_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 tcp_status = 21;</code>
    */
   public Builder clearTcpStatus() {
    bitField0_ = (bitField0_ & ~0x00100000);
    tcpStatus_ = 0;
    onChanged();
    return this;
   }

   private int serverCountryId_ ;
   /**
    * <code>optional int32 server_country_id = 22;</code>
    */
   public boolean hasServerCountryId() {
    return ((bitField0_ & 0x00200000) == 0x00200000);
   }
   /**
    * <code>optional int32 server_country_id = 22;</code>
    */
   public int getServerCountryId() {
    return serverCountryId_;
   }
   /**
    * <code>optional int32 server_country_id = 22;</code>
    */
   public Builder setServerCountryId(int value) {
    bitField0_ |= 0x00200000;
    serverCountryId_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 server_country_id = 22;</code>
    */
   public Builder clearServerCountryId() {
    bitField0_ = (bitField0_ & ~0x00200000);
    serverCountryId_ = 0;
    onChanged();
    return this;
   }

   private int serverNetsegmentId_ ;
   /**
    * <code>optional int32 server_netsegment_id = 23;</code>
    */
   public boolean hasServerNetsegmentId() {
    return ((bitField0_ & 0x00400000) == 0x00400000);
   }
   /**
    * <code>optional int32 server_netsegment_id = 23;</code>
    */
   public int getServerNetsegmentId() {
    return serverNetsegmentId_;
   }
   /**
    * <code>optional int32 server_netsegment_id = 23;</code>
    */
   public Builder setServerNetsegmentId(int value) {
    bitField0_ |= 0x00400000;
    serverNetsegmentId_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 server_netsegment_id = 23;</code>
    */
   public Builder clearServerNetsegmentId() {
    bitField0_ = (bitField0_ & ~0x00400000);
    serverNetsegmentId_ = 0;
    onChanged();
    return this;
   }

   private long avgPktSize_ ;
   /**
    * <code>optional int64 avg_pkt_size = 24;</code>
    */
   public boolean hasAvgPktSize() {
    return ((bitField0_ & 0x00800000) == 0x00800000);
   }
   /**
    * <code>optional int64 avg_pkt_size = 24;</code>
    */
   public long getAvgPktSize() {
    return avgPktSize_;
   }
   /**
    * <code>optional int64 avg_pkt_size = 24;</code>
    */
   public Builder setAvgPktSize(long value) {
    bitField0_ |= 0x00800000;
    avgPktSize_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 avg_pkt_size = 24;</code>
    */
   public Builder clearAvgPktSize() {
    bitField0_ = (bitField0_ & ~0x00800000);
    avgPktSize_ = 0L;
    onChanged();
    return this;
   }

   private int serverPort_ ;
   /**
    * <code>optional int32 server_port = 25;</code>
    */
   public boolean hasServerPort() {
    return ((bitField0_ & 0x01000000) == 0x01000000);
   }
   /**
    * <code>optional int32 server_port = 25;</code>
    */
   public int getServerPort() {
    return serverPort_;
   }
   /**
    * <code>optional int32 server_port = 25;</code>
    */
   public Builder setServerPort(int value) {
    bitField0_ |= 0x01000000;
    serverPort_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 server_port = 25;</code>
    */
   public Builder clearServerPort() {
    bitField0_ = (bitField0_ & ~0x01000000);
    serverPort_ = 0;
    onChanged();
    return this;
   }

   private long serverTotalByte_ ;
   /**
    * <code>optional int64 server_total_byte = 26;</code>
    */
   public boolean hasServerTotalByte() {
    return ((bitField0_ & 0x02000000) == 0x02000000);
   }
   /**
    * <code>optional int64 server_total_byte = 26;</code>
    */
   public long getServerTotalByte() {
    return serverTotalByte_;
   }
   /**
    * <code>optional int64 server_total_byte = 26;</code>
    */
   public Builder setServerTotalByte(long value) {
    bitField0_ |= 0x02000000;
    serverTotalByte_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int64 server_total_byte = 26;</code>
    */
   public Builder clearServerTotalByte() {
    bitField0_ = (bitField0_ & ~0x02000000);
    serverTotalByte_ = 0L;
    onChanged();
    return this;
   }

   private int totalPacketps_ ;
   /**
    * <code>optional int32 total_packetps = 27;</code>
    */
   public boolean hasTotalPacketps() {
    return ((bitField0_ & 0x04000000) == 0x04000000);
   }
   /**
    * <code>optional int32 total_packetps = 27;</code>
    */
   public int getTotalPacketps() {
    return totalPacketps_;
   }
   /**
    * <code>optional int32 total_packetps = 27;</code>
    */
   public Builder setTotalPacketps(int value) {
    bitField0_ |= 0x04000000;
    totalPacketps_ = value;
    onChanged();
    return this;
   }
   /**
    * <code>optional int32 total_packetps = 27;</code>
    */
   public Builder clearTotalPacketps() {
    bitField0_ = (bitField0_ & ~0x04000000);
    totalPacketps_ = 0;
    onChanged();
    return this;
   }
   public final Builder setUnknownFields(
     final com.google.protobuf.UnknownFieldSet unknownFields) {
    return super.setUnknownFields(unknownFields);
   }

   public final Builder mergeUnknownFields(
     final com.google.protobuf.UnknownFieldSet unknownFields) {
    return super.mergeUnknownFields(unknownFields);
   }

   // @@protoc_insertion_point(builder_scope:TCPLog)
  }

  // @@protoc_insertion_point(class_scope:TCPLog)
  private static final TCPLogOuterClass.TCPLog DEFAULT_INSTANCE;
  static {
   DEFAULT_INSTANCE = new TCPLogOuterClass.TCPLog();
  }

  public static TCPLogOuterClass.TCPLog getDefaultInstance() {
   return DEFAULT_INSTANCE;
  }

  @java.lang.Deprecated public static final com.google.protobuf.Parser<TCPLog>
    PARSER = new com.google.protobuf.AbstractParser<TCPLog>() {
   public TCPLog parsePartialFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws com.google.protobuf.InvalidProtocolBufferException {
     return new TCPLog(input, extensionRegistry);
   }
  };

  public static com.google.protobuf.Parser<TCPLog> parser() {
   return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<TCPLog> getParserForType() {
   return PARSER;
  }

  public TCPLogOuterClass.TCPLog getDefaultInstanceForType() {
   return DEFAULT_INSTANCE;
  }

 }

 private static final com.google.protobuf.Descriptors.Descriptor
  internal_static_TCPLog_descriptor;
 private static final
  com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
   internal_static_TCPLog_fieldAccessorTable;

 public static com.google.protobuf.Descriptors.FileDescriptor
   getDescriptor() {
  return descriptor;
 }
 private static com.google.protobuf.Descriptors.FileDescriptor
   descriptor;
 static {
  java.lang.String[] descriptorData = {
   "\n\014TCPLog.proto\"\357\004\n\006TCPLog\022\024\n\014total_bytep" +
   "s\030\001 \001(\005\022\027\n\017flow_start_time\030\002 \001(\003\022\014\n\004date" +
   "\030\003 \001(\003\022\033\n\023server_total_packet\030\004 \001(\003\022\031\n\021c" +
   "lient_total_byte\030\005 \001(\003\022\017\n\007link_id\030\006 \001(\005\022" +
   "\022\n\ntotal_byte\030\007 \001(\003\022\025\n\rflow_end_time\030\010 \001" +
   "(\003\022\023\n\013client_port\030\t \001(\005\022\020\n\010protocol\030\n \001(" +
   "\005\022\024\n\014total_packet\030\013 \001(\003\022\025\n\rflow_duration" +
   "\030\014 \001(\003\022\n\n\002id\030\r \001(\t\022\026\n\016server_ip_addr\030\016 \001" +
   "(\t\022\026\n\016direction_mask\030\017 \001(\t\022\013\n\003app\030\020 \001(\005\022" +
   "\031\n\021client_country_id\030\021 \001(\005\022\034\n\024client_net",
   "segment_id\030\022 \001(\005\022\033\n\023client_total_packet\030" +
   "\023 \001(\003\022\026\n\016client_ip_addr\030\024 \001(\t\022\022\n\ntcp_sta" +
   "tus\030\025 \001(\005\022\031\n\021server_country_id\030\026 \001(\005\022\034\n\024" +
   "server_netsegment_id\030\027 \001(\005\022\024\n\014avg_pkt_si" +
   "ze\030\030 \001(\003\022\023\n\013server_port\030\031 \001(\005\022\031\n\021server_" +
   "total_byte\030\032 \001(\003\022\026\n\016total_packetps\030\033 \001(\005"
  };
  com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
    new com.google.protobuf.Descriptors.FileDescriptor.  InternalDescriptorAssigner() {
     public com.google.protobuf.ExtensionRegistry assignDescriptors(
       com.google.protobuf.Descriptors.FileDescriptor root) {
      descriptor = root;
      return null;
     }
    };
  com.google.protobuf.Descriptors.FileDescriptor
   .internalBuildGeneratedFileFrom(descriptorData,
    new com.google.protobuf.Descriptors.FileDescriptor[] {
    }, assigner);
  internal_static_TCPLog_descriptor =
   getDescriptor().getMessageTypes().get(0);
  internal_static_TCPLog_fieldAccessorTable = new
   com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
    internal_static_TCPLog_descriptor,
    new java.lang.String[] { "TotalByteps", "FlowStartTime", "Date", "ServerTotalPacket", "ClientTotalByte", "LinkId", "TotalByte", "FlowEndTime", "ClientPort", "Protocol", "TotalPacket", "FlowDuration", "Id", "ServerIpAddr", "DirectionMask", "App", "ClientCountryId", "ClientNetsegmentId", "ClientTotalPacket", "ClientIpAddr", "TcpStatus", "ServerCountryId", "ServerNetsegmentId", "AvgPktSize", "ServerPort", "ServerTotalByte", "TotalPacketps", });
 }

 // @@protoc_insertion_point(outer_class_scope)
}

之后便可以使用该类进行序列化和反序列化。

具体示例代码如下》:

import java.io.File;
import java.io.FileOutputStream;

public class ProtoTest3 {
 /**
 * @param args
 * @throws Exception
 * @author qiang(upupgo)
 */
public static void main(String[] args) throws Exception {
    //模拟将对象转成byte[],方便传输
   TCPLogOuterClass.TCPLog.Builder builder = TCPLogOuterClass.TCPLog.newBuilder();
  builder.setTotalByteps(1024);
  builder.setFlowStartTime(1502415717l);
  builder.setDate(1502415717l);
  //序列化到文件
   TCPLogOuterClass.TCPLog tcpLog= builder.build();
   FileOutputStream out = new FileOutputStream(new File("D:/pb"));
   out.write(tcpLog.toByteArray());
   out.close();
   //反序列化
  TCPLogOuterClass.TCPLog tcp = TCPLogOuterClass.TCPLog.parseFrom(tcpLog.toByteArray());
  System.out.println(tcp);
}
}

二、AVRO序列化基本操作:

AVRO简介:

Apache Avro™ is a data serialization system.
Avro provides:
Rich data structures.
A compact, fast, binary data format.
A container file, to store persistent data.
Remote procedure call (RPC).
Simple integration with dynamic languages. Code generation is not required to read or write data files nor to use or implement RPC protocols. Code generation as an optional optimization, only worth implementing for statically typed languages.

Avro是一个序列化系统。丰富的数据结构、快速压缩的二进制数据格式、数据持久化存储、RPC及动态语言集成。

2.1定义协议文件(TCPLog.avro)

{"namespace": "example.avro",
 "type": "record",
 "name": "TCPLog",
 "fields": [
   {"name": "total_byteps", "type": "int"},
   {"name": "flow_start_time", "type": "long"},
   {"name": "date", "type": "long"}

 ]
}

avro和protobuf一样可以生成相应语言的类文件,或直接支持动态扩张。下面以Java语言不生成类说明:

具体序列化与反序列化操作代码如下:、

package avro;

import java.io.File;

import org.apache.avro.Schema;
import org.apache.avro.file.DataFileReader;
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.DatumReader;
import org.apache.avro.io.DatumWriter;
/**
 * @date 2017年8月13日22:15:32
 * @author qiang(upupgo)
 *
 */
public class AvroTest2 {
public static void main(String[] args) throws Exception {
  String filePath = "D:/TCPLog.avsc";
  Schema schema = new Schema.Parser().parse(new File(filePath));

  GenericRecord tcpLog = new GenericData.Record(schema);
  tcpLog.put("total_byteps", 1024);
  tcpLog.put("flow_start_time", 1502415717L);
  tcpLog.put("date", 1502415717L);

  System.out.println(tcpLog);

  // Serialize user1 and tcpLog to disk
  File file = new File("D:/avro");
  DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<GenericRecord>(schema);
  DataFileWriter<GenericRecord> dataFileWriter = new DataFileWriter<GenericRecord>(datumWriter);
  dataFileWriter.create(schema, file);
  long timestart = System.currentTimeMillis();
  dataFileWriter.append(tcpLog);
  dataFileWriter.close();
  long timeend = System.currentTimeMillis();
  System.out.println(timeend-timestart);

  // Deserialize users from disk
  DatumReader<GenericRecord> datumReader = new GenericDatumReader<GenericRecord>(schema);
  DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(new File("d:/avro"), datumReader);
  GenericRecord tcpLogs = null;
  long timestart1 = System.currentTimeMillis();
  while (dataFileReader.hasNext()) {
  // Reuse user object by passing it to next(). This saves us from
  // allocating and garbage collecting many objects for files with
  // many items.
    tcpLogs = dataFileReader.next();
//  System.out.println("xx"+tcpLogs);
 }
  long timeend1 = System.currentTimeMillis();
  System.out.println("Deserialize"+(timeend1-timestart1));
 }
}

以下是通过对100W tcpLog序列化操作对比结论:

通过对比测试发现 avro的性能要不pb稍微好一些,且支持动态性。故技术选型上可以优先考虑。

以上是通过测试对比了pb与avro的一些性能差异,但是具体测试和机器和样本都有关系,可以参考。

以下是对比protobuf、avro、thrift的一些优缺点:

Google protobuf:
优点

  二进制消息,性能好/效率高(空间和时间效率都很不错)
  proto文件生成目标代码,简单易用
  序列化反序列化直接对应程序中的数据类,不需要解析后在进行映射(XML,JSON都是这种方式)
  支持向前兼容(新加字段采用默认值)和向后兼容(忽略新加字段),简化升级
  支持多种语言(可以把proto文件看做IDL文件)
  Netty等一些框架集成

缺点

  官方只支持C++,JAVA和Python语言绑定
  二进制可读性差(貌似提供了Text_Fromat功能)
  二进制不具有自描述特性
  默认不具备动态特性(可以通过动态定义生成消息类型或者动态编译支持)
  只涉及序列化和反序列化技术,不涉及RPC功能(类似XML或者JSON的解析器)

Apache Thrift:
应用

  Facebook的开源的日志收集系统(scribe: https://github.com/facebook/scribe)
  淘宝的实时数据传输平台(TimeTunnel http://code.taobao.org/p/TimeTunnel/wiki/index)
  Evernote开放接口(https://github.com/evernote/evernote-thrift)
  Quora(http://www.quora.com/Apache-Thrift)
  HBase( http://abloz.com/hbase/book.html#thrift )
  …

优点

  支持非常多的语言绑定
  thrift文件生成目标代码,简单易用
  消息定义文件支持注释
  数据结构与传输表现的分离,支持多种消息格式
  包含完整的客户端/服务端堆栈,可快速实现RPC
  支持同步和异步通信

缺点

  和protobuf一样不支持动态特性

Apache Avro:
应用

  Hadoop RPC (http://hadoop.apache.org/#What+Is+Apache+Hadoop%3F)

优点

  二进制消息,性能好/效率高
  使用JSON描述模式
  模式和数据统一存储,消息自描述,不需要生成stub代码(支持生成IDL)
  RPC调用在握手阶段交换模式定义
  包含完整的客户端/服务端堆栈,可快速实现RPC
  支持同步和异步通信
  支持动态消息
  模式定义允许定义数据的排序(序列化时会遵循这个顺序)
  提供了基于Jetty内核的服务基于Netty的服务

缺点

  只支持Avro自己的序列化格式
  语言绑定不如Thrift丰富

如有错误欢迎指正,如果对您有帮助也欢迎打赏 点赞 推荐 谢谢!^^

以上这篇浅谈序列化之protobuf与avro对比(Java)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。

(0)

相关推荐

  • java序列化和serialVersionUID的使用方法实例

    java序列化和serialVersionUID的使用方法实例 1.序列化: 序列化可以将一个java对象以二进制流的方式在网络中传输并且可以被持久化到数据库.文件系统中,反序列化则是可以把之前持久化在数据库或文件系统中的二进制数据以流的方式读取出来重新构造成一个和之前相同内容的java对象.  2.序列化的作用: 第一种:用于将java对象状态储存起来,通常放到一个文件中,使下次需要用到的时候再读取到它之前的状态信息. 第二种:可以让java对象在网络中传输.  3.序列化的实现: 1).需要

  • java 序列化与反序列化的实例详解

     1.Java序列化与反序列化 Java序列化是指把Java对象转换为字节序列的过程:而Java反序列化是指把字节序列恢复为Java对象的过程.  2.为什么需要序列化与反序列化 我们知道,当两个进程进行远程通信时,可以相互发送各种类型的数据,包括文本.图片.音频.视频等, 而这些数据都会以二进制序列的形式在网络上传送.那么当两个Java进程进行通信时,能否实现进程间的对象传送呢?答案是可以的.如何做到呢?这就需要Java序列化与反序列化了.换句话说,一方面,发送方需要把这个Java对象转换为字

  • java如何利用FastJSON、Gson、Jackson三种Json格式工具自定义时间序列化

    Java处理JSON数据有三个比较流行的类库FastJSON.Gson和Jackson. Jackson Jackson是由其社区进行维护,简单易用并且性能也相对高些.但是对于复杂的bean转换Json,转换的格式鄙视标准的Json格式.PS:Jackson为Spring MVC内置Json解析工具 Gson Gson是由谷歌公司研发的产品,目前是最全的Json解析工具.完全可以将复杂的类型的Json解析成Bean或者Bean到Json的转换 FastJson Fastjson是一个Java语言

  • java 中序列化与readResolve()方法的实例详解

    java 中序列化与readResolve()方法的实例详解 readResolve方法是作用是什么?这个方法跟对象的序列化相关(这样倒是解释了为什么 readResolve方法是private修饰的). 怎么跟对象的序列化相关了? 下面我们先简要地回顾下对象的序列化.一般来说,一个类实现了 Serializable接口,我们就可以把它往内存地写再从内存里读出而"组装"成一个跟原来一模一样的对象.不过当序列化遇到单例时,里边就有了个问题:从内存读出而组装的对象破坏了单例的规则.单例是要

  • java 中序列化NotSerializableException问题解决办法

    java 中序列化NotSerializableException问题解决办法 前言: 某项目中,要将某个自定义类MMessage对象,通过ObjectOutputStream和ObjectInputStream传递,该MMessage的特征描述: 1 该类未继承Serializable接口: 2 其父类Message的父类继承了Serializable接口: 3 其父类中有一个字段类型为Java.io.ByteArrayOutputStream类型: 经测试发现,MMessage类序列化过程中

  • Java 序列化和反序列化实例详解

    Java 序列化和反序列化实例详解 在分布式应用中,对象只有经过序列化才能在各个分布式组件之间传输,这就涉及到两个方面的技术-发送者将对象序列化,接受者将对象反序列化,下面就是一个很好的例子! 1.实体-Employee import java.io.Serializable; public class Employee implements Serializable{ /** * */ private static final long serialVersionUID = 1L; publi

  • java 中Spark中将对象序列化存储到hdfs

    java 中Spark中将对象序列化存储到hdfs 摘要: Spark应用中经常会遇到这样一个需求: 需要将JAVA对象序列化并存储到HDFS, 尤其是利用MLlib计算出来的一些模型, 存储到hdfs以便模型可以反复利用. 下面的例子演示了Spark环境下从Hbase读取数据, 生成一个word2vec模型, 存储到hdfs. 废话不多说, 直接贴代码了. spark1.4 + hbase0.98 import org.apache.spark.storage.StorageLevel imp

  • 浅谈java中为什么实体类需要实现序列化

    当客户端访问某个能开启会话功能的资源,web服务器就会创建一个HTTPSession对象,每个HTTPSession对象都会占用一定的内存,如果在同一个时间段内访问的用户太多,就会消耗大量的服务器内存,为了解决这个问题我们使用一种技术:session的持久化. 什么是session的持久化? web服务器会把暂时不活动的并且没有失效的HTTPSession对象转移到文件系统或数据库中储存,服务器要用时在把他们转载到内存. 把Session对象转移到文件系统或数据库中储存就需要用到序列化: jav

  • 浅谈序列化之protobuf与avro对比(Java)

    最近在做socket通信中用到了关于序列化工具选型的问题,在调研过程中开始趋向于用protobuf,可以省去了编解码的过程.能够实现快速开发,且只需要维护一份协议文件即可. 但是调研过程中发现了protobuf的一些弊端,比如需要生成相应的文件类,和业务绑定太紧密,所以在看了AVRO之后发现它完美解决了这个问题. 下面记录下对这两种序列化工具的入门与测评. 一.protobuf基本操作 protobuf简介: Protocol Buffers (a.k.a., protobuf) are Goo

  • 浅谈MySQL和Lucene索引的对比分析

    MySQL和Lucene都可以对数据构建索引并通过索引查询数据,一个是关系型数据库,一个是构建搜索引擎(Solr.ElasticSearch)的核心类库.两者的索引(index)有什么区别呢?以前写过一篇<Solr与MySQL查询性能对比>,只是简单的对比了下查询性能,对于内部原理却没有解释,本文简单分析下两者的索引区别. MySQL索引实现 在MySQL中,索引属于存储引擎级别的概念,不同存储引擎对索引的实现方式是不同的,本文主要讨论MyISAM和InnoDB两个存储引擎的索引实现方式. M

  • 浅谈JSP与Servlet传值及对比(总结)

    JSP是Servlet技术的扩展,本质上是Servlet的简易方式,更强调应用的外表表达. JSP编译后是"类servlet". Servlet和JSP最主要的不同点在于,Servlet的应用逻辑是在Java文件中,并且完全从表示层中的HTML里分离开来. 而JSP的情况是Java和HTML可以组合成一个扩展名为.jsp的文件.JSP侧重于视图,Servlet主要用于控制逻辑. 本篇从以下四个方面探讨下JSP与Servlet的传值问题: 一.JSP传值给Servlet JSP传值给Se

  • 浅谈Linux vfork与fork简单对比分析

    本文分享了Linux vfork与fork简单对比分析,分享给大家,具体如下: fork相关问题: 一.fork基础了解 fork作用为创建一个子进程,在使用了fork命令后,内核会分配新的内存块和数据结构给子进程,并且将父进程的部分数据结构内容拷贝到子进程,最后再将子进程添加到系统进程列表中,添加完成后fork返回,开始调度. 头文件:#include < unistd.h > 函数原型:pid_t fork( ) 返回值:返回值大于0则当前进程为父进程,等于0代表为子进程,小于零代表创建子

  • 浅谈redux, koa, express 中间件实现对比解析

    如果你有 express ,koa, redux 的使用经验,就会发现他们都有 中间件(middlewares)的概念,中间件 是一种拦截器的思想,用于在某个特定的输入输出之间添加一些额外处理,同时不影响原有操作. 最开始接触 中间件是在服务端使用 express 和 koa 的时候,后来从服务端延伸到前端,看到其在redux的设计中也得到的极大的发挥.中间件的设计思想也为许多框架带来了灵活而强大的扩展性. 本文主要对比redux, koa, express 的中间件实现,为了更直观,我会抽取出

  • 浅谈es6语法 (Proxy和Reflect的对比)

    如下所示: { //原始对象 let obj={ time:'2017-03-11', name:'net', _r:123 }; //(代理商)第一个参数代理对象,第二个参数真正代理的东西 let monitor=new Proxy(obj,{ // 拦截对象属性的读取 get(target,key){ return target[key].replace('2017','2018') }, // 拦截对象设置属性 set(target,key,value){ if(key==='name')

  • 浅谈C# 序列化与反序列化几种格式的转换

    这里介绍了几种方式之间的序列化与反序列化之间的转换 首先介绍的如何序列化,将object对象序列化常见的两种方式即string和xml对象; 第一种将object转换为string对象,这种比较简单没有什么可谈的: public string ScriptSerialize<T>(T t) { JavaScriptSerializer serializer = new JavaScriptSerializer(); return serializer.Serialize(t); } 第二种将o

  • 浅谈二分法查找和原始算法查找的效率对比

    我就废话不多说了,大家还是直接看代码吧! import java.text.MessageFormat; public class AppTest { static int length = 70000000; static int[] array = new int[length]; static { for (int i = 0; i < length; i++) { array[i] = i; } } public static void main(String[] args) { for

  • 浅谈.Net中的序列化和反序列化

    序列化和反序列化相信大家都经常听到,也都会用, 然而有些人可能不知道:.net为什么要有这个东西以及.net Frameword如何为我们实现这样的机制, 在这里我也是简单谈谈我对序列化和反序列化的一些理解. 一.什么序列化和反序列化 序列化通俗地讲就是将一个对象转换成一个字节流的过程,这样就可以轻松保存在磁盘文件或数据库中.反序列化是序列化的逆过程,就是将一个字节流转换回原来的对象的过程. 然而为什么需要序列化和反序列化这样的机制呢?这个问题也就涉及到序列化和反序列化的用途了, 对于序列化的主

随机推荐