You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/08/31 15:12:55 UTC
svn commit: r1806811 - in /uima/uv3/uimaj-v3/trunk/uimaj-json/src:
main/java/org/apache/uima/json/ test/java/org/apache/uima/json/
test/resources/CasSerialization/expected/json/
Author: schor
Date: Thu Aug 31 15:12:55 2017
New Revision: 1806811
URL: http://svn.apache.org/viewvc?rev=1806811&view=rev
Log:
[UIMA-5532] fixes for JSON serialization, including dynamic multi-refs
Modified:
uima/uv3/uimaj-v3/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java
uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/java/org/apache/uima/json/JsonCasSerializerTest.java
uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt (contents, props changed)
uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-l.txt (props changed)
uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt (contents, props changed)
uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a3-not-a.txt
uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt (contents, props changed)
Modified: uima/uv3/uimaj-v3/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java?rev=1806811&r1=1806810&r2=1806811&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java Thu Aug 31 15:12:55 2017
@@ -936,7 +936,7 @@ public class JsonCasSerializer {
// if we're not going to write the actual FS here,
// and are just going to write the ref,
// skip the start object
- if (cds.multiRefFSs == null || !cds.multiRefFSs.contains(fs)) {
+ if (!cds.isDynamicMultiRef || !cds.multiRefFSs.contains(fs)) {
jch.writeNlJustBeforeNext();
jg.writeStartObject(); // start of feat : value
}
@@ -1101,7 +1101,7 @@ public class JsonCasSerializer {
* @throws IOException
*/
private void writeFsOrRef(TOP fs) throws IOException {
- if (fs == null || null == cds.multiRefFSs || cds.multiRefFSs.contains(fs)) {
+ if (fs == null || !cds.isDynamicMultiRef || cds.multiRefFSs.contains(fs)) {
jg.writeNumber(cds.getXmiIdAsInt(fs));
} else {
isEmbeddedFromFsFeature = false;
@@ -1125,7 +1125,7 @@ public class JsonCasSerializer {
}
private void writeFsOrRef(TOP fs, FeatureImpl fi) throws IOException {
- if (fs == null || null == cds.multiRefFSs || cds.multiRefFSs.contains(fs)) {
+ if (fs == null || !cds.isDynamicMultiRef || cds.multiRefFSs.contains(fs)) {
jg.writeFieldName(getShortFeatureName(fi));
jg.writeNumber(cds.getXmiIdAsInt(fs));
} else {
@@ -1420,13 +1420,13 @@ public class JsonCasSerializer {
}
private boolean isDynamicOrStaticMultiRef(FeatureImpl fi, TOP fs) {
- return (cds.multiRefFSs == null) ?
+ return (!cds.isDynamicMultiRef) ?
cds.isStaticMultiRef(fi) :
cds.multiRefFSs.contains(fs);
}
private boolean isDynamicOrStaticMultiRef(FeatureImpl fi, TOP fs, boolean isListAsFSs) {
- return (cds.multiRefFSs == null) ?
+ return (!cds.isDynamicMultiRef) ?
(isListAsFSs || cds.isStaticMultiRef(fi)) :
cds.multiRefFSs.contains(fs);
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/java/org/apache/uima/json/JsonCasSerializerTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/java/org/apache/uima/json/JsonCasSerializerTest.java?rev=1806811&r1=1806810&r2=1806811&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/java/org/apache/uima/json/JsonCasSerializerTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/java/org/apache/uima/json/JsonCasSerializerTest.java Thu Aug 31 15:12:55 2017
@@ -345,6 +345,11 @@ public class JsonCasSerializerTest exten
}
public void arrayOrListRefstst(boolean tstArray) throws Exception {
+
+ // using dynamic embedding
+ // an element is multiply-referenced if it is both in the index (referenced by the "view") and is referenced
+ // by an FSRef in a feature or a slot in an FSArray
+
jcas.reset();
// make root FS that is indexed and has a ref
@@ -374,16 +379,18 @@ public class JsonCasSerializerTest exten
l2.setHead(refa3);;
if (tstArray) {
- root.setAArrayFS(a);
+ root.setAArrayFS(a); // is not (yet) multiply referenced
} else {
root.setAListFs(l0);
}
String sfx = (tstArray) ? "a" : "l";
// all embeddable:
+ // because ref1,2,3 are not index, and FSArray isn't either
serializeAndCompare("array-all-embeddable-" + sfx + ".txt");
// 1 not embeddable, at all 3 positions
refa1.addToIndexes();
+ // ref1 is multiply indexed
serializeAndCompare("array-a1-not-" + sfx + ".txt");
refa1.removeFromIndexes();
refa2.addToIndexes();
Modified: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt?rev=1806811&r1=1806810&r2=1806811&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt Thu Aug 31 15:12:55 2017
@@ -2,9 +2,9 @@
"_views" : {
"_InitialView" : {
"RefTypes" : [
- {"sofa" : 2, "aArrayFS" : [3, 4, 5 ] }, 3 ] } },
+ {"sofa" : 2, "aArrayFS" : [3,
+ {"_type" : "RefTypes", "sofa" : 2 },
+ {"_type" : "RefTypes", "sofa" : 2 } ] }, 3 ] } },
"_referenced_fss" : {
"2" : {"_type" : "Sofa", "sofaNum" : 1, "sofaID" : "_InitialView" },
- "3" : {"_type" : "RefTypes", "sofa" : 2 },
- "4" : {"_type" : "RefTypes", "sofa" : 2 },
- "5" : {"_type" : "RefTypes", "sofa" : 2 } } }
\ No newline at end of file
+ "3" : {"_type" : "RefTypes", "sofa" : 2 } } }
\ No newline at end of file
Propchange: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 31 15:12:55 2017
@@ -0,0 +1,4 @@
+/uima/uimaj/branches/2.6.0-json/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt:1616936-1617592
+/uima/uimaj/branches/depend-on-july-9-build-tools/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt:963167-964468
+/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt:1436573-1462257
+/uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-a.txt:1690273-1805699
Propchange: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-l.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 31 15:12:55 2017
@@ -0,0 +1,4 @@
+/uima/uimaj/branches/2.6.0-json/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-l.txt:1616936-1617592
+/uima/uimaj/branches/depend-on-july-9-build-tools/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-l.txt:963167-964468
+/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-l.txt:1436573-1462257
+/uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a1-not-l.txt:1690273-1805699
Modified: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt?rev=1806811&r1=1806810&r2=1806811&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt Thu Aug 31 15:12:55 2017
@@ -2,9 +2,9 @@
"_views" : {
"_InitialView" : {
"RefTypes" : [
- {"sofa" : 2, "aArrayFS" : [3, 4, 5 ] }, 4 ] } },
+ {"sofa" : 2, "aArrayFS" : [
+ {"_type" : "RefTypes", "sofa" : 2 }, 4,
+ {"_type" : "RefTypes", "sofa" : 2 } ] }, 4 ] } },
"_referenced_fss" : {
"2" : {"_type" : "Sofa", "sofaNum" : 1, "sofaID" : "_InitialView" },
- "3" : {"_type" : "RefTypes", "sofa" : 2 },
- "4" : {"_type" : "RefTypes", "sofa" : 2 },
- "5" : {"_type" : "RefTypes", "sofa" : 2 } } }
\ No newline at end of file
+ "4" : {"_type" : "RefTypes", "sofa" : 2 } } }
\ No newline at end of file
Propchange: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 31 15:12:55 2017
@@ -0,0 +1,4 @@
+/uima/uimaj/branches/2.6.0-json/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt:1616936-1617592
+/uima/uimaj/branches/depend-on-july-9-build-tools/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt:963167-964468
+/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt:1436573-1462257
+/uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a2-not-a.txt:1690273-1805699
Modified: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a3-not-a.txt
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a3-not-a.txt?rev=1806811&r1=1806810&r2=1806811&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a3-not-a.txt (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-a3-not-a.txt Thu Aug 31 15:12:55 2017
@@ -2,9 +2,9 @@
"_views" : {
"_InitialView" : {
"RefTypes" : [
- {"sofa" : 2, "aArrayFS" : [3, 4, 5 ] }, 5 ] } },
+ {"sofa" : 2, "aArrayFS" : [
+ {"_type" : "RefTypes", "sofa" : 2 },
+ {"_type" : "RefTypes", "sofa" : 2 }, 5 ] }, 5 ] } },
"_referenced_fss" : {
"2" : {"_type" : "Sofa", "sofaNum" : 1, "sofaID" : "_InitialView" },
- "3" : {"_type" : "RefTypes", "sofa" : 2 },
- "4" : {"_type" : "RefTypes", "sofa" : 2 },
"5" : {"_type" : "RefTypes", "sofa" : 2 } } }
\ No newline at end of file
Modified: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt?rev=1806811&r1=1806810&r2=1806811&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt Thu Aug 31 15:12:55 2017
@@ -2,9 +2,9 @@
"_views" : {
"_InitialView" : {
"RefTypes" : [
- {"sofa" : 2, "aArrayFS" : [3, 4, 5 ] } ] } },
+ {"sofa" : 2, "aArrayFS" : [
+ {"_type" : "RefTypes", "sofa" : 2 },
+ {"_type" : "RefTypes", "sofa" : 2 },
+ {"_type" : "RefTypes", "sofa" : 2 } ] } ] } },
"_referenced_fss" : {
- "2" : {"_type" : "Sofa", "sofaNum" : 1, "sofaID" : "_InitialView" },
- "3" : {"_type" : "RefTypes", "sofa" : 2 },
- "4" : {"_type" : "RefTypes", "sofa" : 2 },
- "5" : {"_type" : "RefTypes", "sofa" : 2 } } }
\ No newline at end of file
+ "2" : {"_type" : "Sofa", "sofaNum" : 1, "sofaID" : "_InitialView" } } }
\ No newline at end of file
Propchange: uima/uv3/uimaj-v3/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 31 15:12:55 2017
@@ -0,0 +1,4 @@
+/uima/uimaj/branches/2.6.0-json/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt:1616936-1617592
+/uima/uimaj/branches/depend-on-july-9-build-tools/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt:963167-964468
+/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt:1436573-1462257
+/uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/array-all-embeddable-a.txt:1690273-1805699