MCPcopy Create free account
hub / github.com/questdb/questdb / openROCached

Method openROCached

core/src/main/java/io/questdb/std/FdCache.java:187–207  ·  view source on GitHub ↗

Opens file in read-only mode with caching support.

(LPSZ lpsz)

Source from the content-addressed store, hash-verified

185 * Opens file in read-only mode with caching support.
186 */
187 public synchronized long openROCached(LPSZ lpsz) {
188 final FdCacheRecord holder = getFdCacheRecord(lpsz);
189 if (holder == null) {
190 // Failed to open
191 return -1;
192 }
193
194 holder.count++;
195
196 // find a unique key even if the index generator wrapped over
197 long uniqROFd;
198 int keyIndex;
199 do {
200 uniqROFd = Numbers.encodeLowHighInts(nextIndex(), holder.osFd);
201 keyIndex = openFdMapByFd.keyIndex(uniqROFd);
202 } while (keyIndex < 0);
203
204 openFdMapByFd.putAt(keyIndex, uniqROFd, holder);
205
206 return uniqROFd;
207 }
208
209 /**
210 * Removes file path from cache when file is deleted.

Callers 1

openROMethod · 0.80

Calls 5

getFdCacheRecordMethod · 0.95
encodeLowHighIntsMethod · 0.95
nextIndexMethod · 0.95
keyIndexMethod · 0.45
putAtMethod · 0.45

Tested by

no test coverage detected