Author: schor Date: Mon Nov 2 21:46:49 2015 New Revision: 1712167 URL: http://svn.apache.org/viewvc?rev=1712167&view=rev Log: [UIMA-4663] change id()() to id() - bad change-all from earlier.
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FeatureStructure.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.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_set_sorted.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_singletype.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_subtypes_ordered.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIterator.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonArray.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FeatureStructure.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FeatureStructure.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FeatureStructure.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FeatureStructure.java Mon Nov 2 21:46:49 2015 @@ -353,6 +353,6 @@ public interface FeatureStructure { * return the unique (to this CAS) id of this feature structure */ - int id()(); + int id(); } Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Mon Nov 2 21:46:49 2015 @@ -37,6 +37,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; +import java.util.function.IntSupplier; +import java.util.function.Supplier; import org.apache.uima.UIMAFramework; import org.apache.uima.UIMARuntimeException; @@ -1143,7 +1145,7 @@ public class CASImpl extends AbstractCas * @param nbrOfConsecutive */ private void logFSUpdate(FeatureStructureImplC fs, FeatureImpl fi, int arrayIndexStart, int nbrOfConsecutive) { - if (this.svd.trackingMark != null && !this.svd.trackingMark.isNew(fs.id()())) { + if (this.svd.trackingMark != null && !this.svd.trackingMark.isNew(fs.id())) { //log the FS //create or use last FsChange element @@ -1208,7 +1210,6 @@ public class CASImpl extends AbstractCas /* * Support code for JCas setters */ - public void setWithCheckAndJournal(FeatureStructureImplC fs, int featCode, Runnable setter) { boolean wasRemoved = checkForInvalidFeatureSetting(fs, featCode); setter.run(); @@ -1218,6 +1219,22 @@ public class CASImpl extends AbstractCas maybeLogUpdate(fs, featCode); } + /** + * This method called by setters in JCas gen'd classes when + * the setter must check for journaling and index corruption + * @param fs + * @param featCode + * @param setter + */ + public void setWithCheckAndJournal(FeatureStructureImplC fs, IntSupplier featCodeSupplier, Runnable setter) { + boolean wasRemoved = checkForInvalidFeatureSetting(fs, featCodeSupplier); + setter.run(); + if (wasRemoved) { + maybeAddback(fs); + } + maybeLogUpdate(fs, featCodeSupplier.getAsInt()); + } + // public void setWithCheck(FeatureStructureImplC fs, FeatureImpl feat, Runnable setter) { // boolean wasRemoved = checkForInvalidFeatureSetting(fs, feat); // setter.run(); @@ -1226,11 +1243,23 @@ public class CASImpl extends AbstractCas // } // } + /** + * This method called by setters in JCas gen'd classes when + * the setter must check for journaling + * @param fs + * @param fi + * @param setter + */ public void setWithJournal(FeatureStructureImplC fs, FeatureImpl fi, Runnable setter) { setter.run(); maybeLogUpdate(fs, fi); } + public void setWithJournal(FeatureStructureImplC fs, Supplier<FeatureImpl> fiSupplier, Runnable setter) { + setter.run(); + maybeLogUpdate(fs, fiSupplier); + } + /** * * @param fs the Feature Structure being updated @@ -1248,6 +1277,13 @@ public class CASImpl extends AbstractCas this.logFSUpdate(fs, feat); } } + + public void maybeLogUpdate(FeatureStructureImplC fs, Supplier<FeatureImpl> featSupplier) { + if (this.svd.trackingMark != null) { + this.logFSUpdate(fs, featSupplier.get()); + } + } + public void maybeLogUpdate(FeatureStructureImplC fs, int featCode) { if (this.svd.trackingMark != null) { @@ -1926,7 +1962,7 @@ public class CASImpl extends AbstractCas Type ti = getTypeSystemImpl().ll_getTypeForCode(typeCode); TOP fs = createFS(ti); svd.cache_not_in_index = fs; - return fs.id()(); + return fs.id(); } public final int ll_createFS(int typeCode, boolean doCheck) { @@ -1945,7 +1981,7 @@ public class CASImpl extends AbstractCas * @see org.apache.uima.cas.impl.LowLevelCAS#ll_createArray(int, int) */ public int ll_createArray(int typeCode, int arrayLength) { - return createArray(typeCode, arrayLength).id()(); + return createArray(typeCode, arrayLength).id(); } public int ll_createByteArray(int arrayLength) { @@ -2010,7 +2046,7 @@ public class CASImpl extends AbstractCas if (null == fs) { return NULL; } - return ((FeatureStructureImplC)fs).id()(); + return ((FeatureStructureImplC)fs).id(); } @SuppressWarnings("unchecked") @@ -2039,11 +2075,11 @@ public class CASImpl extends AbstractCas } public final int ll_getRefValue(int fsRef, int featureCode) { - return getFsFromId_checked(fsRef).getFeatureValue(getTypeSystemImpl().getFeatureForCode_checked(featureCode)).id()(); + return getFsFromId_checked(fsRef).getFeatureValue(getTypeSystemImpl().getFeatureForCode_checked(featureCode)).id(); } public final int ll_getRefValueFeatOffset(int fsRef, int featureOffset) { - return ((FeatureStructureImplC)getFsFromId_checked(fsRef)._refData[featureOffset]).id()(); + return ((FeatureStructureImplC)getFsFromId_checked(fsRef)._refData[featureOffset]).id(); } public final int ll_getIntValue(int fsRef, int featureCode, boolean doTypeChecks) { @@ -2136,7 +2172,25 @@ public class CASImpl extends AbstractCas if (IS_DISABLED_PROTECT_INDEXES && ssz == 0) { return false; } + + return checkForInvalidFeatureSettingCommon(fs, featCode, ssz); + } + + private boolean checkForInvalidFeatureSetting(FeatureStructureImplC fs, IntSupplier featCodeSupplier) { + if (fs == svd.cache_not_in_index) { + return false; + } + + final int ssz = svd.fssTobeAddedback.size(); + // skip if protection is disabled, and no explicit protection block + if (IS_DISABLED_PROTECT_INDEXES && ssz == 0) { + return false; + } + return checkForInvalidFeatureSettingCommon(fs, featCodeSupplier.getAsInt(), ssz); + } + + private boolean checkForInvalidFeatureSettingCommon(FeatureStructureImplC fs, int featCode, int ssz) { // next method skips if the fsRef is not in the index (cache) final boolean wasRemoved = removeFromCorruptableIndexAnyView( fs, @@ -2144,7 +2198,6 @@ public class CASImpl extends AbstractCas svd.fsTobeAddedbackSingle, featCode); - // skip message if wasn't removed // skip message if protected in explicit block if (wasRemoved && IS_REPORT_FS_UPDATE_CORRUPTS_INDEX && ssz == 0) { @@ -2431,7 +2484,7 @@ public class CASImpl extends AbstractCas } public final int ll_getRefArrayValue(int fsRef, int position) { - return ((TOP)getRefArrayValue(((FSArray)getFsFromId_checked(fsRef)), position)).id()(); + return ((TOP)getRefArrayValue(((FSArray)getFsFromId_checked(fsRef)), position)).id(); } private void throwAccessTypeError(int fsRef, int typeCode) { @@ -2994,7 +3047,7 @@ public class CASImpl extends AbstractCas } public int ll_createAnnotation(int typeCode, int begin, int end) { - return createAnnotation(getTypeSystemImpl().getTypeForCode(typeCode), begin, end).id()(); + return createAnnotation(getTypeSystemImpl().getTypeForCode(typeCode), begin, end).id(); } /** @@ -3118,7 +3171,7 @@ public class CASImpl extends AbstractCas FSIterator<FeatureStructure> it = getIndexRepository().getIndex(CAS.STD_ANNOTATION_INDEX, getTypeSystemImpl().docType).iterator(); if (it.isValid()) { - return it.get().id()(); + return it.get().id(); } return 0; } @@ -3186,7 +3239,7 @@ public class CASImpl extends AbstractCas * @return the addr of the sofaFS associated with this view, or 0 */ public int ll_getSofa() { - return mySofaIsValid() ? mySofaRef.id()() : 0; + return mySofaIsValid() ? mySofaRef.id() : 0; } public String getViewName() { Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSsTobeAddedback.java Mon Nov 2 21:46:49 2015 @@ -62,7 +62,7 @@ abstract class FSsTobeAddedback implemen private void logPart(FeatureStructureImplC fs, FSIndexRepositoryImpl view) { log(view); - System.out.format(", fs_id = %,d", fs.id()()); + System.out.format(", fs_id = %,d", fs.id()); } protected void log(FeatureStructureImplC fs, FSIndexRepositoryImpl view, int count) { 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=1712167&r1=1712166&r2=1712167&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 Mon Nov 2 21:46:49 2015 @@ -224,7 +224,7 @@ public class FeatureStructureImplC imple public final int getAddress() { return _id; }; @Override - public final int id()() {return _id; }; + public final int id() {return _id; }; // backwards compatibility @Override Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java Mon Nov 2 21:46:49 2015 @@ -83,7 +83,7 @@ public class FsIndex_bag<T extends Featu * For bag indexes, compare equal only if identical addresses */ public int compare(FeatureStructure fs1, FeatureStructure fs2) { - return (fs1 == fs2) ? 0 : (fs1.id()() < fs2.id()()) ? -1 : 1; + return (fs1 == fs2) ? 0 : (fs1.id() < fs2.id()) ? -1 : 1; } /* 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=1712167&r1=1712166&r2=1712167&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 Mon Nov 2 21:46:49 2015 @@ -140,7 +140,7 @@ public class FsIndex_flat<T extends Feat // ordered case // r is index if found, otherwise, (-(insertion point) - 1). - int r = Arrays.binarySearch(indexedFSs, (FeatureStructureImplC) fs, (FeatureStructureImplC f1, FeatureStructureImplC f2) -> Integer.compare(f1.id()(), f2.id()())); + int r = Arrays.binarySearch(indexedFSs, (FeatureStructureImplC) fs, (FeatureStructureImplC f1, FeatureStructureImplC f2) -> Integer.compare(f1.id(), f2.id())); return (r == 0) ? fs : null; } Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java Mon Nov 2 21:46:49 2015 @@ -60,7 +60,7 @@ public class FsIndex_set_sorted<T extend (FeatureStructure o1, FeatureStructure o2) -> { final int c = compare(o1, o2); // augment normal comparator with one that compares IDs if everything else equal - return (c == 0) ? (Integer.compare(o1.id()(), o2.id()())) : c;}) + return (c == 0) ? (Integer.compare(o1.id(), o2.id())) : c;}) : new TreeSet<FeatureStructure>( (FeatureStructure o1, FeatureStructure o2) -> compare(o1, o2)); } @@ -188,7 +188,7 @@ public class FsIndex_set_sorted<T extend @Override protected void bulkAddTo(IntVector v) { - this.indexedFSs.stream().mapToInt(fs -> ((FeatureStructureImplC)fs).id()()).forEach(v::add); + this.indexedFSs.stream().mapToInt(fs -> ((FeatureStructureImplC)fs).id()).forEach(v::add); } NavigableSet<FeatureStructure> getNavigableSet() { //used by FsIterator_sorted to compute various derivitive nav sets Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_singletype.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_singletype.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_singletype.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_singletype.java Mon Nov 2 21:46:49 2015 @@ -52,7 +52,7 @@ public abstract class FsIterator_singlet if (comparator != null) { return comparator.compare(this.get(), o.get()); } - return Integer.compare(this.get().id()(), o.get().id()()); + return Integer.compare(this.get().id(), o.get().id()); } @Override Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_subtypes_ordered.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_subtypes_ordered.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_subtypes_ordered.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIterator_subtypes_ordered.java Mon Nov 2 21:46:49 2015 @@ -240,7 +240,7 @@ public class FsIterator_subtypes_ordered // addresses. We need to do this in order to be able to ensure that a // reverse iterator produces the reverse order of the forward iterator. if (d == 0) { - d = fsLeft.id()() - fsRight.id()(); + d = fsLeft.id() - fsRight.id(); } return d * dir < 0; } Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIterator.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIterator.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIterator.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIterator.java Mon Nov 2 21:46:49 2015 @@ -42,7 +42,7 @@ public interface LowLevelIterator<T exte * Iff the iterator is not valid. */ default int ll_get() throws NoSuchElementException { - return get().id()(); + return get().id(); }; /** Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java Mon Nov 2 21:46:49 2015 @@ -57,7 +57,7 @@ public class MarkerImpl implements Marke if (!isValid || !cas.isInCAS(fs)) { throw new CASRuntimeException(CASRuntimeException.CAS_MISMATCH, "FS and Marker are not from the same CAS."); } - return isNew(fs.id()()); + return isNew(fs.id()); } public boolean isModified(FeatureStructure aFs) { Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java Mon Nov 2 21:46:49 2015 @@ -132,7 +132,7 @@ public class Subiterator<T extends Annot this.fsIndexRepo = fsIndexRepo; moveToStart(); - startId = isValid() ? get().id()() : 0; + startId = isValid() ? get().id() : 0; } @@ -159,7 +159,7 @@ public class Subiterator<T extends Annot private void moveToExact(T targetAnnotation) { it.moveTo(targetAnnotation); // move to left-most equal one while (it.isValid()) { // advance to the exact equal one - if (targetAnnotation.id()() == it.get().id()()) { + if (targetAnnotation.id() == it.get().id()) { break; } it.moveToNext(); @@ -338,7 +338,7 @@ public class Subiterator<T extends Annot return; } - if (isValid() && it.get().id()() == startId) { + if (isValid() && it.get().id() == startId) { it.moveToFirst(); it.moveToPrevious(); // make it invalid } else { Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonArray.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonArray.java?rev=1712167&r1=1712166&r2=1712167&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonArray.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonArray.java Mon Nov 2 21:46:49 2015 @@ -32,5 +32,5 @@ public interface CommonArray { void copyValuesFrom(CommonArray v); - int id()(); + int id(); }