Author: lewismc
Date: Thu Oct 24 13:31:29 2013
New Revision: 1535375
URL: http://svn.apache.org/r1535375
Log:
GORA-94 patch v7 commit. 2 failing tests remaining
Added:
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/Employee.java
Removed:
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/persistency/TestListGenericArray.java
Modified:
gora/branches/GORA_94/gora-compiler/src/main/java/org/apache/gora/compiler/GoraCompiler.java
gora/branches/GORA_94/gora-compiler/src/main/velocity/org/apache/gora/compiler/templates/record.vm
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/WebPageDataCreator.java
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/WebPage.java
gora/branches/GORA_94/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestGoraInputFormat.java
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestPersistentSerialization.java
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
Modified:
gora/branches/GORA_94/gora-compiler/src/main/java/org/apache/gora/compiler/GoraCompiler.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-compiler/src/main/java/org/apache/gora/compiler/GoraCompiler.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-compiler/src/main/java/org/apache/gora/compiler/GoraCompiler.java
(original)
+++
gora/branches/GORA_94/gora-compiler/src/main/java/org/apache/gora/compiler/GoraCompiler.java
Thu Oct 24 13:31:29 2013
@@ -21,8 +21,11 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.avro.Schema;
@@ -48,18 +51,22 @@ public class GoraCompiler extends Specif
static {
GORA_HIDDEN_FIELD_NAMES.add(DIRTY_BYTES_FIELD_NAME);
}
-
- public static void compileSchema(File[] srcFiles, File dest) throws
IOException {
+
+ public static void compileSchema(File[] srcFiles, File dest)
+ throws IOException {
Schema.Parser parser = new Schema.Parser();
for (File src : srcFiles) {
Schema originalSchema = parser.parse(src);
- Schema newSchema = getSchemaWithDirtySupport(originalSchema);
+ Map<Schema,Schema> queue = new HashMap<Schema,Schema>();
+ Schema newSchema = getSchemaWithDirtySupport(originalSchema, queue);
GoraCompiler compiler = new GoraCompiler(newSchema);
compiler.setTemplateDir("/org/apache/gora/compiler/templates/");
compiler.compileToDestination(src, dest);
+
}
}
+
public static String generateAppropriateImmutabilityModifier(Schema schema){
switch (schema.getType()) {
@@ -122,40 +129,43 @@ public class GoraCompiler extends Specif
super(schema);
}
- private static Schema getSchemaWithDirtySupport(Schema originalSchema)
throws IOException {
+ private static Schema getSchemaWithDirtySupport(Schema originalSchema,
Map<Schema,Schema> queue) throws IOException {
switch (originalSchema.getType()) {
case RECORD:
- return getRecordSchemaWithDirtySupport(originalSchema);
+ if (queue.containsKey(originalSchema)) {
+ return queue.get(originalSchema);
+ }
+ return getRecordSchemaWithDirtySupport(originalSchema,queue);
case UNION:
- return getUnionSchemaWithDirtySupport(originalSchema);
+ return getUnionSchemaWithDirtySupport(originalSchema,queue);
case MAP:
- return getMapSchemaWithDirtySupport(originalSchema);
+ return getMapSchemaWithDirtySupport(originalSchema,queue);
case ARRAY:
- return getArraySchemaWithDirtySupport(originalSchema);
+ return getArraySchemaWithDirtySupport(originalSchema,queue);
default:
return originalSchema;
}
}
-
- private static Schema getArraySchemaWithDirtySupport(Schema originalSchema)
throws IOException {
- return
Schema.createArray(getSchemaWithDirtySupport(originalSchema.getElementType()));
+
+ private static Schema getArraySchemaWithDirtySupport(Schema originalSchema,
Map<Schema,Schema> queue) throws IOException {
+ return
Schema.createArray(getSchemaWithDirtySupport(originalSchema.getElementType(),queue));
}
- private static Schema getMapSchemaWithDirtySupport(Schema originalSchema)
throws IOException {
- return
Schema.createMap(getSchemaWithDirtySupport(originalSchema.getValueType()));
+ private static Schema getMapSchemaWithDirtySupport(Schema originalSchema,
Map<Schema,Schema> queue) throws IOException {
+ return
Schema.createMap(getSchemaWithDirtySupport(originalSchema.getValueType(),queue));
}
- private static Schema getUnionSchemaWithDirtySupport(Schema originalSchema)
throws IOException {
+ private static Schema getUnionSchemaWithDirtySupport(Schema originalSchema,
Map<Schema,Schema> queue) throws IOException {
List<Schema> schemaTypes = originalSchema.getTypes();
List<Schema> newTypeSchemas = new ArrayList<Schema>();
for (int i = 0; i < schemaTypes.size(); i++) {
Schema currentTypeSchema = schemaTypes.get(i);
- newTypeSchemas.add(getSchemaWithDirtySupport(currentTypeSchema));
+ newTypeSchemas.add(getSchemaWithDirtySupport(currentTypeSchema,queue));
}
return Schema.createUnion(newTypeSchemas);
}
- private static Schema getRecordSchemaWithDirtySupport(Schema originalSchema)
throws IOException {
+ private static Schema getRecordSchemaWithDirtySupport(Schema originalSchema,
Map<Schema,Schema> queue) throws IOException {
if (originalSchema.getType() != Type.RECORD) {
throw new IOException("Gora only supports record schemas.");
}
@@ -170,6 +180,9 @@ public class GoraCompiler extends Specif
Schema newSchema = Schema.createRecord(originalSchema.getName(),
originalSchema.getDoc(), originalSchema.getNamespace(),
originalSchema.isError());
+
+ queue.put(originalSchema, newSchema);
+
List<Field> newFields = new ArrayList<Schema.Field>();
byte[] defaultDirtyBytesValue = new
byte[getNumberOfBytesNeededForDirtyBits(originalSchema)];
Arrays.fill(defaultDirtyBytesValue, (byte) 0);
@@ -183,7 +196,7 @@ public class GoraCompiler extends Specif
for (Field originalField : originalFields) {
// recursively add dirty support
Field newField = new Field(originalField.name(),
- getSchemaWithDirtySupport(originalField.schema()),
+ getSchemaWithDirtySupport(originalField.schema(),queue),
originalField.doc(), originalField.defaultValue(),
originalField.order());
newFields.add(newField);
Modified:
gora/branches/GORA_94/gora-compiler/src/main/velocity/org/apache/gora/compiler/templates/record.vm
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-compiler/src/main/velocity/org/apache/gora/compiler/templates/record.vm?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-compiler/src/main/velocity/org/apache/gora/compiler/templates/record.vm
(original)
+++
gora/branches/GORA_94/gora-compiler/src/main/velocity/org/apache/gora/compiler/templates/record.vm
Thu Oct 24 13:31:29 2013
@@ -24,6 +24,13 @@ package $schema.getNamespace();
#end
public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends
org.apache.avro.specific.SpecificExceptionBase#else extends
org.apache.gora.persistency.impl.PersistentBase#end implements
org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent
{
public static final org.apache.avro.Schema SCHEMA$ = new
org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}");
+
+ public static final String[] _ALL_FIELDS = {
+#foreach ($field in $schema.getFields())
+ "${this.mangle($field.name(), $schema.isError())}",
+#end
+ };
+
#foreach ($field in $schema.getFields())
#if ($field.doc())
/** $field.doc() */
Modified:
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/WebPageDataCreator.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/WebPageDataCreator.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/WebPageDataCreator.java
(original)
+++
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/WebPageDataCreator.java
Thu Oct 24 13:31:29 2013
@@ -109,7 +109,7 @@ public class WebPageDataCreator {
}
public static void createWebPageData(DataStore<String, WebPage> dataStore)
- throws IOException {
+ throws IOException {
try{
WebPage page;
log.info("creating web page data");
@@ -117,11 +117,13 @@ public class WebPageDataCreator {
for(int i=0; i<URLS.length; i++) {
page = new WebPage();
page.setUrl(new Utf8(URLS[i]));
- page.setContent(ByteBuffer.wrap(CONTENTS[i].getBytes()));
- page.setParsedContent(new ArrayList<CharSequence>());
- for(String token : CONTENTS[i].split(" ")) {
- page.getParsedContent().add(new Utf8(token));
- }
+ page.setParsedContent(new ArrayList<CharSequence>());
+ if (CONTENTS[i]!=null){
+ page.setContent(ByteBuffer.wrap(CONTENTS[i].getBytes()));
+ for(String token : CONTENTS[i].split(" ")) {
+ page.getParsedContent().add(new Utf8(token));
+ }
+ }
page.setOutlinks(new HashMap<CharSequence, CharSequence>());
for(int j=0; j<LINKS[i].length; j++) {
Added:
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/Employee.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/Employee.java?rev=1535375&view=auto
==============================================================================
---
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/Employee.java
(added)
+++
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/Employee.java
Thu Oct 24 13:31:29 2013
@@ -0,0 +1,614 @@
+/**
+ * Autogenerated by Avro
+ *
+ * DO NOT EDIT DIRECTLY
+ */
+package org.apache.gora.examples.generated;
+@SuppressWarnings("all")
+public class Employee extends org.apache.gora.persistency.impl.PersistentBase
implements org.apache.avro.specific.SpecificRecord,
org.apache.gora.persistency.Persistent {
+ public static final org.apache.avro.Schema SCHEMA$ = new
org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"org.apache.gora.examples.generated\",\"fields\":[{\"name\":\"__g__dirty\",\"type\":\"bytes\",\"doc\":\"Bytes
used to represent weather or not a field is
dirty.\",\"default\":\"AA==\"},{\"name\":\"name\",\"type\":[\"string\",\"null\"]},{\"name\":\"dateOfBirth\",\"type\":\"long\"},{\"name\":\"ssn\",\"type\":\"string\"},{\"name\":\"salary\",\"type\":\"int\"},{\"name\":\"boss\",\"type\":[\"null\",\"Employee\",\"string\"]},{\"name\":\"webpage\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"WebPage\",\"fields\":[{\"name\":\"__g__dirty\",\"type\":\"bytes\",\"doc\":\"Bytes
used to represent weather or not a field is
dirty.\",\"default\":\"AA==\"},{\"name\":\"url\",\"type\":\"string\"},{\"name\":\"content\",\"type\":[\"null\",\"bytes\"]},{\"name\":\"parsedContent\",\"type\":{\"type\":\"array\",\"items\":\"string\"}},{\"name\":\"outl
inks\",\"type\":{\"type\":\"map\",\"values\":\"string\"}},{\"name\":\"metadata\",\"type\":{\"type\":\"record\",\"name\":\"Metadata\",\"fields\":[{\"name\":\"__g__dirty\",\"type\":\"bytes\",\"doc\":\"Bytes
used to represent weather or not a field is
dirty.\",\"default\":\"AA==\"},{\"name\":\"version\",\"type\":\"int\"},{\"name\":\"data\",\"type\":{\"type\":\"map\",\"values\":\"string\"}}]}}]}]}]}");
+
+ public static final String[] _ALL_FIELDS = {
+ "__g__dirty",
+ "name",
+ "dateOfBirth",
+ "ssn",
+ "salary",
+ "boss",
+ "webpage",
+ };
+
+ /** Bytes used to represent weather or not a field is dirty. */
+ private java.nio.ByteBuffer __g__dirty = java.nio.ByteBuffer.wrap(new
byte[1]);
+ private java.lang.CharSequence name;
+ private long dateOfBirth;
+ private java.lang.CharSequence ssn;
+ private int salary;
+ private java.lang.Object boss;
+ private org.apache.gora.examples.generated.WebPage webpage;
+ public org.apache.avro.Schema getSchema() { return SCHEMA$; }
+ // Used by DatumWriter. Applications should not call.
+ public java.lang.Object get(int field$) {
+ switch (field$) {
+ case 0: return __g__dirty;
+ case 1: return name;
+ case 2: return dateOfBirth;
+ case 3: return ssn;
+ case 4: return salary;
+ case 5: return boss;
+ case 6: return webpage;
+ default: throw new org.apache.avro.AvroRuntimeException("Bad index");
+ }
+ }
+ // Used by DatumReader. Applications should not call.
+ @SuppressWarnings(value="unchecked")
+ public void put(int field$, java.lang.Object value$) {
+ switch (field$) {
+ case 0: __g__dirty = (java.nio.ByteBuffer)value$; break;
+ case 1: name = (java.lang.CharSequence)value$; break;
+ case 2: dateOfBirth = (java.lang.Long)value$; break;
+ case 3: ssn = (java.lang.CharSequence)value$; break;
+ case 4: salary = (java.lang.Integer)value$; break;
+ case 5: boss = (java.lang.Object)value$; break;
+ case 6: webpage = (org.apache.gora.examples.generated.WebPage)value$;
break;
+ default: throw new org.apache.avro.AvroRuntimeException("Bad index");
+ }
+ }
+
+ /**
+ * Gets the value of the 'name' field.
+ */
+ public java.lang.CharSequence getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the 'name' field.
+ * @param value the value to set.
+ */
+ public void setName(java.lang.CharSequence value) {
+ this.name = value;
+ setDirty(1);
+ }
+
+ /**
+ * Checks the dirty status of the 'name' field. A field is dirty if it
represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isNameDirty(java.lang.CharSequence value) {
+ return isDirty(1);
+ }
+
+ /**
+ * Gets the value of the 'dateOfBirth' field.
+ */
+ public java.lang.Long getDateOfBirth() {
+ return dateOfBirth;
+ }
+
+ /**
+ * Sets the value of the 'dateOfBirth' field.
+ * @param value the value to set.
+ */
+ public void setDateOfBirth(java.lang.Long value) {
+ this.dateOfBirth = value;
+ setDirty(2);
+ }
+
+ /**
+ * Checks the dirty status of the 'dateOfBirth' field. A field is dirty if
it represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isDateOfBirthDirty(java.lang.Long value) {
+ return isDirty(2);
+ }
+
+ /**
+ * Gets the value of the 'ssn' field.
+ */
+ public java.lang.CharSequence getSsn() {
+ return ssn.toString();
+ }
+
+ /**
+ * Sets the value of the 'ssn' field.
+ * @param value the value to set.
+ */
+ public void setSsn(java.lang.CharSequence value) {
+ this.ssn = value.toString();
+ setDirty(3);
+ }
+
+ /**
+ * Checks the dirty status of the 'ssn' field. A field is dirty if it
represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isSsnDirty(java.lang.CharSequence value) {
+ return isDirty(3);
+ }
+
+ /**
+ * Gets the value of the 'salary' field.
+ */
+ public java.lang.Integer getSalary() {
+ return salary;
+ }
+
+ /**
+ * Sets the value of the 'salary' field.
+ * @param value the value to set.
+ */
+ public void setSalary(java.lang.Integer value) {
+ this.salary = value;
+ setDirty(4);
+ }
+
+ /**
+ * Checks the dirty status of the 'salary' field. A field is dirty if it
represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isSalaryDirty(java.lang.Integer value) {
+ return isDirty(4);
+ }
+
+ /**
+ * Gets the value of the 'boss' field.
+ */
+ public java.lang.Object getBoss() {
+ return boss;
+ }
+
+ /**
+ * Sets the value of the 'boss' field.
+ * @param value the value to set.
+ */
+ public void setBoss(java.lang.Object value) {
+ this.boss = value;
+ setDirty(5);
+ }
+
+ /**
+ * Checks the dirty status of the 'boss' field. A field is dirty if it
represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isBossDirty(java.lang.Object value) {
+ return isDirty(5);
+ }
+
+ /**
+ * Gets the value of the 'webpage' field.
+ */
+ public org.apache.gora.examples.generated.WebPage getWebpage() {
+ return webpage;
+ }
+
+ /**
+ * Sets the value of the 'webpage' field.
+ * @param value the value to set.
+ */
+ public void setWebpage(org.apache.gora.examples.generated.WebPage value) {
+ this.webpage = value;
+ setDirty(6);
+ }
+
+ /**
+ * Checks the dirty status of the 'webpage' field. A field is dirty if it
represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isWebpageDirty(org.apache.gora.examples.generated.WebPage
value) {
+ return isDirty(6);
+ }
+
+ /** Creates a new Employee RecordBuilder */
+ public static org.apache.gora.examples.generated.Employee.Builder
newBuilder() {
+ return new org.apache.gora.examples.generated.Employee.Builder();
+ }
+
+ /** Creates a new Employee RecordBuilder by copying an existing Builder */
+ public static org.apache.gora.examples.generated.Employee.Builder
newBuilder(org.apache.gora.examples.generated.Employee.Builder other) {
+ return new org.apache.gora.examples.generated.Employee.Builder(other);
+ }
+
+ /** Creates a new Employee RecordBuilder by copying an existing Employee
instance */
+ public static org.apache.gora.examples.generated.Employee.Builder
newBuilder(org.apache.gora.examples.generated.Employee other) {
+ return new org.apache.gora.examples.generated.Employee.Builder(other);
+ }
+
+ private static java.nio.ByteBuffer deepCopyToWriteOnlyBuffer(
+ java.nio.ByteBuffer input) {
+ java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
+ int position = input.position();
+ input.reset();
+ int mark = input.position();
+ int limit = input.limit();
+ input.rewind();
+ input.limit(input.capacity());
+ copy.put(input);
+ input.rewind();
+ copy.rewind();
+ input.position(mark);
+ input.mark();
+ copy.position(mark);
+ copy.mark();
+ input.position(position);
+ copy.position(position);
+ input.limit(limit);
+ copy.limit(limit);
+ return copy.asReadOnlyBuffer();
+ }
+
+ /**
+ * RecordBuilder for Employee instances.
+ */
+ public static class Builder extends
org.apache.avro.specific.SpecificRecordBuilderBase<Employee>
+ implements org.apache.avro.data.RecordBuilder<Employee> {
+
+ private java.nio.ByteBuffer __g__dirty;
+ private java.lang.CharSequence name;
+ private long dateOfBirth;
+ private java.lang.CharSequence ssn;
+ private int salary;
+ private java.lang.Object boss;
+ private org.apache.gora.examples.generated.WebPage webpage;
+
+ /** Creates a new Builder */
+ private Builder() {
+ super(org.apache.gora.examples.generated.Employee.SCHEMA$);
+ }
+
+ /** Creates a Builder by copying an existing Builder */
+ private Builder(org.apache.gora.examples.generated.Employee.Builder other)
{
+ super(other);
+ }
+
+ /** Creates a Builder by copying an existing Employee instance */
+ private Builder(org.apache.gora.examples.generated.Employee other) {
+ super(org.apache.gora.examples.generated.Employee.SCHEMA$);
+ if (isValidValue(fields()[0], other.__g__dirty)) {
+ this.__g__dirty = (java.nio.ByteBuffer)
data().deepCopy(fields()[0].schema(), other.__g__dirty);
+ fieldSetFlags()[0] = true;
+ }
+ if (isValidValue(fields()[1], other.name)) {
+ this.name = (java.lang.CharSequence)
data().deepCopy(fields()[1].schema(), other.name);
+ fieldSetFlags()[1] = true;
+ }
+ if (isValidValue(fields()[2], other.dateOfBirth)) {
+ this.dateOfBirth = (java.lang.Long)
data().deepCopy(fields()[2].schema(), other.dateOfBirth);
+ fieldSetFlags()[2] = true;
+ }
+ if (isValidValue(fields()[3], other.ssn)) {
+ this.ssn = (java.lang.CharSequence)
data().deepCopy(fields()[3].schema(), other.ssn);
+ fieldSetFlags()[3] = true;
+ }
+ if (isValidValue(fields()[4], other.salary)) {
+ this.salary = (java.lang.Integer)
data().deepCopy(fields()[4].schema(), other.salary);
+ fieldSetFlags()[4] = true;
+ }
+ if (isValidValue(fields()[5], other.boss)) {
+ this.boss = (java.lang.Object) data().deepCopy(fields()[5].schema(),
other.boss);
+ fieldSetFlags()[5] = true;
+ }
+ if (isValidValue(fields()[6], other.webpage)) {
+ this.webpage = (org.apache.gora.examples.generated.WebPage)
data().deepCopy(fields()[6].schema(), other.webpage);
+ fieldSetFlags()[6] = true;
+ }
+ }
+
+ /** Gets the value of the 'name' field */
+ public java.lang.CharSequence getName() {
+ return name;
+ }
+
+ /** Sets the value of the 'name' field */
+ public org.apache.gora.examples.generated.Employee.Builder
setName(java.lang.CharSequence value) {
+ validate(fields()[1], value);
+ this.name = value;
+ fieldSetFlags()[1] = true;
+ return this;
+ }
+
+ /** Checks whether the 'name' field has been set */
+ public boolean hasName() {
+ return fieldSetFlags()[1];
+ }
+
+ /** Clears the value of the 'name' field */
+ public org.apache.gora.examples.generated.Employee.Builder clearName() {
+ name = null;
+ fieldSetFlags()[1] = false;
+ return this;
+ }
+
+ /** Gets the value of the 'dateOfBirth' field */
+ public java.lang.Long getDateOfBirth() {
+ return dateOfBirth;
+ }
+
+ /** Sets the value of the 'dateOfBirth' field */
+ public org.apache.gora.examples.generated.Employee.Builder
setDateOfBirth(long value) {
+ validate(fields()[2], value);
+ this.dateOfBirth = value;
+ fieldSetFlags()[2] = true;
+ return this;
+ }
+
+ /** Checks whether the 'dateOfBirth' field has been set */
+ public boolean hasDateOfBirth() {
+ return fieldSetFlags()[2];
+ }
+
+ /** Clears the value of the 'dateOfBirth' field */
+ public org.apache.gora.examples.generated.Employee.Builder
clearDateOfBirth() {
+ fieldSetFlags()[2] = false;
+ return this;
+ }
+
+ /** Gets the value of the 'ssn' field */
+ public java.lang.CharSequence getSsn() {
+ return ssn;
+ }
+
+ /** Sets the value of the 'ssn' field */
+ public org.apache.gora.examples.generated.Employee.Builder
setSsn(java.lang.CharSequence value) {
+ validate(fields()[3], value);
+ this.ssn = value;
+ fieldSetFlags()[3] = true;
+ return this;
+ }
+
+ /** Checks whether the 'ssn' field has been set */
+ public boolean hasSsn() {
+ return fieldSetFlags()[3];
+ }
+
+ /** Clears the value of the 'ssn' field */
+ public org.apache.gora.examples.generated.Employee.Builder clearSsn() {
+ ssn = null;
+ fieldSetFlags()[3] = false;
+ return this;
+ }
+
+ /** Gets the value of the 'salary' field */
+ public java.lang.Integer getSalary() {
+ return salary;
+ }
+
+ /** Sets the value of the 'salary' field */
+ public org.apache.gora.examples.generated.Employee.Builder setSalary(int
value) {
+ validate(fields()[4], value);
+ this.salary = value;
+ fieldSetFlags()[4] = true;
+ return this;
+ }
+
+ /** Checks whether the 'salary' field has been set */
+ public boolean hasSalary() {
+ return fieldSetFlags()[4];
+ }
+
+ /** Clears the value of the 'salary' field */
+ public org.apache.gora.examples.generated.Employee.Builder clearSalary() {
+ fieldSetFlags()[4] = false;
+ return this;
+ }
+
+ /** Gets the value of the 'boss' field */
+ public java.lang.Object getBoss() {
+ return boss;
+ }
+
+ /** Sets the value of the 'boss' field */
+ public org.apache.gora.examples.generated.Employee.Builder
setBoss(java.lang.Object value) {
+ validate(fields()[5], value);
+ this.boss = value;
+ fieldSetFlags()[5] = true;
+ return this;
+ }
+
+ /** Checks whether the 'boss' field has been set */
+ public boolean hasBoss() {
+ return fieldSetFlags()[5];
+ }
+
+ /** Clears the value of the 'boss' field */
+ public org.apache.gora.examples.generated.Employee.Builder clearBoss() {
+ boss = null;
+ fieldSetFlags()[5] = false;
+ return this;
+ }
+
+ /** Gets the value of the 'webpage' field */
+ public org.apache.gora.examples.generated.WebPage getWebpage() {
+ return webpage;
+ }
+
+ /** Sets the value of the 'webpage' field */
+ public org.apache.gora.examples.generated.Employee.Builder
setWebpage(org.apache.gora.examples.generated.WebPage value) {
+ validate(fields()[6], value);
+ this.webpage = value;
+ fieldSetFlags()[6] = true;
+ return this;
+ }
+
+ /** Checks whether the 'webpage' field has been set */
+ public boolean hasWebpage() {
+ return fieldSetFlags()[6];
+ }
+
+ /** Clears the value of the 'webpage' field */
+ public org.apache.gora.examples.generated.Employee.Builder clearWebpage() {
+ webpage = null;
+ fieldSetFlags()[6] = false;
+ return this;
+ }
+
+ @Override
+ public Employee build() {
+ try {
+ Employee record = new Employee();
+ record.__g__dirty = fieldSetFlags()[0] ? this.__g__dirty :
(java.nio.ByteBuffer) defaultValue(fields()[0]);
+ record.name = fieldSetFlags()[1] ? this.name :
(java.lang.CharSequence) defaultValue(fields()[1]);
+ record.dateOfBirth = fieldSetFlags()[2] ? this.dateOfBirth :
(java.lang.Long) defaultValue(fields()[2]);
+ record.ssn = fieldSetFlags()[3] ? this.ssn : (java.lang.CharSequence)
defaultValue(fields()[3]);
+ record.salary = fieldSetFlags()[4] ? this.salary : (java.lang.Integer)
defaultValue(fields()[4]);
+ record.boss = fieldSetFlags()[5] ? this.boss : (java.lang.Object)
defaultValue(fields()[5]);
+ record.webpage = fieldSetFlags()[6] ? this.webpage :
(org.apache.gora.examples.generated.WebPage) defaultValue(fields()[6]);
+ return record;
+ } catch (Exception e) {
+ throw new org.apache.avro.AvroRuntimeException(e);
+ }
+ }
+ }
+
+ public Employee.Tombstone getTombstone(){
+ return TOMBSTONE;
+ }
+
+ private static final Tombstone TOMBSTONE = new Tombstone();
+
+ public static final class Tombstone extends Employee implements
org.apache.gora.persistency.Tombstone {
+
+ private Tombstone() { }
+
+ /**
+ * Gets the value of the 'name' field.
+ */
+ public java.lang.CharSequence getName() {
+ throw new java.lang.UnsupportedOperationException("Get is not
supported on tombstones");
+ }
+
+ /**
+ * Sets the value of the 'name' field.
+ * @param value the value to set.
+ */
+ public void setName(java.lang.CharSequence value) {
+ throw new java.lang.UnsupportedOperationException("Set is not
supported on tombstones");
+ }
+
+ /**
+ * Checks the dirty status of the 'name' field. A field is dirty if
it represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isNameDirty(java.lang.CharSequence value) {
+ throw new java.lang.UnsupportedOperationException("IsDirty is not
supported on tombstones");
+ }
+
+ /**
+ * Gets the value of the 'dateOfBirth' field.
+ */
+ public java.lang.Long getDateOfBirth() {
+ throw new java.lang.UnsupportedOperationException("Get is not
supported on tombstones");
+ }
+
+ /**
+ * Sets the value of the 'dateOfBirth' field.
+ * @param value the value to set.
+ */
+ public void setDateOfBirth(java.lang.Long value) {
+ throw new java.lang.UnsupportedOperationException("Set is not
supported on tombstones");
+ }
+
+ /**
+ * Checks the dirty status of the 'dateOfBirth' field. A field is
dirty if it represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isDateOfBirthDirty(java.lang.Long value) {
+ throw new java.lang.UnsupportedOperationException("IsDirty is not
supported on tombstones");
+ }
+
+ /**
+ * Gets the value of the 'ssn' field.
+ */
+ public java.lang.CharSequence getSsn() {
+ throw new java.lang.UnsupportedOperationException("Get is not
supported on tombstones");
+ }
+
+ /**
+ * Sets the value of the 'ssn' field.
+ * @param value the value to set.
+ */
+ public void setSsn(java.lang.CharSequence value) {
+ throw new java.lang.UnsupportedOperationException("Set is not
supported on tombstones");
+ }
+
+ /**
+ * Checks the dirty status of the 'ssn' field. A field is dirty if it
represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isSsnDirty(java.lang.CharSequence value) {
+ throw new java.lang.UnsupportedOperationException("IsDirty is not
supported on tombstones");
+ }
+
+ /**
+ * Gets the value of the 'salary' field.
+ */
+ public java.lang.Integer getSalary() {
+ throw new java.lang.UnsupportedOperationException("Get is not
supported on tombstones");
+ }
+
+ /**
+ * Sets the value of the 'salary' field.
+ * @param value the value to set.
+ */
+ public void setSalary(java.lang.Integer value) {
+ throw new java.lang.UnsupportedOperationException("Set is not
supported on tombstones");
+ }
+
+ /**
+ * Checks the dirty status of the 'salary' field. A field is dirty if
it represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isSalaryDirty(java.lang.Integer value) {
+ throw new java.lang.UnsupportedOperationException("IsDirty is not
supported on tombstones");
+ }
+
+ /**
+ * Gets the value of the 'boss' field.
+ */
+ public java.lang.Object getBoss() {
+ throw new java.lang.UnsupportedOperationException("Get is not
supported on tombstones");
+ }
+
+ /**
+ * Sets the value of the 'boss' field.
+ * @param value the value to set.
+ */
+ public void setBoss(java.lang.Object value) {
+ throw new java.lang.UnsupportedOperationException("Set is not
supported on tombstones");
+ }
+
+ /**
+ * Checks the dirty status of the 'boss' field. A field is dirty if
it represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean isBossDirty(java.lang.Object value) {
+ throw new java.lang.UnsupportedOperationException("IsDirty is not
supported on tombstones");
+ }
+
+ /**
+ * Gets the value of the 'webpage' field.
+ */
+ public org.apache.gora.examples.generated.WebPage getWebpage() {
+ throw new java.lang.UnsupportedOperationException("Get is not
supported on tombstones");
+ }
+
+ /**
+ * Sets the value of the 'webpage' field.
+ * @param value the value to set.
+ */
+ public void setWebpage(org.apache.gora.examples.generated.WebPage
value) {
+ throw new java.lang.UnsupportedOperationException("Set is not
supported on tombstones");
+ }
+
+ /**
+ * Checks the dirty status of the 'webpage' field. A field is dirty
if it represents a change that has not yet been written to the database.
+ * @param value the value to set.
+ */
+ public boolean
isWebpageDirty(org.apache.gora.examples.generated.WebPage value) {
+ throw new java.lang.UnsupportedOperationException("IsDirty is not
supported on tombstones");
+ }
+
+
+ }
+
+}
\ No newline at end of file
Modified:
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/WebPage.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/WebPage.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/WebPage.java
(original)
+++
gora/branches/GORA_94/gora-core/src/examples/java/org/apache/gora/examples/generated/WebPage.java
Thu Oct 24 13:31:29 2013
@@ -45,7 +45,7 @@ public class WebPage extends org.apache.
* Gets the value of the 'url' field.
*/
public java.lang.CharSequence getUrl() {
- return url.toString();
+ return url;
}
/**
@@ -53,7 +53,7 @@ public class WebPage extends org.apache.
* @param value the value to set.
*/
public void setUrl(java.lang.CharSequence value) {
- this.url = value.toString();
+ this.url = value;
setDirty(1);
}
Modified:
gora/branches/GORA_94/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
(original)
+++
gora/branches/GORA_94/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
Thu Oct 24 13:31:29 2013
@@ -1,20 +1,20 @@
/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.gora.mapreduce;
import java.io.IOException;
@@ -27,9 +27,9 @@ import org.apache.gora.persistency.Persi
import org.apache.hadoop.io.serializer.Serializer;
/**
-* Hadoop serializer using {@link SpecificDatumWriter}
-* with {@link BinaryEncoder}.
-*/
+ * Hadoop serializer using {@link PersistentDatumWriter}
+ * with {@link BinaryEncoder}.
+ */
public class PersistentSerializer implements Serializer<Persistent> {
private SpecificDatumWriter<Persistent> datumWriter;
Modified:
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestGoraInputFormat.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestGoraInputFormat.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestGoraInputFormat.java
(original)
+++
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestGoraInputFormat.java
Thu Oct 24 13:31:29 2013
@@ -54,6 +54,15 @@ public class TestGoraInputFormat {
return inputFormat.getSplits(job);
}
+ /**
+ * First, asserts that the attempt to obtain splits results in
+ * greater than 0 splits which can be used for computation.
+ * We then check that the partition query (obtained by using the
+ * splits) has the same fields as we would expect by directly
+ * accessing the fields of an Employee object.
+ * @throws IOException
+ * @throws InterruptedException
+ */
@Test
@SuppressWarnings("rawtypes")
public void testGetSplits() throws IOException, InterruptedException {
@@ -63,7 +72,7 @@ public class TestGoraInputFormat {
InputSplit split = splits.get(0);
PartitionQuery query = ((GoraInputSplit)split).getQuery();
- Assert.assertTrue(Arrays.equals(getEmployeeFieldNames(),
query.getFields()));
+ assertTrue(Arrays.equals(getEmployeeFieldNames(), query.getFields()));
}
private static String[] getEmployeeFieldNames(){
Modified:
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestPersistentSerialization.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestPersistentSerialization.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestPersistentSerialization.java
(original)
+++
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/mapreduce/TestPersistentSerialization.java
Thu Oct 24 13:31:29 2013
@@ -40,6 +40,13 @@ import static org.junit.Assert.assertEqu
*/
public class TestPersistentSerialization {
+ /**
+ * Creates an Employee object in-memory setting several fields to dirty.
+ * Asserts that it can be serialized and
+ * deserialzed without loosing data. We do this by asserting
+ * what we get 'before' and 'after' (de)serialization processes.
+ * @throws Exception
+ */
@SuppressWarnings("unchecked")
@Test
public void testSerdeEmployee() throws Exception {
@@ -52,6 +59,12 @@ public class TestPersistentSerialization
TestIOUtils.testSerializeDeserialize(employee);
}
+ /**
+ * Creates an Employee object but only sets one field as dirty.
+ * We then do (de)serialization and check 'before' and 'after'
+ * states.
+ * @throws Exception
+ */
@Test
public void testSerdeEmployeeOneField() throws Exception {
Employee employee = new Employee();
@@ -60,6 +73,12 @@ public class TestPersistentSerialization
TestIOUtils.testSerializeDeserialize(employee);
}
+ /**
+ * Creates an Employee object setting only two fields as dirty.
+ * We then do (de)serialization and check 'before' and 'after'
+ * states.
+ * @throws Exception
+ */
@Test
public void testSerdeEmployeeTwoFields() throws Exception {
Employee employee = new Employee();
@@ -69,6 +88,16 @@ public class TestPersistentSerialization
TestIOUtils.testSerializeDeserialize(employee);
}
+ /**
+ * Creates an WebPage object in-memory setting several fields to dirty.
+ * Run a query over the persistent data.
+ * Asserts that the results can be serialized and
+ * deserialzed without loosing data. We do this by asserting
+ * what we get 'before' and 'after' (de)serialization processes.
+ * Also simple assertion for equal number of URL's in WebPage
+ * and results.
+ * @throws Exception
+ */
@SuppressWarnings("unchecked")
@Test
public void testSerdeWebPage() throws Exception {
@@ -88,6 +117,13 @@ public class TestPersistentSerialization
assertEquals(WebPageDataCreator.URLS.length, i);
}
+ /**
+ * Creates multiple WebPage objects setting several fields to dirty.
+ * Asserts that the data can be serialized and
+ * deserialzed without loosing data. We do this by asserting
+ * what we get 'before' and 'after' (de)serialization processes.
+ * @throws Exception
+ */
@Test
public void testSerdeMultipleWebPages() throws Exception {
WebPage page1 = new WebPage();
Modified:
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
(original)
+++
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
Thu Oct 24 13:31:29 2013
@@ -22,22 +22,17 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
-
+import java.util.List;
+import org.apache.avro.Schema.Field;
import org.apache.avro.util.Utf8;
import org.apache.gora.examples.generated.Employee;
-import org.apache.gora.examples.generated.ImmutableFields;
-import org.apache.gora.examples.generated.Metadata;
-import org.apache.gora.examples.generated.V2;
import org.apache.gora.examples.generated.WebPage;
import org.apache.gora.memory.store.MemStore;
import org.apache.gora.store.DataStoreFactory;
import org.apache.gora.store.DataStoreTestUtil;
-import org.apache.gora.util.AvroUtils;
import org.apache.hadoop.conf.Configuration;
-import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-
import org.junit.Test;
/**
@@ -45,77 +40,113 @@ import org.junit.Test;
*/
public class TestPersistentBase {
+ /**
+ * Assert that the list of fields from the WebPage Schema
+ * are as we expect. This is done by creating and accessing
+ * a WebPage object, then comparing the results against
+ * static fields of the WebPage.SCHEMA$.
+ */
@Test
public void testGetFields() {
WebPage page = new WebPage();
- String[] fields = page.getFields();
- assertArrayEquals(WebPage._ALL_FIELDS, fields);
+ List<Field> fields = page.getSchema().getFields();
+ assertEquals(WebPage.SCHEMA$.getFields(), fields);
}
+ /**
+ * Assert that individual field values are as we would
+ * expect from directly accessing WebPage.SCHEMA$ values.
+ */
@Test
public void testGetField() {
WebPage page = new WebPage();
- for(int i=0; i<WebPage._ALL_FIELDS.length; i++) {
- String field = page.getField(i);
- assertEquals(WebPage._ALL_FIELDS[i], field);
+ for(int i=0; i<WebPage.SCHEMA$.getFields().toArray().length; i++) {
+ Field field = page.getSchema().getFields().get(i);
+ assertEquals(WebPage.SCHEMA$.getFields().get(i), field);
}
}
+ /**
+ * Assert that field positions as found within the SCHEMA array
+ * are as we would expect by accessing them directly.
+ */
@Test
public void testGetFieldIndex() {
WebPage page = new WebPage();
- for(int i=0; i<WebPage._ALL_FIELDS.length; i++) {
- int index = page.getFieldIndex(WebPage._ALL_FIELDS[i]);
+ for(int i=0; i<WebPage.SCHEMA$.getFields().toArray().length; i++) {
+ int index = page.getSchema().getFields().get(i).pos();
assertEquals(i, index);
}
}
+ /**
+ * Assert that field positions as found within the SCHEMA array
+ * are as we would expect by accessing them directly.
+ * This tests for both WebPage and Employee data beans.
+ */
@Test
public void testFieldsWithTwoClasses() {
WebPage page = new WebPage();
- for(int i=0; i<WebPage._ALL_FIELDS.length; i++) {
- int index = page.getFieldIndex(WebPage._ALL_FIELDS[i]);
+ for(int i=0; i<WebPage.SCHEMA$.getFields().toArray().length; i++) {
+ int index = page.getSchema().getFields().get(i).pos();
assertEquals(i, index);
}
Employee employee = new Employee();
for(int i=0; i<Employee._ALL_FIELDS.length; i++) {
- int index = employee.getFieldIndex(Employee._ALL_FIELDS[i]);
+ int index = employee.getSchema().getFields().get(i).pos();
assertEquals(i, index);
}
}
+ /**
+ * First we create a new WebPage object, to which we add some
+ * field values. This makes the fields dirty as we have not
+ * flushed them to the datastore. We then clear the dirty
+ * fields and assert that the values DO NOT exist for the
+ * field we previously made dirty.
+ * We then set new values for fields, consequently making them
+ * dirty, before testing the clearing of an entirely new object
+ * has all fields as null as they should be clean.
+ */
@Test
public void testClear() {
//test clear all fields
WebPage page = new WebPage();
+
page.setUrl(new Utf8("http://foo.com"));
- page.addToParsedContent(new Utf8("foo"));
- page.putToOutlinks(new Utf8("foo"), new Utf8("bar"));
+ page.setParsedContent(new ArrayList<CharSequence>());
+ page.getParsedContent().add(new Utf8("foo"));
+ page.setOutlinks(new HashMap<CharSequence, CharSequence>());
+ page.getOutlinks().put(new Utf8("foo"), new Utf8("bar"));
page.setContent(ByteBuffer.wrap("foo baz bar".getBytes()));
page.clear();
assertNull(page.getUrl());
- assertEquals(0, page.getParsedContent().size());
- assertEquals(0, page.getOutlinks().size());
+ assertNull(page.getParsedContent());
+ assertNull(page.getOutlinks());
assertNull(page.getContent());
//set fields again
page.setUrl(new Utf8("http://bar.com"));
- page.addToParsedContent(new Utf8("bar"));
- page.putToOutlinks(new Utf8("bar"), new Utf8("baz"));
+ page.setParsedContent(new ArrayList<CharSequence>());
+ page.getParsedContent().add(new Utf8("bar"));
+ page.setOutlinks(new HashMap<CharSequence, CharSequence>());
+ page.getOutlinks().put(new Utf8("bar"), new Utf8("baz"));
page.setContent(ByteBuffer.wrap("foo baz bar barbaz".getBytes()));
//test clear new object
page = new WebPage();
page.clear();
-
- //test primitive fields
- Employee employee = new Employee();
- employee.clear();
}
+ /**
+ * Tests and asserts that an in-memory representation of the
+ * Employee object is Equal to a clone of the same object.
+ * @throws IOException
+ * @throws Exception
+ */
@Test
public void testClone() throws IOException, Exception {
//more tests for clone are in TestPersistentDatumReader
@@ -125,6 +156,6 @@ public class TestPersistentBase {
Employee employee = DataStoreTestUtil.createEmployee(store);
- assertEquals(employee, employee.clone());
+ assertEquals(employee, Employee.newBuilder(employee).build());
}
}
Modified:
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
URL:
http://svn.apache.org/viewvc/gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java?rev=1535375&r1=1535374&r2=1535375&view=diff
==============================================================================
---
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
(original)
+++
gora/branches/GORA_94/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
Thu Oct 24 13:31:29 2013
@@ -338,9 +338,9 @@ public class DataStoreTestUtil {
for (int i = 0; i < 1; i++) {
String key = Long.toString(ssn + i);
Employee employee = dataStore.get(key);
- assertEquals(now - 18L * YEAR_IN_MS, employee.getDateOfBirth());
//.intValue()?
+ assertEquals(now - 18L * YEAR_IN_MS,
employee.getDateOfBirth().intValue());
assertEquals("John Doe " + (i + 5), employee.getName().toString());
- assertEquals(120000, employee.getSalary()); //.intValue()?
+ assertEquals(120000, employee.getSalary().intValue());
}
}
@@ -437,19 +437,20 @@ public class DataStoreTestUtil {
" actual=" + CONTENTS[i] + " i=" + i
, Arrays.equals( toByteArray(page.getContent() )
, CONTENTS[i].getBytes()));
- GenericArray<Utf8> parsedContent = page.getParsedContent();
+
+ List<CharSequence> parsedContent = page.getParsedContent();
assertNotNull(parsedContent);
assertTrue(parsedContent.size() > 0);
int j=0;
String[] tokens = CONTENTS[i].split(" ");
- for(Utf8 token : parsedContent) {
+ for(CharSequence token : parsedContent) {
assertEquals(tokens[j++], token.toString());
}
} else {
// when page.getContent() is null
assertTrue(CONTENTS[i] == null) ;
- GenericArray<Utf8> parsedContent = page.getParsedContent();
+ List<CharSequence> parsedContent = page.getParsedContent();
assertNotNull(parsedContent);
assertTrue(parsedContent.size() == 0);
}
@@ -459,7 +460,7 @@ public class DataStoreTestUtil {
assertTrue(page.getOutlinks().size() > 0);
for(int k=0; k<LINKS[i].length; k++) {
assertEquals(ANCHORS[i][k],
- page.getFromOutlinks(new Utf8(URLS[LINKS[i][k]])).toString());
+ page.getOutlinks().get(new Utf8(URLS[LINKS[i][k]])).toString());
}
} else {
assertTrue(page.getOutlinks() == null || page.getOutlinks().isEmpty());
@@ -477,7 +478,7 @@ public class DataStoreTestUtil {
}
public static void testGetWebPage(DataStore<String, WebPage> store) throws
IOException, Exception {
- testGetWebPage(store, WebPage._ALL_FIELDS);
+ testGetWebPage(store, WebPage.SCHEMA$.getFields().toArray(new String[0]));
}
public static void testGetWebPageDefaultFields(DataStore<String, WebPage>
store)
@@ -504,7 +505,7 @@ public class DataStoreTestUtil {
public static void testQueryWebPageSingleKey(DataStore<String, WebPage>
store)
throws IOException, Exception {
- testQueryWebPageSingleKey(store, WebPage._ALL_FIELDS);
+ testQueryWebPageSingleKey(store, WebPage.SCHEMA$.getFields().toArray(new
String[0]));
}
public static void testQueryWebPageSingleKeyDefaultFields(
@@ -843,7 +844,7 @@ public class DataStoreTestUtil {
page = store.get(revUrl);
metadata = page.getMetadata();
assertNotNull(metadata);
- assertEquals(1, metadata.getVersion()); //.intValue()?
+ assertEquals(1, metadata.getVersion().intValue());
assertEquals(new Utf8("baz"), metadata.getData().get(new Utf8("foo")));
}