You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/06/16 16:06:06 UTC

svn commit: r955233 - in /lucene/lucy/trunk: core/Lucy/Plan/ core/Lucy/Test/Plan/ perl/lib/Lucy/ perl/t/core/

Author: marvin
Date: Wed Jun 16 14:06:06 2010
New Revision: 955233

URL: http://svn.apache.org/viewvc?rev=955233&view=rev
Log:
LUCY-110: Add Lucy::Plan::Architecture.

Added:
    lucene/lucy/trunk/core/Lucy/Plan/Architecture.bp   (with props)
    lucene/lucy/trunk/core/Lucy/Plan/Architecture.c   (with props)
    lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.bp   (with props)
    lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.c   (with props)
    lucene/lucy/trunk/perl/t/core/228-architecture.t   (with props)
Modified:
    lucene/lucy/trunk/core/Lucy/Plan/Schema.bp
    lucene/lucy/trunk/core/Lucy/Plan/Schema.c
    lucene/lucy/trunk/perl/lib/Lucy/Test.pm

Added: lucene/lucy/trunk/core/Lucy/Plan/Architecture.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Plan/Architecture.bp?rev=955233&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Plan/Architecture.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Plan/Architecture.bp Wed Jun 16 14:06:06 2010
@@ -0,0 +1,155 @@
+parcel Lucy;
+
+/** Configure major components of an index.
+ *
+ * By default, a Lucy index consists of several main parts: lexicon,
+ * postings, stored documents, deletions, and highlight data.  The readers and
+ * writers for that data are spawned by Architecture.  Each component operates
+ * at the segment level; Architecture's factory methods are used to build up
+ * SegWriter and SegReader.
+ */
+class Lucy::Plan::Architecture cnick Arch extends Lucy::Object::Obj {
+
+    public inert incremented Architecture*
+    new();
+
+    public inert Architecture*
+    init(Architecture *self);
+
+    /** Initialize a SegWriter, adding DataWriter components.
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Init_Seg_Writer(Architecture *self, SegWriter *writer);
+
+    /** Spawn a LexiconWriter and Register() it with the supplied SegWriter,
+     * but don't add it to the SegWriter's writer stack.
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Register_Lexicon_Writer(Architecture *self, SegWriter *writer);
+
+    /** Spawn a PostingListWriter and Register() it with the supplied
+     * SegWriter, adding it to the SegWriter's writer stack.  The SegWriter
+     * must contain a previously registered LexiconWriter.
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Register_Posting_List_Writer(Architecture *self, SegWriter *writer);
+
+    /** Spawn a DataWriter and Register() it with the supplied SegWriter,
+     * adding it to the SegWriter's writer stack.
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Register_Doc_Writer(Architecture *self, SegWriter *writer);
+
+    /** Spawn a SortWriter and Register() it with the supplied SegWriter,
+     * adding it to the SegWriter's writer stack.
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Register_Sort_Writer(Architecture *self, SegWriter *writer);
+
+    /** Spawn a HighlightWriter and Register() it with the supplied SegWriter,
+     * adding it to the SegWriter's writer stack.
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Register_Highlight_Writer(Architecture *self, SegWriter *writer);
+
+    /** Spawn a DeletionsWriter and Register() it with the supplied SegWriter,
+     * also calling Set_Del_Writer().
+     *
+     * @param writer A SegWriter.
+     */
+    public void
+    Register_Deletions_Writer(Architecture *self, SegWriter *writer);
+
+    /** Initialize a SegReader, registering DataReaders.
+     */
+    public void
+    Init_Seg_Reader(Architecture *self, SegReader *reader);
+
+    /** Spawn a DocReader and Register() it with the supplied SegReader.
+     *
+     * @param reader A SegReader.
+     */
+    public void
+    Register_Doc_Reader(Architecture *self, SegReader *reader);
+
+    /** Spawn a PostingListReader and Register() it with the supplied SegReader.
+     *
+     * @param reader A SegReader.
+     */
+    public void
+    Register_Posting_List_Reader(Architecture *self, SegReader *reader);
+
+    /** Spawn a SortReader and Register() it with the supplied SegReader.
+     *
+     * @param reader A SegReader.
+     */
+    public void
+    Register_Sort_Reader(Architecture *self, SegReader *reader);
+
+    /** Spawn a HighlightReader and Register() it with the supplied
+     * SegReader.
+     *
+     * @param reader A SegReader.
+     */
+    public void
+    Register_Highlight_Reader(Architecture *self, SegReader *reader);
+
+    /** Spawn a LexiconReader and Register() it with the supplied SegReader.
+     *
+     * @param reader A SegReader.
+     */
+    public void
+    Register_Lexicon_Reader(Architecture *self, SegReader *reader);
+
+    /** Spawn a DeletionsReader and Register() it with the supplied SegReader.
+     *
+     * @param reader A SegReader.
+     */
+    public void
+    Register_Deletions_Reader(Architecture *self, SegReader *reader);
+
+    /** Factory method for creating a new Similarity object.
+     */
+    public Similarity*
+    Make_Similarity(Architecture *self);
+
+    public int32_t
+    Index_Interval(Architecture *self);
+
+    public int32_t 
+    Skip_Interval(Architecture *self);
+
+    /** Returns true for any Architecture object. Subclasses should override
+     * this weak check.
+     */
+    public bool_t 
+    Equals(Architecture *self, Obj *other);
+}
+
+/* Copyright 2010 The Apache Software Foundation
+ *
+ * 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.
+ */
+

