本文整理了Java中org.apache.metamodel.query.Query.getSelectClause
方法的一些代码示例,展示了Query.getSelectClause
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getSelectClause
方法的具体详情如下:
包路径:org.apache.metamodel.query.Query
类名称:Query
方法名:getSelectClause
暂无
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
private static List<SelectItem> getSelectItems(List<Query> splitQueries) {
if (splitQueries.isEmpty()) {
return new ArrayList<SelectItem>(0);
}
return splitQueries.get(0).getSelectClause().getItems();
}
代码示例来源:origin: apache/metamodel
private static List<SelectItem> getSelectItems(List<Query> splitQueries) {
if (splitQueries.isEmpty()) {
return new ArrayList<SelectItem>(0);
}
return splitQueries.get(0).getSelectClause().getItems();
}
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
protected List<SelectItem> getSelectItems() {
return _query.getSelectClause().getItems();
}
代码示例来源:origin: apache/metamodel
protected List<SelectItem> getSelectItems() {
return _query.getSelectClause().getItems();
}
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
@Override
protected String rewriteSelectClause(Query query, SelectClause selectClause) {
String result = super.rewriteSelectClause(query, selectClause);
Integer maxRows = query.getMaxRows();
if (maxRows != null) {
if (query.getSelectClause().isDistinct()) {
result = "SELECT DISTINCT TOP " + maxRows + " " + result.substring("SELECT DISTINCT ".length());
} else {
result = "SELECT TOP " + maxRows + " " + result.substring("SELECT ".length());
}
}
return result;
}
代码示例来源:origin: apache/metamodel
@Override
protected String rewriteSelectClause(Query query, SelectClause selectClause) {
String result = super.rewriteSelectClause(query, selectClause);
Integer maxRows = query.getMaxRows();
if (maxRows != null) {
if (query.getSelectClause().isDistinct()) {
result = "SELECT DISTINCT TOP " + maxRows + " " + result.substring("SELECT DISTINCT ".length());
} else {
result = "SELECT TOP " + maxRows + " " + result.substring("SELECT ".length());
}
}
return result;
}
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
/**
* Gets the size of a row (in bytes).
*
* @param query
* the query that will yield the rows
* @return an integer representing the size of a row from the given query
* (in bytes).
*/
protected int getRowSize(Query query) {
List<SelectItem> items = query.getSelectClause().getItems();
int bytesPerRow = 0;
for (SelectItem selectItem : items) {
bytesPerRow += getValueSize(selectItem);
}
return bytesPerRow;
}
代码示例来源:origin: apache/metamodel
/**
* Gets the size of a row (in bytes).
*
* @param query
* the query that will yield the rows
* @return an integer representing the size of a row from the given query
* (in bytes).
*/
protected int getRowSize(Query query) {
List<SelectItem> items = query.getSelectClause().getItems();
int bytesPerRow = 0;
for (SelectItem selectItem : items) {
bytesPerRow += getValueSize(selectItem);
}
return bytesPerRow;
}
代码示例来源:origin: org.apache.metamodel/MetaModel-core
/**
* This method returns the select item of the given alias name.
*
* @param query
* @return
*/
public static SelectItem getSelectItemByAlias(Query query, String alias) {
List<SelectItem> selectItems = query.getSelectClause().getItems();
for (SelectItem selectItem : selectItems) {
if (selectItem.getAlias() != null && selectItem.getAlias().equals(alias)) {
return selectItem;
}
}
return null;
}
代码示例来源:origin: apache/metamodel
/**
* This method returns the select item of the given alias name.
*
* @param query
* @return
*/
public static SelectItem getSelectItemByAlias(Query query, String alias) {
List<SelectItem> selectItems = query.getSelectClause().getItems();
for (SelectItem selectItem : selectItems) {
if (selectItem.getAlias() != null && selectItem.getAlias().equals(alias)) {
return selectItem;
}
}
return null;
}
代码示例来源:origin: apache/metamodel
public String rewriteQuery(Query query) {
query = beforeRewrite(query);
final StringBuilder sb = new StringBuilder();
sb.append(rewriteSelectClause(query, query.getSelectClause()));
sb.append(rewriteFromClause(query, query.getFromClause()));
sb.append(rewriteWhereClause(query, query.getWhereClause()));
sb.append(rewriteGroupByClause(query, query.getGroupByClause()));
sb.append(rewriteHavingClause(query, query.getHavingClause()));
sb.append(rewriteOrderByClause(query, query.getOrderByClause()));
return sb.toString();
}
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
public String rewriteQuery(Query query) {
query = beforeRewrite(query);
final StringBuilder sb = new StringBuilder();
sb.append(rewriteSelectClause(query, query.getSelectClause()));
sb.append(rewriteFromClause(query, query.getFromClause()));
sb.append(rewriteWhereClause(query, query.getWhereClause()));
sb.append(rewriteGroupByClause(query, query.getGroupByClause()));
sb.append(rewriteHavingClause(query, query.getHavingClause()));
sb.append(rewriteOrderByClause(query, query.getOrderByClause()));
return sb.toString();
}
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
/**
* Gets whether a query is guaranteed to only yield a single row. Such
* queries are queries that only consist of aggregation functions and no
* group by clause.
*
* @param query
* @return
*/
private boolean isSingleRowQuery(Query query) {
if (!query.getGroupByClause().isEmpty()) {
return false;
}
List<SelectItem> items = query.getSelectClause().getItems();
for (SelectItem item : items) {
if (item.getAggregateFunction() == null) {
return false;
}
}
return true;
}
代码示例来源:origin: apache/metamodel
/**
* Gets whether a query is guaranteed to only yield a single row. Such
* queries are queries that only consist of aggregation functions and no
* group by clause.
*
* @param query
* @return
*/
private boolean isSingleRowQuery(Query query) {
if (!query.getGroupByClause().isEmpty()) {
return false;
}
List<SelectItem> items = query.getSelectClause().getItems();
for (SelectItem item : items) {
if (item.getAggregateFunction() == null) {
return false;
}
}
return true;
}
代码示例来源:origin: datacleaner/DataCleaner
public SimpleDictionary loadIntoMemory(final DatastoreConnection datastoreConnection) {
final DataContext dataContext = datastoreConnection.getDataContext();
final Column column = getColumn(datastoreConnection);
final Query query = dataContext.query().from(column.getTable()).select(column).toQuery();
if (datastoreConnection.getDatastore().getPerformanceCharacteristics().isQueryOptimizationPreferred()) {
query.getSelectClause().setDistinct(true);
}
final Set<String> values = new HashSet<>();
try (DataSet dataSet = dataContext.executeQuery(query)) {
while (dataSet.next()) {
final Object value = dataSet.getRow().getValue(0);
if (value != null) {
values.add(value.toString());
}
}
}
return new SimpleDictionary(getName(), values);
}
代码示例来源:origin: org.apache.metamodel/MetaModel-jdbc
private long getRowCount(Query q) {
q = q.clone();
SelectItem countAllItem = SelectItem.getCountAllItem();
if (q.getGroupByClause().getItemCount() > 0) {
q = new Query().from(new FromItem(q).setAlias("sq")).select(countAllItem);
} else {
q.getSelectClause().removeItems();
q.select(countAllItem);
}
Row row = MetaModelHelper.executeSingleRowQuery(_dataContext, q);
Number count = (Number) row.getValue(countAllItem);
return count.longValue();
}
代码示例来源:origin: apache/metamodel
private long getRowCount(Query q) {
q = q.clone();
SelectItem countAllItem = SelectItem.getCountAllItem();
if (q.getGroupByClause().getItemCount() > 0) {
q = new Query().from(new FromItem(q).setAlias("sq")).select(countAllItem);
} else {
q.getSelectClause().removeItems();
q.select(countAllItem);
}
Row row = MetaModelHelper.executeSingleRowQuery(_dataContext, q);
Number count = (Number) row.getValue(countAllItem);
return count.longValue();
}
代码示例来源:origin: datacleaner/DataCleaner
public void initialize() {
final Table table = _outputDataStreamJob.getOutputDataStream().getTable();
final Query query = new Query();
query.from(table).selectAll();
final List<SelectItem> selectItems = query.getSelectClause().getItems();
final ConsumeRowHandler consumeRowHandler = _publisher.createConsumeRowHandler();
_outputRowCollector = new OutputDataStreamRowCollector(_publisher, selectItems, consumeRowHandler);
final OutputDataStream outputDataStream = _outputDataStreamJob.getOutputDataStream();
_component.initializeOutputDataStream(outputDataStream, query, _outputRowCollector);
_publisher.getAnalysisListener()
.rowProcessingBegin(_publisher.getAnalysisJob(), _publisher.getRowProcessingMetrics());
}
代码示例来源:origin: org.apache.metamodel/MetaModel-core
public Query selectAll(final FromItem fromItem) {
if (fromItem.getTable() != null) {
final List<Column> columns = fromItem.getTable().getColumns();
for (final Column column : columns) {
select(column, fromItem);
}
} else if (fromItem.getJoin() != null) {
selectAll(fromItem.getLeftSide());
selectAll(fromItem.getRightSide());
} else if (fromItem.getSubQuery() != null) {
final List<SelectItem> items = fromItem.getSubQuery().getSelectClause().getItems();
for (final SelectItem subQuerySelectItem : items) {
select(new SelectItem(subQuerySelectItem, fromItem));
}
} else {
throw new MetaModelException("All select items ('*') not determinable with from item: " + fromItem);
}
return this;
}
代码示例来源:origin: apache/metamodel
public Query selectAll(final FromItem fromItem) {
if (fromItem.getTable() != null) {
final List<Column> columns = fromItem.getTable().getColumns();
for (final Column column : columns) {
select(column, fromItem);
}
} else if (fromItem.getJoin() != null) {
selectAll(fromItem.getLeftSide());
selectAll(fromItem.getRightSide());
} else if (fromItem.getSubQuery() != null) {
final List<SelectItem> items = fromItem.getSubQuery().getSelectClause().getItems();
for (final SelectItem subQuerySelectItem : items) {
select(new SelectItem(subQuerySelectItem, fromItem));
}
} else {
throw new MetaModelException("All select items ('*') not determinable with from item: " + fromItem);
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!