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

Method Flush

index/write.go:196–230  ·  view source on GitHub ↗

Flush flushes the index entry to the target file.

()

Source from the content-addressed store, hash-verified

194
195// Flush flushes the index entry to the target file.
196func (ix *IndexWriter) Flush() {
197 ix.addName("")
198
199 var off [5]uint32
200 ix.main.writeString(magic)
201 off[0] = ix.main.offset()
202 for _, p := range ix.paths {
203 ix.main.writeString(p)
204 ix.main.writeString("\x00")
205 }
206 ix.main.writeString("\x00")
207 off[1] = ix.main.offset()
208 copyFile(ix.main, ix.nameData)
209 off[2] = ix.main.offset()
210 ix.mergePost(ix.main)
211 off[3] = ix.main.offset()
212 copyFile(ix.main, ix.nameIndex)
213 off[4] = ix.main.offset()
214 copyFile(ix.main, ix.postIndex)
215 for _, v := range off {
216 ix.main.writeUint32(v)
217 }
218 ix.main.writeString(trailerMagic)
219
220 os.Remove(ix.nameData.name)
221 for _, f := range ix.postFile {
222 os.Remove(f.Name())
223 }
224 os.Remove(ix.nameIndex.name)
225 os.Remove(ix.postIndex.name)
226
227 log.Printf("%d data bytes, %d index bytes", ix.totalBytes, ix.main.offset())
228
229 ix.main.flush()
230}
231
232func copyFile(dst, src *bufWriter) {
233 dst.flush()

Callers 2

mainFunction · 0.80
buildFlushIndexFunction · 0.80

Calls 8

addNameMethod · 0.95
mergePostMethod · 0.95
copyFileFunction · 0.85
writeStringMethod · 0.80
offsetMethod · 0.80
writeUint32Method · 0.80
NameMethod · 0.80
flushMethod · 0.80

Tested by 1

buildFlushIndexFunction · 0.64