当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.getRows方法代码示例

本文整理汇总了Java中com.stratio.crossdata.common.data.ResultSet.getRows方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getRows方法的具体用法?Java ResultSet.getRows怎么用?Java ResultSet.getRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.stratio.crossdata.common.data.ResultSet的用法示例。


在下文中一共展示了ResultSet.getRows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCellsFromResultSet

import com.stratio.crossdata.common.data.ResultSet; //导入方法依赖的package包/类
/**
 * @param resultSet
 * @return
 * @throws ExecutionException
 */
public static List<Cells> createCellsFromResultSet(ResultSet resultSet) throws ExecutionException {
	List<Row> rows = resultSet.getRows();
	List<Cells> cellsList = null;
	if (rows != null && rows.size() > 0) {
		cellsList = new ArrayList<Cells>(rows.size());
		if (cellsList != null) {
			List<ColumnMetadata> columnsMetadata = resultSet.getColumnMetadata();
			String qualifiedName = columnsMetadata.get(0).getName().getTableName().getQualifiedName();
			String[] arrNames = qualifiedName.split("\\.");
			if (arrNames.length != 2) {
				throw new ExecutionException(
						"Table name must be a qualified name: [catalog_name.table_name] but is: "
								+ columnsMetadata.get(0).getName().getTableName().getQualifiedName());
			}
			String catalogName = arrNames[0];
			String tableName = arrNames[1];
			for (Row row : rows) {
				cellsList.add(buildCellsFromRow(row, catalogName, tableName, columnsMetadata));
			}
		}
	}
	return cellsList;
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:29,代码来源:QueryPartialResultsUtils.java

示例2: testPartialResultJoinTest

import com.stratio.crossdata.common.data.ResultSet; //导入方法依赖的package包/类
@Test
public void testPartialResultJoinTest() throws ConnectorException {

    // Input data
    List<LogicalStep> stepList = new LinkedList<>();
    Project projectLeft = createProject(CASSANDRA_CLUSTERNAME_CONSTANT, KEYSPACE, MYTABLE1_CONSTANT,
                    Arrays.asList(ARTIST_CONSTANT, DESCRIPTION_CONSTANT, TITLE_CONSTANT, YEAR_CONSTANT));

    ResultSet resultSet = deepQueryEngine.execute(selectLogicalWorkflow()).getResultSet();
    List<ColumnMetadata> columnMetadata = resultSet.getColumnMetadata();
    List<Row> rows = resultSet.getRows();

    Join join = createJoinPartialResults("joinId", createColumn(KEYSPACE, MYTABLE1_CONSTANT, ARTIST_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT), columnMetadata, rows);

    join.setNextStep(createSelect(Arrays.asList(createColumn(KEYSPACE, MYTABLE1_CONSTANT, ARTIST_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE2_CONSTANT, AGE_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE1_CONSTANT, DESCRIPTION_CONSTANT)), Arrays.asList(
                    ARTIST_ALIAS_CONSTANT, ARTIST_ALIAS2_CONSTANT, DESCRIPTION_ALIAS_CONSTANT, AGE_ALIAS_CONSTANT)));
    projectLeft.setNextStep(join);

    // One initial steps
    stepList.add(projectLeft);

    LogicalWorkflow logicalWorkflow = new LogicalWorkflow(stepList);

    // Execution
    QueryResult result = deepQueryEngine.execute(logicalWorkflow);

    // Assertions
    List<ColumnMetadata> columnsMetadata = result.getResultSet().getColumnMetadata();
    List<Row> rowsList = result.getResultSet().getRows();

    // Checking results number
    assertEquals("Wrong number of rows metadata", 4, columnsMetadata.size());
    assertEquals("Wrong number of rows", 72, rowsList.size());

    // Checking metadata
    assertEquals("Author expected", ARTIST_ALIAS_CONSTANT, columnsMetadata.get(0).getName().getAlias());
    assertEquals("Author expected", ARTIST_ALIAS2_CONSTANT, columnsMetadata.get(1).getName().getAlias());
    assertEquals("Author expected", DESCRIPTION_ALIAS_CONSTANT, columnsMetadata.get(2).getName().getAlias());
    assertEquals("Author expected", AGE_ALIAS_CONSTANT, columnsMetadata.get(3).getName().getAlias());
    assertEquals("mytable1 expected", KEYSPACE + "." + MYTABLE1_CONSTANT, columnsMetadata.get(0).getName()
                    .getTableName().getQualifiedName());
    assertEquals("mytable2 expected", KEYSPACE + "." + MYTABLE2_CONSTANT, columnsMetadata.get(1).getName()
                    .getTableName().getQualifiedName());
    assertEquals("mytable2 expected", KEYSPACE + "." + MYTABLE2_CONSTANT, columnsMetadata.get(2).getName()
                    .getTableName().getQualifiedName());
    assertEquals("mytable1 expected", KEYSPACE + "." + MYTABLE1_CONSTANT, columnsMetadata.get(3).getName()
                    .getTableName().getQualifiedName());

    // Checking rows
    for (Row row : rowsList) {
        assertEquals("Wrong number of columns in the row", 4, row.size());
        assertNotNull("Expecting author column in row", row.getCell(ARTIST_ALIAS_CONSTANT));
        assertNotNull("Expecting author column in row", row.getCell(ARTIST_ALIAS2_CONSTANT));
        assertNotNull("Expecting author column in row", row.getCell(DESCRIPTION_ALIAS_CONSTANT));
        assertNotNull("Expecting author column in row", row.getCell(AGE_ALIAS_CONSTANT));
    }
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:62,代码来源:JoinResultSetAndCassandraFT.java

示例3: testPartialResultJoinTestWithAlias

import com.stratio.crossdata.common.data.ResultSet; //导入方法依赖的package包/类
@Test
public void testPartialResultJoinTestWithAlias() throws ConnectorException {

    // Input data
    List<LogicalStep> stepList = new LinkedList<>();
    Project projectLeft = createProject(CASSANDRA_CLUSTERNAME_CONSTANT, KEYSPACE, MYTABLE1_CONSTANT,
                    Arrays.asList(ARTIST_CONSTANT, DESCRIPTION_CONSTANT, TITLE_CONSTANT, YEAR_CONSTANT));

    ResultSet resultSet = deepQueryEngine.execute(selectLogicalWorkflowWithAlias()).getResultSet();
    List<ColumnMetadata> columnMetadata = resultSet.getColumnMetadata();
    List<Row> rows = resultSet.getRows();

    Join join = createJoinPartialResults("joinId", createColumn(KEYSPACE, MYTABLE1_CONSTANT, ARTIST_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT), columnMetadata, rows);

    join.setNextStep(createSelect(Arrays.asList(createColumn(KEYSPACE, MYTABLE1_CONSTANT, ARTIST_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE2_CONSTANT, AGE_CONSTANT),
                    createColumn(KEYSPACE, MYTABLE1_CONSTANT, DESCRIPTION_CONSTANT)), Arrays.asList(
                    ARTIST_ALIAS_CONSTANT, ARTIST_ALIAS2_CONSTANT, DESCRIPTION_ALIAS_CONSTANT, AGE_ALIAS_CONSTANT)));
    projectLeft.setNextStep(join);

    // One initial steps
    stepList.add(projectLeft);

    LogicalWorkflow logicalWorkflow = new LogicalWorkflow(stepList);

    // Execution
    QueryResult result = deepQueryEngine.execute(logicalWorkflow);

    // Assertions
    List<ColumnMetadata> columnsMetadata = result.getResultSet().getColumnMetadata();
    List<Row> rowsList = result.getResultSet().getRows();

    // Checking results number
    assertEquals("Wrong number of rows metadata", 4, columnsMetadata.size());
    assertEquals("Wrong number of rows", 72, rowsList.size());

    // Checking metadata
    assertEquals("Author expected", ARTIST_ALIAS_CONSTANT, columnsMetadata.get(0).getName().getAlias());
    assertEquals("Author expected", ARTIST_ALIAS2_CONSTANT, columnsMetadata.get(1).getName().getAlias());
    assertEquals("Author expected", DESCRIPTION_ALIAS_CONSTANT, columnsMetadata.get(2).getName().getAlias());
    assertEquals("Author expected", AGE_ALIAS_CONSTANT, columnsMetadata.get(3).getName().getAlias());
    assertEquals("mytable1 expected", KEYSPACE + "." + MYTABLE1_CONSTANT, columnsMetadata.get(0).getName()
                    .getTableName().getQualifiedName());
    assertEquals("mytable2 expected", KEYSPACE + "." + MYTABLE2_CONSTANT, columnsMetadata.get(1).getName()
                    .getTableName().getQualifiedName());
    assertEquals("mytable2 expected", KEYSPACE + "." + MYTABLE2_CONSTANT, columnsMetadata.get(2).getName()
                    .getTableName().getQualifiedName());
    assertEquals("mytable1 expected", KEYSPACE + "." + MYTABLE1_CONSTANT, columnsMetadata.get(3).getName()
                    .getTableName().getQualifiedName());

    // Checking rows
    for (Row row : rowsList) {
        assertEquals("Wrong number of columns in the row", 4, row.size());
        assertNotNull("Expecting author column in row", row.getCell(ARTIST_ALIAS_CONSTANT));
        assertNotNull("Expecting author column in row", row.getCell(ARTIST_ALIAS2_CONSTANT));
        assertNotNull("Expecting author column in row", row.getCell(DESCRIPTION_ALIAS_CONSTANT));
        assertNotNull("Expecting author column in row", row.getCell(AGE_ALIAS_CONSTANT));
    }
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:62,代码来源:JoinResultSetAndCassandraFT.java


注:本文中的com.stratio.crossdata.common.data.ResultSet.getRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。