Return-Path: Delivered-To: apmail-hadoop-pig-commits-archive@www.apache.org Received: (qmail 86687 invoked from network); 4 Feb 2010 00:01:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Feb 2010 00:01:11 -0000 Received: (qmail 53535 invoked by uid 500); 4 Feb 2010 00:01:11 -0000 Delivered-To: apmail-hadoop-pig-commits-archive@hadoop.apache.org Received: (qmail 53489 invoked by uid 500); 4 Feb 2010 00:01:11 -0000 Mailing-List: contact pig-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: pig-dev@hadoop.apache.org Delivered-To: mailing list pig-commits@hadoop.apache.org Received: (qmail 53478 invoked by uid 500); 4 Feb 2010 00:01:11 -0000 Delivered-To: apmail-incubator-pig-commits@incubator.apache.org Received: (qmail 53475 invoked by uid 99); 4 Feb 2010 00:01:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Feb 2010 00:01:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Thu, 04 Feb 2010 00:01:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D76942388AA0; Thu, 4 Feb 2010 00:00:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r906294 - in /hadoop/pig/branches/load-store-redesign: src/org/apache/pig/impl/builtin/DefaultIndexableLoader.java test/org/apache/pig/test/TestMergeJoin.java Date: Thu, 04 Feb 2010 00:00:49 -0000 To: pig-commits@incubator.apache.org From: pradeepkth@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100204000049.D76942388AA0@eris.apache.org> Author: pradeepkth Date: Thu Feb 4 00:00:49 2010 New Revision: 906294 URL: http://svn.apache.org/viewvc?rev=906294&view=rev Log: PIG-1090: additional patch handle issue in merge join where the index has only one entry (daijy via pradeepkth) Modified: hadoop/pig/branches/load-store-redesign/src/org/apache/pig/impl/builtin/DefaultIndexableLoader.java hadoop/pig/branches/load-store-redesign/test/org/apache/pig/test/TestMergeJoin.java Modified: hadoop/pig/branches/load-store-redesign/src/org/apache/pig/impl/builtin/DefaultIndexableLoader.java URL: http://svn.apache.org/viewvc/hadoop/pig/branches/load-store-redesign/src/org/apache/pig/impl/builtin/DefaultIndexableLoader.java?rev=906294&r1=906293&r2=906294&view=diff ============================================================================== --- hadoop/pig/branches/load-store-redesign/src/org/apache/pig/impl/builtin/DefaultIndexableLoader.java (original) +++ hadoop/pig/branches/load-store-redesign/src/org/apache/pig/impl/builtin/DefaultIndexableLoader.java Thu Feb 4 00:00:49 2010 @@ -132,6 +132,11 @@ // Its possible that we hit end of index and still doesn't encounter // idx entry >= left key, in that case return last index entry. matchedEntry = prevIdxEntry; + if (prevIdxEntry!=null) { + Object extractedKey = extractKeysFromIdxTuple(prevIdxEntry); + if (extractedKey!=null) + index.add(prevIdxEntry); + } break; } Object extractedKey = extractKeysFromIdxTuple(curIdxEntry); Modified: hadoop/pig/branches/load-store-redesign/test/org/apache/pig/test/TestMergeJoin.java URL: http://svn.apache.org/viewvc/hadoop/pig/branches/load-store-redesign/test/org/apache/pig/test/TestMergeJoin.java?rev=906294&r1=906293&r2=906294&view=diff ============================================================================== --- hadoop/pig/branches/load-store-redesign/test/org/apache/pig/test/TestMergeJoin.java (original) +++ hadoop/pig/branches/load-store-redesign/test/org/apache/pig/test/TestMergeJoin.java Thu Feb 4 00:00:49 2010 @@ -55,6 +55,7 @@ public class TestMergeJoin { private static final String INPUT_FILE = "testMergeJoinInput.txt"; + private static final String INPUT_FILE2 = "testMergeJoinInput2.txt"; private PigServer pigServer; private MiniCluster cluster = MiniCluster.buildCluster(); @@ -77,6 +78,8 @@ input[k++] = si + "\t" + j; } Util.createInputFile(cluster, INPUT_FILE, input); + + Util.createInputFile(cluster, INPUT_FILE2, new String[]{"2"}); } /** @@ -85,6 +88,7 @@ @After public void tearDown() throws Exception { Util.deleteFile(cluster, INPUT_FILE); + Util.deleteFile(cluster, INPUT_FILE2); } /** @@ -557,6 +561,33 @@ Assert.assertFalse(iter.hasNext()); } + @Test + public void testMergeJoinEmptyIndex() throws IOException{ + DataBag dbMergeJoin = BagFactory.getInstance().newDefaultBag(), dbshj = BagFactory.getInstance().newDefaultBag(); + pigServer.registerQuery("A = LOAD '" + INPUT_FILE2 + "';"); + pigServer.registerQuery("B = LOAD '" + INPUT_FILE + "';"); + + { + pigServer.registerQuery("C = join A by $0, B by $0 using \"merge\";"); + Iterator iter = pigServer.openIterator("C"); + while(iter.hasNext()) { + dbMergeJoin.add(iter.next()); + } + } + + { + pigServer.registerQuery("C = join A by $0, B by $0;"); + Iterator iter = pigServer.openIterator("C"); + + while(iter.hasNext()) { + dbshj.add(iter.next()); + } + } + + Assert.assertEquals(dbMergeJoin.size(), dbshj.size()); + Assert.assertEquals(true, TestHelper.compareBags(dbMergeJoin, dbshj)); + } + /** * A dummy loader which implements {@link IndexableLoadFunc} to test * that expressions are not allowed as merge join keys when the right input's