in memory logs search
git clone https://github.com/avinashb98/log-search
cd log-search
- O(n) worst-case, n is the total number of logs
- O(1) best-case
ADD [key] [text]
Time Complexities
- O(n) worst-case, n is the total number of logs
- O(1) best-case
SEARCH [word] [limit]
# input.txt
n # number which is the maximum logs stored
.
.
command
.
.
END
cp input_sample.txt input.txt
# edit the sample commands file
go build .
./log-search
go test -v ./...
The inverted index consists of 2 data structures.
It is a map of a word to a list of entryIds. Used to optimally query entries corresponding to a word.
It is a map of an entryId to a list of keys. Used to optimally unmap a deleted or updated entry.