| ns/op | op/s | MdAPE | benchmark
|--------------------:|--------------------:|--------:|:----------------------------------------------
| 3.03 | 329,748,861.72 | 3.2% | `(a + b) / 2`
| 3.01 | 332,744,047.95 | 4.1% | `a + ((b - a) / 2)`
| 3.01 | 331,690,526.09 | 2.3% | `A/2 + B/2 + (A & B & 1)`
| 3.13 | 318,986,706.11 | 2.3% | `std::midpoint()`
// use it like so: | |
// auto l = co_away LM.lock(co_await this_coro{}, resource_type, resource_id); | |
// auto l = co_await LM.shared_lock(resource_type, resource_id); | |
// | |
// this_coro{} is a statub; using the await_transform() facilities of promise_type{} | |
// facilites zero-cost access to the current coroutine handle; which is | |
// used for exclusive locks, e.g | |
/* | |
struct this_coro final { | |
// |
bool Microservice::tx(connection *const c) { | |
int fd = c->fd; | |
_l1: | |
auto it = c->out.head; | |
auto index = c->out.head_data_index; | |
if (!it->next) { | |
// fast-path | |
const auto size = it->size; | |
int r = writev(fd, it->data + c->out.head_data_index, size - index); |
// contrived example | |
task<int> fun_with_coroutines() { | |
auto fd = co_await async_open("/tmp/file.txt", O_RDONLY); | |
if (-1 == fd) { | |
co_return - 1; | |
} | |
char buf[16]; |
#!/bin/bash | |
# This builds a self-contained archive for access to abseil containers+hashes | |
mkdir /tmp/BUILDYARD | |
cd /tmp/BUILDYARD | |
git clone --depth 1 https://github.com/abseil/abseil-cpp.git | |
cd abseil-cpp | |
mkdir build | |
cd build | |
cmake .. -DABSL_RUN_TESTS=ON -DABSL_USE_GOOGLETEST_HEAD=ON -DCMAKE_CXX_STANDARD=17 | |
cmake --build . --target all |
int main(int argc, char *argv[]) { | |
std::vector<unsigned> arr{1, 2, 3, 4}, out; | |
const auto reduce = [](auto it, const auto end, | |
auto &&f, auto &&result) { | |
using lambda_t = decltype(f); | |
using value_t = typename std::remove_reference<decltype(*it)>::type; | |
using res_t = typename std::result_of<lambda_t(decltype(result), value_t)>::type; | |
while (it != end) { |
#include <atomic> | |
#include <thread> | |
struct Thread { | |
struct thread_id final { | |
uint32_t id_; | |
thread_id() { | |
static std::atomic<uint32_t> next{0}; |
#ifndef TOKEN_PASTE | |
#define TOKEN_PASTE(x, y) x##y | |
#define TOKEN_PASTE2(x, y) TOKEN_PASTE(x, y) | |
#endif | |
template <typename L> | |
struct scope_guard | |
{ | |
L l_; | |
bool invoked_{false}; |
Trinity is a modern C++ information-retrieval library for building queries, indexing documents and other content, running queries and scoring documents matching them. It facilitates the development of search engines and other systems and applications that depend on that functionality, and has been designed with simplicity, performance, modularity, extensibility, and elegance
in mind.
This is the initial release and as such, new features and API extensions may come in later releases. It has been under development for 2 weeks, and will be updated frequently with improvements, enhancements and fixes to any potential issues reported.
It's named after Trinity in the Matrix movies, and it's also about the Trinity of (query, index, search) that are the core functions supported by the library.
Trinity makes it easy to index documents and access all documents that match a query. It solves the recall problem and everything else about it, and it gives
struct query_assign_ctx | |
{ | |
uint32_t nextIndex; | |
std::vector<std::vector<phrase *> *> stack; | |
}; | |
static void assign_query_indices(ast_node *const n, query_assign_ctx &ctx) | |
{ | |
if (n->is_unary()) | |
{ |