lucene-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r178578 - in /incubator/lucene4c/branches/gcj-backend: Makefile src/search/index_searcher.cxx
Date Thu, 26 May 2005 04:52:05 GMT
Author: rooneg
Date: Wed May 25 21:52:03 2005
New Revision: 178578

URL: http://svn.apache.org/viewcvs?rev=178578&view=rev
Log:
Implement IndexSearcher wrappers.

Note that there are still bugs with closing index searchers, which cause
crashes at pool clear time, but the actual searcher seems to work fine.

* src/search/index_searcher.cxx: new file.

* Makefile: build index_searcher.cxx, force debugging symbols on, link
  the test program with cc instead of c++, just to confirm that we can.

Added:
    incubator/lucene4c/branches/gcj-backend/src/search/index_searcher.cxx
Modified:
    incubator/lucene4c/branches/gcj-backend/Makefile

Modified: incubator/lucene4c/branches/gcj-backend/Makefile
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/Makefile?rev=178578&r1=178577&r2=178578&view=diff
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/Makefile (original)
+++ incubator/lucene4c/branches/gcj-backend/Makefile Wed May 25 21:52:03 2005
@@ -5,9 +5,9 @@
 CFLAGS=`$(APR_ROOT)/apr-1-config --cflags`
 INCLUDES=-Iinclude -I$(APR_ROOT)/include
 
-CC=$(GCC_ROOT)/bin/gcc -Wall
-CXX=$(GCC_ROOT)/bin/g++ -Wall
-JCC=$(GCC_ROOT)/bin/gcj -Wall
+CC=$(GCC_ROOT)/bin/gcc -g -Wall
+CXX=$(GCC_ROOT)/bin/g++ -g -Wall
+JCC=$(GCC_ROOT)/bin/gcj -g -Wall
 JCCH=$(GCC_ROOT)/bin/gcjh
 JAR=$(GCC_ROOT)/bin/fastjar
 
@@ -21,6 +21,7 @@
      src/org/apache/lucene4c/QueryParserHack.o \
      src/query_parser/query_parser.o \
      src/search/searcher.o \
+     src/search/index_searcher.o \
      src/index/writer.o
 
 %.o: %.cxx
@@ -41,7 +42,7 @@
 	$(JCCH) --classpath lib/lucene-1.4.3.jar:src org.apache.lucene4c.QueryParserHack -d include
 
 test/test: lib/liblucene4c.so test/main.o
-	$(CXX) $(CFLAGS) test/main.o -o $@ -Llib -Wl,-rpath=lib -llucene4c -L$(APR_ROOT)/.libs -Wl,-rpath=$(APR_ROOT)/.libs
-lapr-1
+	$(CC) $(CFLAGS) test/main.o -o $@ -Llib -Wl,-rpath=lib -llucene4c -L$(APR_ROOT)/.libs -Wl,-rpath=$(APR_ROOT)/.libs
-lapr-1
 
 clean:
 	rm -f $(OBJS)

Added: incubator/lucene4c/branches/gcj-backend/src/search/index_searcher.cxx
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/src/search/index_searcher.cxx?rev=178578&view=auto
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/src/search/index_searcher.cxx (added)
+++ incubator/lucene4c/branches/gcj-backend/src/search/index_searcher.cxx Wed May 25 21:52:03
2005
@@ -0,0 +1,111 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gcj/cni.h>
+
+#include <java/lang/ClassCastException.h>
+
+#include <org/apache/lucene/search/IndexSearcher.h>
+
+#include "lcn_searcher.h"
+
+#include "../util/exception.h"
+
+#include "searcher.hxx"
+
+using namespace org::apache::lucene::search;
+
+extern "C" {
+
+struct index_searcher_make_baton {
+  lcn_searcher_t **searcher;
+  const char *path;
+  apr_pool_t *pool;
+};
+
+static apr_status_t
+run_close (void *b)
+{
+  lcn_searcher_t *searcher = static_cast<lcn_searcher_t *>(b);
+
+  lcn_error_t *err = lcn_index_searcher_close (searcher);
+
+  if (err)
+    {
+      lcn_error_clear (err);
+
+      return APR_EGENERAL; // XXX better error...
+    }
+
+  return APR_SUCCESS;
+}
+
+static void
+index_searcher_make_internal (void *b)
+{
+  index_searcher_make_baton *iwcb = static_cast<index_searcher_make_baton *>(b);
+
+  *iwcb->searcher = static_cast<lcn_searcher_t *>
+                      (apr_palloc (iwcb->pool, sizeof (lcn_searcher_t)));
+
+  jstring path = JvNewStringUTF (iwcb->path);
+
+  (*iwcb->searcher)->impl = new IndexSearcher (path);
+
+  apr_pool_cleanup_register (iwcb->pool, *iwcb->searcher, run_close, NULL);
+}
+
+lcn_error_t *
+lcn_index_searcher_open (lcn_searcher_t **searcher,
+                         const char *path,
+                         apr_pool_t *pool)
+{
+  index_searcher_make_baton iwmb;
+
+  iwmb.searcher = searcher;
+  iwmb.path = path;
+  iwmb.pool = pool;
+
+  return lcn__swallow_exception (index_searcher_make_internal, &iwmb);
+}
+
+static void
+index_searcher_close_internal (void *b)
+{
+  lcn_searcher_t *searcher = static_cast<lcn_searcher_t *>(b);
+
+  // XXX should be dynamic cast...
+  IndexSearcher *s = static_cast<IndexSearcher *>(searcher->impl);
+
+  if (s)
+    {
+      s->close ();
+    }
+  else
+    {
+      throw new ::java::lang::ClassCastException (
+        JvNewStringUTF ("can't cast impl to IndexSearcher")
+      );
+    }
+}
+
+lcn_error_t *
+lcn_index_searcher_close (lcn_searcher_t *searcher)
+{
+  return lcn__swallow_exception (index_searcher_close_internal, searcher);
+}
+
+} // extern "C"



Mime
View raw message