private void findRecordsWithInvalidTransactionIds(VectorizedRowBatch batch, BitSet selectedBitSet) { if (batch.cols[OrcRecordUpdater.CURRENT_TRANSACTION].isRepeating) { // When we have repeating values, we can unset the whole bitset at once // if the repeating value is not a valid transaction. long currentTransactionIdForBatch = ((LongColumnVector) batch.cols[OrcRecordUpdater.CURRENT_TRANSACTION]).vector[0]; if (!validTxnList.isTxnValid(currentTransactionIdForBatch)) { selectedBitSet.clear(0, batch.size); } return; } long[] currentTransactionVector = ((LongColumnVector) batch.cols[OrcRecordUpdater.CURRENT_TRANSACTION]).vector; // Loop through the bits that are set to true and mark those rows as false, if their // current transactions are not valid. for (int setBitIndex = selectedBitSet.nextSetBit(0); setBitIndex >= 0; setBitIndex = selectedBitSet.nextSetBit(setBitIndex+1)) { if (!validTxnList.isTxnValid(currentTransactionVector[setBitIndex])) { selectedBitSet.clear(setBitIndex); } } }
/** * checks {@code visibilityTxnId} to see if {@code child} is committed in current snapshot */ private static boolean isDirUsable(FileStatus child, long visibilityTxnId, List<FileStatus> aborted, ValidTxnList validTxnList) { if(validTxnList == null) { throw new IllegalArgumentException("No ValidTxnList for " + child.getPath()); } if(!validTxnList.isTxnValid(visibilityTxnId)) { boolean isAborted = validTxnList.isTxnAborted(visibilityTxnId); if(isAborted) { aborted.add(child);//so we can clean it up } LOG.debug("getChildState() ignoring(" + aborted + ") " + child); return false; } return true; } public static HdfsFileStatusWithId createOriginalObj(
((LongColumnVector) batch.cols[OrcRecordUpdater.CURRENT_TRANSACTION]).vector[currentTransactionIndex]; ++indexPtrInBatch; if (validTxnList.isTxnValid(currentTransaction)) { isValidNext = true; deleteRecordKey.set(originalTransaction, rowId);
if (validTxnList.isTxnValid(txnId) || validTxnList.isTxnAborted(txnId)) {
long txnId = rs.getLong(1); long writeId = rs.getLong(2); if (validTxnList.isTxnValid(txnId)) {
@Test public void testTxns() throws Exception { List<Long> tids = client.openTxns("me", 3).getTxn_ids(); Assert.assertEquals(1L, (long) tids.get(0)); Assert.assertEquals(2L, (long) tids.get(1)); Assert.assertEquals(3L, (long) tids.get(2)); client.rollbackTxn(1); client.commitTxn(2); ValidTxnList validTxns = client.getValidTxns(); Assert.assertFalse(validTxns.isTxnValid(1)); Assert.assertTrue(validTxns.isTxnValid(2)); Assert.assertFalse(validTxns.isTxnValid(3)); Assert.assertFalse(validTxns.isTxnValid(4)); }
@Test public void testOpenTxnNotExcluded() throws Exception { List<Long> tids = client.openTxns("me", 3).getTxn_ids(); Assert.assertEquals(1L, (long) tids.get(0)); Assert.assertEquals(2L, (long) tids.get(1)); Assert.assertEquals(3L, (long) tids.get(2)); client.rollbackTxn(1); client.commitTxn(2); ValidTxnList validTxns = client.getValidTxns(3); Assert.assertFalse(validTxns.isTxnValid(1)); Assert.assertTrue(validTxns.isTxnValid(2)); Assert.assertTrue(validTxns.isTxnValid(3)); Assert.assertFalse(validTxns.isTxnValid(4)); }
if (!validTxnList.isTxnValid( ((ReaderKey) recordIdentifier).getCurrentTransactionId())) { continue;
@Test public void testTxNWithKeyValueNoTableId() throws Exception { List<Long> tids = client.openTxns("me", 1).getTxn_ids(); Assert.assertEquals(1L, (long) tids.get(0)); try { client.commitTxnWithKeyValue(1, 10, TxnStore.TXN_KEY_START + "mykey", "myvalue"); Assert.fail("Should have raised exception"); } catch (IllegalStateException e) { Assert.assertTrue(e.getMessage().contains("key=" + TxnStore.TXN_KEY_START + "mykey")); Assert.assertTrue(e.getMessage().contains("value=myvalue")); Assert.assertTrue(e.getMessage().contains("Only one row should have been affected but")); } ValidTxnList validTxns = client.getValidTxns(1); Assert.assertTrue(validTxns.isTxnValid(1)); }
@Test public void testOpenTxnWithType() throws Exception { long txnId = client.openTxn("me", TxnType.DEFAULT); client.commitTxn(txnId); ValidTxnList validTxns = client.getValidTxns(); Assert.assertTrue(validTxns.isTxnValid(txnId)); }
client.commitTxnWithKeyValue(1, tbl.getId(), TxnStore.TXN_KEY_START + "mykey", "myvalue"); ValidTxnList validTxns = client.getValidTxns(1); Assert.assertTrue(validTxns.isTxnValid(1));
@Test public void testTxNWithKeyWrongPrefix() throws Exception { String dbName = "mydbKeyValueWrongPrefix"; String tblName = "mytable"; List<Long> tids = client.openTxns("me", 1).getTxn_ids(); Assert.assertEquals(1L, (long) tids.get(0)); try { Database db = new DatabaseBuilder().setName(dbName).build(conf); db.unsetCatalogName(); client.createDatabase(db); Table tbl = new TableBuilder().setDbName(dbName).setTableName(tblName) .addCol("id", "int").addCol("name", "string") .setType(TableType.MANAGED_TABLE.name()).build(conf); client.createTable(tbl); tbl = client.getTable(dbName, tblName); client.commitTxnWithKeyValue(1, tbl.getId(), "mykey", "myvalue"); Assert.fail("Should have raised exception"); } catch (IllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("key=mykey")); Assert.assertTrue(e.getMessage().contains("value=myvalue")); Assert.assertTrue(e.getMessage().contains("key should start with")); } finally { client.dropTable(dbName, tblName); client.dropDatabase(dbName); } ValidTxnList validTxns = client.getValidTxns(1); Assert.assertTrue(validTxns.isTxnValid(1)); }
if (!validTxnList.isTxnValid( ((ReaderKey) recordIdentifier).getCurrentTransactionId())) { continue;