From 0a1de81441af1666294cfc345445528a71d62992 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Thu, 9 Jan 2020 10:47:09 -0600 Subject: [PATCH] allow field and index names up to 230 characters The lowest limitation I've seen on any filesystem we care about is 255 characters. 230 leaves enough space that an index or field could be backed up and have a timestamp and file extension appended while still allowing for much longer index and field names. --- docs/getting-started.md | 8 ++++---- docs/query-language.md | 2 +- field_test.go | 3 ++- pilosa.go | 4 ++-- pilosa_internal_test.go | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index a236d2156..982bf1ca1 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -100,7 +100,7 @@ curl localhost:10101/index/repository -X POST ``` response {"success":true} ``` -The index name must be 64 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. +The index name must be 230 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. Let's create the `stargazer` field which has user IDs of stargazers as its rows: ``` request @@ -325,7 +325,7 @@ Next, let's create the `repository` index: repository := schema.Index("repository") ``` -The index name must be 64 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. +The index name must be 230 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. Let's create the `stargazer` field which has user IDs of stargazers as its rows: ``` @@ -615,7 +615,7 @@ Next, let's create the `repository` index: ``` Index repository = schema.index("repository"); ``` -The index name must be 64 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. +The index name must be 230 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. Let's create the `stargazer` field which has user IDs of stargazers as its rows: ``` @@ -818,7 +818,7 @@ Next, let's create the `repository` index: ``` repository = schema.index("repository") ``` -The index name must be 64 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. +The index name must be 230 characters or fewer, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. The same goes for field names. Let's create the `stargazer` field which has user IDs of stargazers as its rows: ``` diff --git a/docs/query-language.md b/docs/query-language.md index 4413d95d7..527cad445 100644 --- a/docs/query-language.md +++ b/docs/query-language.md @@ -43,7 +43,7 @@ curl localhost:10101/index/repository/query \ #### Arguments and Types -* `field` The field specifies on which Pilosa [field](../glossary/#field) the query will operate. Valid field names are lower case strings; they start with a lowercase letter, and contain only alphanumeric characters and `_-`. They must be 64 characters or less in length. +* `field` The field specifies on which Pilosa [field](../glossary/#field) the query will operate. Valid field names are lower case strings; they start with a lowercase letter, and contain only alphanumeric characters and `_-`. They must be 230 characters or less in length. * `TIMESTAMP` This is a timestamp in the following format `YYYY-MM-DDTHH:MM` (e.g. 2006-01-02T15:04). * `UINT` An unsigned integer (e.g. 42839). * `BOOL` A boolean value, `true` or `false`. diff --git a/field_test.go b/field_test.go index 398002ca2..40b64728a 100644 --- a/field_test.go +++ b/field_test.go @@ -158,6 +158,7 @@ func TestField_NameValidation(t *testing.T) { "under_score", "abc123", "trailing_", + "charact2301234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", } invalidFieldNames := []string{ "", @@ -168,7 +169,7 @@ func TestField_NameValidation(t *testing.T) { "abc def", "camelCase", "UPPERCASE", - "a12345678901234567890123456789012345678901234567890123456789012345", + "charact23112345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", } path, err := ioutil.TempDir("", "pilosa-field-") diff --git a/pilosa.go b/pilosa.go index 42ab3d3c1..61f3cde53 100644 --- a/pilosa.go +++ b/pilosa.go @@ -48,7 +48,7 @@ var ( ErrInvalidView = errors.New("invalid view") ErrInvalidCacheType = errors.New("invalid cache type") - ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 64 characters") + ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 230 characters") ErrLabel = errors.New("invalid row or column label, must match [A-Za-z0-9_-]") // ErrFragmentNotFound is returned when a fragment does not exist. @@ -118,7 +118,7 @@ func newNotFoundError(err error) NotFoundError { } // Regular expression to validate index and field names. -var nameRegexp = regexp.MustCompile(`^[a-z][a-z0-9_-]{0,63}$`) +var nameRegexp = regexp.MustCompile(`^[a-z][a-z0-9_-]{0,229}$`) // ColumnAttrSet represents a set of attributes for a vertical column in an index. // Can have a set of attributes attached to it. diff --git a/pilosa_internal_test.go b/pilosa_internal_test.go index 40e33ac4b..4abe89072 100644 --- a/pilosa_internal_test.go +++ b/pilosa_internal_test.go @@ -21,7 +21,7 @@ import ( func TestValidateName(t *testing.T) { names := []string{ "a", "ab", "ab1", "b-c", "d_e", "exists", - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "longbutnottoolongaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345689012345689012345678901234567890", } for _, name := range names { if validateName(name) != nil { @@ -33,7 +33,7 @@ func TestValidateName(t *testing.T) { func TestValidateNameInvalid(t *testing.T) { names := []string{ "", "'", "^", "/", "\\", "A", "*", "a:b", "valid?no", "yüce", "1", "_", "-", - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", "_exists", + "long123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1", "_exists", } for _, name := range names { if validateName(name) == nil {