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/25 03:32:11 UTC
svn commit: r957777 - in /lucene/lucy/trunk: core/Lucy/Index/DataReader.bp
core/Lucy/Index/DataReader.c perl/lib/Lucy/Index/DataReader.pm
Author: marvin
Date: Fri Jun 25 01:32:11 2010
New Revision: 957777
URL: http://svn.apache.org/viewvc?rev=957777&view=rev
Log:
LUCY-118:
Add Lucy::Index::DataReader.
Added:
lucene/lucy/trunk/core/Lucy/Index/DataReader.bp (with props)
lucene/lucy/trunk/core/Lucy/Index/DataReader.c (with props)
lucene/lucy/trunk/perl/lib/Lucy/Index/DataReader.pm (with props)
Added: lucene/lucy/trunk/core/Lucy/Index/DataReader.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Index/DataReader.bp?rev=957777&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Index/DataReader.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Index/DataReader.bp Fri Jun 25 01:32:11 2010
@@ -0,0 +1,98 @@
+parcel Lucy;
+
+/** Abstract base class for reading index data.
+ *
+ * DataReader is the companion class to DataWriter. Every index
+ * component will implement one of each.
+ */
+
+class Lucy::Index::DataReader extends Lucy::Object::Obj {
+
+ Schema *schema;
+ Folder *folder;
+ Snapshot *snapshot;
+ VArray *segments;
+ Segment *segment;
+ int32_t seg_tick;
+
+ /**
+ * @param schema A Schema.
+ * @param folder A Folder.
+ * @param snapshot A Snapshot.
+ * @param segments An array of Segments.
+ * @param seg_tick The array index of the Segment object within the
+ * <code>segments</code> array that this particular DataReader is assigned
+ * to, if any. A value of -1 indicates that no Segment should be
+ * assigned.
+ */
+ public inert DataReader*
+ init(DataReader *self, Schema *schema = NULL, Folder *folder = NULL,
+ Snapshot *snapshot = NULL, VArray *segments = NULL,
+ int32_t seg_tick = -1);
+
+ /** Create a reader which aggregates the output of several lower level
+ * readers. Return NULL if such a reader is not valid.
+ *
+ * @param readers An array of DataReaders.
+ * @param offsets Doc id start offsets for each reader.
+ */
+ public abstract incremented nullable DataReader*
+ Aggregator(DataReader *self, VArray *readers, I32Array *offsets);
+
+ /** Accessor for "schema" member var.
+ */
+ public nullable Schema*
+ Get_Schema(DataReader *self);
+
+ /** Accessor for "folder" member var.
+ */
+ public nullable Folder*
+ Get_Folder(DataReader *self);
+
+ /** Accessor for "snapshot" member var.
+ */
+ public nullable Snapshot*
+ Get_Snapshot(DataReader *self);
+
+ /** Accessor for "segments" member var.
+ */
+ public nullable VArray*
+ Get_Segments(DataReader *self);
+
+ /** Accessor for "segment" member var.
+ */
+ public nullable Segment*
+ Get_Segment(DataReader *self);
+
+ /** Accessor for "seg_tick" member var.
+ */
+ public int32_t
+ Get_Seg_Tick(DataReader *self);
+
+ /** Release external resources, e.g. streams. Implementations must be
+ * safe for multiple calls. Once called, no other operations may be
+ * performed upon either the reader or any component subreaders other than
+ * object destruction.
+ */
+ public abstract void
+ Close(DataReader *self);
+
+ public void
+ Destroy(DataReader *self);
+}
+
+/* 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/Index/DataReader.bp
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/core/Lucy/Index/DataReader.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Index/DataReader.c?rev=957777&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Index/DataReader.c (added)
+++ lucene/lucy/trunk/core/Lucy/Index/DataReader.c Fri Jun 25 01:32:11 2010
@@ -0,0 +1,84 @@
+#define C_LUCY_DATAREADER
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Index/DataReader.h"
+#include "Lucy/Index/Segment.h"
+#include "Lucy/Index/Snapshot.h"
+#include "Lucy/Plan/Schema.h"
+#include "Lucy/Store/Folder.h"
+
+DataReader*
+DataReader_init(DataReader *self, Schema *schema, Folder *folder,
+ Snapshot *snapshot, VArray *segments, int32_t seg_tick)
+{
+ self->schema = (Schema*)INCREF(schema);
+ self->folder = (Folder*)INCREF(folder);
+ self->snapshot = (Snapshot*)INCREF(snapshot);
+ self->segments = (VArray*)INCREF(segments);
+ self->seg_tick = seg_tick;
+ if (seg_tick != -1) {
+ if (!segments) {
+ THROW(ERR, "No segments array provided, but seg_tick is %i32",
+ seg_tick);
+ }
+ else {
+ Segment *segment = (Segment*)VA_Fetch(segments, seg_tick);
+ if (!segment) {
+ THROW(ERR, "No segment at seg_tick %i32", seg_tick);
+ }
+ self->segment = (Segment*)INCREF(segment);
+ }
+ }
+ else {
+ self->segment = NULL;
+ }
+
+ ABSTRACT_CLASS_CHECK(self, DATAREADER);
+ return self;
+}
+
+void
+DataReader_destroy(DataReader *self)
+{
+ DECREF(self->schema);
+ DECREF(self->folder);
+ DECREF(self->snapshot);
+ DECREF(self->segments);
+ DECREF(self->segment);
+ SUPER_DESTROY(self, DATAREADER);
+}
+
+Schema*
+DataReader_get_schema(DataReader *self)
+ { return self->schema; }
+Folder*
+DataReader_get_folder(DataReader *self)
+ { return self->folder; }
+Snapshot*
+DataReader_get_snapshot(DataReader *self)
+ { return self->snapshot; }
+VArray*
+DataReader_get_segments(DataReader *self)
+ { return self->segments; }
+int32_t
+DataReader_get_seg_tick(DataReader *self)
+ { return self->seg_tick; }
+Segment*
+DataReader_get_segment(DataReader *self)
+ { return self->segment; }
+
+/* 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/Index/DataReader.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/perl/lib/Lucy/Index/DataReader.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/lib/Lucy/Index/DataReader.pm?rev=957777&view=auto
==============================================================================
--- lucene/lucy/trunk/perl/lib/Lucy/Index/DataReader.pm (added)
+++ lucene/lucy/trunk/perl/lib/Lucy/Index/DataReader.pm Fri Jun 25 01:32:11 2010
@@ -0,0 +1,75 @@
+package Lucy::Index::DataReader;
+use Lucy;
+
+1;
+
+__END__
+
+__BINDING__
+
+my $synopsis = <<'END_SYNOPSIS';
+ # Abstract base class.
+END_SYNOPSIS
+
+my $constructor = <<'END_CONSTRUCTOR';
+ my $reader = MyDataReader->new(
+ schema => $seg_reader->get_schema, # default undef
+ folder => $seg_reader->get_folder, # default undef
+ snapshot => $seg_reader->get_snapshot, # default undef
+ segments => $seg_reader->get_segments, # default undef
+ seg_tick => $seg_reader->get_seg_tick, # default -1
+ );
+END_CONSTRUCTOR
+
+Clownfish::Binding::Perl::Class->register(
+ parcel => "Lucy",
+ class_name => "Lucy::Index::DataReader",
+ bind_methods => [
+ qw(
+ Get_Schema
+ Get_Folder
+ Get_Segments
+ Get_Snapshot
+ Get_Seg_Tick
+ Get_Segment
+ Aggregator
+ Close
+ )
+ ],
+ bind_constructors => ["new"],
+ make_pod => {
+ synopsis => $synopsis,
+ constructor => { sample => $constructor, },
+ methods => [
+ qw(
+ get_schema
+ get_folder
+ get_snapshot
+ get_segments
+ get_segment
+ get_seg_tick
+ aggregator
+ )
+ ]
+ },
+);
+
+
+__COPYRIGHT__
+
+ /**
+ * 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/perl/lib/Lucy/Index/DataReader.pm
------------------------------------------------------------------------------
svn:eol-style = native