filedictrb 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f023c0d5acca6fc0f6355bae7c34f61eb5682f9f4652f83dd8befefac6f2c050
4
- data.tar.gz: de7ba4f1fcf57e21771312bf9bb8daacdfc39a044e9ef263a81494bb6e976dca
3
+ metadata.gz: 7cb1c1d801bf8943d6493a6c40be882c5d47c58166c56b6860abf8b98fc14a98
4
+ data.tar.gz: 394f0febd55f827bfb3aafb3559ba89b6b458b3a7ed2c3b6d857d900e38b7374
5
5
  SHA512:
6
- metadata.gz: 2cb1f1f1a43a0494aa95f8d31d0b1b490f63ce07c57bcc1e6af2003064656784034064cebefd8247b886174e3e57c600c4464e2eba69a61cf7720c6cee9fcc1e
7
- data.tar.gz: 3f4f4dbf014f9af21ad104a3282f09ce7d07c22f70c60e5e33b43c58159bb403567e42116896091062a527bd881524d15db9b8724a16065395b0cdd6cdb715c1
6
+ metadata.gz: 4a700778e49bd15c6686b9457b7a7987f4d6c8b47be4abf805a6a09d95156ce71ff8e15e7cb50ffcfa11f96e78f3eb633c19d10bf472c6f7963deb5ae658f9f4
7
+ data.tar.gz: dc233039e2c4d0e2aade78efc7cd6b55ab088cbdeaa373d9219137ae1241585dbe32b4e5984eeb402c52a32a027ee14f2950fa5540b3a3b932a34d13ff834b8c
@@ -120,15 +120,17 @@ static void filedict_deinit(filedict_t *filedict) {
120
120
  * This computes the size of the entire filedict file given an initial bucket count and hashmap count.
121
121
  */
122
122
  static size_t filedict_file_size(size_t initial_bucket_count, size_t hashmap_count) {
123
- size_t result = sizeof(filedict_header_t);
124
- size_t i;
125
-
126
- for (i = 0; i < hashmap_count; ++i) {
127
- /* Bucket count is multiplied by 2 for each additional hashmap. */
128
- result += (initial_bucket_count << i) * sizeof(filedict_bucket_t);
129
- }
130
-
131
- return result;
123
+ /*
124
+ * We used to size each additional hashmap at 2x the previous, but realistically it seems that
125
+ * most resizes are triggered by keys that are ridiculously large, not by mass collision.
126
+ *
127
+ * A more proper fix might be to re-structure the whole filedict. We could keep the existing
128
+ * hashmap structure, but with buckets that expand dynamically. This would require each bucket
129
+ * to contain a "pointer" to the next bucket object if present.
130
+ *
131
+ * For now, it's easiser to just keep the hashmap duplication without the size doubling.
132
+ */
133
+ return sizeof(filedict_header_t) + initial_bucket_count * hashmap_count * sizeof(filedict_bucket_t);
132
134
  }
133
135
 
134
136
  /*
@@ -289,7 +291,6 @@ try_again:
289
291
 
290
292
  ++hashmap_i;
291
293
  hashmap += bucket_count;
292
- bucket_count = (bucket_count << 1);
293
294
  }
294
295
 
295
296
  /*
@@ -409,7 +410,7 @@ static int filedict_read_advance_hashmap(filedict_read_t *read) {
409
410
 
410
411
  filedict_bucket_t *hashmap = filedict->data + offset;
411
412
 
412
- read->bucket_count = (size_t)header->initial_bucket_count << read->hashmap_i;
413
+ read->bucket_count = (size_t)header->initial_bucket_count;
413
414
  read->bucket = &hashmap[read->key_hash % read->bucket_count];
414
415
  read->entry = &read->bucket->entries[0];
415
416
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Filedict
4
- VERSION = "0.1.4"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filedictrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Baillie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.1.6
61
+ rubygems_version: 3.3.3
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Uses filedict to emulate a file-backed Hash<Set<String>>