Class MongoBaseStore
- All Implemented Interfaces:
io.agentscope.harness.agent.filesystem.remote.store.BaseStore
BaseStore.
Each item is stored as a separate MongoDB document. Namespace paths and keys are encoded
into a compound _id for uniqueness, using \\u001F (ASCII Unit Separator) as
the segment delimiter. The namespace field stores the full namespace path with a
trailing separator, enabling prefix-matching via range queries ($gte/{$lt}) on the
compound index — consistent with PostgresBaseStore and JdbcStore.
Supports optimistic concurrency via a version field. Value serialization uses
JsonCodec.convertValue(java.lang.Object, java.lang.Class<T>) to avoid an intermediate JSON string round-trip.
-
Constructor Summary
ConstructorsConstructorDescriptionMongoBaseStore(com.mongodb.client.MongoDatabase database, String collectionName) Creates a new instance using the sharedJsonUtils.getJsonCodec().MongoBaseStore(com.mongodb.client.MongoDatabase database, String collectionName, io.agentscope.core.util.JsonCodec codec) Creates a new instance with a customJsonCodec. -
Method Summary
Modifier and TypeMethodDescriptionvoidio.agentscope.harness.agent.filesystem.remote.store.StoreItemvoidbooleanList<io.agentscope.harness.agent.filesystem.remote.store.StoreItem>Searches for items within a namespace, including child namespaces (prefix matching).
-
Constructor Details
-
MongoBaseStore
Creates a new instance using the sharedJsonUtils.getJsonCodec().- Parameters:
database- the MongoDB databasecollectionName- the collection name
-
MongoBaseStore
public MongoBaseStore(com.mongodb.client.MongoDatabase database, String collectionName, io.agentscope.core.util.JsonCodec codec) Creates a new instance with a customJsonCodec.- Parameters:
database- the MongoDB databasecollectionName- the collection namecodec- JSON codec for serializing values
-
-
Method Details
-
get
public io.agentscope.harness.agent.filesystem.remote.store.StoreItem get(List<String> namespace, String key) - Specified by:
getin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
put
- Specified by:
putin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
putIfVersion
public boolean putIfVersion(List<String> namespace, String key, Map<String, Object> value, long expectedVersion) - Specified by:
putIfVersionin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
search
public List<io.agentscope.harness.agent.filesystem.remote.store.StoreItem> search(List<String> namespace, int limit, int offset) Searches for items within a namespace, including child namespaces (prefix matching).The namespace path is encoded with a trailing separator so that a range query
gte(nsPrefix)/lt(nsPrefix + )matches both the exact namespace and all descendant sub-namespaces, consistent withInMemoryStore,PostgresBaseStore, andJdbcStore.Note: the upper bound uses
Character.MAX_VALUE(), which does not match namespace segments containing Unicode supplementary characters (code points aboveU+FFFF, such as emoji). This is a theoretical limitation — supplementary characters are unlikely in namespace segments — and the range query preserves full B-tree index utilisation, which a$regexprefix match would not.- Specified by:
searchin interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-
delete
- Specified by:
deletein interfaceio.agentscope.harness.agent.filesystem.remote.store.BaseStore
-