LoadRecords loads and indexes raw protobuf records from the data files found in a given path.
(dataPath string)
| 17 | // LoadRecords loads and indexes raw protobuf records from |
| 18 | // the data files found in a given path. |
| 19 | func LoadRecords(dataPath string) (*Records, error) { |
| 20 | recs := &Records{ |
| 21 | Index: WithDriver(dataPath, RecordDriver{}), |
| 22 | metaBy: make(map[string]metaIndex), |
| 23 | } |
| 24 | |
| 25 | if err := recs.Load(); err != nil { |
| 26 | return nil, err |
| 27 | } |
| 28 | |
| 29 | for _, m := range recs.index { |
| 30 | recs.metaIndexCreate(m.(*pb.Record)) |
| 31 | } |
| 32 | |
| 33 | return recs, nil |
| 34 | } |
| 35 | |
| 36 | func (r *Records) metaIndexCreate(rec *pb.Record) { |
| 37 | r.Lock() |