[Mulgara-svn] r1429 - branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples
pag at mulgara.org
pag at mulgara.org
Mon Jan 12 21:07:00 UTC 2009
Author: pag
Date: 2009-01-12 13:07:00 -0800 (Mon, 12 Jan 2009)
New Revision: 1429
Added:
branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedStoreAppend.java
Log:
A new operation to take identically structured StoreTuples and merge them
Added: branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedStoreAppend.java
===================================================================
--- branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedStoreAppend.java (rev 0)
+++ branches/xa11/src/jar/tuples/java/org/mulgara/store/tuples/OrderedStoreAppend.java 2009-01-12 21:07:00 UTC (rev 1429)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 Fedora Commons, Inc.
+ *
+ * Licensed 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.mulgara.store.tuples;
+
+import org.mulgara.query.TuplesException;
+
+/**
+ * A class for performing appends between identically structured StoreTuples.
+ *
+ * @created Dec 17, 2008
+ * @author Paul Gearon
+ * @copyright © 2005 <a href="http://www.fedora-commons.org/">Fedora Commons</a>
+ */
+public class OrderedStoreAppend extends OrderedAppend implements StoreTuples {
+
+ /**
+ * @param operands
+ * @throws TuplesException
+ */
+ public OrderedStoreAppend(StoreTuples[] operands) throws TuplesException {
+ super(operands);
+ assert operands.length >= 2 : "Performing join on fewer than 2 operands";
+ assert operandsMatch(operands) : "Operands do not match in OrderedStoreAppend";
+ }
+
+ /**
+ * @see org.mulgara.store.tuples.StoreTuples#getColumnOrder()
+ */
+ public int[] getColumnOrder() {
+ return ((StoreTuples)operands[0]).getColumnOrder();
+ }
+
+ /**
+ * Test if all the operands match, like they are supposed to.
+ * @param operands The operands to test.
+ * @return <code>true</code> iff the operands all share column ordering.
+ */
+ private boolean operandsMatch(StoreTuples[] operands) {
+ int[] order = operands[0].getColumnOrder();
+ for (int i = 1; i < operands.length; i++) {
+ int[] newOrder = operands[i].getColumnOrder();
+ if (newOrder.length != order.length) return false;
+ for (int c = 0; c < order.length; c++) if (newOrder[c] != order[c]) return false;
+ }
+ return true;
+ }
+
+}
More information about the Mulgara-svn
mailing list