You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A search engine built from scratch in pure Java 21 — no HashMap, no ArrayList, no String allocation during indexing. Every subsystem is designed around CPU cache locality, zero-GC ingestion, and lock-free concurrent reads.
Architecture
[Raw Files on Disk]
│
▼ Zero-copy mmap (FileChannel → MappedByteBuffer)
[MemoryMappedIngestor] Streams raw bytes via the OS page cache
│
▼ Zero-allocation bitwise parsing
[TokenHasher] Rolling 64-bit FNV-1a hash — tokens never become Strings
│
▼ O(1) primitive-array storage
[HighPerformanceIndex] Open-addressed hash table (long[] keys, int[] offsets)
│ + block-based postings arena (packed int[])
▼ StampedLock optimistic reads
[ConcurrentQueryEngine] Multi-threaded Okapi BM25 ranking
Parallel long[]/int[] arrays, linear probing, cache-line packed
Tokenizing
String.split() — floods Young Gen, triggers GC
Rolling FNV-1a hash over raw bytes, zero allocations
File I/O
BufferedReader — kernel→user-space copies
mmap via MappedByteBuffer, OS page cache serves bytes directly
Postings
ArrayList<Posting> objects
Packed [capacity, count, docId, tf, ...] blocks in one int[] arena, doubling relocation on overflow
Read concurrency
synchronized / read locks block
StampedLock optimistic reads — lock-free unless a write races, then graceful fallback
Components
HighPerformanceIndex — inverted index. Open addressing + linear probing, MurmurHash3 finalizer for slot spreading, amortized O(1) block growth for postings.
TokenHasher — shared FNV-1a hashing so ingestion (bytes) and queries (strings) produce identical token hashes.
ConcurrentQueryEngine — fixed thread pool sized to physical cores; BM25 scoring (k1=1.2, b=0.75); top-K result extraction.
SearchEngineHarness — end-to-end demo: writes a corpus to disk, ingests it, runs ranked queries, then holds a steady-state loop for VisualVM/JConsole heap profiling.