MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / upsertPrepared

Method upsertPrepared

vector/memoryBackend.js:124–141  ·  view source on GitHub ↗
(preparedItems)

Source from the content-addressed store, hash-verified

122 }
123
124 upsertPrepared(preparedItems) {
125 for (const item of preparedItems) {
126 const existingIndex = this.idToIndex.get(item.id);
127 if (existingIndex !== undefined) {
128 this._writeVector(existingIndex, item.vector);
129 this.metadata[existingIndex] = item.metadata;
130 continue;
131 }
132
133 const index = this.size;
134 this._ensureCapacity(index + 1);
135 this.ids[index] = item.id;
136 this.metadata[index] = item.metadata;
137 this.idToIndex.set(item.id, index);
138 this._writeVector(index, item.vector);
139 this.size += 1;
140 }
141 }
142
143 async upsert(items) {
144 const prepared = this.prepareItems(items);

Callers 3

upsertMethod · 0.95
initMethod · 0.80
upsertMethod · 0.80

Calls 4

_writeVectorMethod · 0.95
_ensureCapacityMethod · 0.95
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected