Merge pull request #376 from linhvo/pil357-frame-name

Pil357 frame name
This commit is contained in:
Travis Turner 2017-03-10 16:18:26 -06:00 • committed by GitHub
commit 371665f459
5 changed files with 11 additions and 11 deletions

6
db.go
View file

@ -60,7 +60,7 @@ func NewDB(path, name string) (*DB, error) {
frames: make(map[string]*Frame),
remoteMaxSlice: 0,
profileAttrStore: NewAttrStore(filepath.Join(path, "data")),
profileAttrStore: NewAttrStore(filepath.Join(path, ".data")),
columnLabel: DefaultColumnLabel,
@ -165,7 +165,7 @@ func (db *DB) loadMeta() error {
var pb internal.DB
// Read data from meta file.
buf, err := ioutil.ReadFile(filepath.Join(db.path, "meta"))
buf, err := ioutil.ReadFile(filepath.Join(db.path, ".meta"))
if os.IsNotExist(err) {
db.timeQuantum = ""
db.columnLabel = DefaultColumnLabel
@ -197,7 +197,7 @@ func (db *DB) saveMeta() error {
}
// Write to meta file.
if err := ioutil.WriteFile(filepath.Join(db.path, "meta"), buf, 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(db.path, ".meta"), buf, 0666); err != nil {
return err
}

View file

@ -58,7 +58,7 @@ func NewFrame(path, db, name string) (*Frame, error) {
name: name,
fragments: make(map[uint64]*Fragment),
bitmapAttrStore: NewAttrStore(filepath.Join(path, "data")),
bitmapAttrStore: NewAttrStore(filepath.Join(path, ".data")),
stats: NopStatsClient,
@ -202,7 +202,7 @@ func (f *Frame) loadMeta() error {
var pb internal.Frame
// Read data from meta file.
buf, err := ioutil.ReadFile(filepath.Join(f.path, "meta"))
buf, err := ioutil.ReadFile(filepath.Join(f.path, ".meta"))
if os.IsNotExist(err) {
f.timeQuantum = ""
f.rowLabel = DefaultRowLabel
@ -234,7 +234,7 @@ func (f *Frame) saveMeta() error {
}
// Write to meta file.
if err := ioutil.WriteFile(filepath.Join(f.path, "meta"), buf, 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(f.path, ".meta"), buf, 0666); err != nil {
return err
}

View file

@ -106,13 +106,13 @@ func (f *Frame) Reopen() error {
return nil
}
// NewFrame returns a new instance of Frame d/0.
// NewFrame does not return a frame when name is invalid.
func TestFrame_NameRestriction(t *testing.T) {
path, err := ioutil.TempDir("", "pilosa-frame-")
if err != nil {
panic(err)
}
frame, err := pilosa.NewFrame(path, "d", "ABC")
frame, err := pilosa.NewFrame(path, "d", ".meta")
if frame != nil {
t.Fatalf("unexpected frame name %s", err)
}

View file

@ -605,7 +605,7 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) {
// Set attributes on the database.
d := idx.MustCreateDBIfNotExists("d", pilosa.DBOptions{})
f, err := d.CreateFrameIfNotExists("f", pilosa.FrameOptions{})
f, err := d.CreateFrameIfNotExists("meta", pilosa.FrameOptions{})
if err != nil {
t.Fatal(err)
}
@ -631,7 +631,7 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) {
resp, err := http.Post(
s.URL+"/frame/attr/diff?db=d",
"application/json",
strings.NewReader(`{"db":"d", "frame":"f", "blocks":`+string(MustMarshalJSON(blks))+`}`),
strings.NewReader(`{"db":"d", "frame":"meta", "blocks":`+string(MustMarshalJSON(blks))+`}`),
)
if err != nil {
t.Fatal(err)

View file

@ -29,7 +29,7 @@ var (
// Regular expression to valuate db and frame's name
// Todo: remove . when frame doesn't require . for topN
var nameRegexp = regexp.MustCompile(`^([a-z0-9._-]{1,64}$)`)
var nameRegexp = regexp.MustCompile(`^[a-z0-9][a-z0-9._-]{0,64}$`)
// Profile represents vertical column in a database.
// A profile can have a set of attributes attached to it.