Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't rely on weakref being null, fix blobcache #9

Merged
merged 1 commit into from
Mar 17, 2016
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
12 changes: 4 additions & 8 deletions src/blob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ function load_local(collid::UUID, blob::UUID)
end
function load_local{T}(coll::BlobCollection, blob::Blob{T})
if !haskey(coll.cache, blob.id)
val = blob.data.value
(val == nothing) && (val = load(blob.metadata, coll.reader))
val = load(blob.metadata, coll.reader)
blob.data.value = coll.cache[blob.id] = val
blob.locality = locality(coll.reader, coll.nodemap)
end
Expand All @@ -328,12 +327,9 @@ load(coll::BlobCollection, blobid::UUID) = load(coll, coll.blobs[blobid])
load{T,L<:WeakLocality}(coll::BlobCollection, blob::Blob{T,L}) = load_local(coll, blob)
function load{T,L<:StrongLocality}(coll::BlobCollection, blob::Blob{T,L})
if !haskey(coll.cache, blob.id)
val = blob.data.value
if val == nothing
# select a node from blob's local nodes
fetchfrom = select_local(coll, blob)
val = (fetchfrom == myid()) ? load_local(coll.id, blob.id) : remotecall_fetch(load_local, fetchfrom, coll.id, blob.id)
end
# select a node from blob's local nodes
fetchfrom = select_local(coll, blob)
val = (fetchfrom == myid()) ? load_local(coll.id, blob.id) : remotecall_fetch(load_local, fetchfrom, coll.id, blob.id)
blob.data.value = coll.cache[blob.id] = val
end
(coll.cache[blob.id])::T
Expand Down
4 changes: 2 additions & 2 deletions src/cache/blobcache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function Base.setindex!{K, V}(lru::LRU{K, V}, v, key)
end

while lru.isfull(lru)
rm = pop!(lru.q)
rm = last(lru.q)
delete!(lru, rm.k)
end

Expand All @@ -104,7 +104,7 @@ function Base.resize!(lru::LRU, n::Int)
n < 0 && error("size must be a positive integer")
lru.maxsize = n
while lru.isfull(lru)
rm = pop!(lru.q)
rm = last(lru.q)
delete!(lru, rm.k)
end
return lru
Expand Down