AC_CHECK_FUNCS([sched_yield])
fi
+AC_CHECK_HEADER([lz4.h], AC_CHECK_LIB([lz4], [main]))
+AC_CHECK_HEADER([snappy.h], AC_CHECK_LIB([snappy], [main]))
+AC_CHECK_HEADER([zlib.h], AC_CHECK_LIB([z], [main]))
+AC_CHECK_HEADER([lzma.h], AC_CHECK_LIB([lzma], [main]))
+
AC_SUBST(AM_CPPFLAGS, '-I../$(top_srcdir)'" "'-I$(top_srcdir)/io'" "'-I$(top_srcdir)/test'" $BOOST_CPPFLAGS")
AC_SUBST(AM_LDFLAGS, "$BOOST_LDFLAGS $BOOST_THREAD_LIB $BOOST_FILESYSTEM_LIB $BOOST_SYSTEM_LIB $BOOST_REGEX_LIB -lpthread")
#include "folly/io/Compression.h"
+#if FOLLY_HAVE_LIBLZ4
#include <lz4.h>
#include <lz4hc.h>
+#endif
+
#include <glog/logging.h>
+
+#if FOLLY_HAVE_LIBSNAPPY
#include <snappy.h>
#include <snappy-sinksource.h>
+#endif
+
+#if FOLLY_HAVE_LIBZ
#include <zlib.h>
+#endif
+
+#if FOLLY_HAVE_LIBLZMA
#include <lzma.h>
+#endif
#include "folly/Conv.h"
#include "folly/Memory.h"
return data->clone();
}
+namespace {
+
+void encodeVarintToIOBuf(uint64_t val, folly::IOBuf* out) {
+ DCHECK_GE(out->tailroom(), kMaxVarintLength64);
+ out->append(encodeVarint(val, out->writableTail()));
+}
+
+uint64_t decodeVarintFromCursor(folly::io::Cursor& cursor) {
+ // Must have enough room in *this* buffer.
+ auto p = cursor.peek();
+ folly::ByteRange range(p.first, p.second);
+ uint64_t val = decodeVarint(range);
+ cursor.skip(range.data() - p.first);
+ return val;
+}
+
+} // namespace
+
+#if FOLLY_HAVE_LIBLZ4
+
/**
* LZ4 compression
*/
return 1.8 * (uint64_t(1) << 30);
}
-namespace {
-
-void encodeVarintToIOBuf(uint64_t val, folly::IOBuf* out) {
- DCHECK_GE(out->tailroom(), kMaxVarintLength64);
- out->append(encodeVarint(val, out->writableTail()));
-}
-
-uint64_t decodeVarintFromCursor(folly::io::Cursor& cursor) {
- // Must have enough room in *this* buffer.
- auto p = cursor.peek();
- folly::ByteRange range(p.first, p.second);
- uint64_t val = decodeVarint(range);
- cursor.skip(range.data() - p.first);
- return val;
-}
-
-} // namespace
-
std::unique_ptr<IOBuf> LZ4Codec::doCompress(const IOBuf* data) {
std::unique_ptr<IOBuf> clone;
if (data->isChained()) {
return out;
}
+#endif // FOLLY_HAVE_LIBLZ4
+
+#if FOLLY_HAVE_LIBSNAPPY
+
/**
* Snappy compression
*/
return out;
}
+#endif // FOLLY_HAVE_LIBSNAPPY
+
+#if FOLLY_HAVE_LIBZ
/**
* Zlib codec
*/
return false;
}
-
std::unique_ptr<IOBuf> ZlibCodec::doCompress(const IOBuf* data) {
z_stream stream;
stream.zalloc = nullptr;
return out;
}
+#endif // FOLLY_HAVE_LIBZ
+
+#if FOLLY_HAVE_LIBLZMA
+
/**
* LZMA2 compression
*/
return out;
}
+#endif // FOLLY_HAVE_LIBLZMA
typedef std::unique_ptr<Codec> (*CodecFactory)(int, CodecType);
static_cast<size_t>(CodecType::NUM_CODEC_TYPES)] = {
nullptr, // USER_DEFINED
NoCompressionCodec::create,
+
+#if FOLLY_HAVE_LIBLZ4
LZ4Codec::create,
+#else
+ nullptr,
+#endif
+
+#if FOLLY_HAVE_LIBSNAPPY
SnappyCodec::create,
+#else
+ nullptr,
+#endif
+
+#if FOLLY_HAVE_LIBZ
ZlibCodec::create,
+#else
+ nullptr,
+#endif
+
+#if FOLLY_HAVE_LIBLZ4
LZ4Codec::create,
+#else
+ nullptr,
+#endif
+
+#if FOLLY_HAVE_LIBLZMA
LZMA2Codec::create,
LZMA2Codec::create,
+#else
+ nullptr,
+ nullptr,
+#endif
};
} // namespace