本文整理了Java中org.apache.gora.query.Query.getEndKey
方法的一些代码示例,展示了Query.getEndKey
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getEndKey
方法的具体详情如下:
包路径:org.apache.gora.query.Query
类名称:Query
方法名:getEndKey
暂无
代码示例来源:origin: apache/gora
private Range createRange(Query<K,T> query) {
Text startRow = null;
Text endRow = null;
if (query.getStartKey() != null)
startRow = new Text(toBytes(query.getStartKey()));
if (query.getEndKey() != null)
endRow = new Text(toBytes(query.getEndKey()));
return new Range(startRow, true, endRow, true);
}
代码示例来源:origin: apache/gora
/**
* Compute the query itself. Only make use of the keys for querying.
*
* @return a {@link DBObject} corresponding to the query
*/
public static DBObject toDBQuery(Query<?, ?> query) {
BasicDBObject q = new BasicDBObject();
if ((query.getStartKey() != null) && (query.getEndKey() != null)
&& query.getStartKey().equals(query.getEndKey())) {
q.put("_id", query.getStartKey());
} else {
if (query.getStartKey() != null)
q.put("_id", new BasicDBObject("$gte", query.getStartKey()));
if (query.getEndKey() != null)
q.put("_id", new BasicDBObject("$lte", query.getEndKey()));
}
return q;
}
代码示例来源:origin: apache/gora
/**
* Sets query to be performed
*
* @param pQuery
*/
public void setQuery(Query<K, T> pQuery){
this.setStartKey(query.getStartKey());
this.setEndKey(query.getEndKey());
}
代码示例来源:origin: org.apache.gora/gora-cassandra
public long deleteByQuery(Query query) {
List<Object> objectArrayList = new ArrayList<>();
if (query.getKey() == null && query.getEndKey() == null && query.getStartKey() == null) {
if (query.getFields() == null) {
client.getSession().execute(CassandraQueryFactory.getTruncateTableQuery(mapping));
} else {
LOG.error("Delete by Query is not supported for the Queries which didn't specify Query keys with fields.");
}
} else {
String cqlQuery = CassandraQueryFactory.getDeleteByQuery(mapping, query, objectArrayList);
ResultSet results;
SimpleStatement statement;
if (objectArrayList.size() == 0) {
statement = new SimpleStatement(cqlQuery);
} else {
statement = new SimpleStatement(cqlQuery, objectArrayList.toArray());
}
if (writeConsistencyLevel != null) {
statement.setConsistencyLevel(ConsistencyLevel.valueOf(writeConsistencyLevel));
}
results = client.getSession().execute(statement);
LOG.debug("Delete by Query was applied : " + results.wasApplied());
}
LOG.info("Delete By Query method doesn't return the deleted element count.");
return 0;
}
代码示例来源: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
/**
* Builds range query expression
*
*/
public void buildRangeExpression() {
DynamoDBScanExpression queryExpression = new DynamoDBScanExpression();
ComparisonOperator compOp = ComparisonOperator.BETWEEN;
// hash key range
Map<String, AttributeValue> hashAttrVals = buildHashKey(query.getStartKey());
Map<String, AttributeValue> endHashAttrVals = buildHashKey(query.getEndKey());
for (Entry<String, AttributeValue> en : hashAttrVals.entrySet()) {
Condition scanFilterHashCondition = new Condition().withComparisonOperator(
compOp.toString()).withAttributeValueList(en.getValue(), endHashAttrVals.get(en.getKey()));
queryExpression.addFilterCondition(en.getKey(), scanFilterHashCondition);
}
// range key range
Map<String, AttributeValue> rangeAttrVals = buildRangeKey(query.getStartKey());
Map<String, AttributeValue> endRangeAttrVals = buildRangeKey(query.getEndKey());
for (Entry<String, AttributeValue> en : rangeAttrVals.entrySet()) {
Condition scanFilterRangeCondition = new Condition().withComparisonOperator(
compOp.toString()).withAttributeValueList(en.getValue(), endRangeAttrVals.get(en.getKey()));
queryExpression.addFilterCondition(en.getKey(), scanFilterRangeCondition);
}
dynamoDBExpression = queryExpression;
}
代码示例来源: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
public long deleteByQuery(Query query) throws GoraException {
try {
List<Object> objectArrayList = new ArrayList<>();
if (query.getKey() == null && query.getEndKey() == null && query.getStartKey() == null) {
if (query.getFields() == null) {
client.getSession().execute(CassandraQueryFactory.getTruncateTableQuery(mapping));
} else {
LOG.error("Delete by Query is not supported for the Queries which didn't specify Query keys with fields.");
}
} else {
String cqlQuery = CassandraQueryFactory.getDeleteByQuery(mapping, query, objectArrayList);
ResultSet results;
SimpleStatement statement;
if (objectArrayList.size() == 0) {
statement = new SimpleStatement(cqlQuery);
} else {
statement = new SimpleStatement(cqlQuery, objectArrayList.toArray());
}
if (writeConsistencyLevel != null) {
statement.setConsistencyLevel(ConsistencyLevel.valueOf(writeConsistencyLevel));
}
results = client.getSession().execute(statement);
LOG.debug("Delete by Query was applied : " + results.wasApplied());
}
LOG.info("Delete By Query method doesn't return the deleted element count.");
return 0;
} catch (Exception e) {
throw new GoraException(e);
}
}
代码示例来源:origin: com.argonio.gora/gora-hbase
@Override
public org.apache.gora.query.Result<K, T> execute(Query<K, T> query){
try{
//check if query.fields is null
query.setFields(getFieldsToQuery(query.getFields()));
if(query.getStartKey() != null && query.getStartKey().equals(
query.getEndKey())) {
Get get = new Get(toBytes(query.getStartKey()));
addFields(get, query.getFields());
addTimeRange(get, query);
Result result = table.get(get);
return new HBaseGetResult<K,T>(this, query, result);
} else {
ResultScanner scanner = createScanner(query);
org.apache.gora.query.Result<K,T> result
= new HBaseScannerResult<K,T>(this, query, scanner);
return result;
}
}catch(IOException ex){
LOG.error(ex.getMessage());
LOG.error(ex.getStackTrace().toString());
return null;
}
}
代码示例来源:origin: apache/gora
private void defineQueryParams() {
if ((query.getStartKey() != null || query.getKey() != null)
&& query.getEndKey() != null) {
DynamoDBQuery.setType(RANGE_QUERY);
} else if (query.getKey() != null || query.getStartKey() != null) {
DynamoDBQuery.setType(SCAN_QUERY);
}
}
代码示例来源:origin: org.apache.gora/gora-jcache
@Override
public Result<K, T> execute(Query<K, T> query) {
K startKey = query.getStartKey();
K endKey = query.getEndKey();
if (startKey == null) {
if (!cacheEntryList.isEmpty()) {
startKey = (K) cacheEntryList.first();
}
}
if (endKey == null) {
if (!cacheEntryList.isEmpty()) {
endKey = (K) cacheEntryList.last();
}
}
query.setFields(getFieldsToQuery(query.getFields()));
ConcurrentSkipListSet<K> cacheEntrySubList = null;
try {
cacheEntrySubList = (ConcurrentSkipListSet<K>) cacheEntryList.subSet(startKey, true, endKey, true);
} catch (NullPointerException npe) {
LOG.error("NPE occurred while executing the query for JCacheStore. Hence returning empty entry set.", npe);
return new JCacheResult<>(this, query, new ConcurrentSkipListSet<K>());
}
return new JCacheResult<>(this, query, cacheEntrySubList);
}
代码示例来源:origin: com.argonio.gora/gora-hbase
public ResultScanner createScanner(Query<K, T> query) throws IOException {
final Scan scan = new Scan();
scan.setCaching(this.getScannerCaching()) ;
if (query.getStartKey() != null) {
scan.setStartRow(toBytes(query.getStartKey()));
}
if (query.getEndKey() != null) {
scan.setStopRow(toBytes(query.getEndKey()));
}
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: org.apache.gora/gora-core
public Result<K, T> execute(Query<K, T> query) {
K startKey = query.getStartKey();
K endKey = query.getEndKey();
if(startKey == null) {
if (!map.isEmpty()) {
代码示例来源: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: 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
@Override
public org.apache.gora.query.Result<K, T> execute(Query<K, T> query) throws GoraException {
try{
//check if query.fields is null
query.setFields(getFieldsToQuery(query.getFields()));
if(query.getStartKey() != null && query.getStartKey().equals(
query.getEndKey())) {
Get get = new Get(toBytes(query.getStartKey()));
addFields(get, query.getFields());
addTimeRange(get, query);
Result result = table.get(get);
return new HBaseGetResult<>(this, query, result);
} else {
ResultScanner scanner = createScanner(query);
org.apache.gora.query.Result<K,T> result
= new HBaseScannerResult<>(this, query, scanner);
return result;
}
}catch(IOException ex){
throw new GoraException(ex) ;
}
}
代码示例来源: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: com.argonio.gora/gora-cassandra
K endKey = query.getEndKey();
代码示例来源:origin: apache/gora
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
K startKey = query.getStartKey();
K endKey = query.getEndKey();
if (startKey == null) {
if (!cacheEntryList.isEmpty()) {
startKey = (K) cacheEntryList.first();
}
}
if (endKey == null) {
if (!cacheEntryList.isEmpty()) {
endKey = (K) cacheEntryList.last();
}
}
query.setFields(getFieldsToQuery(query.getFields()));
NavigableSet<K> cacheEntrySubList = null;
if (startKey != null && endKey != null) {
try {
cacheEntrySubList = cacheEntryList.subSet(startKey, true, endKey, true);
} catch (Exception e) {
throw new GoraException(e);
}
} else {
// Empty
cacheEntrySubList = Collections.emptyNavigableSet() ;
}
return new JCacheResult<>(this, query, cacheEntrySubList);
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!