lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [01/13] lucy git commit: Add error to Go binding for MakeCompiler.
Date Tue, 24 Nov 2015 23:38:23 GMT
Repository: lucy
Updated Branches:
  refs/heads/master 19921d847 -> dc3a17e88


Add error to Go binding for MakeCompiler.


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

Branch: refs/heads/master
Commit: dac0e2bd5d4f93f84842d393a59d3f84f215bf88
Parents: 6d0a55f
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Mon Nov 16 14:30:20 2015 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Fri Nov 20 16:43:37 2015 -0800

----------------------------------------------------------------------
 go/build.go            |  4 ++++
 go/lucy/search.go      | 13 +++++++++++++
 go/lucy/search_test.go |  6 +++---
 3 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/dac0e2bd/go/build.go
----------------------------------------------------------------------
diff --git a/go/build.go b/go/build.go
index fc73f64..6dff074 100644
--- a/go/build.go
+++ b/go/build.go
@@ -228,6 +228,10 @@ func specClasses(parcel *cfc.Parcel) {
 	hitsBinding.SetSuppressStruct(true)
 	hitsBinding.Register()
 
+	queryBinding := cfc.NewGoClass(parcel, "Lucy::Search::Query")
+	queryBinding.SpecMethod("Make_Compiler", "MakeCompiler(Searcher, float32, bool) (Compiler,
error)")
+	queryBinding.Register()
+
 	compilerBinding := cfc.NewGoClass(parcel, "Lucy::Search::Compiler")
 	compilerBinding.SpecMethod("Make_Matcher", "MakeMatcher(SegReader, bool) (Matcher, error)")
 	compilerBinding.Register()

http://git-wip-us.apache.org/repos/asf/lucy/blob/dac0e2bd/go/lucy/search.go
----------------------------------------------------------------------
diff --git a/go/lucy/search.go b/go/lucy/search.go
index c539044..2db169b 100644
--- a/go/lucy/search.go
+++ b/go/lucy/search.go
@@ -245,6 +245,19 @@ func (td *TopDocsIMP) GetMatchDocs() []MatchDoc {
 	return slice
 }
 
+func (q *QueryIMP) MakeCompiler(searcher Searcher, boost float32,
+	subordinate bool) (retval Compiler, err error) {
+	err = clownfish.TrapErr(func() {
+		self := (*C.lucy_Query)(clownfish.Unwrap(q, "q"))
+		searcherCF := (*C.lucy_Searcher)(clownfish.Unwrap(searcher, "searcher"))
+		retvalCF := C.LUCY_Query_Make_Compiler(self, searcherCF, C.float(boost), C.bool(subordinate))
+		if retvalCF != nil {
+			retval = clownfish.WRAPAny(unsafe.Pointer(retvalCF)).(Compiler)
+		}
+	})
+	return retval, err
+}
+
 func (c *CompilerIMP) MakeMatcher(reader SegReader, needScore bool) (retval Matcher, err
error) {
 	err = clownfish.TrapErr(func() {
 		self := (*C.lucy_Compiler)(clownfish.Unwrap(c, "c"))

http://git-wip-us.apache.org/repos/asf/lucy/blob/dac0e2bd/go/lucy/search_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go
index a92708c..1127f72 100644
--- a/go/lucy/search_test.go
+++ b/go/lucy/search_test.go
@@ -55,9 +55,9 @@ func checkQueryEquals(t *testing.T, query Query) {
 func checkQueryMakeCompiler(t *testing.T, query Query) {
 	index := createTestIndex("foo", "bar", "baz")
 	searcher, _ := OpenIndexSearcher(index)
-	compiler := query.MakeCompiler(searcher, 1.0, false)
-	if got, ok := compiler.(Compiler); !ok {
-		t.Error("MakeCompiler failed: got '%v'", got)
+	compiler, err := query.MakeCompiler(searcher, 1.0, false)
+	if _, ok := compiler.(Compiler); !ok || err != nil {
+		t.Error("MakeCompiler for %v failed: %v", query, err)
 	}
 }
 


Mime
View raw message