Propchange: lucene/lucy/trunk/core/Lucy/Plan/Architecture.bp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/lucy/trunk/core/Lucy/Plan/Architecture.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Plan/Architecture.c?rev=955233&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Plan/Architecture.c (added)
+++ lucene/lucy/trunk/core/Lucy/Plan/Architecture.c Wed Jun 16 14:06:06 2010
@@ -0,0 +1,178 @@
+#define C_LUCY_ARCHITECTURE
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Plan/Architecture.h"
+#include "Lucy/Index/Segment.h"
+#include "Lucy/Index/SegReader.h"
+#include "Lucy/Index/SegWriter.h"
+#include "Lucy/Index/Similarity.h"
+#include "Lucy/Index/Similarity/LuceneSimilarity.h"
+#include "Lucy/Index/Snapshot.h"
+#include "Lucy/Plan/Schema.h"
+#include "Lucy/Store/Folder.h"
+
+Architecture*
+Arch_new()
+{
+    Architecture *self = (Architecture*)VTable_Make_Obj(ARCHITECTURE);
+    return Arch_init(self);
+}
+
+Architecture*
+Arch_init(Architecture *self)
+{
+    return self;
+}
+
+bool_t
+Arch_equals(Architecture *self, Obj *other)
+{
+    Architecture *evil_twin = (Architecture*)other;
+    if (evil_twin == self) return true;
+    if (!other) return false;
+    if (!Obj_Is_A(other, ARCHITECTURE)) return false;
+    return true;
+}
+
+void
+Arch_init_seg_writer(Architecture *self, SegWriter *writer)
+{
+    Arch_Register_Lexicon_Writer(self, writer);
+    Arch_Register_Posting_List_Writer(self, writer);
+    Arch_Register_Sort_Writer(self, writer);
+    Arch_Register_Doc_Writer(self, writer);
+    Arch_Register_Highlight_Writer(self, writer);
+    Arch_Register_Deletions_Writer(self, writer);
+}
+
+void
+Arch_register_lexicon_writer(Architecture *self, SegWriter *writer)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(writer);
+}
+
+void
+Arch_register_posting_list_writer(Architecture *self, SegWriter *writer)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(writer);
+}
+
+void
+Arch_register_doc_writer(Architecture *self, SegWriter *writer)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(writer);
+}
+
+void
+Arch_register_sort_writer(Architecture *self, SegWriter *writer)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(writer);
+}
+
+void
+Arch_register_highlight_writer(Architecture *self, SegWriter *writer)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(writer);
+}
+
+void
+Arch_register_deletions_writer(Architecture *self, SegWriter *writer)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(writer);
+}
+
+void
+Arch_init_seg_reader(Architecture *self, SegReader *reader)
+{
+    Arch_Register_Doc_Reader(self, reader);
+    Arch_Register_Lexicon_Reader(self, reader);
+    Arch_Register_Posting_List_Reader(self, reader);
+    Arch_Register_Sort_Reader(self, reader);
+    Arch_Register_Highlight_Reader(self, reader);
+    Arch_Register_Deletions_Reader(self, reader);
+}
+
+void
+Arch_register_doc_reader(Architecture *self, SegReader *reader)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(reader);
+}
+
+void
+Arch_register_posting_list_reader(Architecture *self, SegReader *reader)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(reader);
+}
+
+void
+Arch_register_lexicon_reader(Architecture *self, SegReader *reader)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(reader);
+}
+
+void
+Arch_register_sort_reader(Architecture *self, SegReader *reader)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(reader);
+}
+
+void
+Arch_register_highlight_reader(Architecture *self, SegReader *reader)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(reader);
+}
+
+void
+Arch_register_deletions_reader(Architecture *self, SegReader *reader)
+{
+    UNUSED_VAR(self);
+    UNUSED_VAR(reader);
+}
+
+Similarity*
+Arch_make_similarity(Architecture *self)
+{
+    UNUSED_VAR(self);
+    return (Similarity*)LuceneSim_new();
+}
+
+int32_t
+Arch_index_interval(Architecture *self) 
+{
+    UNUSED_VAR(self);
+    return 128;
+}
+
+int32_t
+Arch_skip_interval(Architecture *self) 
+{
+    UNUSED_VAR(self);
+    return 16;
+}
+
+/* Copyright 2010 The Apache Software Foundation
+ *
+ * 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.
+ */
+

