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


Java ColumnType类代码示例

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


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

示例1: computeResultSet

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的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

示例2: createSelect

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的package包/类
public static Select createSelect(List<ColumnName> columnsList, List<String> aliasNamesList) {

        Map<Selector, String> columnsAliases = new LinkedHashMap<>();
        Map<String, ColumnType> columnsTypes = new LinkedHashMap<>();
        Map<Selector, ColumnType> typeMapFromColumnName = new LinkedHashMap<>();

        Iterator<String> aliasesIt = aliasNamesList.iterator();
        for (ColumnName column : columnsList) {
            ColumnSelector columnSelector = new ColumnSelector(column);
            columnsAliases.put(columnSelector, aliasesIt.next());

            columnsTypes.put(column.getQualifiedName(), new ColumnType(DataType.TEXT));
            typeMapFromColumnName.put(columnSelector, new ColumnType(DataType.TEXT));
        }

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

        return new Select(operations, columnsAliases, columnsTypes, typeMapFromColumnName);
    }
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:21,代码来源:LogicalWorkflowBuilder.java

示例3: getOrderedRelationsTest

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的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

示例4: createSelect

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的package包/类
private Select createSelect() {

        ColumnName columnName = new ColumnName("catalogname", "tablename1", "column1Name");
        ColumnSelector columnSelector = new ColumnSelector(columnName);
        columnSelector.setAlias("nameAlias");
        Map<Selector, String> columnsAliases = new HashMap<>();
        columnsAliases.put(columnSelector, "nameAlias");

        Map<String, ColumnType> columnsTypes = new HashMap<>();
        columnsTypes.put("catalogname.tablename1.column1Name", new ColumnType(DataType.BIGINT));

        Map<Selector, ColumnType> typeMapFromColumnName = new LinkedHashMap<>();

        typeMapFromColumnName.put(columnSelector, new ColumnType(DataType.BIGINT));

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

        return new Select(operations, columnsAliases, columnsTypes, typeMapFromColumnName);
    }
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:21,代码来源:QueryExecutorTest.java

示例5: generateMetadata

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的package包/类
private List<ColumnMetadata> generateMetadata(Map<Selector, String> columnMap,
        Map<Selector, ColumnType> columnType) {
    Long timeMetadata = System.currentTimeMillis();
    if (LOGGER.isDebugEnabled()){
        LOGGER.debug("Metadata generation starting");
    }
    List<ColumnMetadata> resultMetadata = new LinkedList<>();
    Object[] parameters = {};
    for (Entry<Selector, String> columnItem : columnMap.entrySet()) {
        if (LOGGER.isDebugEnabled()){
            LOGGER.debug("Generate metadata from ["+columnItem.getKey()+"]");
        }
        ColumnName columnName = columnItem.getKey().getColumnName();
        String columnAlias = columnItem.getValue();
        columnName.setAlias(columnAlias);

        ColumnMetadata columnMetadata = new ColumnMetadata(columnName, parameters, columnType.get(columnName));

        resultMetadata.add(columnMetadata);
        if (LOGGER.isDebugEnabled()){
            LOGGER.debug("columnName ["+columnName+"] : columnAlias ["+columnAlias+"] : columnType ["+columnType
                    .get(columnName)+"]");
        }
    }

    LOGGER.info("TIME - Generate Metadata) in ["+(System.currentTimeMillis()-timeMetadata)+" ms]");
    if (LOGGER.isDebugEnabled()){
        LOGGER.debug("The metadata has been created");
    }
    return resultMetadata;
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:32,代码来源:QueryExecutor.java

示例6: createCellsFromResultSetTest

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的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

示例7: buildQueryResult

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的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

示例8: metaMetadata

import com.stratio.crossdata.common.metadata.ColumnType; //导入依赖的package包/类
/**
 * @param catalog
 * @param table
 * @param row
 * @param i
 * @return ColumnMetadata
 */
private ColumnMetadata metaMetadata(String catalog, String table, String row, ColumnType i) {

    Object[] params = {};
    return new ColumnMetadata(new ColumnName(catalog, table, row), params, i);
}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:13,代码来源:QueryPartialResultsUtilsTest.java


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