mirror of https://github.com/apache/cassandra
Fix CFMetaData ids serialization
patch by slebresne; reviewed by iamaleksey for CASSANDRA-9848
This commit is contained in:
parent
a668638611
commit
6249a3b1e6
|
|
@ -2,7 +2,7 @@
|
|||
* Metrics should use up to date nomenclature (CASSANDRA-9448)
|
||||
* Change CREATE/ALTER TABLE syntax for compression (CASSANDRA-8384)
|
||||
* Cleanup crc and adler code for java 8 (CASSANDRA-9650)
|
||||
* Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781, 9808, 9825)
|
||||
* Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781, 9808, 9825, 9848)
|
||||
* Update Guava to 18.0 (CASSANDRA-9653)
|
||||
* Bloom filter false positive ratio is not honoured (CASSANDRA-8413)
|
||||
* New option for cassandra-stress to leave a ratio of columns null (CASSANDRA-9522)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
package org.apache.cassandra.config;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -49,6 +48,7 @@ import org.apache.cassandra.db.marshal.*;
|
|||
import org.apache.cassandra.exceptions.*;
|
||||
import org.apache.cassandra.io.compress.CompressionParameters;
|
||||
import org.apache.cassandra.io.compress.LZ4Compressor;
|
||||
import org.apache.cassandra.io.util.DataInputPlus;
|
||||
import org.apache.cassandra.io.util.DataOutputPlus;
|
||||
import org.apache.cassandra.schema.SchemaKeyspace;
|
||||
import org.apache.cassandra.schema.Triggers;
|
||||
|
|
@ -1507,23 +1507,16 @@ public final class CFMetaData
|
|||
}
|
||||
}
|
||||
|
||||
// We don't use UUIDSerializer below because we want to use this with vint-encoded streams and UUIDSerializer
|
||||
// currently assumes a NATIVE encoding. This is also why we don't use writeLong()/readLong in the methods below:
|
||||
// this would encode the values, but by design of UUID it is likely that both long will be very big numbers
|
||||
// and so we have a fair change that the encoding will take more than 16 bytes which is not desirable. Note that
|
||||
// we could make UUIDSerializer work as the serializer below, but I'll keep that to later.
|
||||
public static class Serializer
|
||||
{
|
||||
public void serialize(CFMetaData metadata, DataOutputPlus out, int version) throws IOException
|
||||
{
|
||||
// for some reason these are stored is LITTLE_ENDIAN; so just reverse them
|
||||
out.writeLong(Long.reverseBytes(metadata.cfId.getMostSignificantBits()));
|
||||
out.writeLong(Long.reverseBytes(metadata.cfId.getLeastSignificantBits()));
|
||||
UUIDSerializer.serializer.serialize(metadata.cfId, out, version);
|
||||
}
|
||||
|
||||
public CFMetaData deserialize(DataInput in, int version) throws IOException
|
||||
public CFMetaData deserialize(DataInputPlus in, int version) throws IOException
|
||||
{
|
||||
UUID cfId = new UUID(Long.reverseBytes(in.readLong()), Long.reverseBytes(in.readLong()));
|
||||
UUID cfId = UUIDSerializer.serializer.deserialize(in, version);
|
||||
CFMetaData metadata = Schema.instance.getCFMetaData(cfId);
|
||||
if (metadata == null)
|
||||
{
|
||||
|
|
@ -1538,8 +1531,7 @@ public final class CFMetaData
|
|||
|
||||
public long serializedSize(CFMetaData metadata, int version)
|
||||
{
|
||||
// We've made sure it was encoded as 16 bytes whatever the TypeSizes is.
|
||||
return 16;
|
||||
return UUIDSerializer.serializer.serializedSize(metadata.cfId, version);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public abstract class ReadResponse
|
|||
{
|
||||
try
|
||||
{
|
||||
DataInput in = new DataInputStream(ByteBufferUtil.inputStream(data));
|
||||
DataInputPlus in = new DataInputPlus.DataInputStreamPlus(ByteBufferUtil.inputStream(data));
|
||||
return UnfilteredPartitionIterators.serializerForIntraNode().deserialize(in, MessagingService.current_version, flag);
|
||||
}
|
||||
catch (IOException e)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
package org.apache.cassandra.db.partitions;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOError;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -29,6 +28,7 @@ import org.apache.cassandra.config.ColumnDefinition;
|
|||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.db.rows.*;
|
||||
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.MergeIterator;
|
||||
|
|
@ -435,7 +435,7 @@ public abstract class UnfilteredPartitionIterators
|
|||
out.writeBoolean(false);
|
||||
}
|
||||
|
||||
public UnfilteredPartitionIterator deserialize(final DataInput in, final int version, final SerializationHelper.Flag flag) throws IOException
|
||||
public UnfilteredPartitionIterator deserialize(final DataInputPlus in, final int version, final SerializationHelper.Flag flag) throws IOException
|
||||
{
|
||||
if (version < MessagingService.VERSION_30)
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.io.util.DataInputPlus;
|
||||
import org.apache.cassandra.io.util.DataOutputPlus;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
|
@ -174,7 +175,7 @@ public class UnfilteredRowIteratorSerializer
|
|||
return size;
|
||||
}
|
||||
|
||||
public Header deserializeHeader(DataInput in, int version, SerializationHelper.Flag flag) throws IOException
|
||||
public Header deserializeHeader(DataInputPlus in, int version, SerializationHelper.Flag flag) throws IOException
|
||||
{
|
||||
CFMetaData metadata = CFMetaData.serializer.deserialize(in, version);
|
||||
DecoratedKey key = StorageService.getPartitioner().decorateKey(ByteBufferUtil.readWithLength(in));
|
||||
|
|
@ -207,7 +208,7 @@ public class UnfilteredRowIteratorSerializer
|
|||
while (UnfilteredSerializer.serializer.deserialize(in, header, helper, rowWriter, markerWriter) != null);
|
||||
}
|
||||
|
||||
public UnfilteredRowIterator deserialize(final DataInput in, int version, SerializationHelper.Flag flag) throws IOException
|
||||
public UnfilteredRowIterator deserialize(final DataInputPlus in, int version, SerializationHelper.Flag flag) throws IOException
|
||||
{
|
||||
final Header h = deserializeHeader(in, version, flag);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,4 +44,4 @@ public class UUIDSerializer implements IVersionedSerializer<UUID>
|
|||
{
|
||||
return TypeSizes.sizeof(uuid.getMostSignificantBits()) + TypeSizes.sizeof(uuid.getLeastSignificantBits());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue