/** * Returns the maximum timestamp to use for time-range operations, based on the given transaction. * @param tx The current transaction * @return The maximum timestamp (exclusive) to use for time-range operations */ public static long getMaxVisibleTimestamp(Transaction tx) { // NOTE: +1 here because we want read up to writepointer inclusive, but timerange's end is exclusive // however, we also need to guard against overflow in the case write pointer is set to MAX_VALUE return tx.getWritePointer() < Long.MAX_VALUE ? tx.getWritePointer() + 1 : tx.getWritePointer(); }
/** * Returns the maximum timestamp to use for time-range operations, based on the given transaction. * @param tx The current transaction * @return The maximum timestamp (exclusive) to use for time-range operations */ public static long getMaxVisibleTimestamp(Transaction tx) { // NOTE: +1 here because we want read up to writepointer inclusive, but timerange's end is exclusive // however, we also need to guard against overflow in the case write pointer is set to MAX_VALUE return tx.getWritePointer() < Long.MAX_VALUE ? tx.getWritePointer() + 1 : tx.getWritePointer(); }
protected void addToChangeSet(byte[] row, byte[] family, byte[] qualifier) { long currentWritePointer = tx.getWritePointer(); Set<ActionChange> changeSet = changeSets.get(currentWritePointer); if (changeSet == null) { changeSet = Sets.newHashSet(); changeSets.put(currentWritePointer, changeSet); } switch (conflictLevel) { case ROW: case NONE: // with ROW or NONE conflict detection, we still need to track changes per-family, since this // is the granularity at which we will issue deletes for rollback changeSet.add(new ActionChange(row, family)); break; case COLUMN: changeSet.add(new ActionChange(row, family, qualifier)); break; default: throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel); } }
protected void addToChangeSet(byte[] row, byte[] family, byte[] qualifier) { long currentWritePointer = tx.getWritePointer(); Set<ActionChange> changeSet = changeSets.get(currentWritePointer); if (changeSet == null) { changeSet = Sets.newHashSet(); changeSets.put(currentWritePointer, changeSet); } switch (conflictLevel) { case ROW: case NONE: // with ROW or NONE conflict detection, we still need to track changes per-family, since this // is the granularity at which we will issue deletes for rollback changeSet.add(new ActionChange(row, family)); break; case COLUMN: changeSet.add(new ActionChange(row, family, qualifier)); break; default: throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel); } }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Delete transactionalizeAction(Delete delete) throws IOException { long transactionTimestamp = tx.getWritePointer();
private Delete transactionalizeAction(Delete delete) throws IOException { long transactionTimestamp = tx.getWritePointer();
private Delete transactionalizeAction(Delete delete) throws IOException { long transactionTimestamp = tx.getWritePointer();
private Delete transactionalizeAction(Delete delete) throws IOException { long transactionTimestamp = tx.getWritePointer();
doCommit(tx.getTransactionId(), tx.getWritePointer(), changeSet, commitPointer, addToCommitted);
doCommit(tx.getTransactionId(), tx.getWritePointer(), changeSet, commitPointer, addToCommitted);
public static TTransaction wrap(Transaction tx) { return new TTransaction(tx.getTransactionId(), tx.getReadPointer(), Longs.asList(tx.getInvalids()), Longs.asList(tx.getInProgress()), tx.getFirstShortInProgress(), getTTransactionType(tx.getType()), tx.getWritePointer(), Longs.asList(tx.getCheckpointWritePointers()), getTVisibilityLevel(tx.getVisibilityLevel())); }
public static TTransaction wrap(Transaction tx) { return new TTransaction(tx.getTransactionId(), tx.getReadPointer(), Longs.asList(tx.getInvalids()), Longs.asList(tx.getInProgress()), tx.getFirstShortInProgress(), getTTransactionType(tx.getType()), tx.getWritePointer(), Longs.asList(tx.getCheckpointWritePointers()), getTVisibilityLevel(tx.getVisibilityLevel())); }