MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / _read_with_offset

Method _read_with_offset

apps/knowledge/models/knowledge.py:453–468  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

451
452 def get_bytes_stream(self, start=0, end=None, chunk_size=64 * 1024):
453 def _read_with_offset():
454 offset = start
455 while True:
456 result = select_one(
457 "SELECT lo_get(%s::oid, %s, %s) as chunk",
458 [self.loid, offset, end - offset if end and (end - offset) < chunk_size else chunk_size],
459 )
460 chunk = result["chunk"] if result else None
461 if not chunk:
462 break
463 yield chunk
464 offset += len(chunk)
465 if len(chunk) < chunk_size:
466 break
467 if end and offset > end:
468 break
469
470 return _read_with_offset()
471

Callers

nothing calls this directly

Calls 1

select_oneFunction · 0.90

Tested by

no test coverage detected