lucene-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r178073 - in /incubator/lucene4c/branches/gcj-backend: Makefile include/lcn_query_parser.h src/org/ src/org/apache/ src/org/apache/lucene4c/ src/org/apache/lucene4c/QueryParserHack.java src/query_parser/query_parser.cxx src/search/query.hxx
Date Tue, 24 May 2005 04:34:10 GMT
Author: rooneg
Date: Mon May 23 21:34:08 2005
New Revision: 178073

URL: http://svn.apache.org/viewcvs?rev=178073&view=rev
Log:
Add a wrapper around the Lucene QueryParser code.  This requires some
gymnastics, since the Java code cannot be parsed by gcjh, so we need to
access it through an intermediate Java class instead of calling into it
directly from C++ code.

* include/lcn_query_parser.h: resurrect this file...
  (lcn_query_parser_create,
   lcn_query_parser_parse): removed for now.
  (lcn_query_parse): new wrapper function.

* src/query_parser/query_parser.cxx: new file.

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

* src/org/apache/lucene4c/QueryParserHack.java: new file.

* Makefile: build QueryParserHack.java and query_parser.cxx.

Added:
    incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h
      - copied, changed from r171263, incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h
    incubator/lucene4c/branches/gcj-backend/src/org/
    incubator/lucene4c/branches/gcj-backend/src/org/apache/
    incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/   (with props)
    incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/QueryParserHack.java
    incubator/lucene4c/branches/gcj-backend/src/query_parser/query_parser.cxx
    incubator/lucene4c/branches/gcj-backend/src/search/query.hxx
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=178073&r1=178072&r2=178073&view=diff
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/Makefile (original)
+++ incubator/lucene4c/branches/gcj-backend/Makefile Mon May 23 21:34:08 2005
@@ -18,6 +18,8 @@
      src/document/field.o \
      src/document/document.o \
      src/analysis/standard.o \
+     src/org/apache/lucene4c/QueryParserHack.o \
+     src/query_parser/query_parser.o \
      src/index/writer.o
 
 %.o: %.cxx
@@ -26,7 +28,16 @@
 %.o: %.c
 	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
 
-all: lib/liblucene4c.so test/test
+%.o: %.java
+	$(JCC) $(INCLUDES) --classpath lib/lucene-1.4.3.jar -c $< -o $@
+
+%.class: %.java
+	javac --classpath lib/lucene-1.4.3.jar -d src $<
+
+all: lib/liblucene4c.so test/test include/org/apache/lucene4c/QueryParserHack.h
+
+include/org/apache/lucene4c/QueryParserHack.h: src/org/apache/lucene4c/QueryParserHack.class
+	$(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
@@ -48,6 +59,7 @@
 headers:
 	$(JAR) xvf lib/lucene-1.4.3.jar
 	rm -rf META-INF
+	mkdir -p src/org/apache/lucene4c
 	mkdir .tmp && mv org .tmp/org
 	find .tmp -type d | \
         sed 's|\.tmp/|include/|' | \

Copied: incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h (from r171263,
incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h)
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h?p2=incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h&p1=incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h&r1=171263&r2=178073&rev=178073&view=diff
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h (original)
+++ incubator/lucene4c/branches/gcj-backend/include/lcn_query_parser.h Mon May 23 21:34:08
2005
@@ -22,8 +22,11 @@
 #ifndef _LCN_QUERY_PARSER_H
 #define _LCN_QUERY_PARSER_H
 
-#include "lcn_types.h"
+#include "lcn_pools.h"
+#include "lcn_error.h"
 #include "lcn_query.h"
+#include "lcn_field.h"
+#include "lcn_analyzer.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -32,20 +35,18 @@
 /** A query parser. */
 typedef struct lcn_query_parser_t lcn_query_parser_t;
 
-/** Create a query parser @a parser, which uses @a default_field and
- * @a default_occur and is allocated from @a pool. */
+/** Create @a query from @a input, with default field @a field, analyzed
+ * with @a analyzer, allocated in @a pool.
+ *
+ * @note this creates an @c lcn_query_parser_t object under the hood.  If
+ * you want to avoid the overhead of recreating the parser for each parse
+ * use @c lcn_query_parser_create and @c lcn_query_parser_parse. */
 lcn_error_t *
-lcn_query_parser_create (lcn_query_parser_t **parser,
-                         lcn_char_t *default_field,
-                         lcn_boolean_clause_occur_t default_occur,
-                         apr_pool_t *pool);
-
-/** Use @a parser to create @a query from @a input, allocated in @a pool. */
-lcn_error_t *
-lcn_query_parser_parse (lcn_query_t **query,
-                        lcn_query_parser_t *parser,
-                        lcn_char_t *input,
-                        apr_pool_t *pool);
+lcn_query_parse (lcn_query_t **query,
+                 const char *input,
+                 lcn_field_t *field,
+                 lcn_analyzer_t *analyzer,
+                 apr_pool_t *pool);
 
 #ifdef __cplusplus
 }

