當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。