@Test public void getQueryResult() throws SQLException { QueryResultSet resultSet = query.getQueryResult(); assertTrue(resultSet.hasNextPage()); try { resultSet.getPage(); fail(); } catch (Exception ignored) { } SwiftResultSet swiftResultSet = resultSet.convert(new SwiftMetaDataEntity()); assertTrue(swiftResultSet.hasNext()); List<Row> rows = new ArrayList<Row>(); while (swiftResultSet.hasNext()) { rows.add(swiftResultSet.getNextRow()); } assertTrue(rows.size() > 0); assertEquals(expected, rows); }
@Override public QueryResultSet<SwiftNode> getQueryResult() throws SQLException { QueryResultSet<SwiftNode> resultSet = query.getQueryResult(); SwiftRowOperator<Row> operator = new SwiftRowOperator<Row>() { @Override public List<Row> operate(SwiftNode node) { int dimensionSize = SwiftNodeUtils.getDimensionSize(node); Iterator<List<SwiftNode>> rowIt = new Tree2RowIterator<SwiftNode>(dimensionSize, node.getChildren().iterator(), new Function<SwiftNode, Iterator<SwiftNode>>() { @Override public Iterator<SwiftNode> apply(SwiftNode p) { return p.getChildren().iterator(); } }); List<List<SwiftNode>> rows = IteratorUtils.iterator2List(rowIt); sortRow(dimensionSize, rows, sortList); return IteratorUtils.iterator2List(new MapperIterator<List<SwiftNode>, Row>(rows.iterator(), new Function<List<SwiftNode>, Row>() { @Override public Row apply(List<SwiftNode> p) { return SwiftNodeUtils.nodes2Row(p); } })); } }; return new FakeNodeQueryResultSet(operator, resultSet); }
RowSortQuery implements Query<QueryResultSet<SwiftNode>> { @Override public QueryResultSet<SwiftNode> getQueryResult() throws SQLException { QueryResultSet<SwiftNode> resultSet = query.getQueryResult(); SwiftRowOperator<Row> operator = new SwiftRowOperator<Row>() { @Override public List<Row> operate(SwiftNode node) { int dimensionSize = SwiftNodeUtils.getDimensionSize(node); Iterator<List<SwiftNode>> rowIt = new Tree2RowIterator<SwiftNode>(dimensionSize, node.getChildren().iterator(), new Function<SwiftNode, Iterator<SwiftNode>>() { @Override public Iterator<SwiftNode> apply(SwiftNode p) { return p.getChildren().iterator(); } }); List<List<SwiftNode>> rows = IteratorUtils.iterator2List(rowIt); sortRow(dimensionSize, rows, sortList); return IteratorUtils.iterator2List(new MapperIterator<List<SwiftNode>, Row>(rows.iterator(), new Function<List<SwiftNode>, Row>() { @Override public Row apply(List<SwiftNode> p) { return SwiftNodeUtils.nodes2Row(p); } })); } }; return new FakeNodeQueryResultSet(operator, resultSet); } }
RowSortQuery implements Query<QueryResultSet<SwiftNode>> { @Override public QueryResultSet<SwiftNode> getQueryResult() throws SQLException { QueryResultSet<SwiftNode> resultSet = query.getQueryResult(); SwiftRowOperator<Row> operator = new SwiftRowOperator<Row>() { @Override public List<Row> operate(SwiftNode node) { int dimensionSize = SwiftNodeUtils.getDimensionSize(node); Iterator<List<SwiftNode>> rowIt = new Tree2RowIterator<SwiftNode>(dimensionSize, node.getChildren().iterator(), new Function<SwiftNode, Iterator<SwiftNode>>() { @Override public Iterator<SwiftNode> apply(SwiftNode p) { return p.getChildren().iterator(); } }); List<List<SwiftNode>> rows = IteratorUtils.iterator2List(rowIt); sortRow(dimensionSize, rows, sortList); return IteratorUtils.iterator2List(new MapperIterator<List<SwiftNode>, Row>(rows.iterator(), new Function<List<SwiftNode>, Row>() { @Override public Row apply(List<SwiftNode> p) { return SwiftNodeUtils.nodes2Row(p); } })); } }; return new FakeNodeQueryResultSet(operator, resultSet); } RowSortQuery(Query<QueryResultSet<SwiftNode>> query, List<Sort> sortList); }
RowSortQuery implements Query<QueryResultSet<SwiftNode>> { @Override public QueryResultSet<SwiftNode> getQueryResult() throws SQLException { QueryResultSet<SwiftNode> resultSet = query.getQueryResult(); SwiftRowOperator<Row> operator = new SwiftRowOperator<Row>() { @Override public List<Row> operate(SwiftNode node) { int dimensionSize = SwiftNodeUtils.getDimensionSize(node); Iterator<List<SwiftNode>> rowIt = new Tree2RowIterator<SwiftNode>(dimensionSize, node.getChildren().iterator(), new Function<SwiftNode, Iterator<SwiftNode>>() { @Override public Iterator<SwiftNode> apply(SwiftNode p) { return p.getChildren().iterator(); } }); List<List<SwiftNode>> rows = IteratorUtils.iterator2List(rowIt); sortRow(dimensionSize, rows, sortList); return IteratorUtils.iterator2List(new MapperIterator<List<SwiftNode>, Row>(rows.iterator(), new Function<List<SwiftNode>, Row>() { @Override public Row apply(List<SwiftNode> p) { return SwiftNodeUtils.nodes2Row(p); } })); } }; return new FakeNodeQueryResultSet(operator, resultSet); } RowSortQuery(Query<QueryResultSet<SwiftNode>> query, List<Sort> sortList); @Override QueryResultSet<SwiftNode> getQueryResult(); }
RowSortQuery implements Query<QueryResultSet<SwiftNode>> { @Override public QueryResultSet<SwiftNode> getQueryResult() throws SQLException { QueryResultSet<SwiftNode> resultSet = query.getQueryResult(); SwiftRowOperator<Row> operator = new SwiftRowOperator<Row>() { @Override public List<Row> operate(SwiftNode node) { int dimensionSize = SwiftNodeUtils.getDimensionSize(node); Iterator<List<SwiftNode>> rowIt = new Tree2RowIterator<SwiftNode>(dimensionSize, node.getChildren().iterator(), new Function<SwiftNode, Iterator<SwiftNode>>() { @Override public Iterator<SwiftNode> apply(SwiftNode p) { return p.getChildren().iterator(); } }); List<List<SwiftNode>> rows = IteratorUtils.iterator2List(rowIt); sortRow(dimensionSize, rows, sortList); return IteratorUtils.iterator2List(new MapperIterator<List<SwiftNode>, Row>(rows.iterator(), new Function<List<SwiftNode>, Row>() { @Override public Row apply(List<SwiftNode> p) { return SwiftNodeUtils.nodes2Row(p); } })); } }; return new FakeNodeQueryResultSet(operator, resultSet); } RowSortQuery(Query<QueryResultSet<SwiftNode>> query, List<Sort> sortList); @Override QueryResultSet<SwiftNode> getQueryResult();  }