/** * Returns the oldest visible timestamp for the given transaction, based on the TTLs configured for each column * family. If no TTL is set on any column family, the oldest visible timestamp will be {@code 0}. * @param ttlByFamily A map of column family name to TTL value (in milliseconds) * @param tx The current transaction * @return The oldest timestamp that will be visible for the given transaction and TTL configuration */ public static long getOldestVisibleTimestamp(Map<byte[], Long> ttlByFamily, Transaction tx) { long maxTTL = getMaxTTL(ttlByFamily); // we know that data will not be cleaned up while this tx is running up to this point as janitor uses it return maxTTL < Long.MAX_VALUE ? tx.getVisibilityUpperBound() - maxTTL * TxConstants.MAX_TX_PER_MS : 0; }
/** * Returns the oldest visible timestamp for the given transaction, based on the TTLs configured for each column * family. If no TTL is set on any column family, the oldest visible timestamp will be {@code 0}. * @param ttlByFamily A map of column family name to TTL value (in milliseconds) * @param tx The current transaction * @return The oldest timestamp that will be visible for the given transaction and TTL configuration */ public static long getOldestVisibleTimestamp(Map<byte[], Long> ttlByFamily, Transaction tx) { long maxTTL = getMaxTTL(ttlByFamily); // we know that data will not be cleaned up while this tx is running up to this point as janitor uses it return maxTTL < Long.MAX_VALUE ? tx.getVisibilityUpperBound() - maxTTL * TxConstants.MAX_TX_PER_MS : 0; }
/** * Returns the oldest visible timestamp for the given transaction, based on the TTLs configured for each column * family. If no TTL is set on any column family, the oldest visible timestamp will be {@code 0}. * @param ttlByFamily A map of column family name to TTL value (in milliseconds) * @param tx The current transaction * @param readNonTxnData indicates that the timestamp returned should allow reading non-transactional data * @return The oldest timestamp that will be visible for the given transaction and TTL configuration */ public static long getOldestVisibleTimestamp(Map<byte[], Long> ttlByFamily, Transaction tx, boolean readNonTxnData) { if (readNonTxnData) { long maxTTL = getMaxTTL(ttlByFamily); return maxTTL < Long.MAX_VALUE ? System.currentTimeMillis() - maxTTL : 0; } return getOldestVisibleTimestamp(ttlByFamily, tx); }
/** * Returns the oldest visible timestamp for the given transaction, based on the TTLs configured for each column * family. If no TTL is set on any column family, the oldest visible timestamp will be {@code 0}. * @param ttlByFamily A map of column family name to TTL value (in milliseconds) * @param tx The current transaction * @param readNonTxnData indicates that the timestamp returned should allow reading non-transactional data * @return The oldest timestamp that will be visible for the given transaction and TTL configuration */ public static long getOldestVisibleTimestamp(Map<byte[], Long> ttlByFamily, Transaction tx, boolean readNonTxnData) { if (readNonTxnData) { long maxTTL = getMaxTTL(ttlByFamily); return maxTTL < Long.MAX_VALUE ? System.currentTimeMillis() - maxTTL : 0; } return getOldestVisibleTimestamp(ttlByFamily, tx); }