INNER CODE UNIT · Python
oversized_records
defiprime/defiprime1 · scripts/algolia-index.py:73
def oversized_records(records, cap):
found = []
for record in records:
size = record_size(record)
if size > cap:
found.append((record.get("objectID"), size))
return found
def batch_records(records, max_bytes, max_records):
batches = []
current = []
current_bytes = 0
for record in records:
size = record_size(record)
if current and (
len(current) >= max_records or current_bytes + size > max_bytes
):