hi, all
I am implementing Chord in bloom, I hoped to get help from P2's chord.olg because
I have studied and run many examples of p2, but now, I do not know how to implement these
snippets of chord.olg in Bloom as follows:
f4 eagerFinger(@NI,I,B,BI) :- fFix(@NI,E,I),
lookupResults(@NI,K,B,BI,E).
f5 finger(@NI,I,B,BI) :- eagerFinger(@NI,I,B,BI).
f6 eagerFinger(@NI,I,B,BI) :- node(@NI,N), eagerFinger(@NI,I1,B,BI),
I:=I1 + 1, K:=0x1I << I + N, K in (N,B), BI != NI.
in here, eagerFinger and lookupResults are unmaterialize table, finger and node are defined
as below:
materialize(finger, 180, 160, keys(2)).
materialize(node, infinity, 1, keys(1)).
according to the context, my understanding about the above snippets are:
at first, when getting lookup results, the first record will be added in eagerFinger of rule f4,
and then, eagerFinger will be updated 159 times in rule f5, at the same time the content of eagerFinger
will be added to finger in f5. In summary, one table immediately changes many times when some one
rule (here, f4) is met.
for bloom, I seemed to need more complicated rules:
state do
table :init1, [:t1, :t2] # like lookResults
table :test1, [:t1] => [:t2] # assistant table
table :test2, [:t1] => [:t2, :ruleName] # like eagerFinger
periodic :tik, 1
end
bootstrap do
test1 <= [[10, 0]]
end
bloom do
# test2 will chang many times when test2 gets one ideal input (the interval is 3s)
test2 <+- init1 {|xo| [xo.t1, xo.t2, "rule1"]}
test1 <+- (tik*test2*test1).combos do |tk, t2,t1|
if t2.ruleName == "rule1"
[t2.t1, t2.t2]
else
[t1.t1, t1.t2+2]
end
end
test2 <+- test1 do |t|
if t.t2.to_i == 10000
[10,0,"NIL"]
end
end
I am right? or there is a better method?
Thanks a lot in advance!
BEST REGARDS
PengCZ