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/11 02:01:12 UTC
svn commit: r953509 - in /lucene/lucy/trunk: core/Lucy/Plan/NumericType.bp
core/Lucy/Plan/NumericType.c core/Lucy/Test/Plan/TestNumericType.bp
core/Lucy/Test/Plan/TestNumericType.c perl/lib/Lucy/Test.pm
perl/t/core/232-numeric_type.t
Author: marvin
Date: Fri Jun 11 00:01:12 2010
New Revision: 953509
URL: http://svn.apache.org/viewvc?rev=953509&view=rev
Log:
Add numeric FieldType classes: abstract classes NumericType, IntType,
FloatType, and concrete classes Int32Type, Int64Type, Float32Type and
Float64Type. (LUCY-108)
Added:
lucene/lucy/trunk/core/Lucy/Plan/NumericType.bp (with props)
lucene/lucy/trunk/core/Lucy/Plan/NumericType.c (with props)
lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.bp (with props)
lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.c (with props)
lucene/lucy/trunk/perl/t/core/232-numeric_type.t (with props)
Modified:
lucene/lucy/trunk/perl/lib/Lucy/Test.pm
Added: lucene/lucy/trunk/core/Lucy/Plan/NumericType.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Plan/NumericType.bp?rev=953509&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Plan/NumericType.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Plan/NumericType.bp Fri Jun 11 00:01:12 2010
@@ -0,0 +1,151 @@
+parcel Lucy;
+
+class Lucy::Plan::NumericType cnick NumType
+ extends Lucy::Plan::FieldType : dumpable {
+
+ public inert NumericType*
+ init(NumericType *self, Similarity *similarity = NULL);
+
+ inert NumericType*
+ init2(NumericType *self, Similarity *similarity = NULL, float boost = 1.0,
+ bool_t indexed = true, bool_t stored = true,
+ bool_t sortable = false);
+
+ /** Returns true.
+ */
+ public bool_t
+ Binary(NumericType *self);
+
+ /** Return the primitive type specifier for the object type, e.g.
+ * f64_t for Float64, uint32_t for UInteger32, etc.
+ */
+ abstract incremented CharBuf*
+ Specifier(NumericType *self);
+
+ incremented Hash*
+ Dump_For_Schema(NumericType *self);
+
+ public incremented Hash*
+ Dump(NumericType *self);
+
+ public incremented NumericType*
+ Load(NumericType *self, Obj *dump);
+}
+
+abstract class Lucy::Plan::FloatType
+ extends Lucy::Plan::NumericType : dumpable { }
+
+class Lucy::Plan::Float64Type
+ extends Lucy::Plan::FloatType : dumpable {
+
+ public inert Float64Type*
+ new(Similarity *similarity = NULL);
+
+ public inert Float64Type*
+ init(Float64Type *self, Similarity *similarity = NULL);
+
+ inert Float64Type*
+ init2(Float64Type *self, Similarity *similarity = NULL, float boost = 1.0,
+ bool_t indexed = true, bool_t stored = true,
+ bool_t sortable = true);
+
+ uint8_t
+ Scalar_Type_ID(Float64Type *self);
+
+ incremented CharBuf*
+ Specifier(Float64Type *self);
+
+ public bool_t
+ Equals(Float64Type *self, Obj *other);
+}
+
+class Lucy::Plan::Float32Type
+ extends Lucy::Plan::FloatType : dumpable {
+
+ public inert Float32Type*
+ new(Similarity *similarity = NULL);
+
+ public inert Float32Type*
+ init(Float32Type *self, Similarity *similarity = NULL);
+
+ inert Float32Type*
+ init2(Float32Type *self, Similarity *similarity = NULL, float boost = 1.0,
+ bool_t indexed = true, bool_t stored = true,
+ bool_t sortable = false);
+
+ uint8_t
+ Scalar_Type_ID(Float32Type *self);
+
+ incremented CharBuf*
+ Specifier(Float32Type *self);
+
+ public bool_t
+ Equals(Float32Type *self, Obj *other);
+}
+
+abstract class Lucy::Plan::IntType
+ extends Lucy::Plan::NumericType : dumpable { }
+
+class Lucy::Plan::Int32Type
+ extends Lucy::Plan::IntType : dumpable {
+
+ public inert Int32Type*
+ new(Similarity *similarity = NULL);
+
+ public inert Int32Type*
+ init(Int32Type *self, Similarity *similarity = NULL);
+
+ inert Int32Type*
+ init2(Int32Type *self, Similarity *similarity = NULL, float boost = 1.0,
+ bool_t indexed = true, bool_t stored = true,
+ bool_t sortable = false);
+
+ uint8_t
+ Scalar_Type_ID(Int32Type *self);
+
+ incremented CharBuf*
+ Specifier(Int32Type *self);
+
+ public bool_t
+ Equals(Int32Type *self, Obj *other);
+}
+
+class Lucy::Plan::Int64Type
+ extends Lucy::Plan::IntType : dumpable {
+
+ public inert Int64Type*
+ new(Similarity *similarity = NULL);
+
+ public inert Int64Type*
+ init(Int64Type *self, Similarity *similarity = NULL);
+
+ inert Int64Type*
+ init2(Int64Type *self, Similarity *similarity = NULL, float boost = 1.0,
+ bool_t indexed = true, bool_t stored = true,
+ bool_t sortable = false);
+
+ uint8_t
+ Scalar_Type_ID(Int64Type *self);
+
+ incremented CharBuf*
+ Specifier(Int64Type *self);
+
+ public bool_t
+ Equals(Int64Type *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/NumericType.bp
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/core/Lucy/Plan/NumericType.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Plan/NumericType.c?rev=953509&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Plan/NumericType.c (added)
+++ lucene/lucy/trunk/core/Lucy/Plan/NumericType.c Fri Jun 11 00:01:12 2010
@@ -0,0 +1,332 @@
+#define C_LUCY_NUMERICTYPE
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Plan/NumericType.h"
+#include "Lucy/Index/Similarity.h"
+
+NumericType*
+NumType_init(NumericType *self, Similarity *similarity)
+{
+ return NumType_init2(self, similarity, 1.0, true, true, false);
+}
+
+NumericType*
+NumType_init2(NumericType *self, Similarity *similarity, float boost,
+ bool_t indexed, bool_t stored, bool_t sortable)
+{
+ return (NumericType*)FType_init2((FieldType*)self, similarity, boost,
+ indexed, stored, sortable);
+}
+
+bool_t
+NumType_binary(NumericType *self)
+{
+ UNUSED_VAR(self);
+ return true;
+}
+
+Hash*
+NumType_dump_for_schema(NumericType *self)
+{
+ Hash *dump = Hash_new(0);
+ Hash_Store_Str(dump, "type", 4, (Obj*)NumType_Specifier(self));
+
+ // Store attributes that override the defaults.
+ if (self->boost != 1.0) {
+ Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", self->boost));
+ }
+ if (!self->indexed) {
+ Hash_Store_Str(dump, "indexed", 7, (Obj*)CB_newf("0"));
+ }
+ if (!self->stored) {
+ Hash_Store_Str(dump, "stored", 6, (Obj*)CB_newf("0"));
+ }
+ if (self->sortable) {
+ Hash_Store_Str(dump, "sortable", 8, (Obj*)CB_newf("1"));
+ }
+
+ return dump;
+}
+
+Hash*
+NumType_dump(NumericType *self)
+{
+ Hash *dump = NumType_Dump_For_Schema(self);
+ Hash_Store_Str(dump, "_class", 6,
+ (Obj*)CB_Clone(NumType_Get_Class_Name(self)));
+ if (self->sim) {
+ Hash_Store_Str(dump, "similarity", 10, (Obj*)Sim_Dump(self->sim));
+ }
+ DECREF(Hash_Delete_Str(dump, "type", 4));
+ return dump;
+}
+
+NumericType*
+NumType_load(NumericType *self, Obj *dump)
+{
+ UNUSED_VAR(self);
+ Hash *source = (Hash*)CERTIFY(dump, HASH);
+
+ // Get a VTable
+ CharBuf *class_name = (CharBuf*)Hash_Fetch_Str(source, "_class", 6);
+ CharBuf *type_spec = (CharBuf*)Hash_Fetch_Str(source, "type", 4);
+ VTable *vtable = NULL;
+ if (class_name != NULL && Obj_Is_A((Obj*)class_name, CHARBUF)) {
+ vtable = VTable_singleton(class_name, NULL);
+ }
+ else if (type_spec != NULL && Obj_Is_A((Obj*)type_spec, CHARBUF)) {
+ if (CB_Equals_Str(type_spec, "i32_t", 5)) {
+ vtable = INT32TYPE;
+ }
+ else if (CB_Equals_Str(type_spec, "i64_t", 5)) {
+ vtable = INT64TYPE;
+ }
+ else if (CB_Equals_Str(type_spec, "f32_t", 5)) {
+ vtable = FLOAT32TYPE;
+ }
+ else if (CB_Equals_Str(type_spec, "f64_t", 5)) {
+ vtable = FLOAT64TYPE;
+ }
+ else {
+ THROW(ERR, "Unrecognized type string: '%o'", type_spec);
+ }
+ }
+ CERTIFY(vtable, VTABLE);
+ NumericType *loaded = (NumericType*)VTable_Make_Obj(vtable);
+
+ // Extract boost.
+ Obj *boost_dump = Hash_Fetch_Str(source, "boost", 5);
+ float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f;
+
+ // Find boolean properties.
+ Obj *indexed_dump = Hash_Fetch_Str(source, "indexed", 7);
+ Obj *stored_dump = Hash_Fetch_Str(source, "stored", 6);
+ Obj *sort_dump = Hash_Fetch_Str(source, "sortable", 8);
+ bool_t indexed = indexed_dump ? (bool_t)Obj_To_I64(indexed_dump) : true;
+ bool_t stored = stored_dump ? (bool_t)Obj_To_I64(stored_dump) : true;
+ bool_t sortable = sort_dump ? (bool_t)Obj_To_I64(sort_dump) : false;
+
+ // Extract a Similarity.
+ Similarity *sim = NULL;
+ Obj *sim_dump = Hash_Fetch_Str(source, "similarity", 10);
+ if (sim_dump) {
+ if (Obj_Is_A(sim_dump, SIMILARITY)) {
+ // Schema munged the dump and installed a shared sim.
+ sim = (Similarity*)INCREF(sim_dump);
+ }
+ else {
+ sim = (Similarity*)CERTIFY(
+ Obj_Load(sim_dump, sim_dump), SIMILARITY);
+ }
+ }
+
+ return NumType_init2(loaded, sim, boost, indexed, stored, sortable);
+}
+
+/****************************************************************************/
+
+Float64Type*
+Float64Type_new(Similarity *similarity)
+{
+ Float64Type *self = (Float64Type*)VTable_Make_Obj(FLOAT64TYPE);
+ return Float64Type_init(self, similarity);
+}
+
+Float64Type*
+Float64Type_init(Float64Type *self, Similarity *similarity)
+{
+ return Float64Type_init2(self, similarity, 1.0, true, true, false);
+}
+
+Float64Type*
+Float64Type_init2(Float64Type *self, Similarity *similarity, float boost,
+ bool_t indexed, bool_t stored, bool_t sortable)
+{
+ return (Float64Type*)NumType_init2((NumericType*)self, similarity, boost,
+ indexed, stored, sortable);
+}
+
+CharBuf*
+Float64Type_specifier(Float64Type *self)
+{
+ UNUSED_VAR(self);
+ return CB_newf("f64_t");
+}
+
+uint8_t
+Float64Type_scalar_type_id(Float64Type *self)
+{
+ UNUSED_VAR(self);
+ return Obj_FLOAT64;
+}
+
+bool_t
+Float64Type_equals(Float64Type *self, Obj *other)
+{
+ if (self == (Float64Type*)other) { return true; }
+ if (!other) { return false; }
+ if (!Obj_Is_A(other, FLOAT64TYPE)) { return false; }
+ Float64Type_equals_t super_equals = (Float64Type_equals_t)
+ SUPER_METHOD(FLOAT64TYPE, Float64Type, Equals);
+ return super_equals(self, other);
+}
+
+/****************************************************************************/
+
+Float32Type*
+Float32Type_new(Similarity *similarity)
+{
+ Float32Type *self = (Float32Type*)VTable_Make_Obj(FLOAT32TYPE);
+ return Float32Type_init(self, similarity);
+}
+
+Float32Type*
+Float32Type_init(Float32Type *self, Similarity *similarity)
+{
+ return Float32Type_init2(self, similarity, 1.0, true, true, false);
+}
+
+Float32Type*
+Float32Type_init2(Float32Type *self, Similarity *similarity, float boost,
+ bool_t indexed, bool_t stored, bool_t sortable)
+{
+ return (Float32Type*)NumType_init2((NumericType*)self, similarity, boost,
+ indexed, stored, sortable);
+}
+
+CharBuf*
+Float32Type_specifier(Float32Type *self)
+{
+ UNUSED_VAR(self);
+ return CB_newf("f32_t");
+}
+
+uint8_t
+Float32Type_scalar_type_id(Float32Type *self)
+{
+ UNUSED_VAR(self);
+ return Obj_FLOAT32;
+}
+
+bool_t
+Float32Type_equals(Float32Type *self, Obj *other)
+{
+ if (self == (Float32Type*)other) { return true; }
+ if (!other) { return false; }
+ if (!Obj_Is_A(other, FLOAT32TYPE)) { return false; }
+ Float32Type_equals_t super_equals = (Float32Type_equals_t)
+ SUPER_METHOD(FLOAT32TYPE, Float32Type, Equals);
+ return super_equals(self, other);
+}
+
+/****************************************************************************/
+
+Int32Type*
+Int32Type_new(Similarity *similarity)
+{
+ Int32Type *self = (Int32Type*)VTable_Make_Obj(INT32TYPE);
+ return Int32Type_init(self, similarity);
+}
+
+Int32Type*
+Int32Type_init(Int32Type *self, Similarity *similarity)
+{
+ return Int32Type_init2(self, similarity, 1.0, true, true, false);
+}
+
+Int32Type*
+Int32Type_init2(Int32Type *self, Similarity *similarity, float boost,
+ bool_t indexed, bool_t stored, bool_t sortable)
+{
+ return (Int32Type*)NumType_init2((NumericType*)self, similarity, boost,
+ indexed, stored, sortable);
+}
+
+CharBuf*
+Int32Type_specifier(Int32Type *self)
+{
+ UNUSED_VAR(self);
+ return CB_newf("i32_t");
+}
+
+uint8_t
+Int32Type_scalar_type_id(Int32Type *self)
+{
+ UNUSED_VAR(self);
+ return Obj_INT32;
+}
+
+bool_t
+Int32Type_equals(Int32Type *self, Obj *other)
+{
+ if (self == (Int32Type*)other) { return true; }
+ if (!other) { return false; }
+ if (!Obj_Is_A(other, INT32TYPE)) { return false; }
+ Int32Type_equals_t super_equals = (Int32Type_equals_t)
+ SUPER_METHOD(INT32TYPE, Int32Type, Equals);
+ return super_equals(self, other);
+}
+
+/****************************************************************************/
+
+Int64Type*
+Int64Type_new(Similarity *similarity)
+{
+ Int64Type *self = (Int64Type*)VTable_Make_Obj(INT64TYPE);
+ return Int64Type_init(self, similarity);
+}
+
+Int64Type*
+Int64Type_init(Int64Type *self, Similarity *similarity)
+{
+ return Int64Type_init2(self, similarity, 1.0, true, true, false);
+}
+
+Int64Type*
+Int64Type_init2(Int64Type *self, Similarity *similarity, float boost,
+ bool_t indexed, bool_t stored, bool_t sortable)
+{
+ return (Int64Type*)NumType_init2((NumericType*)self, similarity, boost,
+ indexed, stored, sortable);
+}
+
+CharBuf*
+Int64Type_specifier(Int64Type *self)
+{
+ UNUSED_VAR(self);
+ return CB_newf("i64_t");
+}
+
+uint8_t
+Int64Type_scalar_type_id(Int64Type *self)
+{
+ UNUSED_VAR(self);
+ return Obj_INT64;
+}
+
+bool_t
+Int64Type_equals(Int64Type *self, Obj *other)
+{
+ if (self == (Int64Type*)other) { return true; }
+ if (!other) { return false; }
+ if (!Obj_Is_A(other, INT64TYPE)) { return false; }
+ Int64Type_equals_t super_equals = (Int64Type_equals_t)
+ SUPER_METHOD(INT64TYPE, Int64Type, Equals);
+ return super_equals(self, 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/NumericType.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.bp?rev=953509&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.bp Fri Jun 11 00:01:12 2010
@@ -0,0 +1,22 @@
+parcel Lucy;
+
+inert class Lucy::Test::Plan::TestNumericType {
+ 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/TestNumericType.bp
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.c?rev=953509&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.c (added)
+++ lucene/lucy/trunk/core/Lucy/Test/Plan/TestNumericType.c Fri Jun 11 00:01:12 2010
@@ -0,0 +1,145 @@
+#define C_LUCY_TESTNUMERICTYPE
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Test.h"
+#include "Lucy/Test/Plan/TestNumericType.h"
+#include "Lucy/Test/Index/Similarity/DummySimilarity.h"
+#include "Lucy/Plan/NumericType.h"
+
+static void
+test_Dump_Load_and_Equals(TestBatch *batch)
+{
+ Similarity *sim = (Similarity*)DummySim_new(1);
+ Int32Type *i32 = Int32Type_new(sim);
+ Int64Type *i64 = Int64Type_new(sim);
+ Float32Type *f32 = Float32Type_new(sim);
+ Float64Type *f64 = Float64Type_new(sim);
+
+ ASSERT_FALSE(batch, Int32Type_Equals(i32, (Obj*)i64),
+ "Int32Type_Equals() false for different type");
+ ASSERT_FALSE(batch, Int32Type_Equals(i32, NULL),
+ "Int32Type_Equals() false for NULL");
+
+ ASSERT_FALSE(batch, Int64Type_Equals(i64, (Obj*)i32),
+ "Int64Type_Equals() false for different type");
+ ASSERT_FALSE(batch, Int64Type_Equals(i64, NULL),
+ "Int64Type_Equals() false for NULL");
+
+ ASSERT_FALSE(batch, Float32Type_Equals(f32, (Obj*)f64),
+ "Float32Type_Equals() false for different type");
+ ASSERT_FALSE(batch, Float32Type_Equals(f32, NULL),
+ "Float32Type_Equals() false for NULL");
+
+ ASSERT_FALSE(batch, Float64Type_Equals(f64, (Obj*)f32),
+ "Float64Type_Equals() false for different type");
+ ASSERT_FALSE(batch, Float64Type_Equals(f64, NULL),
+ "Float64Type_Equals() false for NULL");
+
+ {
+ Obj *dump = (Obj*)Int32Type_Dump(i32);
+ Obj *other = Obj_Load(dump, dump);
+ ASSERT_TRUE(batch, Int32Type_Equals(i32, other),
+ "Dump => Load round trip for Int32Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Int64Type_Dump(i64);
+ Obj *other = Obj_Load(dump, dump);
+ ASSERT_TRUE(batch, Int64Type_Equals(i64, other),
+ "Dump => Load round trip for Int64Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Float32Type_Dump(f32);
+ Obj *other = Obj_Load(dump, dump);
+ ASSERT_TRUE(batch, Float32Type_Equals(f32, other),
+ "Dump => Load round trip for Float32Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Float64Type_Dump(f64);
+ Obj *other = Obj_Load(dump, dump);
+ ASSERT_TRUE(batch, Float64Type_Equals(f64, other),
+ "Dump => Load round trip for Float64Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Int32Type_Dump_For_Schema(i32);
+ // (This step is normally performed by Schema_Load() internally.)
+ Hash_Store_Str((Hash*)dump, "similarity", 10, INCREF(sim));
+ Int32Type *other = (Int32Type*)NumType_load(NULL, dump);
+ ASSERT_TRUE(batch, Int32Type_Equals(i32, (Obj*)other),
+ "Dump_For_Schema => Load round trip for Int32Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Int64Type_Dump_For_Schema(i64);
+ Hash_Store_Str((Hash*)dump, "similarity", 10, INCREF(sim));
+ Int64Type *other = (Int64Type*)NumType_load(NULL, dump);
+ ASSERT_TRUE(batch, Int64Type_Equals(i64, (Obj*)other),
+ "Dump_For_Schema => Load round trip for Int64Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Float32Type_Dump_For_Schema(f32);
+ Hash_Store_Str((Hash*)dump, "similarity", 10, INCREF(sim));
+ Float32Type *other = (Float32Type*)NumType_load(NULL, dump);
+ ASSERT_TRUE(batch, Float32Type_Equals(f32, (Obj*)other),
+ "Dump_For_Schema => Load round trip for Float32Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ {
+ Obj *dump = (Obj*)Float64Type_Dump_For_Schema(f64);
+ Hash_Store_Str((Hash*)dump, "similarity", 10, INCREF(sim));
+ Float64Type *other = (Float64Type*)NumType_load(NULL, dump);
+ ASSERT_TRUE(batch, Float64Type_Equals(f64, (Obj*)other),
+ "Dump_For_Schema => Load round trip for Float64Type");
+ DECREF(dump);
+ DECREF(other);
+ }
+
+ DECREF(i32);
+ DECREF(i64);
+ DECREF(f32);
+ DECREF(f64);
+ DECREF(sim);
+}
+
+void
+TestNumericType_run_tests()
+{
+ TestBatch *batch = TestBatch_new(16);
+ TestBatch_Plan(batch);
+ test_Dump_Load_and_Equals(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/TestNumericType.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=953509&r1=953508&r2=953509&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/lib/Lucy/Test.pm (original)
+++ lucene/lucy/trunk/perl/lib/Lucy/Test.pm Fri Jun 11 00:01:12 2010
@@ -56,6 +56,9 @@ PPCODE:
else if (strEQ(package, "TestFieldType")) {
lucy_TestFType_run_tests();
}
+ else if (strEQ(package, "TestNumericType")) {
+ lucy_TestNumericType_run_tests();
+ }
else if (strEQ(package, "TestTextType")) {
lucy_TestTextType_run_tests();
}
Added: lucene/lucy/trunk/perl/t/core/232-numeric_type.t
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/t/core/232-numeric_type.t?rev=953509&view=auto
==============================================================================
--- lucene/lucy/trunk/perl/t/core/232-numeric_type.t (added)
+++ lucene/lucy/trunk/perl/t/core/232-numeric_type.t Fri Jun 11 00:01:12 2010
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+
+use Lucy::Test;
+Lucy::Test::run_tests("TestNumericType");
+
Propchange: lucene/lucy/trunk/perl/t/core/232-numeric_type.t
------------------------------------------------------------------------------
svn:eol-style = native