Extract query and record cache tracking into parent.
This commit is contained in:
@@ -105,6 +105,7 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
|||||||
} finally {
|
} finally {
|
||||||
JDBCUtil.close(stmt);
|
JDBCUtil.close(stmt);
|
||||||
}
|
}
|
||||||
|
_uncachedQueries++;
|
||||||
|
|
||||||
// now fetch any records we can from the cache
|
// now fetch any records we can from the cache
|
||||||
loadFromCache(ctx, allKeys, entities, fetchKeys);
|
loadFromCache(ctx, allKeys, entities, fetchKeys);
|
||||||
@@ -120,13 +121,10 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
|||||||
return loadAndResolve(ctx, conn, allKeys, fetchKeys, entities, stmtString);
|
return loadAndResolve(ctx, conn, allKeys, fetchKeys, entities, stmtString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Query
|
protected CacheKey getCacheKey ()
|
||||||
public void updateStats (Stats stats)
|
|
||||||
{
|
{
|
||||||
stats.noteQuery(0, 1, _cachedRecords, _uncachedRecords); // one uncached query
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _cachedRecords, _uncachedRecords;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,16 +160,9 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
|||||||
return loadAndResolve(ctx, conn, _keys, _fetchKeys, _entities, null);
|
return loadAndResolve(ctx, conn, _keys, _fetchKeys, _entities, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Query
|
|
||||||
public void updateStats (Stats stats)
|
|
||||||
{
|
|
||||||
stats.noteQuery(0, 0, _cachedRecords, _uncachedRecords);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Collection<Key<T>> _keys;
|
protected Collection<Key<T>> _keys;
|
||||||
protected Map<Key<T>, T> _entities = Maps.newHashMap();
|
protected Map<Key<T>, T> _entities = Maps.newHashMap();
|
||||||
protected Set<Key<T>> _fetchKeys = Sets.newHashSet();
|
protected Set<Key<T>> _fetchKeys = Sets.newHashSet();
|
||||||
protected int _cachedRecords, _uncachedRecords;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,6 +203,7 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
|||||||
} finally {
|
} finally {
|
||||||
JDBCUtil.close(stmt);
|
JDBCUtil.close(stmt);
|
||||||
}
|
}
|
||||||
|
_uncachedQueries++;
|
||||||
if (PersistenceContext.CACHE_DEBUG) {
|
if (PersistenceContext.CACHE_DEBUG) {
|
||||||
log.info("Loaded " + _marsh.getTableName(), "query", _select,
|
log.info("Loaded " + _marsh.getTableName(), "query", _select,
|
||||||
"uncached", _uncachedRecords);
|
"uncached", _uncachedRecords);
|
||||||
@@ -219,14 +211,12 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
|||||||
// TODO: do we want to cache these results?
|
// TODO: do we want to cache these results?
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override // from Query
|
@Override // from Query
|
||||||
public void updateStats (Stats stats)
|
public void updateStats (Stats stats)
|
||||||
{
|
{
|
||||||
stats.noteQuery(0, 1, 0, _uncachedRecords);
|
stats.noteQuery(_cachedQueries, _uncachedQueries, _cachedRecords, _uncachedRecords);
|
||||||
}
|
|
||||||
|
|
||||||
protected int _uncachedRecords;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FindAllQuery (PersistenceContext ctx, Class<T> type)
|
protected FindAllQuery (PersistenceContext ctx, Class<T> type)
|
||||||
@@ -349,4 +339,5 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
|||||||
protected DepotMarshaller<T> _marsh;
|
protected DepotMarshaller<T> _marsh;
|
||||||
protected Class<T> _type;
|
protected Class<T> _type;
|
||||||
protected SelectClause<T> _select;
|
protected SelectClause<T> _select;
|
||||||
|
protected int _cachedQueries, _uncachedQueries, _cachedRecords, _uncachedRecords;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user