Return-Path: X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 32CDE9418 for ; Sun, 18 Dec 2011 08:27:14 +0000 (UTC) Received: (qmail 51612 invoked by uid 500); 18 Dec 2011 08:27:13 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 51541 invoked by uid 500); 18 Dec 2011 08:27:08 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 51533 invoked by uid 99); 18 Dec 2011 08:27:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Dec 2011 08:27:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Dec 2011 08:27:00 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EAD8923888E7; Sun, 18 Dec 2011 08:26:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1220349 [1/6] - in /incubator/lcf/branches/CONNECTORS-286/warthog-reimport: ./ lib/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/warthog/ src/main/java/org/apache/warthog/api/ src/main... Date: Sun, 18 Dec 2011 08:26:34 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111218082639.EAD8923888E7@eris.apache.org> Author: kwright Date: Sun Dec 18 08:26:30 2011 New Revision: 1220349 URL: http://svn.apache.org/viewvc?rev=1220349&view=rev Log: SVN messed up and won't actually allow me to commit a reorganization without errors so I am importing it by hand. Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/build.xml incubator/lcf/branches/CONNECTORS-286/warthog-reimport/lib/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/lib/junit-4.7.jar (with props) incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateRelationship.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnBreakOnChange.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMax.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMin.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAfter.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBefore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBetween.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterCriteria.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEquals.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsMultiple.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrAfter.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrBefore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationship.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationshipBuilder.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterSubquery.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexAfter.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBefore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBetween.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexCriteria.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEquals.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsMultiple.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrAfter.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrBefore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationship.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationshipBuilder.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinRelationship.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipRelationship.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnCalculator.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnDescription.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHComparator.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHConcurrencyException.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHException.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHIndex.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationship.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationshipBuilder.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRowID.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTable.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTableStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHUniqueConstraintViolationException.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHAtomicByteKeyValueStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyIterator.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyMap.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BooleanValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BufferPointer.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterArray.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ColumnCount.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ColumnSumLong.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/IntegerKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/IntegerValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/LongArray.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/LongComparatorAscending.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/LongKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/LongValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/StringArray.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/StringComparatorAscending.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/StringKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/StringValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvalue/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvalue/WHAtomicKeyValueStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvalue/WHKeyIterator.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvalue/WHKeyMap.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/GeneralIDFactoryKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/Index.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexLookupKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNameKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNodeColumnKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNodeEqualsKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNodeGreaterKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNodeKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNodeLesserKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexNodeParentKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexRootKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/IndexValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/Table.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableAccessor.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableBaseKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableColumnKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableHeadKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableIndexKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHTransaction.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHTransactionalStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemAtomicByteKeyValueStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemAtomicNativeKeyValueStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemByteTransactionImpl.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemByteTransactionalStoreImpl.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemNativeTransactionImpl.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemNativeTransactionalStoreImpl.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/build.xml URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/build.xml?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/build.xml (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/build.xml Sun Dec 18 08:26:30 2011 @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/lib/junit-4.7.jar URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/lib/junit-4.7.jar?rev=1220349&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/lib/junit-4.7.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateAccessor.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateAccessor.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateAccessor.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateAccessor.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,178 @@ +/* $Id: AggregateAccessor.java -1 $ */ + +/** +* 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.warthog.api; + +import java.util.*; + +/** Accessor class that returns aggregate rows. +*/ +public class AggregateAccessor implements WHAccessor +{ + protected WHAccessor baseAccessor; + protected WHColumnCalculator[] returnColumnCalculators; + protected String[] returnColumnNames; + protected WHRowID currentRowID; + protected long nextRowNumber = 0L; + protected boolean finalRowRendered = false; + + protected Map currentRowValues = new HashMap(); + + public AggregateAccessor(WHAccessor baseAccessor, WHColumnCalculator[] returnColumnCalculators, String[] returnColumnNames) + throws WHException + { + this.baseAccessor = baseAccessor; + this.returnColumnCalculators = returnColumnCalculators; + this.returnColumnNames = returnColumnNames; + goToNextLegalRow(); + } + + protected void goToNextLegalRow() + throws WHException + { + while (true) + { + WHRowID baseRowID = baseAccessor.getCurrentRowID(); + if (baseRowID == null) + { + if (!finalRowRendered) + { + finalRowRendered = true; + // End! Tally all rows; there may a row of data we need to return still. + boolean seenNoValue = false; + for (int i = 0 ; i < returnColumnCalculators.length ; i++) + { + if (returnColumnCalculators[i].canGenerateSummaryValue() == false) + seenNoValue = true; + } + + if (!seenNoValue) + { + if (tallyCalculators()); + { + currentRowID = new LongRowID(nextRowNumber); + return; + } + } + } + // No final row + currentRowID = null; + currentRowValues = null; + return; + } + // Feed the row into all the calculators. If a value emerges from any one of them, demand a value + // from ALL of them and set up a new row. + boolean seenValue = false; + for (int i = 0 ; i < returnColumnCalculators.length ; i++) + { + if (returnColumnCalculators[i].canProcessRowValue(baseAccessor) == false) + seenValue = true; + } + + if (seenValue) + { + if (tallyCalculators()) + { + currentRowID = new LongRowID(nextRowNumber); + nextRowNumber++; + // By returning, we guarantee that the same base accessor row will be + // used again, which is part of the contract. + return; + } + } + + // Add in the row to all column calculators + for (int i = 0 ; i < returnColumnCalculators.length ; i++) + { + returnColumnCalculators[i].processRowValue(baseAccessor); + } + + // Go process the next base accessor row + baseAccessor.advance(); + } + } + + protected boolean tallyCalculators() + throws WHException + { + WHValue[] calculatedValues = new WHValue[returnColumnCalculators.length]; + boolean seenValue = false; + boolean seenNoValue = false; + for (int i = 0 ; i < returnColumnCalculators.length ; i++) + { + calculatedValues[i] = returnColumnCalculators[i].tally(); + if (calculatedValues[i] != null) + seenValue = true; + else + seenNoValue = true; + } + if (seenValue && seenNoValue) + throw new WHException("Column calculators cannot tally consistently"); + + if (seenValue) + { + currentRowValues.clear(); + for (int i = 0 ; i < returnColumnCalculators.length ; i++) + { + currentRowValues.put(returnColumnNames[i],calculatedValues[i]); + } + } + return seenValue; + } + + /** Advance to the next row. + */ + public void advance() + throws WHException + { + if (currentRowID != null) + { + goToNextLegalRow(); + } + } + + /** Read the current relationship row ID, Null will be returned if we are + * at the end of the sequence. + */ + public WHRowID getCurrentRowID() + throws WHException + { + return currentRowID; + } + + /** Get the data for the current row and specified column. + */ + public WHValue getValue(String columnName) + throws WHException + { + if (currentRowID != null) + return currentRowValues.get(columnName); + throw new WHException("Can't read beyond end of accessor"); + } + + protected static class LongRowID implements WHRowID + { + protected long value; + + public LongRowID(long value) + { + this.value = value; + } + } +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateRelationship.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateRelationship.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateRelationship.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/AggregateRelationship.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,68 @@ +/* $Id: AggregateRelationship.java -1 $ */ + +/** +* 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.warthog.api; + +/** This relationship type applies column aggregation and row aggregation +* capabilities. +*/ +public class AggregateRelationship implements WHRelationship +{ + protected WHRelationship relationshipToAggregate; + protected WHColumnDescription[] returnColumnCalculators; + protected String[] returnColumnNames; + + /** Constructor */ + public AggregateRelationship(WHRelationship relationshipToAggregate, + WHColumnDescription[] returnColumnCalculators) + throws WHException + { + this.relationshipToAggregate = relationshipToAggregate; + this.returnColumnCalculators = returnColumnCalculators; + // Calculate the return column names + returnColumnNames = new String[returnColumnCalculators.length]; + for (int i = 0 ; i < returnColumnCalculators.length ; i++) + { + returnColumnNames[i] = returnColumnCalculators[i].getReturnColumnName(); + } + } + + /** Get the column names represented by the relationship. */ + public String[] getColumnNames() + throws WHException + { + return returnColumnNames; + } + + /** Get the row accessor. This determines + * both the initial set of rows and the ordering. The results can be later filtered to + * yield the final output data. + */ + public WHAccessor buildAccessor() + throws WHException + { + WHColumnCalculator[] calculators = new WHColumnCalculator[returnColumnCalculators.length]; + for (int i = 0 ; i < calculators.length ; i++) + { + calculators[i] = returnColumnCalculators[i].createCalculator(); + } + return new AggregateAccessor(relationshipToAggregate.buildAccessor(),calculators,returnColumnNames); + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnBreakOnChange.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnBreakOnChange.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnBreakOnChange.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnBreakOnChange.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,114 @@ +/* $Id: ColumnBreakOnChange.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class is used to create a column upon which presorted aggregation works. +* By signaling when the value changes from row to row, this column definition creates +* "buckets". which can be used for both DISTINCT and GROUP BY functionality, +* as long as the rows returned by the underlying accessor are ordered by the column +* being selected. +*/ +public class ColumnBreakOnChange implements WHColumnDescription +{ + protected String baseColumnName; + protected String returnColumnName; + + /** Constructor */ + public ColumnBreakOnChange(String baseColumnName, String returnColumnName) + { + this.baseColumnName = baseColumnName; + this.returnColumnName = returnColumnName; + } + + /** Get the name of the return column */ + public String getReturnColumnName() + throws WHException + { + return returnColumnName; + } + + /** Create a return column calculator for this column. + */ + public WHColumnCalculator createCalculator() + throws WHException + { + return new BreakCalculator(baseColumnName); + } + + protected static class BreakCalculator implements WHColumnCalculator + { + protected String baseColumnName; + + protected WHValue previousValue = null; + + public BreakCalculator(String baseColumnName) + { + this.baseColumnName = baseColumnName; + } + + /** Check whether a row can be added to to the column calculator. + * Does NOT actually change the result of the calculator! + *@return true if the row can be added and false if a tally should be done immediately. + */ + public boolean canProcessRowValue(WHAccessor accessor) + throws WHException + { + if (previousValue == null) + return true; + WHValue newValue = accessor.getValue(baseColumnName); + if (newValue.equals(previousValue)) + return true; + return false; + } + + /** Check whether this calculator is capable of generating a final summary row value. + *@return true if it is capable. tally() will only be called at the end for the summary + * row if all columns are capable of generating a summary value. + */ + public boolean canGenerateSummaryValue() + throws WHException + { + return (previousValue != null); + } + + /** Feed a row to the column calculator. + */ + public void processRowValue(WHAccessor accessor) + throws WHException + { + previousValue = accessor.getValue(baseColumnName); + } + + /** Tally a final result, obtaining whatever current aggregate value there is. + * Also resets the calculator in preparation for another set of rows. + */ + public WHValue tally() + throws WHException + { + WHValue rval = previousValue; + previousValue = null; + return rval; + } + + } + +} + + \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMax.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMax.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMax.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMax.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,127 @@ +/* $Id: ColumnMax.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class is used to create a column which finds the max of values found in the specified +* base column. +*/ +public class ColumnMax implements WHColumnDescription +{ + protected WHComparator comparator; + protected String baseColumnName; + protected String returnColumnName; + + /** Constructor */ + public ColumnMax(WHComparator comparator, String baseColumnName, String returnColumnName) + { + this.comparator = comparator; + this.baseColumnName = baseColumnName; + this.returnColumnName = returnColumnName; + } + + /** Get the name of the return column */ + public String getReturnColumnName() + throws WHException + { + return returnColumnName; + } + + /** Create a return column calculator for this column. + */ + public WHColumnCalculator createCalculator() + throws WHException + { + return new MaxCalculator(comparator,baseColumnName); + } + + protected static class MaxCalculator implements WHColumnCalculator + { + protected WHComparator comparator; + protected String baseColumnName; + + protected boolean firstValue = true; + protected WHValue max = null; + + public MaxCalculator(WHComparator comparator, String baseColumnName) + { + this.comparator = comparator; + this.baseColumnName = baseColumnName; + } + + /** Check whether a row can be added to to the column calculator. + * Does NOT actually change the result of the calculator! + *@return true if the row can be added and false if a tally should be done immediately. + */ + public boolean canProcessRowValue(WHAccessor accessor) + throws WHException + { + // This calculator can always accept new values + return true; + } + + /** Check whether this calculator is capable of generating a final summary row value. + *@return true if it is capable. tally() will only be called at the end for the summary + * row if all columns are capable of generating a summary value. + */ + public boolean canGenerateSummaryValue() + throws WHException + { + // This calculator can only generate a summary value if there's at least one row + return !firstValue; + } + + /** Feed a row to the column calculator. + */ + public void processRowValue(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(baseColumnName); + if (value != null) + { + if (firstValue) + { + max = value; + firstValue = false; + } + else + { + if (comparator.compare(max,value) == WHComparator.RESULT_GREATER) + max = value; + } + } + } + + /** Tally a final result, obtaining whatever current aggregate value there is. + * Also resets the calculator in preparation for another set of rows. + */ + public WHValue tally() + throws WHException + { + WHValue rval = max; + max = null; + firstValue = true; + return rval; + } + + } + +} + + \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMin.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMin.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMin.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/ColumnMin.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,127 @@ +/* $Id: ColumnMin.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class is used to create a column which finds minimum of values found in the specified +* base column. +*/ +public class ColumnMin implements WHColumnDescription +{ + protected WHComparator comparator; + protected String baseColumnName; + protected String returnColumnName; + + /** Constructor */ + public ColumnMin(WHComparator comparator, String baseColumnName, String returnColumnName) + { + this.comparator = comparator; + this.baseColumnName = baseColumnName; + this.returnColumnName = returnColumnName; + } + + /** Get the name of the return column */ + public String getReturnColumnName() + throws WHException + { + return returnColumnName; + } + + /** Create a return column calculator for this column. + */ + public WHColumnCalculator createCalculator() + throws WHException + { + return new MinCalculator(comparator,baseColumnName); + } + + protected static class MinCalculator implements WHColumnCalculator + { + protected WHComparator comparator; + protected String baseColumnName; + + protected boolean firstValue = true; + protected WHValue min = null; + + public MinCalculator(WHComparator comparator, String baseColumnName) + { + this.comparator = comparator; + this.baseColumnName = baseColumnName; + } + + /** Check whether a row can be added to to the column calculator. + * Does NOT actually change the result of the calculator! + *@return true if the row can be added and false if a tally should be done immediately. + */ + public boolean canProcessRowValue(WHAccessor accessor) + throws WHException + { + // This calculator can always accept new values + return true; + } + + /** Check whether this calculator is capable of generating a final summary row value. + *@return true if it is capable. tally() will only be called at the end for the summary + * row if all columns are capable of generating a summary value. + */ + public boolean canGenerateSummaryValue() + throws WHException + { + // This calculator can only generate a summary value if there's at least one row + return !firstValue; + } + + /** Feed a row to the column calculator. + */ + public void processRowValue(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(baseColumnName); + if (value != null) + { + if (firstValue) + { + min = value; + firstValue = false; + } + else + { + if (comparator.compare(min,value) == WHComparator.RESULT_LESS) + min = value; + } + } + } + + /** Tally a final result, obtaining whatever current aggregate value there is. + * Also resets the calculator in preparation for another set of rows. + */ + public WHValue tally() + throws WHException + { + WHValue rval = min; + min = null; + firstValue = true; + return rval; + } + + } + +} + + \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAccessor.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAccessor.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAccessor.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAccessor.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,81 @@ +/* $Id: FilterAccessor.java -1 $ */ + +/** +* 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.warthog.api; + +/** Accessor class that performs generic filtering. +*/ +public class FilterAccessor implements WHAccessor +{ + protected FilterCriteria filter; + protected WHAccessor baseAccessor; + protected WHRowID currentRowID; + + public FilterAccessor(WHAccessor baseAccessor, FilterCriteria filter) + throws WHException + { + this.baseAccessor = baseAccessor; + this.filter = filter; + goToNextLegalRow(); + } + + protected void goToNextLegalRow() + throws WHException + { + while (true) + { + currentRowID = baseAccessor.getCurrentRowID(); + if (currentRowID == null) + break; + if (filter == null || filter.include(baseAccessor)) + break; + baseAccessor.advance(); + } + } + + /** Advance to the next row. + */ + public void advance() + throws WHException + { + if (currentRowID != null) + { + baseAccessor.advance(); + goToNextLegalRow(); + } + } + + /** Read the current relationship row ID, Null will be returned if we are + * at the end of the sequence. + */ + public WHRowID getCurrentRowID() + throws WHException + { + return currentRowID; + } + + /** Get the data for the current row and specified column. + */ + public WHValue getValue(String columnName) + throws WHException + { + return baseAccessor.getValue(columnName); + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAfter.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAfter.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAfter.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterAfter.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,48 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering where a specific column is after a specific value, based +* on a comparator. +*/ +public class FilterAfter extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue matchValue; + + public FilterAfter(String columnName, WHValue matchValue, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.matchValue = matchValue; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + return comparator.compare(value,matchValue) == WHComparator.RESULT_LESS; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBefore.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBefore.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBefore.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBefore.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,48 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering where a specific column is before a specific value, based +* on a comparator. +*/ +public class FilterBefore extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue matchValue; + + public FilterBefore(String columnName, WHValue matchValue, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.matchValue = matchValue; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + return comparator.compare(value,matchValue) == WHComparator.RESULT_GREATER; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBetween.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBetween.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBetween.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterBetween.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,54 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering where a specific column is between two specific values, based +* on a comparator. +*/ +public class FilterBetween extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue afterValue; + protected WHValue beforeValue; + + public FilterBetween(String columnName, WHValue afterValue, WHValue beforeValue, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.afterValue = afterValue; + this.beforeValue = beforeValue; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + int afterResult = comparator.compare(value,afterValue); + if (afterResult != WHComparator.RESULT_LESS) + return false; + int beforeResult = comparator.compare(value,beforeValue); + return beforeResult == WHComparator.RESULT_GREATER; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterCriteria.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterCriteria.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterCriteria.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterCriteria.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,38 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This base class specifies filtering that is applied on top of an accessor. +*/ +public class FilterCriteria +{ + public FilterCriteria() + { + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + return true; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEquals.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEquals.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEquals.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEquals.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,47 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering on a specific column for a specific value. +*/ +public class FilterEquals extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue matchValue; + + public FilterEquals(String columnName, WHValue matchValue, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.matchValue = matchValue; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + return comparator.compare(value,matchValue) == WHComparator.RESULT_EQUALS; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsMultiple.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsMultiple.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsMultiple.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsMultiple.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,52 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering on a specific column for a specific set of values. +*/ +public class FilterEqualsMultiple extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue[] matchValues; + + public FilterEqualsMultiple(String columnName, WHValue[] matchValues, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.matchValues = matchValues; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + for (int i = 0 ; i < matchValues.length ; i++) + { + if (comparator.compare(value,matchValues[i]) == WHComparator.RESULT_EQUALS) + return true; + } + return false; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrAfter.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrAfter.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrAfter.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrAfter.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,49 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering where a specific column is equal to or after a specific value, based +* on a comparator. +*/ +public class FilterEqualsOrAfter extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue matchValue; + + public FilterEqualsOrAfter(String columnName, WHValue matchValue, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.matchValue = matchValue; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + int result = comparator.compare(value,matchValue); + return result == WHComparator.RESULT_LESS || result == WHComparator.RESULT_EQUALS; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrBefore.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrBefore.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrBefore.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterEqualsOrBefore.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,49 @@ +/* $Id: FilterCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class specifies filtering where a specific column is equal to or before a specific value, based +* on a comparator. +*/ +public class FilterEqualsOrBefore extends FilterCriteria +{ + protected WHComparator comparator; + protected String columnName; + protected WHValue matchValue; + + public FilterEqualsOrBefore(String columnName, WHValue matchValue, WHComparator comparator) + { + super(); + this.comparator = comparator; + this.columnName = columnName; + this.matchValue = matchValue; + } + + /** Check if a row should be filtered or not. + */ + public boolean include(WHAccessor accessor) + throws WHException + { + WHValue value = accessor.getValue(columnName); + int result = comparator.compare(value,matchValue); + return result == WHComparator.RESULT_GREATER || result == WHComparator.RESULT_EQUALS; + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationship.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationship.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationship.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationship.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,53 @@ +/* $Id: FilterRelationship.java -1 $ */ + +/** +* 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.warthog.api; + +/** This relationship type applies filtering criteria on top of another relationship. +*/ +public class FilterRelationship implements WHRelationship +{ + protected WHRelationship relationshipToFilter; + protected FilterCriteria filterer; + + /** Constructor */ + public FilterRelationship(WHRelationship relationshipToFilter, FilterCriteria filterer) + { + this.relationshipToFilter = relationshipToFilter; + this.filterer = filterer; + } + + /** Get the column names represented by the relationship. */ + public String[] getColumnNames() + throws WHException + { + return relationshipToFilter.getColumnNames(); + } + + /** Get the row accessor. This determines + * both the initial set of rows and the ordering. The results can be later filtered to + * yield the final output data. + */ + public WHAccessor buildAccessor() + throws WHException + { + return new FilterAccessor(relationshipToFilter.buildAccessor(),filterer); + } + +} Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationshipBuilder.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationshipBuilder.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationshipBuilder.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterRelationshipBuilder.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,100 @@ +/* $Id: FilterRelationshipBuilder.java -1 $ */ + +/** +* 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.warthog.api; + +import java.lang.reflect.*; + +/** Build a relationship based on another WHRelationshipBuilder with an applied filter. +*/ +public class FilterRelationshipBuilder implements WHRelationshipBuilder +{ + protected WHRelationshipBuilder baseRelationshipBuilder; + protected FilterCriteria filterer; + protected String columnToFilter; + protected String filterClassName; + protected String matchColumnName; + protected WHComparator comparator; + + /** Constructor. + * Can be called on one of two ways. Either filterer is null and matchColumnName, columnToFilter, and filterClassName + * are set, or filterer is non-null. The class specified by filterClassName will be instantiated + * using the XXX(columnName, value) constructor. + */ + public FilterRelationshipBuilder(WHRelationshipBuilder baseRelationshipBuilder, + FilterCriteria filterer, String matchColumnName, String filterClassName, String columnToFilter, + WHComparator comparator) + throws WHException + { + this.baseRelationshipBuilder = baseRelationshipBuilder; + this.filterer = filterer; + this.columnToFilter = columnToFilter; + this.filterClassName = filterClassName; + this.matchColumnName = matchColumnName; + this.comparator = comparator; + } + + /** Construct a relationship based on the specified accessor row. + */ + public WHRelationship createRelationship(WHAccessor accessor) + throws WHException + { + // Build the base accessor using the accessor builder we've been handed + WHRelationship baseRelationship = baseRelationshipBuilder.createRelationship(accessor); + + if (matchColumnName != null && columnToFilter != null && filterClassName != null && + comparator != null) + { + WHValue theMatchValue = accessor.getValue(matchColumnName); + try + { + Class classValue = Class.forName(filterClassName); + Constructor constructor = classValue.getConstructor(new Class[]{String.class,WHValue.class,WHComparator.class}); + Object object = constructor.newInstance(new Object[]{columnToFilter,theMatchValue,comparator}); + if (!(object instanceof FilterCriteria)) + throw new WHException("Filter class '"+filterClassName+"' does not extend FilterCriteria"); + filterer = (FilterCriteria)object; + } + catch (ClassNotFoundException e) + { + throw new WHException("Can't find filter class '"+filterClassName+"': "+e.getMessage(),e); + } + catch (NoSuchMethodException e) + { + throw new WHException("Filter class '"+filterClassName+"' does not have a constructor with (String,WHValue,WHComparator) arguments: "+e.getMessage(),e); + } + catch (InvocationTargetException e) + { + throw new WHException("Constructor exception instantiating filter class '"+filterClassName+"': "+e.getMessage(),e); + } + catch (InstantiationException e) + { + throw new WHException("Instantiation exception for filter class '"+filterClassName+"': "+e.getMessage(),e); + } + catch (IllegalAccessException e) + { + throw new WHException("Filter class '"+filterClassName+"' (String,WHValue,WHComparator) constructor has protected access",e); + } + } + + // Now build the filter relationship with it. + return new FilterRelationship(baseRelationship,filterer); + } + +} \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterSubquery.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterSubquery.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterSubquery.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/FilterSubquery.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,54 @@ +/* $Id: FilterSubquery.java -1 $ */ + +/** +* 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.warthog.api; + +/** Filter using a secondary index, in either an "exists" or "not exists" +* way. This filter must build a new accessor for every isUnfiltered() request, +* and return 'true' if the accessor is non-empty, or the converse (depending on the +* setting of the isExists flag). +* Note that there are a number of 'moving parts' needed to make this filter work. +* The accessor must be constructed on the fly, so there has to be some code that +* finds the right table or index accessor based on the join criteria. That's going to +* be handled by a class implementing WHRelationshipBuilder. +*/ +public class FilterSubquery extends FilterCriteria +{ + protected boolean isExists; + protected WHRelationshipBuilder builder; + + /** Constructor */ + public FilterSubquery(boolean isExists, WHRelationshipBuilder builder) + { + super(); + this.isExists = isExists; + this.builder = builder; + } + + /** Check if a row should be filtered or not. + */ + @Override + public boolean include(WHAccessor accessor) + throws WHException + { + WHRelationship checkerRelationship = builder.createRelationship(accessor); + return isExists ^ (checkerRelationship.buildAccessor().getCurrentRowID() == null); + } + +} \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexAfter.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexAfter.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexAfter.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexAfter.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,62 @@ +/* $Id: IndexAfter.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class represents index criteria designed to locate matches that follow +* a specific WHValue. +*/ +public class IndexAfter extends IndexCriteria +{ + protected WHValue value; + + /** Constructor */ + public IndexAfter(WHValue value) + { + super(); + this.value = value; + } + + /** Evaluate a given value (which comes from a table row described by a btree node, and which + * may turn out to be null) against the criteria as determined by this class, and return + * an appropriate bit pattern. The bit pattern is used to limit which branches of the index tree the search + * should descend. + * + * The comparator is provided to allow simple inequality comparisons against known values using the same logic + * as the index is organized by. + */ + public int evaluateValue(WHValue value, WHComparator comparator) + throws WHException + { + int result = comparator.compare(value,this.value); + if (result == WHComparator.RESULT_EQUALS) + return SIGNAL_GREATER; + + if (result == WHComparator.RESULT_GREATER) + return SIGNAL_GREATER; + + if (result == WHComparator.RESULT_LESS) + return SIGNAL_LESSER | SIGNAL_EQUALS | SIGNAL_GREATER; + + throw new WHException("Comparator returned unexpected value"); + } + +} + + \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBefore.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBefore.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBefore.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBefore.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,62 @@ +/* $Id: IndexBefore.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class represents index criteria designed to locate matches that precede +* a specific WHValue. +*/ +public class IndexBefore extends IndexCriteria +{ + protected WHValue value; + + /** Constructor */ + public IndexBefore(WHValue value) + { + super(); + this.value = value; + } + + /** Evaluate a given value (which comes from a table row described by a btree node, and which + * may turn out to be null) against the criteria as determined by this class, and return + * an appropriate bit pattern. The bit pattern is used to limit which branches of the index tree the search + * should descend. + * + * The comparator is provided to allow simple inequality comparisons against known values using the same logic + * as the index is organized by. + */ + public int evaluateValue(WHValue value, WHComparator comparator) + throws WHException + { + int result = comparator.compare(value,this.value); + if (result == WHComparator.RESULT_EQUALS) + return SIGNAL_LESSER; + + if (result == WHComparator.RESULT_GREATER) + return SIGNAL_GREATER | SIGNAL_EQUALS | SIGNAL_LESSER; + + if (result == WHComparator.RESULT_LESS) + return SIGNAL_LESSER; + + throw new WHException("Comparator returned unexpected value"); + } + +} + + \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBetween.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBetween.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBetween.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexBetween.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,74 @@ +/* $Id: IndexBetween.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class represents index criteria designed to locate matches that follow +* a specific WHValue, but precede a second WHValue, non-inclusive. +*/ +public class IndexBetween extends IndexCriteria +{ + protected WHValue afterValue; + protected WHValue beforeValue; + + /** Constructor */ + public IndexBetween(WHValue afterValue, WHValue beforeValue) + { + super(); + this.afterValue = afterValue; + this.beforeValue = beforeValue; + } + + /** Evaluate a given value (which comes from a table row described by a btree node, and which + * may turn out to be null) against the criteria as determined by this class, and return + * an appropriate bit pattern. The bit pattern is used to limit which branches of the index tree the search + * should descend. + * + * The comparator is provided to allow simple inequality comparisons against known values using the same logic + * as the index is organized by. + */ + public int evaluateValue(WHValue value, WHComparator comparator) + throws WHException + { + int afterResult = comparator.compare(value,afterValue); + if (afterResult == WHComparator.RESULT_EQUALS) + return SIGNAL_GREATER; + + if (afterResult == WHComparator.RESULT_GREATER) + return SIGNAL_GREATER; + + if (afterResult == WHComparator.RESULT_LESS) + { + int beforeResult = comparator.compare(value,beforeValue); + if (beforeResult == WHComparator.RESULT_EQUALS) + return SIGNAL_LESSER; + + if (beforeResult == WHComparator.RESULT_GREATER) + return SIGNAL_LESSER | SIGNAL_EQUALS | SIGNAL_GREATER; + + if (beforeResult == WHComparator.RESULT_LESS) + return SIGNAL_LESSER; + } + + throw new WHException("Comparator returned unexpected value"); + } + +} + + \ No newline at end of file Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexCriteria.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexCriteria.java?rev=1220349&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexCriteria.java (added) +++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexCriteria.java Sun Dec 18 08:26:30 2011 @@ -0,0 +1,62 @@ +/* $Id: IndexCriteria.java -1 $ */ + +/** +* 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.warthog.api; + +/** This class represents what is needed to scan an index and make decisions about +* what subtrees to descend into, and which not to. An instance of this interface will +* be present for each column present in the index. Override this class to provide +* specific exclusions for specific index scans. +*/ +public class IndexCriteria +{ + // Return signals. This constitutes 3 bits which determine how to proceed in order + // to locate the next matching row in the index, at least as far as the current + // comparator and key are concerned. + + // Zero value for the bit indicates "skip", while a 1 value indicates "descend". + + public static final int SIGNAL_LESSER = 1; + public static final int SIGNAL_GREATER = 2; + public static final int SIGNAL_EQUALS = 4; + + /** Constructor */ + public IndexCriteria() + { + } + + /** Evaluate a given value (which comes from a table row described by a btree node, and which + * may turn out to be null) against the criteria as determined by this class, and return + * an appropriate bit pattern. The bit pattern is used to limit which branches of the index tree the search + * should descend. + * + * The comparator is provided to allow simple inequality comparisons against known values using the same logic + * as the index is organized by. + */ + public int evaluateValue(WHValue value, WHComparator comparator) + throws WHException + { + // The base case is that there is no limiting criteria, so that the criteria places no restrictions + // on which way we are allowed to descend. + return SIGNAL_LESSER | SIGNAL_GREATER | SIGNAL_EQUALS; + } + +} + + \ No newline at end of file