public static void main(String[] args) {

    String path = "/data/test/test.pb";
    ProtoWriter pwriter = new ProtoWriter();
    pwriter.openFile(path);

    // TODO Auto-generated method stub
    BigtableData.Builder data = BigtableData.newBuilder();
    data.setPrimaryKey("ttt");
    data.addLevelValues(12);
    data.addLevelValues(123);
    data.addLevelValues(124);
    data.addLevelValues(125);
    data.addLevelValues(126);
    pwriter.writeObject(data.build());

    data = BigtableData.newBuilder();
    data.setPrimaryKey("kkk");
    data.addLevelValues(12);
    data.addLevelValues(123);
    pwriter.writeObject(data.build());
    pwriter.close();

    ProtoReader preader = new ProtoReader();
    preader.openFile(path);
    BigtableData tt = preader.readObject();
    System.out.println("key: " + tt.getPrimaryKey() + " value: " + tt.getLevelValuesCount());
    tt = preader.readObject();
    System.out.println("key: " + tt.getPrimaryKey() + " value: " + tt.getLevelValuesCount());
    preader.close();
  }
 @Override
 public E decode(ProtoReader reader) throws IOException {
   int value = reader.readVarint32();
   E constant;
   try {
     //noinspection unchecked
     constant = (E) fromValueMethod.invoke(null, value);
   } catch (IllegalAccessException | InvocationTargetException e) {
     throw new AssertionError(e);
   }
   if (constant == null) {
     throw new EnumConstantNotFoundException(value, type);
   }
   return constant;
 }