additional golint issues resolved
This commit is contained in:
parent
d534b0836b
commit
377ae090d0
@ -36,7 +36,7 @@ func (p *FlexibleGoDateTimeParser) ParseDateTime(input string) (time.Time, error
|
|||||||
return rv, nil
|
return rv, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return time.Time{}, analysis.InvalidDateTime
|
return time.Time{}, analysis.ErrInvalidDateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
func FlexibleGoDateTimeParserConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.DateTimeParser, error) {
|
func FlexibleGoDateTimeParserConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.DateTimeParser, error) {
|
||||||
|
@ -53,7 +53,7 @@ func TestFlexibleDateTimeParser(t *testing.T) {
|
|||||||
{
|
{
|
||||||
input: "not a date time",
|
input: "not a date time",
|
||||||
expectedTime: time.Time{},
|
expectedTime: time.Time{},
|
||||||
expectedError: analysis.InvalidDateTime,
|
expectedError: analysis.ErrInvalidDateTime,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ func (tfs TokenFrequencies) MergeAll(remoteField string, other TokenFrequencies)
|
|||||||
i := 0
|
i := 0
|
||||||
for _, tf := range index {
|
for _, tf := range index {
|
||||||
rv[i] = tf
|
rv[i] = tf
|
||||||
i += 1
|
i++
|
||||||
}
|
}
|
||||||
return rv
|
return rv
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ func TokenFrequency(tokens TokenStream) TokenFrequencies {
|
|||||||
i := 0
|
i := 0
|
||||||
for _, tf := range index {
|
for _, tf := range index {
|
||||||
rv[i] = tf
|
rv[i] = tf
|
||||||
i += 1
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv
|
return rv
|
||||||
|
@ -23,12 +23,12 @@ func NewTokenMap() TokenMap {
|
|||||||
return make(TokenMap, 0)
|
return make(TokenMap, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s TokenMap) LoadFile(filename string) error {
|
func (t TokenMap) LoadFile(filename string) error {
|
||||||
data, err := ioutil.ReadFile(filename)
|
data, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return s.LoadBytes(data)
|
return t.LoadBytes(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TokenMap) LoadBytes(data []byte) error {
|
func (t TokenMap) LoadBytes(data []byte) error {
|
||||||
|
@ -70,7 +70,7 @@ func (a *Analyzer) Analyze(input []byte) TokenStream {
|
|||||||
return tokens
|
return tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
var InvalidDateTime = fmt.Errorf("unable to parse datetime with any of the layouts")
|
var ErrInvalidDateTime = fmt.Errorf("unable to parse datetime with any of the layouts")
|
||||||
|
|
||||||
type DateTimeParser interface {
|
type DateTimeParser interface {
|
||||||
ParseDateTime(string) (time.Time, error)
|
ParseDateTime(string) (time.Time, error)
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"code.google.com/p/goprotobuf/proto"
|
"code.google.com/p/goprotobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VersionKey []byte = []byte{'v'}
|
var VersionKey = []byte{'v'}
|
||||||
|
|
||||||
const Version uint8 = 1
|
const Version uint8 = 1
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ func (udc *UpsideDownCouch) batchRows(addRows []UpsideDownCouchRow, updateRows [
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tr.freq += 1 // incr
|
tr.freq++ // incr
|
||||||
} else {
|
} else {
|
||||||
tr = NewTermFrequencyRow(tfr.term, tfr.field, "", 1, 0)
|
tr = NewTermFrequencyRow(tfr.term, tfr.field, "", 1, 0)
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func (udc *UpsideDownCouch) batchRows(addRows []UpsideDownCouchRow, updateRows [
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tr.freq -= 1 // incr
|
tr.freq-- // incr
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("unexpected missing row, deleting term, expected count row to exist: %v", tr.Key())
|
return fmt.Errorf("unexpected missing row, deleting term, expected count row to exist: %v", tr.Key())
|
||||||
}
|
}
|
||||||
@ -193,13 +193,13 @@ func (udc *UpsideDownCouch) countDocs() uint64 {
|
|||||||
it := udc.store.Iterator([]byte{'b'})
|
it := udc.store.Iterator([]byte{'b'})
|
||||||
defer it.Close()
|
defer it.Close()
|
||||||
|
|
||||||
var rv uint64 = 0
|
var rv uint64
|
||||||
key, _, valid := it.Current()
|
key, _, valid := it.Current()
|
||||||
for valid {
|
for valid {
|
||||||
if !bytes.HasPrefix(key, []byte{'b'}) {
|
if !bytes.HasPrefix(key, []byte{'b'}) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
rv += 1
|
rv++
|
||||||
it.Next()
|
it.Next()
|
||||||
key, _, valid = it.Current()
|
key, _, valid = it.Current()
|
||||||
}
|
}
|
||||||
@ -211,10 +211,10 @@ func (udc *UpsideDownCouch) rowCount() uint64 {
|
|||||||
it := udc.store.Iterator([]byte{0})
|
it := udc.store.Iterator([]byte{0})
|
||||||
defer it.Close()
|
defer it.Close()
|
||||||
|
|
||||||
var rv uint64 = 0
|
var rv uint64
|
||||||
_, _, valid := it.Current()
|
_, _, valid := it.Current()
|
||||||
for valid {
|
for valid {
|
||||||
rv += 1
|
rv++
|
||||||
it.Next()
|
it.Next()
|
||||||
_, _, valid = it.Current()
|
_, _, valid = it.Current()
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ func (udc *UpsideDownCouch) Update(doc *document.Document) error {
|
|||||||
|
|
||||||
err = udc.batchRows(addRows, updateRows, deleteRows)
|
err = udc.batchRows(addRows, updateRows, deleteRows)
|
||||||
if err == nil && backIndexRow == nil {
|
if err == nil && backIndexRow == nil {
|
||||||
udc.docCount += 1
|
udc.docCount++
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ func (udc *UpsideDownCouch) updateSingle(doc *document.Document, backIndexRow *B
|
|||||||
updateRows = append(updateRows, backIndexRow)
|
updateRows = append(updateRows, backIndexRow)
|
||||||
|
|
||||||
// any of the existing rows that weren't updated need to be deleted
|
// any of the existing rows that weren't updated need to be deleted
|
||||||
for existingTermKey, _ := range existingTermKeys {
|
for existingTermKey := range existingTermKeys {
|
||||||
termFreqRow, err := NewTermFrequencyRowK([]byte(existingTermKey))
|
termFreqRow, err := NewTermFrequencyRowK([]byte(existingTermKey))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
deleteRows = append(deleteRows, termFreqRow)
|
deleteRows = append(deleteRows, termFreqRow)
|
||||||
@ -325,7 +325,7 @@ func (udc *UpsideDownCouch) updateSingle(doc *document.Document, backIndexRow *B
|
|||||||
}
|
}
|
||||||
|
|
||||||
// any of the existing stored fields that weren't updated need to be deleted
|
// any of the existing stored fields that weren't updated need to be deleted
|
||||||
for existingStoredKey, _ := range existingStoredKeys {
|
for existingStoredKey := range existingStoredKeys {
|
||||||
storedRow, err := NewStoredRowK([]byte(existingStoredKey))
|
storedRow, err := NewStoredRowK([]byte(existingStoredKey))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
deleteRows = append(deleteRows, storedRow)
|
deleteRows = append(deleteRows, storedRow)
|
||||||
@ -440,7 +440,7 @@ func (udc *UpsideDownCouch) Delete(id string) error {
|
|||||||
|
|
||||||
err = udc.batchRows(nil, nil, deleteRows)
|
err = udc.batchRows(nil, nil, deleteRows)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
udc.docCount -= 1
|
udc.docCount--
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -485,7 +485,7 @@ func (udc *UpsideDownCouch) backIndexRowsForBatch(batch index.Batch) (map[string
|
|||||||
// FIXME faster to order the ids and scan sequentially
|
// FIXME faster to order the ids and scan sequentially
|
||||||
// for now just get it working
|
// for now just get it working
|
||||||
rv := make(map[string]*BackIndexRow, 0)
|
rv := make(map[string]*BackIndexRow, 0)
|
||||||
for docId, _ := range batch {
|
for docId := range batch {
|
||||||
backIndexRow, err := udc.backIndexRowForDoc(docId)
|
backIndexRow, err := udc.backIndexRowForDoc(docId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -37,7 +37,7 @@ func TestIndexOpenReopen(t *testing.T) {
|
|||||||
t.Errorf("error opening index: %v", err)
|
t.Errorf("error opening index: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
docCount := idx.DocCount()
|
docCount := idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
||||||
@ -78,7 +78,7 @@ func TestIndexInsert(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer idx.Close()
|
defer idx.Close()
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
docCount := idx.DocCount()
|
docCount := idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
||||||
@ -90,7 +90,7 @@ func TestIndexInsert(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
docCount = idx.DocCount()
|
docCount = idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
@ -116,7 +116,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer idx.Close()
|
defer idx.Close()
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
docCount := idx.DocCount()
|
docCount := idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
||||||
@ -128,7 +128,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
doc2 := document.NewDocument("2")
|
doc2 := document.NewDocument("2")
|
||||||
doc2.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
|
doc2.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
|
||||||
@ -136,7 +136,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
docCount = idx.DocCount()
|
docCount = idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
@ -147,7 +147,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error deleting entry from index: %v", err)
|
t.Errorf("Error deleting entry from index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount -= 1
|
expectedCount--
|
||||||
|
|
||||||
docCount = idx.DocCount()
|
docCount = idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
@ -158,7 +158,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error deleting entry from index: %v", err)
|
t.Errorf("Error deleting entry from index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount -= 1
|
expectedCount--
|
||||||
|
|
||||||
docCount = idx.DocCount()
|
docCount = idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
@ -232,7 +232,7 @@ func TestIndexInsertMultiple(t *testing.T) {
|
|||||||
t.Errorf("error opening index: %v", err)
|
t.Errorf("error opening index: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
|
|
||||||
doc := document.NewDocument("1")
|
doc := document.NewDocument("1")
|
||||||
doc.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
|
doc.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
|
||||||
@ -295,7 +295,7 @@ func TestIndexInsertWithStore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer idx.Close()
|
defer idx.Close()
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
docCount := idx.DocCount()
|
docCount := idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
||||||
@ -307,7 +307,7 @@ func TestIndexInsertWithStore(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
docCount = idx.DocCount()
|
docCount = idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
@ -400,7 +400,7 @@ func TestIndexBatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer idx.Close()
|
defer idx.Close()
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
|
|
||||||
// first create 2 docs the old fashioned way
|
// first create 2 docs the old fashioned way
|
||||||
doc := document.NewDocument("1")
|
doc := document.NewDocument("1")
|
||||||
@ -409,7 +409,7 @@ func TestIndexBatch(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
doc = document.NewDocument("2")
|
doc = document.NewDocument("2")
|
||||||
doc.AddField(document.NewTextField("name", []uint64{}, []byte("test2")))
|
doc.AddField(document.NewTextField("name", []uint64{}, []byte("test2")))
|
||||||
@ -417,7 +417,7 @@ func TestIndexBatch(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
// now create a batch which does 3 things
|
// now create a batch which does 3 things
|
||||||
// insert new doc
|
// insert new doc
|
||||||
@ -477,7 +477,7 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer idx.Close()
|
defer idx.Close()
|
||||||
|
|
||||||
var expectedCount uint64 = 0
|
var expectedCount uint64
|
||||||
docCount := idx.DocCount()
|
docCount := idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
t.Errorf("Expected document count to be %d got %d", expectedCount, docCount)
|
||||||
@ -495,7 +495,7 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating index: %v", err)
|
t.Errorf("Error updating index: %v", err)
|
||||||
}
|
}
|
||||||
expectedCount += 1
|
expectedCount++
|
||||||
|
|
||||||
docCount = idx.DocCount()
|
docCount = idx.DocCount()
|
||||||
if docCount != expectedCount {
|
if docCount != expectedCount {
|
||||||
|
Loading…
Reference in New Issue
Block a user