Propchange: lucene/lucy/trunk/core/Lucy/Plan/Architecture.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/lucy/trunk/core/Lucy/Plan/Schema.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Plan/Schema.bp?rev=955233&r1=955232&r2=955233&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Plan/Schema.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Plan/Schema.bp Wed Jun 16 14:06:06 2010
@@ -12,6 +12,7 @@ parcel Lucy;
  */
 class Lucy::Plan::Schema extends Lucy::Object::Obj {
 
+    Architecture      *arch;
     Similarity        *sim;
     Hash              *types;
     Hash              *sims;
@@ -27,6 +28,11 @@ class Lucy::Plan::Schema extends Lucy::O
     public inert Schema*
     init(Schema *self);
 
+    /** Factory method which returns the Architecture for this index. 
+     */
+    public incremented Architecture*
+    Architecture(Schema *self);
+
     /** Define the behavior of a field by associating it with a FieldType.
      *
      * If this method has already been called for the supplied
@@ -66,6 +72,11 @@ class Lucy::Plan::Schema extends Lucy::O
     public incremented VArray*
     All_Fields(Schema *self);
 
+    /** Return the Schema instance's internal Architecture object.
+     */
+    public Architecture* 
+    Get_Architecture(Schema *self);
+
     /** Return the Schema instance's internal Similarity object.
      */
     public Similarity* 

Modified: lucene/lucy/trunk/core/Lucy/Plan/Schema.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Plan/Schema.c?rev=955233&r1=955232&r2=955233&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Plan/Schema.c (original)
+++ lucene/lucy/trunk/core/Lucy/Plan/Schema.c Wed Jun 16 14:06:06 2010
@@ -6,7 +6,7 @@
 #include "Lucy/Plan/Schema.h"
 #include "Lucy/Analysis/Analyzer.h"
 #include "Lucy/Index/Similarity.h"
-#include "Lucy/Index/Similarity/LuceneSimilarity.h"
+#include "Lucy/Plan/Architecture.h"
 #include "Lucy/Plan/FieldType.h"
 #include "Lucy/Plan/BlobType.h"
 #include "Lucy/Plan/NumericType.h"
@@ -46,7 +46,8 @@ Schema_init(Schema *self)
     VA_Resize(self->uniq_analyzers, 1);
 
     // Assign. 
-    self->sim = (Similarity*)LuceneSim_new();
+    self->arch = Schema_Architecture(self);
+    self->sim  = Arch_Make_Similarity(self->arch);
 
     return self;
 }
@@ -54,6 +55,7 @@ Schema_init(Schema *self)
 void
 Schema_destroy(Schema *self) 
 {
+    DECREF(self->arch);
     DECREF(self->analyzers);
     DECREF(self->uniq_analyzers);
     DECREF(self->uniq_sims);
@@ -86,11 +88,19 @@ Schema_equals(Schema *self, Obj *other)
     if (evil_twin == self) return true;
     if (!other) return false;
     if (!Obj_Is_A(other, SCHEMA)) return false;
+    if (!Arch_Equals(self->arch, (Obj*)evil_twin->arch)) return false;
     if (!Sim_Equals(self->sim, (Obj*)evil_twin->sim)) return false;
     if (!Hash_Equals(self->types, (Obj*)evil_twin->types)) return false;
     return true;
 }
 
