Skip to content

Reference

db.count

Return the number of searchable vectors.

db.count() -> int

None.

int: the number of vectors that are not deleted.

Nothing in normal use.

  • Never raises for valid use; a RuntimeError is possible only after an earlier internal fault.
  • Thread safety: releases the GIL and takes a shared lock, so calls from several threads run in parallel; they wait while a write is running. See Threads and processes.
import srvdb
db = srvdb.create("./vectors", dimension=128)
v = [1.0] + [0.0] * 127 # tiny 128-dimension vectors
w = [0.0, 1.0] + [0.0] * 126
db.add(["a", "b"], [v, w], ["{}", "{}"])
db.delete(["a"])
print(db.count())
# 1