svn commit: r1730950 - /uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java
Author: degenaro Date: Wed Feb 17 21:42:56 2016 New Revision: 1730950 URL: http://svn.apache.org/viewvc?rev=1730950&view=rev Log: UIMA-4577 DUCC Web Server (WS) should test for empty string (in addition to null) when accounting for number of service implementor instances (obtained from DB) Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java?rev=1730950&r1=1730949&r2=1730950&view=diff == --- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java Wed Feb 17 21:42:56 2016 @@ -71,19 +71,22 @@ public class DuccDataHelper { String implementors = meta.getProperty(IServicesRegistry.implementors); String[] ret = new String[0]; if(implementors != null) { -String[] tempArray = implementors.trim().split("\\s+"); -ret = new String[tempArray.length]; -int i = 0; -for (String s : tempArray) { -// Back compatibility for the shadow web servers, if no inst id then -// just return the 's' -if ( s.indexOf(".") > 0 ) { -String[] id_inst = s.split("\\."); -ret[i++] = id_inst[0].trim(); -} else { -ret[i++] = s; + implementors = implementors.trim(); + if(implementors.length() > 0) { + String[] tempArray = implementors.trim().split("\\s+"); +ret = new String[tempArray.length]; +int i = 0; +for (String s : tempArray) { +// Back compatibility for the shadow web servers, if no inst id then +// just return the 's' +if ( s.indexOf(".") > 0 ) { +String[] id_inst = s.split("\\."); +ret[i++] = id_inst[0].trim(); +} else { +ret[i++] = s; +} } -} + } } return ret; }
svn commit: r1730949 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database: DbUtil.java StateServicesDb.java
Author: challngr Date: Wed Feb 17 21:37:22 2016 New Revision: 1730949 URL: http://svn.apache.org/viewvc?rev=1730949&view=rev Log: UIMA-4577 Correctly handle keys in property files to avoid malformed CQL. Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/DbUtil.java uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/StateServicesDb.java Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/DbUtil.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/DbUtil.java?rev=1730949&r1=1730948&r2=1730949&view=diff == --- uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/DbUtil.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/DbUtil.java Wed Feb 17 21:37:22 2016 @@ -205,6 +205,9 @@ class DbUtil } +/** + * Imporant: do not pass key fields in the props or this will barf. + */ static String mkUpdate(String table, String key, Object... props) { int len = props.length; @@ -212,20 +215,21 @@ class DbUtil buf.append(table); buf.append(" SET "); +// NOTE: The property set must NOT contain any key fields or this is likely to barf. Caller +// must insure. for ( int i = 0; i < len; i+=2) { IDbProperty prop = (IDbProperty) props[i]; -if ( !prop.isPrimaryKey()) { // not allowed to update this - // we allow it in 'props' so callers can - // simply call update and expect the right - // thing to happen -buf.append(prop.columnName()); -buf.append("="); -buf.append(rep(prop, props[i+1])); -if ( i + 2 < len ) { -buf.append(","); -} +if ( prop.isPrimaryKey() ) { +throw new IllegalArgumentException("Primary key not allowed in UPDATE"); } + +buf.append(prop.columnName()); +buf.append("="); +buf.append(rep(prop, props[i+1])); +if ( i + 2 < len ) { +buf.append(","); +} } buf.append(" WHERE "); buf.append(key); Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/StateServicesDb.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/StateServicesDb.java?rev=1730949&r1=1730948&r2=1730949&view=diff == --- uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/StateServicesDb.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-database/src/main/java/org/apache/uima/ducc/database/StateServicesDb.java Wed Feb 17 21:37:22 2016 @@ -349,17 +349,18 @@ public class StateServicesDb try { h = dbManager.open(); Map map = mkMap(serviceId, table, converter, props); -Object[] updates = new Object[props.size()*2]; +List tmp = new ArrayList(); int i = 0; for ( IDbProperty k : map.keySet() ) { if ( logger.isTrace() ) { logger.trace(methodName, null, "Updating", k.columnName(), "with", map.get(k)); } -updates[i++] = k; -updates[i++] = map.get(k); +if ( k.isPrimaryKey() ) continue;// we do not get to update this +tmp.add(k); +tmp.add(map.get(k)); } -h.updateProperties(table, key, updates); +h.updateProperties(table, key, tmp.toArray(new Object[tmp.size()])); return true; } catch ( Exception e ) { logger.error(methodName, null, "Unable to update properties for service", key, "table", table, ":", e);
svn commit: r1730941 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
Author: schor Date: Wed Feb 17 20:53:15 2016 New Revision: 1730941 URL: http://svn.apache.org/viewvc?rev=1730941&view=rev Log: [UIMA-4669] fix compilation errors with maven compiler (no error with Eclipse compiler) Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1730941&r1=1730940&r2=1730941&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Wed Feb 17 20:53:15 2016 @@ -209,7 +209,7 @@ public class FSIndexRepositoryImpl imple */ int aSortedIndex = -1; // -1 or the position of an arbitrary sorted index int aBagIndex = -1; // -1 or the position of an arbitrary bag index -final ArrayList> indexesForType = new ArrayList<>(0); +final ArrayList> indexesForType = new ArrayList<>(0); FsIndex_iicp getNonSetIndex() { if (aSortedIndex < 0 && aBagIndex < 0) { // index is empty! @@ -218,7 +218,7 @@ public class FSIndexRepositoryImpl imple return (FsIndex_iicp) indexesForType.get((aBagIndex >= 0) ? aBagIndex : aSortedIndex); } -void add(FsIndex_iicp iicp) { +void add(FsIndex_iicp iicp) { typename = iicp.fsIndex_singletype.getType().getName(); final int kind = iicp.fsIndex_singletype.getIndexingStrategy(); int i = indexesForType.size(); @@ -239,8 +239,8 @@ public class FSIndexRepositoryImpl imple } FsIndex_iicp getIndexExcludingType(int indexingStrategy, FSIndexComparatorImpl comparatorForIndexSpecs) { - for (FsIndex_iicp index : indexesForType) { -FsIndex_singletype singleTypeIndex = index.fsIndex_singletype; + for (FsIndex_iicp index : indexesForType) { +FsIndex_singletype singleTypeIndex = index.fsIndex_singletype; if (singleTypeIndex.getIndexingStrategy() == indexingStrategy) { FSIndexComparatorImpl indexComp = singleTypeIndex.getComparatorImplForIndexSpecs(); @@ -644,7 +644,7 @@ public class FSIndexRepositoryImpl imple //if (indexType == FSIndex.SORTED_INDEX) { // this.indexArray[typeCode].add(0, iicp); // shifts rest down //} else -getIndexesForType(typeCode).add((FsIndex_iicp) iicp); +getIndexesForType(typeCode).add((FsIndex_iicp) iicp); //} return iicp; } @@ -959,7 +959,7 @@ public class FSIndexRepositoryImpl imple throw new CASRuntimeException(CASRuntimeException.TYPE_NOT_IN_INDEX, label, type.getName(), indexType.getName()); } -final ArrayList> inds = this.getIndexesForType(ti.getCode()).indexesForType; +final ArrayList> inds = this.getIndexesForType(ti.getCode()).indexesForType; // Since we found an index for the correct type, and // named indexes at creation time create all their subtype iicps, find() must return a // valid result @@ -984,7 +984,7 @@ public class FSIndexRepositoryImpl imple incrementIllegalIndexUpdateDetector(typeCode); // get a list of all indexes defined over this type // Includes indexes defined on supertypes of this type -final ArrayList> allIndexesForType = getIndexesForType(typeCode).indexesForType; +final ArrayList> allIndexesForType = getIndexesForType(typeCode).indexesForType; for (FsIndex_iicp iicp : allIndexesForType) { iicp.fsIndex_singletype.removeAll(); } @@ -1236,11 +1236,11 @@ public class FSIndexRepositoryImpl imple incrementIllegalIndexUpdateDetector(typeCode); // Get the indexes for the type. -final ArrayList> indexes = getIndexesForType(typeCode).indexesForType; +final ArrayList> indexes = getIndexesForType(typeCode).indexesForType; // Add fsRef to all indexes. boolean noIndexOrOnlySetindexes = true; -for (FsIndex_iicp iicp : indexes) { +for (FsIndex_iicp iicp : indexes) { // the indexes for the type are over the type and its subtypes. final int indexingStrategy = iicp.fsIndex_singletype.getIndexingStrategy(); @@ -1296,12 +1296,12 @@ public class FSIndexRepositoryImpl imple } final int typeCode = fs._typeImpl.getCode(); incrementIllegalIndexUpdateDetector(typeCode); -final ArrayList> idxList = getIndexesForType(typeCode).indexesForType; +final ArrayList> idxList = getIndexesForType(typeCode).indexesForType; boolean wasRemoved = false; -for (FsIndex_iicp iicp : idxList) { - FsIndex_singletype st = iicp.fsIndex_singletyp
svn commit: r1730930 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-web/src: main/java/org/apache/uima/ducc/ws/server/ test/java/org/ test/java/org/apache/ test/java/org/apache/uima/ test/java/org/apach
Author: degenaro Date: Wed Feb 17 20:02:09 2016 New Revision: 1730930 URL: http://svn.apache.org/viewvc?rev=1730930&view=rev Log: (empty) Added: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/TestSuite.java (with props) Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerUtils.java Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java?rev=1730930&r1=1730929&r2=1730930&view=diff == --- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java Wed Feb 17 20:02:09 2016 @@ -315,20 +315,22 @@ public class DuccHandlerClassic extends sb.append(""); sb.append(""); // Swap - DecimalFormat formatter = new DecimalFormat("###0.0"); sb.append(""); - double swap = job.getSwapUsageGb(); - if(job.isCompleted()) { - swap = job.getSwapUsageGbMax(); - } - String displaySwapMax = formatter.format(swap); - if(swap > 0) { - sb.append(""); + String swapSizeDisplay = ""; + String swapSizeHover = ""; + title = ""; + double swapBytes = 0; + swapBytes = DuccHandlerUtils.getSwapSizeBytes(job); + swapSizeDisplay = DuccHandlerUtils.getSwapSizeDisplay(swapBytes); + swapSizeHover = DuccHandlerUtils.getSwapSizeHover(swapBytes); + title = "title="+"\""+swapSizeHover+"\""; + if(swapBytes > 0) { + sb.append(""); } else { - sb.append(""); + sb.append(""); } - sb.append(displaySwapMax); + sb.append(swapSizeDisplay); sb.append(""); sb.append(""); // Memory @@ -796,25 +798,25 @@ public class DuccHandlerClassic extends } sb.append(""); // Swap - String swap = ""; - double dswap = 0; + sb.append(""); + String swapSizeDisplay = ""; + String swapSizeHover = ""; + title = ""; + double swapBytes = 0; if(duccwork instanceof DuccWorkJob) { - DecimalFormat formatter = new DecimalFormat("###0.0"); DuccWorkJob job = (DuccWorkJob) duccwork; - dswap = job.getSwapUsageGb(); - if(job.isCompleted()) { - dswap = job.getSwapUsageGbMax(); - } - swap = formatter.format(dswap); + swapBytes = DuccHandlerUtils.getSwapSizeBytes(job); + swapSizeDisplay = DuccHandlerUtils.getSwapSizeDisplay(swapBytes); + swapSizeHover = DuccHandlerUtils.getSwapSizeHover(swapBytes); + title = "title="+"\""+swapSizeHover+"\""; } - sb.append(""); - if(dswap > 0) { - sb.append(""); + if(swapBytes > 0) { + sb.append(""); } else { - sb.append(""); + sb.append(""); } - sb.append(swap); + sb.append(swapSizeDisplay); sb.append(""); sb.append(""); // Memory @@ -949,8 +951,6 @@ public class DuccHandlerClassic extends duccLogger.trace(methodName, jobid, messages.fetch("exit")); } - private static Decim
svn commit: r1730929 - /uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java
Author: schor Date: Wed Feb 17 19:56:52 2016 New Revision: 1730929 URL: http://svn.apache.org/viewvc?rev=1730929&view=rev Log: no Jira extend cas copier performance looping to 60K (but is commented out, normally) Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java?rev=1730929&r1=1730928&r2=1730929&view=diff == --- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java (original) +++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java Wed Feb 17 19:56:52 2016 @@ -227,7 +227,7 @@ public class CasCopierTest extends TestC // do the copy long shortest = Long.MAX_VALUE; int i = 0; -//for (; i < 6000; i++) { // uncomment for perf test. was more than 5x faster than version 2.6.0 +//for (; i < 6; i++) { // uncomment for perf test. was more than 5x faster than version 2.6.0 destCas.reset(); long startTime = System.nanoTime(); copier = new CasCopier(srcCas, destCas);
svn commit: r1730928 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryMergingTest.java
Author: schor Date: Wed Feb 17 19:53:07 2016 New Revision: 1730928 URL: http://svn.apache.org/viewvc?rev=1730928&view=rev Log: [UIMA-4674] test that equal non-updatable things get merged Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryMergingTest.java Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryMergingTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryMergingTest.java?rev=1730928&view=auto == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryMergingTest.java (added) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryMergingTest.java Wed Feb 17 19:53:07 2016 @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.uima.cas.test; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.CASException; +import org.apache.uima.cas.FSIndex; +import org.apache.uima.cas.FSIndexRepository; +import org.apache.uima.cas.FSIterator; +import org.apache.uima.cas.Feature; +import org.apache.uima.cas.FeatureStructure; +import org.apache.uima.cas.Type; +import org.apache.uima.cas.admin.CASFactory; +import org.apache.uima.cas.admin.FSIndexComparator; +import org.apache.uima.cas.admin.FSIndexRepositoryMgr; +import org.apache.uima.cas.admin.LinearTypeOrderBuilder; +import org.apache.uima.cas.impl.CASImpl; +import org.apache.uima.cas.impl.FSIndexComparatorImpl; +import org.apache.uima.cas.impl.FSIndexRepositoryImpl; +import org.apache.uima.cas.impl.FsIndex_annotation; +import org.apache.uima.cas.impl.FsIndex_singletype; +import org.apache.uima.cas.impl.TypeImpl; +import org.apache.uima.cas.impl.TypeSystemImpl; +import org.apache.uima.cas.text.AnnotationFS; +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.tcas.Annotation; + +import junit.framework.TestCase; + +/** + * Check these use cases: + * 1) two identical index definitions, with different names: merged? + * 2) two index definitions with the same kind and comparator, but different starting types - subindexes merged? + * + * + */ +public class IndexRepositoryMergingTest extends TestCase { + + CASImpl cas; + + TypeSystemImpl typeSystem; + + FSIndexRepositoryImpl ir; + + TypeImpl annotSubtype; + + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { +cas = (CASImpl) CASFactory.createCAS(); + +TypeSystemImpl ts = this.typeSystem = cas.getTypeSystemImpl(); +annotSubtype = ts.addType("annotSubtype", ts.annotType); +ts.addFeature("x", annotSubtype, ts.intType); +cas.commitTypeSystem(); // also creates the initial indexrepository +// handle type system reuse +ts = this.typeSystem = cas.getTypeSystemImpl(); +annotSubtype = ts.getType("annotSubtype"); + +cas.initCASIndexes(); // requires committed type system + + +ir = (FSIndexRepositoryImpl) this.cas.getIndexRepositoryMgr(); +FSIndexComparator comp = ir.createComparator(); +Type annotation = ts.getType(CAS.TYPE_NAME_ANNOTATION); +comp.setType(annotation); +comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_BEGIN), +FSIndexComparator.STANDARD_COMPARE); +comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END), +FSIndexComparator.REVERSE_STANDARD_COMPARE); +LinearTypeOrderBuilder tob = ir.createTypeSortOrder(); +try { +// tob.add(new String[] { CAS.TYPE_NAME_ANNOTATION, "annotSubtype", }); // is equal to annotationIndex + tob.add(new String[] { "annotSubtype", CAS.TYPE_NAME_ANNOTATION }); // is !equal AnnotationIndex + comp.addKey(tob.getOrder(), FSIndexComparator.STANDARD_COMPARE); +} catch (CASException e) { + TestCase.assertTrue(false); +} +ir.createIndex(comp, "Annot Index"); // should not be the same as the built-in one due to d
svn commit: r1730927 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemReinitTest.java
Author: schor Date: Wed Feb 17 19:51:08 2016 New Revision: 1730927 URL: http://svn.apache.org/viewvc?rev=1730927&view=rev Log: [UIMA-4667] update to work with class reorganization Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemReinitTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemReinitTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemReinitTest.java?rev=1730927&r1=1730926&r2=1730927&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemReinitTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemReinitTest.java Wed Feb 17 19:51:08 2016 @@ -67,7 +67,7 @@ public class TypeSystemReinitTest extend // reinit // This uses cas2 which only has a base type system to start, //and loads it from a complete serialization which has other new types - cas2.reinit(ser); + cas2.getBinaryCasSerDes().reinit(ser); CAS tcas3 = cas2.getCurrentView(); assertTrue(tcas2 == tcas3); @@ -97,7 +97,7 @@ public class TypeSystemReinitTest extend // reinit // This uses cas2 which only has a base type system to start, //and loads it from a complete serialization which has other new types - cas2.reinit(ser); + cas2.getBinaryCasSerDes().reinit(ser); CAS tcas3 = cas2.getCurrentView(); assertTrue(tcas2 == tcas3);
svn commit: r1730926 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
Author: schor Date: Wed Feb 17 19:50:09 2016 New Revision: 1730926 URL: http://svn.apache.org/viewvc?rev=1730926&view=rev Log: [UIMA-4720] re init types/features if type system reuse happens at commit time Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java?rev=1730926&r1=1730925&r2=1730926&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java Wed Feb 17 19:50:09 2016 @@ -118,6 +118,13 @@ public class SofaTest extends TestCase { // Commit the type system. ((CASImpl) this.casMgr).commitTypeSystem(); + // reinit type system values because the commit might reuse an existing one + tsa = this.casMgr.getTypeSystemMgr(); + this.annotationType = tsa.getType(CAS.TYPE_NAME_ANNOTATION); + this.docAnnotationType = tsa.getType(CAS.TYPE_NAME_DOCUMENT_ANNOTATION); + this.crossType = tsa.getType("sofa.test.CrossAnnotation"); + this.otherFeat = crossType.getFeatureByBaseName("otherAnnotation"); + // Create the Base indexes. this.casMgr.initCASIndexes(); FSIndexRepositoryMgr irm = this.casMgr.getIndexRepositoryMgr();
svn commit: r1730925 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java
Author: schor Date: Wed Feb 17 19:48:36 2016 New Revision: 1730925 URL: http://svn.apache.org/viewvc?rev=1730925&view=rev Log: no Jira - set flag to prevent throwing during index corruption check. Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java?rev=1730925&r1=1730924&r2=1730925&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java Wed Feb 17 19:48:36 2016 @@ -892,6 +892,7 @@ public class SerializationReinitTest ext //== //deserialize delta xmi into cas1 ByteArrayInputStream fisDelta = new ByteArrayInputStream(fosDelta.toByteArray()); + CASImpl.IS_THROW_EXCEPTION_CORRUPT_INDEX = false; Serialization.deserializeCAS(cas1, fisDelta); //==
svn commit: r1730924 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexSerializationTest.java
Author: schor Date: Wed Feb 17 19:38:56 2016 New Revision: 1730924 URL: http://svn.apache.org/viewvc?rev=1730924&view=rev Log: no Jira - add 2 comments Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexSerializationTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexSerializationTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexSerializationTest.java?rev=1730924&r1=1730923&r2=1730924&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexSerializationTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexSerializationTest.java Wed Feb 17 19:38:56 2016 @@ -226,8 +226,8 @@ public class IndexSerializationTest exte CASCompleteSerializer cs; cs = Serialization.serializeCASComplete(casMgr); // casMgr = CASFactory.createCAS(); -CASMgr realCasMgr = CASFactory.createCAS(); -((CASImpl) realCasMgr).commitTypeSystem(); +CASMgr realCasMgr = CASFactory.createCAS(); // creates base view, but no ts, so no ir +((CASImpl) realCasMgr).commitTypeSystem(); // also makes index repo (which will be replaced), but doesn't init the built-in indexes Serialization.deserializeCASComplete(cs, realCasMgr); cas = ((CASImpl) realCasMgr).getCurrentView(); casMgr = (CASMgr) cas;
svn commit: r1730923 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java
Author: schor Date: Wed Feb 17 19:38:24 2016 New Revision: 1730923 URL: http://svn.apache.org/viewvc?rev=1730923&view=rev Log: no Jira - fix one test which was comparing using the wrong cas Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java?rev=1730923&r1=1730922&r2=1730923&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java Wed Feb 17 19:38:24 2016 @@ -65,7 +65,7 @@ public class CompleteSerializationTest e } catch (Exception e) { assertTrue(false); } - assertTrue(cas.getTypeSystemMgr().getType(CASTestSetup.GROUP_1) != null); + assertTrue(((CASImpl) newCas).getTypeSystemMgr().getType(CASTestSetup.GROUP_1) != null); assertTrue(((CASImpl) newCas).isBackwardCompatibleCas()); assertEquals("Create the sofa for the inital view", newCas.getDocumentText());
svn commit: r1730922 - /uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java
Author: schor Date: Wed Feb 17 19:37:14 2016 New Revision: 1730922 URL: http://svn.apache.org/viewvc?rev=1730922&view=rev Log: no Jira - fix test case which in one test was testing the wrong cas. Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java?rev=1730922&r1=1730921&r2=1730922&view=diff == --- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java (original) +++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CompleteSerializationTest.java Wed Feb 17 19:37:14 2016 @@ -65,7 +65,7 @@ public class CompleteSerializationTest e } catch (Exception e) { assertTrue(false); } - assertTrue(cas.getTypeSystemMgr().getType(CASTestSetup.GROUP_1) != null); + assertTrue(((CASImpl) newCas).getTypeSystemMgr().getType(CASTestSetup.GROUP_1) != null); assertTrue(((CASImpl) newCas).isBackwardCompatibleCas()); assertEquals("Create the sofa for the inital view", newCas.getDocumentText());
svn commit: r1730920 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java
Author: schor Date: Wed Feb 17 19:07:20 2016 New Revision: 1730920 URL: http://svn.apache.org/viewvc?rev=1730920&view=rev Log: no jira - expand the cascopier performance test from 6000 to 6 iterations (but it's normally disabled) Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java?rev=1730920&r1=1730919&r2=1730920&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java Wed Feb 17 19:07:20 2016 @@ -225,7 +225,7 @@ public class CasCopierTest extends TestC // do the copy long shortest = Long.MAX_VALUE; int i = 0; -//for (; i < 6000; i++) { // uncomment for perf test. was more than 5x faster than version 2.6.0 +//for (; i < 6; i++) { // uncomment for perf test. was more than 5x faster than version 2.6.0 destCas.reset(); long startTime = System.nanoTime(); copier = new CasCopier(srcCas, destCas);
svn commit: r1730919 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java
Author: schor Date: Wed Feb 17 19:06:20 2016 New Revision: 1730919 URL: http://svn.apache.org/viewvc?rev=1730919&view=rev Log: no Jira - fix call to internal constructor whose arg list changed Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java?rev=1730919&r1=1730918&r2=1730919&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java Wed Feb 17 19:06:20 2016 @@ -67,7 +67,7 @@ public class IndexCorruptionReportingTes } private FsIndex_bag cbi() { -FSIndexComparator comparatorForIndexSpecs = new FSIndexComparatorImpl(cas); +FSIndexComparator comparatorForIndexSpecs = new FSIndexComparatorImpl(); return new FsIndex_bag(cas, ts.getTopType(), 16, FSIndex.BAG_INDEX, comparatorForIndexSpecs ); }
svn commit: r1730918 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/Id2FSTest.java
Author: schor Date: Wed Feb 17 19:05:57 2016 New Revision: 1730918 URL: http://svn.apache.org/viewvc?rev=1730918&view=rev Log: no Jira - fix call to constructor for Id2FS which now takes initial heap size arg Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/Id2FSTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/Id2FSTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/Id2FSTest.java?rev=1730918&r1=1730917&r2=1730918&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/Id2FSTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/Id2FSTest.java Wed Feb 17 19:05:57 2016 @@ -81,7 +81,7 @@ public class Id2FSTest extends TestCase assertTrue(caught); } -Id2FS id2fs = new Id2FS(); +Id2FS id2fs = new Id2FS(200); cas.reset(); fs1 = new TOP(jcas);
svn commit: r1730917 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java
Author: schor Date: Wed Feb 17 19:05:09 2016 New Revision: 1730917 URL: http://svn.apache.org/viewvc?rev=1730917&view=rev Log: no Jira - fix call to internal constructor whose arg list changed Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java?rev=1730917&r1=1730916&r2=1730917&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java Wed Feb 17 19:05:09 2016 @@ -71,7 +71,7 @@ public class FSBagIndexTest extends Test } private FsIndex_bag cbi() { -FSIndexComparator comparatorForIndexSpecs = new FSIndexComparatorImpl(cas); +FSIndexComparator comparatorForIndexSpecs = new FSIndexComparatorImpl(); comparatorForIndexSpecs.setType(ts.getTopType()); return new FsIndex_bag(cas, ts.getType("uima.cas.TOP"), 16, FSIndex.BAG_INDEX, comparatorForIndexSpecs); }
svn commit: r1730916 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java
Author: schor Date: Wed Feb 17 19:04:24 2016 New Revision: 1730916 URL: http://svn.apache.org/viewvc?rev=1730916&view=rev Log: [UIMA-4674] cleanup random use Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java?rev=1730916&r1=1730915&r2=1730916&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java Wed Feb 17 19:04:24 2016 @@ -79,6 +79,11 @@ public class SerDesTest6 extends TestCas Akof1, Akof2, } + private static long seed; + // -8,093,220,039,004,886,811 +// final private static Random random = setRandom(seed = -8093220039004886811L); + final private static Random random = setRandom(); + static {System.out.format("SerDesTest6 RandomSeed: %,d%n", seed); } private final String testDocText = "test document text"; private CASImpl remoteCas; @@ -90,8 +95,6 @@ public class SerDesTest6 extends TestCas private CASImpl casSrc; private TTypeSystem[] alternateTTypeSystems; - private Random random; - private long seed; public class CASTestSetup implements AnnotatorInitializer { @@ -247,25 +250,26 @@ public class SerDesTest6 extends TestCas // Constructor public SerDesTest6() { -//setRandom(seed = 1994207594477441796L); -setRandom(); -System.out.format("SerDesTest6 RandomSeed: %,d%n", seed); + +//setRandom(); + } - private void setRandom() { + private static Random setRandom() { Random sg = new Random(); seed = sg.nextLong(); -//seed = -4003978854850136823L; -random = new Random(seed); +//seed = 1096269913061953477L; +return new Random(seed); } - private void setRandom(long seed) { -random = new Random(seed); + private static Random setRandom(long seed) { +return new Random(seed); } public TTypeSystem setupTTypeSystem(TypeSystems kind) { if (kind == EqTwoTypes) { TTypeSystem m = new TTypeSystem(mSrc.tsm, kind); + m.cas = mSrc.cas; // m.ts = mSrc.cas.getTypeSystemImpl(); return mSrc; } @@ -449,7 +453,7 @@ public class SerDesTest6 extends TestCas verifyDelta(marker, ri); break; } - setRandom(); +// setRandom(); setUp(); System.out.println(" testDelta w/ String array mod random = " + seed + ", i = " + i); } @@ -474,7 +478,7 @@ public class SerDesTest6 extends TestCas verifyDelta(marker, ri); break; } - setRandom(); +// setRandom(); setUp(); System.out.println(" testDelta w/ dbl array mod random = " + seed + ", i = " + i); } @@ -501,7 +505,7 @@ public class SerDesTest6 extends TestCas verifyDelta(marker, ri); break; } - setRandom(); // retry with different random number +// setRandom(); // retry with different random number setUp(); System.out.println(" testDelta w byte array mod retrying, i = " + i); } @@ -613,9 +617,9 @@ public class SerDesTest6 extends TestCas ReuseInfo ri[] = serializeDeserialize(casSrc, remoteCas, null, null); MarkerImpl marker = (MarkerImpl) remoteCas.createMarker(); -lfs = getIndexedFSs(remoteCas, m); +lfs = getIndexedFSs(remoteCas, m); // get list of all "Akof1" FS FeatureStructure fs = remoteCas.createFS(m.getType(Akof1)); -maybeSetFeatureKind( lfs.get(0), m, "Fs", fs); +maybeSetFeatureKind( lfs.get(0), m, "Fs", fs); // set the lfs.get(0) featurestructure's feature "Fs" to the new fs verifyDelta(marker, ri); } @@ -711,14 +715,14 @@ public class SerDesTest6 extends TestCas } public void testArrayAux() { -ArrayList fsl = new ArrayList(); +ArrayList fsList = new ArrayList(); /** * Strings, non-array Long/Double: * Make equal items, * ser/deser, update one of the equal items, insure other not updated */ -FeatureStructure fsAt1 = newAkof(casSrc, mSrc, Akof1, fsl); -FeatureStructure fsAt2 = newAkof(casSrc, mSrc, Akof1, fsl); +FeatureStructure fsAt1 = newAkof(casSrc, mSrc, Akof1, fsList); +FeatureStructure fsAt2 = newAkof(casSrc, mSrc, Akof1, fsList); casSrc.addFsToIndexes(fsAt1); casSrc.addFsToIndexes(fsAt2); @@ -739,8 +743,8 @@ public class SerDesTest6 extends TestCas casSrc.reset(); -fsAt1 = newAkof(casSrc, mSrc, Akof1, fsl); -fsAt2 = newAkof(casSrc, mSrc, Akof1, fsl); +fsAt1 = newAkof(casSrc, mSrc, Akof1, fsList); +
svn commit: r1730915 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest4.java
Author: schor Date: Wed Feb 17 19:02:00 2016 New Revision: 1730915 URL: http://svn.apache.org/viewvc?rev=1730915&view=rev Log: [UIMA-4674] cleanup random use, fix test case for some class reorg. in core 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=1730915&r1=1730914&r2=1730915&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 Feb 17 19:02:00 2016 @@ -107,7 +107,7 @@ public class SerDesTest4 extends TestCas public double nextDouble() { int r = usePrevData ? readNextSavedInt() : super.nextInt(0x7); if (capture) writeSavedInt(r); - return Double.longBitsToDouble((long) r); + return CASImpl.long2double((long) r); } } @@ -286,18 +286,17 @@ public class SerDesTest4 extends TestCas } public SerDesTest4() { -Random sg = new Random(); -seed = sg.nextLong(); -random.setSeed(seed); } public void setUp() { long seed = (new Random()).nextLong(); random.setSeed(seed); +//random .setSeed(15L); //System.out.format("RandomSeed: %,d%n", seed); try { - this.cas = (CASImpl) CASInitializer.initCas(new CASTestSetup(), ts -> reinitTypeSystem(ts)); + CASTestSetup cts = new CASTestSetup(); + this.cas = (CASImpl) CASInitializer.initCas(cts, ts -> cts.reinitTypeSystem(ts)); this.ts = (TypeSystemImpl) this.cas.getTypeSystem(); deserCas = (CASImpl) CasCreationUtils.createCas(ts, null, null, null); deltaCas = (CASImpl) CasCreationUtils.createCas(ts, null, null, null); @@ -587,7 +586,7 @@ public class SerDesTest4 extends TestCas ByteArrayOutputStream baos = new ByteArrayOutputStream(); Serialization.serializeCAS(cas, baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); -c2.reinit(bais); +c2.getBinaryCasSerDes().reinit(bais); } private FeatureStructure newAkof(List fsl) { @@ -896,7 +895,7 @@ public class SerDesTest4 extends TestCas } else { bais = new ByteArrayInputStream(readIn(fname)); } - deserCas.reinit(bais); + deserCas.getBinaryCasSerDes().reinit(bais); assertTrue(bcs.getCasCompare().compareCASes(cas, deserCas)); } catch (IOException e) { throw new RuntimeException(e); @@ -926,13 +925,16 @@ public class SerDesTest4 extends TestCas } else { bais = new ByteArrayInputStream(readIn(fname)); } - - deltaCas.reinit(bais); + BinaryCasSerDes bcsd_deltaCas = deltaCas.getBinaryCasSerDes(); + bcsd_deltaCas.reinit(bais); assertTrue(bcs.getCasCompare().compareCASes(cas, deltaCas)); - // verify indexed fs same, and in same order - int[] fsIndexes1 = cas.getIndexedFSs(); - int[] fsIndexes2 = deltaCas.getIndexedFSs(); + // 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)); } catch (IOException e) { throw new RuntimeException(e);
svn commit: r1730913 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasTypeSystemMapperTst.java
Author: schor Date: Wed Feb 17 18:57:47 2016 New Revision: 1730913 URL: http://svn.apache.org/viewvc?rev=1730913&view=rev Log: [UIMA-4673] fix type mapper test to work with V3 Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasTypeSystemMapperTst.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasTypeSystemMapperTst.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasTypeSystemMapperTst.java?rev=1730913&r1=1730912&r2=1730913&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasTypeSystemMapperTst.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasTypeSystemMapperTst.java Wed Feb 17 18:57:47 2016 @@ -19,6 +19,10 @@ package org.apache.uima.cas.impl; import java.util.BitSet; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import org.apache.uima.cas.CAS; import org.apache.uima.cas.Feature; @@ -32,8 +36,37 @@ import org.apache.uima.resource.Resource import junit.framework.TestCase; +/** + * CasTypeSystemMapper maintains resources to map between two type systems, and handles + * types present in one but not the other, + * same-named types present in both but with different feature sets + * + * The correspondence is by the name of the types and their features. + * + * Same-named features must have the same range. + * Types with no features - OK + * + * Testing: make instances of type systems + * - with / without missing types + * - with same-named types having different features + * - with same named but not == types and features + * + * Verify appropriate mapping is there. + */ + public class CasTypeSystemMapperTst extends TestCase { + private static TypeSystemImpl tsi = new TypeSystemImpl(); // just to get the built-ins + private static int t0 = tsi.getNumberOfTypes(); + private static int t1 = t0 + 1; + private static int t2 = t0 + 2; + + private TypeSystemImpl ts1, ts2; + + private TypeImpl t1t, t2t, ts1t1, ts1t2, ts2t1, ts2t2; + + private CasTypeSystemMapper m; + protected void setUp() throws Exception { super.setUp(); } @@ -81,211 +114,265 @@ public class CasTypeSystemMapperTst exte // } public void testCasTypeSystemMapperFull() throws ResourceInitializationException { -TypeSystemImpl ts1 = createTs(3, 0x1, 0x1); -TypeSystemImpl ts2 = createTs(3, 0x1, 0x1); -CasTypeSystemMapper m = new CasTypeSystemMapper(ts1, ts2); -chkbase(m, 38); +ts1 = createTs(3, 0x1, 0x1); +ts2 = createTs(3, 0x1, 0x1); // become == type systems +m = new CasTypeSystemMapper(ts1, ts2); +chkbase(m, t2); // check all are equal assertTrue(m.isEqual()); } public void testMissingType1() throws ResourceInitializationException { -TypeSystemImpl ts1 = createTs(3, 0x1, 0x1); -TypeSystemImpl ts2 = createTs(1, 0x1, 0x1); -CasTypeSystemMapper m = new CasTypeSystemMapper(ts1, ts2); -chkbase(m, 39); -assertEquals(0, m.mapTypeCodeSrc2Tgt(40)); +ts1 = createTs(3, 0x1, 0x1); +ts1t2 = t2t; +ts2 = createTs(1, 0x1, 0x1); // missing t2t + +m = new CasTypeSystemMapper(ts1, ts2); +chkbase(m, t1); // should be the same up thru t1 +assertEquals(null, m.mapTypeSrc2Tgt(ts1t2)); // ts1t2 is missing, so this should map to null assertFalse(m.isEqual()); } public void testMissingType2() throws ResourceInitializationException { -TypeSystemImpl ts1 = createTs(3, 0x1, 0x1); -TypeSystemImpl ts2 = createTs(2, 0x1, 0x1); -CasTypeSystemMapper m = new CasTypeSystemMapper(ts1, ts2); -chkbase(m, 38); -assertEquals( 0, m.mapTypeCodeSrc2Tgt(39)); -assertEquals(39, m.mapTypeCodeSrc2Tgt(40)); -assertEquals(40, m.mapTypeCodeTgt2Src(39)); -chkfeats(m, 40); +ts1 = createTs(3, 0x1, 0x1); +ts1t1 = t1t; +ts1t2 = t2t; +ts2 = createTs(2, 0x1, 0x1); // missing ts11 + +m = new CasTypeSystemMapper(ts1, ts2); +chkbase(m, t0); +assertEquals( null, m.mapTypeSrc2Tgt(ts1t1)); +assertEquals(t1t, m.mapTypeSrc2Tgt(ts1t2)); +assertEquals(ts1t2, m.mapTypeCodeTgt2Src(t1)); +chkfeats(m, ts1t2, t1t); assertFalse(m.isEqual()); } public void testMissingType3() throws ResourceInitializationException { -TypeSystemImpl ts1 = createTs(1, 0x1, 0x1); -TypeSystemImpl ts2 = createTs(3, 0x1, 0x1); -CasTypeSystemMapper m = new CasTypeSystemMapper(ts1, ts2); -chkbase(m, 39); -assertEquals(0, m.mapTypeCodeTgt2Src(40)); +ts1 = createTs(1, 0x1, 0x1); +ts2 =
svn commit: r1730912 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java
Author: schor Date: Wed Feb 17 18:57:01 2016 New Revision: 1730912 URL: http://svn.apache.org/viewvc?rev=1730912&view=rev Log: no Jira - use Misc.internalError() Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java?rev=1730912&r1=1730911&r2=1730912&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java Wed Feb 17 18:57:01 2016 @@ -234,7 +234,7 @@ public class CasComparer { case Slot_HeapRef: returncompareAllArrayElements(len1, i -> compare1(((FSArray )fs1).get(i), ((FSArray )fs2).get(i), visited), "Miscompare FS Arrays %n%s%n%s", fs1, fs2); case Slot_StrRef: returncompareAllArrayElements(len1, i -> Misc.compareStrings(((StringArray )fs1).get(i), ((StringArray )fs2).get(i)), "Miscompare String Arrays %n%s%n%s", fs1, fs2); default: - assert(false); return 0; // only to avoid a compile error + Misc.internalError(); return 0; // only to avoid a compile error } }
svn commit: r1730911 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
Author: schor Date: Wed Feb 17 18:55:23 2016 New Revision: 1730911 URL: http://svn.apache.org/viewvc?rev=1730911&view=rev Log: no Jira, fix test case to not routinely generate and recover from null url - makes debugging harder. Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java?rev=1730911&r1=1730910&r2=1730911&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java Wed Feb 17 18:55:23 2016 @@ -96,7 +96,7 @@ public class SimpleCasGenerator extends URL url = this.getClass().getClassLoader().getResource(filename); //System.out.println(" File" + url.getPath()); // open input stream to file -file = new File(url.getPath()); +file = new File((null == url) ? filename : url.getPath()); } catch (Exception e) { file = new File(filename); }
svn commit: r1730910 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
Author: schor Date: Wed Feb 17 18:51:53 2016 New Revision: 1730910 URL: http://svn.apache.org/viewvc?rev=1730910&view=rev Log: [UIMA-4674] allow view iterator to return a subtype of CAS (e.g. CASImpl) Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java?rev=1730910&r1=1730909&r2=1730910&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java Wed Feb 17 18:51:53 2016 @@ -1045,9 +1045,9 @@ public interface CAS extends AbstractCas * structures) pertaining to that Sofa. * * @return an iterator which returns all views. Each object returned by - * the iterator is of type CAS. + * the iterator is of type CAS or a subtype. */ - Iterator getViewIterator(); + Iterator getViewIterator(); /** * Get iterator over all views with the given name prefix. Each view provides access to Sofa data
svn commit: r1730851 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/ObjHashSet.java
Author: schor Date: Wed Feb 17 15:10:45 2016 New Revision: 1730851 URL: http://svn.apache.org/viewvc?rev=1730851&view=rev Log: [UIMA-4674] minor performance improvement Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/ObjHashSet.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/ObjHashSet.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/ObjHashSet.java?rev=1730851&r1=1730850&r2=1730851&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/ObjHashSet.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/ObjHashSet.java Wed Feb 17 15:10:45 2016 @@ -63,7 +63,7 @@ public class ObjHashSet implements Se private int size; // number of elements in the table private int nbrRemoved; // number of removed elements (coded as removed) - // the actual Object table + // the actual Object table, operated as a hashtable private T [] keys; private boolean secondTimeShrinkable = false; @@ -364,9 +364,9 @@ public class ObjHashSet implements Se * @return updated pos */ public int moveToNextFilled(int pos) { -if (pos < 0) { - pos = 0; -} +//if (pos < 0) { +// pos = 0; +//} final int max = getCapacity(); while (true) { @@ -406,6 +406,10 @@ public class ObjHashSet implements Se private class ObjHashSetIterator implements Iterator { +/** + * Keep this always pointing to a non-0 entry, or + * if not valid, outside the range + */ protected int curPosition; private ObjHashSetIterator() { @@ -414,16 +418,18 @@ public class ObjHashSet implements Se @Override public final boolean hasNext() { - curPosition = moveToNextFilled(curPosition); return curPosition < getCapacity(); } @Override public final T next() { - if (!hasNext()) { + try { +T r = get(curPosition); +curPosition = moveToNextFilled(curPosition + 1); +return r; + } catch (ArrayIndexOutOfBoundsException e) { throw new NoSuchElementException(); } - return get(curPosition++); } @Override
svn commit: r1730909 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
Author: schor Date: Wed Feb 17 18:48:08 2016 New Revision: 1730909 URL: http://svn.apache.org/viewvc?rev=1730909&view=rev Log: [UIMA-4674] add error msg Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java?rev=1730909&r1=1730908&r2=1730909&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java Wed Feb 17 18:48:08 2016 @@ -239,6 +239,9 @@ public class CASRuntimeException extends /** Type Systems must be committed before calling this method. */ public static final String TYPESYSTEMS_NOT_COMMITTED = "TYPESYSTEMS_NOT_COMMITTED"; + /** While deserializing, no type found for type code {0}. */ + public static final String deserialized_type_not_found = "deserialized_type_not_found"; + /** * The constructors are organized *
svn commit: r1730908 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/TypeSystem.java
Author: schor Date: Wed Feb 17 18:47:28 2016 New Revision: 1730908 URL: http://svn.apache.org/viewvc?rev=1730908&view=rev Log: no Jira - remove unused method Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/TypeSystem.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/TypeSystem.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/TypeSystem.java?rev=1730908&r1=1730907&r2=1730908&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/TypeSystem.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/TypeSystem.java Wed Feb 17 18:47:28 2016 @@ -97,13 +97,6 @@ public interface TypeSystem { Iterator getTypeIterator(); /** - * Get a Stream over all types, in no particular order. - * - * @return The stream. - */ - Stream types(); - - /** * Get the top type, i.e., the root of the type system. * * @return The top type.
svn commit: r1730907 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java
Author: schor Date: Wed Feb 17 18:47:02 2016 New Revision: 1730907 URL: http://svn.apache.org/viewvc?rev=1730907&view=rev Log: [UIMA-4674] performance - add get and next with no valid checking Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java?rev=1730907&r1=1730906&r2=1730907&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java Wed Feb 17 18:47:02 2016 @@ -90,12 +90,24 @@ public interface FSIterator
svn commit: r1730906 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java
Author: schor Date: Wed Feb 17 18:46:01 2016 New Revision: 1730906 URL: http://svn.apache.org/viewvc?rev=1730906&view=rev Log: [UIMA-4674] remove unused class Removed: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java
svn commit: r1730905 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/SlotKindsConstants.java
Author: schor Date: Wed Feb 17 18:45:06 2016 New Revision: 1730905 URL: http://svn.apache.org/viewvc?rev=1730905&view=rev Log: [UIMA-4665] constants common class Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/SlotKindsConstants.java Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/SlotKindsConstants.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/SlotKindsConstants.java?rev=1730905&view=auto == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/SlotKindsConstants.java (added) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/SlotKindsConstants.java Wed Feb 17 18:45:06 2016 @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.uima.cas.impl; + +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_ArrayLength; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Byte; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Control; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Double_Exponent; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Double_Mantissa_Sign; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Float_Exponent; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Float_Mantissa_Sign; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_FsIndexes; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_HeapRef; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Int; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Long_High; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Long_Low; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Short; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrRef; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrChars; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrLength; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrOffset; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrSeg; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_TypeCode; + +/** + * Users "implement" this interface to get access to these constants in their code + */ +public interface SlotKindsConstants { + static final boolean CAN_BE_NEGATIVE = true; + static final boolean IGNORED = true; + static final boolean IN_MAIN_HEAP = true; + + final static int arrayLength_i = Slot_ArrayLength.ordinal(); + final static int heapRef_i = Slot_HeapRef.ordinal(); + final static int int_i = Slot_Int.ordinal(); + final static int byte_i = Slot_Byte.ordinal(); + final static int short_i = Slot_Short.ordinal(); + final static int typeCode_i = Slot_TypeCode.ordinal(); + final static int strOffset_i = Slot_StrOffset.ordinal(); + final static int strLength_i = Slot_StrLength.ordinal(); + final static int long_High_i = Slot_Long_High.ordinal(); + final static int long_Low_i = Slot_Long_Low.ordinal(); + final static int float_Mantissa_Sign_i = Slot_Float_Mantissa_Sign.ordinal(); + final static int float_Exponent_i = Slot_Float_Exponent.ordinal(); + final static int double_Mantissa_Sign_i = Slot_Double_Mantissa_Sign.ordinal(); + final static int double_Exponent_i = Slot_Double_Exponent.ordinal(); + final static int fsIndexes_i = Slot_FsIndexes.ordinal(); + final static int strChars_i = Slot_StrChars.ordinal(); + final static int control_i = Slot_Control.ordinal(); + final static int strSeg_i = Slot_StrSeg.ordinal(); + + final static int NBR_SLOT_KIND_ZIP_STREAMS = Slot_StrRef.ordinal(); +} +
svn commit: r1730902 [2/3] - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl: BinaryCasSerDes4.java BinaryCasSerDes6.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java?rev=1730902&r1=1730901&r2=1730902&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java Wed Feb 17 18:43:42 2016 @@ -19,34 +19,7 @@ package org.apache.uima.cas.impl; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.NBR_SLOT_KIND_ZIP_STREAMS; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_ArrayLength; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Boolean; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_BooleanRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Byte; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_ByteRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Control; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_DoubleRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Double_Exponent; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Double_Mantissa_Sign; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Float; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Float_Exponent; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Float_Mantissa_Sign; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_FsIndexes; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_HeapRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Int; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_LongRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Long_High; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Long_Low; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_MainHeap; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Short; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_ShortRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrChars; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrLength; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrOffset; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrRef; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrSeg; -import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_TypeCode; +import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Int; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -63,10 +36,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; +import java.util.BitSet; +import java.util.Collections; import java.util.List; -import java.util.Map; +import java.util.function.Consumer; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import java.util.zip.Inflater; @@ -74,11 +47,29 @@ import java.util.zip.InflaterInputStream import org.apache.uima.cas.AbstractCas; import org.apache.uima.cas.CASRuntimeException; -import org.apache.uima.cas.Feature; import org.apache.uima.cas.Marker; +import org.apache.uima.cas.impl.CASImpl.FsChange; import org.apache.uima.cas.impl.FSsTobeAddedback.FSsTobeAddedbackSingle; +import org.apache.uima.cas.impl.SlotKinds.SlotKind; +import org.apache.uima.internal.util.Int2ObjHashMap; +import org.apache.uima.internal.util.IntListIterator; import org.apache.uima.internal.util.IntVector; +import org.apache.uima.internal.util.Obj2IntIdentityHashMap; import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.cas.BooleanArray; +import org.apache.uima.jcas.cas.ByteArray; +import org.apache.uima.jcas.cas.CommonArray; +import org.apache.uima.jcas.cas.DoubleArray; +import org.apache.uima.jcas.cas.FSArray; +import org.apache.uima.jcas.cas.FloatArray; +import org.apache.uima.jcas.cas.IntegerArray; +import org.apache.uima.jcas.cas.LongArray; +import org.apache.uima.jcas.cas.ShortArray; +import org.apache.uima.jcas.cas.Sofa; +import org.apache.uima.jcas.cas.StringArray; +import org.apache.uima.jcas.cas.TOP; +import org.apache.uima.resource.ResourceInitializationException; +import org.apache.uima.util.Misc; import org.apache.uima.util.impl.DataIO; import org.apache.uima.util.impl.OptimizeStrings
svn commit: r1730902 [3/3] - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl: BinaryCasSerDes4.java BinaryCasSerDes6.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java?rev=1730902&r1=1730901&r2=1730902&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java Wed Feb 17 18:43:42 2016 @@ -19,27 +19,10 @@ package org.apache.uima.cas.impl; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.NBR_SLOT_KIND_ZIP_STREAMS; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_ArrayLength; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Byte; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Control; import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_DoubleRef; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Double_Exponent; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Double_Mantissa_Sign; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Float_Exponent; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Float_Mantissa_Sign; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_FsIndexes; import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_HeapRef; import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Int; import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_LongRef; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Long_High; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Long_Low; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_Short; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrChars; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrLength; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrOffset; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_StrSeg; -import static org.apache.uima.cas.impl.SlotKinds.SlotKind.Slot_TypeCode; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -57,12 +40,12 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; -import java.util.Collection; import java.util.Collections; -import java.util.IdentityHashMap; +import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.function.Consumer; +import java.util.function.IntFunction; import java.util.function.IntPredicate; import java.util.stream.Stream; import java.util.zip.Deflater; @@ -75,11 +58,13 @@ import org.apache.uima.cas.CASRuntimeExc import org.apache.uima.cas.FSIterator; import org.apache.uima.cas.Feature; import org.apache.uima.cas.impl.CASImpl.FsChange; +import org.apache.uima.cas.impl.CommonSerDes.Header; import org.apache.uima.cas.impl.FSsTobeAddedback.FSsTobeAddedbackSingle; import org.apache.uima.cas.impl.SlotKinds.SlotKind; import org.apache.uima.internal.util.Int2ObjHashMap; import org.apache.uima.internal.util.IntListIterator; import org.apache.uima.internal.util.IntVector; +import org.apache.uima.internal.util.Pair; import org.apache.uima.jcas.JCas; import org.apache.uima.jcas.cas.BooleanArray; import org.apache.uima.jcas.cas.ByteArray; @@ -210,8 +195,8 @@ import org.apache.uima.util.impl.Seriali * * * ** uses info saved when serializing * ** */ -public class BinaryCasSerDes6 { - +public class BinaryCasSerDes6 implements SlotKindsConstants { + private static final String EMPTY_STRING = ""; private static final boolean TRACE_SER = false; @@ -221,14 +206,6 @@ public class BinaryCasSerDes6 { private static final boolean TRACE_MOD_DES = false; private static final boolean TRACE_STR_ARRAY = false; - /** - * Version of the serializer/deserializer, used to allow deserialization of - * older versions - * - * Version 0 - initial SVN checkin - * Version 1 - changes to support CasTypeSystemMapper - */ - private static final int VERSION = 1; /** * Compression alternatives @@ -298,26 +275,6 @@ public class BinaryCasSerDes6 { return new ReuseInfo(foundFSsBitset, fssToSerialize, fsStartIndexes); } - // speedups - ints for SlotKind ordinals - final private static int arrayLength_i = Slot_ArrayLength.ordinal(); - final private static int heapRef_i = Slot_HeapRef.ordinal(); - final private static int int_i = Slot_Int.ordinal(); - final private static int byte_i = Slot_Byte.ordinal(); - final private static int short_i = Slot_Short.ordinal(); - final private static int
svn commit: r1730903 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java
Author: schor Date: Wed Feb 17 18:44:09 2016 New Revision: 1730903 URL: http://svn.apache.org/viewvc?rev=1730903&view=rev Log: [UIMA-4674] update error msg Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java?rev=1730903&r1=1730902&r2=1730903&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java Wed Feb 17 18:44:09 2016 @@ -97,6 +97,11 @@ public class CASAdminException extends U */ public static final String INDEX_DUPLICATES_NOT_SUPPORTED = "INDEX_DUPLICATES_NOT_SUPPORTED"; + /** + * Total number of UIMA types, {0}, exceeds the maximum of 32767. + */ + public static final String TOO_MANY_TYPES = "TOO_MANY_TYPES"; + private String resourceBundleName = DEFAULT_RESOURCE_BUNDLE_NAME; public CASAdminException(String aResourceBundleName, Throwable aCause, String aMessageKey, Object ... aArguments) {
svn commit: r1730902 [1/3] - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl: BinaryCasSerDes4.java BinaryCasSerDes6.java
Author: schor Date: Wed Feb 17 18:43:42 2016 New Revision: 1730902 URL: http://svn.apache.org/viewvc?rev=1730902&view=rev Log: [UIMA-4674][UIMA-4665] use common shared code, remove redundant checking for set/get of features. Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
svn commit: r1730901 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
Author: schor Date: Wed Feb 17 18:41:59 2016 New Revision: 1730901 URL: http://svn.apache.org/viewvc?rev=1730901&view=rev Log: [UIMA-4674] remove redundant checking for set/get of features Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java?rev=1730901&r1=1730900&r2=1730901&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Wed Feb 17 18:41:59 2016 @@ -1487,12 +1487,12 @@ public class BinaryCasSerDes { case Slot_Int: case Slot_Float: if (!isSofa || feat != tsi.sofaNum) { - fs.setIntLikeValue(slotKind, feat, heapFeat(heapIndex, feat)); + fs.setIntLikeValueNcNj(slotKind, feat, heapFeat(heapIndex, feat)); } break; - case Slot_LongRef: fs.setLongValue(feat, longHeap.heap[heapFeat(heapIndex, feat)]); break; - case Slot_DoubleRef: fs.setDoubleValue(feat, CASImpl.long2double(longHeap.heap[heapFeat(heapIndex, feat)])); break; + case Slot_LongRef: fs.setLongValueNcNj(feat, longHeap.heap[heapFeat(heapIndex, feat)]); break; + case Slot_DoubleRef: fs.setDoubleValueNcNj(feat, CASImpl.long2double(longHeap.heap[heapFeat(heapIndex, feat)])); break; case Slot_StrRef: { String s = stringHeap.getStringForCode(heapFeat(heapIndex, feat)); if (null == s) { @@ -1519,7 +1519,7 @@ public class BinaryCasSerDes { break; } } -fs.setStringValue(feat, s); +fs.setStringValueNcNj(feat, s); break; } @@ -1532,7 +1532,7 @@ public class BinaryCasSerDes { if (feat == tsi.sofaArray) { ((Sofa)finalFs).setLocalSofaData(item); } else { - finalFs.setFeatureValue(feat, item); + finalFs.setFeatureValueNcNj(feat, item); }}, addr2fs); break; }
svn commit: r1730900 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
Author: schor Date: Wed Feb 17 18:41:18 2016 New Revision: 1730900 URL: http://svn.apache.org/viewvc?rev=1730900&view=rev Log: [UIMA-4665][UIMA-4663] move some things to shared classes Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java?rev=1730900&r1=1730899&r2=1730900&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java Wed Feb 17 18:41:18 2016 @@ -23,19 +23,33 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.Serializable; -import java.nio.ByteBuffer; -import java.util.ArrayList; +import java.util.BitSet; import org.apache.uima.cas.CASRuntimeException; import org.apache.uima.cas.Marker; +import org.apache.uima.cas.function.IntConsumer_withIOException; +import org.apache.uima.cas.impl.CASImpl.FsChange; +import org.apache.uima.internal.util.IntVector; +import org.apache.uima.internal.util.Obj2IntIdentityHashMap; +import org.apache.uima.jcas.cas.BooleanArray; +import org.apache.uima.jcas.cas.ByteArray; +import org.apache.uima.jcas.cas.DoubleArray; +import org.apache.uima.jcas.cas.FSArray; +import org.apache.uima.jcas.cas.FloatArray; +import org.apache.uima.jcas.cas.IntegerArray; +import org.apache.uima.jcas.cas.LongArray; +import org.apache.uima.jcas.cas.ShortArray; +import org.apache.uima.jcas.cas.StringArray; +import org.apache.uima.jcas.cas.TOP; +import org.apache.uima.util.Misc; /** * This object has 2 purposes. * - it can hold a collection of individually Java-object-serializable objects representing a CAS + * the list of FS's indexed in the CAS * - * - it has special methods to do a custom binary serialization (no compression) of a CAS + lists - * of its indexed FSs. + * - it has special methods (versions of addCAS) to do a custom binary serialization (no compression) of a CAS + lists + * of its indexed FSs. * * One use of this class follows this form: * @@ -81,7 +95,7 @@ public class CASSerializer implements Se // the 0th position in the string table should be null and will be ignored. public String[] stringTable; - // All FSs in any index. + // Special encoding of fs pseudo-addrs and counts by view incl. sofa and view counts public int[] fsIndex; public byte[] byteHeapArray; @@ -117,63 +131,41 @@ public class CASSerializer implements Se } /** - * Add the CAS to be serialized. Note that we need the implementation here, the interface is not - * enough. + * Add the CAS to be serialized. * * @param cas The CAS to be serialized. - * @param addMetaData - + * @param addMetaData - true to include metadata */ public void addCAS(CASImpl cas, boolean addMetaData) { -this.fsIndex = cas.getIndexedFSs(); -final int heapSize = cas.getHeap().getCellsUsed(); -this.heapArray = new int[heapSize]; -System.arraycopy(cas.getHeap().heap, 0, this.heapArray, 0, heapSize); +BinaryCasSerDes bcsd = cas.getBinaryCasSerDes(); +CommonSerDesSequential csds = new CommonSerDesSequential(cas.getBaseCAS()); +scanAllFSsForBinarySerialization(bcsd, null, csds); // populates the arrays +this.fsIndex = bcsd.getIndexedFSs(csds.fs2addr); // must follow scanAll... + if (addMetaData) { // some details about current main-heap specifications // not required to deserialize // not sent for C++ // is 7 words long // not serialized by custom serializers, only by Java object serialization - this.heapMetaData = cas.getHeap().getMetaData(); + int heapsz = bcsd.heap.getCellsUsed(); + this.heapMetaData = new int[] { +Heap.getRoundedSize(heapsz), // a bit more than the size of the used heap +heapsz, // the position of the next (unused) slot in the heap +heapsz, +0, +0, +1024, // initial size +0}; } -this.stringTable = stringArrayListToArray(cas.getStringTable()); - -final int byteHeapSize = cas.getByteHeap().getSize(); -this.byteHeapArray = new byte[byteHeapSize]; -System.arraycopy(cas.getByteHeap().heap, 0, this.byteHeapArray, 0, byteHeapSize); - -final int shortHeapSize = cas.getShortHeap().getSize(); -this.shortHeapArray = new short[shortHeapSize]; -System.arraycopy(cas.getShortHeap().heap, 0, this.shortHeapArray, 0, shortHeapSize); - -final
svn commit: r1730898 - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima: UIMAException_Messages.properties cas/admin/admin_errors.properties
Author: schor Date: Wed Feb 17 18:36:23 2016 New Revision: 1730898 URL: http://svn.apache.org/viewvc?rev=1730898&view=rev Log: [UIMA-4674] update error msgs Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/cas/admin/admin_errors.properties Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties?rev=1730898&r1=1730897&r2=1730898&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties Wed Feb 17 18:36:23 2016 @@ -561,8 +561,7 @@ PROTECTED_SOFA_FEATURE = Can''t use stan JCAS_MISSING_COVERCLASS = The JCAS cover class "{0}" could not be loaded. INVALID_FEATURE_PATH = The feature path "{0}" is not valid. NO_PRIMITIVE_TAIL = The feature path does not end in a primitive valued feature. -BLOB_SERIALIZATION = Error trying to do binary serialization of CAS data and write the BLOB to an output stream. -BLOB_DESERIALIZATION = Error trying to read BLOB data from an input stream and deserialize into a CAS. + SOFADATASTREAM_ERROR = Error trying to open a stream to Sofa data. INVALID_BASE_CAS_METHOD = Can''t call method "{0}" on the base CAS. ANNOTATION_IN_WRONG_INDEX = Error - the Annotation "{0}" is over view "{1}" and cannot be added to indexes associated with the different view "{2}". @@ -582,4 +581,11 @@ CREATE_FS_BEFORE_TS_COMMITTED = Cannot c GET_CLASS_FOR_TYPE_BEFORE_TS_COMMIT = Cannot request the Java Class for a UIMA type before type system commit. CAS_MISSING_FS = The CAS doesn''t have a Feature Structure whose ID is {0}; it may have been garbage collected. INVALID_FS_ID = The Feature Structure ID {0} is invalid. -TYPESYSTEMS_NOT_COMMITTED = Type Systems must be committed before calling this method. \ No newline at end of file +TYPESYSTEMS_NOT_COMMITTED = Type Systems must be committed before calling this method. + +# +# Serialization / deserialization runtime exceptions +# +BLOB_SERIALIZATION = Error trying to do binary serialization of CAS data and write the BLOB to an output stream. +BLOB_DESERIALIZATION = Error trying to read BLOB data from an input stream and deserialize into a CAS. +deserialized_type_not_found = While deserializing, no type found for type code {0}. Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/cas/admin/admin_errors.properties URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/cas/admin/admin_errors.properties?rev=1730898&r1=1730897&r2=1730898&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/cas/admin/admin_errors.properties (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/cas/admin/admin_errors.properties Wed Feb 17 18:36:23 2016 @@ -40,4 +40,5 @@ DUPLICATE_TYPE = Trying to define type " MISSING_ARRAY_TYPE_FOR_COMPONENT = Tried to obtain a UIMA Array type for component "{0}", but no such array type is defined. STRING_SUBTYPE_REDEFINE_NAME_CONFLICT = Can''t define a Subtype of String whose type name "{0}" is the same as an existing non String Subtype "{1}" STRING_SUBTYPE_CONFLICTING_ALLOWED_VALUES = Can''t define a Subtype of String "{0}" with allowed Values "{1}", which has the same name as an existing String Subtype with different allowed values "{2}". -INDEX_DUPLICATES_NOT_SUPPORTED = uima.allow_duplicate_add_to_indexes is not supported in UIMA Version 3 and later \ No newline at end of file +INDEX_DUPLICATES_NOT_SUPPORTED = uima.allow_duplicate_add_to_indexes is not supported in UIMA Version 3 and later +TOO_MANY_TYPES = Total number of UIMA types, {0}, exceeds the maximum of 32766. \ No newline at end of file
svn commit: r1730848 - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl: CommonSerDes.java CommonSerDesSequential.java
Author: schor Date: Wed Feb 17 14:49:19 2016 New Revision: 1730848 URL: http://svn.apache.org/viewvc?rev=1730848&view=rev Log: [UIMA-4665] some refactoring to share more common code in de/serializing Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDes.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDesSequential.java Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDes.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDes.java?rev=1730848&view=auto == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDes.java (added) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDes.java Wed Feb 17 14:49:19 2016 @@ -0,0 +1,192 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.uima.cas.impl; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; + +/** + * Common de/serialization + */ +public class CommonSerDes { + + int version1; + int version2; + + boolean isDelta; + boolean isCompressed; + + /* + * HEADERS + * Serialization versioning + * There are 1 or 2 words used for versioning. + * Compressed formats and plain formats with bit xx on in first word use 2nd word + * + * First word: + * + * - bit in 0x01 position: on for binary non-delta (redundant) + * - bit in 0x02 position: on means delta, off - not delta + * - bit in 0x04 position: on means compressed, off means plain binary + * - bits 0xF8 reserved + * + * - byte in 0xFF 00 position: incrementing (starting w/ 0) version + * + * Form 4: 0 = original (UIMA v2) + * 1 = fixes to original found during V3 development + * 2 = V3 + * + * - byte in 0xFF 00 00 position: special flags with some shared meaning + * -- bit 0x01 00 00: V3 formats + * + * Second word: + * - bit in 0x01 position: on means form6, off = form 4 + */ + + static class Header { +boolean isDelta; +boolean isCompressed; +boolean isV3style; +boolean form4; +boolean form6; +byte seqVersionNbr; +boolean isV3; +boolean swap; +int v; // for error messages + + +Reading reading; + +Header delta() {isDelta = true; return this; } +Header delta(boolean v) {isDelta = v; return this; } +Header form4() {isCompressed = form4 = true; form6 = false; return this; } +Header form6() {isCompressed = form6 = true; form4 = false; return this; } +Header seqVer(int v) { assert (v >= 0 && v < 256); seqVersionNbr = (byte)v; return this; } +Header v3() {isV3 = true; return this; } + + +void write(DataOutputStream dos) throws IOException { + v = (!isCompressed && !isDelta) ? 1 : 0; + if (isDelta) v |= 0x02; + if (isCompressed) v |= 0x04; + v |= (seqVersionNbr << 8); + if (isV3) v |= 0x01; + + byte[] uima = new byte[4]; + uima[0] = 85; // U + uima[1] = 73; // I + uima[2] = 77; // M + uima[3] = 65; // A + + ByteBuffer buf = ByteBuffer.wrap(uima); + int key = buf.asIntBuffer().get(); + + dos.writeInt(key); + dos.writeInt(v); + + if (isCompressed) { +dos.writeInt(form6 ? 1 : 0); + } +} + } + + static Header createHeader() { +return new Header(); + } + + + static Header readHeader(DataInputStream dis) throws IOException { + +Header h = new Header(); +// key +// determine if byte swap if needed based on key +byte[] bytebuf = new byte[4]; +bytebuf[0] = dis.r
svn commit: r1730876 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java
Author: schor Date: Wed Feb 17 17:07:24 2016 New Revision: 1730876 URL: http://svn.apache.org/viewvc?rev=1730876&view=rev Log: [UIMA-4674] performance versions that eliminate redundant checking Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java?rev=1730876&r1=1730875&r2=1730876&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java Wed Feb 17 17:07:24 2016 @@ -1115,6 +1115,12 @@ public class FeatureStructureImplC imple throw new CASRuntimeException(CASRuntimeException.INTERNAL_ERROR); // dummy, always overridden } + /** + * Internal Use only + * @param slotKind - + * @param fi - + * @param v - + */ public void setIntLikeValue(SlotKind slotKind, FeatureImpl fi, int v) { switch(slotKind) { case Slot_Boolean: setBooleanValue(fi, v == 1); break; @@ -1127,7 +1133,26 @@ public class FeatureStructureImplC imple } /** + * Internal Use only - no feature check, no journaling + * @param slotKind - + * @param fi - + * @param v - + */ + public void setIntLikeValueNcNj(SlotKind slotKind, FeatureImpl fi, int v) { +switch(slotKind) { +case Slot_Boolean: setBooleanValueNcNj(fi, v == 1); break; +case Slot_Byte: setByteValueNcNj(fi, (byte) v); break; +case Slot_Short: setShortValueNcNj(fi, (short) v); break; +case Slot_Int: setIntValueNcNj(fi, v); break; +case Slot_Float: setFloatValueNcNj(fi, CASImpl.int2float(v)); break; +default: Misc.internalError(); +} + } + + + /** * for compressed form 4 - for getting the prev value of int-like slots + * Uses unchecked forms for feature access * @param slotKind * @param fi * @param v @@ -1165,11 +1190,11 @@ public class FeatureStructureImplC imple } switch(slotKind) { -case Slot_Boolean: return getBooleanValue(f) ? 1 : 0; -case Slot_Byte: return getByteValue(f); -case Slot_Short: return getShortValue(f); -case Slot_Int: return getIntValue(f); -case Slot_Float: return CASImpl.float2int(getFloatValue(f)); +case Slot_Boolean: return getBooleanValueNc(f) ? 1 : 0; +case Slot_Byte: return getByteValueNc(f); +case Slot_Short: return getShortValueNc(f); +case Slot_Int: return getIntValueNc(f); +case Slot_Float: return CASImpl.float2int(getFloatValueNc(f)); default: Misc.internalError(); return 0; } }
svn commit: r1730847 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
Author: schor Date: Wed Feb 17 14:48:05 2016 New Revision: 1730847 URL: http://svn.apache.org/viewvc?rev=1730847&view=rev Log: [UIMA-4663] [UIMA-4792] common de/serialization code for binary and sequential (e.g. form4) forms. Remove some redundancy in check-for-updating-that-might-corrupt-indexes. Move some common code to CommonSerDes class. Incorporate new versioning (consistent with V2 change). Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java?rev=1730847&r1=1730846&r2=1730847&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Wed Feb 17 14:48:05 2016 @@ -36,6 +36,8 @@ import org.apache.uima.cas.CASRuntimeExc import org.apache.uima.cas.SerialFormat; import org.apache.uima.cas.function.Consumer_T_int_withIOException; import org.apache.uima.cas.function.DeserBinaryIndexes; +import org.apache.uima.cas.impl.CommonSerDes.Header; +import org.apache.uima.cas.impl.CommonSerDes.Reading; import org.apache.uima.cas.impl.SlotKinds.SlotKind; import org.apache.uima.internal.util.Int2ObjHashMap; import org.apache.uima.internal.util.IntListIterator; @@ -288,7 +290,7 @@ public class BinaryCasSerDes { boolean wasRemoved; if (!type.isArray()) { FeatureImpl feat = type.getFeatureImpls().get(heapAddr - fsStartAddr - 1); -wasRemoved = baseCas.removeFromCorruptableIndexAnyView(fs, tobeAddedback, feat.getCode()); +wasRemoved = baseCas.checkForInvalidFeatureSetting(fs, feat.getCode(), tobeAddedback); addrOfFsToBeAddedBack = wasRemoved ? fsStartAddr : 0; fsToBeAddedBack = wasRemoved ? fs : null; } @@ -376,60 +378,24 @@ public class BinaryCasSerDes { public SerialFormat reinit(InputStream istream) throws CASRuntimeException { -final DataInputStream dis = (istream instanceof DataInputStream) ? - (DataInputStream) istream : new DataInputStream(istream); +final DataInputStream dis = CommonSerDes.maybeWrapToDataInputStream(istream); try { - // key - // determine if byte swap if needed based on key - byte[] bytebuf = new byte[4]; - bytebuf[0] = dis.readByte(); // U - bytebuf[1] = dis.readByte(); // I - bytebuf[2] = dis.readByte(); // M - bytebuf[3] = dis.readByte(); // A - - final boolean swap = (bytebuf[0] != 85); - - // version - // version bit in 2's place indicates this is in delta format. - /** - * Serialization versioning - * There are 1 or 2 words used for versioning. - * Compressed formats and plain formats with bit xx on in first word use 2nd word - * - * First word: - * - * - bit in 0x02 position: on means delta, off - not delta - * - bit in 0x04 position: on means compressed, off means plain binary - * - bit in 0x40 position: on means 2nd word present - * - * - byte in 0xFF00 position: incrementing (starting w/ 0) version - * - * Form 4: 0 = original (UIMA v2) - * 1 = fixes to original found during V3 development - * - * - byte in 0xFF 00 00 position: special flags with some shared meaning - * -- bit 0x01 00 00: V3 formats - * - * Second word: - * - bit in 0x01 position: on means form6, off = form 4 - * - bit in 0x02 position: 1 = compressed form 6 - */ - final int version1 = readInt(dis, swap); - final int version2 = ((version1 & 0x44) != 0) ? readInt(dis, swap) : 0; - - final boolean delta = ((version1 & 2) == 2); + Header h = CommonSerDes.readHeader(dis); + + final boolean delta = h.isDelta; if (!delta) { baseCas.resetNoQuestions(); } - if (0 != (version1 & 4)) { + if (h.isCompressed) { if (TRACE_DESER) { - System.out.format("BinDeser version = %d compressedVersion = %d%n", version1, version2); + System.out.format("BinDeser version = %d%n", h.v); } -if (version2 == 0) { - (new BinaryCasSerDes4(baseCas.getTypeSystemImpl(), false)).deserialize(baseCas, dis, delta, version1); +if (h.form4) { + (new BinaryCasSerDes4(baseCas.getTypeSystemImpl(), false)) +.deserialize(baseCas, dis, delta, h.v); return SerialFormat.C
svn commit: r1730843 - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function: Consumer_T_int_withIOException.java Consumer_T_withIOException.java
Author: schor Date: Wed Feb 17 14:39:09 2016 New Revision: 1730843 URL: http://svn.apache.org/viewvc?rev=1730843&view=rev Log: [UIMA-4663] support for deserialization Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_int_withIOException.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_withIOException.java Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_int_withIOException.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_int_withIOException.java?rev=1730843&view=auto == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_int_withIOException.java (added) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_int_withIOException.java Wed Feb 17 14:39:09 2016 @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.uima.cas.function; + +import java.io.IOException; + +@FunctionalInterface +public interface Consumer_T_int_withIOException { + void accept(T t, int i) throws IOException; +} Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_withIOException.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_withIOException.java?rev=1730843&view=auto == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_withIOException.java (added) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/Consumer_T_withIOException.java Wed Feb 17 14:39:09 2016 @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.uima.cas.function; + +import java.io.IOException; + +@FunctionalInterface +public interface Consumer_T_withIOException { + void accept(T t) throws IOException; +}
svn commit: r1730845 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/package-info.java
Author: schor Date: Wed Feb 17 14:41:34 2016 New Revision: 1730845 URL: http://svn.apache.org/viewvc?rev=1730845&view=rev Log: no Jira - update comment Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/package-info.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/package-info.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/package-info.java?rev=1730845&r1=1730844&r2=1730845&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/package-info.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/package-info.java Wed Feb 17 14:41:34 2016 @@ -17,12 +17,13 @@ * under the License. */ /** - * Functional Interfaces used by generators and by getters and setters + * Custom Functional Interfaces used by various UIMA methods + * - generators and by getters and setters + * - de/serializers * - * There is a separate one for all the java primitives used by UIMA: + * For generators/getters/setters, there is a separate one for all the java primitives used by UIMA: * boolean, byte, short, int, long, float, double, - * and one more for non-primitives, which is generic in the type of the object. - * - * There are 2 interfaces per type - one for the setter, and one for the getter. + * and one more for non-primitives, which is generic in the type of the object. + * There are 2 interfaces per type - one for the setter, and one for the getter. */ package org.apache.uima.cas.function; \ No newline at end of file
svn commit: r1730844 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/IntConsumer_withIOException.java
Author: schor Date: Wed Feb 17 14:39:43 2016 New Revision: 1730844 URL: http://svn.apache.org/viewvc?rev=1730844&view=rev Log: [UIMA-4663] support for serialization Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/IntConsumer_withIOException.java Added: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/IntConsumer_withIOException.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/IntConsumer_withIOException.java?rev=1730844&view=auto == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/IntConsumer_withIOException.java (added) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/function/IntConsumer_withIOException.java Wed Feb 17 14:39:43 2016 @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.uima.cas.function; + +import java.io.IOException; + +@FunctionalInterface +public interface IntConsumer_withIOException { + void accept(int i) throws IOException; +}
svn commit: r1730842 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/LinearTypeOrder.java
Author: schor Date: Wed Feb 17 14:37:06 2016 New Revision: 1730842 URL: http://svn.apache.org/viewvc?rev=1730842&view=rev Log: no Jira - remove unused import Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/LinearTypeOrder.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/LinearTypeOrder.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/LinearTypeOrder.java?rev=1730842&r1=1730841&r2=1730842&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/LinearTypeOrder.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/LinearTypeOrder.java Wed Feb 17 14:37:06 2016 @@ -21,7 +21,6 @@ package org.apache.uima.cas.admin; import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.Type; -import org.apache.uima.cas.impl.FeatureStructureImplC; /** * Linear order on types.
svn commit: r1730841 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASFactory.java
Author: schor Date: Wed Feb 17 14:36:17 2016 New Revision: 1730841 URL: http://svn.apache.org/viewvc?rev=1730841&view=rev Log: [UIMA-4674] support initialHeapSize again Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASFactory.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASFactory.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASFactory.java?rev=1730841&r1=1730840&r2=1730841&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASFactory.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASFactory.java Wed Feb 17 14:36:17 2016 @@ -80,7 +80,7 @@ public abstract class CASFactory { if (ts == null) { throw new NullPointerException("TypeSystem"); } -return new CASImpl((TypeSystemImpl) ts); +return new CASImpl((TypeSystemImpl) ts, initialHeapSize); } /** @@ -99,7 +99,7 @@ public abstract class CASFactory { if (ts == null) { throw new NullPointerException("TypeSystem"); } -return new CASImpl((TypeSystemImpl) ts); +return new CASImpl((TypeSystemImpl) ts, CASImpl.DEFAULT_INITIAL_HEAP_SIZE); } /**
svn commit: r1730840 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java
Author: schor Date: Wed Feb 17 14:35:44 2016 New Revision: 1730840 URL: http://svn.apache.org/viewvc?rev=1730840&view=rev Log: [UIMA-4670] fix spelling of bundle name Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java?rev=1730840&r1=1730839&r2=1730840&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/admin/CASAdminException.java Wed Feb 17 14:35:44 2016 @@ -25,7 +25,7 @@ public class CASAdminException extends U private static final long serialVersionUID = 1L; - private static String DEFAULT_RESOURCE_BUNDLE_NAME = "org.apache.uima.admin.admin_errors"; + private static String DEFAULT_RESOURCE_BUNDLE_NAME = "org.apache.uima.cas.admin.admin_errors"; /** Can't add index to a committed repository. */ public static final String REPOSITORY_LOCKED = "REPOSITORY_LOCKED";
svn commit: r1730862 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java
Author: schor Date: Wed Feb 17 15:41:36 2016 New Revision: 1730862 URL: http://svn.apache.org/viewvc?rev=1730862&view=rev Log: [UIMA-4664] performance - eliminate redundant checks in accessors in comparator. Add removeAll method that sometimes updates the fs's inSetSortedIndex flag. Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java?rev=1730862&r1=1730861&r2=1730862&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java Wed Feb 17 15:41:36 2016 @@ -30,6 +30,7 @@ import org.apache.uima.cas.FeatureStruct import org.apache.uima.cas.Type; import org.apache.uima.cas.admin.FSIndexComparator; import org.apache.uima.cas.admin.LinearTypeOrder; +import org.apache.uima.jcas.cas.TOP; import org.apache.uima.util.Misc; /** @@ -203,12 +204,15 @@ public abstract class FsIndex_singletype * @see org.apache.uima.cas.FSIndex#compare(T, T) */ @Override - public int compare(FeatureStructure fs1, FeatureStructure fs2) { + public int compare(FeatureStructure afs1, FeatureStructure afs2) { -if (fs1 == fs2) { +if (afs1 == afs2) { return 0; } +FeatureStructureImplC fs1 = (FeatureStructureImplC) afs1; +FeatureStructureImplC fs2 = (FeatureStructureImplC) afs2; + /** * for each key: * if Feature: @@ -222,34 +226,35 @@ public abstract class FsIndex_singletype if (key instanceof FeatureImpl) { FeatureImpl fi = (FeatureImpl) key; if (fi.getRange() instanceof TypeImpl_string) { // string and string subtypes - result = Misc.compareStrings(fs1.getStringValue(fi), fs2.getStringValue(fi)); + result = Misc.compareStrings(fs1.getStringValueNc(fi), fs2.getStringValueNc(fi)); } else { switch (keyTypeCodes[i]) { case TypeSystemImpl.booleanTypeCode: -result = Integer.compare(fs1.getBooleanValue(fi) ? 1 : 0, - fs2.getBooleanValue(fi) ? 1 : 0); +result = Integer.compare(fs1.getBooleanValueNc(fi) ? 1 : 0, + fs2.getBooleanValueNc(fi) ? 1 : 0); break; case TypeSystemImpl.byteTypeCode: -result = Integer.compare(fs1.getByteValue(fi), fs2.getByteValue(fi)); +result = Integer.compare(fs1.getByteValueNc(fi), fs2.getByteValueNc(fi)); break; case TypeSystemImpl.shortTypeCode: -result = Integer.compare(fs1.getShortValue(fi), fs2.getShortValue(fi)); +result = Integer.compare(fs1.getShortValueNc(fi), fs2.getShortValueNc(fi)); break; case TypeSystemImpl.intTypeCode: -result = Integer.compare(fs1.getIntValue(fi), fs2.getIntValue(fi)); +result = Integer.compare(fs1.getIntValueNc(fi), fs2.getIntValueNc(fi)); break; case TypeSystemImpl.longTypeCode: -result = Long.compare(fs1.getLongValue(fi), fs2.getLongValue(fi)); +result = Long.compare(fs1.getLongValueNc(fi), fs2.getLongValueNc(fi)); break; case TypeSystemImpl.floatTypeCode: -result = Float.compare(fs1.getFloatValue(fi), fs2.getFloatValue(fi)); +result = Float.compare(fs1.getFloatValueNc(fi), fs2.getFloatValueNc(fi)); break; case TypeSystemImpl.doubleTypeCode: -result = Double.compare(fs1.getDoubleValue(fi), fs2.getDoubleValue(fi)); +result = Double.compare(fs1.getDoubleValueNc(fi), fs2.getDoubleValueNc(fi)); break; - case TypeSystemImpl.stringTypeCode: -result = Misc.compareStrings(fs1.getStringValue(fi), fs2.getStringValue(fi)); -break; +// next is compared above before the switch +// case TypeSystemImpl.stringTypeCode: +//result = Misc.compareStrings(fs1.getStringValueNc(fi), fs2.getStringValueNc(fi)); +//break; } // end of switch } } else { // is type order compare @@ -350,4 +355,18 @@ public abstract class FsIndex_singletype boolean isSorted() { return indexType == FSIndex.SORTED_INDEX; } + + /** + * Differs from flush in that it manipulates flags in the FSs to indicate removed. + */ + void removeAll() { +FSIterator it = iterator(); +if (type instanceof TypeImpl_annotBase) { +
svn commit: r1730863 - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl: FsIndex_annotation.java FsIndex_flat.java FsIndex_snapshot.java
Author: schor Date: Wed Feb 17 15:42:50 2016 New Revision: 1730863 URL: http://svn.apache.org/viewvc?rev=1730863&view=rev Log: [UIMA-4674] minor performance, remove unused statics Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java?rev=1730863&r1=1730862&r2=1730863&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java Wed Feb 17 15:42:50 2016 @@ -110,8 +110,7 @@ public class FsIndex_annotation dtr; T annot; while (it.isValid()) { - annot = it.get(); - it.moveToNext(); + annot = it.nextNvc(); dtr = new AnnotationTreeNodeImpl(); dtr.set(annot); node.addChild(dtr); Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java?rev=1730863&r1=1730862&r2=1730863&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java Wed Feb 17 15:42:50 2016 @@ -64,7 +64,7 @@ public class FsIndex_flat it = iicp.iterator(); int i = 0; while (it.hasNext()) { - a[i++] = it.next(); + a[i++] = it.nextNvc(); } if (i != a.length) { Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java?rev=1730863&r1=1730862&r2=1730863&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java Wed Feb 17 15:42:50 2016 @@ -30,10 +30,7 @@ import org.apache.uima.jcas.cas.TOP; * base on the setting of IteratorExtraFunction */ public class FsIndex_snapshot implements FSIndex { - - static final boolean ORDERED = false; - static final boolean UNORDERED = true; - + /** * wrapped index */
svn commit: r1730869 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
Author: schor Date: Wed Feb 17 16:40:14 2016 New Revision: 1730869 URL: http://svn.apache.org/viewvc?rev=1730869&view=rev Log: [UIMA-4674] "remove" updates, remove cache-not-in-index, maintain fs._inSetSortedIndex value, use unordered iterator when getting all indexed FSs, some performance speedups. Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1730869&r1=1730868&r2=1730869&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Wed Feb 17 16:40:14 2016 @@ -48,6 +48,7 @@ import org.apache.uima.cas.admin.LinearT import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.internal.util.IntVector; import org.apache.uima.internal.util.ObjHashSet; +import org.apache.uima.jcas.cas.AnnotationBase; import org.apache.uima.jcas.cas.TOP; import org.apache.uima.jcas.tcas.Annotation; import org.apache.uima.util.Misc; @@ -74,7 +75,7 @@ import org.apache.uima.util.Misc; */ public class FSIndexRepositoryImpl implements FSIndexRepositoryMgr, LowLevelIndexRepository { - private final static boolean DEBUG = false; +// private final static boolean DEBUG = false; public final static boolean ITEM_ADDED_TO_INDEX = true; public final static boolean ITEM_REMOVED_FROM_INDEX = false; @@ -323,10 +324,11 @@ public class FSIndexRepositoryImpl imple // Monitor indexes used to optimize getIndexedFS and flush - // only used for faster access to next set bit + // set of typecodes corresponding to indexes that are used final private IntVector usedIndexes; // one bit per typeCode, indexed by typeCode + // This is only to speed up the test to skip adding an index to the set of "used" ones if it already is used. final private boolean[] isUsed; // Monitor which indexes are iterated over, to allow resetting flatIndexes @@ -576,7 +578,9 @@ public class FSIndexRepositoryImpl imple for (int i = 0; i < usedIndexes.size(); i++) { int used = this.usedIndexes.get(i); isUsed[used] = false; - indexArray[used].indexesForType.stream().forEach(iicp -> iicp.fsIndex_singletype.flush()); + for (FsIndex_iicp iicp : indexArray[used].indexesForType) { +iicp.fsIndex_singletype.flush(); + } } //clearIteratedSortedIndexes(); @@ -982,7 +986,7 @@ public class FSIndexRepositoryImpl imple // Includes indexes defined on supertypes of this type final ArrayList> allIndexesForType = getIndexesForType(typeCode).indexesForType; for (FsIndex_iicp iicp : allIndexesForType) { - iicp.fsIndex_singletype.flush(); + iicp.fsIndex_singletype.removeAll(); } } @@ -1166,7 +1170,7 @@ public class FSIndexRepositoryImpl imple } public void removeFS(int fsRef) { -ll_removeFS(fsRef); +removeFS(cas.getFsFromId_checked(fsRef)); } /* @@ -1209,7 +1213,6 @@ public class FSIndexRepositoryImpl imple } private void addFS_common(T fs, boolean isAddback) { -cas.maybeClearCacheNotInIndex(fs); TypeImpl ti = ((FeatureStructureImplC)fs)._typeImpl; final int typeCode = ti.getCode(); @@ -1259,6 +1262,7 @@ public class FSIndexRepositoryImpl imple logIndexOperation(fs, true); } +fs._setInSetSortedIndexed(); if (isAddback) { return; } // https://issues.apache.org/jira/browse/UIMA-4111 @@ -1276,7 +1280,7 @@ public class FSIndexRepositoryImpl imple } if (!this.isUsed[typeCode]) { - // mark this index as used + // mark this type as being in some indexes this.isUsed[typeCode] = true; this.usedIndexes.add(typeCode); } @@ -1287,6 +1291,9 @@ public class FSIndexRepositoryImpl imple } boolean removeFS_ret(TOP fs, boolean skipBagIndexes) { +if (!fs._inSetSortedIndex() && skipBagIndexes) { + return false; +} final int typeCode = fs._typeImpl.getCode(); incrementIllegalIndexUpdateDetector(typeCode); final ArrayList> idxList = getIndexesForType(typeCode).indexesForType; @@ -1311,6 +1318,10 @@ public class FSIndexRepositoryImpl imple if (this.cas.getCurrentMark() != null) { logIndexOperation(fs, ITEM_REMOVED_FROM_INDEX); } + if (skipBagIndexes || // means called for remove from all corruptable indexes + fs instanceof AnnotationBase) { // means only indexed in this index +fs._resetInSetSortedIn
svn commit: r1730860 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java
Author: schor Date: Wed Feb 17 15:38:13 2016 New Revision: 1730860 URL: http://svn.apache.org/viewvc?rev=1730860&view=rev Log: [UIMA-4664] add iteratorUnordered method to get non-rattling iterator Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java?rev=1730860&r1=1730859&r2=1730860&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java Wed Feb 17 15:38:13 2016 @@ -415,6 +415,14 @@ class FsIndex_iicp(this) : new FsIterator_aggregation_common(new FsIterator_subtypes_unordered(this).iterators, fsIndex_singletype); } + + public FSIterator iteratorUnordered() { +createIndexIteratorCache(); + +return (cachedSubFsLeafIndexes.size() == 1) + ? (FSIterator) fsIndex_singletype.iterator() + : new FsIterator_aggregation_common(new FsIterator_subtypes_unordered(this).iterators, fsIndex_singletype); + } /** * Iterator over arbitrary Feature Structures, but also filters out non-AnnotationFS FeatureStructures
svn commit: r1730868 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java
Author: schor Date: Wed Feb 17 16:36:01 2016 New Revision: 1730868 URL: http://svn.apache.org/viewvc?rev=1730868&view=rev Log: [UIMA-4674] make some fields final, change size of typecode array to shorts, and test for number of UIMA types > 32766, shorten compare method and use short values (may reduce L1 cache loading) Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java?rev=1730868&r1=1730867&r2=1730868&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java Wed Feb 17 16:36:01 2016 @@ -31,6 +31,7 @@ import org.apache.uima.cas.CASException; import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.Type; import org.apache.uima.cas.TypeSystem; +import org.apache.uima.cas.admin.CASAdminException; import org.apache.uima.cas.admin.LinearTypeOrder; import org.apache.uima.cas.admin.LinearTypeOrderBuilder; import org.apache.uima.internal.util.GraphNode; @@ -55,10 +56,10 @@ public class LinearTypeOrderBuilderImpl // be awkward and inefficient to compute it from lt. // index = orderNumber, value = type-code // used by serialization routines -private int[] order; +final private int[] order; // index= typeCode, value = order number -private int[] typeCodeToOrder; +final private short[] typeCodeToOrder; private boolean hashCodeComputed = false; @@ -92,9 +93,14 @@ public class LinearTypeOrderBuilderImpl super(); TypeSystemImpl tsi = (TypeSystemImpl) ts; this.order = typeList; - this.typeCodeToOrder = new int[this.order.length + tsi.getSmallestType()]; + final int sz = this.order.length + tsi.getSmallestType(); + if (sz > 32767) { +/** Total number of UIMA types, {0}, exceeds the maximum of 32766. **/ +throw new CASAdminException(CASAdminException.TOO_MANY_TYPES, sz - 1); + } + this.typeCodeToOrder = new short[this.order.length + tsi.getSmallestType()]; for (int i = 0; i < this.order.length; i++) { -this.typeCodeToOrder[this.order[i]] = i; +this.typeCodeToOrder[this.order[i]] = (short)i; } } @@ -105,15 +111,8 @@ public class LinearTypeOrderBuilderImpl */ @Override public int compare(FeatureStructure fs1, FeatureStructure fs2) { - if (fs1 == fs2) return 0; - - final int tc1 = fs1._getTypeCode(); - final int tc2 = fs2._getTypeCode(); - - return (tc1 == tc2) - ? 0 - : Integer.compare(typeCodeToOrder[tc1], -typeCodeToOrder[tc2]); + return Short.compare(this.typeCodeToOrder[fs1._getTypeCode()], + this.typeCodeToOrder[fs2._getTypeCode()]); } // Look-up.
svn commit: r1730858 - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl: XCASDeserializer.java XmiCasDeserializer.java
Author: schor Date: Wed Feb 17 15:22:16 2016 New Revision: 1730858 URL: http://svn.apache.org/viewvc?rev=1730858&view=rev Log: [UIMA-4697][UIMA-4674] fix xcas deser of doc annot to remove from index before updating its features. rename one method Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java?rev=1730858&r1=1730857&r2=1730858&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java Wed Feb 17 15:22:16 2016 @@ -435,7 +435,7 @@ public class XCASDeserializer { } if (ts.docType.subsumes(type)) { fs = casView.getDocumentAnnotation(); -cas.setCacheNotInIndex(fs); +cas.removeFromCorruptableIndexAnyView(fs, cas.getAddbackSingle()); } else { fs = casView.createFS(type); } @@ -494,6 +494,10 @@ public class XCASDeserializer { } } + if (ts.docType.subsumes(type)) { +cas.addbackSingle(fs); + } + if (sofaTypeCode == typecode) { Sofa sofa = (Sofa) fs; cas.getBaseIndexRepository().addFS(sofa); Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java?rev=1730858&r1=1730857&r2=1730858&view=diff == --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java Wed Feb 17 15:22:16 2016 @@ -852,7 +852,7 @@ public class XmiCasDeserializer { // we do this once, before the feature setting loop, because that loop may set a sofa Ref which is // invalid (to be fixed up later). But the removal code needs a valid sofa ref. if (!isNewFs || fs._getTypeCode() == TypeSystemImpl.docTypeCode) { -casBeingFilled.removeFromCorruptableIndexAnyViewSetCache(fs, casBeingFilled.getAddbackSingle()); +casBeingFilled.removeFromCorruptableIndexAnyView(fs, casBeingFilled.getAddbackSingle()); // else clause not needed because caller does ll_createFS which sets this anyways // } else { //// need this to prevent using sofa ref before it's set