Skip to content

Commit

Permalink
split 0 and 1 byte bins
Browse files Browse the repository at this point in the history
  • Loading branch information
calccrypto committed Oct 4, 2023
1 parent 74a01e9 commit 2f0e2a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions scripts/gufi_stats
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ def size_bins(args, base, type): # pylint: disable=redefined-builtin
queries = [
'-I', build_create(args.inmemory_name, pinode_create + ['{0} INTEGER'.format(bits)]),
'-E', 'INSERT INTO {0} {1}'.format(args.inmemory_name,
gufi_common.build_query(pinode + ['CASE WHEN size == 0 THEN 0 ELSE CAST(FLOOR(LOG({0}, size)) AS INTEGER) END'.format(base)],
gufi_common.build_query(pinode + ['CASE WHEN size == 0 THEN -1 ELSE CAST(FLOOR(LOG({0}, size)) AS INTEGER) END'.format(base)],
[table],
['type == \'{0}\''.format(type)],
None, # cannot GROUP BY here because value would be aggregate
Expand All @@ -1035,7 +1035,7 @@ def size_bins(args, base, type): # pylint: disable=redefined-builtin
None,
None,
None)),
'-G', gufi_common.build_query(pinode + ['CAST(pow({0}, {1}) AS INTEGER)'.format(base, bits), 'SUM(count)'],
'-G', gufi_common.build_query(pinode + ['CASE WHEN {1} == -1 THEN 0 ELSE CAST(pow({0}, {1}) AS INTEGER) END'.format(base, bits), 'SUM(count)'],
[args.aggregate_name],
None,
pinode + [bits],
Expand Down
16 changes: 10 additions & 6 deletions test/regression/gufi_stats.expected
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ $ gufi_stats --num-results 6 --order DESC gid-size "prefix"
1001 10 leaf_directory/leaf_file1

$ gufi_stats filesize-log2-bins "prefix"
1 1
0 1
8 2
1024 1
1048576 1
Expand All @@ -267,21 +267,23 @@ $ gufi_stats -r filesize-log2-bins "prefix"
7 2 2
12 8 2
15 8 1
16 1 1
16 0 1
16 8 2
16 1024 1
16 1048576 1

$ gufi_stats -c filesize-log2-bins "prefix"
1 2
0 1
1 1
2 2
4 1
8 5
1024 1
1048576 1

$ gufi_stats filesize-log1024-bins "prefix"
1 3
0 1
1 2
1024 1
1048576 1

Expand All @@ -290,12 +292,14 @@ $ gufi_stats -r filesize-log1024-bins "prefix"
7 1 3
12 1 2
15 1 1
16 1 3
16 0 1
16 1 2
16 1024 1
16 1048576 1

$ gufi_stats -c filesize-log1024-bins "prefix"
1 10
0 1
1 9
1024 1
1048576 1

Expand Down

0 comments on commit 2f0e2a8

Please sign in to comment.