Package io.deephaven.grpc.compression
Class CompressionCodecs
java.lang.Object
io.deephaven.grpc.compression.CompressionCodecs
The compression types that Deephaven supports for gRPC messages, named as in gRPC's
grpc-encoding and
grpc-accept-encoding headers; their gRPC registries; and parsers for compression type lists and a client's
grpc-accept-encoding. The supported types are the ones that the CompressionCodecProviders on the
classpath supply: zstd, gzip, snappy and deflate, whose providers this module
includes, plus every type that a deployment's own provider adds.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckSupported(@NotNull String name) static io.grpc.Codecstatic io.grpc.CompressorRegistrystatic io.grpc.CompressorRegistrycompressorRegistry(@NotNull Collection<String> types) static io.grpc.DecompressorRegistrydecompressorRegistry(@NotNull Collection<String> advertised) Builds a registry that can decode every supported encoding, but advertises onlyadvertisedin thegrpc-accept-encodingheader.static io.grpc.DecompressorRegistrydecompressorRegistry(@NotNull Collection<String> types, @NotNull Collection<String> advertised) Builds a registry that can decode each oftypes, but advertises only those also inadvertisedin thegrpc-accept-encodingheader.parseAcceptEncoding(@Nullable String header) Parses the value of agrpc-accept-encodingheader.Parses an ordered, comma-separated list of encoding names, such as"zstd, snappy, gzip".
-
Field Details
-
SUPPORTED
The name of every supported compression type, excludingidentity, sorted by name. The providers this module includes supply:deflate: the algorithm ofgzipin the zlib format, which compresses to the same size at the same speed and decompresses slightly slower. Clients built on gRPC Core, such as the Python, C++ and R clients, can decode it andgzip, but no other type this module includes.gzip: compresses slightly smaller thanzstdbut much more slowly. Most gRPC clients can decode it.snappy: the fastest of these types, but the one that saves the least.zstd: Zstandard, which compresses nearly as well asgzip, and many times faster.
CompressionCodecProvideron the classpath adds its type, or replaces the built-in type of the same name.
-
-
Method Details
-
compressorRegistry
public static io.grpc.CompressorRegistry compressorRegistry()- Returns:
- a registry holding a compressor for every supported encoding, plus
identity
-
compressorRegistry
public static io.grpc.CompressorRegistry compressorRegistry(@NotNull @NotNull Collection<String> types) - Parameters:
types- the encodings to register; each must besupported- Returns:
- a registry holding a compressor for each of
types, plusidentity
-
decompressorRegistry
public static io.grpc.DecompressorRegistry decompressorRegistry(@NotNull @NotNull Collection<String> advertised) Builds a registry that can decode every supported encoding, but advertises onlyadvertisedin thegrpc-accept-encodingheader.- Parameters:
advertised- the encodings to advertise; each must besupported- Returns:
- the registry
-
decompressorRegistry
public static io.grpc.DecompressorRegistry decompressorRegistry(@NotNull @NotNull Collection<String> types, @NotNull @NotNull Collection<String> advertised) Builds a registry that can decode each oftypes, but advertises only those also inadvertisedin thegrpc-accept-encodingheader. -
codec
- Parameters:
name- the name of a compression type; case and surrounding whitespace are ignored- Returns:
- the codec for
name, the one thatcompressorRegistry()anddecompressorRegistry(Collection)register - Throws:
IllegalArgumentException- ifnameis notsupported
-
parseList
Parses an ordered, comma-separated list of encoding names, such as"zstd, snappy, gzip". Names are trimmed and lower-cased, blank entries are skipped, and repeats keep their first position.- Parameters:
list- the list to parse;nullor blank yields an empty list- Returns:
- the encodings, in order of preference
- Throws:
IllegalArgumentException- if a name is notsupported
-
parseAcceptEncoding
Parses the value of agrpc-accept-encodingheader. UnlikeparseList(String), unknown names are kept; they simply never match.- Parameters:
header- the header value;nullyields an empty set- Returns:
- the lower-cased encoding names
-
checkSupported
- Parameters:
name- the name of a compression type; case and surrounding whitespace are ignored- Returns:
name, trimmed and lower-cased- Throws:
IllegalArgumentException- ifnameis notsupported
-