[
https://issues.apache.org/jira/browse/OAK-3566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14993500#comment-14993500
]
Thomas Mueller commented on OAK-3566:
-------------------------------------
Algorithm and example code (can be implemented using multiple Guava bloom
filters, or using our own "forgetful" bloom filter):
There are separate bits, or bloom filter, for the last second, 2 seconds, 4
seconds, and so on.
When running a query: Don't update the cache if the query took longer than 128
seconds; otherwise: check the relevant bits of the bloom filter(s), and
_bitwise or_ all entries - if one bit is set, don't update the cache.
Bloom filter update: If an entry was updated, set bit a of the relevant entries.
Bloom filter shift & forget background thread: every second, for every entry, b
= b or a, and set a = 0; every 2 seconds, c = c or b, and then b = a; and so on
(see the code below).
{noformat}
a: updated the last second
b: updated 2 seconds before
c: updated 4 seconds before
d: updated 8 seconds before
e: updated 16 seconds before
f: updated 32 seconds before
g: updated 64 seconds before
h: updated 128 seconds before
public static void main(String... args) throws Exception {
int bits = 0;
String set = "1000000100110000000000000100000000000000000000000000000";
for (int i = 0; i < set.length(); i++) {
boolean now = set.charAt(i) == '1';
if (now) {
bits |= 1;
}
System.out.println("time: " + (100 + i) +
" now: " + (now ? 1 : 0) +
" state: " + Integer.toBinaryString(0x100 |
bits).substring(1));
if ((i & 31) == 16) {
bits ^= bits & 16;
}
if ((i & 15) == 8) {
bits |= (bits & 8) << 1;
bits ^= bits & 8;
}
if ((i & 7) == 4) {
bits |= (bits & 4) << 1;
bits ^= bits & 4;
}
if ((i & 3) == 2) {
bits |= (bits & 2) << 1;
bits ^= bits & 2;
}
if ((i & 1) == 1) {
bits |= (bits & 1) << 1;
bits ^= bits & 1;
}
}
}
output:
time: 100 now: 1 state: 00000001
time: 101 now: 0 state: 00000001
time: 102 now: 0 state: 00000010
time: 103 now: 0 state: 00000100
time: 104 now: 0 state: 00000100
time: 105 now: 0 state: 00001000
time: 106 now: 0 state: 00001000
time: 107 now: 1 state: 00001001
time: 108 now: 0 state: 00001010
time: 109 now: 0 state: 00010010
time: 110 now: 1 state: 00010011
time: 111 now: 1 state: 00010101
time: 112 now: 0 state: 00010110
time: 113 now: 0 state: 00011010
time: 114 now: 0 state: 00011010
time: 115 now: 0 state: 00011100
time: 116 now: 0 state: 00011100
time: 117 now: 0 state: 00001100
time: 118 now: 0 state: 00001100
time: 119 now: 0 state: 00001100
time: 120 now: 0 state: 00001100
time: 121 now: 0 state: 00001000
time: 122 now: 0 state: 00001000
time: 123 now: 0 state: 00001000
time: 124 now: 0 state: 00001000
time: 125 now: 1 state: 00010001
time: 126 now: 0 state: 00010010
time: 127 now: 0 state: 00010100
time: 128 now: 0 state: 00010100
time: 129 now: 0 state: 00011000
time: 130 now: 0 state: 00011000
time: 131 now: 0 state: 00011000
time: 132 now: 0 state: 00011000
time: 133 now: 0 state: 00011000
time: 134 now: 0 state: 00011000
time: 135 now: 0 state: 00011000
time: 136 now: 0 state: 00011000
time: 137 now: 0 state: 00011000
time: 138 now: 0 state: 00011000
time: 139 now: 0 state: 00011000
time: 140 now: 0 state: 00011000
time: 141 now: 0 state: 00010000
time: 142 now: 0 state: 00010000
time: 143 now: 0 state: 00010000
time: 144 now: 0 state: 00010000
time: 145 now: 0 state: 00010000
time: 146 now: 0 state: 00010000
time: 147 now: 0 state: 00010000
time: 148 now: 0 state: 00010000
time: 149 now: 0 state: 00000000
time: 150 now: 0 state: 00000000
time: 151 now: 0 state: 00000000
time: 152 now: 0 state: 00000000
time: 153 now: 0 state: 00000000
time: 154 now: 0 state: 00000000
{noformat}
> Stale documents in RDBDocumentStore cache
> -----------------------------------------
>
> Key: OAK-3566
> URL: https://issues.apache.org/jira/browse/OAK-3566
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: core, rdbmk
> Affects Versions: 1.0, 1.2
> Reporter: Marcel Reutegger
> Assignee: Julian Reschke
> Attachments: OAK-3566-test.patch, OAK-3566.diff, OAK-3566.patch
>
>
> This issue is about the same problem as described in OAK-1897 but for the
> RDBDocumentStore implementation.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)