You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2018/01/11 18:40:37 UTC
svn commit: r1820908 - in
/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima:
cas/impl/ internal/util/
Author: schor
Date: Thu Jan 11 18:40:37 2018
New Revision: 1820908
URL: http://svn.apache.org/viewvc?rev=1820908&view=rev
Log:
no Jira, change internal impl of Int2ObjHashMap to have 2 generic types
Modified:
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDesSequential.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiSerializationSharedData.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjHashMap.java
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java?rev=1820908&r1=1820907&r2=1820908&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Thu Jan 11 18:40:37 2018
@@ -171,7 +171,7 @@ public class BinaryCasSerDes {
// * For delta, the addr is the modeled addr for the full CAS including both above and below the line.
// *
// */
-// final Int2ObjHashMap<TOP> addr2fs;
+// final Int2ObjHashMap<TOP, TOP> addr2fs;
// /**
// * a map from a fs array of boolean/byte/short/long/double to its addr in the modeled aux heap
@@ -191,9 +191,9 @@ public class BinaryCasSerDes {
* updated when delta deserializing.
* reset at end of delta deserializings because multiple mods not supported
*/
- final private Int2ObjHashMap<TOP> byteAuxAddr2fsa = new Int2ObjHashMap<>(TOP.class);
- final private Int2ObjHashMap<TOP> shortAuxAddr2fsa = new Int2ObjHashMap<>(TOP.class);
- final private Int2ObjHashMap<TOP> longAuxAddr2fsa = new Int2ObjHashMap<>(TOP.class);
+ final private Int2ObjHashMap<TOP, TOP> byteAuxAddr2fsa = new Int2ObjHashMap<>(TOP.class);
+ final private Int2ObjHashMap<TOP, TOP> shortAuxAddr2fsa = new Int2ObjHashMap<>(TOP.class);
+ final private Int2ObjHashMap<TOP, TOP> longAuxAddr2fsa = new Int2ObjHashMap<>(TOP.class);
/**
* used to calculate total heap size
@@ -399,7 +399,7 @@ public class BinaryCasSerDes {
* and then maybe remove the new one (and remember which views to re-add to).
* @param heapAddr
*/
- private void maybeAddBackAndRemoveFs(int heapAddr, Int2ObjHashMap<TOP> addr2fs) {
+ private void maybeAddBackAndRemoveFs(int heapAddr, Int2ObjHashMap<TOP, TOP> addr2fs) {
if (fsStartAddr == -1) {
fssIndex = -1;
addrOfFsToBeAddedBack = -1;
@@ -424,7 +424,7 @@ public class BinaryCasSerDes {
* @param heapAddr - the heap addr
* @param bds -
*/
- private void findCorrespondingFs(int heapAddr, Int2ObjHashMap<TOP> addr2fs) {
+ private void findCorrespondingFs(int heapAddr, Int2ObjHashMap<TOP, TOP> addr2fs) {
if (fsStartAddr < heapAddr && heapAddr < fsEndAddr) {
return;
}
@@ -995,7 +995,7 @@ public class BinaryCasSerDes {
* @return heapsz (used by caller to do word alignment)
* @throws IOException
*/
- int updateAuxArrayMods(Reading r, Int2ObjHashMap<TOP> auxAddr2fsa,
+ int updateAuxArrayMods(Reading r, Int2ObjHashMap<TOP, TOP> auxAddr2fsa,
Consumer_T_int_withIOException<TOP> setter) throws IOException {
final int heapsz = r.readInt();
if (heapsz > 0) {
@@ -1596,7 +1596,7 @@ public class BinaryCasSerDes {
*/
private void createFSsFromHeaps(boolean isDelta, int startPos, CommonSerDesSequential csds) {
final int heapsz = heap.getCellsUsed();
- final Int2ObjHashMap<TOP> addr2fs = csds.addr2fs;
+ final Int2ObjHashMap<TOP, TOP> addr2fs = csds.addr2fs;
tsi = baseCas.getTypeSystemImpl();
TOP fs;
TypeImpl type;
@@ -1785,7 +1785,7 @@ public class BinaryCasSerDes {
FeatureImpl feat,
List<Runnable> fixups4forwardFsRefs,
Consumer<TOP> setter,
- Int2ObjHashMap<TOP> addr2fs) {
+ Int2ObjHashMap<TOP, TOP> addr2fs) {
int a = heapFeat(heapIndex, feat);
if (a == 0) {
return;
@@ -1807,7 +1807,7 @@ public class BinaryCasSerDes {
return heap.heap[nextFsAddr + 1 + feat.getOffset()];
}
- private Sofa getSofaFromAnnotBase(int annotBaseAddr, StringHeap stringHeap2, Int2ObjHashMap<TOP> addr2fs,
+ private Sofa getSofaFromAnnotBase(int annotBaseAddr, StringHeap stringHeap2, Int2ObjHashMap<TOP, TOP> addr2fs,
CommonSerDesSequential csds) {
int sofaAddr = heapFeat(annotBaseAddr, tsi.annotBaseSofaFeat);
if (0 == sofaAddr) {
@@ -1852,7 +1852,7 @@ public class BinaryCasSerDes {
* @param slotAddr - the main heap slot addr being updated
* @param slotValue - the new value
*/
- private void updateHeapSlot(BinDeserSupport bds, int slotAddr, int slotValue, Int2ObjHashMap<TOP> addr2fs) {
+ private void updateHeapSlot(BinDeserSupport bds, int slotAddr, int slotValue, Int2ObjHashMap<TOP, TOP> addr2fs) {
TOP fs = bds.fs;
TypeImpl type = fs._getTypeImpl();
if (type.isArray()) {
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java?rev=1820908&r1=1820907&r2=1820908&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java Thu Jan 11 18:40:37 2018
@@ -362,7 +362,7 @@ public class BinaryCasSerDes4 implements
* Contrast with fs2addr and addr2fs in csds - these use the pseudo v2 addresses as the int
*/
private final Obj2IntIdentityHashMap<TOP> fs2seq = new Obj2IntIdentityHashMap<TOP>(TOP.class, TOP._singleton);
-// private final Int2ObjHashMap<TOP> seq2fs = new Int2ObjHashMap<>(TOP.class);
+// private final Int2ObjHashMap<TOP, TOP> seq2fs = new Int2ObjHashMap<>(TOP.class);
/**
*
* @param cas -
@@ -1574,7 +1574,7 @@ public class BinaryCasSerDes4 implements
* Note: This may be identity map, but may not in the case for V3 where some FSs are GC'd
*/
// private final Obj2IntIdentityHashMap<TOP> fs2seq = new Obj2IntIdentityHashMap<TOP>(TOP.class, TOP.singleton);
- private final Int2ObjHashMap<TOP> seq2fs = new Int2ObjHashMap<>(TOP.class);
+ private final Int2ObjHashMap<TOP, TOP> seq2fs = new Int2ObjHashMap<>(TOP.class);
/**
* Called after header was read and determined that
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java?rev=1820908&r1=1820907&r2=1820908&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java Thu Jan 11 18:40:37 2018
@@ -367,7 +367,7 @@ public class BinaryCasSerDes6 implements
* first index: key is type code
* 2nd index: key is slot-offset number (0-based)
*/
- final private Int2ObjHashMap<long[]> prevFsWithLongValues;
+ final private Int2ObjHashMap<long[], long[]> prevFsWithLongValues;
/**
* ordered set of FSs found in indexes or linked from other found FSs.
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDesSequential.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDesSequential.java?rev=1820908&r1=1820907&r2=1820908&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDesSequential.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CommonSerDesSequential.java Thu Jan 11 18:40:37 2018
@@ -74,7 +74,7 @@ public class CommonSerDesSequential {
* For delta, the addr is the modeled addr for the full CAS including both above and below the line.
*
*/
- final Int2ObjHashMap<TOP> addr2fs = new Int2ObjHashMap<>(TOP.class);
+ final Int2ObjHashMap<TOP, TOP> addr2fs = new Int2ObjHashMap<>(TOP.class);
/**
* The FSs in this list are not necessarily sequential, but is in ascending (simulated heap) order,
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiSerializationSharedData.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiSerializationSharedData.java?rev=1820908&r1=1820907&r2=1820908&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiSerializationSharedData.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiSerializationSharedData.java Thu Jan 11 18:40:37 2018
@@ -78,7 +78,7 @@ public class XmiSerializationSharedData
* getFsAddrForXmiId() method, necessary to support merging multiple XMI
* CASes into the same CAS object.
**/
- private Int2ObjHashMap<TOP> xmiIdToFs = new Int2ObjHashMap<>(TOP.class);
+ private Int2ObjHashMap<TOP, TOP> xmiIdToFs = new Int2ObjHashMap<>(TOP.class);
/**
* List of OotsElementData objects, each of which captures information about
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjHashMap.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjHashMap.java?rev=1820908&r1=1820907&r2=1820908&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjHashMap.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjHashMap.java Thu Jan 11 18:40:37 2018
@@ -50,7 +50,7 @@ import org.apache.uima.util.impl.Constan
* A cleanout of removed items occurs when necessary.
*
*/
-public class Int2ObjHashMap<T> extends Common_hash_support implements Iterable<IntEntry<T>>{
+public class Int2ObjHashMap<T, E extends T> extends Common_hash_support implements Iterable<IntEntry<E>>{
private static final int REMOVED_KEY = Integer.MIN_VALUE;
@@ -503,14 +503,24 @@ public class Int2ObjHashMap<T> extends C
};
}
- public Int2ObjHashMap<T> copy() {
+ public T[] valuesArray() {
+ Iterator<T> it = values();
+ int size = size();
+ T[] r = (T[]) Array.newInstance(componentType, size);
+ for (int i = 0; i < size; i++) {
+ r[i] = it.next();
+ }
+ return r;
+ }
+
+ public Int2ObjHashMap<T, E> copy() {
return new Int2ObjHashMap<>(this);
}
@Override
- public Iterator<IntEntry<T>> iterator() {
+ public Iterator<IntEntry<E>> iterator() {
- return new Iterator<IntEntry<T>>() {
+ return new Iterator<IntEntry<E>>() {
/**
* Keep this always pointing to a non-0 entry, or
@@ -524,11 +534,11 @@ public class Int2ObjHashMap<T> extends C
}
@Override
- public IntEntry next() {
+ public IntEntry<E> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- final IntEntry<T> r = new IntEntry<>(keys[curPosition], values[curPosition]);
+ final IntEntry<E> r = new IntEntry<E>(keys[curPosition], (E) values[curPosition]);
curPosition = moveToNextFilled(curPosition + 1);
return r;
}