Skip to content

Commit

Permalink
Fix tests and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
xichen2020 committed Dec 27, 2018
1 parent ec459b5 commit cb61c1d
Show file tree
Hide file tree
Showing 9 changed files with 448 additions and 455 deletions.
269 changes: 109 additions & 160 deletions encoding/encoding_mock.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/mocks/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ package mocks
//go:generate sh -c "mockgen -package=encoding $PACKAGE/encoding RewindableIntIterator,RewindableStringIterator,ForwardDoubleIterator,ForwardBoolIterator | genclean -pkg $PACKAGE/encoding -out $GOPATH/src/$PACKAGE/encoding/encoding_mock.go"

// mockgen rules for generating mocks for unexported interfaces (file mode).
//go:generate sh -c "mockgen -package=storage -destination=$GOPATH/src/$PACKAGE/storage/segment_mock.go -source=$GOPATH/src/$PACKAGE/storage/segment.go"
//go:generate sh -c "mockgen -package=storage -destination=$GOPATH/src/$PACKAGE/storage/segment_base_mock.go -source=$GOPATH/src/$PACKAGE/storage/segment_base.go"
5 changes: 4 additions & 1 deletion server/http/handlers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ func (s *service) Query(w http.ResponseWriter, r *http.Request) {
return
}

pq, err := q.Parse()
parseOpts := query.ParseOptions{
FieldPathSeparator: s.dbOpts.FieldPathSeparator(),
}
pq, err := q.Parse(parseOpts)
if err != nil {
err = fmt.Errorf("unable to parse raw query %v: %v", q, err)
writeErrorResponse(w, err)
Expand Down
3 changes: 2 additions & 1 deletion storage/immutable_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type immutableSeg struct {
fields map[hash.Hash]document.DocsField
}

// nolint: unparam
func newImmutableSegment(
id string,
numDocs int32,
Expand Down Expand Up @@ -505,7 +506,7 @@ func (s *immutableSeg) addQueryFieldToMap(
fm map[hash.Hash]queryFieldMeta,
newFieldMeta queryFieldMeta,
) error {
// Do not insert emtpy fields.
// Do not insert empty fields.
if len(newFieldMeta.fieldPath) == 0 {
return nil
}
Expand Down
5 changes: 1 addition & 4 deletions storage/sealed_segment.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package storage

import (
"sync"
"sync/atomic"
"time"

Expand Down Expand Up @@ -78,8 +77,6 @@ type sealedFlushingSeg struct {
nowFn clock.NowFn
unloadAfterUnreadFor time.Duration

numReaders int32
wgRead sync.WaitGroup
lastReadAtNanos int64

// The flush related fields are always accessed within a single-thread context
Expand Down Expand Up @@ -122,7 +119,7 @@ func (s *sealedFlushingSeg) ShouldUnload() bool {
}

// If there are readers currently reading from this segment, don't unload.
if atomic.LoadInt32(&s.numReaders) > 0 {
if s.NumReaders() > 0 {
return false
}

Expand Down
262 changes: 262 additions & 0 deletions storage/segment_base_mock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
// Copyright (c) 2018 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Automatically generated by MockGen. DO NOT EDIT!
// Source: github.com/xichen2020/eventdb/storage/segment_base.go

package storage

import (
"github.com/golang/mock/gomock"
)

// Mock of immutableSegmentBase interface
type MockimmutableSegmentBase struct {
ctrl *gomock.Controller
recorder *_MockimmutableSegmentBaseRecorder
}

// Recorder for MockimmutableSegmentBase (not exported)
type _MockimmutableSegmentBaseRecorder struct {
mock *MockimmutableSegmentBase
}

func NewMockimmutableSegmentBase(ctrl *gomock.Controller) *MockimmutableSegmentBase {
mock := &MockimmutableSegmentBase{ctrl: ctrl}
mock.recorder = &_MockimmutableSegmentBaseRecorder{mock}
return mock
}

func (_m *MockimmutableSegmentBase) EXPECT() *_MockimmutableSegmentBaseRecorder {
return _m.recorder
}

func (_m *MockimmutableSegmentBase) ID() string {
ret := _m.ctrl.Call(_m, "ID")
ret0, _ := ret[0].(string)
return ret0
}

func (_mr *_MockimmutableSegmentBaseRecorder) ID() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ID")
}

func (_m *MockimmutableSegmentBase) NumDocuments() int32 {
ret := _m.ctrl.Call(_m, "NumDocuments")
ret0, _ := ret[0].(int32)
return ret0
}

func (_mr *_MockimmutableSegmentBaseRecorder) NumDocuments() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "NumDocuments")
}

func (_m *MockimmutableSegmentBase) MinTimeNanos() int64 {
ret := _m.ctrl.Call(_m, "MinTimeNanos")
ret0, _ := ret[0].(int64)
return ret0
}

func (_mr *_MockimmutableSegmentBaseRecorder) MinTimeNanos() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "MinTimeNanos")
}

func (_m *MockimmutableSegmentBase) MaxTimeNanos() int64 {
ret := _m.ctrl.Call(_m, "MaxTimeNanos")
ret0, _ := ret[0].(int64)
return ret0
}

func (_mr *_MockimmutableSegmentBaseRecorder) MaxTimeNanos() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "MaxTimeNanos")
}

func (_m *MockimmutableSegmentBase) Intersects(startNanosInclusive int64, endNanosExclusive int64) bool {
ret := _m.ctrl.Call(_m, "Intersects", startNanosInclusive, endNanosExclusive)
ret0, _ := ret[0].(bool)
return ret0
}

