[#316] locode/csv: Scan subdivision csv-table into memory
Scanning subdivision csv-table entries one-by-one takes significant time and system resources. To speed up random access to table records, on the first call, the table is pumped into memory (map). On subsequent calls, I/O operations are not performed. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
307355f165
commit
977229eb5a
2 changed files with 57 additions and 16 deletions
|
@ -3,6 +3,7 @@ package csvlocode
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Prm groups the required parameters of the Table's constructor.
|
||||
|
@ -34,6 +35,10 @@ type Table struct {
|
|||
mode os.FileMode
|
||||
|
||||
subDivPath string
|
||||
|
||||
subDivOnce sync.Once
|
||||
|
||||
mSubDiv map[subDivKey]subDivRecord
|
||||
}
|
||||
|
||||
const invalidPrmValFmt = "invalid parameter %s (%T):%v"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue