/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Avro.File
{
abstract public class Codec
{
///
/// Compress data using implemented codec
///
///
///
abstract public byte[] Compress(byte[] uncompressedData);
///
/// Decompress data using implemented codec
///
///
///
abstract public byte[] Decompress(byte[] compressedData);
///
/// Name of this codec type
///
///
abstract public string GetName();
///
/// Codecs must implement an equals() method
///
///
///
abstract public override bool Equals(object other);
///
/// Codecs must implement a HashCode() method that is
/// consistent with Equals
///
///
abstract public override int GetHashCode();
///
/// Codec types
///
public enum Type
{
Deflate,
//Snappy
Null
};
///
/// Factory method to return child
/// codec instance based on Codec.Type
///
///
///
public static Codec CreateCodec(Type codecType)
{
switch (codecType)
{
case Type.Deflate:
return new DeflateCodec();
default:
return new NullCodec();
}
}
///
/// Factory method to return child
/// codec instance based on string type
///
///
///
public static Codec CreateCodecFromString(string codecType)
{
switch (codecType)
{
case DataFileConstants.DeflateCodec:
return new DeflateCodec();
default:
return new NullCodec();
}
}
///
/// Returns name of codec
///
///
public override string ToString()
{
return GetName();
}
}
}