My Project
Static Public Member Functions | List of all members
ParaEngine::CIntegerEncoder Class Reference

Static Public Member Functions

template<typename VALUE_TYPE >
static bool TryDecodeUInt32 (CParaFile &source, VALUE_TYPE &value, int &nByteRead)
 
template<typename VALUE_TYPE >
static int EncodeUInt32 (VALUE_TYPE value, BYTE *buffer, StringBuilder &stream)
 
template<typename VALUE_TYPE >
static int EncodeSkipOne (StringBuilder &stream, const std::vector< VALUE_TYPE > &data)
 Author: LiXizhi here we will use skip 1 algorithm to compress the data, since the result is sorted integer. More...
 
template<typename VALUE_TYPE >
static bool IsSkipOneBetter (const std::vector< VALUE_TYPE > &data)
 return true, if more than half of the input is continuous integer with step 1. More...
 
template<typename VALUE_TYPE >
static void DecodeSkipOne (CParaFile &stream, std::vector< VALUE_TYPE > &list, int nStreamSize=0xfffffff)
 
template<typename VALUE_TYPE >
static int EncodeIntDeltaArray (StringBuilder &stream, const std::vector< VALUE_TYPE > &data)
 
template<typename VALUE_TYPE >
static void DecodeIntDeltaArray (CParaFile &stream, std::vector< VALUE_TYPE > &list, int nStreamSize=0xfffffff)
 
template<typename VALUE_TYPE >
static int EncodeSameInteger (StringBuilder &stream, const std::vector< VALUE_TYPE > &data)
 Author: LiXizhi if the input array contains, many data of the same value. More...
 
template<typename VALUE_TYPE >
static void DecodeSameInteger (CParaFile &stream, std::vector< VALUE_TYPE > &list, int nStreamSize=0xfffffff)
 
template<typename VALUE_TYPE >
static bool IsSameIntegerBetter (const std::vector< VALUE_TYPE > &data)
 
template<typename VALUE_TYPE >
static int EncodeIntArray (StringBuilder &stream, const std::vector< VALUE_TYPE > &data)
 
template<typename VALUE_TYPE >
static void DecodeIntArray (CParaFile &stream, std::vector< VALUE_TYPE > &list, int nStreamSize=0xfffffff)
 

Member Function Documentation

§ EncodeSameInteger()

template<typename VALUE_TYPE >
static int ParaEngine::CIntegerEncoder::EncodeSameInteger ( StringBuilder stream,
const std::vector< VALUE_TYPE > &  data 
)
inlinestatic

Author: LiXizhi if the input array contains, many data of the same value.

1,1,1,2,2,2,2,3,3,3,3 is saved as 1,3,2,4,3,4 (value, count, value, count, ... value)

§ EncodeSkipOne()

template<typename VALUE_TYPE >
static int ParaEngine::CIntegerEncoder::EncodeSkipOne ( StringBuilder stream,
const std::vector< VALUE_TYPE > &  data 
)
inlinestatic

Author: LiXizhi here we will use skip 1 algorithm to compress the data, since the result is sorted integer.

More advanced one is PForDelta algorithm, which is discussed in part here http://stackoverflow.com/questions/283299/best-compression-algorithm-for-a-sequence-of-integers Example: to compress: 1-100, 110-160: "skip 1" (assume start at zero as it makes things easier), "take 100", "skip 9", "take 51"; subtract 1 from each, giving (as decimals) result: 0,99,8,50

§ IsSkipOneBetter()

template<typename VALUE_TYPE >
static bool ParaEngine::CIntegerEncoder::IsSkipOneBetter ( const std::vector< VALUE_TYPE > &  data)
inlinestatic

return true, if more than half of the input is continuous integer with step 1.

if true, we prefer using EncodeSkipOne.


The documentation for this class was generated from the following file: