MCPcopy Create free account
hub / github.com/bcndev/bytecoin / Cursor

Method Cursor

src/platform/DBsqlite3.cpp:126–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124static const size_t max_key_size = 255;
125
126DBsqliteKV::Cursor::Cursor(const DBsqliteKV *db,
127 const sqlite::Dbi &db_dbi,
128 const std::string &prefix,
129 const std::string &middle,
130 bool forward)
131 : db(db), prefix(prefix) {
132 std::string start = prefix + middle;
133 std::string finish = start;
134 if (finish.size() < max_key_size)
135 finish += std::string(max_key_size - finish.size(), char(0xff)); // char('~')
136 const char *sql = forward ? "SELECT kk, vv FROM kv_table WHERE kk >= ? ORDER BY kk ASC"
137 : "SELECT kk, vv FROM kv_table WHERE kk <= ? ORDER BY kk DESC";
138 stmt_get.prepare(db_dbi, sql);
139 stmt_get.bind_blob(1, forward ? start.data() : finish.data(), forward ? start.size() : finish.size());
140 step_and_check();
141}
142
143void DBsqliteKV::Cursor::next() { step_and_check(); }
144

Callers

nothing calls this directly

Calls 4

bind_blobMethod · 0.80
sizeMethod · 0.45
prepareMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected