github.com/tsuna/gohbase@v0.0.0-20250731002811-4ffcadfba63e/compression/codec.go (about)

     1  // Copyright (C) 2020  The GoHBase Authors.  All rights reserved.
     2  // This file is part of GoHBase.
     3  // Use of this source code is governed by the Apache License 2.0
     4  // that can be found in the COPYING file.
     5  
     6  package compression
     7  
     8  import (
     9  	"github.com/tsuna/gohbase/compression/snappy"
    10  )
    11  
    12  // Codec is used to encode and decode chunks of hadoop's sequence file chunks.
    13  type Codec interface {
    14  	// Encode encodes uncompressed bytes from src and appends them to dst.
    15  	Encode(src, dst []byte) ([]byte, uint32)
    16  	// Decode decodes compressed bytes from src and appends them to dst.
    17  	Decode(src, dst []byte) ([]byte, uint32, error)
    18  	// ChunkLen returns the maximum size of chunk for particular codec.
    19  	ChunkLen() uint32
    20  	// CellBlockCompressorClass returns full Java class name of the compressor on the HBase side
    21  	CellBlockCompressorClass() string
    22  }
    23  
    24  // New instantiates passed codec. Currently supported codes are:
    25  // - snappy
    26  func New(codec string) Codec {
    27  	switch codec {
    28  	case "snappy":
    29  		return snappy.New()
    30  	default:
    31  		panic("uknown compression codec")
    32  	}
    33  }