(preparedItems)
| 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); |
no test coverage detected