本文整理了Java中org.apache.gora.query.Query.getLimit
方法的一些代码示例,展示了Query.getLimit
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getLimit
方法的具体详情如下:
包路径:org.apache.gora.query.Query
类名称:Query
方法名:getLimit
[英]Returns the maximum number of results
[中]返回最大结果数
代码示例来源:origin: org.apache.gora/gora-core
@Override
/**
* Gets the results limit number used
*/
public long getLimit() {
return baseQuery.getLimit();
}
代码示例来源:origin: apache/gora
public ResultBase(DataStore<K,T> dataStore, Query<K,T> query) {
this.dataStore = dataStore;
this.query = query;
this.limit = query.getLimit();
}
代码示例来源:origin: apache/gora
/**
* Constructor
* @param dataStore
* @param query
*/
public ResultWSBase(DataStore<K,T> dataStore, Query<K,T> query) {
this.dataStore = dataStore;
this.query = query;
this.limit = query.getLimit();
}
代码示例来源:origin: org.apache.gora/gora-core
/**
* Constructor
* @param dataStore
* @param query
*/
public ResultWSBase(DataStore<K,T> dataStore, Query<K,T> query) {
this.dataStore = dataStore;
this.query = query;
this.limit = query.getLimit();
}
代码示例来源:origin: org.apache.gora/gora-core
public ResultBase(DataStore<K,T> dataStore, Query<K,T> query) {
this.dataStore = dataStore;
this.query = query;
this.limit = query.getLimit();
}
代码示例来源:origin: apache/gora
@Override
/**
* Gets the results limit number used
*/
public long getLimit() {
return baseQuery.getLimit();
}
代码示例来源:origin: org.apache.gora/gora-core
@Override
public long getLimit() {
return baseQuery.getLimit();
}
代码示例来源:origin: apache/gora
@Override
public long getLimit() {
return baseQuery.getLimit();
}
代码示例来源:origin: apache/gora
@Override
public long deleteByQuery(Query<K, T> query) throws GoraException {
String deleteQuery;
if (query.getFields() != null && query.getFields().length < igniteMapping.getFields().size()) {
List<String> dbFields = new ArrayList<>();
for (String af : query.getFields()) {
dbFields.add(igniteMapping.getFields().get(af).getName());
}
deleteQuery = IgniteSQLBuilder.createDeleteQueryWithFields(igniteMapping, dbFields);
} else {
deleteQuery = IgniteSQLBuilder.createDeleteQueryMultipleRecords(igniteMapping);
}
String selectQueryWhere = IgniteSQLBuilder.createWhereClause(igniteMapping, query.getStartKey(), query.getEndKey(), query.getLimit());
try (PreparedStatement stmt = connection.prepareStatement(deleteQuery + selectQueryWhere)) {
IgniteSQLBuilder.fillWhereClause(stmt, query.getStartKey(), query.getEndKey());
stmt.executeUpdate();
return 0;
} catch (SQLException ex) {
throw new GoraException(ex);
}
}
代码示例来源:origin: apache/gora
/**
* This method returns CQL Query for execute method. This CQL contains a Select Query to retrieve data from the table
*
* @param mapping Cassandra Mapping {@link CassandraMapping}
* @param cassandraQuery Query {@link CassandraQuery}
* @param objects object list
* @return CQL Query
*/
static String getExecuteQuery(CassandraMapping mapping, Query cassandraQuery, List<Object> objects, String[] fields) {
long limit = cassandraQuery.getLimit();
Select select = QueryBuilder.select(getColumnNames(mapping, Arrays.asList(fields))).from(mapping.getKeySpace().getName(), mapping.getCoreName());
if (limit > 0) {
select = select.limit((int) limit);
}
if (Boolean.parseBoolean(mapping.getProperty("allowFiltering"))) {
select.allowFiltering();
}
return processQuery(cassandraQuery, select, mapping, objects);
}
代码示例来源:origin: org.apache.gora/gora-cassandra
/**
* This method returns CQL Query for execute method. This CQL contains a Select Query to retrieve data from the table
*
* @param mapping Cassandra Mapping {@link CassandraMapping}
* @param cassandraQuery Query {@link CassandraQuery}
* @param objects object list
* @return CQL Query
*/
static String getExecuteQuery(CassandraMapping mapping, Query cassandraQuery, List<Object> objects, String[] fields) {
long limit = cassandraQuery.getLimit();
Select select = QueryBuilder.select(getColumnNames(mapping, Arrays.asList(fields))).from(mapping.getKeySpace().getName(), mapping.getCoreName());
if (limit > 0) {
select = select.limit((int) limit);
}
if (Boolean.parseBoolean(mapping.getProperty("allowFiltering"))) {
select.allowFiltering();
}
return processQuery(cassandraQuery, select, mapping, objects);
}
代码示例来源:origin: apache/gora
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
String[] fields = getFieldsToQuery(query.getFields());
//Avro fields to Ignite fields
List<String> dbFields = new ArrayList<>();
for (String aField : fields) {
dbFields.add(igniteMapping.getFields().get(aField).getName());
}
String selectQuery = IgniteSQLBuilder.createSelectQuery(igniteMapping, dbFields);
String selectQueryWhere = IgniteSQLBuilder.createWhereClause(igniteMapping, query.getStartKey(), query.getEndKey(), query.getLimit());
try (PreparedStatement stmt = connection.prepareStatement(selectQuery + selectQueryWhere)) {
RowSetFactory factory = RowSetProvider.newFactory();
CachedRowSet rowset = factory.createCachedRowSet();
IgniteSQLBuilder.fillWhereClause(stmt, query.getStartKey(), query.getEndKey());
ResultSet executeQuery = stmt.executeQuery();
rowset.populate(executeQuery);
IgniteResult<K, T> igniteResult = new IgniteResult<>(this, query, rowset);
return igniteResult;
} catch (SQLException ex) {
throw new GoraException(ex);
}
}
代码示例来源:origin: apache/gora
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
try{
if (counter.isModulo()) {
boolean firstBatch = (this.result == null);
if (! firstBatch) {
this.query.setStartKey(this.result.getKey());
if (this.query.getLimit() == counter.getRecordsMax()) {
this.query.setLimit(counter.getRecordsMax() + 1);
}
}
if (this.result != null) {
this.result.close();
}
executeQuery();
if (! firstBatch) {
// skip first result
this.result.next();
}
}
counter.increment();
return this.result.next();
}
catch(Exception e){
LOG.error("Error reading Gora records: {}", e.getMessage());
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.gora/gora-core
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
try{
if (counter.isModulo()) {
boolean firstBatch = (this.result == null);
if (! firstBatch) {
this.query.setStartKey(this.result.getKey());
if (this.query.getLimit() == counter.getRecordsMax()) {
this.query.setLimit(counter.getRecordsMax() + 1);
}
}
if (this.result != null) {
this.result.close();
}
executeQuery();
if (! firstBatch) {
// skip first result
this.result.next();
}
}
counter.increment();
return this.result.next();
}
catch(Exception e){
LOG.error("Error reading Gora records: {}", e.getMessage());
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.gora/gora-couchdb
/**
* Execute the query and return the result.
*/
@Override
public Result<K, T> execute(Query<K, T> query) {
query.setFields(getFieldsToQuery(query.getFields()));
final ViewQuery viewQuery = new ViewQuery()
.allDocs()
.includeDocs(true)
.startKey(query.getStartKey())
.endKey(query.getEndKey())
.limit(Ints.checkedCast(query.getLimit())); //FIXME GORA have long value but ektorp client use integer
CouchDBResult<K, T> couchDBResult = new CouchDBResult<>(this, query, db.queryView(viewQuery, Map.class));
return couchDBResult;
}
代码示例来源:origin: apache/gora
/**
* Execute the query and return the result.
*/
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
try {
query.setFields(getFieldsToQuery(query.getFields()));
final ViewQuery viewQuery = new ViewQuery()
.allDocs()
.includeDocs(true)
.startKey(query.getStartKey())
.endKey(query.getEndKey())
.limit(Ints.checkedCast(query.getLimit())); //FIXME GORA have long value but ektorp client use integer
CouchDBResult<K, T> couchDBResult = new CouchDBResult<>(this, query, db.queryView(viewQuery, Map.class));
return couchDBResult;
} catch (Exception e) {
throw new GoraException(e) ;
}
}
代码示例来源:origin: apache/gora
public ResultScanner createScanner(Query<K, T> query) throws IOException {
final Scan scan = new Scan();
scan.setMaxResultSize(query.getLimit());
scan.setCaching(this.getScannerCaching()) ;
if (query.getStartKey() != null) {
scan.setStartRow(toBytes(query.getStartKey()));
}
if (query.getEndKey() != null) {
// In HBase the end key is exclusive, so we add a trail zero to make it inclusive
// as the Gora's query interface declares.
byte[] endKey = toBytes(query.getEndKey());
byte[] inclusiveEndKey = Arrays.copyOf(endKey, endKey.length+1);
scan.setStopRow(inclusiveEndKey);
}
addFields(scan, query);
if (query.getFilter() != null) {
boolean succeeded = filterUtil.setFilter(scan, query.getFilter(), this);
if (succeeded) {
// don't need local filter
query.setLocalFilterEnabled(false);
}
}
return table.getScanner(scan);
}
代码示例来源:origin: com.argonio.gora/gora-cassandra
int limit = (int) query.getLimit();
if (limit < 1) {
limit = Integer.MAX_VALUE;
代码示例来源:origin: apache/gora
/**
* {@inheritDoc}
*/
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
String[] fields = getFieldsToQuery(query.getFields());
OrientDBQuery dataStoreQuery;
if (query instanceof OrientDBQuery) {
dataStoreQuery = ((OrientDBQuery) query);
} else {
dataStoreQuery = (OrientDBQuery) ((PartitionQueryImpl<K, T>) query).getBaseQuery();
}
dataStoreQuery.populateOrientDBQuery(orientDBMapping, fields, getFields());
try (ODatabaseDocumentTx selectTx = connectionPool.acquire()) {
selectTx.activateOnCurrentThread();
OConcurrentResultSet<ODocument> result = selectTx.command(dataStoreQuery.getOrientDBQuery())
.execute(dataStoreQuery.getParams());
result.setLimit((int) query.getLimit());
return new OrientDBResult<K, T>(this, query, result);
} catch (Exception e) {
throw new GoraException(e);
}
}
代码示例来源:origin: com.argonio.gora/gora-cassandra
public List<SuperRow<K, String, ByteBuffer, ByteBuffer>> executeSuper(CassandraQuery<K, T> cassandraQuery, String family) {
String[] columnNames = cassandraQuery.getColumns(family);
Query<K, T> query = cassandraQuery.getQuery();
int limit = (int) query.getLimit();
if (limit < 1) {
limit = Integer.MAX_VALUE;
}
K startKey = query.getStartKey();
K endKey = query.getEndKey();
RangeSuperSlicesQuery<K, String, ByteBuffer, ByteBuffer> rangeSuperSlicesQuery = HFactory.createRangeSuperSlicesQuery
(this.keyspace, this.keySerializer, StringSerializer.get(), ByteBufferSerializer.get(), ByteBufferSerializer.get());
rangeSuperSlicesQuery.setColumnFamily(family);
rangeSuperSlicesQuery.setKeys(startKey, endKey);
rangeSuperSlicesQuery.setRange("", "", false, GoraRecordReader.BUFFER_LIMIT_READ_VALUE);
rangeSuperSlicesQuery.setRowCount(limit);
rangeSuperSlicesQuery.setColumnNames(columnNames);
QueryResult<OrderedSuperRows<K, String, ByteBuffer, ByteBuffer>> queryResult = rangeSuperSlicesQuery.execute();
OrderedSuperRows<K, String, ByteBuffer, ByteBuffer> orderedRows = queryResult.get();
return orderedRows.getList();
}
内容来源于网络,如有侵权,请联系作者删除!