Skip to content

Commit

Permalink
Merge pull request #26 from zendesk/sbloch/consider-namespace-in-key-…
Browse files Browse the repository at this point in the history
…length

Consider presence of namespace when computing slice size
  • Loading branch information
snbloch committed Jan 25, 2024
2 parents c3bf721 + b3fa2ad commit 9e85d26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
large_object_store (1.6.0)
large_object_store (1.6.1)
zstd-ruby (~> 1.5.5)

GEM
Expand Down
4 changes: 3 additions & 1 deletion lib/large_object_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def write(key, value, **options)

# calculate slice size; note that key length is a factor because
# the key is stored on the same slab page as the value
slice_size = MAX_OBJECT_SIZE - ITEM_HEADER_SIZE - UUID_SIZE - key.bytesize
namespace = (store.respond_to?(:options) && store.options[:namespace]) || ""
namespace_length = namespace.empty? ? 0 : namespace.size + 1
slice_size = MAX_OBJECT_SIZE - ITEM_HEADER_SIZE - UUID_SIZE - key.bytesize - namespace_length

# store number of pages
pages = (value.size / slice_size.to_f).ceil
Expand Down
2 changes: 1 addition & 1 deletion lib/large_object_store/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LargeObjectStore
VERSION = "1.6.0"
VERSION = "1.6.1"
end

0 comments on commit 9e85d26

Please sign in to comment.