fix: feature-detect setConnectionsCodec before wiring the connections codec
wireConnectionsCodec() called this.index.setConnectionsCodec(codec) unconditionally. Vector-index providers that don't keep per-node connection lists (single-file graph formats) have no such hook — the unconditional call forced them to carry a no-op shim just to survive brain.init(). Guard with a typeof check and skip silently: the delta-varint codec only applies to the JS HNSW connection layout, so providers without the hook lose nothing. Providers can now drop their shims.
This commit is contained in:
parent
cfb051cc5a
commit
747ab974f3
1 changed files with 5 additions and 0 deletions
|
|
@ -9469,6 +9469,11 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
const idMapper = this.metadataIndex.getIdMapper?.()
|
||||
if (!idMapper) return
|
||||
|
||||
// Feature-detect: vector-index providers without per-node connection
|
||||
// lists (e.g. single-file graph formats) don't expose this hook. Skip
|
||||
// silently — the codec only applies to the JS HNSW connection layout.
|
||||
if (typeof this.index.setConnectionsCodec !== 'function') return
|
||||
|
||||
const codec = new ConnectionsCodec(provider, idMapper)
|
||||
this.index.setConnectionsCodec(codec)
|
||||
if (!this.config.silent) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue