This commit is contained in:
alex.sharov 2022-12-06 12:28:53 +07:00
parent 183856e788
commit 00bb99d66d
2 changed files with 12 additions and 1 deletions

View File

@ -182,6 +182,7 @@ func (h *History) scanStateFiles(files []fs.DirEntry) {
continue
}
}
log.Info("scan files", "name", fmt.Sprintf("%s.%d-%d.v", h.filenameBase, startStep, endStep))
h.files.ReplaceOrInsert(item)
}
if len(uselessFiles) > 0 {
@ -201,10 +202,12 @@ func (h *History) openFiles() error {
fromStep, toStep := item.startTxNum/h.aggregationStep, item.endTxNum/h.aggregationStep
datPath := filepath.Join(h.dir, fmt.Sprintf("%s.%d-%d.v", h.filenameBase, fromStep, toStep))
if !dir.FileExist(datPath) {
log.Warn("open files: not exists!", "name", fmt.Sprintf("%s.%d-%d.v", h.filenameBase, fromStep, toStep))
invalidFileItems = append(invalidFileItems, item)
return true
}
if item.decompressor, err = compress.NewDecompressor(datPath); err != nil {
log.Warn("open files: NewDecompressor!", "err", err, "name", fmt.Sprintf("%s.%d-%d.v", h.filenameBase, fromStep, toStep))
log.Debug("Hisrory.openFiles: %w, %s", err, datPath)
return false
}
@ -212,10 +215,13 @@ func (h *History) openFiles() error {
idxPath := filepath.Join(h.dir, fmt.Sprintf("%s.%d-%d.vi", h.filenameBase, fromStep, toStep))
if dir.FileExist(idxPath) {
if item.index, err = recsplit.OpenIndex(idxPath); err != nil {
log.Warn("open files: recsplit.OpenIndex!", "err", err, "name", fmt.Sprintf("%s.%d-%d.v", h.filenameBase, fromStep, toStep))
log.Debug("Hisrory.openFiles: %w, %s", err, idxPath)
return false
}
totalKeys += item.index.KeyCount()
} else {
log.Warn("open files: not exists!", "err", fmt.Sprintf("%s.%d-%d.vi", h.filenameBase, fromStep, toStep))
}
}
return true

View File

@ -246,9 +246,11 @@ func (ii *InvertedIndex) openFiles() error {
fromStep, toStep := item.startTxNum/ii.aggregationStep, item.endTxNum/ii.aggregationStep
datPath := filepath.Join(ii.dir, fmt.Sprintf("%s.%d-%d.ef", ii.filenameBase, fromStep, toStep))
if !dir.FileExist(datPath) {
log.Warn("open files: not exists!", "name", fmt.Sprintf("%s.%d-%d.ef", ii.filenameBase, fromStep, toStep))
invalidFileItems = append(invalidFileItems, item)
}
if item.decompressor, err = compress.NewDecompressor(datPath); err != nil {
log.Warn("open files: compress.NewDecompressor!", "err", err, "name", fmt.Sprintf("%s.%d-%d.ef", ii.filenameBase, fromStep, toStep))
log.Debug("InvertedIndex.openFiles: %w, %s", err, datPath)
return false
}
@ -257,10 +259,13 @@ func (ii *InvertedIndex) openFiles() error {
idxPath := filepath.Join(ii.dir, fmt.Sprintf("%s.%d-%d.efi", ii.filenameBase, fromStep, toStep))
if dir.FileExist(idxPath) {
if item.index, err = recsplit.OpenIndex(idxPath); err != nil {
log.Debug("InvertedIndex.openFiles: %w, %s", err, idxPath)
log.Warn("open files: recsplit.OpenIndex!", "err", err, "name", fmt.Sprintf("%s.%d-%d.efi", ii.filenameBase, fromStep, toStep))
log.Info("open files: not exists!", "name", fmt.Sprintf("%s.%d-%d.efi", ii.filenameBase, fromStep, toStep))
return false
}
totalKeys += item.index.KeyCount()
} else {
log.Warn("open files: not exists!", "name", fmt.Sprintf("%s.%d-%d.efi", ii.filenameBase, fromStep, toStep))
}
}
return true