Search in sources :

Example 1 with InfinispanQuery

use of org.apache.gora.infinispan.query.InfinispanQuery in project gora by apache.

the class InfinispanStore method deleteByQuery.

@Override
public long deleteByQuery(Query<K, T> query) throws GoraException {
    try {
        ((InfinispanQuery<K, T>) query).build();
        LOG.debug("deleteByQuery(" + query.toString() + ")");
        InfinispanQuery<K, T> q = (InfinispanQuery) query;
        q.build();
        for (T t : q.list()) {
            infinispanClient.deleteByKey((K) t.get(primaryFieldPos));
        }
        return q.getResultSize();
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) InfinispanQuery(org.apache.gora.infinispan.query.InfinispanQuery) IOException(java.io.IOException) GoraException(org.apache.gora.util.GoraException)

Example 2 with InfinispanQuery

use of org.apache.gora.infinispan.query.InfinispanQuery in project gora by apache.

the class InfinispanStore method execute.

/**
 * Execute the query and return the result.
 */
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
    LOG.debug("execute()");
    try {
        ((InfinispanQuery<K, T>) query).build();
        InfinispanResult<K, T> result = null;
        result = new InfinispanResult<>(this, (InfinispanQuery<K, T>) query);
        LOG.trace("query: " + query.toString());
        LOG.trace("result size: " + result.size());
        return result;
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) InfinispanQuery(org.apache.gora.infinispan.query.InfinispanQuery) IOException(java.io.IOException) GoraException(org.apache.gora.util.GoraException)

Example 3 with InfinispanQuery

use of org.apache.gora.infinispan.query.InfinispanQuery in project gora by apache.

the class InfinispanStore method get.

@Override
public T get(K key, String[] fields) throws GoraException {
    LOG.debug("get(" + key + "," + fields + ")");
    try {
        if (fields == null)
            return infinispanClient.get(key);
        InfinispanQuery<K, T> query = new InfinispanQuery<K, T>(this);
        query.setKey(key);
        query.setFields(fields);
        query.build();
        Result<K, T> result = query.execute();
        result.next();
        return result.get();
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) InfinispanQuery(org.apache.gora.infinispan.query.InfinispanQuery) IOException(java.io.IOException) GoraException(org.apache.gora.util.GoraException)

Aggregations

IOException (java.io.IOException)3 InfinispanQuery (org.apache.gora.infinispan.query.InfinispanQuery)3 GoraException (org.apache.gora.util.GoraException)3