lucene-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r178377 - in /incubator/lucene4c/branches/gcj-backend: Makefile include/lcn_index_searcher.h include/lcn_query.h include/lcn_searcher.h src/search/searcher.cxx src/search/searcher.hxx
Date Wed, 25 May 2005 05:43:10 GMT
Author: rooneg
Date: Tue May 24 22:43:09 2005
New Revision: 178377

URL: http://svn.apache.org/viewcvs?rev=178377&view=rev
Log:
Implement a first cut at lcn_searcher_search.

This is totally untested, since I don't have a way to actually create
an lcn_searcher_t yet, but that will come soon enough...

* include/lcn_index_searcher.h: renamed to...

* include/lcn_searcher.h: this.
  (lcn_index_searcher_t): rename to...
  (lcn_searcher_t): this.
  (lcn_filter_t, lcn_sort_t): new typedefs.
  (lcn_index_searcher_open, lcn_index_searcher_close): take lcn_searcher_t,
   not lcn_index_searcher_t.
  (lcn_index_searcher_search): rename to...
  (lcn_searcher_search): this.  also update arguments.

* include/lcn_query.h: include lcn_error.h.

* src/search/searcher.hxx: new file.

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

* Makefile: build src/search/searcher.cxx.

Added:
    incubator/lucene4c/branches/gcj-backend/include/lcn_searcher.h
      - copied, changed from r178073, incubator/lucene4c/branches/gcj-backend/include/lcn_index_searcher.h
    incubator/lucene4c/branches/gcj-backend/src/search/searcher.cxx
    incubator/lucene4c/branches/gcj-backend/src/search/searcher.hxx
Removed:
    incubator/lucene4c/branches/gcj-backend/include/lcn_index_searcher.h
Modified:
    incubator/lucene4c/branches/gcj-backend/Makefile
    incubator/lucene4c/branches/gcj-backend/include/lcn_query.h

Modified: incubator/lucene4c/branches/gcj-backend/Makefile
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/Makefile?rev=178377&r1=178376&r2=178377&view=diff
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/Makefile (original)
+++ incubator/lucene4c/branches/gcj-backend/Makefile Tue May 24 22:43:09 2005
@@ -20,6 +20,7 @@
      src/analysis/standard.o \
      src/org/apache/lucene4c/QueryParserHack.o \
      src/query_parser/query_parser.o \
+     src/search/searcher.o \
      src/index/writer.o
 
 %.o: %.cxx

Modified: incubator/lucene4c/branches/gcj-backend/include/lcn_query.h
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/include/lcn_query.h?rev=178377&r1=178376&r2=178377&view=diff
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/include/lcn_query.h (original)
+++ incubator/lucene4c/branches/gcj-backend/include/lcn_query.h Tue May 24 22:43:09 2005
@@ -22,6 +22,8 @@
 #ifndef _LCN_QUERY_H
 #define _LCN_QUERY_H
 
+#include "lcn_error.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */

Copied: incubator/lucene4c/branches/gcj-backend/include/lcn_searcher.h (from r178073, incubator/lucene4c/branches/gcj-backend/include/lcn_index_searcher.h)
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/include/lcn_searcher.h?p2=incubator/lucene4c/branches/gcj-backend/include/lcn_searcher.h&p1=incubator/lucene4c/branches/gcj-backend/include/lcn_index_searcher.h&r1=178073&r2=178377&rev=178377&view=diff
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/include/lcn_index_searcher.h (original)
+++ incubator/lucene4c/branches/gcj-backend/include/lcn_searcher.h Tue May 24 22:43:09 2005
@@ -19,31 +19,39 @@
 
 #include <apr_tables.h>
 
-#ifndef _LCN_INDEX_SEARCHER_H
-#define _LCN_INDEX_SEARCHER_H
+#ifndef _LCN_SEARCHER_H
+#define _LCN_SEARCHER_H
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-typedef struct lcn_index_searcher_t lcn_index_searcher_t;
+typedef struct lcn_searcher_t lcn_searcher_t;
+
+/* XXX temporarily declared here, will move eventually */
+typedef struct lcn_filter_t lcn_filter_t;
+typedef struct lcn_sort_t lcn_sort_t;
 
 lcn_error_t *
