mirror of https://github.com/apache/cassandra
do not schedule additional durability attempts while some in flight; plus minor performance improvements
This commit is contained in:
parent
570d65249f
commit
91def31284
|
|
@ -1 +1 @@
|
|||
Subproject commit eedd13ac4b7b9f61d574badb4bfc47611a838739
|
||||
Subproject commit dd04c81214be9213cf503025bf6ed4cbf118be00
|
||||
|
|
@ -97,7 +97,7 @@ public abstract class DecoratedKey implements PartitionPosition, FilterKey
|
|||
return -position.compareTo(partitioner.decorateKey(key));
|
||||
|
||||
DecoratedKey otherKey = (DecoratedKey) position;
|
||||
int cmp = partitioner.getToken(key).compareTo(otherKey.getToken());
|
||||
int cmp = partitioner.compareToken(key, otherKey.getToken());
|
||||
return cmp == 0 ? ByteBufferUtil.compareUnsigned(key, otherKey.getKey()) : cmp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,16 @@ public interface IPartitioner
|
|||
*/
|
||||
public Token getToken(ByteBuffer key);
|
||||
|
||||
/**
|
||||
* @return a Token that can be used to route a given key
|
||||
* (This is NOT a method to create a Token from its string representation;
|
||||
* for that, use TokenFactory.fromString.)
|
||||
*/
|
||||
default int compareToken(ByteBuffer key, Token token)
|
||||
{
|
||||
return getToken(key).compareTo(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a randomly generated token
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -72,6 +72,11 @@ public class LocalPartitioner implements IPartitioner
|
|||
return new LocalToken(key);
|
||||
}
|
||||
|
||||
public int compareToken(ByteBuffer key, Token token)
|
||||
{
|
||||
return comparator.compare(key, ((LocalToken)token).token);
|
||||
}
|
||||
|
||||
public LocalToken getRandomToken()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ public class BigTableReader extends SSTableReaderWithFilter implements IndexSumm
|
|||
// of the next interval).
|
||||
int i = 0;
|
||||
String path = null;
|
||||
ByteBuffer indexKey = null;
|
||||
try (FileDataInput in = ifile.createReader(sampledPosition))
|
||||
{
|
||||
path = in.getPath();
|
||||
|
|
@ -318,7 +319,13 @@ public class BigTableReader extends SSTableReaderWithFilter implements IndexSumm
|
|||
{
|
||||
i++;
|
||||
|
||||
ByteBuffer indexKey = ByteBufferUtil.readWithShortLength(in);
|
||||
int length = in.readUnsignedShort();
|
||||
if (indexKey == null || indexKey.capacity() < length)
|
||||
indexKey = ByteBuffer.allocate(length);
|
||||
|
||||
in.readFully(indexKey.array(), 0, length);
|
||||
indexKey.position(0);
|
||||
indexKey.limit(length);
|
||||
|
||||
boolean opSatisfied; // did we find an appropriate position for the op requested
|
||||
boolean exactMatch; // is the current position an exact match for the key, suitable for caching
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import accord.local.Command;
|
|||
import accord.local.KeyHistory;
|
||||
import accord.local.RedundantBefore;
|
||||
import accord.primitives.PartialDeps;
|
||||
import accord.primitives.Participants;
|
||||
import accord.primitives.Routable.Domain;
|
||||
import accord.primitives.SaveStatus;
|
||||
import accord.primitives.Status;
|
||||
|
|
@ -252,7 +251,7 @@ public class CommandsForRangesLoader implements AccordStateCache.Listener<TxnId,
|
|||
if (cmd.partialTxn() == null)
|
||||
return null;
|
||||
|
||||
Participants<?> keysOrRanges = cmd.participants().touches();
|
||||
Ranges keysOrRanges = cmd.participants().touches().toRanges();
|
||||
if (keysOrRanges.domain() != Domain.Range)
|
||||
throw new AssertionError(String.format("Txn keys are not range for %s", cmd.partialTxn()));
|
||||
Ranges ranges = (Ranges) keysOrRanges;
|
||||
|
|
@ -276,7 +275,7 @@ public class CommandsForRangesLoader implements AccordStateCache.Listener<TxnId,
|
|||
}
|
||||
|
||||
PartialDeps partialDeps = cmd.partialDeps();
|
||||
boolean hasAsDep = findAsDep != null && partialDeps.rangeDeps.intersects(findAsDep, ranges);
|
||||
boolean hasAsDep = findAsDep != null && partialDeps != null && partialDeps.rangeDeps.intersects(findAsDep, ranges);
|
||||
return new Summary(cmd.txnId(), cmd.executeAt(), saveStatus, ranges, findAsDep, hasAsDep);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue