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


Java OLAPContext类代码示例

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


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

示例1: buildSqlResponse

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
private SQLResponse buildSqlResponse(Boolean isPushDown, List<List<String>> results,
        List<SelectedColumnMeta> columnMetas) {

    boolean isPartialResult = false;
    StringBuilder cubeSb = new StringBuilder();
    StringBuilder logSb = new StringBuilder("Processed rows for each storageContext: ");
    if (OLAPContext.getThreadLocalContexts() != null) { // contexts can be null in case of 'explain plan for'
        for (OLAPContext ctx : OLAPContext.getThreadLocalContexts()) {
            if (ctx.realization != null) {
                isPartialResult |= ctx.storageContext.isPartialResultReturned();
                if (cubeSb.length() > 0) {
                    cubeSb.append(",");
                }
                cubeSb.append(ctx.realization.getCanonicalName());
                logSb.append(ctx.storageContext.getProcessedRowCount()).append(" ");
            }
        }
    }
    logger.info(logSb.toString());

    SQLResponse response = new SQLResponse(columnMetas, results, cubeSb.toString(), 0, false, null, isPartialResult,
            isPushDown);
    response.setTotalScanCount(QueryContext.current().getScannedRows());
    response.setTotalScanBytes(QueryContext.current().getScannedBytes());
    return response;
}
 
开发者ID:apache,项目名称:kylin,代码行数:27,代码来源:QueryService.java

示例2: LookupTableEnumerator

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public LookupTableEnumerator(OLAPContext olapContext) {

        //TODO: assuming LookupTableEnumerator is handled by a cube
        CubeInstance cube = (CubeInstance) olapContext.realization;

        String lookupTableName = olapContext.firstTableScan.getTableName();
        DimensionDesc dim = cube.getDescriptor().findDimensionByTable(lookupTableName);
        if (dim == null)
            throw new IllegalStateException("No dimension with derived columns found for lookup table " + lookupTableName + ", cube desc " + cube.getDescriptor());

        CubeManager cubeMgr = CubeManager.getInstance(cube.getConfig());
        LookupStringTable table = cubeMgr.getLookupTable(cube.getLatestReadySegment(), dim);
        this.allRows = table.getAllRows();

        OLAPTable olapTable = (OLAPTable) olapContext.firstTableScan.getOlapTable();
        this.colDescs = olapTable.getExposedColumns();
        this.current = new Object[colDescs.size()];

        reset();
    }
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:21,代码来源:LookupTableEnumerator.java

示例3: selectRealization

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public static IRealization selectRealization(OLAPContext olapContext) throws NoRealizationFoundException {

        ProjectManager prjMgr = ProjectManager.getInstance(olapContext.olapSchema.getConfig());
        String factTableName = olapContext.firstTableScan.getTableName();
        String projectName = olapContext.olapSchema.getProjectName();
        List<IRealization> realizations = Lists.newArrayList(prjMgr.getRealizationsByTable(projectName, factTableName));
        logger.info("Find candidates by table " + factTableName + " and project=" + projectName + " : " + StringUtils.join(realizations, ","));

        //rule based realization selection, rules might reorder realizations or remove specific realization
        RoutingRule.applyRules(realizations, olapContext);

        if (realizations.size() == 0) {
            throw new NoRealizationFoundException("Can't find any realization. Please confirm with providers. SQL digest: " + olapContext.getSQLDigest().toString());
        }

        logger.info("The realizations remaining: ");
        logger.info(RoutingRule.getPrintableText(realizations));
        logger.info("The realization being chosen: " + realizations.get(0).getName());

        return realizations.get(0);
    }
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:22,代码来源:QueryRouter.java

