lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [03/15] lucy git commit: Tune and test Go bindings for BackgroundMerger.
Date Sat, 07 Nov 2015 02:48:52 GMT
Tune and test Go bindings for BackgroundMerger.


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

Branch: refs/heads/master
Commit: 70d9076ccafc9bb9af16d3fe14d780ae5abc2d1b
Parents: 71dd0aa
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Thu Oct 29 13:06:07 2015 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sat Oct 31 15:31:15 2015 -0700

----------------------------------------------------------------------
 go/build.go           |  5 +++++
 go/lucy/index.go      | 26 ++++++++++++++++++++++++++
 go/lucy/index_test.go | 15 +++++++++++++++
 3 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/70d9076c/go/build.go
----------------------------------------------------------------------
diff --git a/go/build.go b/go/build.go
index eaf896b..72446d4 100644
--- a/go/build.go
+++ b/go/build.go
@@ -157,6 +157,11 @@ func specClasses(parcel *cfc.Parcel) {
 	indexerBinding.SetSuppressStruct(true)
 	indexerBinding.Register()
 
+	bgMergerBinding := cfc.NewGoClass(parcel, "Lucy::Index::BackgroundMerger")
+	bgMergerBinding.SpecMethod("Prepare_Commit", "PrepareCommit() error")
+	bgMergerBinding.SpecMethod("Commit", "Commit() error")
+	bgMergerBinding.Register()
+
 	schemaBinding := cfc.NewGoClass(parcel, "Lucy::Plan::Schema")
 	schemaBinding.SpecMethod("All_Fields", "AllFields() []string")
 	schemaBinding.Register()

http://git-wip-us.apache.org/repos/asf/lucy/blob/70d9076c/go/lucy/index.go
----------------------------------------------------------------------
diff --git a/go/lucy/index.go b/go/lucy/index.go
index 3b9a8f5..83b36df 100644
--- a/go/lucy/index.go
+++ b/go/lucy/index.go
@@ -19,6 +19,7 @@ package lucy
 /*
 #include "Lucy/Index/Indexer.h"
 #include "Lucy/Index/IndexManager.h"
+#include "Lucy/Index/BackgroundMerger.h"
 #include "Lucy/Document/Doc.h"
 #include "Lucy/Plan/Schema.h"
 #include "Clownfish/Hash.h"
@@ -222,3 +223,28 @@ func (obj *IndexerIMP) Commit() error {
 		C.LUCY_Indexer_Commit(self)
 	})
 }
+
+func OpenBackgroundMerger(index interface{}, manager IndexManager) (bgm BackgroundMerger,
err error) {
+	err = clownfish.TrapErr(func() {
+		indexC := (*C.cfish_Obj)(clownfish.GoToClownfish(index, unsafe.Pointer(C.CFISH_OBJ), false))
+		defer C.cfish_decref(unsafe.Pointer(indexC))
+		managerC := (*C.lucy_IndexManager)(clownfish.UnwrapNullable(manager))
+		cfObj := C.lucy_BGMerger_new(indexC, managerC)
+		bgm = WRAPBackgroundMerger(unsafe.Pointer(cfObj))
+	})
+	return bgm, err
+}
+
+func (bgm *BackgroundMergerIMP) PrepareCommit() error {
+	return clownfish.TrapErr(func() {
+		self := (*C.lucy_BackgroundMerger)(clownfish.Unwrap(bgm, "bgm"))
+		C.LUCY_BGMerger_Prepare_Commit(self)
+	})
+}
+
+func (bgm *BackgroundMergerIMP) Commit() error {
+	return clownfish.TrapErr(func() {
+		self := (*C.lucy_BackgroundMerger)(clownfish.Unwrap(bgm, "bgm"))
+		C.LUCY_BGMerger_Commit(self)
+	})
+}

http://git-wip-us.apache.org/repos/asf/lucy/blob/70d9076c/go/lucy/index_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/index_test.go b/go/lucy/index_test.go
index 0afdf92..86055ae 100644
--- a/go/lucy/index_test.go
+++ b/go/lucy/index_test.go
@@ -126,3 +126,18 @@ func TestIndexerMisc(t *testing.T) {
 		t.Errorf("Commit: %v", err)
 	}
 }
+
+func TestBackgroundMergerMisc(t *testing.T) {
+	var err error
+	index := createTestIndex("foo", "bar", "baz")
+	merger, _ := OpenBackgroundMerger(index, nil)
+	merger.Optimize()
+	err = merger.PrepareCommit()
+	if err != nil {
+		t.Errorf("PrepareCommit: %v", err)
+	}
+	err = merger.Commit()
+	if err != nil {
+		t.Errorf("Commit: %v", err)
+	}
+}


Mime
View raw message