提交 f1277a5c 编写于 作者: D Daniel Gustafsson

Remove unused and inline single-use functions

This removes a few unused functions, and inlines the function body of
another one which only had a single caller. Also properly mark a
few functions as static.
Reviewed-by: NHeikki Linnakangas <hlinnakangas@pivotal.io>
上级 ccfe82b7
......@@ -289,49 +289,3 @@ void serializeSparseData(char *target, SparseData source)
((StringInfo)(SDATA_INDEX_SINFO(target)))->data = NULL;
}
}
#ifdef NOT
//TODO
SparseData deserializeSparseData(char *source)
{
SparseData sdata = makeEmptySparseData();
char *target = (char *)sdata;
int index_size,vals_size;
/* Unpack into an empty SparseDataStructure and fill the empty
* StringInfo structures with data
*/
/* SparseDataStruct header */
memcpy(target,source,SIZEOF_SPARSEDATAHDR);
target+=SIZEOF_SPARSEDATAHDR;
index_size = SDATA_INDEX_SIZE(source);
vals_size = SDATA_DATA_SIZE(source);
sdata->vals->data = (char *)palloc(vals_size);
sdata->index->data = (char *)palloc(index_size);
sdata->vals->len = sdata->unique_value_count;
sdata->vals->maxlen = sdata->unique_value_count;
memcpy(sdata->vals->data,SDATA_VALS_PTR(source),vals_size);
sdata->index->len = index_size;
sdata->index->maxlen = sdata->index->len;
memcpy(sdata->index->data,SDATA_INDEX_PTR(source),index_size);
return(sdata);
}
#endif
void printSparseData(SparseData sdata);
void printSparseData(SparseData sdata) {
int value_count = sdata->unique_value_count;
{
char *indexdata = sdata->index->data;
double *values = (double *)(sdata->vals->data);
for (int i=0; i<value_count; i++) {
printf("run_length[%d] = %lld, ",i,(long long int)compword_to_int8(indexdata));
printf("value[%d] = %f\n",i,values[i]);
indexdata+=int8compstoragesize(indexdata);
}
}
}
......@@ -127,7 +127,6 @@ typedef SparseDataStruct *SparseData;
int64 *sdata_index_to_int64arr(SparseData sdata);
void serializeSparseData(char *target, SparseData source);
SparseData deserializeSparseData(char *source);
SparseData makeEmptySparseData(void);
SparseData makeInplaceSparseData(char *vals, char *index,
......
......@@ -14,20 +14,16 @@
#include "sparse_vector.h"
static char **get_text_array_contents(ArrayType *array, int *numitems);
int gp_isnew_query(void);
static int gp_isnew_query(void);
static SvecType *classify_document(char **features, int num_features, char **document, int num_words, int allocate);
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
SvecType *classify_document(char **features, int num_features, char **document, int num_words, int allocate);
Datum calc_logidf(PG_FUNCTION_ARGS);
Datum gp_extract_feature_histogram(PG_FUNCTION_ARGS);
void gp_extract_feature_histogram_usage(char *msg);
void gp_extract_feature_histogram_errout(char *msg);
/*
* gp_extract_feature_histogram
* By: Luke Lonergan, November 2009, Greenplum Inc.
......@@ -133,7 +129,10 @@ gp_extract_feature_histogram(PG_FUNCTION_ARGS)
* trying to call this in some sort of crazy way.
*/
if (PG_NARGS() != 2)
gp_extract_feature_histogram_usage("gp_extract_feature_histogram called with wrong number of arguments");
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("gp_extract_feature_histogram called with wrong number of arguments"),
errhint("Required argument is a base 10 encoded IPv4 address. Example: 10.4.128.1 would be entered here as the number 10004128001.")));
/* Retrieve the C text array equivalents from the PG text[][] inputs */
features = get_text_array_contents(PG_GETARG_ARRAYTYPE_P(0),&num_features);
......@@ -153,21 +152,9 @@ gp_extract_feature_histogram(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(returnval);
}
void
gp_extract_feature_histogram_usage(char *msg) {
ereport(ERROR,(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg(
"%s\ngp_extract_feature_histogram requires args: IP_Address INT8\nWhere IP_Address is a 10s encoded IPV4 address. For example: 10.4.128.1 would be entered here as the number 10004128001.",msg)));
}
void
gp_extract_feature_histogram_errout(char *msg) {
ereport(ERROR,(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
errmsg(
"%s\ngp_extract_feature_histogram internal error.",msg)));
}
SvecType *classify_document(char **features, int num_features, char **document, int num_words, int allocate) {
static SvecType *
classify_document(char **features, int num_features, char **document, int num_words, int allocate)
{
float8 *histogram = NULL;
ENTRY item, *found_item;
int i;
......@@ -352,7 +339,9 @@ get_text_array_contents(ArrayType *array, int *numitems)
extern int gp_command_count;
extern int gp_session_id;
int gp_isnew_query(void) {
static int
gp_isnew_query(void)
{
static int firstcall=1;
static int last_cnt,last_sid;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册