Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
remove all references to inverse and range enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jaffee committed May 30, 2018
1 parent 6f1b7c4 commit d4f17ef
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 223 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ test:
go test

test-all:
go test -tags=integration -v
go test -tags=integration

test-all-race:
go test -race -tags=integration -v
go test -race -tags=integration

release:
printf "package pilosa\nconst Version = \"$(VERSION)\"" > version.go
printf "package pilosa\nconst Version = \"$(VERSION)\"" > version.go
18 changes: 7 additions & 11 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,9 @@ func (c *Client) Schema() (*Schema, error) {
for _, frameInfo := range indexInfo.Frames {
fields := make(map[string]rangeField)
frameOptions := &FrameOptions{
CacheSize: frameInfo.Options.CacheSize,
CacheType: CacheType(frameInfo.Options.CacheType),
InverseEnabled: frameInfo.Options.InverseEnabled,
TimeQuantum: TimeQuantum(frameInfo.Options.TimeQuantum),
RangeEnabled: frameInfo.Options.RangeEnabled,
CacheSize: frameInfo.Options.CacheSize,
CacheType: CacheType(frameInfo.Options.CacheType),
TimeQuantum: TimeQuantum(frameInfo.Options.TimeQuantum),
}
for _, fieldInfo := range frameInfo.Options.Fields {
fields[fieldInfo.Name] = map[string]interface{}{
Expand Down Expand Up @@ -1119,12 +1117,10 @@ type StatusFrame struct {

// StatusOptions contains options for a frame or an index.
type StatusOptions struct {
CacheType string `json:"cacheType"`
CacheSize uint `json:"cacheSize"`
InverseEnabled bool `json:"inverseEnabled"`
RangeEnabled bool `json:"rangeEnabled"`
Fields []StatusField `json:"fields"`
TimeQuantum string `json:"timeQuantum"`
CacheType string `json:"cacheType"`
CacheSize uint `json:"cacheSize"`
Fields []StatusField `json:"fields"`
TimeQuantum string `json:"timeQuantum"`
}

// StatusField contains a field in the status.
Expand Down
52 changes: 3 additions & 49 deletions client_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
testFrame, err = index.Frame("test-frame", &FrameOptions{RangeEnabled: true})
testFrame, err = index.Frame("test-frame", &FrameOptions{})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -399,47 +399,6 @@ func TestMaxHostsFail(t *testing.T) {
}
}

func TestQueryInverseBitmap(t *testing.T) {
client := getClient()
f1, err := index.Frame("f1-inversable", InverseEnabled(true))
if err != nil {
t.Fatal(err)
}
err = client.EnsureFrame(f1)
if err != nil {
t.Fatal(err)
}
_, err = client.Query(
index.BatchQuery(
f1.SetBit(1000, 5000),
f1.SetBit(1000, 6000),
f1.SetBit(3000, 5000)))
if err != nil {
t.Fatal(err)
}
response, err := client.Query(
index.BatchQuery(
f1.Bitmap(1000),
f1.InverseBitmap(5000),
))
if err != nil {
t.Fatal(err)
}
if len(response.Results()) != 2 {
t.Fatalf("Response should contain 2 results")
}
bits1 := response.Results()[0].Bitmap().Bits
targetBits1 := []uint64{5000, 6000}
if !reflect.DeepEqual(targetBits1, bits1) {
t.Fatalf("bits should be: %v, but it is: %v", targetBits1, bits1)
}
bits2 := response.Results()[1].Bitmap().Bits
targetBits2 := []uint64{1000, 3000}
if !reflect.DeepEqual(targetBits2, bits2) {
t.Fatalf("bits should be: %v, but it is: %v", targetBits2, bits2)
}
}

func TestQueryFailsIfAddressNotResolved(t *testing.T) {
uri, _ := NewURIFromAddress("nonexisting.domain.pilosa.com:3456")
client, _ := NewClient(uri)
Expand Down Expand Up @@ -515,7 +474,6 @@ func TestSchema(t *testing.T) {
f, err := index.Frame("schema-test-frame",
CacheTypeLRU,
CacheSize(9999),
InverseEnabled(true),
TimeQuantumYearMonthDay,
)
err = client.EnsureFrame(f)
Expand All @@ -537,9 +495,6 @@ func TestSchema(t *testing.T) {
if opt.CacheSize != 9999 {
t.Fatalf("cache size 9999 != %d", opt.CacheSize)
}
if opt.InverseEnabled != true {
t.Fatal("inverse enabled false")
}
if opt.TimeQuantum != TimeQuantumYearMonthDay {
t.Fatalf("time quantum %s != %s", string(TimeQuantumYearMonthDay), string(opt.TimeQuantum))
}
Expand Down Expand Up @@ -1133,8 +1088,7 @@ func TestRangeFrame(t *testing.T) {

func TestCreateIntField(t *testing.T) {
client := getClient()
options := &FrameOptions{RangeEnabled: true}
frame, _ := index.Frame("rangeframe-addfield", options)
frame, _ := index.Frame("rangeframe-addfield", &FrameOptions{})
err := client.EnsureFrame(frame)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1558,7 +1512,7 @@ func TestExportFrameFailure(t *testing.T) {
contentLength: -1,
},
"/slices/max": {
content: []byte(`{"standard":{"go-testindex": 0},"inverse":{}}`),
content: []byte(`{"standard":{"go-testindex": 0}}`),
statusCode: 404,
contentLength: -1,
},
Expand Down
5 changes: 0 additions & 5 deletions docs/data-model-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ Frame:
* `FilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery`
* `Range(rowID uint64, start time.Time, end time.Time) *PQLBitmapQuery`
* `SetRowAttrs(rowID uint64, attrs map[string]interface{}) *PQLBaseQuery`
* (**deprecated**) `InverseBitmap(columnID uint64) *PQLBitmapQuery`
* (**deprecated**) `InverseTopN(n uint64) *PQLBitmapQuery`
* (**deprecated**) `InverseBitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery`
* (**deprecated**) `InverseFilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery`
* (**deprecated**) `InverseRange(columnID uint64, start time.Time, end time.Time) *PQLBitmapQuery`
* (**deprecated**) `Sum(bitmap *PQLBitmapQuery, field string) *PQLBaseQuery`
* (**deprecated**) `SetIntFieldValue(columnID uint64, field string, value int) *PQLBaseQuery`

Expand Down
112 changes: 11 additions & 101 deletions orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,9 @@ type FrameInfo struct {
type FrameOptions struct {
// If a Frame has a time quantum, then Views are generated for each of the defined time segments.
TimeQuantum TimeQuantum
// Enables inverted frames
InverseEnabled bool
CacheType CacheType
CacheSize uint
RangeEnabled bool
fields map[string]rangeField
CacheType CacheType
CacheSize uint
fields map[string]rangeField
}

func (fo *FrameOptions) withDefaults() (updated *FrameOptions) {
Expand All @@ -392,9 +389,6 @@ func (fo *FrameOptions) withDefaults() (updated *FrameOptions) {

func (fo FrameOptions) String() string {
mopt := map[string]interface{}{}
if fo.InverseEnabled {
mopt["inverseEnabled"] = true
}
if fo.TimeQuantum != TimeQuantumNone {
mopt["timeQuantum"] = string(fo.TimeQuantum)
}
Expand All @@ -404,11 +398,7 @@ func (fo FrameOptions) String() string {
if fo.CacheSize != 0 {
mopt["cacheSize"] = fo.CacheSize
}
if fo.RangeEnabled {
mopt["rangeEnabled"] = true
}
if len(fo.fields) > 0 {
mopt["rangeEnabled"] = true
fields := make([]rangeField, 0, len(fo.fields))
for _, field := range fo.fields {
fields = append(fields, field)
Expand Down Expand Up @@ -463,16 +453,6 @@ func (fo *FrameOptions) addOptions(options ...interface{}) error {
// FrameOption is used to pass an option to index.Frame function.
type FrameOption func(options *FrameOptions) error

// InverseEnabled enables inverse frame.
// *DEPRECATED*
func InverseEnabled(enabled bool) FrameOption {
return func(options *FrameOptions) error {
log.Println("The InverseEnabled frame option is deprecated and will be removed.")
options.InverseEnabled = enabled
return nil
}
}

// OptFrameCacheSize sets the cache size.
func OptFrameCacheSize(size uint) FrameOption {
return func(options *FrameOptions) error {
Expand All @@ -488,16 +468,6 @@ func CacheSize(size uint) FrameOption {
return OptFrameCacheSize(size)
}

// RangeEnabled enables range encoding for a frame.
// *DEPRECATED*
func RangeEnabled(enabled bool) FrameOption {
return func(options *FrameOptions) error {
log.Println("The RangeEnabled frame option is deprecated and will be removed.")
options.RangeEnabled = enabled
return nil
}
}

// OptFrameIntField adds an integer field to the frame.
func OptFrameIntField(name string, min int, max int) FrameOption {
return func(options *FrameOptions) error {
Expand Down Expand Up @@ -565,22 +535,6 @@ func (f *Frame) BitmapK(rowKey string) *PQLBitmapQuery {
rowKey, f.name), f.index, nil)
}

// InverseBitmap creates a bitmap query using the column label.
// Bitmap retrieves the indices of all the set bits in a row or column based on whether the row label or column label is given in the query.
// It also retrieves any attributes set on that row or column.
// *DEPRECATED*
func (f *Frame) InverseBitmap(columnID uint64) *PQLBaseQuery {
return NewPQLBaseQuery(fmt.Sprintf("Bitmap(col=%d, frame='%s')",
columnID, f.name), f.index, nil)
}

// InverseBitmapK creates a Bitmap query using a string key instead of an
// integer columnID. This will only work against a Pilosa Enterprise server.
func (f *Frame) InverseBitmapK(columnKey string) *PQLBaseQuery {
return NewPQLBaseQuery(fmt.Sprintf("Bitmap(col='%s', frame='%s')",
columnKey, f.name), f.index, nil)
}

// SetBit creates a SetBit query.
// SetBit, assigns a value of 1 to a bit in the binary matrix, thus associating the given row in the given frame with the given column.
func (f *Frame) SetBit(rowID uint64, columnID uint64) *PQLBaseQuery {
Expand Down Expand Up @@ -628,64 +582,36 @@ func (f *Frame) ClearBitK(rowKey string, columnKey string) *PQLBaseQuery {
// TopN creates a TopN query with the given item count.
// Returns the id and count of the top n bitmaps (by count of bits) in the frame.
func (f *Frame) TopN(n uint64) *PQLBitmapQuery {
return NewPQLBitmapQuery(fmt.Sprintf("TopN(frame='%s', n=%d, inverse=false)", f.name, n), f.index, nil)
}

// InverseTopN creates a TopN query with the given item count.
// Returns the id and count of the top n bitmaps (by count of bits) in the frame.
// This variant sets inverse=true
// *DEPRECATED*
func (f *Frame) InverseTopN(n uint64) *PQLBitmapQuery {
return NewPQLBitmapQuery(fmt.Sprintf("TopN(frame='%s', n=%d, inverse=true)", f.name, n), f.index, nil)
return NewPQLBitmapQuery(fmt.Sprintf("TopN(frame='%s', n=%d)", f.name, n), f.index, nil)
}

// BitmapTopN creates a TopN query with the given item count and bitmap.
// This variant supports customizing the bitmap query.
func (f *Frame) BitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery {
return NewPQLBitmapQuery(fmt.Sprintf("TopN(%s, frame='%s', n=%d, inverse=false)",
bitmap.serialize(), f.name, n), f.index, nil)
}

// InverseBitmapTopN creates a TopN query with the given item count and bitmap.
// This variant supports customizing the bitmap query and sets inverse=true.
// *DEPRECATED*
func (f *Frame) InverseBitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery {
return NewPQLBitmapQuery(fmt.Sprintf("TopN(%s, frame='%s', n=%d, inverse=true)",
return NewPQLBitmapQuery(fmt.Sprintf("TopN(%s, frame='%s', n=%d)",
bitmap.serialize(), f.name, n), f.index, nil)
}

// FilterFieldTopN creates a TopN query with the given item count, bitmap, field and the filter for that field
// The field and filters arguments work together to only return Bitmaps which have the attribute specified by field with one of the values specified in filters.
func (f *Frame) FilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery {
return f.filterFieldTopN(n, bitmap, false, field, values...)
return f.filterFieldTopN(n, bitmap, field, values...)
}

// InverseFilterFieldTopN creates a TopN query with the given item count, bitmap, field and the filter for that field
// The field and filters arguments work together to only return Bitmaps which have the attribute specified by field with one of the values specified in filters.
// This variant sets inverse=true.
// *DEPRECATED*
func (f *Frame) InverseFilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery {
return f.filterFieldTopN(n, bitmap, true, field, values...)
}

func (f *Frame) filterFieldTopN(n uint64, bitmap *PQLBitmapQuery, inverse bool, field string, values ...interface{}) *PQLBitmapQuery {
func (f *Frame) filterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery {
if err := validateLabel(field); err != nil {
return NewPQLBitmapQuery("", f.index, err)
}
b, err := json.Marshal(values)
if err != nil {
return NewPQLBitmapQuery("", f.index, err)
}
inverseStr := "true"
if !inverse {
inverseStr = "false"
}
if bitmap == nil {
return NewPQLBitmapQuery(fmt.Sprintf("TopN(frame='%s', n=%d, inverse=%s, field='%s', filters=%s)",
f.name, n, inverseStr, field, string(b)), f.index, nil)
return NewPQLBitmapQuery(fmt.Sprintf("TopN(frame='%s', n=%d, field='%s', filters=%s)",
f.name, n, field, string(b)), f.index, nil)
}
return NewPQLBitmapQuery(fmt.Sprintf("TopN(%s, frame='%s', n=%d, inverse=%s, field='%s', filters=%s)",
bitmap.serialize(), f.name, n, inverseStr, field, string(b)), f.index, nil)
return NewPQLBitmapQuery(fmt.Sprintf("TopN(%s, frame='%s', n=%d, field='%s', filters=%s)",
bitmap.serialize(), f.name, n, field, string(b)), f.index, nil)
}

// Range creates a Range query.
Expand All @@ -702,22 +628,6 @@ func (f *Frame) RangeK(rowKey string, start time.Time, end time.Time) *PQLBitmap
rowKey, f.name, start.Format(timeFormat), end.Format(timeFormat)), f.index, nil)
}

// InverseRange creates a Range query.
// Similar to Bitmap, but only returns bits which were set with timestamps between the given start and end timestamps.
// *DEPRECATED*
func (f *Frame) InverseRange(columnID uint64, start time.Time, end time.Time) *PQLBitmapQuery {
return NewPQLBitmapQuery(fmt.Sprintf("Range(col=%d, frame='%s', start='%s', end='%s')",
columnID, f.name, start.Format(timeFormat), end.Format(timeFormat)), f.index, nil)
}

// InverseRangeK creates a Range query using a string column key. This will only
// work against a Pilosa Enterprise server.
// *DEPRECATED*
func (f *Frame) InverseRangeK(columnKey string, start time.Time, end time.Time) *PQLBitmapQuery {
return NewPQLBitmapQuery(fmt.Sprintf("Range(col='%s', frame='%s', start='%s', end='%s')",
columnKey, f.name, start.Format(timeFormat), end.Format(timeFormat)), f.index, nil)
}

// SetRowAttrs creates a SetRowAttrs query.
// SetRowAttrs associates arbitrary key/value pairs with a row in a frame.
// Following types are accepted: integer, float, string and boolean types.
Expand Down
Loading

0 comments on commit d4f17ef

Please sign in to comment.