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 2014/12/09 23:15:50 UTC
svn commit: r1644207 -
/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/DeferredIndexUpdates.java
Author: schor
Date: Tue Dec 9 22:15:50 2014
New Revision: 1644207
URL: http://svn.apache.org/r1644207
Log:
[UIMA-4100] support Xmi deserialization - data structure to remember adds and removes to do after fixups/finalizes
Added:
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/DeferredIndexUpdates.java
Added: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/DeferredIndexUpdates.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/DeferredIndexUpdates.java?rev=1644207&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/DeferredIndexUpdates.java (added)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/DeferredIndexUpdates.java Tue Dec 9 22:15:50 2014
@@ -0,0 +1,73 @@
+/*
+ * 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.util.IdentityHashMap;
+
+import org.apache.uima.internal.util.PositiveIntSet;
+import org.apache.uima.internal.util.PositiveIntSet_impl;
+
+
+
+ /**
+ * for XCAS and XMI deserialization, need to remember
+ * what's being added to the indices and/or removed, because
+ * the actual FSs are not yet "fixed up" (adjusted for
+ * reference id's -> actual addresses, including the sofa refs)
+ * for non-delta updates.
+ *
+ * Workaround (2014) is to remember the information, and do the
+ * adds / removes after the fixups.
+ *
+ * The information to be remembered is:
+ * 1) the View reference (a ref to the FSIndexRepository
+ * a) for each of these, the list of FSaddrs to be added or removed
+ *
+ * The list of FSaddrs ought to be a set with no duplicates, but because
+ * it could be sourced from a hand-edited source, we cannot depend on that
+ * so we store the list as a "set" to prevent duplicates.
+ *
+ * The remove operation only removes 1 instance (in case multiple instances
+ * of the same FS are in the indices).
+ *
+ * Currently only used by XMI deserialization
+ *
+ * Constructor - done by caller - constructs IdentityHashMap
+ */
+
+@SuppressWarnings("serial")
+class DeferredIndexUpdates extends IdentityHashMap<FSIndexRepositoryImpl, PositiveIntSet> {
+
+ void addTodo(FSIndexRepositoryImpl ir, int fsAddr) {
+ getTodos(ir).add(fsAddr);
+ }
+
+ /**
+ * Does just-in-time creation of PositiveIntSet if needed before adding
+ * @param ir
+ * @param fsAddr
+ */
+ PositiveIntSet getTodos(FSIndexRepositoryImpl ir) {
+ PositiveIntSet s = get(ir);
+ if (null == s) {
+ put(ir, s = new PositiveIntSet_impl());
+ }
+ return s;
+ }
+}
\ No newline at end of file