--------------------------------------------------------
(dir string, options StoreOptions)
| 515 | // -------------------------------------------------------- |
| 516 | |
| 517 | func openStore(dir string, options StoreOptions) (*Store, error) { |
| 518 | fileInfos, err := ioutil.ReadDir(dir) |
| 519 | if err != nil { |
| 520 | return nil, err |
| 521 | } |
| 522 | |
| 523 | var maxFNameSeq int64 |
| 524 | |
| 525 | var fnames []string |
| 526 | for _, fileInfo := range fileInfos { // Find candidate file names. |
| 527 | fname := fileInfo.Name() |
| 528 | if strings.HasPrefix(fname, StorePrefix) && |
| 529 | strings.HasSuffix(fname, StoreSuffix) { |
| 530 | fnames = append(fnames, fname) |
| 531 | } |
| 532 | |
| 533 | fnameSeq, err := ParseFNameSeq(fname) |
| 534 | if err == nil && fnameSeq > maxFNameSeq { |
| 535 | maxFNameSeq = fnameSeq |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | if options.OpenFile == nil { |
| 540 | options.OpenFile = |
| 541 | func(name string, flag int, perm os.FileMode) (File, error) { |
| 542 | return os.OpenFile(name, flag, perm) |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | histograms := make(ghistogram.Histograms) |
| 547 | histograms["PersistFooterUsecs"] = |
| 548 | ghistogram.NewNamedHistogram("PersistFooterUsecs", 10, 4, 4) |
| 549 | histograms["PersistUsecs"] = |
| 550 | ghistogram.NewNamedHistogram("PersistUsecs", 10, 4, 4) |
| 551 | histograms["CompactUsecs"] = |
| 552 | ghistogram.NewNamedHistogram("CompactUsecs", 10, 4, 4) |
| 553 | |
| 554 | if len(fnames) <= 0 { |
| 555 | emptyFooter := &Footer{ |
| 556 | refs: 1, |
| 557 | ss: &segmentStack{options: &options.CollectionOptions}, |
| 558 | ChildFooters: make(map[string]*Footer), |
| 559 | } |
| 560 | |
| 561 | return &Store{ |
| 562 | dir: dir, |
| 563 | options: &options, |
| 564 | refs: 1, |
| 565 | footer: emptyFooter, |
| 566 | nextFNameSeq: 1, |
| 567 | histograms: histograms, |
| 568 | fileRefMap: make(map[string]*FileRef), |
| 569 | abortCh: make(chan struct{}), |
| 570 | }, nil |
| 571 | } |
| 572 | |
| 573 | sort.Strings(fnames) |
| 574 | if options.CollectionOptions.Log != nil { |
no test coverage detected
searching dependent graphs…