• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SQLJoinTableSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parserTable

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
private void parserTable(SQLTableSource table,TableFilter tFilter,boolean isOutJoin){
	if(table instanceof SQLJoinTableSource){
		SQLJoinTableSource table1=(SQLJoinTableSource)table;	
		joinType=table1.getJoinType().toString();
		if ((table1.getJoinType()==JoinType.COMMA)||(table1.getJoinType()==JoinType.JOIN)||(table1.getJoinType()==JoinType.INNER_JOIN)
				||(table1.getJoinType()==JoinType.LEFT_OUTER_JOIN))	{					
			tFilter=setTableFilter(tFilter,getTableFilter(table1.getLeft(),isOutJoin));
			if (tableFilter==null){
				tableFilter=tFilter;
			}
		}
		//parserTable(table1.getLeft());	//SQLExprTableSource
		parserTable(table1.getRight(),tFilter,true);
		
		SQLExpr expr=table1.getCondition();//SQLBinaryOpExpr
		parserJoinKey(expr);
	}
	else {
		tFilter=setTableFilter(tFilter,getTableFilter(table,isOutJoin));
		LOGGER.info("table "+table.toString() +" Alias:"+table.getAlias()+" Hints:"+table.getHints());
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:23,代码来源:JoinParser.java


示例2: isFromJoinOrUnionTable

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public static boolean isFromJoinOrUnionTable(SQLExpr expr) {
    SQLObject temp = expr;
    AtomicInteger counter = new AtomicInteger(10);
    while (temp != null &&
            !(expr instanceof SQLSelectQueryBlock) &&
            !(expr instanceof SQLJoinTableSource) && !(expr instanceof SQLUnionQuery) && counter.get() > 0) {
        counter.decrementAndGet();
        temp = temp.getParent();
        if (temp instanceof SQLSelectQueryBlock) {
            SQLTableSource from = ((SQLSelectQueryBlock) temp).getFrom();
            if (from instanceof SQLJoinTableSource || from instanceof SQLUnionQuery) {
                return true;
            }
        }
        if (temp instanceof SQLJoinTableSource || temp instanceof SQLUnionQuery) {
            return true;
        }
    }
    return false;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:21,代码来源:Util.java


示例3: clone

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public SQLJoinTableSource clone() {
    OracleSelectJoin x = new OracleSelectJoin();
    cloneTo(x);

    if (pivot != null) {
        x.setPivot(pivot.clone());
    }

    if (flashback != null) {
        x.setFlashback(flashback.clone());
    }

    return x;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:15,代码来源:OracleSelectJoin.java


示例4: innerRun

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public List<InternalSearchHit> innerRun() throws IOException, SqlParseException {

        Map<String, Map<String, List<Object>>> optimizationTermsFilterStructure =
                initOptimizationStructure();

        updateFirstTableLimitIfNeeded();
        TableInJoinRequestBuilder firstTableRequest = requestBuilder.getFirstTable();
        createKeyToResultsAndFillOptimizationStructure(optimizationTermsFilterStructure, firstTableRequest);

        TableInJoinRequestBuilder secondTableRequest = requestBuilder.getSecondTable();
        if (needToOptimize(optimizationTermsFilterStructure)) {
            updateRequestWithTermsFilter(optimizationTermsFilterStructure, secondTableRequest);
        }

        List<InternalSearchHit> combinedResult = createCombinedResults(secondTableRequest);

        int currentNumOfResults = combinedResult.size();
        int totalLimit = requestBuilder.getTotalLimit();
        if (requestBuilder.getJoinType() == SQLJoinTableSource.JoinType.LEFT_OUTER_JOIN && currentNumOfResults < totalLimit) {
            String t1Alias = requestBuilder.getFirstTable().getAlias();
            String t2Alias = requestBuilder.getSecondTable().getAlias();
            //todo: for each till Limit
            addUnmatchedResults(combinedResult, this.hashJoinComparisonStructure.getAllSearchHits(),
                    requestBuilder.getSecondTable().getReturnedFields(),
                    currentNumOfResults, totalLimit,
                    t1Alias,
                    t2Alias);
        }
        if(firstTableRequest.getOriginalSelect().isOrderdSelect()){
            Collections.sort(combinedResult,new Comparator<InternalSearchHit>() {
                @Override
                public int compare(InternalSearchHit o1, InternalSearchHit o2) {
                    return o1.docId() - o2.docId();
                }
            });

        }
        return combinedResult;
    }
 
开发者ID:mazhou,项目名称:es-sql,代码行数:40,代码来源:HashJoinElasticExecutor.java


示例5: updateFirstTableLimitIfNeeded

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
private void updateFirstTableLimitIfNeeded() {
    if (requestBuilder.getJoinType() == SQLJoinTableSource.JoinType.LEFT_OUTER_JOIN) {
        Integer firstTableHintLimit = requestBuilder.getFirstTable().getHintLimit();
        int totalLimit = requestBuilder.getTotalLimit();
        if (firstTableHintLimit == null || firstTableHintLimit > totalLimit) {
            requestBuilder.getFirstTable().setHintLimit(totalLimit);
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:10,代码来源:HashJoinElasticExecutor.java


示例6: combineResultsFromMultiResponses

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
private int combineResultsFromMultiResponses(List<InternalSearchHit> combinedResults, int totalLimit, int currentCombinedResults, SearchHit[] hits, int currentIndex, MultiSearchRequest multiSearchRequest) {
    MultiSearchResponse.Item[] responses = client.multiSearch(multiSearchRequest).actionGet().getResponses();
    String t1Alias = nestedLoopsRequest.getFirstTable().getAlias();
    String t2Alias = nestedLoopsRequest.getSecondTable().getAlias();

    for(int j =0 ; j < responses.length && currentCombinedResults < totalLimit ; j++){
        SearchHit hitFromFirstTable = hits[currentIndex+j];
        onlyReturnedFields(hitFromFirstTable.sourceAsMap(), nestedLoopsRequest.getFirstTable().getReturnedFields(),nestedLoopsRequest.getFirstTable().getOriginalSelect().isSelectAll());

        SearchResponse multiItemResponse = responses[j].getResponse();
        updateMetaSearchResults(multiItemResponse);

        //todo: if responseForHit.getHits.length < responseForHit.getTotalHits(). need to fetch more!
        SearchHits responseForHit = multiItemResponse.getHits();

        if(responseForHit.getHits().length == 0 && nestedLoopsRequest.getJoinType() == SQLJoinTableSource.JoinType.LEFT_OUTER_JOIN){
            InternalSearchHit unmachedResult = createUnmachedResult(nestedLoopsRequest.getSecondTable().getReturnedFields(), currentCombinedResults, t1Alias, t2Alias, hitFromFirstTable);
            combinedResults.add(unmachedResult);
            currentCombinedResults++;
            continue;
        }

        for(SearchHit matchedHit : responseForHit.getHits() ){
            InternalSearchHit searchHit = getMergedHit(currentCombinedResults, t1Alias, t2Alias, hitFromFirstTable, matchedHit);
            combinedResults.add(searchHit);
            currentCombinedResults++;
            if(currentCombinedResults >= totalLimit) break;
        }
        if(currentCombinedResults >= totalLimit) break;

    }
    return currentCombinedResults;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:34,代码来源:NestedLoopsElasticExecutor.java


示例7: innerRun

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public List<SearchHit> innerRun() throws IOException, SqlParseException {

        Map<String, Map<String, List<Object>>> optimizationTermsFilterStructure =
                initOptimizationStructure();

        updateFirstTableLimitIfNeeded();
        TableInJoinRequestBuilder firstTableRequest = requestBuilder.getFirstTable();
        createKeyToResultsAndFillOptimizationStructure(optimizationTermsFilterStructure, firstTableRequest);

        TableInJoinRequestBuilder secondTableRequest = requestBuilder.getSecondTable();
        if (needToOptimize(optimizationTermsFilterStructure)) {
            updateRequestWithTermsFilter(optimizationTermsFilterStructure, secondTableRequest);
        }

        List<SearchHit> combinedResult = createCombinedResults(secondTableRequest);

        int currentNumOfResults = combinedResult.size();
        int totalLimit = requestBuilder.getTotalLimit();
        if (requestBuilder.getJoinType() == SQLJoinTableSource.JoinType.LEFT_OUTER_JOIN && currentNumOfResults < totalLimit) {
            String t1Alias = requestBuilder.getFirstTable().getAlias();
            String t2Alias = requestBuilder.getSecondTable().getAlias();
            //todo: for each till Limit
            addUnmatchedResults(combinedResult, this.hashJoinComparisonStructure.getAllSearchHits(),
                    requestBuilder.getSecondTable().getReturnedFields(),
                    currentNumOfResults, totalLimit,
                    t1Alias,
                    t2Alias);
        }
        if(firstTableRequest.getOriginalSelect().isOrderdSelect()){
            Collections.sort(combinedResult,new Comparator<SearchHit>() {
                @Override
                public int compare(SearchHit o1, SearchHit o2) {
                    return o1.docId() - o2.docId();
                }
            });

        }
        return combinedResult;
    }
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:40,代码来源:HashJoinElasticExecutor.java


示例8: combineResultsFromMultiResponses

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
private int combineResultsFromMultiResponses(List<SearchHit> combinedResults, int totalLimit, int currentCombinedResults, SearchHit[] hits, int currentIndex, MultiSearchRequest multiSearchRequest) {
    MultiSearchResponse.Item[] responses = client.multiSearch(multiSearchRequest).actionGet().getResponses();
    String t1Alias = nestedLoopsRequest.getFirstTable().getAlias();
    String t2Alias = nestedLoopsRequest.getSecondTable().getAlias();

    for(int j =0 ; j < responses.length && currentCombinedResults < totalLimit ; j++){
        SearchHit hitFromFirstTable = hits[currentIndex+j];
        onlyReturnedFields(hitFromFirstTable.getSourceAsMap(), nestedLoopsRequest.getFirstTable().getReturnedFields(),nestedLoopsRequest.getFirstTable().getOriginalSelect().isSelectAll());

        SearchResponse multiItemResponse = responses[j].getResponse();
        updateMetaSearchResults(multiItemResponse);

        //todo: if responseForHit.getHits.length < responseForHit.getTotalHits(). need to fetch more!
        SearchHits responseForHit = multiItemResponse.getHits();

        if(responseForHit.getHits().length == 0 && nestedLoopsRequest.getJoinType() == SQLJoinTableSource.JoinType.LEFT_OUTER_JOIN){
            SearchHit unmachedResult = createUnmachedResult(nestedLoopsRequest.getSecondTable().getReturnedFields(), currentCombinedResults, t1Alias, t2Alias, hitFromFirstTable);
            combinedResults.add(unmachedResult);
            currentCombinedResults++;
            continue;
        }

        for(SearchHit matchedHit : responseForHit.getHits() ){
            SearchHit searchHit = getMergedHit(currentCombinedResults, t1Alias, t2Alias, hitFromFirstTable, matchedHit);
            combinedResults.add(searchHit);
            currentCombinedResults++;
            if(currentCombinedResults >= totalLimit) break;
        }
        if(currentCombinedResults >= totalLimit) break;

    }
    return currentCombinedResults;
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:34,代码来源:NestedLoopsElasticExecutor.java


示例9: getOwnerTableName

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
/**
     * 从between语句中获取字段所属的表名。
     * 对于容易出现ambiguous的(字段不知道到底属于哪个表),实际应用中必须使用别名来避免歧义
     * @param betweenExpr
     * @param column
     * @return
     */
    private String getOwnerTableName(SQLBetweenExpr betweenExpr,String column) {
        if(tableStats.size() == 1) {//只有一个表,直接返回这一个表名
            return tableStats.keySet().iterator().next().getName();
        } else if(tableStats.size() == 0) {//一个表都没有,返回空串
            return "";
        } else {//多个表名
            for (Column col : columns.keySet())
            {
                if(col.getName().equals(column)) {
                    return col.getTable();
                }
            }
//            for(Column col : columns) {//从columns中找表名
//                if(col.getName().equals(column)) {
//                    return col.getTable();
//                }
//            }

            //前面没找到表名的,自己从parent中解析

            SQLObject parent = betweenExpr.getParent();
            if(parent instanceof SQLBinaryOpExpr)
            {
                parent=parent.getParent();
            }

            if(parent instanceof MySqlSelectQueryBlock) {
                MySqlSelectQueryBlock select = (MySqlSelectQueryBlock) parent;
                if(select.getFrom() instanceof SQLJoinTableSource) {//多表连接
                    SQLJoinTableSource joinTableSource = (SQLJoinTableSource)select.getFrom();
                    return joinTableSource.getLeft().toString();//将left作为主表,此处有不严谨处,但也是实在没有办法,如果要准确,字段前带表名或者表的别名即可
                } else if(select.getFrom() instanceof SQLExprTableSource) {//单表
                    return select.getFrom().toString();
                }
            }
            else if(parent instanceof SQLUpdateStatement) {
                SQLUpdateStatement update = (SQLUpdateStatement) parent;
                return update.getTableName().getSimpleName();
            } else if(parent instanceof SQLDeleteStatement) {
                SQLDeleteStatement delete = (SQLDeleteStatement) parent;
                return delete.getTableName().getSimpleName();
            } else {
                
            }
        }
        return "";
    }
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:55,代码来源:MycatSchemaStatVisitor.java


示例10: join

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public SQLJoinTableSource join(SQLTableSource right, JoinType joinType, SQLExpr condition) {
    SQLJoinTableSource joined = new OracleSelectJoin(this, joinType, right, condition);
    return joined;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:5,代码来源:OracleSelectJoin.java


示例11: isJoin

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
private static boolean isJoin(SQLQueryExpr sqlExpr,String sql) {
    MySqlSelectQueryBlock query = (MySqlSelectQueryBlock) sqlExpr.getSubQuery().getQuery();
    return query.getFrom() instanceof  SQLJoinTableSource && sql.toLowerCase().contains("join");
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:5,代码来源:ESActionFactory.java


示例12: getJoinType

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public SQLJoinTableSource.JoinType getJoinType() {
    return joinType;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:4,代码来源:JoinRequestBuilder.java


示例13: setJoinType

import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource; //导入依赖的package包/类
public void setJoinType(SQLJoinTableSource.JoinType joinType) {
    this.joinType = joinType;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:4,代码来源:JoinRequestBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Git类代码示例发布时间:2022-05-23
下一篇:
Java SensorPort类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap