|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.indiana.iucbrf.casebase.AbstractCaseBase edu.indiana.iucbrf.casebase.AbstractKeyableCaseBase edu.indiana.iucbrf.casebase.RDBCaseBase edu.indiana.iucbrf.casebase.CachedRDBCaseBase
public class CachedRDBCaseBase
This class uses a relational database to store the case base, but will
read and store the entire case base in memory when it is accessed.
Content changes to the cache are immediately written through to the database.
The policy regarding synchronization of the cache and database is as follows:
- Upon instantiation, the cache does not exist.
- When a case is added or removed:
if the cache exists, the action occurs on the cache and on the database, immediately.
else the action occurs only on the database immediately.
- When getCase() is called:
if the cache exists, it is accessed and the case is returned.
else the entire database is read into the cache, and the case is returned.
- When getCaseCount() or isEmpty() is called:
if the cache exists, it is accessed to get the requested data.
else the database is accessed to get the requested data.
- When iterator() is called:
if the cache exists, an iterator on it is returned.
else the entire database is read into the cache, and an iterator on the cache is returned.
Field Summary | |
---|---|
protected AbstractKeyableCaseBase |
cacheCB
|
Fields inherited from class edu.indiana.iucbrf.casebase.RDBCaseBase |
---|
con, domain, iterator, rdbCaseBaseInfo, stmt |
Fields inherited from class edu.indiana.iucbrf.casebase.AbstractKeyableCaseBase |
---|
markerList |
Fields inherited from class edu.indiana.iucbrf.casebase.AbstractCaseBase |
---|
caseClass, debugMode, DEFAULT_INITIAL_CAPACITY, listeners, prototype |
Fields inherited from interface edu.indiana.util.swing.SwingRepresentable |
---|
TITLE_FONT |
Constructor Summary | |
---|---|
CachedRDBCaseBase(Domain domain,
RDBCaseBaseInfo rdbCaseBaseInfo)
Creates a new instance of CachedRDBCaseBase |
|
CachedRDBCaseBase(Domain domain,
RDBCaseBaseInfo rdbCaseBaseInfo,
CaseGenerator caseGenerator,
int numToGenerate)
|
Method Summary | |
---|---|
void |
addCaseWithKey(Case acase)
Adds the case with the given key. |
void |
doThreadedOperation()
|
Case |
getCase(long key)
Get the case with the given key. |
int |
getCaseCount()
Gets the number of cases in this case base |
java.util.Iterator |
iterator()
Create an iterator on the case base. |
protected void |
readRDBCaseBaseIntoCache()
Reads the RDBCaseBase into a FlatCaseBase (in memory). |
boolean |
removeCase(long key)
Remove the case with the given key. |
protected boolean |
removeCaseImpl(Case c)
Completes the task of removing a case, begun by removeCase(). |
protected void |
setAllCaseShellsIntoCache()
Creates and places the case shells into the cacheCB. |
protected void |
setAllInactiveContextsIntoCache()
|
protected void |
setAllProblemsAndSolutionsIntoCache()
|
void |
setDoneWithThreadedOperation(boolean doneWithThreadedOperation)
|
java.lang.String |
toString()
Convert this case base into a String representation. |
protected void |
waitForCacheLoad()
|
Methods inherited from class edu.indiana.iucbrf.casebase.RDBCaseBase |
---|
addInactiveContextsToTable, addProblemToTable, addSolutionToTable, close, ensureCapacity, finalize, getBasicCaseInfoGivenKey, getInactiveContextsGivenKey, getProblemAndSolutionGivenKey, initializeCB, initializeCB, makeCaseShellFromResultSet, removeCase |
Methods inherited from class edu.indiana.iucbrf.casebase.AbstractKeyableCaseBase |
---|
addCaseImpl, getMarkerKeys, getNextCaseKey |
Methods inherited from class edu.indiana.iucbrf.casebase.AbstractCaseBase |
---|
addCase, addCaseBaseListener, addCases, addCases, addCases, buildCaseJList, checkCaseType, classMemberIterator, clearAllEstimates, fireCaseAdded, fireCaseClassChanged, fireCaseRemoved, fireCaseReplaced, fireCasesCleared, getCaseClass, getCasesMatching, getDomain, getPrototype, isEmpty, removeCase, removeCaseBaseListener, setBaseFileName, setCaseClass, setDebugMode, setDomain, toSwing, toSwing, toVerboseString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.indiana.iucbrf.casebase.CaseBase |
---|
addCase, addCaseBaseListener, addCases, addCases, addCases, clearAllEstimates, getCaseClass, getCasesMatching, getDomain, isEmpty, removeCase, removeCaseBaseListener, setBaseFileName, setCaseClass, setDomain, toVerboseString |
Methods inherited from interface edu.indiana.iucbrf.util.SwingRepresentableWithDomain |
---|
toSwing |
Methods inherited from interface edu.indiana.util.swing.SwingRepresentable |
---|
toSwing |
Field Detail |
---|
protected AbstractKeyableCaseBase cacheCB
Constructor Detail |
---|
public CachedRDBCaseBase(Domain domain, RDBCaseBaseInfo rdbCaseBaseInfo)
public CachedRDBCaseBase(Domain domain, RDBCaseBaseInfo rdbCaseBaseInfo, CaseGenerator caseGenerator, int numToGenerate)
Method Detail |
---|
protected void waitForCacheLoad()
public void setDoneWithThreadedOperation(boolean doneWithThreadedOperation)
setDoneWithThreadedOperation
in interface Multithreaded
public void doThreadedOperation()
doThreadedOperation
in interface Multithreaded
public void addCaseWithKey(Case acase)
addCaseWithKey
in interface KeyableCaseBase
addCaseWithKey
in class RDBCaseBase
acase
- a Casepublic Case getCase(long key)
getCase
in interface KeyableCaseBase
getCase
in class RDBCaseBase
key
- The key of the case to be retrieved.
public int getCaseCount()
getCaseCount
in interface CaseBase
getCaseCount
in class RDBCaseBase
public java.lang.String toString()
toString
in interface CaseBase
toString
in class RDBCaseBase
protected boolean removeCaseImpl(Case c)
removeCaseImpl
in class RDBCaseBase
public boolean removeCase(long key)
KeyableCaseBase
removeCase
in interface KeyableCaseBase
removeCase
in class RDBCaseBase
key
- The key of the case to be removed.
public java.util.Iterator iterator()
iterator
in interface CaseBase
iterator
in class RDBCaseBase
protected void readRDBCaseBaseIntoCache()
protected void setAllCaseShellsIntoCache()
protected void setAllProblemsAndSolutionsIntoCache()
protected void setAllInactiveContextsIntoCache()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |