<commit_before>/*
Copyright (c) 2012-2014 The SSDB Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
/* kv */
#include "serv.h"
#include "net/proc.h"
#include "net/server.h"


int proc_type(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;
	CHECK_NUM_PARAMS(2);

	std::string val;
	int ret = serv->ssdb->type(req[1], &val);
	check_key(ret);
	if(ret < 0){
		reply_err_return(ret);
	}

	resp->reply_get(ret, &val);

	return 0;
}

int proc_get(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;
	CHECK_NUM_PARAMS(2);

	std::string val;
	int ret = serv->ssdb->get(req[1], &val);
	check_key(ret);
	if(ret < 0){
		reply_err_return(ret);
	} else {
		resp->reply_get(ret, &val);
	}

	return 0;
}

int proc_getset(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;<commit_msg>SWAP-29 修复key不存在时候type命令返回结果<commit_after>/*
Copyright (c) 2012-2014 The SSDB Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
/* kv */
#include "serv.h"
#include "net/proc.h"
#include "net/server.h"


int proc_type(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;
	CHECK_NUM_PARAMS(2);

	std::string val;
	int ret = serv->ssdb->type(req[1], &val);
	check_key(ret);
	if(ret < 0){
		reply_err_return(ret);
	}

	resp->reply_get(1, &val);

	return 0;
}

int proc_get(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;
	CHECK_NUM_PARAMS(2);

	std::string val;
	int ret = serv->ssdb->get(req[1], &val);
	check_key(ret);
	if(ret < 0){
		reply_err_return(ret);
	} else {
		resp->reply_get(ret, &val);
	}

	return 0;
}

int proc_getset(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;
{'fraction_non_alphanumeric': 0.15749162278602202, 'fraction_numerical': 0.01675442795595979, 'mean_word_length': 4.726027397260274, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '634400', 'n_tokens_mistral': 837, 'n_tokens_neox': 811, 'n_words': 218}