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<Tuple> iter = pigServer.openIterator("C");
+ while(iter.hasNext()) {
+ dbMergeJoin.add(iter.next());
+ }
+ }
+
+ {
+ pigServer.registerQuery("C = join A by $0, B by $0;");
+ Iterator<Tuple> 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