Package org.apache.cassandra.db.rows
Class UnfilteredSerializer
- java.lang.Object
-
- org.apache.cassandra.db.rows.UnfilteredSerializer
-
public class UnfilteredSerializer extends java.lang.Object
Serialize/deserialize a single Unfiltered (both on-wire and on-disk).The encoded format for an unfiltered is
<flags>(<row>|<marker>)
where:-
<flags>
is a byte (or two) whose bits are flags used by the rest of the serialization. Each flag is defined/explained below as the "Unfiltered flags" constants. One of those flags is an extension flag, and if present, indicates the presence of a 2ndbyte that contains more flags. If the extension is not set, defaults are assumed for the flags of that 2nd byte. -
<row>
is<clustering><sizes>[<pkliveness>][<deletion>][<columns>]<columns_data>
where:<clustering>
is the row clustering as serialized byClustering.Serializer
(note that static row are an exception and don't have this).<sizes>
are the sizes of the whole unfiltered on disk and of the previous unfiltered. This is only present for sstables and is used to efficiently skip rows (both forward and backward).<pkliveness>
is the row primary key liveness infos, and it contains the timestamp, ttl and local deletion time of that info, though some/all of those can be absent based on the flags.deletion
is the row deletion. It's presence is determined by the flags and if present, it conists of both the deletion timestamp and local deletion time.<columns>
are the columns present in the row encoded byColumns.Serializer.serializeSubset(java.util.Collection<org.apache.cassandra.schema.ColumnMetadata>, org.apache.cassandra.db.Columns, org.apache.cassandra.io.util.DataOutputPlus)
. It is absent if the row contains all the columns of theSerializationHeader
(which is then indicated by a flag).<columns_data>
is the data for each of the column present in the row. The encoding of each data depends on whether the data is for a simple or complex column:- Simple columns are simply encoded as one
<cell>
- Complex columns are encoded as
[<delTime>]<n><cell1>...<celln>
where<delTime>
is the deletion for this complex column (if flags indicates its presence),<n>
is the vint encoded value of n, i.e.<celln>
's 1-based inde and<celli>
are the<cell>
for this complex column
- Simple columns are simply encoded as one
-
<marker>
is<bound><deletion>
where<bound>
is the marker bound as serialized byClusteringBoundOrBoundary.Serializer
and<deletion>
is the marker deletion time.
The serialization of a
<cell>
is defined byCell.Serializer
. -
-
-
Field Summary
Fields Modifier and Type Field Description static UnfilteredSerializer
serializer
-
Constructor Summary
Constructors Constructor Description UnfilteredSerializer()
-
Method Summary
-
-
-
Field Detail
-
serializer
public static final UnfilteredSerializer serializer
-
-
Method Detail
-
serialize
public void serialize(Unfiltered unfiltered, SerializationHelper helper, DataOutputPlus out, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
serialize
public void serialize(Unfiltered unfiltered, SerializationHelper helper, DataOutputPlus out, long previousUnfilteredSize, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeStaticRow
public void serializeStaticRow(Row row, SerializationHelper helper, DataOutputPlus out, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
serializedSize
public long serializedSize(Unfiltered unfiltered, SerializationHelper helper, int version)
-
serializedSize
public long serializedSize(Unfiltered unfiltered, SerializationHelper helper, long previousUnfilteredSize, int version)
-
writeEndOfPartition
public void writeEndOfPartition(DataOutputPlus out) throws java.io.IOException
- Throws:
java.io.IOException
-
serializedSizeEndOfPartition
public long serializedSizeEndOfPartition()
-
deserialize
public Unfiltered deserialize(DataInputPlus in, SerializationHeader header, DeserializationHelper helper, Row.Builder builder) throws java.io.IOException
Deserialize anUnfiltered
from the provided input.- Parameters:
in
- the input from which to deserialize.header
- serialization header corresponding to the serialized data.helper
- the helper to use for deserialization.builder
- a row builder, passed here so we don't allocate a new one for every new row.- Returns:
- the deserialized
Unfiltered
ornull
if we've read the end of a partition. This method is guaranteed to never return empty rows. - Throws:
java.io.IOException
-
deserializeTombstonesOnly
public Unfiltered deserializeTombstonesOnly(FileDataInput in, SerializationHeader header, DeserializationHelper helper) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeStaticRow
public Row deserializeStaticRow(DataInputPlus in, SerializationHeader header, DeserializationHelper helper) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeMarkerBody
public RangeTombstoneMarker deserializeMarkerBody(DataInputPlus in, SerializationHeader header, ClusteringBoundOrBoundary<?> bound) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeRowBody
public Row deserializeRowBody(DataInputPlus in, SerializationHeader header, DeserializationHelper helper, int flags, int extendedFlags, Row.Builder builder) throws java.io.IOException
- Throws:
java.io.IOException
-
skipRowBody
public void skipRowBody(DataInputPlus in) throws java.io.IOException
- Throws:
java.io.IOException
-
skipStaticRow
public void skipStaticRow(DataInputPlus in, SerializationHeader header, DeserializationHelper helper) throws java.io.IOException
- Throws:
java.io.IOException
-
skipMarkerBody
public void skipMarkerBody(DataInputPlus in) throws java.io.IOException
- Throws:
java.io.IOException
-
isEndOfPartition
public static boolean isEndOfPartition(int flags)
-
kind
public static Unfiltered.Kind kind(int flags)
-
isStatic
public static boolean isStatic(int extendedFlags)
-
readExtendedFlags
public static int readExtendedFlags(DataInputPlus in, int flags) throws java.io.IOException
- Throws:
java.io.IOException
-
hasExtendedFlags
public static boolean hasExtendedFlags(Row row)
-
-