Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit cdc6c8c

Browse files
jfontanajnavarro
authored andcommitted
Improvement/use latest pilosa (#449)
* Revert "pilosa: use different holder per db/table pair" This reverts commit 144b824. Keeps the test to load multiple indexes. Signed-off-by: Javi Fontan <[email protected]> * travis: upgrade pilosa library for testing Lets reopen holder. Signed-off-by: Javi Fontan <[email protected]> (cherry picked from commit 8c2fc22)
1 parent e9c9ff5 commit cdc6c8c

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
install:
2121
- go get -u github.com/golang/dep/cmd/dep
2222
- touch Gopkg.toml
23-
- dep ensure -v -add "github.com/pilosa/pilosa@1.1.0" "github.com/moovweb/rubex@b3d9ff6ad7d9b14f94a91c8271cd9ad9e77132e5"
23+
- dep ensure -v -add "github.com/pilosa/pilosa@f62dbc00b96f596a1f2ef8b4e87ba8ec847eda37" "github.com/moovweb/rubex@b3d9ff6ad7d9b14f94a91c8271cd9ad9e77132e5"
2424
- make dependencies
2525

2626
before_script:

sql/index/pilosa/driver.go

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,19 @@ type (
6767
timeMapping time.Duration
6868
}
6969

70-
tableMap map[string]*pilosa.Holder
71-
dbMap map[string]tableMap
72-
7370
// Driver implements sql.IndexDriver interface.
7471
Driver struct {
75-
root string
76-
holders dbMap
72+
root string
73+
holder *pilosa.Holder
7774
}
7875
)
7976

8077
// NewDriver returns a new instance of pilosa.Driver
8178
// which satisfies sql.IndexDriver interface
8279
func NewDriver(root string) *Driver {
8380
return &Driver{
84-
root: root,
85-
holders: make(dbMap),
81+
root: root,
82+
holder: pilosa.NewHolder(),
8683
}
8784
}
8885

@@ -117,9 +114,8 @@ func (d *Driver) Create(
117114
return nil, err
118115
}
119116

120-
holder := d.holder(db, table)
121-
holder.Path = d.pilosaDirPath(db, table)
122-
idx, err := holder.CreateIndexIfNotExists(
117+
d.holder.Path = d.pilosaDirPath(db, table)
118+
idx, err := d.holder.CreateIndexIfNotExists(
123119
indexName(db, table),
124120
pilosa.IndexOptions{},
125121
)
@@ -148,20 +144,19 @@ func (d *Driver) LoadAll(db, table string) ([]sql.Index, error) {
148144
root = filepath.Join(d.root, db, table)
149145
)
150146

151-
holder := d.holder(db, table)
152-
holder.Path = d.pilosaDirPath(db, table)
153-
if _, err := os.Stat(holder.Path); err != nil {
147+
d.holder.Path = d.pilosaDirPath(db, table)
148+
if _, err := os.Stat(d.holder.Path); err != nil {
154149
if os.IsNotExist(err) {
155150
return indexes, nil
156151
}
157152
return nil, err
158153
}
159154

160-
err := holder.Open()
155+
err := d.holder.Open()
161156
if err != nil {
162157
return nil, err
163158
}
164-
defer holder.Close()
159+
defer d.holder.Close()
165160

166161
dirs, err := ioutil.ReadDir(root)
167162
if err != nil {
@@ -190,27 +185,9 @@ func (d *Driver) LoadAll(db, table string) ([]sql.Index, error) {
190185
return indexes, nil
191186
}
192187

193-
func (d *Driver) holder(db, table string) *pilosa.Holder {
194-
tables, ok := d.holders[db]
195-
if !ok {
196-
tables = make(tableMap)
197-
d.holders[db] = tables
198-
}
199-
200-
holder, ok := tables[table]
201-
if !ok {
202-
holder = pilosa.NewHolder()
203-
tables[table] = holder
204-
d.holders[db] = tables
205-
}
206-
207-
return holder
208-
}
209-
210188
func (d *Driver) loadIndex(db, table, id string) (*pilosaIndex, error) {
211189
name := indexName(db, table)
212-
holder := d.holder(db, table)
213-
idx := holder.Index(name)
190+
idx := d.holder.Index(name)
214191
if idx == nil {
215192
return nil, errLoadingIndex.New(name)
216193
}

0 commit comments

Comments
 (0)