示例4: apply

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
@Override
public void apply(List<IRealization> realizations, OLAPContext olapContext) {
    if (realizations.size() > 0) {
        IRealization first = realizations.get(0);

        if (first instanceof CubeInstance) {
            CubeInstance cube = (CubeInstance) first;
            adjustOLAPContextIfNecessary(cube, olapContext);
        }

        if (first instanceof IIInstance) {
            IIInstance ii = (IIInstance) first;
            adjustOLAPContextIfNecessary(ii, olapContext);
        }
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:17,代码来源:AdjustForWeeklyMatchedRealization.java

示例5: convertAggregationToDimension

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
private static void convertAggregationToDimension(OLAPContext olapContext, Collection<FunctionDesc> availableAggregations, String factTableName) {
    Iterator<FunctionDesc> it = olapContext.aggregations.iterator();
    while (it.hasNext()) {
        FunctionDesc functionDesc = it.next();
        if (!availableAggregations.contains(functionDesc)) {
            // try to convert the metric to dimension to see if it works
            TblColRef col = functionDesc.selectTblColRef(olapContext.metricsColumns, factTableName);
            functionDesc.setDimensionAsMetric(true);
            olapContext.rewriteFields.remove(functionDesc.getRewriteFieldName());
            if (col != null) {
                olapContext.metricsColumns.remove(col);
                olapContext.groupByColumns.add(col);
            }
            logger.info("Adjust OLAPContext for " + functionDesc);
        }
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:18,代码来源:AdjustForWeeklyMatchedRealization.java

示例6: executeQuery

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
protected SQLResponse executeQuery(String sql, SQLRequest sqlRequest) throws Exception {
    sql = sql.trim().replace(";", "");

    int limit = sqlRequest.getLimit();
    if (limit > 0 && !sql.toLowerCase().contains("limit")) {
        sql += (" LIMIT " + limit);
    }

    int offset = sqlRequest.getOffset();
    if (offset > 0 && !sql.toLowerCase().contains("offset")) {
        sql += (" OFFSET " + offset);
    }

    // add extra parameters into olap context, like acceptPartial
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(OLAPContext.PRM_ACCEPT_PARTIAL_RESULT, String.valueOf(sqlRequest.isAcceptPartial()));
    OLAPContext.setParameters(parameters);

    return execute(sql, sqlRequest);
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:21,代码来源:QueryService.java

示例7: intercept

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public void intercept(List<OLAPContext> contexts) {
    if (!isEnabled()) {
        return;
    }
    Collection<String> userIdentifierBlackList = getIdentifierBlackList(contexts);
    intercept(contexts, userIdentifierBlackList);
}
 
开发者ID:apache,项目名称:kylin,代码行数:8,代码来源:QueryInterceptor.java

示例8: tableFilter

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public static void tableFilter(List<OLAPContext> contexts, List<String> tableBlackList) {
        Set<String> tableWithSchema = getTableWithSchema(contexts);
        for (String tbl : tableBlackList) {
            if (tableWithSchema.contains(tbl.toUpperCase())) {
//                throw new kylin.AccessDeniedException("table:" + tbl);
                System.out.println("Access table:" + tbl + " denied");
            }
        }
    }
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:TableLevelACL.java

示例9: columnFilter

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public static void columnFilter(List<OLAPContext> contexts, List<String> columnBlackList) {
        List<String> allColWithTblAndSchema = getAllColWithTblAndSchema(contexts);
        for (String tbl : columnBlackList) {
            if (allColWithTblAndSchema.contains(tbl.toUpperCase())) {
//                throw new kylin.AccessDeniedException("table:" + tbl);
                System.out.println("Access table:" + tbl + " denied");
            }
        }
    }
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:TableLevelACL.java

示例10: getAllColWithTblAndSchema

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public static List<String> getAllColWithTblAndSchema(List<OLAPContext> contexts) {
    // all columns with table and DB. Like DB.TABLE.COLUMN
    List<String> allColWithTblAndSchema = new ArrayList<>();
    for (OLAPContext context : contexts) {
        Set<TblColRef> allColumns = context.allColumns;
        for (TblColRef tblColRef : allColumns) {
            allColWithTblAndSchema.add(tblColRef.getColumWithTableAndSchema());
        }
    }
    return allColWithTblAndSchema;
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:TableLevelACL.java

示例11: getTableWithSchema

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public static Set<String> getTableWithSchema(List<OLAPContext> contexts) {
    // all tables with DB, Like DB.TABLE
    Set<String> tableWithSchema = new HashSet<>();
    for (OLAPContext context : contexts) {
        Set<TblColRef> allColumns = context.allColumns;
        for (TblColRef tblColRef : allColumns) {
            tableWithSchema.add(tblColRef.getTableWithSchema());
        }
    }
    return tableWithSchema;
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:TableLevelACL.java

示例12: enumerator

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public Enumerator<Object[]> enumerator() {
    OLAPContext olapContext = OLAPContext.getThreadLocalContextById(contextId);
    switch (type) {
    case OLAP:
        return BackdoorToggles.getPrepareOnly() ? new EmptyEnumerator()
                : new OLAPEnumerator(olapContext, optiqContext);
    case LOOKUP_TABLE:
        return BackdoorToggles.getPrepareOnly() ? new EmptyEnumerator() : new LookupTableEnumerator(olapContext);
    case HIVE:
        return BackdoorToggles.getPrepareOnly() ? new EmptyEnumerator() : new HiveEnumerator(olapContext);
    default:
        throw new IllegalArgumentException("Wrong type " + type + "!");
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:15,代码来源:OLAPQuery.java

示例13: selectRealization

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
public static void selectRealization(List<OLAPContext> contexts) {
    // try different model for different context

    for (OLAPContext ctx : contexts) {
        ctx.realizationCheck = new RealizationCheck();
        attemptSelectRealization(ctx);
        Preconditions.checkNotNull(ctx.realization);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:RealizationChooser.java

示例14: matches

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
private static Map<String, String> matches(DataModelDesc model, OLAPContext ctx) {
    Map<String, String> result = Maps.newHashMap();

    TableRef firstTable = ctx.firstTableScan.getTableRef();

    Map<String, String> matchUp = null;

    if (ctx.joins.isEmpty() && model.isLookupTable(firstTable.getTableIdentity())) {
        // one lookup table
        String modelAlias = model.findFirstTable(firstTable.getTableIdentity()).getAlias();
        matchUp = ImmutableMap.of(firstTable.getAlias(), modelAlias);
    } else if (ctx.joins.size() != ctx.allTableScans.size() - 1) {
        // has hanging tables
        ctx.realizationCheck.addModelIncapableReason(model,
                RealizationCheck.IncapableReason.create(RealizationCheck.IncapableType.MODEL_BAD_JOIN_SEQUENCE));
        throw new IllegalStateException("Please adjust the sequence of join tables. " + toErrorMsg(ctx));
    } else {
        // normal big joins
        if (ctx.joinsTree == null) {
            ctx.joinsTree = new JoinsTree(firstTable, ctx.joins);
        }
        matchUp = ctx.joinsTree.matches(model.getJoinsTree(), result);
    }

    if (matchUp == null) {
        ctx.realizationCheck.addModelIncapableReason(model,
                RealizationCheck.IncapableReason.create(RealizationCheck.IncapableType.MODEL_UNMATCHED_JOIN));
        return null;
    }

    result.putAll(matchUp);

    ctx.realizationCheck.addCapableModel(model, result);
    return result;
}
 
开发者ID:apache,项目名称:kylin,代码行数:36,代码来源:RealizationChooser.java

示例15: adjustForDimensionAsMeasure

import org.apache.kylin.query.relnode.OLAPContext; //导入依赖的package包/类
private static void adjustForDimensionAsMeasure(Candidate chosen, OLAPContext olapContext) {
    CapabilityResult capability = chosen.getCapability();
    for (CapabilityInfluence inf : capability.influences) {
        // convert the metric to dimension
        if (inf instanceof DimensionAsMeasure) {
            FunctionDesc functionDesc = ((DimensionAsMeasure) inf).getMeasureFunction();
            functionDesc.setDimensionAsMetric(true);
            logger.info("Adjust DimensionAsMeasure for " + functionDesc);
        }
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:QueryRouter.java


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