Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.8.6-alpha0

* Read `type_count(..)` from cache if available, pr #443.

# v1.8.5

* Added `min()` and `max()` functions, issue #441.
Expand Down
16 changes: 15 additions & 1 deletion inc/ti/fn/fntypecount.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ static int do__f_type_count(ti_query_t * query, cleri_node_t * nd, ex_t * e)
if (!type)
return ti_raw_err_not_found((ti_raw_t *) query->rval, "type", e);

n = ti_query_count_type(query, type);
/* use cache if available */
if (type->t_cache)
{
n = type->t_cache->n;
}
else
{
ssize_t r = ti_query_count_type(query, type);
if (r < 0)
{
ex_set_mem(e);
return e->nr;
}
n = (size_t) r;
}

ti_val_unsafe_drop(query->rval);
query->rval = (ti_val_t *) ti_vint_create((int64_t) n);
Expand Down
4 changes: 2 additions & 2 deletions inc/ti/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define TI_VERSION_MAJOR 1
#define TI_VERSION_MINOR 8
#define TI_VERSION_PATCH 5
#define TI_VERSION_PATCH 6

/* The syntax version is used to test compatibility with functions
* using the `ti_nodes_check_syntax()` function */
Expand All @@ -25,7 +25,7 @@
* "-rc0"
* ""
*/
#define TI_VERSION_PRE_RELEASE ""
#define TI_VERSION_PRE_RELEASE "-alpha0"

#define TI_MAINTAINER \
"Jeroen van der Heijden <jeroen@cesbit.com>"
Expand Down
5 changes: 5 additions & 0 deletions itest/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2406,9 +2406,14 @@ async def test_idx_type(self, client):
[
timeit(type_all('T1').len()), // fast
timeit(type_all('V').len()), // slow
timeit(type_count('T1')), // fast
timeit(type_count('V')), // slow
];
""")
self.assertLess(res[0]['time'], res[1]['time'])
self.assertLess(res[2]['time'], res[3]['time'])
self.assertEqual(res[0]['data'], res[2]['data'])
self.assertEqual(res[1]['data'], res[3]['data'])


if __name__ == '__main__':
Expand Down