MCPcopy
hub / github.com/google/codesearch / Open

Function Open

index/read.go:97–112  ·  view source on GitHub ↗
(file string)

Source from the content-addressed store, hash-verified

95const postEntrySize = 3 + 4 + 4
96
97func Open(file string) *Index {
98 mm := mmap(file)
99 if len(mm.d) < 4*4+len(trailerMagic) || string(mm.d[len(mm.d)-len(trailerMagic):]) != trailerMagic {
100 corrupt()
101 }
102 n := uint32(len(mm.d) - len(trailerMagic) - 5*4)
103 ix := &Index{data: mm}
104 ix.pathData = ix.uint32(n)
105 ix.nameData = ix.uint32(n + 4)
106 ix.postData = ix.uint32(n + 8)
107 ix.nameIndex = ix.uint32(n + 12)
108 ix.postIndex = ix.uint32(n + 16)
109 ix.numName = int((ix.postIndex-ix.nameIndex)/4) - 1
110 ix.numPost = int((n - ix.postIndex) / postEntrySize)
111 return ix
112}
113
114// slice returns the slice of index data starting at the given byte offset.
115// If n >= 0, the slice must have length at least n and is truncated to length n.

Callers 5

mainFunction · 0.92
MainFunction · 0.92
TestTrivialPostingFunction · 0.85
MergeFunction · 0.85
TestMergeFunction · 0.85

Calls 3

uint32Method · 0.95
mmapFunction · 0.85
corruptFunction · 0.85

Tested by 2

TestTrivialPostingFunction · 0.68
TestMergeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…