Propchange: incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon May 23 21:34:08 2005
@@ -0,0 +1 @@
+*.class

Added: incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/QueryParserHack.java
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/QueryParserHack.java?rev=178073&view=auto
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/QueryParserHack.java (added)
+++ incubator/lucene4c/branches/gcj-backend/src/org/apache/lucene4c/QueryParserHack.java Mon
May 23 21:34:08 2005
@@ -0,0 +1,14 @@
+package org.apache.lucene4c;
+
+class QueryParserHack {
+  static org.apache.lucene.search.Query
+  parse (String query,
+         String field,
+         org.apache.lucene.analysis.Analyzer analyzer)
+    throws org.apache.lucene.queryParser.ParseException
+  {
+    return org.apache.lucene.queryParser.QueryParser.parse (query,
+                                                            field,
+                                                            analyzer);
+  }
+}

Added: incubator/lucene4c/branches/gcj-backend/src/query_parser/query_parser.cxx
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/src/query_parser/query_parser.cxx?rev=178073&view=auto
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/src/query_parser/query_parser.cxx (added)
+++ incubator/lucene4c/branches/gcj-backend/src/query_parser/query_parser.cxx Mon May 23 21:34:08
2005
@@ -0,0 +1,76 @@
+/* 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 "org/apache/lucene4c/QueryParserHack.h"
+
+#include "lcn_query_parser.h"
+
+#include "../search/query.hxx"
+#include "../document/field.hxx"
+#include "../analysis/analyzer.hxx"
+
+#include "../util/exception.h"
+
+using namespace org::apache::lucene4c;
+
+extern "C" {
+
+struct query_parse_baton {
+  lcn_query_t **query;
+  const char *input;
+  lcn_field_t *field;
+  lcn_analyzer_t *analyzer;
+  apr_pool_t *pool;
+};
+
+static void
+query_parse_internal (void *baton)
+{
+  query_parse_baton *qpb = static_cast<query_parse_baton *>(baton);
+
+  *qpb->query = static_cast<lcn_query_t *>(apr_palloc (qpb->pool,
+                                                       sizeof (lcn_query_t)));
+
+  jstring query = JvNewStringUTF (qpb->input);
+
+  jstring field = qpb->field->impl->name();
+
+  (*qpb->query)->impl = QueryParserHack::parse(query,
+                                               field,
+                                               qpb->analyzer->impl);
+}
+
+lcn_error_t *
+lcn_query_parse (lcn_query_t **query,
+                 const char *input,
+                 lcn_field_t *field,
+                 lcn_analyzer_t *analyzer,
+                 apr_pool_t *pool)
+{
+  query_parse_baton qpb;
+
+  qpb.query = query;
+  qpb.input = input;
+  qpb.field = field;
+  qpb.analyzer = analyzer;
+  qpb.pool = pool;
+
+  return lcn__swallow_exception (query_parse_internal, &qpb);
+}
+
+} // extern "C"

Added: incubator/lucene4c/branches/gcj-backend/src/search/query.hxx
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/branches/gcj-backend/src/search/query.hxx?rev=178073&view=auto
==============================================================================
--- incubator/lucene4c/branches/gcj-backend/src/search/query.hxx (added)
+++ incubator/lucene4c/branches/gcj-backend/src/search/query.hxx Mon May 23 21:34:08 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/Query.h>
+
+#ifndef _QUERY_HXX
+#define _QUERY_HXX
+
+extern "C" {
+
+struct lcn_query_t {
+  ::org::apache::lucene::search::Query *impl;
+};
+
+} // extern "C"
+
+#endif // _QUERY_HXX



Mime
View raw message