Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.infinispan.server.resp.serialization;
import static org.infinispan.server.resp.serialization.RespConstants.CRLF;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import org.infinispan.server.resp.ByteBufPool;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
/**
* REdis Serialization Protocol (RESP) for primitive values in version 3.
*
* RESP is the wire protocol for communication between client and server. The protocol is text-based and utilizes
* prefixes/special characters to segment messages. We strictly follow the RESP3 serialization format for all objects.
* RESP3 is a superset of RESP2, providing interoperation with objects in version 2 and adding more elements and signals in version 3.
*
*
*
* The basic idea of the protocol is to prefix an element with a magic byte to identify the type. The {@link RespConstants#CRLF_STRING}
* is the protocol terminator that segments the elements. Varying-sized elements have a numeric prefix to determine the size.
* RESP protocol serializes numbers in base 10. Next, we cover each primitive type.
*
*
*
* In this class, we cover the serialization of primitive types in RESP3. The messages are composed of primitive or
* aggregate types, such as arrays and hashes. Aggregate types are composed of other aggregate types or primitives.
*
*
* @see RESP Specification
* @see RESP3 Specification
* @since 15.0
* @author José Bolina
*/
class PrimitiveSerializer {
/**
* Group the serializers for bulk string.
*/
static ResponseSerializer>[] BULK_STRING_SERIALIZERS = {
BulkStringSerializer.INSTANCE,
BulkStringSerializer2.INSTANCE,
};
/**
* Group all serializers, except the null.
*/
static Collection> SERIALIZERS = List.of(
SimpleStringSerializer.INSTANCE,
BulkStringSerializer.INSTANCE,
BulkStringSerializer2.INSTANCE,
IntegerSerializer.INSTANCE,
SimpleErrorSerializer.INSTANCE,
BooleanSerializer.INSTANCE
);
/**
* Represent non-existent values.
*
*
* The prefix is the underscore character ({@link RespConstants#NULL}), followed by the separator.
*
*
* Warning: Always check with the null serializer first before trying any other. This approach guarantees the
* value is non-null during the serialization.
*/
final static class NullSerializer implements ResponseSerializer