Snappy.java — netty Source File
Architecture documentation for Snappy.java, a java file in the netty codebase.
Entity Profile
Relationship Graph
Source Code
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.util.concurrent.FastThreadLocal;
import io.netty.util.internal.MathUtil;
import io.netty.util.internal.SystemPropertyUtil;
import java.util.Arrays;
/**
* Uncompresses an input {@link ByteBuf} encoded with Snappy compression into an
* output {@link ByteBuf}.
* <p>
* See <a href="https://github.com/google/snappy/blob/master/format_description.txt">snappy format</a>.
*/
public final class Snappy {
private static final int MAX_HT_SIZE = 1 << 14;
private static final int MIN_COMPRESSIBLE_BYTES = 15;
// used as a return value to indicate that we haven't yet read our full preamble
private static final int PREAMBLE_NOT_FULL = -1;
private static final int NOT_ENOUGH_INPUT = -1;
// constants for the tag types
private static final int LITERAL = 0;
private static final int COPY_1_BYTE_OFFSET = 1;
private static final int COPY_2_BYTE_OFFSET = 2;
private static final int COPY_4_BYTE_OFFSET = 3;
// Hash table used to compress, shared between subsequent call to .encode()
private static final FastThreadLocal<short[]> HASH_TABLE = new FastThreadLocal<short[]>();
private static final boolean DEFAULT_REUSE_HASHTABLE =
SystemPropertyUtil.getBoolean("io.netty.handler.codec.compression.snappy.reuseHashTable", false);
public Snappy() {
this(DEFAULT_REUSE_HASHTABLE);
}
Snappy(boolean reuseHashtable) {
this.reuseHashtable = reuseHashtable;
}
public static Snappy withHashTableReuse() {
// ... (664 more lines)
Domain
Subdomains
Classes
Types
Source
Frequently Asked Questions
What does Snappy.java do?
Snappy.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is Snappy.java in the architecture?
Snappy.java is located at codec-compression/src/main/java/io/netty/handler/codec/compression/Snappy.java (domain: Buffer, subdomain: Allocators, directory: codec-compression/src/main/java/io/netty/handler/codec/compression).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free