Package com.tnsai.session.extraction
Class InMemoryKnowledgeStore
java.lang.Object
com.tnsai.session.extraction.InMemoryKnowledgeStore
- All Implemented Interfaces:
KnowledgeStore
In-memory implementation of KnowledgeStore.
Useful for testing and temporary storage.
- Author:
- TnsAI Team
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.session.extraction.KnowledgeStore
KnowledgeStore.KnowledgeStats -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all stored knowledge.intcount()Gets the total count of stored knowledge.intcountByType(ExtractionType type) Gets count by type.booleanDeletes knowledge by ID.findSimilar(ExtractedKnowledge knowledge, int limit) Finds knowledge similar to the given item.getStats()Gets statistics about stored knowledge.listBySession(String sessionId) Lists all knowledge by session.listByType(ExtractionType type) Lists all knowledge by type.listRecent(int limit) Lists recent knowledge.Loads knowledge by ID.voidsave(ExtractedKnowledge knowledge) Saves knowledge to the store.search(String query, KnowledgeFilter filter) Searches knowledge with filter.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tnsai.session.extraction.KnowledgeStore
saveAll, search
-
Constructor Details
-
InMemoryKnowledgeStore
public InMemoryKnowledgeStore()
-
-
Method Details
-
save
Description copied from interface:KnowledgeStoreSaves knowledge to the store.- Specified by:
savein interfaceKnowledgeStore- Parameters:
knowledge- the knowledge to save
-
load
Description copied from interface:KnowledgeStoreLoads knowledge by ID.- Specified by:
loadin interfaceKnowledgeStore- Parameters:
id- the knowledge ID- Returns:
- the knowledge, or empty if not found
-
delete
Description copied from interface:KnowledgeStoreDeletes knowledge by ID.- Specified by:
deletein interfaceKnowledgeStore- Parameters:
id- the knowledge ID- Returns:
- true if deleted, false if not found
-
search
Description copied from interface:KnowledgeStoreSearches knowledge with filter.- Specified by:
searchin interfaceKnowledgeStore- Parameters:
query- the search query (can be null for filter-only search)filter- the filter to apply- Returns:
- matching knowledge items
-
findSimilar
Description copied from interface:KnowledgeStoreFinds knowledge similar to the given item.- Specified by:
findSimilarin interfaceKnowledgeStore- Parameters:
knowledge- the reference knowledgelimit- maximum results- Returns:
- similar knowledge items
-
listByType
Description copied from interface:KnowledgeStoreLists all knowledge by type.- Specified by:
listByTypein interfaceKnowledgeStore- Parameters:
type- the extraction type- Returns:
- knowledge items of that type
-
listBySession
Description copied from interface:KnowledgeStoreLists all knowledge by session.- Specified by:
listBySessionin interfaceKnowledgeStore- Parameters:
sessionId- the session ID- Returns:
- knowledge items from that session
-
listRecent
Description copied from interface:KnowledgeStoreLists recent knowledge.- Specified by:
listRecentin interfaceKnowledgeStore- Parameters:
limit- maximum results- Returns:
- most recent knowledge items
-
count
public int count()Description copied from interface:KnowledgeStoreGets the total count of stored knowledge.- Specified by:
countin interfaceKnowledgeStore- Returns:
- count
-
countByType
Description copied from interface:KnowledgeStoreGets count by type.- Specified by:
countByTypein interfaceKnowledgeStore- Parameters:
type- the extraction type- Returns:
- count of that type
-
clear
public void clear()Description copied from interface:KnowledgeStoreClears all stored knowledge.- Specified by:
clearin interfaceKnowledgeStore
-
getStats
Description copied from interface:KnowledgeStoreGets statistics about stored knowledge.- Specified by:
getStatsin interfaceKnowledgeStore- Returns:
- knowledge statistics
-