mirror of https://github.com/apache/cassandra
Fix legacy non-compound range tombstone serialization
Patch by Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-11930
This commit is contained in:
parent
02f78f658c
commit
c98b6484e1
|
|
@ -1,4 +1,6 @@
|
|||
3.0.7
|
||||
* Fix legacy serialization of Thrift-generated non-compound range tombstones
|
||||
when communicating with 2.x nodes (CASSANDRA-11930)
|
||||
* Fix Directories instantiations where CFS.initialDirectories should be used (CASSANDRA-11849)
|
||||
* Avoid referencing DatabaseDescriptor in AbstractType (CASSANDRA-11912)
|
||||
* Fix sstables not being protected from removal during index build (CASSANDRA-11905)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ import org.apache.cassandra.io.util.DataInputPlus;
|
|||
import org.apache.cassandra.io.util.DataOutputPlus;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
import org.apache.cassandra.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
|
||||
|
||||
|
|
@ -49,6 +51,8 @@ import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
|
|||
*/
|
||||
public abstract class LegacyLayout
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(LegacyLayout.class);
|
||||
|
||||
public final static int MAX_CELL_NAME_LENGTH = FBUtilities.MAX_UNSIGNED_SHORT;
|
||||
|
||||
public final static int STATIC_PREFIX = 0xFFFF;
|
||||
|
|
@ -2199,9 +2203,19 @@ public abstract class LegacyLayout
|
|||
if (size == 0)
|
||||
return;
|
||||
|
||||
if (metadata.isCompound())
|
||||
serializeCompound(out, metadata.isDense());
|
||||
else
|
||||
serializeSimple(out);
|
||||
}
|
||||
|
||||
private void serializeCompound(DataOutputPlus out, boolean isDense) throws IOException
|
||||
{
|
||||
List<AbstractType<?>> types = new ArrayList<>(comparator.clusteringComparator.subtypes());
|
||||
if (!metadata.isDense())
|
||||
|
||||
if (!isDense)
|
||||
types.add(UTF8Type.instance);
|
||||
|
||||
CompositeType type = CompositeType.getInstance(types);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
|
|
@ -2230,6 +2244,30 @@ public abstract class LegacyLayout
|
|||
}
|
||||
}
|
||||
|
||||
private void serializeSimple(DataOutputPlus out) throws IOException
|
||||
{
|
||||
List<AbstractType<?>> types = new ArrayList<>(comparator.clusteringComparator.subtypes());
|
||||
assert types.size() == 1 : types;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
LegacyBound start = starts[i];
|
||||
LegacyBound end = ends[i];
|
||||
|
||||
ClusteringPrefix startClustering = start.bound.clustering();
|
||||
ClusteringPrefix endClustering = end.bound.clustering();
|
||||
|
||||
assert startClustering.size() == 1;
|
||||
assert endClustering.size() == 1;
|
||||
|
||||
ByteBufferUtil.writeWithShortLength(startClustering.get(0), out);
|
||||
ByteBufferUtil.writeWithShortLength(endClustering.get(0), out);
|
||||
|
||||
out.writeInt(delTimes[i]);
|
||||
out.writeLong(markedAts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public long serializedSize(CFMetaData metadata)
|
||||
{
|
||||
long size = 0;
|
||||
|
|
@ -2238,8 +2276,17 @@ public abstract class LegacyLayout
|
|||
if (this.size == 0)
|
||||
return size;
|
||||
|
||||
if (metadata.isCompound())
|
||||
return size + serializedSizeCompound(metadata.isDense());
|
||||
else
|
||||
return size + serializedSizeSimple();
|
||||
}
|
||||
|
||||
private long serializedSizeCompound(boolean isDense)
|
||||
{
|
||||
long size = 0;
|
||||
List<AbstractType<?>> types = new ArrayList<>(comparator.clusteringComparator.subtypes());
|
||||
if (!metadata.isDense())
|
||||
if (!isDense)
|
||||
types.add(UTF8Type.instance);
|
||||
CompositeType type = CompositeType.getInstance(types);
|
||||
|
||||
|
|
@ -2269,5 +2316,31 @@ public abstract class LegacyLayout
|
|||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
private long serializedSizeSimple()
|
||||
{
|
||||
long size = 0;
|
||||
List<AbstractType<?>> types = new ArrayList<>(comparator.clusteringComparator.subtypes());
|
||||
assert types.size() == 1 : types;
|
||||
|
||||
for (int i = 0; i < this.size; i++)
|
||||
{
|
||||
LegacyBound start = starts[i];
|
||||
LegacyBound end = ends[i];
|
||||
|
||||
ClusteringPrefix startClustering = start.bound.clustering();
|
||||
ClusteringPrefix endClustering = end.bound.clustering();
|
||||
|
||||
assert startClustering.size() == 1;
|
||||
assert endClustering.size() == 1;
|
||||
|
||||
size += ByteBufferUtil.serializedSizeWithShortLength(startClustering.get(0));
|
||||
size += ByteBufferUtil.serializedSizeWithShortLength(endClustering.get(0));
|
||||
|
||||
size += TypeSizes.sizeof(delTimes[i]);
|
||||
size += TypeSizes.sizeof(markedAts[i]);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue