/** * Creates a "dummy" transaction based on the given txVisibilityState's state. This is not a "real" transaction in * the sense that it has not been started, data should not be written with it, and it cannot be committed. However, * this can still be useful for filtering data according to the txVisibilityState's state. Instead of the actual * write pointer from the txVisibilityState, however, we use {@code Long.MAX_VALUE} to avoid mis-identifying any cells * as being written by this transaction (and therefore visible). */ public static Transaction createDummyTransaction(TransactionVisibilityState txVisibilityState) { return new Transaction(txVisibilityState.getReadPointer(), Long.MAX_VALUE, Longs.toArray(txVisibilityState.getInvalid()), Longs.toArray(txVisibilityState.getInProgress().keySet()), TxUtils.getFirstShortInProgress(txVisibilityState.getInProgress()), TransactionType.SHORT); }
/** * Creates a "dummy" transaction based on the given txVisibilityState's state. This is not a "real" transaction in * the sense that it has not been started, data should not be written with it, and it cannot be committed. However, * this can still be useful for filtering data according to the txVisibilityState's state. Instead of the actual * write pointer from the txVisibilityState, however, we use {@code Long.MAX_VALUE} to avoid mis-identifying any cells * as being written by this transaction (and therefore visible). */ public static Transaction createDummyTransaction(TransactionVisibilityState txVisibilityState) { return new Transaction(txVisibilityState.getReadPointer(), Long.MAX_VALUE, Longs.toArray(txVisibilityState.getInvalid()), Longs.toArray(txVisibilityState.getInProgress().keySet()), TxUtils.getFirstShortInProgress(txVisibilityState.getInProgress()), TransactionType.SHORT); }
@Override public TransactionSnapshot decode(InputStream in) { BinaryDecoder decoder = new BinaryDecoder(in); try { TransactionVisibilityState minTxSnapshot = decodeTransactionVisibilityState(in); NavigableMap<Long, Set<ChangeId>> committing = decodeChangeSets(decoder); NavigableMap<Long, Set<ChangeId>> committed = decodeChangeSets(decoder); return new TransactionSnapshot(minTxSnapshot.getTimestamp(), minTxSnapshot.getReadPointer(), minTxSnapshot.getWritePointer(), minTxSnapshot.getInvalid(), minTxSnapshot.getInProgress(), committing, committed); } catch (IOException e) { LOG.error("Unable to deserialize transaction state: ", e); throw Throwables.propagate(e); } }
@Override public TransactionSnapshot decode(InputStream in) { BinaryDecoder decoder = new BinaryDecoder(in); try { TransactionVisibilityState minTxSnapshot = decodeTransactionVisibilityState(in); NavigableMap<Long, Set<ChangeId>> committing = decodeChangeSets(decoder); NavigableMap<Long, Set<ChangeId>> committed = decodeChangeSets(decoder); return new TransactionSnapshot(minTxSnapshot.getTimestamp(), minTxSnapshot.getReadPointer(), minTxSnapshot.getWritePointer(), minTxSnapshot.getInvalid(), minTxSnapshot.getInProgress(), committing, committed); } catch (IOException e) { LOG.error("Unable to deserialize transaction state: ", e); throw Throwables.propagate(e); } }
private void assertTransactionVisibilityStateEquals(TransactionVisibilityState expected, TransactionVisibilityState input) { Assert.assertEquals(expected.getTimestamp(), input.getTimestamp()); Assert.assertEquals(expected.getReadPointer(), input.getReadPointer()); Assert.assertEquals(expected.getWritePointer(), input.getWritePointer()); Assert.assertEquals(expected.getInProgress(), input.getInProgress()); Assert.assertEquals(expected.getInvalid(), input.getInvalid()); } }