本文整理汇总了Golang中github.com/balzaczyy/golucene/core/store.IndexOutput.WriteStringSet方法的典型用法代码示例。如果您正苦于以下问题:Golang IndexOutput.WriteStringSet方法的具体用法?Golang IndexOutput.WriteStringSet怎么用?Golang IndexOutput.WriteStringSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/balzaczyy/golucene/core/store.IndexOutput
的用法示例。
在下文中一共展示了IndexOutput.WriteStringSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: write
func (sis *SegmentInfos) write(directory store.Directory) (err error) {
segmentsFilename := sis.nextSegmentFilename()
// Always advance the generation on write:
if sis.generation == -1 {
sis.generation = 1
} else {
sis.generation++
}
var segnOutput store.IndexOutput
var success = false
// var upgradedSIFiles = make(map[string]bool)
defer func() {
if !success {
// We hit an error above; try to close the file but suppress
// any errors
util.CloseWhileSuppressingError(segnOutput)
// for filename, _ := range upgradedSIFiles {
// directory.DeleteFile(filename) // ignore error
// }
// Try not to leave a truncated segments_N fle in the index:
directory.DeleteFile(segmentsFilename) // ignore error
}
}()
if segnOutput, err = directory.CreateOutput(segmentsFilename, store.IO_CONTEXT_DEFAULT); err != nil {
return
}
if err = codec.WriteHeader(segnOutput, "segments", VERSION_49); err != nil {
return
}
if err = segnOutput.WriteLong(sis.version); err == nil {
if err = segnOutput.WriteInt(int32(sis.counter)); err == nil {
err = segnOutput.WriteInt(int32(len(sis.Segments)))
}
}
if err != nil {
return
}
for _, siPerCommit := range sis.Segments {
si := siPerCommit.Info
if err = segnOutput.WriteString(si.Name); err == nil {
if err = segnOutput.WriteString(si.Codec().(Codec).Name()); err == nil {
if err = segnOutput.WriteLong(siPerCommit.DelGen()); err == nil {
assert2(siPerCommit.DelCount() >= 0 && siPerCommit.DelCount() <= si.DocCount(),
"cannot write segment: invalid docCount segment=%v docCount=%v delCount=%v",
si.Name, si.DocCount(), siPerCommit.DelCount())
if err = segnOutput.WriteInt(int32(siPerCommit.DelCount())); err == nil {
if err = segnOutput.WriteLong(siPerCommit.FieldInfosGen()); err == nil {
if err = segnOutput.WriteLong(siPerCommit.DocValuesGen()); err == nil {
if err = segnOutput.WriteStringSet(siPerCommit.FieldInfosFiles()); err == nil {
dvUpdatesFiles := siPerCommit.DocValuesUpdatesFiles()
if err = segnOutput.WriteInt(int32(len(dvUpdatesFiles))); err == nil {
for k, v := range dvUpdatesFiles {
if err = segnOutput.WriteInt(int32(k)); err != nil {
break
}
if err = segnOutput.WriteStringSet(v); err != nil {
break
}
}
}
}
}
}
}
}
}
}
if err != nil {
return
}
assert(si.Dir == directory)
// If this segment is pre-4.x, perform a one-time "upgrade" to
// write the .si file for it:
if version := si.Version(); len(version) == 0 || !version.OnOrAfter(util.VERSION_4_0) {
panic("not implemented yet")
}
}
if err = segnOutput.WriteStringStringMap(sis.userData); err != nil {
return
}
sis.pendingSegnOutput = segnOutput
success = true
return nil
}