Esempio n. 1
0
  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();
  }
Esempio n. 2
0
 @Override
 public void encode(ProtoWriter writer, E value) throws IOException {
   writer.writeVarint32(value.getValue());
 }
Esempio n. 3
0
 @Override
 public int encodedSize(E value) {
   return ProtoWriter.varint32Size(value.getValue());
 }