예제 #1
0
		void
		Compress(const std::vector<T>& data, BufferT& out)
		{
			ssize_t countBS = sizeof(T)*data.size();

			// allocate as much memory as we need
			int maxOut = LZ4_compressBound(countBS);
			out.resize(maxOut);

			int r = LZ4_compress((const char*)&data.front(), (char*)&out.front(), countBS);
			if(r == 0) {
				Util::fire_exception("lz4 compression failed");
			}

			// trim to really used size
			out.resize(r);
		}
예제 #2
0
파일: ArLZO.hpp 프로젝트: urykhy/reportdb
		void
		Compress(const std::vector<T>& data, BufferT& out)
		{
			ssize_t countBS = sizeof(T)*data.size();
			lzo_uint outLen=(countBS + countBS / 16 + 64 + 3);   // from simple.c in LZO distrib

			// allocate as much memory as we need
			out.resize(outLen);

			int32_t r = lzo1x_999_compress(
				reinterpret_cast<const lzo_bytep>(&data.front()),
				countBS,
				&out.front(),
				&outLen,
				&lzoTemp[0]);
			if (r != LZO_E_OK) {
				Util::fire_exception("lzo compression failed");
			}

			// trim to really used size
			out.resize(outLen);
		}