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

Function Strs_get_tape_nbytes

python/stringzilla.c:1923–1957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1921}
1922
1923static PyObject *Strs_get_tape_nbytes(Strs *self, void *closure) {
1924 if (!Strs_ensure_tape_layout(self)) return NULL;
1925
1926 sz_size_t tape_nbytes = 0;
1927 switch (self->layout) {
1928 case STRS_U32_TAPE_VIEW: {
1929 sz_size_t count = self->data.u32_tape_view.count;
1930 sz_u32_t *offsets = self->data.u32_tape_view.offsets;
1931 // The tape size is the last offset (offsets[count])
1932 tape_nbytes = (count > 0) ? offsets[count] : 0;
1933 break;
1934 }
1935 case STRS_U32_TAPE: {
1936 sz_size_t count = self->data.u32_tape.count;
1937 sz_u32_t *offsets = self->data.u32_tape.offsets;
1938 tape_nbytes = (count > 0) ? offsets[count] : 0;
1939 break;
1940 }
1941 case STRS_U64_TAPE_VIEW: {
1942 sz_size_t count = self->data.u64_tape_view.count;
1943 sz_u64_t *offsets = self->data.u64_tape_view.offsets;
1944 tape_nbytes = (count > 0) ? offsets[count] : 0;
1945 break;
1946 }
1947 case STRS_U64_TAPE: {
1948 sz_size_t count = self->data.u64_tape.count;
1949 sz_u64_t *offsets = self->data.u64_tape.offsets;
1950 tape_nbytes = (count > 0) ? offsets[count] : 0;
1951 break;
1952 }
1953 default: PyErr_SetString(PyExc_RuntimeError, "Unknown Strs layout"); return NULL;
1954 }
1955
1956 return PyLong_FromSize_t(tape_nbytes);
1957}
1958
1959static PyObject *Strs_get_offsets_nbytes(Strs *self, void *closure) {
1960 if (!Strs_ensure_tape_layout(self)) return NULL;

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…