Make PolyMatcher ctor bindings take []Matcher.

Make ANDMatcher, ORMatcher, and ORScorer constructors take a slice of
Matcher rather than a slice of empty interface.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/9cd103c7
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/9cd103c7
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/9cd103c7

Branch: refs/heads/master
Commit: 9cd103c7dfafa7153480789cb28618e4555abebd
Parents: aaf6abb
Author: Marvin Humphrey <[email protected]>
Authored: Wed Sep 9 18:55:21 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Wed Sep 9 18:58:22 2015 -0700

----------------------------------------------------------------------
 go/build.go       | 12 ++++++++++++
 go/lucy/search.go | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/9cd103c7/go/build.go
----------------------------------------------------------------------
diff --git a/go/build.go b/go/build.go
index 5c84645..7596f7b 100644
--- a/go/build.go
+++ b/go/build.go
@@ -168,6 +168,18 @@ func specClasses(parcel *cfc.Parcel) {
        orQueryBinding.SetSuppressCtor(true)
        orQueryBinding.Register()
 
+       andMatcherBinding := cfc.NewGoClass(parcel, "Lucy::Search::ANDMatcher")
+       andMatcherBinding.SetSuppressCtor(true)
+       andMatcherBinding.Register()
+
+       orMatcherBinding := cfc.NewGoClass(parcel, "Lucy::Search::ORMatcher")
+       orMatcherBinding.SetSuppressCtor(true)
+       orMatcherBinding.Register()
+
+       orScorerBinding := cfc.NewGoClass(parcel, "Lucy::Search::ORScorer")
+       orScorerBinding.SetSuppressCtor(true)
+       orScorerBinding.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/9cd103c7/go/lucy/search.go
----------------------------------------------------------------------
diff --git a/go/lucy/search.go b/go/lucy/search.go
index 0c8dbb2..2785d51 100644
--- a/go/lucy/search.go
+++ b/go/lucy/search.go
@@ -24,6 +24,8 @@ package lucy
 #include "Lucy/Search/Searcher.h"
 #include "Lucy/Search/ANDQuery.h"
 #include "Lucy/Search/ORQuery.h"
+#include "Lucy/Search/ANDMatcher.h"
+#include "Lucy/Search/ORMatcher.h"
 #include "Lucy/Document/HitDoc.h"
 #include "LucyX/Search/MockMatcher.h"
 #include "Clownfish/Blob.h"
@@ -192,6 +194,38 @@ func NewORQuery(children []Query) ORQuery {
        return WRAPORQuery(unsafe.Pointer(cfObj))
 }
 
+func NewANDMatcher(children []Matcher, sim Similarity) ANDMatcher {
+       simC := (*C.lucy_Similarity)(clownfish.UnwrapNullable(sim))
+       vec := clownfish.NewVector(len(children))
+       for _, child := range children {
+               vec.Push(child)
+       }
+       childrenC := (*C.cfish_Vector)(unsafe.Pointer(vec.TOPTR()))
+       cfObj := C.lucy_ANDMatcher_new(childrenC, simC)
+       return WRAPANDMatcher(unsafe.Pointer(cfObj))
+}
+
+func NewORMatcher(children []Matcher) ORMatcher {
+       vec := clownfish.NewVector(len(children))
+       for _, child := range children {
+               vec.Push(child)
+       }
+       childrenC := (*C.cfish_Vector)(unsafe.Pointer(vec.TOPTR()))
+       cfObj := C.lucy_ORMatcher_new(childrenC)
+       return WRAPORMatcher(unsafe.Pointer(cfObj))
+}
+
+func NewORScorer(children []Matcher, sim Similarity) ORScorer {
+       simC := (*C.lucy_Similarity)(clownfish.UnwrapNullable(sim))
+       vec := clownfish.NewVector(len(children))
+       for _, child := range children {
+               vec.Push(child)
+       }
+       childrenC := (*C.cfish_Vector)(unsafe.Pointer(vec.TOPTR()))
+       cfObj := C.lucy_ORScorer_new(childrenC, simC)
+       return WRAPORScorer(unsafe.Pointer(cfObj))
+}
+
 func newMockMatcher(docIDs []int32, scores []float32) MockMatcher {
        docIDsconv := NewI32Array(docIDs)
        docIDsCF := (*C.lucy_I32Array)(unsafe.Pointer(docIDsconv.TOPTR()))

Reply via email to