}
}
BasicBSONList result = (BasicBSONList) reply.get("Splits");
Map<Query, Long> queries = new HashMap<>();
for (Object split : result) {
BSONObject splitObj = (BasicBSONObject) split;
BSONObject query = (BasicBSONObject) (splitObj.get("Query"));
String sql = new String((byte[]) query.get("Sql"));
BSONObject bindVars = (BasicBSONObject) query.get("BindVariables");
List<BindVariable> bindVariables = new LinkedList<>();
for (String key : bindVars.keySet()) {
BindVariable bv = null;
Object val = bindVars.get(key);
if (val == null) {
bv = BindVariable.forNull(key);
}
if (val instanceof UnsignedLong) {
bv = BindVariable.forULong(key, (UnsignedLong) val);
}
if (val instanceof Long) {
bv = BindVariable.forLong(key, (Long) val);
}
if (val instanceof Double) {
bv = BindVariable.forDouble(key, (Double) val);
}
if (val instanceof byte[]) {
bv = BindVariable.forBytes(key, (byte[]) val);
}
if (bv == null) {
throw new RuntimeException("invalid bind variable type: " + val.getClass());
}
bindVariables.add(bv);
}
String keyspace = new String((byte[]) query.get("Keyspace"));
String tabletType = new String((byte[]) query.get("TabletType"));
List<KeyRange> keyranges = new ArrayList<>();
for (Object o : (List<?>) query.get("KeyRanges")) {
BSONObject keyrange = (BasicBSONObject) o;
String start = Hex.encodeHexString((byte[]) keyrange.get("Start"));
String end = Hex.encodeHexString((byte[]) keyrange.get("End"));
KeyRange kr = new KeyRange(KeyspaceId.valueOf(start), KeyspaceId.valueOf(end));
keyranges.add(kr);
}
Query q = new QueryBuilder(sql, keyspace, tabletType).setKeyRanges(keyranges)