@Override public void decode(TransactionEdit dest, DataInput in) throws IOException { dest.setWritePointer(in.readLong()); int stateIdx = in.readInt(); try { dest.setState(TransactionEdit.State.values()[stateIdx]); } catch (ArrayIndexOutOfBoundsException e) { throw new IOException("State enum ordinal value is out of range: " + stateIdx); } dest.setExpiration(in.readLong()); dest.setCommitPointer(in.readLong()); dest.setCanCommit(in.readBoolean()); int changeSize = in.readInt(); Set<ChangeId> changes = Sets.newHashSet(); for (int i = 0; i < changeSize; i++) { int currentLength = in.readInt(); byte[] currentBytes = new byte[currentLength]; in.readFully(currentBytes); changes.add(new ChangeId(currentBytes)); } dest.setChanges(changes); // 1st version did not store this info. It is safe to set firstInProgress to 0, it may decrease performance until // this tx is finished, but correctness will be preserved. dest.setVisibilityUpperBound(0); }
@Override public void decode(TransactionEdit dest, DataInput in) throws IOException { dest.setWritePointer(in.readLong()); int stateIdx = in.readInt(); try { dest.setState(TransactionEdit.State.values()[stateIdx]); } catch (ArrayIndexOutOfBoundsException e) { throw new IOException("State enum ordinal value is out of range: " + stateIdx); } dest.setExpiration(in.readLong()); dest.setCommitPointer(in.readLong()); dest.setCanCommit(in.readBoolean()); int changeSize = in.readInt(); Set<ChangeId> changes = Sets.newHashSet(); for (int i = 0; i < changeSize; i++) { int currentLength = in.readInt(); byte[] currentBytes = new byte[currentLength]; in.readFully(currentBytes); changes.add(new ChangeId(currentBytes)); } dest.setChanges(changes); // 1st version did not store this info. It is safe to set firstInProgress to 0, it may decrease performance until // this tx is finished, but correctness will be preserved. dest.setVisibilityUpperBound(0); }
@Override public void decode(TransactionEdit dest, DataInput in) throws IOException { dest.setWritePointer(in.readLong()); int stateIdx = in.readInt(); try { dest.setState(TransactionEdit.State.values()[stateIdx]); } catch (ArrayIndexOutOfBoundsException e) { throw new IOException("State enum ordinal value is out of range: " + stateIdx); } dest.setExpiration(in.readLong()); dest.setCommitPointer(in.readLong()); dest.setCanCommit(in.readBoolean()); int changeSize = in.readInt(); Set<ChangeId> changes = Sets.newHashSet(); for (int i = 0; i < changeSize; i++) { int currentLength = in.readInt(); byte[] currentBytes = new byte[currentLength]; in.readFully(currentBytes); changes.add(new ChangeId(currentBytes)); } dest.setChanges(changes); // 1st version did not store this info. It is safe to set firstInProgress to 0, it may decrease performance until // this tx is finished, but correctness will be preserved. dest.setVisibilityUpperBound(0); }
List<TransactionEdit> edits = Lists.newArrayListWithCapacity(numEntries); for (int i = 0; i < numEntries; i++) { TransactionEdit.State nextType = TransactionEdit.State.values()[random.nextInt(6)]; long writePointer = Math.abs(random.nextLong()); switch (nextType) {