Tune and Test SeriesMatcher Go binding.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/b8b4b8ef Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/b8b4b8ef Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/b8b4b8ef Branch: refs/heads/master Commit: b8b4b8eff29ada478c0ae029c0d6673741674a70 Parents: 79a7769 Author: Marvin Humphrey <[email protected]> Authored: Thu Sep 10 18:37:38 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Tue Sep 15 15:54:50 2015 -0700 ---------------------------------------------------------------------- go/build.go | 4 ++++ go/lucy/search.go | 12 ++++++++++++ go/lucy/search_test.go | 8 ++++++++ 3 files changed, 24 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/b8b4b8ef/go/build.go ---------------------------------------------------------------------- diff --git a/go/build.go b/go/build.go index 7596f7b..10ec5cf 100644 --- a/go/build.go +++ b/go/build.go @@ -180,6 +180,10 @@ func specClasses(parcel *cfc.Parcel) { orScorerBinding.SetSuppressCtor(true) orScorerBinding.Register() + seriesMatcherBinding := cfc.NewGoClass(parcel, "Lucy::Search::SeriesMatcher") + seriesMatcherBinding.SetSuppressCtor(true) + seriesMatcherBinding.Register() + bitVecBinding := cfc.NewGoClass(parcel, "Lucy::Object::BitVector") bitVecBinding.SpecMethod("To_Array", "ToArray() []bool") bitVecBinding.Register() http://git-wip-us.apache.org/repos/asf/lucy/blob/b8b4b8ef/go/lucy/search.go ---------------------------------------------------------------------- diff --git a/go/lucy/search.go b/go/lucy/search.go index 2785d51..18ac6bc 100644 --- a/go/lucy/search.go +++ b/go/lucy/search.go @@ -26,6 +26,7 @@ package lucy #include "Lucy/Search/ORQuery.h" #include "Lucy/Search/ANDMatcher.h" #include "Lucy/Search/ORMatcher.h" +#include "Lucy/Search/SeriesMatcher.h" #include "Lucy/Document/HitDoc.h" #include "LucyX/Search/MockMatcher.h" #include "Clownfish/Blob.h" @@ -226,6 +227,17 @@ func NewORScorer(children []Matcher, sim Similarity) ORScorer { return WRAPORScorer(unsafe.Pointer(cfObj)) } +func NewSeriesMatcher(matchers []Matcher, offsets []int32) SeriesMatcher { + vec := clownfish.NewVector(len(matchers)) + for _, child := range matchers { + vec.Push(child) + } + i32arr := NewI32Array(offsets) + cfObj := C.lucy_SeriesMatcher_new(((*C.cfish_Vector)(clownfish.Unwrap(vec, "matchers"))), + ((*C.lucy_I32Array)(clownfish.Unwrap(i32arr, "offsets")))) + return WRAPSeriesMatcher(unsafe.Pointer(cfObj)) +} + func newMockMatcher(docIDs []int32, scores []float32) MockMatcher { docIDsconv := NewI32Array(docIDs) docIDsCF := (*C.lucy_I32Array)(unsafe.Pointer(docIDsconv.TOPTR())) http://git-wip-us.apache.org/repos/asf/lucy/blob/b8b4b8ef/go/lucy/search_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go index 492ab1f..83fdc71 100644 --- a/go/lucy/search_test.go +++ b/go/lucy/search_test.go @@ -319,3 +319,11 @@ func TestNOTMatcherBasics(t *testing.T) { matcher := NewANDMatcher([]Matcher{a, notB}, nil) checkMatcher(t, matcher, false) } + +func TestSeriesMatcherBasics(t *testing.T) { + a := newMockMatcher([]int32{42}, nil) + b := newMockMatcher([]int32{1, 4}, nil) + c := newMockMatcher([]int32{20}, nil) + matcher := NewSeriesMatcher([]Matcher{a, b, c}, []int32{0, 42, 80}) + checkMatcher(t, matcher, false) +}
