aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-03-24 13:10:14 +0000
committerArne H Juul <arnej@yahooinc.com>2022-03-24 13:10:14 +0000
commitfeeef17624a66e5762568ce21ca9d96d6b21e6cc (patch)
tree66b860cf7148dca9342fc344d63bae14135aee48
parentd816728be160c4632da498cce6cc333ec82b59c5 (diff)
expand tabs and reindent
-rw-r--r--[-rwxr-xr-x]document/src/main/java/com/yahoo/document/DocumentType.java4
-rw-r--r--document/src/main/java/com/yahoo/document/select/Result.java6
-rw-r--r--document/src/main/java/com/yahoo/document/select/convert/NowQueryNode.java2
-rw-r--r--document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java64
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/DocumentReader.java12
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentIdTestCase.java20
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java66
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java142
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/SpanListAdvTestCase.java22
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/SpanNodeAdvTestCase.java260
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/SpanNodeTestCase.java150
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/SpanTreeAdvTest.java22
12 files changed, 385 insertions, 385 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java
index 6cfbb96ae5f..1469776583d 100755..100644
--- a/document/src/main/java/com/yahoo/document/DocumentType.java
+++ b/document/src/main/java/com/yahoo/document/DocumentType.java
@@ -291,8 +291,8 @@ public class DocumentType extends StructuredDataType {
* @param type An already DocumentType object.
*/
public void inherit(DocumentType type) {
- //TODO: There is also a check like the following in SDDocumentType addField(), try to move that to this class' addField() to get it proper,
- // as this method is called only when the doc types are exported.
+ //TODO: There is also a check like the following in SDDocumentType addField(), try to move that to this class' addField() to get it proper,
+ // as this method is called only when the doc types are exported.
verifyTypeConsistency(type);
if (isRegistered()) {
throw new IllegalStateException("You cannot add inheritance to a document type that is already registered.");
diff --git a/document/src/main/java/com/yahoo/document/select/Result.java b/document/src/main/java/com/yahoo/document/select/Result.java
index be8906a4271..a6b3f5cfcbd 100644
--- a/document/src/main/java/com/yahoo/document/select/Result.java
+++ b/document/src/main/java/com/yahoo/document/select/Result.java
@@ -25,9 +25,9 @@ public enum Result {
* @return inverted result
*/
public static Result invert(Result result) {
- if (result == Result.TRUE) return Result.FALSE;
- if (result == Result.FALSE) return Result.TRUE;
- return Result.INVALID;
+ if (result == Result.TRUE) return Result.FALSE;
+ if (result == Result.FALSE) return Result.TRUE;
+ return Result.INVALID;
}
/**
diff --git a/document/src/main/java/com/yahoo/document/select/convert/NowQueryNode.java b/document/src/main/java/com/yahoo/document/select/convert/NowQueryNode.java
index c7180b16210..ee53093fdc4 100644
--- a/document/src/main/java/com/yahoo/document/select/convert/NowQueryNode.java
+++ b/document/src/main/java/com/yahoo/document/select/convert/NowQueryNode.java
@@ -14,7 +14,7 @@ public class NowQueryNode {
this.value = value;
}
NowQueryNode(ArithmeticNode node) {
- // Assumes that the structure is checked and verified earlier
+ // Assumes that the structure is checked and verified earlier
this.value = Long.parseLong(node.getItems().get(1).getNode().toString());
}
@Override
diff --git a/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java b/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java
index f77aaffa7c7..cf7e3851d55 100644
--- a/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java
+++ b/document/src/main/java/com/yahoo/document/select/rule/ComparisonNode.java
@@ -99,9 +99,9 @@ public class ComparisonNode implements ExpressionNode {
String name = (String)value;
if ((operator.equals("=") && name.contains("*")) ||
(operator.equals("=~") && ((name.contains("*") || name.contains("?")))))
- {
- return null; // no idea
- }
+ {
+ return null; // no idea
+ }
return new BucketSet(factory.getBucketId(new DocumentId(name)));
}
} else if (field.equalsIgnoreCase("user")) {
@@ -112,10 +112,10 @@ public class ComparisonNode implements ExpressionNode {
if (value instanceof String) {
String name = (String)value;
if ((operator.equals("=") && name.contains("*")) ||
- (operator.equals("=~") && ((name.contains("*") || name.contains("?")))))
- {
- return null; // no idea
- }
+ (operator.equals("=~") && ((name.contains("*") || name.contains("?")))))
+ {
+ return null; // no idea
+ }
return new BucketSet(new BucketId(factory.getLocationBitCount(), IdIdString.makeLocation(name)));
}
} else if (field.equalsIgnoreCase("bucket")) {
@@ -270,7 +270,7 @@ public class ComparisonNode implements ExpressionNode {
double a = getAsNumber(lhs);
double b = getAsNumber(rhs);
if (Double.isNaN(a) || Double.isNaN(b)) {
- return Result.toResult(lhs.toString().equals(rhs.toString()));
+ return Result.toResult(lhs.toString().equals(rhs.toString()));
}
return Result.toResult(a == b); // Ugh, comparing doubles? Should be converted to long value perhaps...
}
@@ -295,11 +295,11 @@ public class ComparisonNode implements ExpressionNode {
* @return The evaluation result.
*/
private Result evaluateNumber(Object lhs, Object rhs) {
- double a = getAsNumber(lhs);
- double b = getAsNumber(rhs);
- if (Double.isNaN(a) || Double.isNaN(b)) {
- return Result.INVALID;
- }
+ double a = getAsNumber(lhs);
+ double b = getAsNumber(rhs);
+ if (Double.isNaN(a) || Double.isNaN(b)) {
+ return Result.INVALID;
+ }
if (operator.equals("<")) {
return Result.toResult(a < b);
} else if (operator.equals("<=")) {
@@ -353,25 +353,25 @@ public class ComparisonNode implements ExpressionNode {
*/
private String globToRegex(char glob) {
switch (glob) {
- case'*':
- return ".*";
- case'?':
- return ".";
- case'^':
- case'$':
- case'|':
- case'{':
- case'}':
- case'(':
- case')':
- case'[':
- case']':
- case'\\':
- case'+':
- case'.':
- return "\\" + glob;
- default:
- return "" + glob;
+ case'*':
+ return ".*";
+ case'?':
+ return ".";
+ case'^':
+ case'$':
+ case'|':
+ case'{':
+ case'}':
+ case'(':
+ case')':
+ case'[':
+ case']':
+ case'\\':
+ case'+':
+ case'.':
+ return "\\" + glob;
+ default:
+ return "" + glob;
}
}
diff --git a/document/src/main/java/com/yahoo/document/serialization/DocumentReader.java b/document/src/main/java/com/yahoo/document/serialization/DocumentReader.java
index 12a5497a892..b4c242a6f92 100644
--- a/document/src/main/java/com/yahoo/document/serialization/DocumentReader.java
+++ b/document/src/main/java/com/yahoo/document/serialization/DocumentReader.java
@@ -14,12 +14,12 @@ import com.yahoo.document.DocumentTypeManager;
*/
public interface DocumentReader {
- /**
- * Read a document
- *
- * @param document - document to be read
- */
- void read(Document document);
+ /**
+ * Read a document
+ *
+ * @param document - document to be read
+ */
+ void read(Document document);
DocumentId readDocumentId();
DocumentType readDocumentType();
diff --git a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
index 0d3b07fd6ee..4b86357099e 100644
--- a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
@@ -127,20 +127,20 @@ public class DocumentIdTestCase {
private void compareStringByte(String s, byte[] b){
/*
- System.out.println("-- "+s+" --");
- System.out.print("++ 0x");
- for (int i=0; i<b.length; ++i) {
- int nr = b[i] & 0xFF;
- System.out.print(Integer.toHexString(nr / 16) + Integer.toHexString(nr % 16));
- }
- System.out.println(" ++");
+ System.out.println("-- "+s+" --");
+ System.out.print("++ 0x");
+ for (int i=0; i<b.length; ++i) {
+ int nr = b[i] & 0xFF;
+ System.out.print(Integer.toHexString(nr / 16) + Integer.toHexString(nr % 16));
+ }
+ System.out.println(" ++");
*/
s = s.substring(2);
assertEquals(s.length()/2, b.length);
for(int i=0; i<b.length;i++){
String ss = s.substring(2*i,2*i+2);
assertEquals(Integer.valueOf(ss, 16).intValue(),(((int)b[i])+256)%256);
- }
+ }
}
//Compares bucketId with C++ implementation located in
@@ -213,9 +213,9 @@ public class DocumentIdTestCase {
@Test
public void testDocumentIdCanOnlyContainTextCharacters() throws UnsupportedEncodingException {
assertExceptionWhenConstructing(new byte[]{105, 100, 58, 97, 58, 98, 58, 58, 0, 99}, // "id:a:b::0x0c"
- "illegal code point 0x0");
+ "illegal code point 0x0");
assertExceptionWhenConstructing(new byte[]{105, 100, 58, 97, 58, 98, 58, 58, 7, 99}, // "id:a:b::0x7c"
- "illegal code point 0x7");
+ "illegal code point 0x7");
}
private void assertExceptionWhenConstructing(byte[] rawId,
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java
index fcaf96a788f..afe327b7179 100644
--- a/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java
@@ -41,25 +41,25 @@ public class Bug4259784TestCase {
private void annotate(Document document, DocumentTypeManager manager) {
AnnotationTypeRegistry registry = manager.getAnnotationTypeRegistry();
- AnnotationType company = registry.getType("company");
- AnnotationType industry = registry.getType("industry");
- AnnotationType person = registry.getType("person");
- AnnotationType location = registry.getType("location");
+ AnnotationType company = registry.getType("company");
+ AnnotationType industry = registry.getType("industry");
+ AnnotationType person = registry.getType("person");
+ AnnotationType location = registry.getType("location");
- SpanTree tree = new SpanTree("testannotations");
+ SpanTree tree = new SpanTree("testannotations");
SpanList root = (SpanList) tree.getRoot();
- SpanNode span1 = new Span(0,5);
- SpanNode span2 = new Span(5,10);
- SpanNode span3 = new Span(10,15);
- SpanNode span4 = new Span(15,20);
- SpanNode span5 = new Span(6,10);
- SpanNode span6 = new Span(8,4);
+ SpanNode span1 = new Span(0,5);
+ SpanNode span2 = new Span(5,10);
+ SpanNode span3 = new Span(10,15);
+ SpanNode span4 = new Span(15,20);
+ SpanNode span5 = new Span(6,10);
+ SpanNode span6 = new Span(8,4);
SpanNode span7 = new Span(4, 2);
- root.add(span1);
- root.add(span2);
- root.add(span4);
+ root.add(span1);
+ root.add(span2);
+ root.add(span4);
root.add(span5);
root.add(span6);
@@ -71,19 +71,19 @@ public class Bug4259784TestCase {
root.add(aspl);
- Struct personValue = (Struct) person.getDataType().createFieldValue();
- personValue.setFieldValue("name", "Richard Bair");
- Annotation personAn = new Annotation(person, personValue);
- tree.annotate(span1, personAn);
+ Struct personValue = (Struct) person.getDataType().createFieldValue();
+ personValue.setFieldValue("name", "Richard Bair");
+ Annotation personAn = new Annotation(person, personValue);
+ tree.annotate(span1, personAn);
- Struct companyValue = (Struct) company.getDataType().createFieldValue();
- companyValue.setFieldValue("name", "Sun");
+ Struct companyValue = (Struct) company.getDataType().createFieldValue();
+ companyValue.setFieldValue("name", "Sun");
Annotation compAn = new Annotation(company, companyValue);
tree.annotate(span2, compAn);
Struct locationVal = new Struct(manager.getDataType("annotation.location"));
- locationVal.setFieldValue("lat", 37.774929);
- locationVal.setFieldValue("lon", -122.419415);
+ locationVal.setFieldValue("lat", 37.774929);
+ locationVal.setFieldValue("lon", -122.419415);
Annotation locAnnotation = new Annotation(location, locationVal);
tree.annotate(span3, locAnnotation);
@@ -108,24 +108,24 @@ public class Bug4259784TestCase {
Field compLocField = ((StructDataType) company.getDataType()).getField("place");
AnnotationReferenceDataType annType = (AnnotationReferenceDataType) compLocField.getDataType();
FieldValue compLocFieldVal = new AnnotationReference(annType, locAnnotation);
- companyValue.setFieldValue(compLocField, compLocFieldVal);
- companyValue.setFieldValue("vertical", "software");
+ companyValue.setFieldValue(compLocField, compLocFieldVal);
+ companyValue.setFieldValue("vertical", "software");
- Field dirField = ((StructDataType) company.getDataType()).getField("directors");
- Array<FieldValue> dirFieldVal = new Array<FieldValue>(dirField.getDataType());
- AnnotationReferenceDataType annRefType = (AnnotationReferenceDataType) ((ArrayDataType) dirField.getDataType()).getNestedType();
- dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation1));
- dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation2));
- companyValue.setFieldValue(dirField, dirFieldVal);
+ Field dirField = ((StructDataType) company.getDataType()).getField("directors");
+ Array<FieldValue> dirFieldVal = new Array<FieldValue>(dirField.getDataType());
+ AnnotationReferenceDataType annRefType = (AnnotationReferenceDataType) ((ArrayDataType) dirField.getDataType()).getNestedType();
+ dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation1));
+ dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation2));
+ companyValue.setFieldValue(dirField, dirFieldVal);
tree.clearAnnotations(span3);
StringFieldValue body = (StringFieldValue) document.getFieldValue(document.getDataType().getField("body"));
- body.setSpanTree(tree);
- document.setFieldValue(document.getDataType().getField("body"), body);
- }
+ body.setSpanTree(tree);
+ document.setFieldValue(document.getDataType().getField("body"), body);
+ }
}
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java
index ae730ed8cb3..b98c916862c 100644
--- a/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java
@@ -40,35 +40,35 @@ public class Bug4261985TestCase {
public void annotate(Document document, DocumentTypeManager manager) {
AnnotationTypeRegistry registry = manager.getAnnotationTypeRegistry();
- AnnotationType company = registry.getType("company");
- AnnotationType industry = registry.getType("industry");
- AnnotationType person = registry.getType("person");
- AnnotationType location = registry.getType("location");
- AnnotationType bigshots = registry.getType("bigshots");
-
- if (company.inherits(industry)) {
- System.out.println("Company Inherits Industry");
- } else {
- System.out.println("FAIL: COMPANY DOES NOT INHERIT INDUSTRY");
+ AnnotationType company = registry.getType("company");
+ AnnotationType industry = registry.getType("industry");
+ AnnotationType person = registry.getType("person");
+ AnnotationType location = registry.getType("location");
+ AnnotationType bigshots = registry.getType("bigshots");
+
+ if (company.inherits(industry)) {
+ System.out.println("Company Inherits Industry");
+ } else {
+ System.out.println("FAIL: COMPANY DOES NOT INHERIT INDUSTRY");
throw new RuntimeException("FAIL: COMPANY DOES NOT INHERIT INDUSTRY, though it does in SD file");
- }
+ }
- SpanTree tree = new SpanTree("testannotations");
+ SpanTree tree = new SpanTree("testannotations");
SpanList root = (SpanList) tree.getRoot();
- SpanNode span1 = new Span(0,5);
- SpanNode span2 = new Span(5,10);
- SpanNode span3 = new Span(10,15);
- SpanNode span4 = new Span(15,20);
- SpanNode span5 = new Span(6,10);
- SpanNode span6 = new Span(8,4);
+ SpanNode span1 = new Span(0,5);
+ SpanNode span2 = new Span(5,10);
+ SpanNode span3 = new Span(10,15);
+ SpanNode span4 = new Span(15,20);
+ SpanNode span5 = new Span(6,10);
+ SpanNode span6 = new Span(8,4);
SpanNode span7 = new Span(4, 2);
SpanNode span8 = new Span(12, 6);
- root.add(span1);
- root.add(span2);
- //root.add(span3);
- root.add(span4);
+ root.add(span1);
+ root.add(span2);
+ //root.add(span3);
+ root.add(span4);
root.add(span5);
root.add(span6);
//root.add(span7);
@@ -82,74 +82,74 @@ public class Bug4261985TestCase {
root.add(aspl);
- Struct personValue = (Struct) person.getDataType().createFieldValue();
- personValue.setFieldValue("name", "Richard Bair");
- Annotation personAn = new Annotation(person, personValue);
- tree.annotate(span1, personAn);
+ Struct personValue = (Struct) person.getDataType().createFieldValue();
+ personValue.setFieldValue("name", "Richard Bair");
+ Annotation personAn = new Annotation(person, personValue);
+ tree.annotate(span1, personAn);
- Struct companyValue = (Struct) company.getDataType().createFieldValue();
- companyValue.setFieldValue("name", "Sun");
+ Struct companyValue = (Struct) company.getDataType().createFieldValue();
+ companyValue.setFieldValue("name", "Sun");
Struct locationVal = new Struct(manager.getDataType("annotation.location"));
- locationVal.setFieldValue("lat", 37.774929);
- locationVal.setFieldValue("lon", -122.419415);
+ locationVal.setFieldValue("lat", 37.774929);
+ locationVal.setFieldValue("lon", -122.419415);
Annotation locAnnotation = new Annotation(location, locationVal);
Field compLocField = ((StructDataType) company.getDataType()).getField("place");
- //FieldValue compLocFieldVal = new FieldValue(compLocField.getDataType());
+ //FieldValue compLocFieldVal = new FieldValue(compLocField.getDataType());
AnnotationReferenceDataType annType = (AnnotationReferenceDataType) compLocField.getDataType();
FieldValue compLocFieldVal = null;
//if (scenario.equals("createFieldValue")) {
- // compLocFieldVal = annType.createFieldValue(new AnnotationReference(annType, locAnnotation));
+ // compLocFieldVal = annType.createFieldValue(new AnnotationReference(annType, locAnnotation));
//} else {
- compLocFieldVal = new AnnotationReference(annType, locAnnotation);
+ compLocFieldVal = new AnnotationReference(annType, locAnnotation);
//}
- companyValue.setFieldValue(compLocField, compLocFieldVal);
-
- companyValue.setFieldValue("vertical", "software");
- Struct dirValue1 = new Struct(manager.getDataType("annotation.person"));
- dirValue1.setFieldValue("name", "Jonathan Schwartz");
- Annotation dirAnnotation1 = new Annotation(person, dirValue1);
- Struct dirValue2 = new Struct(manager.getDataType("annotation.person"));
- dirValue2.setFieldValue("name", "Scott Mcnealy");
- Annotation dirAnnotation2 = new Annotation(person, dirValue2);
- Field dirField = ((StructDataType) company.getDataType()).getField("directors");
- Array<FieldValue> dirFieldVal = new Array<FieldValue>(dirField.getDataType());
- AnnotationReferenceDataType annRefType = (AnnotationReferenceDataType) ((ArrayDataType) dirField.getDataType()).getNestedType();
- dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation1));
- dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation2));
- companyValue.setFieldValue(dirField, dirFieldVal);
- Annotation compAn = new Annotation(company, companyValue);
- tree.annotate(span2, compAn);
-
- Struct bigshotsValue = (Struct) bigshots.getDataType().createFieldValue();
- Field ceosField = ((StructDataType) bigshots.getDataType()).getField("ceos");
- //FieldValue compLocFieldVal = new FieldValue(compLocField.getDataType());
+ companyValue.setFieldValue(compLocField, compLocFieldVal);
+
+ companyValue.setFieldValue("vertical", "software");
+ Struct dirValue1 = new Struct(manager.getDataType("annotation.person"));
+ dirValue1.setFieldValue("name", "Jonathan Schwartz");
+ Annotation dirAnnotation1 = new Annotation(person, dirValue1);
+ Struct dirValue2 = new Struct(manager.getDataType("annotation.person"));
+ dirValue2.setFieldValue("name", "Scott Mcnealy");
+ Annotation dirAnnotation2 = new Annotation(person, dirValue2);
+ Field dirField = ((StructDataType) company.getDataType()).getField("directors");
+ Array<FieldValue> dirFieldVal = new Array<FieldValue>(dirField.getDataType());
+ AnnotationReferenceDataType annRefType = (AnnotationReferenceDataType) ((ArrayDataType) dirField.getDataType()).getNestedType();
+ dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation1));
+ dirFieldVal.add(new AnnotationReference(annRefType, dirAnnotation2));
+ companyValue.setFieldValue(dirField, dirFieldVal);
+ Annotation compAn = new Annotation(company, companyValue);
+ tree.annotate(span2, compAn);
+
+ Struct bigshotsValue = (Struct) bigshots.getDataType().createFieldValue();
+ Field ceosField = ((StructDataType) bigshots.getDataType()).getField("ceos");
+ //FieldValue compLocFieldVal = new FieldValue(compLocField.getDataType());
AnnotationReferenceDataType annType1 = (AnnotationReferenceDataType) ceosField.getDataType();
FieldValue ceosFieldVal = new AnnotationReference(annType1, compAn);
- bigshotsValue.setFieldValue(ceosField, ceosFieldVal);
+ bigshotsValue.setFieldValue(ceosField, ceosFieldVal);
- Annotation bigshotsAn = new Annotation(bigshots, bigshotsValue);
- tree.annotate(span8, bigshotsAn);
+ Annotation bigshotsAn = new Annotation(bigshots, bigshotsValue);
+ tree.annotate(span8, bigshotsAn);
- Field selfField = ((StructDataType) bigshots.getDataType()).getField("self");
- AnnotationReferenceDataType annType2 = (AnnotationReferenceDataType) selfField.getDataType();
- FieldValue selfFieldVal = new AnnotationReference(annType2, bigshotsAn);
- bigshotsValue.setFieldValue(selfField, selfFieldVal);
- bigshotsAn = new Annotation(bigshots, bigshotsValue);
- tree.annotate(span8, bigshotsAn);
+ Field selfField = ((StructDataType) bigshots.getDataType()).getField("self");
+ AnnotationReferenceDataType annType2 = (AnnotationReferenceDataType) selfField.getDataType();
+ FieldValue selfFieldVal = new AnnotationReference(annType2, bigshotsAn);
+ bigshotsValue.setFieldValue(selfField, selfFieldVal);
+ bigshotsAn = new Annotation(bigshots, bigshotsValue);
+ tree.annotate(span8, bigshotsAn);
- tree.annotate(span3, locAnnotation);
+ tree.annotate(span3, locAnnotation);
tree.annotate(span5, dirAnnotation1);
tree.annotate(span6, dirAnnotation2);
- Struct indValue = new Struct(manager.getDataType("annotation.industry"));
- indValue.setFieldValue("vertical", "Manufacturing");
- Annotation indAn = new Annotation(industry, indValue);
- tree.annotate(span4, indAn);
+ Struct indValue = new Struct(manager.getDataType("annotation.industry"));
+ indValue.setFieldValue("vertical", "Manufacturing");
+ Annotation indAn = new Annotation(industry, indValue);
+ tree.annotate(span4, indAn);
StringFieldValue body = (StringFieldValue) document.getFieldValue(document.getDataType().getField("body"));
- body.setSpanTree(tree);
- document.setFieldValue(document.getDataType().getField("body"), body);
- }
+ body.setSpanTree(tree);
+ document.setFieldValue(document.getDataType().getField("body"), body);
+ }
}
diff --git a/document/src/test/java/com/yahoo/document/annotation/SpanListAdvTestCase.java b/document/src/test/java/com/yahoo/document/annotation/SpanListAdvTestCase.java
index 4ec8806a360..2301c82f6e7 100644
--- a/document/src/test/java/com/yahoo/document/annotation/SpanListAdvTestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/SpanListAdvTestCase.java
@@ -201,8 +201,8 @@ public class SpanListAdvTestCase {
if (debug) System.out.println("\n\nSpanList: [" + root.getFrom() + ", " + root.getTo() + "] num Children: " + root.numChildren());
if (debug) System.out.println("-------------------");
Iterator<SpanNode> childIterator = root.childIterator();
- while (childIterator.hasNext()) {
- SpanNode node = childIterator.next();
+ while (childIterator.hasNext()) {
+ SpanNode node = childIterator.next();
//System.out.println("Span Node: " + node); // + " Span Text: " + node.getText(fieldValStr));
if (debug) System.out.println("\n\nSpan Node: [" + node.getFrom() + ", " + node.getTo() + "] ");
if (node instanceof AlternateSpanList) {
@@ -215,10 +215,10 @@ public class SpanListAdvTestCase {
while (lli.hasNext()) System.out.print(" " + lli.next() + " ");
consumeAnnotations((SpanList) node);
} else {
- if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
- getAnnotationsForNode(node);
+ if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
+ getAnnotationsForNode(node);
}
- }
+ }
if (debug) System.out.println("\nGetting annotations for the SpanList itself : [" + root.getFrom() + ", " + root.getTo() + "] ");
getAnnotationsForNode(root);
}
@@ -264,19 +264,19 @@ public class SpanListAdvTestCase {
public void getAnnotationsForNode(SpanNode node) {
Iterator<Annotation> iter = tree.iterator(node);
boolean annotationPresent = false;
- while (iter.hasNext()) {
+ while (iter.hasNext()) {
annotationPresent = true;
- Annotation xx = iter.next();
- AnnotationType t = xx.getType();
- StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
- if (debug) System.out.println("Annotation: " + xx);
+ Annotation xx = iter.next();
+ AnnotationType t = xx.getType();
+ StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
+ if (debug) System.out.println("Annotation: " + xx);
if (fValue == null) {
if (debug) System.out.println("Field Value is null");
return;
} else {
if (debug) System.out.println("Field Value: " + fValue.getString());
}
- }
+ }
if (!annotationPresent) {
if (debug) System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
}
diff --git a/document/src/test/java/com/yahoo/document/annotation/SpanNodeAdvTestCase.java b/document/src/test/java/com/yahoo/document/annotation/SpanNodeAdvTestCase.java
index e55975b21d2..0e868042a1c 100644
--- a/document/src/test/java/com/yahoo/document/annotation/SpanNodeAdvTestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/SpanNodeAdvTestCase.java
@@ -99,139 +99,139 @@ public class SpanNodeAdvTestCase {
root.addChildren(1, subtreeList4, 10.0d);
}
- @Test
- public void assertIsValid() {
- populateSpanTree();
- root.clearChildren(1);
- root.remove(span3);
+ @Test
+ public void assertIsValid() {
+ populateSpanTree();
+ root.clearChildren(1);
+ root.remove(span3);
assertTrue(root.isValid());
assertTrue(span1.isValid());
assertTrue(span2.isValid());
assertFalse(span3.isValid());
- assertFalse(alternate1.isValid());
+ assertFalse(alternate1.isValid());
assertFalse(span11.isValid());
- assertFalse(branch.isValid());
- assertFalse(span22.isValid());
- assertFalse(alternate2.isValid());
- assertFalse(span33.isValid());
- assertFalse(branch1.isValid());
- assertFalse(span333.isValid());
- assertFalse(span111.isValid());
- assertFalse(span222.isValid());
- }
+ assertFalse(branch.isValid());
+ assertFalse(span22.isValid());
+ assertFalse(alternate2.isValid());
+ assertFalse(span33.isValid());
+ assertFalse(branch1.isValid());
+ assertFalse(span333.isValid());
+ assertFalse(span111.isValid());
+ assertFalse(span222.isValid());
+ }
+
+ @Test
+ public void assertIsLeafNode() {
+ populateSpanTree();
+ assertFalse(root.isLeafNode());
+ assertFalse(alternate1.isLeafNode());
+ assertFalse(branch.isLeafNode());
+ assertTrue(span11.isLeafNode());
+ assertTrue(span22.isLeafNode());
+ assertFalse(alternate2.isLeafNode());
+ assertTrue(span33.isLeafNode());
+ assertFalse(branch1.isLeafNode());
+ assertTrue(span111.isLeafNode());
+ assertTrue(span222.isLeafNode());
+ assertTrue(span333.isLeafNode());
+ }
+
+ @Test
+ public void assertOverlaps() {
+ populateSpanTree();
+ assertTrue(span1.overlaps(span2));
+ assertTrue(span1.overlaps(span3));
+ assertTrue(span2.overlaps(span3));
+ assertFalse(span11.overlaps(span22));
+ assertTrue(span22.overlaps(span33));
+ assertFalse(span11.overlaps(span33));
+ assertTrue(span111.overlaps(span222));
+ assertFalse(span111.overlaps(span333));
+ assertFalse(span222.overlaps(span333));
+ assertTrue(span1.overlaps(span222));
+ assertFalse(span1.overlaps(span333));
+ assertTrue(span2.overlaps(span222));
+ assertFalse(span3.overlaps(span22));
+
+ assertTrue(span2.overlaps(span1));
+ assertTrue(span3.overlaps(span1));
+ assertTrue(span3.overlaps(span2));
+ assertFalse(span22.overlaps(span11));
+ assertTrue(span33.overlaps(span22));
+ assertFalse(span33.overlaps(span11));
+ assertTrue(span222.overlaps(span111));
+ assertFalse(span333.overlaps(span111));
+ assertFalse(span333.overlaps(span222));
+ assertTrue(span222.overlaps(span1));
+ assertFalse(span333.overlaps(span1));
+ assertTrue(span222.overlaps(span2));
+ assertTrue(span1.overlaps(span1));
+ assertFalse(span22.overlaps(span3));
+ assertFalse(root.overlaps(alternate1));
+ assertTrue(alternate2.overlaps(span22));
+ assertTrue(branch.overlaps(root));
+ assertTrue(branch.overlaps(alternate2));
+ assertTrue(root.overlaps(alternate2));
+ assertTrue(span22.overlaps(root));
+
+ }
@Test
- public void assertIsLeafNode() {
- populateSpanTree();
- assertFalse(root.isLeafNode());
- assertFalse(alternate1.isLeafNode());
- assertFalse(branch.isLeafNode());
- assertTrue(span11.isLeafNode());
- assertTrue(span22.isLeafNode());
- assertFalse(alternate2.isLeafNode());
- assertTrue(span33.isLeafNode());
- assertFalse(branch1.isLeafNode());
- assertTrue(span111.isLeafNode());
- assertTrue(span222.isLeafNode());
- assertTrue(span333.isLeafNode());
- }
-
- @Test
- public void assertOverlaps() {
- populateSpanTree();
- assertTrue(span1.overlaps(span2));
- assertTrue(span1.overlaps(span3));
- assertTrue(span2.overlaps(span3));
- assertFalse(span11.overlaps(span22));
- assertTrue(span22.overlaps(span33));
- assertFalse(span11.overlaps(span33));
- assertTrue(span111.overlaps(span222));
- assertFalse(span111.overlaps(span333));
- assertFalse(span222.overlaps(span333));
- assertTrue(span1.overlaps(span222));
- assertFalse(span1.overlaps(span333));
- assertTrue(span2.overlaps(span222));
- assertFalse(span3.overlaps(span22));
-
- assertTrue(span2.overlaps(span1));
- assertTrue(span3.overlaps(span1));
- assertTrue(span3.overlaps(span2));
- assertFalse(span22.overlaps(span11));
- assertTrue(span33.overlaps(span22));
- assertFalse(span33.overlaps(span11));
- assertTrue(span222.overlaps(span111));
- assertFalse(span333.overlaps(span111));
- assertFalse(span333.overlaps(span222));
- assertTrue(span222.overlaps(span1));
- assertFalse(span333.overlaps(span1));
- assertTrue(span222.overlaps(span2));
- assertTrue(span1.overlaps(span1));
- assertFalse(span22.overlaps(span3));
- assertFalse(root.overlaps(alternate1));
- assertTrue(alternate2.overlaps(span22));
- assertTrue(branch.overlaps(root));
- assertTrue(branch.overlaps(alternate2));
- assertTrue(root.overlaps(alternate2));
- assertTrue(span22.overlaps(root));
-
- }
-
- @Test
- public void assertContains() {
- populateSpanTree();
- assertTrue(span222.contains(span1));
- assertFalse(span1.contains(span222));
- assertTrue(span1.contains(span3));
- assertFalse(span33.contains(span111));
- assertTrue(span222.contains(span3));
- assertTrue(span111.contains(span2));
- assertTrue(span2.contains(span111));
- assertTrue(branch.contains(root));
- assertTrue(branch.contains(alternate2));
- assertTrue(root.contains(alternate2));
- assertFalse(alternate2.contains(span22));
- }
+ public void assertContains() {
+ populateSpanTree();
+ assertTrue(span222.contains(span1));
+ assertFalse(span1.contains(span222));
+ assertTrue(span1.contains(span3));
+ assertFalse(span33.contains(span111));
+ assertTrue(span222.contains(span3));
+ assertTrue(span111.contains(span2));
+ assertTrue(span2.contains(span111));
+ assertTrue(branch.contains(root));
+ assertTrue(branch.contains(alternate2));
+ assertTrue(root.contains(alternate2));
+ assertFalse(alternate2.contains(span22));
+ }
@Test
- public void assertCompareTo() {
- populateSpanTree();
- assertEquals(1 , span1.compareTo(span2));
- assertEquals(-1, span2.compareTo(span1));
- assertEquals(-1 , span2.compareTo(span3));
- assertEquals(1, span3.compareTo(span2));
- assertEquals(0, span2.compareTo(span111));
- assertEquals(1, root.compareTo(branch));
- assertEquals(-1, alternate1.compareTo(root));
- assertEquals(1, branch.compareTo(span22));
- assertEquals(-1, branch.compareTo(alternate2));
- assertEquals(1, alternate2.compareTo(root));
- assertEquals(-1, span111.compareTo(root));
- assertEquals(0, span333.compareTo(branch1));
- assertEquals(0, alternate2.compareTo(span33));
- root.removeChildren();
- tree.cleanup();
- assertEquals(1, span11.compareTo(root));
- }
+ public void assertCompareTo() {
+ populateSpanTree();
+ assertEquals(1 , span1.compareTo(span2));
+ assertEquals(-1, span2.compareTo(span1));
+ assertEquals(-1 , span2.compareTo(span3));
+ assertEquals(1, span3.compareTo(span2));
+ assertEquals(0, span2.compareTo(span111));
+ assertEquals(1, root.compareTo(branch));
+ assertEquals(-1, alternate1.compareTo(root));
+ assertEquals(1, branch.compareTo(span22));
+ assertEquals(-1, branch.compareTo(alternate2));
+ assertEquals(1, alternate2.compareTo(root));
+ assertEquals(-1, span111.compareTo(root));
+ assertEquals(0, span333.compareTo(branch1));
+ assertEquals(0, alternate2.compareTo(span33));
+ root.removeChildren();
+ tree.cleanup();
+ assertEquals(1, span11.compareTo(root));
+ }
@Test
- public void assertGetParent() {
- populateSpanTree();
- assertEquals(root, span1.getParent());
- assertEquals(root, span2.getParent());
+ public void assertGetParent() {
+ populateSpanTree();
+ assertEquals(root, span1.getParent());
+ assertEquals(root, span2.getParent());
assertEquals(root, span3.getParent());
- assertEquals(root, alternate1.getParent());
- assertEquals(alternate1, span11.getParent());
- assertEquals(alternate1, branch.getParent());
- assertEquals(branch, span22.getParent());
- assertEquals(branch, alternate2.getParent());
- assertEquals(alternate2, span33.getParent());
- assertEquals(alternate2, span111.getParent());
- assertEquals(branch1, span333.getParent());
- assertEquals(alternate2, branch1.getParent());
- assertEquals(alternate1, span11.getParent());
- }
+ assertEquals(root, alternate1.getParent());
+ assertEquals(alternate1, span11.getParent());
+ assertEquals(alternate1, branch.getParent());
+ assertEquals(branch, span22.getParent());
+ assertEquals(branch, alternate2.getParent());
+ assertEquals(alternate2, span33.getParent());
+ assertEquals(alternate2, span111.getParent());
+ assertEquals(branch1, span333.getParent());
+ assertEquals(alternate2, branch1.getParent());
+ assertEquals(alternate1, span11.getParent());
+ }
@After
@@ -250,8 +250,8 @@ public class SpanNodeAdvTestCase {
if (debug) System.out.println("\n\nSpanList: [" + root.getFrom() + ", " + root.getTo() + "] num Children: " + root.numChildren());
if (debug) System.out.println("-------------------");
Iterator<SpanNode> childIterator = root.childIterator();
- while (childIterator.hasNext()) {
- SpanNode node = childIterator.next();
+ while (childIterator.hasNext()) {
+ SpanNode node = childIterator.next();
//System.out.println("Span Node: " + node); // + " Span Text: " + node.getText(fieldValStr));
if (debug) System.out.println("\n\nSpan Node: [" + node.getFrom() + ", " + node.getTo() + "] ");
if (node instanceof AlternateSpanList) {
@@ -264,10 +264,10 @@ public class SpanNodeAdvTestCase {
while (lli.hasNext()) System.out.print(" " + lli.next() + " ");
consumeAnnotations((SpanList) node);
} else {
- if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
- getAnnotationsForNode(node);
+ if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
+ getAnnotationsForNode(node);
}
- }
+ }
if (debug) System.out.println("\nGetting annotations for the SpanList itself : [" + root.getFrom() + ", " + root.getTo() + "] ");
getAnnotationsForNode(root);
}
@@ -313,19 +313,19 @@ public class SpanNodeAdvTestCase {
public void getAnnotationsForNode(SpanNode node) {
Iterator<Annotation> iter = tree.iterator(node);
boolean annotationPresent = false;
- while (iter.hasNext()) {
+ while (iter.hasNext()) {
annotationPresent = true;
- Annotation xx = iter.next();
- AnnotationType t = xx.getType();
- StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
- if (debug) System.out.println("Annotation: " + xx);
+ Annotation xx = iter.next();
+ AnnotationType t = xx.getType();
+ StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
+ if (debug) System.out.println("Annotation: " + xx);
if (fValue == null) {
if (debug) System.out.println("Field Value is null");
return;
} else {
if (debug) System.out.println("Field Value: " + fValue.getString());
}
- }
+ }
if (!annotationPresent) {
if (debug) System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
}
diff --git a/document/src/test/java/com/yahoo/document/annotation/SpanNodeTestCase.java b/document/src/test/java/com/yahoo/document/annotation/SpanNodeTestCase.java
index 6dfed026a6d..bcb25aeb5fb 100644
--- a/document/src/test/java/com/yahoo/document/annotation/SpanNodeTestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/SpanNodeTestCase.java
@@ -237,7 +237,7 @@ public class SpanNodeTestCase {
public void testOrder() {
{
String text = "08/20/1999";
- //012345678901
+ //012345678901
Span d = new Span(3, 2);
Span m = new Span(0, 2);
Span y = new Span(6, 4);
@@ -380,7 +380,7 @@ public class SpanNodeTestCase {
AnnotationType phraseType = new AnnotationType("phrase");
String text = "There is no bizniz like showbizniz";
- //0123456789012345678901234567890123456789
+ //0123456789012345678901234567890123456789
SpanList sentence = new SpanList();
SpanTree tree = new SpanTree("sentence", sentence);
@@ -501,76 +501,76 @@ public class SpanNodeTestCase {
Iterator<Annotation> annotations = annotationList.iterator();
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("There", annotation.getSpanNode().getText(text));
- assertEquals(word, annotation.getType()); //there: word
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("There", annotation.getSpanNode().getText(text));
+ assertEquals(word, annotation.getType()); //there: word
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("Thereisnobiznizlikeshowbizniz", annotation.getSpanNode().getText(text).toString());
- assertEquals(sentenceType, annotation.getType()); //sentence
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("Thereisnobiznizlikeshowbizniz", annotation.getSpanNode().getText(text).toString());
+ assertEquals(sentenceType, annotation.getType()); //sentence
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("is", annotation.getSpanNode().getText(text));
- assertEquals(word, annotation.getType()); //is: word
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("is", annotation.getSpanNode().getText(text));
+ assertEquals(word, annotation.getType()); //is: word
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("is", annotation.getSpanNode().getText(text));
- assertEquals(verb, annotation.getType()); //is: verb
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("is", annotation.getSpanNode().getText(text));
+ assertEquals(verb, annotation.getType()); //is: verb
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("no", annotation.getSpanNode().getText(text));
- assertEquals(word, annotation.getType()); //no: word
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("no", annotation.getSpanNode().getText(text));
+ assertEquals(word, annotation.getType()); //no: word
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("nobiznizlikeshowbizniz", annotation.getSpanNode().getText(text).toString());
- assertEquals(phraseType, annotation.getType()); //no bizniz like showbizniz: phrase
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("nobiznizlikeshowbizniz", annotation.getSpanNode().getText(text).toString());
+ assertEquals(phraseType, annotation.getType()); //no bizniz like showbizniz: phrase
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("bizniz", annotation.getSpanNode().getText(text));
- assertEquals(word, annotation.getType()); //bizniz: word
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("bizniz", annotation.getSpanNode().getText(text));
+ assertEquals(word, annotation.getType()); //bizniz: word
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("bizniz", annotation.getSpanNode().getText(text));
- assertEquals(noun, annotation.getType()); //bizniz: noun
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("bizniz", annotation.getSpanNode().getText(text));
+ assertEquals(noun, annotation.getType()); //bizniz: noun
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("like", annotation.getSpanNode().getText(text));
- assertEquals(word, annotation.getType()); //like: word
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("like", annotation.getSpanNode().getText(text));
+ assertEquals(word, annotation.getType()); //like: word
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("likeshowbizniz", annotation.getSpanNode().getText(text).toString());
- assertEquals(phraseType, annotation.getType()); //like showbizniz: phrase
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("likeshowbizniz", annotation.getSpanNode().getText(text).toString());
+ assertEquals(phraseType, annotation.getType()); //like showbizniz: phrase
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("showbizniz", annotation.getSpanNode().getText(text));
- assertEquals(word, annotation.getType()); //showbizniz: word
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("showbizniz", annotation.getSpanNode().getText(text));
+ assertEquals(word, annotation.getType()); //showbizniz: word
}
{
- assertTrue(annotations.hasNext());
- Annotation annotation = annotations.next();
- assertEquals("showbizniz", annotation.getSpanNode().getText(text));
- assertEquals(noun, annotation.getType()); //showbizniz: noun
+ assertTrue(annotations.hasNext());
+ Annotation annotation = annotations.next();
+ assertEquals("showbizniz", annotation.getSpanNode().getText(text));
+ assertEquals(noun, annotation.getType()); //showbizniz: noun
}
assertFalse(annotations.hasNext());
@@ -586,37 +586,37 @@ public class SpanNodeTestCase {
}
@Test
- public void testMultilevelRecursion() {
- // 01234567890123
- String text = "Hello!Goodbye!";
+ public void testMultilevelRecursion() {
+ // 01234567890123
+ String text = "Hello!Goodbye!";
AnnotationType block = new AnnotationType("block");
- SpanList root = new SpanList();
+ SpanList root = new SpanList();
SpanTree tree = new SpanTree("root", root);
- SpanList block1 = new SpanList();
- SpanNode hello = new Span(0,6);
+ SpanList block1 = new SpanList();
+ SpanNode hello = new Span(0,6);
tree.annotate(hello, block);
- block1.add(hello);
+ block1.add(hello);
- SpanList block2 = new SpanList();
- SpanNode goodbye = new Span(6,8);
+ SpanList block2 = new SpanList();
+ SpanNode goodbye = new Span(6,8);
tree.annotate(goodbye, block);
- block2.add(goodbye);
-
- root.add(block1).add(block2);
-
- Iterator<SpanNode> nodeIterator = root.childIteratorRecursive();
- assertTrue(nodeIterator.hasNext());
- assertTrue(nodeIterator.next().equals(hello));
- assertTrue(nodeIterator.hasNext());
- assertTrue(nodeIterator.next().equals(block1));
- assertTrue(nodeIterator.hasNext());
- assertTrue(nodeIterator.next().equals(goodbye));
- assertTrue(nodeIterator.hasNext());
- assertTrue(nodeIterator.next().equals(block2));
- assertFalse(nodeIterator.hasNext());
- assertTrue(root.getText(text).toString().equals(text));
- }
+ block2.add(goodbye);
+
+ root.add(block1).add(block2);
+
+ Iterator<SpanNode> nodeIterator = root.childIteratorRecursive();
+ assertTrue(nodeIterator.hasNext());
+ assertTrue(nodeIterator.next().equals(hello));
+ assertTrue(nodeIterator.hasNext());
+ assertTrue(nodeIterator.next().equals(block1));
+ assertTrue(nodeIterator.hasNext());
+ assertTrue(nodeIterator.next().equals(goodbye));
+ assertTrue(nodeIterator.hasNext());
+ assertTrue(nodeIterator.next().equals(block2));
+ assertFalse(nodeIterator.hasNext());
+ assertTrue(root.getText(text).toString().equals(text));
+ }
@Test
public void testRecursiveIteratorDeterministicBehavior() {
diff --git a/document/src/test/java/com/yahoo/document/annotation/SpanTreeAdvTest.java b/document/src/test/java/com/yahoo/document/annotation/SpanTreeAdvTest.java
index 1347759c144..931f2a2fac7 100644
--- a/document/src/test/java/com/yahoo/document/annotation/SpanTreeAdvTest.java
+++ b/document/src/test/java/com/yahoo/document/annotation/SpanTreeAdvTest.java
@@ -238,8 +238,8 @@ public class SpanTreeAdvTest {
if (debug) System.out.println("\n\nSpanList: [" + root.getFrom() + ", " + root.getTo() + "] num Children: " + root.numChildren());
if (debug) System.out.println("-------------------");
Iterator<SpanNode> childIterator = root.childIterator();
- while (childIterator.hasNext()) {
- SpanNode node = childIterator.next();
+ while (childIterator.hasNext()) {
+ SpanNode node = childIterator.next();
//System.out.println("Span Node: " + node); // + " Span Text: " + node.getText(fieldValStr));
if (debug) System.out.println("\n\nSpan Node: [" + node.getFrom() + ", " + node.getTo() + "] ");
if (node instanceof AlternateSpanList) {
@@ -252,10 +252,10 @@ public class SpanTreeAdvTest {
while (lli.hasNext()) System.out.print(" " + lli.next() + " ");
consumeAnnotations((SpanList) node);
} else {
- if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
- getAnnotationsForNode(node);
+ if (debug) System.out.println("\nGetting annotations for this span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
+ getAnnotationsForNode(node);
}
- }
+ }
if (debug) System.out.println("\nGetting annotations for the SpanList itself : [" + root.getFrom() + ", " + root.getTo() + "] ");
getAnnotationsForNode(root);
}
@@ -301,19 +301,19 @@ public class SpanTreeAdvTest {
public void getAnnotationsForNode(SpanNode node) {
Iterator<Annotation> iter = tree.iterator(node);
boolean annotationPresent = false;
- while (iter.hasNext()) {
+ while (iter.hasNext()) {
annotationPresent = true;
- Annotation xx = iter.next();
- AnnotationType t = xx.getType();
- StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
- if (debug) System.out.println("Annotation: " + xx);
+ Annotation xx = iter.next();
+ AnnotationType t = xx.getType();
+ StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
+ if (debug) System.out.println("Annotation: " + xx);
if (fValue == null) {
if (debug) System.out.println("Field Value is null");
return;
} else {
if (debug) System.out.println("Field Value: " + fValue.getString());
}
- }
+ }
if (!annotationPresent) {
if (debug) System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
}