MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / write

Method write

extensions/rocksdb-repos/RocksDbStream.cpp:54–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54int RocksDbStream::write(const uint8_t *value, int size) {
55 gsl_Expects(size >= 0);
56 if (!write_enable_) {
57 return -1;
58 }
59 if (size == 0) {
60 return 0;
61 }
62 if (!IsNullOrEmpty(value)) {
63 auto opendb = db_->open();
64 if (!opendb) {
65 return -1;
66 }
67 rocksdb::Slice slice_value((const char *) value, size);
68 rocksdb::Status status;
69 size_ += size;
70 if (batch_ != nullptr) {
71 status = batch_->Merge(path_, slice_value);
72 } else {
73 rocksdb::WriteOptions opts;
74 opts.sync = true;
75 status = opendb->Merge(opts, path_, slice_value);
76 }
77 if (status.ok()) {
78 return size;
79 } else {
80 return -1;
81 }
82 } else {
83 return -1;
84 }
85}
86
87int RocksDbStream::read(uint8_t *buf, int buflen) {
88 gsl_Expects(buflen >= 0);

Callers

nothing calls this directly

Calls 3

IsNullOrEmptyFunction · 0.85
openMethod · 0.80
MergeMethod · 0.45

Tested by

no test coverage detected