forked from TrueCloudLab/frostfs-node
[#316] locode/airports: Scan csv table into memory
Scanning 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
687c7d3b4a
commit
307355f165
2 changed files with 76 additions and 62 deletions
|
@ -3,6 +3,7 @@ package airportsdb
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Prm groups the required parameters of the DB's constructor.
|
||||
|
@ -30,6 +31,12 @@ type Prm struct {
|
|||
// The DB is immediately ready to work through API.
|
||||
type DB struct {
|
||||
airports, countries pathMode
|
||||
|
||||
airportsOnce, countriesOnce sync.Once
|
||||
|
||||
mCountries map[string]string
|
||||
|
||||
mAirports map[string][]record
|
||||
}
|
||||
|
||||
type pathMode struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue