@Test(expected = PilosaException.class) public void testUnknownType() { Internal.QueryResult result = Internal.QueryResult.newBuilder() .setType(999) .build(); Internal.QueryResponse response = Internal.QueryResponse.newBuilder() .addResults(result) .build(); PilosaClient client = PilosaClient.defaultClient(); QueryResponse r = new QueryResponse(); r.parseQueryResponse(response); }
void parseQueryResponse(Internal.QueryResponse response) { List<QueryResult> results = new ArrayList<>(response.getResultsCount()); for (Internal.QueryResult q : response.getResultsList()) { int type = q.getType(); switch (type) { case QueryResultType.ROW: results.add(RowResult.fromInternal(q)); break; case QueryResultType.BOOL: results.add(BoolResult.fromInternal(q)); break; case QueryResultType.INT: results.add(IntResult.fromInternal(q)); break; case QueryResultType.PAIRS: results.add(TopNResult.fromInternal(q)); break; case QueryResultType.VAL_COUNT: results.add(ValueCountResult.fromInternal(q)); break; case QueryResultType.NIL: results.add(NullResult.defaultResult()); break; case QueryResultType.GROUP_COUNTS: results.add(GroupCountsResult.fromInternal(q)); break; case QueryResultType.ROW_IDENTIFIERS: results.add(RowIdentifiersResult.fromInternal(q)); break; default: throw new PilosaException(String.format("Unknown type: %d", type)); } } this.results = results; ArrayList<ColumnItem> columns = new ArrayList<>(response.getColumnAttrSetsCount()); for (Internal.ColumnAttrSet column : response.getColumnAttrSetsList()) { columns.add(ColumnItem.fromInternal(column)); } this.columns = columns; }
QueryResponse { void parseQueryResponse(Internal.QueryResponse response) { List<QueryResult> results = new ArrayList<>(response.getResultsCount()); for (Internal.QueryResult q : response.getResultsList()) { int type = q.getType(); switch (type) { case QueryResultType.ROW: results.add(RowResult.fromInternal(q)); break; case QueryResultType.BOOL: results.add(BoolResult.fromInternal(q)); break; case QueryResultType.INT: results.add(IntResult.fromInternal(q)); break; case QueryResultType.PAIRS: results.add(TopNResult.fromInternal(q)); break; case QueryResultType.VAL_COUNT: results.add(ValueCountResult.fromInternal(q)); break; case QueryResultType.NIL: results.add(NullResult.defaultResult()); break; case QueryResultType.GROUP_COUNTS: results.add(GroupCountsResult.fromInternal(q)); break; case QueryResultType.ROW_IDENTIFIERS: results.add(RowIdentifiersResult.fromInternal(q)); break; default: throw new PilosaException(String.format("Unknown type: %d", type)); } } this.results = results; ArrayList<ColumnItem> columns = new ArrayList<>(response.getColumnAttrSetsCount()); for (Internal.ColumnAttrSet column : response.getColumnAttrSetsList()) { columns.add(ColumnItem.fromInternal(column)); } this.columns = columns; } }
QueryResponse { void parseQueryResponse(Internal.QueryResponse response) { List<QueryResult> results = new ArrayList<>(response.getResultsCount()); for (Internal.QueryResult q : response.getResultsList()) { int type = q.getType(); switch (type) { case QueryResultType.ROW: results.add(RowResult.fromInternal(q)); break; case QueryResultType.BOOL: results.add(BoolResult.fromInternal(q)); break; case QueryResultType.INT: results.add(IntResult.fromInternal(q)); break; case QueryResultType.PAIRS: results.add(TopNResult.fromInternal(q)); break; case QueryResultType.VAL_COUNT: results.add(ValueCountResult.fromInternal(q)); break; case QueryResultType.NIL: results.add(NullResult.defaultResult()); break; case QueryResultType.GROUP_COUNTS: results.add(GroupCountsResult.fromInternal(q)); break; case QueryResultType.ROW_IDENTIFIERS: results.add(RowIdentifiersResult.fromInternal(q)); break; default: throw new PilosaException(String.format("Unknown type: %d", type)); } } this.results = results; ArrayList<ColumnItem> columns = new ArrayList<>(response.getColumnAttrSetsCount()); for (Internal.ColumnAttrSet column : response.getColumnAttrSetsList()) { columns.add(ColumnItem.fromInternal(column)); } this.columns = columns; } QueryResponse(); }
QueryResponse { void parseQueryResponse(Internal.QueryResponse response) { List<QueryResult> results = new ArrayList<>(response.getResultsCount()); for (Internal.QueryResult q : response.getResultsList()) { int type = q.getType(); switch (type) { case QueryResultType.ROW: results.add(RowResult.fromInternal(q)); break; case QueryResultType.BOOL: results.add(BoolResult.fromInternal(q)); break; case QueryResultType.INT: results.add(IntResult.fromInternal(q)); break; case QueryResultType.PAIRS: results.add(TopNResult.fromInternal(q)); break; case QueryResultType.VAL_COUNT: results.add(ValueCountResult.fromInternal(q)); break; case QueryResultType.NIL: results.add(NullResult.defaultResult()); break; case QueryResultType.GROUP_COUNTS: results.add(GroupCountsResult.fromInternal(q)); break; case QueryResultType.ROW_IDENTIFIERS: results.add(RowIdentifiersResult.fromInternal(q)); break; default: throw new PilosaException(String.format("Unknown type: %d", type)); } } this.results = results; ArrayList<ColumnItem> columns = new ArrayList<>(response.getColumnAttrSetsCount()); for (Internal.ColumnAttrSet column : response.getColumnAttrSetsList()) { columns.add(ColumnItem.fromInternal(column)); } this.columns = columns; } QueryResponse(); List<QueryResult> getResults(); QueryResult getResult(); List<ColumnItem> getColumns(); ColumnItem getColumn(); }
QueryResponse { void parseQueryResponse(Internal.QueryResponse response) { List<QueryResult> results = new ArrayList<>(response.getResultsCount()); for (Internal.QueryResult q : response.getResultsList()) { int type = q.getType(); switch (type) { case QueryResultType.ROW: results.add(RowResult.fromInternal(q)); break; case QueryResultType.BOOL: results.add(BoolResult.fromInternal(q)); break; case QueryResultType.INT: results.add(IntResult.fromInternal(q)); break; case QueryResultType.PAIRS: results.add(TopNResult.fromInternal(q)); break; case QueryResultType.VAL_COUNT: results.add(ValueCountResult.fromInternal(q)); break; case QueryResultType.NIL: results.add(NullResult.defaultResult()); break; case QueryResultType.GROUP_COUNTS: results.add(GroupCountsResult.fromInternal(q)); break; case QueryResultType.ROW_IDENTIFIERS: results.add(RowIdentifiersResult.fromInternal(q)); break; default: throw new PilosaException(String.format("Unknown type: %d", type)); } } this.results = results; ArrayList<ColumnItem> columns = new ArrayList<>(response.getColumnAttrSetsCount()); for (Internal.ColumnAttrSet column : response.getColumnAttrSetsList()) { columns.add(ColumnItem.fromInternal(column)); } this.columns = columns; } QueryResponse(); List<QueryResult> getResults(); QueryResult getResult(); List<ColumnItem> getColumns(); ColumnItem getColumn();  }