+Architecture*
+Schema_architecture(Schema *self)
+{
+    UNUSED_VAR(self);
+    return Arch_new();
+}
+
 void
 Schema_spec_field(Schema *self, const CharBuf *field, FieldType *type)
 {
@@ -181,6 +191,8 @@ Schema_num_fields(Schema *self)
     return Hash_Get_Size(self->types);
 }
 
+Architecture*
+Schema_get_architecture(Schema *self) { return self->arch; }
 Similarity*
 Schema_get_similarity(Schema *self)   { return self->sim; }
 

Added: lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.bp?rev=955233&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.bp Wed Jun 16 14:06:06 2010
@@ -0,0 +1,22 @@
+parcel Lucy;
+
+inert class Lucy::Test::Plan::TestArchitecture cnick TestArch {
+    inert void
+    run_tests();
+}
+
+/* Copyright 2010 The Apache Software Foundation
+ *
+ * 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.
+ */
+

Propchange: lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.bp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.c?rev=955233&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.c (added)
+++ lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.c Wed Jun 16 14:06:06 2010
@@ -0,0 +1,66 @@
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Test.h"
+#include "Lucy/Test/Plan/TestArchitecture.h"
+#include "Lucy/Plan/Architecture.h"
+#include "Lucy/Index/Similarity.h"
+
+static void
+test_Equals(TestBatch *batch)
+{
+    Architecture *arch1 = Arch_new();
+    Architecture *arch2 = Arch_new();
+    ASSERT_TRUE(batch, Arch_Equals(arch1, (Obj*)arch2), 
+        "Equals() true for different objects of the same class");
+    ASSERT_FALSE(batch, Arch_Equals(arch1, NULL), 
+        "Equals() false for NULL");
+    ASSERT_FALSE(batch, Arch_Equals(arch1, (Obj*)&EMPTY), 
+        "Equals() false for different type of object");
+    DECREF(arch1);
+    DECREF(arch2);
+}
+
+static void
+test_intervals(TestBatch *batch)
+{
+    Architecture *arch = Arch_new();
+    ASSERT_INT_EQ(batch, Arch_Index_Interval(arch), 128, "Index_Interval()");
+    ASSERT_INT_EQ(batch, Arch_Skip_Interval(arch), 16, "Skip_Interval()");
+}
+
+static void
+test_Make_Similarity(TestBatch *batch)
+{
+    Architecture *arch = Arch_new();
+    Similarity *sim = Arch_Make_Similarity(arch);
+    ASSERT_TRUE(batch, sim && Sim_Is_A(sim, SIMILARITY), "Make_Similarity()");
+    DECREF(sim);
+    DECREF(arch);
+}
+
+void
+TestArch_run_tests()
+{
+    TestBatch *batch = TestBatch_new(6);
+    TestBatch_Plan(batch);
+    test_Equals(batch);
+    test_intervals(batch);
+    test_Make_Similarity(batch);
+    DECREF(batch);
+}
+
+/* Copyright 2010 The Apache Software Foundation
+ *
+ * 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.
+ */
+

Propchange: lucene/lucy/trunk/core/Lucy/Test/Plan/TestArchitecture.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/lucy/trunk/perl/lib/Lucy/Test.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/lib/Lucy/Test.pm?rev=955233&r1=955232&r2=955233&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/lib/Lucy/Test.pm (original)
+++ lucene/lucy/trunk/perl/lib/Lucy/Test.pm Wed Jun 16 14:06:06 2010
@@ -50,6 +50,9 @@ PPCODE:
         lucy_TestVArray_run_tests();
     }
     // Lucy::Plan 
+    else if (strEQ(package, "TestArchitecture")) {
+        lucy_TestArch_run_tests();
+    }
     else if (strEQ(package, "TestBlobType")) {
         lucy_TestBlobType_run_tests();
     }

Added: lucene/lucy/trunk/perl/t/core/228-architecture.t
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/t/core/228-architecture.t?rev=955233&view=auto
==============================================================================
--- lucene/lucy/trunk/perl/t/core/228-architecture.t (added)
+++ lucene/lucy/trunk/perl/t/core/228-architecture.t Wed Jun 16 14:06:06 2010
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+
+use Lucy::Test;
+Lucy::Test::run_tests("TestArchitecture");
+

Propchange: lucene/lucy/trunk/perl/t/core/228-architecture.t
------------------------------------------------------------------------------
    svn:eol-style = native