MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / Strs_get_offsets_nbytes

Function Strs_get_offsets_nbytes

python/stringzilla.c:1959–1988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1957}
1958
1959static PyObject *Strs_get_offsets_nbytes(Strs *self, void *closure) {
1960 if (!Strs_ensure_tape_layout(self)) return NULL;
1961
1962 sz_size_t count = 0;
1963 sz_size_t offset_size = 0;
1964
1965 switch (self->layout) {
1966 case STRS_U32_TAPE_VIEW:
1967 count = self->data.u32_tape_view.count;
1968 offset_size = sizeof(sz_u32_t);
1969 break;
1970 case STRS_U32_TAPE:
1971 count = self->data.u32_tape.count;
1972 offset_size = sizeof(sz_u32_t);
1973 break;
1974 case STRS_U64_TAPE_VIEW:
1975 count = self->data.u64_tape_view.count;
1976 offset_size = sizeof(sz_u64_t);
1977 break;
1978 case STRS_U64_TAPE:
1979 count = self->data.u64_tape.count;
1980 offset_size = sizeof(sz_u64_t);
1981 break;
1982 default: PyErr_SetString(PyExc_RuntimeError, "Unknown Strs layout"); return NULL;
1983 }
1984
1985 // Arrow format uses N+1 offsets for N strings
1986 sz_size_t offsets_nbytes = (count + 1) * offset_size;
1987 return PyLong_FromSize_t(offsets_nbytes);
1988}
1989
1990static Py_ssize_t Strs_len(Strs *self) {
1991 switch (self->layout) {

Callers

nothing calls this directly

Calls 1

Strs_ensure_tape_layoutFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…