<commit_before>//This is the Couchbase DB Admin
//This implements the DB Admin interface

//It requires you to implement
//Additional callback functions using the
//universal callbacks, which are called upon
//completion of the asynchronous threads

#include "factory/db_admin.h"
#include "factory/writeable.h"
#include "factory/couchbase_interface.h"

#include <sstream>
#include <string>
#include <string.h>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <stdlib.h>
#include <exception>

#include "factory/logging_interface.h"

extern "C"
{
	#include <libcouchbase/couchbase.h>
}

#ifndef COUCHBASE_ADMIN
#define COUCHBASE_ADMIN

extern CallbackInterface storage;
extern CallbackInterface retrieval;
extern CallbackInterface deletion;

//Transfer the callback information into a Request and call the registered callback
static void storage_callback(lcb_t instance, const void *cookie, lcb_storage_t op,
   lcb_error_t err, const lcb_store_resp_t *resp)
{
	//Build the request
	Request *r = new Request();
  RequestError *rerr = r->req_err;

	//Get the Key
	std::string key ((char*)resp->v.v0.key);
	r->req_addr = key;

	//Retrieve any errors
  if (err != LCB_SUCCESS) {
    rerr->err_code = COUCHBASE_BADREQUEST;
		rerr->err_message = lcb_strerror(instance, err);
  }
  else {
    rerr->err_code = NOERROR;
  }

	//Call the registered callback function
	std::string rresp = (*storage)(r);
	delete r;
}

static void get_callback(lcb_t instance, const void *cookie, lcb_error_t err,
   const lcb_get_resp_t *resp)
{
	//Build the request
	Request *r = new Request();
  RequestError *rerr = r->req_err;

	//Get the Key
	char *key_data = (char*)resp->v.v0.key;
	if (key_data)
	{
		std::string key (key_data);
		r->req_addr = key;
	}

	//Get the retrieved value
	char *data = (char*)resp->v.v0.bytes;
	if (data)
	{
		std::string val (data);
	}

	//Retrieve any errors
  if (err != LCB_SUCCESS) {
    rerr->err_code = COUCHBASE_BADREQUEST;
		rerr->err_message = lcb_strerror(instance, err);
  }
  else {
    rerr->err_code = NOERROR;
  }
<commit_msg>CB Admin fixes<commit_after>//This is the Couchbase DB Admin
//This implements the DB Admin interface

//It requires you to implement
//Additional callback functions using the
//universal callbacks, which are called upon
//completion of the asynchronous threads

#include "factory/db_admin.h"
#include "factory/writeable.h"
#include "factory/couchbase_interface.h"

#include <sstream>
#include <string>
#include <string.h>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <stdlib.h>
#include <exception>

#include "factory/logging_interface.h"

extern "C"
{
	#include <libcouchbase/couchbase.h>
}

#ifndef COUCHBASE_ADMIN
#define COUCHBASE_ADMIN

extern CallbackInterface storage;
extern CallbackInterface retrieval;
extern CallbackInterface deletion;

//Transfer the callback information into a Request and call the registered callback
static void storage_callback(lcb_t instance, const void *cookie, lcb_storage_t op,
   lcb_error_t err, const lcb_store_resp_t *resp)
{
	//Build the request
	Request *r = new Request();
  RequestError *rerr = r->req_err;

	//Get the Key
	std::string key ((char*)resp->v.v0.key);
	r->req_addr = key;

	//Retrieve any errors
  if (err != LCB_SUCCESS) {
    rerr->err_code = COUCHBASE_BADREQUEST;
		rerr->err_message = lcb_strerror(instance, err);
  }
  else {
    rerr->err_code = NOERROR;
  }

	//Call the registered callback function
	std::string rresp = (*storage)(r);
	delete r;
}

static void get_callback(lcb_t instance, const void *cookie, lcb_error_t err,
   const lcb_get_resp_t *resp)
{
	//Build the request
	Request *r = new Request();
  RequestError *rerr = r->req_err;

	//Get the Key
	char *key_data = (char*)resp->v.v0.key;
	if (key_data)
	{
		std::string key (key_data);
		r->req_addr = key;
	}

	//Get the retrieved value
	char *data = (char*)resp->v.v0.bytes;
	if (data)
	{
		std::string val (data);
		r->req_data = val;
	}

	//Retrieve any errors
  if (err != LCB_SUCCESS) {
    rerr->err_code = COUCHBASE_BADREQUEST;
		rerr->err_message = lcb_strerror(instance, err);
  }
  else {
    rerr->err_code = NOERROR;
  }

{'fraction_non_alphanumeric': 0.11951807228915663, 'fraction_numerical': 0.0014457831325301205, 'mean_word_length': 4.287898089171975, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1980272', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1450, 'n_words': 410}