-lcn_index_searcher_open (lcn_index_searcher_t **searcher,
+lcn_index_searcher_open (lcn_searcher_t **searcher,
                          const char *path,
                          apr_pool_t *pool);
 
 lcn_error_t *
-lcn_index_searcher_search (apr_array_header_t **hits,
-                           lcn_index_searcher_t *searcher,
-                           lcn_query_t *query,
-                           apr_pool_t *pool);
+lcn_index_searcher_close (lcn_searcher_t *searcher);
 
+/* XXX should replace the array with a real hits interface, to avoid pulling
+ * tons of stuff into ram. */
 lcn_error_t *
-lcn_index_searcher_close (lcn_index_searcher_t *searcher);
+lcn_searcher_search (apr_array_header_t **hits,
+                     lcn_searcher_t *searcher,
+                     lcn_query_t *query,
+                     lcn_filter_t *filter,
+                     lcn_sort_t *sort,
+                     apr_pool_t *pool);
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
-#endif /* _LCN_INDEX_SEARCHER_H */
+#endif /* _LCN_SEARCHER_H */

Added: incubator/lucene4c/branches/gcj-backend/src/search/searcher.cxx
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/src/search/searcher.cxx?rev=178377&view=auto
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/src/search/searcher.cxx (added)
+++ incubator/lucene4c/branches/gcj-backend/src/search/searcher.cxx Tue May 24 22:43:09 2005
@@ -0,0 +1,100 @@
+/* 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/IllegalArgumentException.h>
+
+#include <org/apache/lucene/search/Hits.h>
+
+#include "lcn_searcher.h"
+#include "lcn_document.h"
+
+#include "../util/exception.h"
+
+#include "searcher.hxx"
+#include "query.hxx"
+
+#include "../document/document.hxx"
+
+using namespace java::lang;
+
+using namespace org::apache::lucene::search;
+
+extern "C" {
+
+struct searcher_search_baton {
+  apr_array_header_t **hits;
+  lcn_searcher_t *searcher;
+  lcn_query_t *query;
+  lcn_filter_t *filter;
+  lcn_sort_t *sort;
+  apr_pool_t *pool;
+};
+
+void
+searcher_search_internal (void *baton)
+{
+  searcher_search_baton *ssb = static_cast<searcher_search_baton *>(baton);
+
+  if (ssb->filter || ssb->sort)
+    {
+      throw new IllegalArgumentException (
+        JvNewStringUTF ("filter and sort must be NULL got now...")
+      );
+    }
+
+  Hits *h = ssb->searcher->impl->search (ssb->query->impl);
+
+  *ssb->hits = apr_array_make (ssb->pool,
+                               h->length (),
+                               sizeof (lcn_document_t *));
+
+  for (int i = 0; i < h->length (); ++i)
+    {
+      lcn_document_t *d = static_cast<lcn_document_t *>(
+                            apr_palloc (ssb->pool, sizeof (lcn_document_t))
+                          );
+
+      d->impl = h->doc (i);
+
+      /* XXX should just find a place to put APR_ARRAY_PUSH... */
+ 
+      (*((lcn_document_t **) apr_array_push (*ssb->hits))) = d;
+    }
+}
+
+lcn_error_t *
+lcn_searcher_search (apr_array_header_t **hits,
+                     lcn_searcher_t *searcher,
+                     lcn_query_t *query,
+                     lcn_filter_t *filter,
+                     lcn_sort_t *sort,
+                     apr_pool_t *pool)
+{
+  searcher_search_baton ssb;
+
+  ssb.hits = hits;
+  ssb.searcher = searcher;
+  ssb.query = query;
+  ssb.filter = filter;
+  ssb.sort = sort;
+  ssb.pool = pool;
+
+  return lcn__swallow_exception (searcher_search_internal, &ssb);
+}
+
+} // extern "C"

Added: incubator/lucene4c/branches/gcj-backend/src/search/searcher.hxx
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/src/search/searcher.hxx?rev=178377&view=auto
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/src/search/searcher.hxx (added)
+++ incubator/lucene4c/branches/gcj-backend/src/search/searcher.hxx Tue May 24 22:43:09 2005
@@ -0,0 +1,30 @@
+/* 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 <org/apache/lucene/search/Searcher.h>
+
+#ifndef _SEARCHER_HXX
+#define _SEARCHER_HXX
+
+extern "C" {
+
+struct lcn_searcher_t {
+  org::apache::lucene::search::Searcher *impl;
+};
+
+} // extern "C"
+
+#endif // _SEARCHER_HXX



Mime
View raw message