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


Java ResultSet类代码示例

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


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

示例1: execute

import com.stratio.crossdata.common.data.ResultSet; //导入依赖的package包/类
@Override
public QueryResult execute(LogicalWorkflow workflow) throws ConnectorException {
    ResultSet resultSet = new ResultSet();
    Project project = (Project) workflow.getInitialSteps().iterator().next();
    IRCManager engine = managers.get(project.getClusterName());
    List<Message> messages = engine.getMessagesFromChannel(project.getTableName().getName());
    LogicalStep nextStep = project.getNextStep();
    while (nextStep != null) {
        if (nextStep instanceof Filter) {
            Filter filter = (Filter) nextStep;
            messages = this.applyFilter(messages, filter);
        } else if (nextStep instanceof Select) {
            Select select = (Select) nextStep;
            resultSet = computeResultSet(messages, select);
        }
        nextStep = nextStep.getNextStep();
    }

    return QueryResult.createQueryResult(resultSet);
}
 
开发者ID:aagea,项目名称:crossdata-connector-irc,代码行数:21,代码来源:IRCQueryEngine.java

示例2: computeResultSet

import com.stratio.crossdata.common.data.ResultSet; //导入依赖的package包/类
public ResultSet computeResultSet(List<Message> messages, Select select) {
    ResultSet resultSet = new ResultSet();
    for (Message message : messages) {
        resultSet.add(this.computeRow(message, select));
    }

    //Store the metadata information
    List<ColumnMetadata> columnMetadataList = new ArrayList<>();
    for (Map.Entry<ColumnName, ColumnType> aliasType : select.getTypeMapFromColumnName().entrySet()) {
        ColumnName columnName = aliasType.getKey();
        columnName.setAlias(select.getColumnMap().get(columnName));
        ColumnMetadata metadata = new ColumnMetadata(columnName, null, aliasType.getValue());
        columnMetadataList.add(metadata);
    }
    resultSet.setColumnMetadata(columnMetadataList);
    return resultSet;
}
 
开发者ID:aagea,项目名称:crossdata-connector-irc,代码行数:18,代码来源:IRCQueryEngine.java

示例3: 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

示例4: getOrderedRelationsTest

import com.stratio.crossdata.common.data.ResultSet; //导入依赖的package包/类
@Test
public void getOrderedRelationsTest() throws ExecutionException {
    ColumnSelector colSelectorLeft = new ColumnSelector(new ColumnName(CATALOG, TABLE, ROW1));
    ColumnSelector colSelectorRight = new ColumnSelector(new ColumnName(OTHER_CATALOG, TABLE, ROW2));
    Relation relation1 = new Relation(colSelectorLeft, Operator.EQ, colSelectorRight);
    Relation relation2 = new Relation(colSelectorRight, Operator.EQ, colSelectorLeft);
    List<Relation> listRelations = Arrays.asList(relation1, relation2);

    ResultSet resultSet = new ResultSet();
    ColumnMetadata colMetadata = metaMetadata(CATALOG, TABLE, ROW1, new ColumnType(DataType.INT));
    ColumnMetadata colMetadata2 = metaMetadata(CATALOG, TABLE, ROW2, new ColumnType(DataType.INT));
    resultSet.setColumnMetadata(Arrays.asList(colMetadata, colMetadata2));
    Set<Operations> operation = new HashSet<>();
    operation.add(Operations.PARTIAL_RESULTS);
    PartialResults partialResults = new PartialResults(operation);
    partialResults.setResults(resultSet);

    List<Relation> orderedRelations = QueryPartialResultsUtils.getOrderedRelations(partialResults, listRelations);
    assertEquals(listRelations.size(), orderedRelations.size());
    assertEquals(colSelectorLeft.getName().getQualifiedName(), ((ColumnSelector) orderedRelations.get(0)
                    .getLeftTerm()).getName().getQualifiedName());
    assertEquals(colSelectorLeft.getName().getQualifiedName(), ((ColumnSelector) orderedRelations.get(1)
                    .getLeftTerm()).getName().getQualifiedName());

}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:26,代码来源:QueryPartialResultsUtilsTest.java

示例5: createRDDFromResultSet

import com.stratio.crossdata.common.data.ResultSet; //导入依赖的package包/类
/**
 * @param deepContext
 * @param resSet
 * @return
 * @throws ExecutionException
 */
