Browse Source

Added an history feature

master
Archivist 6 years ago
parent
commit
a1a3bd430b
4 changed files with 29 additions and 4 deletions
  1. +2
    -2
      README.md
  2. +1
    -1
      shard.yml
  3. +25
    -0
      src/crystal-scatter/metaring.cr
  4. +1
    -1
      src/crystal-scatter/version.cr

+ 2
- 2
README.md View File

@ -1,6 +1,6 @@
# crystal-scatter # crystal-scatter
Release candidate for v0.1 "John Scott"
## Installation ## Installation
@ -10,7 +10,7 @@ Add this to your application's `shard.yml`:
dependencies: dependencies:
crystal-scatter: crystal-scatter:
git: https://git.nekoit.xyz/Archivist/crystal-scatter git: https://git.nekoit.xyz/Archivist/crystal-scatter
version: ~> 0.1.0-rc1
version: ~> 0.1.0-rc2
``` ```
## Usage ## Usage

+ 1
- 1
shard.yml View File

@ -1,5 +1,5 @@
name: crystal-scatter name: crystal-scatter
version: 0.1.0-rc1
version: 0.1.0-rc2
authors: authors:
- Ludovic 'Archivist' Lagouardette <lagouardette.ludovic@gmail.com> - Ludovic 'Archivist' Lagouardette <lagouardette.ludovic@gmail.com>

+ 25
- 0
src/crystal-scatter/metaring.cr View File

@ -91,6 +91,31 @@ module Crystal::Scatter
end end
return slices return slices
end end
def get_slices_for(data : String, n_last = 1 : Int32)
n_rings = Array(Ring).new
@lock.synchronize do
t = @rings.size-n_last
n_rings = @rings.skip( t > 0 ? t : 1 )
end
h = hash_impl data
space=UInt64::MAX/@shards
targets = Array(UInt64).new
(1..@shards).each do
targets << h
h+=space
end
ret = Array(Array(Slice)).new
n_rings.each do |ring|
slices = Array(Slice).new
targets.each do |h|
slices << get_slice_from_hash(ring, h)
end
ret << slices
end
return ret
end
end end
end end

+ 1
- 1
src/crystal-scatter/version.cr View File

@ -1,3 +1,3 @@
module Crystal::Scatter module Crystal::Scatter
VERSION = "0.1.0-rc1"
VERSION = "0.1.0-rc2"
end end

Loading…
Cancel
Save