diff --git a/dbshard.go b/dbshard.go index 1cdfaa912..d381c9f85 100644 --- a/dbshard.go +++ b/dbshard.go @@ -34,12 +34,12 @@ import ( var _ = sort.Sort const ( - // DefaultBackendsDir is the default backends directory used to store the + // backendsDir is the default backends directory used to store the // data for each backend. - DefaultBackendsDir = "backends" + backendsDir = "backends" - // DefaultBackendDirPrefix is the default prefix of each backend directory. - DefaultBackendDirPrefix = "backend" + // backendDirPrefix is the default prefix of each backend directory. + backendDirPrefix = "backend" ) // types to support a database file per shard @@ -133,10 +133,6 @@ func (dbs *DBShard) Close() (err error) { return } -func (dbs *DBShard) HolderString() string { - return dbs.HolderPath -} - // Cleanup must be called at every commit/rollback of a Tx, in // order to release the read-write mutex that guarantees a single // writer at a time. Each tx must take care to call cleanup() @@ -570,7 +566,7 @@ func (dbs *DBShard) pathForType(ty txtype) string { // what here for roaring? well, roaringRegistrar.OpenDBWrapper() // is a no-op anyhow. so doesn't need to be correct atm. - path := dbs.HolderPath + sep + dbs.Index + sep + DefaultBackendsDir + sep + DefaultBackendDirPrefix + ty.FileSuffix() + sep + fmt.Sprintf("shard.%04v%v", dbs.Shard, ty.FileSuffix()) + path := dbs.HolderPath + sep + dbs.Index + sep + backendsDir + sep + backendDirPrefix + ty.FileSuffix() + sep + fmt.Sprintf("shard.%04v%v", dbs.Shard, ty.FileSuffix()) if ty == boltTxn { // special case: // bolt doesn't use a directory like the others, just a direct path. @@ -583,7 +579,7 @@ func (dbs *DBShard) pathForType(ty txtype) string { // prefixForType and pathForType must be kept in sync! func (per *DBPerShard) prefixForType(idx *Index, ty txtype) string { // top level paths will end in "@@" - return per.HolderDir + sep + idx.name + sep + DefaultBackendsDir + sep + DefaultBackendDirPrefix + ty.FileSuffix() + sep + return per.HolderDir + sep + idx.name + sep + backendsDir + sep + backendDirPrefix + ty.FileSuffix() + sep } var ErrNoData = fmt.Errorf("no data") diff --git a/holder.go b/holder.go index 6fe1abbd5..38a1df3aa 100644 --- a/holder.go +++ b/holder.go @@ -51,14 +51,14 @@ const ( // existenceFieldName is the name of the internal field used to store existence values. existenceFieldName = "_exists" - // DefaultDiscoDir is the default data directory used by the disco implementation. - DefaultDiscoDir = "disco" + // DiscoDir is the default data directory used by the disco implementation. + DiscoDir = "disco" - // DefaultIndexesDir is the default indexes directory used by the holder. - DefaultIndexesDir = "indexes" + // IndexesDir is the default indexes directory used by the holder. + IndexesDir = "indexes" - // DefaultFieldsDir is the default fields directory used by each index. - DefaultFieldsDir = "fields" + // FieldsDir is the default fields directory used by each index. + FieldsDir = "fields" // ColumnAttrsFileName is the name of the file used for the column attributes store. ColumnAttrsFileName = "column-attributes" @@ -321,7 +321,7 @@ func (h *Holder) Path() string { // IndexesPath returns the path of the indexes directory. func (h *Holder) IndexesPath() string { - return filepath.Join(h.path, DefaultIndexesDir) + return filepath.Join(h.path, IndexesDir) } type HolderInfo struct { diff --git a/index.go b/index.go index 411f37035..6bec27db8 100644 --- a/index.go +++ b/index.go @@ -142,7 +142,7 @@ func (i *Index) Path() string { // FieldsPath returns the path of the fields directory. func (i *Index) FieldsPath() string { - return filepath.Join(i.path, DefaultFieldsDir) + return filepath.Join(i.path, FieldsDir) } // TranslateStorePath returns the translation database path for a partition. diff --git a/server/server.go b/server/server.go index ab94b40f5..40ff3a7ec 100644 --- a/server/server.go +++ b/server/server.go @@ -388,7 +388,7 @@ func (m *Command) SetupServer() error { if err != nil { return errors.Wrapf(err, "expanding directory name: %s", m.Config.DataDir) } - m.Config.Etcd.Dir = filepath.Join(path, pilosa.DefaultDiscoDir) + m.Config.Etcd.Dir = filepath.Join(path, pilosa.DiscoDir) } e := petcd.NewEtcdWithCache(m.Config.Etcd, m.Config.Cluster.ReplicaN) diff --git a/server/server_test.go b/server/server_test.go index 43e67f5ab..44aee924e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -839,7 +839,7 @@ func TestMain_ImportTimestamp(t *testing.T) { t.Fatal(err) } // Ensure the correct views were created. - dir := fmt.Sprintf("%s/%s/%s/%s/%s/views", m.Config.DataDir, pilosa.DefaultIndexesDir, indexName, pilosa.DefaultFieldsDir, fieldName) + dir := fmt.Sprintf("%s/%s/%s/%s/%s/views", m.Config.DataDir, pilosa.IndexesDir, indexName, pilosa.FieldsDir, fieldName) files, err := ioutil.ReadDir(dir) if err != nil { t.Fatal(err) @@ -895,7 +895,7 @@ func TestMain_ImportTimestampNoStandardView(t *testing.T) { } // Ensure the correct views were created. - dir := fmt.Sprintf("%s/%s/%s/%s/%s/views", m.Config.DataDir, pilosa.DefaultIndexesDir, indexName, pilosa.DefaultFieldsDir, fieldName) + dir := fmt.Sprintf("%s/%s/%s/%s/%s/views", m.Config.DataDir, pilosa.IndexesDir, indexName, pilosa.FieldsDir, fieldName) files, err := ioutil.ReadDir(dir) if err != nil { t.Fatal(err) diff --git a/txfactory.go b/txfactory.go index b9f51c601..bb60299f8 100644 --- a/txfactory.go +++ b/txfactory.go @@ -691,7 +691,7 @@ func (f *TxFactory) fieldUsage(indexPath string, fld *Field) (FieldUsage, error) } // field metadata, e.g. rowAttrs - fieldPath := path.Join(indexPath, DefaultFieldsDir, field) + fieldPath := path.Join(indexPath, FieldsDir, field) metaBytes, err := directoryUsage(fieldPath, false) // this includes keys if err != nil { return fieldUsage, errors.Wrapf(err, "getting disk usage for field meta (%s)", field) @@ -750,10 +750,9 @@ func directoryUsage(fname string, recursive bool) (uint64, error) { return size, nil } +// CloseIndex is a no-op. This seems to be in place for debugging purposes. func (f *TxFactory) CloseIndex(idx *Index) error { - // under roaring and all the new databases, this is a no-op. //idx.Dump("CloseIndex") - return nil }