MCPcopy Create free account
hub / github.com/MemTensor/MemOS / upsertHubEmbedding

Method upsertHubEmbedding

packages/memos-core/src/storage/sqlite.ts:2434–2441  ·  view source on GitHub ↗
(chunkId: string, vector: Float32Array)

Source from the content-addressed store, hash-verified

2432 }
2433
2434 upsertHubEmbedding(chunkId: string, vector: Float32Array): void {
2435 const buf = Buffer.from(vector.buffer, vector.byteOffset, vector.byteLength);
2436 this.db.prepare(`
2437 INSERT INTO hub_embeddings (chunk_id, vector, dimensions, updated_at)
2438 VALUES (?, ?, ?, ?)
2439 ON CONFLICT(chunk_id) DO UPDATE SET vector = excluded.vector, dimensions = excluded.dimensions, updated_at = excluded.updated_at
2440 `).run(chunkId, buf, vector.length, Date.now());
2441 }
2442
2443 getHubEmbedding(chunkId: string): Float32Array | null {
2444 const row = this.db.prepare('SELECT vector, dimensions FROM hub_embeddings WHERE chunk_id = ?').get(chunkId) as { vector: Buffer; dimensions: number } | undefined;

Callers 1

embedChunksAsyncMethod · 0.45

Calls 2

prepareMethod · 0.80
runMethod · 0.65

Tested by

no test coverage detected