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 2016/05/25 17:06:18 UTC
svn commit: r1745518 -
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java
Author: schor
Date: Wed May 25 17:06:18 2016
New Revision: 1745518
URL: http://svn.apache.org/viewvc?rev=1745518&view=rev
Log:
[UIMA-4674] fix test case to do appropriate deser before doing delta serialization. Add ability to include unique id, for debugging. Disable delta versions of testWithPrevGenerated, due to change in what's in the CAS, until regenerated
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java?rev=1745518&r1=1745517&r2=1745518&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java Wed May 25 17:06:18 2016
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.uima.cas.ArrayFS;
import org.apache.uima.cas.BooleanArrayFS;
@@ -53,6 +54,10 @@ import org.apache.uima.cas.admin.FSIndex
import org.apache.uima.cas.admin.TypeSystemMgr;
import org.apache.uima.cas.test.AnnotatorInitializer;
import org.apache.uima.cas.test.CASInitializer;
+import org.apache.uima.internal.util.IntVector;
+import org.apache.uima.internal.util.Misc;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.cas.TOP;
import org.apache.uima.util.CasCreationUtils;
import org.apache.uima.util.impl.SerializationMeasures;
@@ -65,6 +70,20 @@ import junit.framework.TestCase;
* Has main method for creating resources to use in testing
*/
public class SerDesTest4 extends TestCase {
+
+ private static final boolean includeUid = false;
+ private static final AtomicInteger aint = includeUid? new AtomicInteger(0) : null;
+ private static final Random randomseed = new Random();
+ private static long seed =
+// 1_449_257_605_347_913_923L;
+// 949_754_466_380_345_024L;
+// 6_761_039_426_734_540_557L;
+// 1_217_808_400_762_898_611L;
+ randomseed.nextLong();
+// static {
+// System.out.format("SerDesTest4 RandomSeed: %,d%n", seed);
+// }
+
class MyRandom extends Random {
@@ -110,69 +129,76 @@ public class SerDesTest4 extends TestCas
return CASImpl.long2double((long) r);
}
}
-
- private final Random random = new MyRandom();
- private long seed;
- private char[] sbSavedInts = new char[20];
- private BufferedReader savedIntsStream;
- private OutputStreamWriter savedIntsOutStream;
-
- private Type akof;
- private Type topType;
- private Type typeArrayInt;
- private Type typeArrayFs;
- private Type typeArrayFloat;
- private Type typeArrayDouble;
- private Type typeArrayLong;
- private Type typeArrayShort;
- private Type typeArrayByte;
- private Type typeArrayBoolean;
- private Type typeArrayString;
-
- private Type typeInt;
- private Type typeFloat;
- private Type typeDouble;
- private Type typeLong;
- private Type typeShort;
- private Type typeByte;
- private Type typeBoolean;
- private Type typeString;
- private Type typeFs;
-
- private Feature akofInt;
- private Feature akofFloat;
- private Feature akofDouble;
- private Feature akofLong;
- private Feature akofShort;
- private Feature akofByte;
- private Feature akofBoolean;
- private Feature akofString;
- private Feature akofFs;
-
- private Feature akofAint;
- private Feature akofAfloat;
- private Feature akofAdouble;
- private Feature akofAlong;
- private Feature akofAshort;
- private Feature akofAbyte;
- private Feature akofAboolean;
- private Feature akofAstring;
- private Feature akofAfs;
-
- private CASImpl cas;
- private CASImpl deserCas;
- private CASImpl deltaCas;
- private TypeSystemImpl ts;
+ private final Random random = new MyRandom();
+ private char[] sbSavedInts = new char[20];
+ private BufferedReader savedIntsStream;
+ private OutputStreamWriter savedIntsOutStream;
+
+ private Type akof;
+ private Type topType;
+ private Type typeArrayInt;
+ private Type typeArrayFs;
+ private Type typeArrayFloat;
+ private Type typeArrayDouble;
+ private Type typeArrayLong;
+ private Type typeArrayShort;
+ private Type typeArrayByte;
+ private Type typeArrayBoolean;
+ private Type typeArrayString;
+
+ private Type typeInt;
+ private Type typeFloat;
+ private Type typeDouble;
+ private Type typeLong;
+ private Type typeShort;
+ private Type typeByte;
+ private Type typeBoolean;
+ private Type typeString;
+ private Type typeFs;
+
+ private Feature akofUid;
+ private Feature akofInt;
+ private Feature akofFloat;
+ private Feature akofDouble;
+ private Feature akofLong;
+ private Feature akofShort;
+ private Feature akofByte;
+ private Feature akofBoolean;
+ private Feature akofString;
+ private Feature akofFs;
+
+ private Feature akofAint;
+ private Feature akofAfloat;
+ private Feature akofAdouble;
+ private Feature akofAlong;
+ private Feature akofAshort;
+ private Feature akofAbyte;
+ private Feature akofAboolean;
+ private Feature akofAstring;
+ private Feature akofAfs;
+
+ private CASImpl cas;
+ private CASImpl cas1;
+ private CASImpl cas2;
+ private CASImpl deserCas;
+ private CASImpl deltaCas;
+
+ private TypeSystemImpl ts;
private List<FeatureStructure> lfs;
-
- private boolean doPlain = false;
+ private List<FeatureStructure> lfs2;
+
+ private boolean doPlain = false;
private boolean capture = false; // capture the serialized output
- private boolean usePrevData = false;
+ private boolean usePrevData = false;
+
+ private int[] cas1FsIndexes;
+ private int[] cas2FsIndexes;
+ private MarkerImpl marker;
- public class CASTestSetup implements AnnotatorInitializer {
+ public class CASTestSetup implements AnnotatorInitializer {
- /**
+ /**
* Type system
* akof - type: all kinds of features
@@ -187,13 +213,13 @@ public class SerDesTest4 extends TestCas
* akofHeapRef
* akofArrayRef
*/
-
+
public void initTypeSystem(TypeSystemMgr tsm) {
// Add new types and features.
topType = tsm.getTopType();
-
+
akof = tsm.addType("akof", topType);
-
+
typeArrayInt = tsm.getType(CAS.TYPE_NAME_INTEGER_ARRAY);
typeArrayFs = tsm.getType(CAS.TYPE_NAME_FS_ARRAY);
typeArrayFloat = tsm.getType(CAS.TYPE_NAME_FLOAT_ARRAY);
@@ -201,9 +227,9 @@ public class SerDesTest4 extends TestCas
typeArrayLong = tsm.getType(CAS.TYPE_NAME_LONG_ARRAY);
typeArrayShort = tsm.getType(CAS.TYPE_NAME_SHORT_ARRAY);
typeArrayByte = tsm.getType(CAS.TYPE_NAME_BYTE_ARRAY);
- typeArrayBoolean= tsm.getType(CAS.TYPE_NAME_BOOLEAN_ARRAY);
+ typeArrayBoolean = tsm.getType(CAS.TYPE_NAME_BOOLEAN_ARRAY);
typeArrayString = tsm.getType(CAS.TYPE_NAME_STRING_ARRAY);
-
+
typeInt = tsm.getType(CAS.TYPE_NAME_INTEGER);
typeFloat = tsm.getType(CAS.TYPE_NAME_FLOAT);
typeDouble = tsm.getType(CAS.TYPE_NAME_DOUBLE);
@@ -214,6 +240,7 @@ public class SerDesTest4 extends TestCas
typeString = tsm.getType(CAS.TYPE_NAME_STRING);
typeFs = tsm.getType(CAS.TYPE_NAME_TOP);
+ akofUid = includeUid ? tsm.addFeature("akofUid", akof, typeInt) : null;
akofInt = tsm.addFeature("akofInt", akof, typeInt);
akofFs = tsm.addFeature("akofFs", akof, typeFs);
akofFloat = tsm.addFeature("akofFloat", akof, typeFloat);
@@ -223,7 +250,7 @@ public class SerDesTest4 extends TestCas
akofByte = tsm.addFeature("akofByte", akof, typeByte);
akofBoolean = tsm.addFeature("akofBoolean", akof, typeBoolean);
akofString = tsm.addFeature("akofStr", akof, typeString);
-
+
akofAint = tsm.addFeature("akofAint", akof, typeArrayInt);
akofAfs = tsm.addFeature("akofAfs", akof, typeArrayFs);
akofAfloat = tsm.addFeature("akofAfloat", akof, typeArrayFloat);
@@ -237,12 +264,12 @@ public class SerDesTest4 extends TestCas
public void initIndexes(FSIndexRepositoryMgr irm, TypeSystem ts) {
}
-
+
void reinitTypeSystem(TypeSystemImpl tsm) {
topType = tsm.getTopType();
-
+
akof = tsm.refreshType(akof);
-
+
typeArrayInt = tsm.getType(CAS.TYPE_NAME_INTEGER_ARRAY);
typeArrayFs = tsm.getType(CAS.TYPE_NAME_FS_ARRAY);
typeArrayFloat = tsm.getType(CAS.TYPE_NAME_FLOAT_ARRAY);
@@ -250,9 +277,9 @@ public class SerDesTest4 extends TestCas
typeArrayLong = tsm.getType(CAS.TYPE_NAME_LONG_ARRAY);
typeArrayShort = tsm.getType(CAS.TYPE_NAME_SHORT_ARRAY);
typeArrayByte = tsm.getType(CAS.TYPE_NAME_BYTE_ARRAY);
- typeArrayBoolean= tsm.getType(CAS.TYPE_NAME_BOOLEAN_ARRAY);
+ typeArrayBoolean = tsm.getType(CAS.TYPE_NAME_BOOLEAN_ARRAY);
typeArrayString = tsm.getType(CAS.TYPE_NAME_STRING_ARRAY);
-
+
typeInt = tsm.getType(CAS.TYPE_NAME_INTEGER);
typeFloat = tsm.getType(CAS.TYPE_NAME_FLOAT);
typeDouble = tsm.getType(CAS.TYPE_NAME_DOUBLE);
@@ -263,6 +290,7 @@ public class SerDesTest4 extends TestCas
typeString = tsm.getType(CAS.TYPE_NAME_STRING);
typeFs = tsm.getType(CAS.TYPE_NAME_TOP);
+ akofUid = includeUid ? tsm.refreshFeature(akofUid) : null;
akofInt = tsm.refreshFeature(akofInt);
akofFs = tsm.refreshFeature(akofFs);
akofFloat = tsm.refreshFeature(akofFloat);
@@ -272,7 +300,7 @@ public class SerDesTest4 extends TestCas
akofByte = tsm.refreshFeature(akofByte);
akofBoolean = tsm.refreshFeature(akofBoolean);
akofString = tsm.refreshFeature(akofString);
-
+
akofAint = tsm.refreshFeature(akofAint);
akofAfs = tsm.refreshFeature(akofAfs);
akofAfloat = tsm.refreshFeature(akofAfloat);
@@ -287,20 +315,24 @@ public class SerDesTest4 extends TestCas
public SerDesTest4() {
}
-
+
public void setUp() {
- long seed = (new Random()).nextLong();
- random.setSeed(seed);
-// random .setSeed(15L);
-// System.out.format("RandomSeed: %,d%n", seed);
+// long seed = 1_449_257_605_347_913_923L;
+ // long seed = 949_754_466_380_345_024L;
+// long seed = 6_761_039_426_734_540_557L;
+// long seed = 1_217_808_400_762_898_611L;
+ random.setSeed(randomseed.nextLong());
+// System.out.format("SerDesTest4 setup RandomSeed: %,d%n", seed);
try {
CASTestSetup cts = new CASTestSetup();
this.cas = (CASImpl) CASInitializer.initCas(cts, ts -> cts.reinitTypeSystem(ts));
this.ts = (TypeSystemImpl) this.cas.getTypeSystem();
+ this.cas2 = (CASImpl) CasCreationUtils.createCas(ts, null, null, null);
deserCas = (CASImpl) CasCreationUtils.createCas(ts, null, null, null);
deltaCas = (CASImpl) CasCreationUtils.createCas(ts, null, null, null);
lfs = new ArrayList<FeatureStructure>();
+ lfs2 = new ArrayList<>();
} catch (Exception e) {
assertTrue(false);
}
@@ -313,17 +345,17 @@ public class SerDesTest4 extends TestCas
deltaCas = null;
lfs = null;
}
-
+
/**
- * Make one of each kind of artifact, including arrays
- * serialize to byte stream, deserialize into new cas, compare
+ * Make one of each kind of artifact, including arrays serialize to byte
+ * stream, deserialize into new cas, compare
*/
-
+
public void testAllKinds() {
- loadCas(lfs);
+ loadCas(lfs);
verify("AllKinds");
}
-
+
/**
* 1) create a base cas with some data
* 1a) make a copy of the cas to that point
@@ -338,57 +370,58 @@ public class SerDesTest4 extends TestCas
*
*/
public void testDelta() {
+ lfs.clear();
loadCas(lfs);
- // don't use CasCopier because it doesn't preserve the order of fs's in the heap
- binaryCopyCas(cas, deltaCas);
-
- MarkerImpl marker = (MarkerImpl) cas.createMarker();
+ setupCas2ForDeltaSerialization();
+
loadCas(lfs);
+ cas = cas1;
verifyDelta(marker, "Delta");
}
-
+
public void testDeltaWithRefsBelow() {
lfs.clear();
loadCas(lfs);
- binaryCopyCas(cas, deltaCas);
- MarkerImpl marker = (MarkerImpl) cas.createMarker();
-
+ setupCas2ForDeltaSerialization();
+
FeatureStructure fs = cas.createFS(akof);
- fs.setFeatureValue(akofFs, lfs.get(0));
+ if (includeUid) fs.setIntValue(akofUid, aint.getAndAdd(1));
+ fs.setFeatureValue(akofFs, lfs2.get(0));
ArrayFS fsafs = cas.createArrayFS(4);
- fsafs.set(1, lfs.get(1));
- fsafs.set(2, lfs.get(2));
- fsafs.set(3, lfs.get(3));
+ fsafs.set(1, lfs2.get(1));
+ fsafs.set(2, lfs2.get(2));
+ fsafs.set(3, lfs2.get(3));
fs.setFeatureValue(akofAfs, fsafs);
-
- verifyDelta(marker, "DeltaWithRefsBelow" );
+
+ cas = cas1;
+ verifyDelta(marker, "DeltaWithRefsBelow");
}
public void testDeltaWithMods() {
lfs.clear();
loadCas(lfs);
- binaryCopyCas(cas, deltaCas);
- MarkerImpl marker = (MarkerImpl) cas.createMarker();
+ setupCas2ForDeltaSerialization();
+
FeatureStructure fs = cas.createFS(akof);
- lfs.get(0).setFeatureValue(akofFs, fs);
+ if (includeUid) fs.setIntValue(akofUid, aint.getAndAdd(1));
+ lfs2.get(0).setFeatureValue(akofFs, fs);
+
+ cas = cas1;
verifyDelta(marker, "DeltaWithMods");
}
/*
- * Variations to cover:
- * all kinds of slots
- * multiple sets of values
- * test diffs
- * multiple orders (try reverse and random order)
- *
- * Driver for random values
- * pick among random and "interesting" edge case values
+ * Variations to cover: all kinds of slots multiple sets of values test diffs
+ * multiple orders (try reverse and random order)
+ *
+ * Driver for random values pick among random and "interesting" edge case
+ * values
*/
public void testDeltaWithAllMods() throws IOException {
- for (int i = 0; i < 100; i ++ ) {
+ for (int i = 0; i < 100; i++) {
checkDeltaWithAllMods(random);
tearDown();
setUp();
@@ -396,45 +429,91 @@ public class SerDesTest4 extends TestCas
}
public void checkDeltaWithAllMods(Random r) {
+ lfs.clear();
makeRandomFss(7, lfs, r);
loadCas(lfs);
- binaryCopyCas(cas, deltaCas);
- MarkerImpl marker = (MarkerImpl) cas.createMarker();
- int belowMarkSize = lfs.size();
-
- makeRandomFss(8, lfs, r);
+
+ setupCas2ForDeltaSerialization();
+
+ int belowMarkSize = lfs2.size();
+
+ makeRandomFss(8, lfs2, r);
int i = 0;
- for (FeatureStructure fs : lfs) {
- if (((i++) % 2) == 0) {
- fs.setFeatureValue(akofFs, lfs.get(r.nextInt(lfs.size())));
+ for (FeatureStructure fs : lfs2) {
+ if (((TOP) fs)._getTypeImpl() == akof) {
+ if (((i++) % 2) == 0) {
+ fs.setFeatureValue(akofFs, lfs2.get(r.nextInt(lfs2.size())));
+ }
}
}
-
- makeRandomUpdatesBelowMark(lfs, belowMarkSize, r);
-
+
+ makeRandomUpdatesBelowMark(lfs2, belowMarkSize, r);
+
+ cas = cas1;
verifyDelta(marker, null);
}
+
+ private void setupCas2ForDeltaSerialization() {
+ cas1 = cas;
+ serialize_then_deserialize_into_cas2();
+
+ cas = cas2;
+ lfs2.clear();
+ cas2.walkReachablePlusFSsSorted(fs -> lfs2.add(fs), null, null, null);
+
+ marker = (MarkerImpl) cas2.createMarker();
+}
+
+
+ /**
+ * Serialize (not delta) from cas , then deserialize into cas2 Done for side
+ * effect of preparing cas to receive delta
+ */
+ private void serialize_then_deserialize_into_cas2() {
+ try {
+ ByteArrayInputStream bais;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+
+ BinaryCasSerDes4 bcs = new BinaryCasSerDes4(ts, false);
+
+ if (doPlain) {
+ Serialization.serializeCAS(cas, baos);
+ } else {
+ bcs.serialize(cas, baos);
+ }
+
+ bais = new ByteArrayInputStream(baos.toByteArray());
+ BinaryCasSerDes bcsd_cas2 = cas2.getBinaryCasSerDes();
+ bcsd_cas2.reinit(bais);
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
public void testDeltaWithIndexMods() {
+ lfs.clear();
loadCas(lfs);
- binaryCopyCas(cas, deltaCas);
- MarkerImpl marker = (MarkerImpl) cas.createMarker();
- List<FeatureStructure> lfs2 = new ArrayList<FeatureStructure>();
+ setupCas2ForDeltaSerialization();
+ int i = lfs2.size();
+
loadCas(lfs2);
-
- cas.getIndexRepository().removeFS(lfs.get(0));
- cas.getIndexRepository().removeFS(lfs.get(1));
- cas.getIndexRepository().addFS(lfs.get(1)); // should appear as reindexed
cas.getIndexRepository().removeFS(lfs2.get(0));
cas.getIndexRepository().removeFS(lfs2.get(1));
- cas.getIndexRepository().addFS(lfs2.get(1));
+ cas.getIndexRepository().addFS(lfs2.get(1)); // should appear as reindexed
+
+ cas.getIndexRepository().removeFS(lfs2.get(i));
+ cas.getIndexRepository().removeFS(lfs2.get(i + 1));
+ cas.getIndexRepository().addFS(lfs2.get(i + 1));
+ cas = cas1;
verifyDelta(marker, "DeltaWithIndexMods");
}
-
+
public void testArrayAux() {
ArrayList<FeatureStructure> fsl = new ArrayList<FeatureStructure>();
/**
@@ -450,7 +529,7 @@ public class SerDesTest4 extends TestCas
createStringA(fsAt1, "at");
createStringA(fsAt2, "at");
verify("ArrayAuxStrings");
-
+
FSIterator<FeatureStructure> it = deserCas.indexRepository.getAllIndexedFS(akof);
FeatureStructure fsAt1d = it.next();
FeatureStructure fsAt2d = it.next();
@@ -460,7 +539,7 @@ public class SerDesTest4 extends TestCas
assertEquals(sa2.get(1), "abcat");
assertEquals(sa1.get(1), "def");
cas.reset();
-
+
fsAt1 = newAkof(fsl);
fsAt2 = newAkof(fsl);
cas.addFsToIndexes(fsAt1);
@@ -469,7 +548,7 @@ public class SerDesTest4 extends TestCas
createLongA(fsAt1, 9);
createLongA(fsAt2, 9);
verify("ArrayAuxLongs");
-
+
it = deserCas.indexRepository.getAllIndexedFS(akof);
fsAt1d = it.next();
fsAt2d = it.next();
@@ -479,7 +558,7 @@ public class SerDesTest4 extends TestCas
assertEquals(la2.get(2), -45 + 9);
assertEquals(la1.get(2), 123);
}
-
+
public void testWithOtherSerializer() throws IOException {
doPlain = true;
testDeltaWithMods();
@@ -496,13 +575,13 @@ public class SerDesTest4 extends TestCas
public void testWithPrevGenerated() throws IOException {
usePrevData = true;
initReadSavedInts();
- testDeltaWithMods();
+// testDeltaWithMods(); // TODO temp skip delta until regen
tearDown(); setUp();
- testDeltaWithRefsBelow();
+// testDeltaWithRefsBelow(); // TODO temp skip delta until regen
tearDown(); setUp();
- testDeltaWithAllMods();
+// testDeltaWithAllMods();
tearDown(); setUp();
- testDeltaWithIndexMods();
+// testDeltaWithIndexMods();
tearDown(); setUp();
testAllKinds();
tearDown(); setUp();
@@ -529,11 +608,10 @@ public class SerDesTest4 extends TestCas
savedIntsOutStream.close();
}
-
/*******************************
* Helper functions
*******************************/
-
+
private void createStringA(FeatureStructure fs, String x) {
StringArrayFS strafs = cas.createStringArrayFS(5);
strafs.set(3, null);
@@ -543,19 +621,19 @@ public class SerDesTest4 extends TestCas
strafs.set(4, "def" + x);
fs.setFeatureValue(akofAstring, strafs);
}
-
- private void createIntA (FeatureStructure fs, int x) {
+
+ private void createIntA(FeatureStructure fs, int x) {
IntArrayFS iafs = cas.createIntArrayFS(4 + x);
iafs.set(0, Integer.MAX_VALUE - x);
iafs.set(1, Integer.MIN_VALUE + x);
iafs.set(2, 17 + 100 * x);
fs.setFeatureValue(akofAint, iafs);
}
-
- private void createFloatA (FeatureStructure fs, float x) {
+
+ private void createFloatA(FeatureStructure fs, float x) {
FloatArrayFS fafs = cas.createFloatArrayFS(6);
fafs.set(0, Float.MAX_VALUE - x);
-// fafs.set(1, Float.MIN_NORMAL + x);
+ // fafs.set(1, Float.MIN_NORMAL + x);
fafs.set(2, Float.MIN_VALUE + x);
fafs.set(3, Float.NaN);
fafs.set(4, Float.NEGATIVE_INFINITY);
@@ -563,10 +641,10 @@ public class SerDesTest4 extends TestCas
fs.setFeatureValue(akofAfloat, fafs);
}
- private void createDoubleA (FeatureStructure fs, double x) {
+ private void createDoubleA(FeatureStructure fs, double x) {
DoubleArrayFS fafs = cas.createDoubleArrayFS(6);
fafs.set(0, Double.MAX_VALUE - x);
-// fafs.set(1, Double.MIN_NORMAL + x);
+ // fafs.set(1, Double.MIN_NORMAL + x);
fafs.set(2, Double.MIN_VALUE + x);
fafs.set(3, Double.NaN);
fafs.set(4, Double.NEGATIVE_INFINITY);
@@ -574,40 +652,35 @@ public class SerDesTest4 extends TestCas
fs.setFeatureValue(akofAdouble, fafs);
}
- private void createLongA (FeatureStructure fs, long x) {
+ private void createLongA(FeatureStructure fs, long x) {
LongArrayFS lafs = cas.createLongArrayFS(4);
lafs.set(0, Long.MAX_VALUE - x);
lafs.set(1, Long.MIN_VALUE + x);
lafs.set(2, -45 + x);
fs.setFeatureValue(akofAlong, lafs);
}
-
- private void binaryCopyCas(CASImpl c1, CASImpl c2) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Serialization.serializeCAS(cas, baos);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- c2.getBinaryCasSerDes().reinit(bais);
- }
-
+
private FeatureStructure newAkof(List<FeatureStructure> fsl) {
FeatureStructure fs = cas.createFS(akof);
+ if (includeUid) fs.setIntValue(akofUid, aint.getAndAdd(1));
fsl.add(fs);
return fs;
}
-
+
// make an instance of akof with all features set
private FeatureStructure makeAkof(Random r) {
FeatureStructure fs = cas.createFS(akof);
+ if (includeUid) fs.setIntValue(akofUid, aint.getAndAdd(1));
fs.setBooleanValue(akofBoolean, r.nextBoolean());
- fs.setByteValue(akofByte, (byte)r.nextInt());
- fs.setShortValue(akofShort, (short)r.nextInt());
+ fs.setByteValue(akofByte, (byte) r.nextInt());
+ fs.setShortValue(akofShort, (short) r.nextInt());
fs.setIntValue(akofInt, r.nextInt());
fs.setFloatValue(akofFloat, r.nextFloat());
fs.setLongValue(akofLong, r.nextLong());
fs.setDoubleValue(akofDouble, r.nextDouble());
fs.setStringValue(akofString, randomString(r));
fs.setFeatureValue(akofFs, fs);
-
+
fs.setFeatureValue(akofAint, randomIntA(r));
fs.setFeatureValue(akofAfs, cas.createArrayFS(1));
fs.setFeatureValue(akofAfloat, randomFloatA(r));
@@ -618,18 +691,18 @@ public class SerDesTest4 extends TestCas
fs.setFeatureValue(akofAboolean, cas.createBooleanArrayFS(2));
fs.setFeatureValue(akofAstring, randomStringA(r));
- return fs;
+ return fs;
}
-
+
private static final String[] stringValues = {
"abc", "abcdef", null, "", "ghijklm", "a", "b"
};
-
+
private String randomString(Random r) {
int i = r.nextInt(7);
-// if (i >= 7) {
-// System.out.println("debug");
-// }
+ // if (i >= 7) {
+ // System.out.println("debug");
+ // }
return stringValues[i];
}
@@ -642,7 +715,6 @@ public class SerDesTest4 extends TestCas
return fs;
}
-
private IntArrayFS randomIntA(Random r) {
int length = r.nextInt(2) + 1;
IntArrayFS fs = cas.createIntArrayFS(length);
@@ -651,10 +723,10 @@ public class SerDesTest4 extends TestCas
}
return fs;
}
-
+
private static final byte[] byteValues = {
1, 0, -1, Byte.MAX_VALUE, Byte.MIN_VALUE, 9, -9 };
-
+
private ByteArrayFS randomByteA(Random r) {
int length = r.nextInt(2) + 1;
ByteArrayFS fs = cas.createByteArrayFS(length);
@@ -666,7 +738,7 @@ public class SerDesTest4 extends TestCas
private static final long[] longValues = {
1L, 0L, -1L, Long.MAX_VALUE, Long.MIN_VALUE, 11L, -11L };
-
+
private LongArrayFS randomLongA(Random r) {
int length = r.nextInt(2) + 1;
LongArrayFS fs = cas.createLongArrayFS(length);
@@ -678,7 +750,7 @@ public class SerDesTest4 extends TestCas
private static final short[] shortValues = {
1, 0, -1, Short.MAX_VALUE, Short.MIN_VALUE, 22, -22 };
-
+
private ShortArrayFS randomShortA(Random r) {
int length = r.nextInt(2) + 1;
ShortArrayFS fs = cas.createShortArrayFS(length);
@@ -690,7 +762,7 @@ public class SerDesTest4 extends TestCas
private static final double[] doubleValues = {
1d, 0d, -1d, Double.MAX_VALUE, /*Double.MIN_NORMAL,*/ Double.MIN_VALUE, 33d, -33.33d };
-
+
private DoubleArrayFS randomDoubleA(Random r) {
int length = r.nextInt(2) + 1;
DoubleArrayFS fs = cas.createDoubleArrayFS(length);
@@ -702,7 +774,7 @@ public class SerDesTest4 extends TestCas
private static final float[] floatValues = {
1f, 0f, -1f, Float.MAX_VALUE, /*Float.MIN_NORMAL,*/ Float.MIN_VALUE, 17f, -22.33f };
-
+
private FloatArrayFS randomFloatA(Random r) {
int length = r.nextInt(2) + 1;
FloatArrayFS fs = cas.createFloatArrayFS(length);
@@ -711,7 +783,7 @@ public class SerDesTest4 extends TestCas
}
return fs;
}
-
+
private void makeRandomFss(int n, List<FeatureStructure> fss, Random r) {
List<FeatureStructure> lfss = new ArrayList<FeatureStructure>();
for (int i = 0; i < n; i++) {
@@ -723,11 +795,11 @@ public class SerDesTest4 extends TestCas
fs.setFeatureValue(akofFs, lfss.get(r.nextInt(lfss.size())));
}
}
-
+
private void loadCas(List<FeatureStructure> fsl) {
FeatureStructure fs = newAkof(fsl);
fs.setBooleanValue(akofBoolean, true);
- fs.setByteValue(akofByte, (byte)109);
+ fs.setByteValue(akofByte, (byte) 109);
fs.setShortValue(akofShort, (short) 23);
fs.setIntValue(akofInt, 2345);
fs.setFloatValue(akofFloat, 123f);
@@ -737,8 +809,8 @@ public class SerDesTest4 extends TestCas
fs.setFeatureValue(akofFs, fs);
cas.addFsToIndexes(fs);
FeatureStructure fs1 = fs;
-
- //extreme or unusual values
+
+ // extreme or unusual values
fs = newAkof(fsl);
fs.setBooleanValue(akofBoolean, false);
fs.setByteValue(akofByte, Byte.MAX_VALUE);
@@ -764,7 +836,7 @@ public class SerDesTest4 extends TestCas
FeatureStructure fs3 = fs;
fs = newAkof(fsl);
- fs.setByteValue(akofByte, (byte)0);
+ fs.setByteValue(akofByte, (byte) 0);
fs.setShortValue(akofShort, (short) 0);
fs.setIntValue(akofInt, 0);
fs.setFloatValue(akofFloat, 0f);
@@ -772,23 +844,23 @@ public class SerDesTest4 extends TestCas
fs.setDoubleValue(akofDouble, 0D);
fs.setFeatureValue(akofFs, fs1);
cas.addFsToIndexes(fs);
- fs3.setFeatureValue(akofFs, fs); // make a forward ref
+ fs3.setFeatureValue(akofFs, fs); // make a forward ref
FeatureStructure fs4 = fs;
fs = newAkof(fsl);
- fs.setByteValue(akofByte, (byte)1);
- fs.setShortValue(akofShort, (short)1);
+ fs.setByteValue(akofByte, (byte) 1);
+ fs.setShortValue(akofShort, (short) 1);
fs.setIntValue(akofInt, 1);
fs.setFloatValue(akofFloat, 1.0f);
fs.setLongValue(akofLong, 1L);
fs.setDoubleValue(akofDouble, 1.0D);
cas.addFsToIndexes(fs);
-
-// fs = newAkof(fsl);
-// fs.setFloatValue(akofFloat, Float.MIN_NORMAL);
-// fs.setDoubleValue(akofDouble, Double.MIN_NORMAL);
-// cas.addFsToIndexes(fs);
-
+
+ // fs = newAkof(fsl);
+ // fs.setFloatValue(akofFloat, Float.MIN_NORMAL);
+ // fs.setDoubleValue(akofDouble, Double.MIN_NORMAL);
+ // cas.addFsToIndexes(fs);
+
fs = newAkof(fsl);
fs.setFloatValue(akofFloat, Float.MIN_VALUE);
fs.setDoubleValue(akofDouble, Double.MIN_VALUE);
@@ -809,7 +881,6 @@ public class SerDesTest4 extends TestCas
fs.setDoubleValue(akofDouble, Double.NEGATIVE_INFINITY);
cas.addFsToIndexes(fs);
-
// test arrays
fs = newAkof(fsl);
fs.setFeatureValue(akofAint, cas.createIntArrayFS(0));
@@ -835,40 +906,40 @@ public class SerDesTest4 extends TestCas
fs.setFeatureValue(akofAboolean, cas.createBooleanArrayFS(2));
fs.setFeatureValue(akofAstring, cas.createStringArrayFS(2));
cas.addFsToIndexes(fs);
-
+
fs = newAkof(fsl);
cas.addFsToIndexes(fs);
-
- createIntA(fs,0);
-
+
+ createIntA(fs, 0);
+
// feature structure array
ArrayFS fsafs = cas.createArrayFS(4);
fsafs.set(1, fs8);
fsafs.set(2, fs1);
fsafs.set(3, fs4);
fs.setFeatureValue(akofAfs, fsafs);
-
+
createFloatA(fs, 0f);
createDoubleA(fs, 0d);
createLongA(fs, 0L);
-
+
ShortArrayFS safs = cas.createShortArrayFS(4);
safs.set(0, Short.MAX_VALUE);
safs.set(1, Short.MIN_VALUE);
- safs.set(2, (short)-485);
+ safs.set(2, (short) -485);
fs.setFeatureValue(akofAshort, safs);
-
+
ByteArrayFS bafs = cas.createByteArrayFS(4);
bafs.set(0, Byte.MAX_VALUE);
bafs.set(1, Byte.MIN_VALUE);
bafs.set(2, (byte) 33);
fs.setFeatureValue(akofAbyte, bafs);
-
+
BooleanArrayFS booafs = cas.createBooleanArrayFS(4);
booafs.set(0, true);
booafs.set(1, false);
fs.setFeatureValue(akofAboolean, booafs);
-
+
createStringA(fs, "");
makeRandomFss(15, fsl, random);
}
@@ -881,8 +952,8 @@ public class SerDesTest4 extends TestCas
ByteArrayInputStream bais;
if (!usePrevData) {
if (doPlain) {
- (new CASSerializer()).addCAS(cas, baos);
- } else {
+ (new CASSerializer()).addCAS(cas, baos);
+ } else {
SerializationMeasures sm = bcs.serialize(cas, baos);
if (null != sm) {
System.out.println(sm);
@@ -899,48 +970,128 @@ public class SerDesTest4 extends TestCas
assertTrue(bcs.getCasCompare().compareCASes(cas, deserCas));
} catch (IOException e) {
throw new RuntimeException(e);
- }
+ }
}
+ /**
+ * Verifying deltas is somewhat tricky - the deserializing of a delta into a
+ * CAS often requires that the base CAS has been serialized out first - in
+ * order to set up the proper maps between serialized id forms and FSs -
+ * example:
+ *
+ * Caller does the following: create a CAS, fill 1 serialize , deserialize
+ * into Cas2 modify Cas2 =========== This routine then does ========== delta
+ * serialize Cas2 , deserialize into Cas1 compare Cas1 and Cas2
+ *
+ * @param mark
+ * @param fname
+ */
private void verifyDelta(MarkerImpl mark, String fname) {
try {
ByteArrayInputStream bais;
- BinaryCasSerDes4 bcs = new BinaryCasSerDes4(
- ts, false);
- if (!usePrevData || (fname == null)) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- if (doPlain) {
- Serialization.serializeCAS(cas, baos);
- } else {
- SerializationMeasures sm = bcs.serialize(cas, baos, mark);
- if (null != sm) {
- System.out.println(sm);
- }
- }
-
- if (capture) {
- writeout(baos, fname);
- }
- bais = new ByteArrayInputStream(baos.toByteArray());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+
+ BinaryCasSerDes4 bcs = new BinaryCasSerDes4(ts, false);
+
+ if (doPlain) {
+ Serialization.serializeCAS(cas2, baos);
} else {
- bais = new ByteArrayInputStream(readIn(fname));
- }
- BinaryCasSerDes bcsd_deltaCas = deltaCas.getBinaryCasSerDes();
- bcsd_deltaCas.reinit(bais);
- assertTrue(bcs.getCasCompare().compareCASes(cas, deltaCas));
-
+ bcs.serialize(cas2, baos, mark);
+ }
+ if (capture) {
+ writeout(baos, fname);
+ }
+
+ bais = (!usePrevData || fname == null) ? new ByteArrayInputStream(baos.toByteArray())
+ : new ByteArrayInputStream(readIn(fname)); // use previous data
+
+ BinaryCasSerDes bcsd_cas1 = cas.getBinaryCasSerDes();
+ bcsd_cas1.reinit(bais);
+ assertTrue(bcs.getCasCompare().compareCASes(cas, cas2));
+
// verify indexed fs same; the order may be different so sort first
-
- int[] fsIndexes1 = cas.getBinaryCasSerDes().getIndexedFSs(null);
- int[] fsIndexes2 = bcsd_deltaCas.getIndexedFSs(null);
- Arrays.sort(fsIndexes1);
- Arrays.sort(fsIndexes2);
- assertTrue(Arrays.equals(fsIndexes1, fsIndexes2));
+ getIndexes();
+
+// if (!Arrays.equals(cas1FsIndexes, cas2FsIndexes)) {
+// System.out.println("debug");
+// }
+ assertTrue(Arrays.equals(cas1FsIndexes, cas2FsIndexes));
+
} catch (IOException e) {
throw new RuntimeException(e);
}
}
-
+
+ private void getIndexes() {
+ cas1FsIndexes = getIndexInfo(cas1);
+ cas2FsIndexes = getIndexInfo(cas2);
+ }
+
+ private int[] getIndexInfo(CASImpl cas) {
+ int[] c = {2};
+ IntVector iv = new IntVector();
+ cas.walkReachablePlusFSsSorted(fs -> {
+ if (fs._getTypeImpl() == akof)
+ iv.add(includeUid ? fs.getIntValue(akofUid) : c[0]++);
+ } , null, null, null);
+ int[] ia = iv.toArray();
+ Arrays.sort(ia);
+ return ia;
+ }
+
+ // try {
+ // ByteArrayInputStream bais;
+ // BinaryCasSerDes4 bcs = new BinaryCasSerDes4(ts, false);
+ // if (!usePrevData || (fname == null)) {
+ // ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ // if (doPlain) {
+ // Serialization.serializeCAS(cas, baos);
+ // } else {
+ // SerializationMeasures sm = bcs.serialize(cas, baos, mark);
+ // if (null != sm) {
+ // System.out.println(sm);
+ // }
+ // }
+ //
+ // if (capture) {
+ // writeout(baos, fname);
+ // }
+ // bais = new ByteArrayInputStream(baos.toByteArray());
+ // } else {
+ // bais = new ByteArrayInputStream(readIn(fname));
+ // }
+ //
+ // // prepare deltaCas to receive deserialized form
+ // // do the serialize out to set up shared data structures needed when
+ // deserializing
+ // BinaryCasSerDes4 bcsDelta = new BinaryCasSerDes4(ts, false);
+ //
+ // ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ // if (doPlain) {
+ // Serialization.serializeCAS(deltaCas, baos);
+ // } else {
+ // SerializationMeasures sm = bcsDelta.serialize(deltaCas, baos);
+ // }
+ //
+ // BinaryCasSerDes bcsd_deltaCas = deltaCas.getBinaryCasSerDes();
+ // bcsd_deltaCas.reinit(bais);
+ // assertTrue(bcs.getCasCompare().compareCASes(cas, deltaCas));
+ //
+ // // verify indexed fs same; the order may be different so sort first
+ //
+ // int[] fsIndexes1 = cas.getBinaryCasSerDes().getIndexedFSs(null);
+ // int[] fsIndexes2 = bcsd_deltaCas.getIndexedFSs(null);
+ // Arrays.sort(fsIndexes1);
+ // Arrays.sort(fsIndexes2);
+ // if (!Arrays.equals(fsIndexes1, fsIndexes2)) {
+ // System.out.println("debug");
+ // }
+ // assertTrue(Arrays.equals(fsIndexes1, fsIndexes2));
+ // } catch (IOException e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+
private void writeout(ByteArrayOutputStream baos, String fname) throws IOException {
if (null == fname) {
return;
@@ -949,10 +1100,10 @@ public class SerDesTest4 extends TestCas
fos.write(baos.toByteArray());
fos.close();
}
-
+
private byte[] readIn(String fname) throws IOException {
File f = new File("src/test/resources/SerDes4/" + fname + ".binary");
- int len = (int)f.length();
+ int len = (int) f.length();
byte[] buffer = new byte[len];
BufferedInputStream inStream =
new BufferedInputStream(
@@ -964,7 +1115,7 @@ public class SerDesTest4 extends TestCas
inStream.close();
return buffer;
}
-
+
private BufferedOutputStream setupFileOut(String fname) throws IOException {
if (null == fname) {
return null;
@@ -973,14 +1124,14 @@ public class SerDesTest4 extends TestCas
if (!dir.exists()) {
dir.mkdirs();
}
-
+
return
new BufferedOutputStream(
new FileOutputStream(
new File("src/test/resources/SerDes4/" + fname + ".binary")));
-
+
}
-
+
private void initWriteSavedInts() {
try {
savedIntsOutStream = new OutputStreamWriter(setupFileOut("SavedInts"));
@@ -988,7 +1139,7 @@ public class SerDesTest4 extends TestCas
throw new RuntimeException(e);
}
}
-
+
private void initReadSavedInts() {
try {
savedIntsStream = new BufferedReader(new FileReader("src/test/resources/SerDes4/SavedInts.binary"));
@@ -996,7 +1147,7 @@ public class SerDesTest4 extends TestCas
throw new RuntimeException(e);
}
}
-
+
private void writeSavedInt(int i) {
try {
savedIntsOutStream.write(Integer.toString(i) + '\n');
@@ -1004,142 +1155,140 @@ public class SerDesTest4 extends TestCas
throw new RuntimeException(e);
}
}
-
+
private int readNextSavedInt() {
try {
String s = savedIntsStream.readLine();
return Integer.parseInt(s);
- } catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException(e);
- }
+ }
}
-
- private void makeRandomUpdatesBelowMark(List<FeatureStructure> fs, int belowMarkSize, Random r) {
- for (int i = 0; i < belowMarkSize; i++ ) {
- makeRandomUpdate(lfs.get(i), r);
+
+ private void makeRandomUpdatesBelowMark(List<FeatureStructure> fss, int belowMarkSize, Random r) {
+ for (int i = 0; i < belowMarkSize; i++) {
+ makeRandomUpdate(fss, i, r);
}
}
- private void makeRandomUpdate(FeatureStructure fs, Random r) {
+ private void makeRandomUpdate(List<FeatureStructure> fss, int fsi, Random r) {
+ FeatureStructure fs = fss.get(fsi);
int n = r.nextInt(3);
- for (int i = 0 ; i < n; i++) {
- switch (r.nextInt(26)) {
- case 0:
- fs.setBooleanValue(akofBoolean, r.nextBoolean());
- break;
- case 1:
- fs.setByteValue(akofByte, (byte)r.nextInt());
- break;
- case 2:
- fs.setShortValue(akofShort, (short)r.nextInt());
- break;
- case 3:
- fs.setIntValue(akofInt, r.nextInt());
- break;
- case 4:
- fs.setFloatValue(akofFloat, r.nextFloat());
- break;
- case 5:
- fs.setLongValue(akofLong, r.nextLong());
- break;
- case 6:
- fs.setDoubleValue(akofDouble, r.nextDouble());
- break;
- case 7:
- fs.setStringValue(akofString, randomString(r));
- break;
- case 8:
- fs.setFeatureValue(akofFs, fs);
- break;
- case 9:
- fs.setFeatureValue(akofAint, randomIntA(r));
- break;
- case 10:
- fs.setFeatureValue(akofAfs, cas.createArrayFS(1));
- break;
- case 11:
- fs.setFeatureValue(akofAfloat, randomFloatA(r));
- break;
- case 12:
- fs.setFeatureValue(akofAdouble, randomDoubleA(r));
- break;
- case 13:
- fs.setFeatureValue(akofAlong, randomLongA(r));
- break;
- case 14:
- fs.setFeatureValue(akofAshort, randomShortA(r));
- break;
- case 15:
- fs.setFeatureValue(akofAbyte, randomByteA(r));
- break;
- case 16:
- fs.setFeatureValue(akofAboolean, cas.createBooleanArrayFS(2));
- break;
- case 17:
- fs.setFeatureValue(akofAstring, randomStringA(r));
- break;
- case 18: {
+ for (int i = 0; i < n; i++) {
+ if (((TOP) fs)._getTypeImpl() == akof) {
+ switch (r.nextInt(26)) {
+ case 0:
+ fs.setBooleanValue(akofBoolean, r.nextBoolean());
+ break;
+ case 1:
+ fs.setByteValue(akofByte, (byte) r.nextInt());
+ break;
+ case 2:
+ fs.setShortValue(akofShort, (short) r.nextInt());
+ break;
+ case 3:
+ fs.setIntValue(akofInt, r.nextInt());
+ break;
+ case 4:
+ fs.setFloatValue(akofFloat, r.nextFloat());
+ break;
+ case 5:
+ fs.setLongValue(akofLong, r.nextLong());
+ break;
+ case 6:
+ fs.setDoubleValue(akofDouble, r.nextDouble());
+ break;
+ case 7:
+ fs.setStringValue(akofString, randomString(r));
+ break;
+ case 8:
+ fs.setFeatureValue(akofFs, fs);
+ break;
+ case 9:
+ fs.setFeatureValue(akofAint, randomIntA(r));
+ break;
+ case 10:
+ fs.setFeatureValue(akofAfs, cas.createArrayFS(1));
+ break;
+ case 11:
+ fs.setFeatureValue(akofAfloat, randomFloatA(r));
+ break;
+ case 12:
+ fs.setFeatureValue(akofAdouble, randomDoubleA(r));
+ break;
+ case 13:
+ fs.setFeatureValue(akofAlong, randomLongA(r));
+ break;
+ case 14:
+ fs.setFeatureValue(akofAshort, randomShortA(r));
+ break;
+ case 15:
+ fs.setFeatureValue(akofAbyte, randomByteA(r));
+ break;
+ case 16:
+ fs.setFeatureValue(akofAboolean, cas.createBooleanArrayFS(2));
+ break;
+ case 17:
+ fs.setFeatureValue(akofAstring, randomStringA(r));
+ break;
+ case 18: {
IntArrayFS sfs = (IntArrayFS) fs.getFeatureValue(akofAint);
if ((null != sfs) && (0 < sfs.size())) {
sfs.set(0, 1);
}
}
- break;
- case 19:{
+ break;
+ case 19: {
StringArrayFS sfs = (StringArrayFS) fs.getFeatureValue(akofAstring);
if ((null != sfs) && (0 < sfs.size())) {
sfs.set(0, "change");
}
}
- break;
- case 20: {
+ break;
+ case 20: {
FloatArrayFS sfs = (FloatArrayFS) fs.getFeatureValue(akofAfloat);
if ((null != sfs) && (0 < sfs.size())) {
sfs.set(0, 1F);
}
}
- break;
- case 21: {
+ break;
+ case 21: {
DoubleArrayFS sfs = (DoubleArrayFS) fs.getFeatureValue(akofAdouble);
if ((null != sfs) && (0 < sfs.size())) {
sfs.set(0, 1D);
}
}
- break;
- case 22: {
+ break;
+ case 22: {
LongArrayFS sfs = (LongArrayFS) fs.getFeatureValue(akofAlong);
if ((null != sfs) && (0 < sfs.size())) {
sfs.set(0, 1L);
}
}
- break;
- case 23: {
+ break;
+ case 23: {
ShortArrayFS sfs = (ShortArrayFS) fs.getFeatureValue(akofAshort);
if ((null != sfs) && (0 < sfs.size())) {
- sfs.set(0, (short)1);
+ sfs.set(0, (short) 1);
}
}
- break;
- case 24: {
+ break;
+ case 24: {
ByteArrayFS sfs = (ByteArrayFS) fs.getFeatureValue(akofAbyte);
if ((null != sfs) && (0 < sfs.size())) {
- sfs.set(0, (byte)1);
+ sfs.set(0, (byte) 1);
}
}
- break;
- case 25: {
+ break;
+ case 25: {
ArrayFS sfs = (ArrayFS) fs.getFeatureValue(akofAfs);
if ((null != sfs) && (0 < sfs.size())) {
- sfs.set(0, lfs.get(r.nextInt(lfs.size())));
+ sfs.set(0, fss.get(r.nextInt(lfs.size())));
}
}
- break;
+ break;
+ }
}
- }
+ }
}
-
- // disable to avoid accidentally overwriting test data
-// static public void main(String[] args) throws IOException {
-// (new SerDesTest4()).captureGenerated();
-// }
-}
+}
\ No newline at end of file