Package com.github.youtube.vitess.jdbc.vtocc.QueryService.QueryResult

Examples of com.github.youtube.vitess.jdbc.vtocc.QueryService.QueryResult.Builder


    sessionInfo.setSessionId((Long) body.get("SessionId"));
    return sessionInfo.build();
  }

  protected QueryResult createQueryResult(BSONObject bsonBody) {
    Builder queryResult = QueryResult.newBuilder();
    queryResult.setInsertId((Long) bsonBody.get("InsertId"));
    BSONObject fields = (BSONObject) bsonBody.get("Fields");
    for (String index : fields.keySet()) {
      BSONObject field = (BSONObject) fields.get(index);
      queryResult.addFields(
          Field.newBuilder()
              .setName(new String((byte[]) field.get("Name"), StandardCharsets.UTF_8))
              .setType(Type.valueOf(Ints.checkedCast((Long) field.get("Type"))))
              .build()
      );
    }

    BSONObject rows = (BSONObject) bsonBody.get("Rows");
    for (String rowIndex : rows.keySet()) {
      BSONObject bsonRow = (BSONObject) rows.get(rowIndex);
      Row.Builder queryRow = Row.newBuilder();
      for (String cellIndex : bsonRow.keySet()) {
        queryRow.addValues(Cell.newBuilder()
            .setValue(ByteString.copyFrom((byte[]) bsonRow.get(cellIndex))));
      }
      queryResult.addRows(queryRow);
    }

    queryResult.setRowsAffected((Long) bsonBody.get("RowsAffected"));
    return queryResult.build();
  }
View Full Code Here

TOP

Related Classes of com.github.youtube.vitess.jdbc.vtocc.QueryService.QueryResult.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.