public static JavaRDD<Cells> createRDDFromResultSet(DeepSparkContext deepContext, ResultSet resSet)
		throws ExecutionException {
	List<Cells> cellsList = createCellsFromResultSet(resSet);
	if (cellsList == null) {
		throw new ExecutionException("An empty result set is not allowed in a join with partial results");
	}

	return deepContext.parallelize(cellsList);
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:16,代码来源:QueryPartialResultsUtils.java

示例6: createJoinPartialResults

import com.stratio.crossdata.common.data.ResultSet; //导入依赖的package包/类
public static Join createJoinPartialResults(String joinId, ColumnName leftSource, ColumnName rightSource,
                                            List<ColumnMetadata> columnMetadata, List<Row> rows) {

    ColumnSelector leftSelector = new ColumnSelector(leftSource);
    ColumnSelector rightSelector = new ColumnSelector(rightSource);

    Relation relation = new Relation(rightSelector, Operator.EQ, leftSelector);

    Set<Operations> operations = new HashSet<>();
    operations.add(Operations.SELECT_INNER_JOIN_PARTIALS_RESULTS);

    Join join = new Join(operations, joinId);
    join.addJoinRelation(relation);
    join.addSourceIdentifier(leftSource.getTableName().getQualifiedName());
    join.addSourceIdentifier(rightSource.getTableName().getQualifiedName());

    Set<Operations> operations2 = new HashSet<>();
    operations2.add(Operations.PARTIAL_RESULTS);

    PartialResults partialResults = new PartialResults(operations2);
    ResultSet resultSet = new ResultSet();
    resultSet.setColumnMetadata(columnMetadata);
    resultSet.setRows(rows);
    partialResults.setResults(resultSet);
    join.addPreviousSteps(partialResults);

    return join;
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:29,代码来源:LogicalWorkflowBuilder.java

示例7: createCellsFromResultSetTest

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

    ResultSet resultSet = new ResultSet();
    resultSet.setColumnMetadata(Arrays.asList(metaMetadata(CATALOG, TABLE, ROW1, new ColumnType(DataType.INT)),
                    metaMetadata(CATALOG, TABLE, ROW2, new ColumnType(DataType.VARCHAR))));
    resultSet.setRows(Arrays.asList(metaRow(ROW1, CELL1_VALUE1, ROW2, CELL1_VALUE2),
                    metaRow(ROW1, CELL2_VALUE1, ROW2, CELL2_VALUE2)));

    // PowerMockito.mockStatic(QueryPartialResultsUtils.class);
    // PowerMockito.when(
    // QueryPartialResultsUtils.buildCellsFromRow(Matchers.any(Row.class), Matchers.anyString(),
    // Matchers.anyString(), Matchers.anyListOf(ColumnMetadata.class))).thenReturn(
    // new Cells(CATALOG + "." + TABLE, Cell.create(ROW1, CELL1_VALUE1), Cell.create(ROW2,
    // CELL1_VALUE2)));

    List<Cells> cellsFromResultSet = QueryPartialResultsUtils.createCellsFromResultSet(resultSet);

    assertEquals(2, cellsFromResultSet.size());
    Cells cell1 = cellsFromResultSet.get(0);
    Cells cell2 = cellsFromResultSet.get(1);
    assertEquals(CATALOG + "." + TABLE, cell1.getnameSpace());
    assertEquals(CATALOG + "." + TABLE, cell2.getnameSpace());
    cell1.getCells(cell1.getnameSpace());
    boolean cellsOrdered = ((Integer) cell1.getCellByName(ROW1).getCellValue()).intValue() == CELL1_VALUE1;
    if (!cellsOrdered) {
        cell2 = cellsFromResultSet.get(0);
        cell1 = cellsFromResultSet.get(1);
    }
    assertEquals(CELL1_VALUE1, ((Integer) cell1.getCellByName(ROW1).getCellValue()));
    assertEquals(CELL1_VALUE2, (String) cell1.getCellByName(ROW2).getCellValue());
    assertEquals(CELL2_VALUE1, ((Integer) cell2.getCellByName(ROW1).getCellValue()));
    assertEquals(CELL2_VALUE2, (String) cell2.getCellByName(ROW2).getCellValue());

}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:36,代码来源:QueryPartialResultsUtilsTest.java

示例8: buildQueryResult

import com.stratio.crossdata.common.data.ResultSet; //导入依赖的package包/类
/**
 * Creates a {@link QueryResult} from the given {@link JavaRDD} based on the select information.
 * 
 * @param resultRdd
 *            Result {@link JavaRDD}.
 * @param selectStep
 *            {@link LogicalStep} containing the select information such as choosen columns and aliases.
 * 
 * @return {@link QueryResult} containing the result.
 */
private QueryResult buildQueryResult(JavaRDD<Cells> resultRdd, Select selectStep) {

	List<Cells> resultCells;

	if(orderBy!=null){
		resultCells = executeOrderBy(orderBy,resultRdd);
	}else{
           Long timeTake = System.currentTimeMillis();

		resultCells = resultRdd.take(limit);
           LOGGER.info("TIME - execute take("+limit+") in ["+(System.currentTimeMillis()-timeTake)+" ms]");
           if (LOGGER.isDebugEnabled()){
               LOGGER.debug("List<Cells> = RDD["+resultRdd.id()+"].take("+limit+")");
               LOGGER.debug("RDD["+resultRdd.id()+"].toDebugString()"+resultRdd.toDebugString());
           }
	}

	Map<Selector, String> columnMap = selectStep.getColumnMap();
	Map<Selector, ColumnType> columnType = selectStep.getTypeMapFromColumnName();


	// Adding column metadata information

       List<ColumnMetadata> resultMetadata = generateMetadata(columnMap, columnType);


       Long timeRows = System.currentTimeMillis();
       List<Row> resultRows = generateRowsResult(resultCells, columnMap);
       LOGGER.info("TIME - Generate rows result in ["+(System.currentTimeMillis()-timeRows)+" ms]");
       if (LOGGER.isDebugEnabled()){
           LOGGER.debug("The resultRows has been created with ["+resultRows.size()+"] rows");
       }



       ResultSet resultSet = new ResultSet();
       resultSet.setRows(resultRows);
       resultSet.setColumnMetadata(resultMetadata);
       QueryResult queryResult = QueryResult.createQueryResult(resultSet,0,true);
	return queryResult;
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:52,代码来源:QueryExecutor.java

示例9: 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

示例10: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。