(options = {})
| 80 | |
| 81 | export class MemoryBackend { |
| 82 | constructor(options = {}) { |
| 83 | this.name = options.name || 'default'; |
| 84 | this.dimension = options.dimension || null; |
| 85 | this.metric = normalizeMetric(options.metric); |
| 86 | this.normalizeVectors = options.normalize ?? (this.metric === 'cosine'); |
| 87 | this.size = 0; |
| 88 | this.capacity = ensurePositiveInteger(options.capacity, 128); |
| 89 | this.ids = new Array(this.capacity); |
| 90 | this.metadata = new Array(this.capacity); |
| 91 | this.vectors = null; |
| 92 | this.idToIndex = new Map(); |
| 93 | } |
| 94 | |
| 95 | async init(options = {}) { |
| 96 | if (options.dimension) { |
nothing calls this directly
no test coverage detected