FAQ
Repository: hive
Updated Branches:
   refs/heads/master f21c58e83 -> f9d1436b2


HIVE-12202 NPE thrown when reading legacy ACID delta files(missed a file)(Elliot West via Eugene Koifman)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/f9d1436b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/f9d1436b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/f9d1436b

Branch: refs/heads/master
Commit: f9d1436b28e96e1435a2aa779ccc8d7ddf4514b2
Parents: f21c58e
Author: Eugene Koifman <ekoifman@hortonworks.com>
Authored: Tue Nov 3 10:46:36 2015 -0800
Committer: Eugene Koifman <ekoifman@hortonworks.com>
Committed: Tue Nov 3 10:46:36 2015 -0800

----------------------------------------------------------------------
  .../hadoop/hive/ql/io/TestAcidInputFormat.java | 88 ++++++++++++++++++++
  1 file changed, 88 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/f9d1436b/ql/src/test/org/apache/hadoop/hive/ql/io/TestAcidInputFormat.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/io/TestAcidInputFormat.java b/ql/src/test/org/apache/hadoop/hive/ql/io/TestAcidInputFormat.java
new file mode 100644
index 0000000..6a77670
--- /dev/null
+++ b/ql/src/test/org/apache/hadoop/hive/ql/io/TestAcidInputFormat.java
@@ -0,0 +1,88 @@
+package org.apache.hadoop.hive.ql.io;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.DataInput;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.hadoop.hive.ql.io.AcidInputFormat.DeltaMetaData;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestAcidInputFormat {
+
+ @Mock
+ private DataInput mockDataInput;
+
+ @Test
+ public void testDeltaMetaDataReadFieldsNoStatementIds() throws Exception {
+ when(mockDataInput.readLong()).thenReturn(1L, 2L);
+ when(mockDataInput.readInt()).thenReturn(0);
+
+ DeltaMetaData deltaMetaData = new AcidInputFormat.DeltaMetaData();
+ deltaMetaData.readFields(mockDataInput);
+
+ verify(mockDataInput, times(1)).readInt();
+ assertThat(deltaMetaData.getMinTxnId(), is(1L));
+ assertThat(deltaMetaData.getMaxTxnId(), is(2L));
+ assertThat(deltaMetaData.getStmtIds().isEmpty(), is(true));
+ }
+
+ @Test
+ public void testDeltaMetaDataReadFieldsWithStatementIds() throws Exception {
+ when(mockDataInput.readLong()).thenReturn(1L, 2L);
+ when(mockDataInput.readInt()).thenReturn(2, 100, 101);
+
+ DeltaMetaData deltaMetaData = new AcidInputFormat.DeltaMetaData();
+ deltaMetaData.readFields(mockDataInput);
+
+ verify(mockDataInput, times(3)).readInt();
+ assertThat(deltaMetaData.getMinTxnId(), is(1L));
+ assertThat(deltaMetaData.getMaxTxnId(), is(2L));
+ assertThat(deltaMetaData.getStmtIds().size(), is(2));
+ assertThat(deltaMetaData.getStmtIds().get(0), is(100));
+ assertThat(deltaMetaData.getStmtIds().get(1), is(101));
+ }
+
+ @Test
+ public void testDeltaMetaConstructWithState() throws Exception {
+ DeltaMetaData deltaMetaData = new AcidInputFormat.DeltaMetaData(2000L, 2001L, Arrays.asList(97, 98, 99));
+
+ assertThat(deltaMetaData.getMinTxnId(), is(2000L));
+ assertThat(deltaMetaData.getMaxTxnId(), is(2001L));
+ assertThat(deltaMetaData.getStmtIds().size(), is(3));
+ assertThat(deltaMetaData.getStmtIds().get(0), is(97));
+ assertThat(deltaMetaData.getStmtIds().get(1), is(98));
+ assertThat(deltaMetaData.getStmtIds().get(2), is(99));
+ }
+
+ @Test
+ public void testDeltaMetaDataReadFieldsWithStatementIdsResetsState() throws Exception {
+ when(mockDataInput.readLong()).thenReturn(1L, 2L);
+ when(mockDataInput.readInt()).thenReturn(2, 100, 101);
+
+ List<Integer> statementIds = new ArrayList<>();
+ statementIds.add(97);
+ statementIds.add(98);
+ statementIds.add(99);
+ DeltaMetaData deltaMetaData = new AcidInputFormat.DeltaMetaData(2000L, 2001L, statementIds);
+ deltaMetaData.readFields(mockDataInput);
+
+ verify(mockDataInput, times(3)).readInt();
+ assertThat(deltaMetaData.getMinTxnId(), is(1L));
+ assertThat(deltaMetaData.getMaxTxnId(), is(2L));
+ assertThat(deltaMetaData.getStmtIds().size(), is(2));
+ assertThat(deltaMetaData.getStmtIds().get(0), is(100));
+ assertThat(deltaMetaData.getStmtIds().get(1), is(101));
+ }
+
+}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedNov 3, '15 at 6:46p
activeNov 3, '15 at 6:46p
posts1
users1
websitehive.apache.org

1 user in discussion

Ekoifman: 1 post

People

Translate

site design / logo © 2021 Grokbase