X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fcluster%2FForeignTable.java;fp=bundles%2Forg.simantics.db.procore%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fprocore%2Fcluster%2FForeignTable.java;h=474e5b8a58502365d6c4f2da166a5960f125908d;hp=6fab99615d16b03d37856580cb0c281f8ddd4cec;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ForeignTable.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ForeignTable.java index 6fab99615..474e5b8a5 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ForeignTable.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ForeignTable.java @@ -1,152 +1,152 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db.procore.cluster; - -import gnu.trove.map.hash.TObjectIntHashMap; - -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.impl.ClusterI.Procedure; -import org.simantics.db.impl.ClusterSupport; -import org.simantics.db.impl.Modifier; -import org.simantics.db.impl.Table; -import org.simantics.db.impl.TableFactory; -import org.simantics.db.impl.TableSizeListener; -import org.simantics.db.service.ClusterUID; -import org.simantics.db.service.ResourceUID; - -final class ForeignElement { - private static final int CLUSTER_OFFSET = 0; // resourceUID - private static final int SIZE_OF = 3; - - static void constructForeign(long[] table, int index, ResourceUID resourceUID) { - int i = CLUSTER_OFFSET + index; - resourceUID.toLong(table, i); - } - static void destructForeign(long[] table, int index) { - int i = CLUSTER_OFFSET + index; - table[i++] = 0; - table[i++] = 0; - table[i++] = 0; - } - static int getSizeOf() { - return SIZE_OF; - } - static ResourceUID getResourceUID(long[] table, int index) { - int i = CLUSTER_OFFSET + index; - return new ResourceUID(table, i); - } - static void fillResourceUID(long[] table, int index, ClusterSmall cluster) { - int i = CLUSTER_OFFSET + index; - cluster.clusterUID1 = table[i]; - cluster.clusterUID2 = table[i+1]; - cluster.executeIndex = (short)table[i+2]; - } -} - -public final class ForeignTable extends Table -{ - public ForeignTable(TableSizeListener sizeListener, int[] header, int headerBase) { - super(TableFactory.getLongFactory(), sizeListener, header, headerBase); - } - public ForeignTable(TableSizeListener sizeListener, int[] header, int headerBase, long[] longs) { - super(TableFactory.getLongFactory(), sizeListener, header, headerBase, longs); - } - public int getUsedSize() { - return getTableCount(); - } - TObjectIntHashMap getHashMap() - throws DatabaseException { - int ELEMENT_SIZE = ForeignElement.getSizeOf(); - final int TABLE_SIZE = getTableCount(); - final int FOREIGN_COUNT = getForeignCount(); - final int BASE = this.getTableBase(); - final int TOP = BASE + TABLE_SIZE * ELEMENT_SIZE; - long[] table = this.getTable(); - int count = 0; - int index = ZERO_SHIFT; - TObjectIntHashMap hm = new TObjectIntHashMap(FOREIGN_COUNT); - for (int i=BASE; i getResourceHashMap() - throws DatabaseException { - int ELEMENT_SIZE = ForeignElement.getSizeOf(); - assert(ELEMENT_SIZE == 3); - final int TABLE_SIZE = getTableCount(); - final int FOREIGN_COUNT = getForeignCount(); - final int BASE = this.getTableBase(); - final int TOP = BASE + TABLE_SIZE * ELEMENT_SIZE; - long[] table = this.getTable(); - int count = 0; - int index = ZERO_SHIFT; - TObjectIntHashMap hm = new TObjectIntHashMap(FOREIGN_COUNT); - for (int i=BASE; i getResourceHashMap() + throws DatabaseException { + int ELEMENT_SIZE = ForeignElement.getSizeOf(); + assert(ELEMENT_SIZE == 3); + final int TABLE_SIZE = getTableCount(); + final int FOREIGN_COUNT = getForeignCount(); + final int BASE = this.getTableBase(); + final int TOP = BASE + TABLE_SIZE * ELEMENT_SIZE; + long[] table = this.getTable(); + int count = 0; + int index = ZERO_SHIFT; + TObjectIntHashMap hm = new TObjectIntHashMap(FOREIGN_COUNT); + for (int i=BASE; i