13 #include <boost/thread.hpp>
14 #include <boost/regex.hpp>
15 #include <boost/iostreams/device/mapped_file.hpp>
17 #include <eblob/eblob.hpp>
21 int main(int argc
, char *argv
[])
24 std::cerr
<< "Usage: " << argv
[0] << " eblob log log_mask" << std::endl
;
28 std::string input_blob_name
= argv
[1];
30 char *log_file
= (char *)"/dev/stdout";
34 int log_mask
= EBLOB_LOG_INFO
| EBLOB_LOG_ERROR
;
36 log_mask
= ::strtoul(argv
[3], NULL
, 0);
39 eblob
eblob(log_file
, log_mask
, input_blob_name
);
41 struct eblob_key ekey
;
42 memset(&ekey
, 0, sizeof(ekey
));
43 snprintf((char *)ekey
.id
, sizeof(ekey
.id
), "test_key");
45 std::string data
= "this is supposed to be compressed data";
46 eblob
.write(ekey
, data
, 0, BLOB_DISK_CTL_COMPRESS
);
48 std::cout
<< "read: " << eblob
.read(ekey
, 0, 0) << std::endl
;
50 std::string key
= "to-be-hashed-test-key";
52 data
= "this is supposed to be compressed data";
53 eblob
.write_hashed(key
, data
, 0, BLOB_DISK_CTL_COMPRESS
);
54 std::cout
<< "read hashed: " << eblob
.read_hashed(key
, 0, 0) << std::endl
;
56 memset(&ekey
, 0, sizeof(ekey
));
57 snprintf((char *)ekey
.id
, sizeof(ekey
.id
), "test_key1");
59 data
= "this is a plain uncompressed data1 ";
60 eblob
.write(ekey
, data
, 0, 0);
61 std::cout
<< "read1: " << eblob
.read(ekey
, 0, 0) << std::endl
;
63 uint64_t offset
= data
.size();
64 data
= "this is a plain uncompressed data2";
65 eblob
.write(ekey
, data
, offset
, 0);
66 std::cout
<< "read2: " << eblob
.read(ekey
, 5, 0) << std::endl
;
68 } catch (const std::exception
&e
) {
69 std::cerr
<< e
.what() << std::endl
;