Search in sources :

Example 1 with QueryResults

use of org.josql.QueryResults in project DirectMemory by raffaeleguidi.

the class OffHeapMemoryBuffer method selectOrderBy.

private QueryResults selectOrderBy(String whereClause, String orderBy, String limit) throws QueryParseException, QueryExecutionException {
    Query q = new Query();
    q.parse("SELECT * FROM " + Pointer.class.getCanonicalName() + "  WHERE " + whereClause + " order by " + orderBy + " " + limit);
    QueryResults qr = q.execute(pointers);
    return qr;
}
Also used : Query(org.josql.Query) QueryResults(org.josql.QueryResults)

Example 2 with QueryResults

use of org.josql.QueryResults in project DirectMemory by raffaeleguidi.

the class OffHeapMemoryBuffer method collectLFU.

public long collectLFU(int limit) {
    if (limit <= 0)
        limit = pointers.size() / 10;
    QueryResults qr;
    try {
        qr = selectOrderBy("free=false", "frequency", "limit 1, " + limit);
        @SuppressWarnings("unchecked") List<Pointer> result = qr.getResults();
        return free(result);
    } catch (QueryParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (QueryExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return 0;
}
Also used : QueryExecutionException(org.josql.QueryExecutionException) QueryResults(org.josql.QueryResults) QueryParseException(org.josql.QueryParseException)

Example 3 with QueryResults

use of org.josql.QueryResults in project DirectMemory by raffaeleguidi.

the class OffHeapMemoryBuffer method select.

private QueryResults select(String whereClause) throws QueryParseException, QueryExecutionException {
    Query q = new Query();
    q.parse("SELECT * FROM " + Pointer.class.getCanonicalName() + "  WHERE " + whereClause);
    QueryResults qr = q.execute(pointers);
    return qr;
}
Also used : Query(org.josql.Query) QueryResults(org.josql.QueryResults)

Aggregations

QueryResults (org.josql.QueryResults)3 Query (org.josql.Query)2 QueryExecutionException (org.josql.QueryExecutionException)1 QueryParseException (org.josql.QueryParseException)1