use of org.apache.hadoop.hive.ql.io.orc.TestInputOutputFormat.MockFile in project hive by apache.
the class TestAcidUtils method testBaseDeltas.
@Test
public void testBaseDeltas() throws Exception {
Configuration conf = new Configuration();
MockFileSystem fs = new MockFileSystem(conf, new MockFile("mock:/tbl/part1/base_5/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/base_10/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/base_49/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_025_025/bucket_0", 0, new byte[0]), new MockFile("mock:/tbl/part1/delta_029_029/bucket_0", 0, new byte[0]), new MockFile("mock:/tbl/part1/delta_025_030/bucket_0", 0, new byte[0]), new MockFile("mock:/tbl/part1/delta_050_105/bucket_0", 0, new byte[0]), new MockFile("mock:/tbl/part1/delta_90_120/bucket_0", 0, new byte[0]));
conf.set(ValidTxnList.VALID_TXNS_KEY, new ValidReadTxnList(new long[0], new BitSet(), 1000, Long.MAX_VALUE).writeToString());
AcidDirectory dir = AcidUtils.getAcidState(fs, new MockPath(fs, "mock:/tbl/part1"), conf, new ValidReaderWriteIdList("tbl:100:" + Long.MAX_VALUE + ":"), null, false);
assertEquals("mock:/tbl/part1/base_49", dir.getBaseDirectory().toString());
List<Path> obsoletes = dir.getObsolete();
assertEquals(5, obsoletes.size());
Set<String> obsoletePathNames = new HashSet<String>();
for (Path obsolete : obsoletes) {
obsoletePathNames.add(obsolete.toString());
}
assertTrue(obsoletePathNames.contains("mock:/tbl/part1/base_5"));
assertTrue(obsoletePathNames.contains("mock:/tbl/part1/base_10"));
assertTrue(obsoletePathNames.contains("mock:/tbl/part1/delta_025_030"));
assertTrue(obsoletePathNames.contains("mock:/tbl/part1/delta_025_025"));
assertTrue(obsoletePathNames.contains("mock:/tbl/part1/delta_029_029"));
assertEquals(0, dir.getOriginalFiles().size());
List<AcidUtils.ParsedDelta> deltas = dir.getCurrentDirectories();
assertEquals(1, deltas.size());
AcidUtils.ParsedDelta delt = deltas.get(0);
assertEquals("mock:/tbl/part1/delta_050_105", delt.getPath().toString());
assertEquals(50, delt.getMinWriteId());
assertEquals(105, delt.getMaxWriteId());
}
use of org.apache.hadoop.hive.ql.io.orc.TestInputOutputFormat.MockFile in project hive by apache.
the class TestAcidUtils method deleteDeltasWithOpenTxnInRead.
@Test
public void deleteDeltasWithOpenTxnInRead() throws Exception {
Configuration conf = new Configuration();
conf.setInt(HiveConf.ConfVars.HIVE_TXN_OPERATIONAL_PROPERTIES.varname, AcidUtils.AcidOperationalProperties.getDefault().toInt());
MockFileSystem fs = new MockFileSystem(conf, new MockFile("mock:/tbl/part1/delta_1_1/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_2_5/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delete_delta_2_5/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delete_delta_3_3/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_4_4_1/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_4_4_3/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_101_101_1/bucket_0", 500, new byte[0]));
Path part = new MockPath(fs, "mock:/tbl/part1");
// hypothetically, txn 50 is open and writing write ID 4
conf.set(ValidTxnList.VALID_TXNS_KEY, new ValidReadTxnList(new long[] { 50 }, new BitSet(), 1000, 55).writeToString());
AcidDirectory dir = AcidUtils.getAcidState(fs, part, conf, new ValidReaderWriteIdList("tbl:100:4:4"), null, false);
List<AcidUtils.ParsedDelta> delts = dir.getCurrentDirectories();
assertEquals(3, delts.size());
assertEquals("mock:/tbl/part1/delta_1_1", delts.get(0).getPath().toString());
assertEquals("mock:/tbl/part1/delete_delta_2_5", delts.get(1).getPath().toString());
assertEquals("mock:/tbl/part1/delta_2_5", delts.get(2).getPath().toString());
// Note that delete_delta_3_3 should not be read, when a minor compacted
// [delete_]delta_2_5 is present.
}
use of org.apache.hadoop.hive.ql.io.orc.TestInputOutputFormat.MockFile in project hive by apache.
the class TestAcidUtils method deltasWithOpenTxnsNotInCompact2.
@Test
public void deltasWithOpenTxnsNotInCompact2() throws Exception {
Configuration conf = new Configuration();
MockFileSystem fs = new MockFileSystem(conf, new MockFile("mock:/tbl/part1/delta_1_1/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_2_5/bucket_0", 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_2_5/bucket_0" + AcidUtils.DELTA_SIDE_FILE_SUFFIX, 500, new byte[0]), new MockFile("mock:/tbl/part1/delta_6_10/bucket_0", 500, new byte[0]));
Path part = new MockPath(fs, "mock:/tbl/part1");
conf.set(ValidTxnList.VALID_TXNS_KEY, new ValidReadTxnList(new long[0], new BitSet(), 1000, Long.MAX_VALUE).writeToString());
AcidDirectory dir = AcidUtils.getAcidState(fs, part, conf, new ValidCompactorWriteIdList("tbl:3:" + Long.MAX_VALUE), null, false);
List<AcidUtils.ParsedDelta> delts = dir.getCurrentDirectories();
assertEquals(1, delts.size());
assertEquals("mock:/tbl/part1/delta_1_1", delts.get(0).getPath().toString());
}
Aggregations