func (_mr *_MockimmutableSegmentBaseRecorder) Intersects(arg0, arg1 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Intersects", arg0, arg1)
}

func (_m *MockimmutableSegmentBase) IncReader() {
_m.ctrl.Call(_m, "IncReader")
}

func (_mr *_MockimmutableSegmentBaseRecorder) IncReader() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "IncReader")
}

func (_m *MockimmutableSegmentBase) DecReader() {
_m.ctrl.Call(_m, "DecReader")
}

func (_mr *_MockimmutableSegmentBaseRecorder) DecReader() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "DecReader")
}

func (_m *MockimmutableSegmentBase) NumReaders() int {
ret := _m.ctrl.Call(_m, "NumReaders")
ret0, _ := ret[0].(int)
return ret0
}

func (_mr *_MockimmutableSegmentBaseRecorder) NumReaders() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "NumReaders")
}

func (_m *MockimmutableSegmentBase) Close() {
_m.ctrl.Call(_m, "Close")
}

func (_mr *_MockimmutableSegmentBaseRecorder) Close() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Close")
}

// Mock of mutableSegmentBase interface
type MockmutableSegmentBase struct {
ctrl *gomock.Controller
recorder *_MockmutableSegmentBaseRecorder
}

// Recorder for MockmutableSegmentBase (not exported)
type _MockmutableSegmentBaseRecorder struct {
mock *MockmutableSegmentBase
}

func NewMockmutableSegmentBase(ctrl *gomock.Controller) *MockmutableSegmentBase {
mock := &MockmutableSegmentBase{ctrl: ctrl}
mock.recorder = &_MockmutableSegmentBaseRecorder{mock}
return mock
}

func (_m *MockmutableSegmentBase) EXPECT() *_MockmutableSegmentBaseRecorder {
return _m.recorder
}

func (_m *MockmutableSegmentBase) ID() string {
ret := _m.ctrl.Call(_m, "ID")
ret0, _ := ret[0].(string)
return ret0
}

func (_mr *_MockmutableSegmentBaseRecorder) ID() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ID")
}

func (_m *MockmutableSegmentBase) NumDocuments() int32 {
ret := _m.ctrl.Call(_m, "NumDocuments")
ret0, _ := ret[0].(int32)
return ret0
}

func (_mr *_MockmutableSegmentBaseRecorder) NumDocuments() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "NumDocuments")
}

func (_m *MockmutableSegmentBase) MinTimeNanos() int64 {
ret := _m.ctrl.Call(_m, "MinTimeNanos")
ret0, _ := ret[0].(int64)
return ret0
}

func (_mr *_MockmutableSegmentBaseRecorder) MinTimeNanos() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "MinTimeNanos")
}

func (_m *MockmutableSegmentBase) MaxTimeNanos() int64 {
ret := _m.ctrl.Call(_m, "MaxTimeNanos")
ret0, _ := ret[0].(int64)
return ret0
}

func (_mr *_MockmutableSegmentBaseRecorder) MaxTimeNanos() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "MaxTimeNanos")
}

func (_m *MockmutableSegmentBase) Intersects(startNanosInclusive int64, endNanosExclusive int64) bool {
ret := _m.ctrl.Call(_m, "Intersects", startNanosInclusive, endNanosExclusive)
ret0, _ := ret[0].(bool)
return ret0
}

func (_mr *_MockmutableSegmentBaseRecorder) Intersects(arg0, arg1 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Intersects", arg0, arg1)
}

func (_m *MockmutableSegmentBase) IncReader() {
_m.ctrl.Call(_m, "IncReader")
}

func (_mr *_MockmutableSegmentBaseRecorder) IncReader() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "IncReader")
}

func (_m *MockmutableSegmentBase) DecReader() {
_m.ctrl.Call(_m, "DecReader")
}

func (_mr *_MockmutableSegmentBaseRecorder) DecReader() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "DecReader")
}

func (_m *MockmutableSegmentBase) NumReaders() int {
ret := _m.ctrl.Call(_m, "NumReaders")
ret0, _ := ret[0].(int)
return ret0
}

func (_mr *_MockmutableSegmentBaseRecorder) NumReaders() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "NumReaders")
}

func (_m *MockmutableSegmentBase) Close() {
_m.ctrl.Call(_m, "Close")
}

func (_mr *_MockmutableSegmentBaseRecorder) Close() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Close")
}

func (_m *MockmutableSegmentBase) SetNumDocuments(v int32) {
_m.ctrl.Call(_m, "SetNumDocuments", v)
}

func (_mr *_MockmutableSegmentBaseRecorder) SetNumDocuments(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "SetNumDocuments", arg0)
}

func (_m *MockmutableSegmentBase) SetMinTimeNanos(v int64) {
_m.ctrl.Call(_m, "SetMinTimeNanos", v)
}

func (_mr *_MockmutableSegmentBaseRecorder) SetMinTimeNanos(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "SetMinTimeNanos", arg0)
}

func (_m *MockmutableSegmentBase) SetMaxTimeNanos(v int64) {
_m.ctrl.Call(_m, "SetMaxTimeNanos", v)
}

func (_mr *_MockmutableSegmentBaseRecorder) SetMaxTimeNanos(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "SetMaxTimeNanos", arg0)
}
Loading

0 comments on commit cb61c1d

Please sign in to comment.