NOTE

2.19 Index

What an index is, index types, implementations, and selection considerations.

Data Structures & AlgorithmsCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is an Index

  • An index is a data structure that associates search keys with corresponding data records (it can be regarded as key-value pairs)
  • Index lookup finds data through the index

2. Why Index Is Needed

  • Used to speed up data lookup

3. Sparse Index vs Dense Index

4. Forward Index vs Inverted Index

5. How to Implement an Index

5.1. Sorted Array

5.2. HashMap

5.3. BitMap

5.4. BloomFilter

5.5. SSTable

5.6. Red-Black Tree

5.7. B+Tree

5.8. SkipList

6. How to Choose an Index Implementation

  • Is the data structured or unstructured?
  • Is the data static or dynamic?
  • Is the index stored in memory or on disk?
  • Exact-value lookup or range lookup?
  • Single-keyword lookup or multi-keyword combined lookup?

6.1. Hash vs SSTable

Hash SSTable
Fully loaded into memory? Yes No
Query efficiency High for equality queries High for range queries
Can keys repeat? No Yes

7. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub