Search in sources :

Example 1 with JCacheResult

use of org.apache.gora.jcache.query.JCacheResult in project gora by apache.

the class JCacheStore method execute.

@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);
}
Also used : GoraException(org.apache.gora.util.GoraException) JCacheResult(org.apache.gora.jcache.query.JCacheResult) GoraException(org.apache.gora.util.GoraException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 JCacheResult (org.apache.gora.jcache.query.JCacheResult)1 GoraException (org.apache.gora.util.GoraException)1