MCPcopy Index your code
hub / github.com/questdb/questdb / cacheMmap

Method cacheMmap

core/src/main/java/io/questdb/std/MmapCache.java:91–109  ·  view source on GitHub ↗

Maps file region into memory, reusing existing mapping if available. @param fd file descriptor to map @param mmapCacheKey unique value that is safe to use as a key for caching the map. FD is not good enough since a FD can be closed after the mapping is created and OS c

(int fd, long mmapCacheKey, long len, long offset, int flags, int memoryTag)

Source from the content-addressed store, hash-verified

89 * @param flags memory mapping flags, e.g., Files.MAP_RO for read-only
90 */
91 public long cacheMmap(int fd, long mmapCacheKey, long len, long offset, int flags, int memoryTag) {
92 if (len < 1) {
93 throw CairoException.critical(0)
94 .put("could not mmap file, invalid len [len=").put(len)
95 .put(", offset=").put(offset)
96 .put(", fd=").put(fd)
97 .put(", memoryTag=").put(memoryTag)
98 .put(']');
99 }
100 if (offset != 0 || mmapCacheKey == 0 || !Files.FS_CACHE_ENABLED || flags == Files.MAP_RW) {
101 return mmap0(fd, len, offset, flags, memoryTag);
102 }
103
104 if (Files.ASYNC_MUNMAP_ENABLED) {
105 return cacheMmapOptimistic(fd, mmapCacheKey, len, memoryTag);
106 } else {
107 return cacheMmapPessimistic(fd, mmapCacheKey, len, memoryTag);
108 }
109 }
110
111 /**
112 * Returns number of times cached memory mappings were reused.

Callers 3

mremapMethod · 0.95
mmapMethod · 0.80
mmapNoCacheMethod · 0.80

Calls 5

criticalMethod · 0.95
mmap0Method · 0.95
cacheMmapOptimisticMethod · 0.95
cacheMmapPessimisticMethod · 0.95
putMethod · 0.65

Tested by

no test coverage detected