本文整理汇总了C++中ARRPTR函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRPTR函数的具体用法?C++ ARRPTR怎么用?C++ ARRPTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARRPTR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: g_int_union
Datum
g_int_union(PG_FUNCTION_ARGS)
{
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1);
int4 i;
ArrayType *res;
int totlen = 0,
*ptr;
for (i = 0; i < entryvec->n; i++)
totlen += ARRNELEMS(GETENTRY(entryvec, i));
res = new_intArrayType(totlen);
ptr = ARRPTR(res);
for (i = 0; i < entryvec->n; i++)
{
memcpy(ptr, ARRPTR(GETENTRY(entryvec, i)), ARRNELEMS(GETENTRY(entryvec, i)) * sizeof(int4));
ptr += ARRNELEMS(GETENTRY(entryvec, i));
}
QSORT(res, 1);
res = _int_unique(res);
*size = VARSIZE(res);
PG_RETURN_POINTER(res);
}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:27,代码来源:_int_gist.c
示例2: g_int_same
Datum
g_int_same(PG_FUNCTION_ARGS)
{
ArrayType *a = (ArrayType *) PointerGetDatum(PG_GETARG_POINTER(0));
ArrayType *b = (ArrayType *) PointerGetDatum(PG_GETARG_POINTER(1));
bool *result = (bool *) PG_GETARG_POINTER(2);
int4 n = ARRNELEMS(a);
int4 *da,
*db;
CHECKARRVALID(a);
CHECKARRVALID(b);
if (n != ARRNELEMS(b))
{
*result = false;
PG_RETURN_POINTER(result);
}
*result = TRUE;
da = ARRPTR(a);
db = ARRPTR(b);
while (n--)
if (*da++ != *db++)
{
*result = FALSE;
break;
}
PG_RETURN_POINTER(result);
}
开发者ID:Joe-xXx,项目名称:postgres-old-soon-decommissioned,代码行数:30,代码来源:_int_gist.c
示例3: g_int_union
Datum
g_int_union(PG_FUNCTION_ARGS)
{
bytea *entryvec = (bytea *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1);
int4 i,
len = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY);
ArrayType *res;
int totlen = 0,
*ptr;
for (i = 0; i < len; i++)
totlen += ARRNELEMS(GETENTRY(entryvec, i));
res = new_intArrayType(totlen);
ptr = ARRPTR(res);
for (i = 0; i < len; i++)
{
memcpy(ptr, ARRPTR(GETENTRY(entryvec, i)), ARRNELEMS(GETENTRY(entryvec, i)) * sizeof(int4));
ptr += ARRNELEMS(GETENTRY(entryvec, i));
}
QSORT(res, 1);
res = _int_unique(res);
*size = VARSIZE(res);
PG_RETURN_POINTER(res);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:28,代码来源:_int_gist.c
示例4: g_int_same
Datum
g_int_same(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P(0);
ArrayType *b = PG_GETARG_ARRAYTYPE_P(1);
bool *result = (bool *) PG_GETARG_POINTER(2);
int32 n = ARRNELEMS(a);
int32 *da,
*db;
CHECKARRVALID(a);
CHECKARRVALID(b);
if (n != ARRNELEMS(b))
{
*result = false;
PG_RETURN_POINTER(result);
}
*result = TRUE;
da = ARRPTR(a);
db = ARRPTR(b);
while (n--)
{
if (*da++ != *db++)
{
*result = FALSE;
break;
}
}
PG_RETURN_POINTER(result);
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:32,代码来源:_int_gist.c
示例5: inner_int_overlap
/* arguments are assumed sorted */
bool
inner_int_overlap(ArrayType *a, ArrayType *b)
{
int na,
nb;
int i,
j;
int *da,
*db;
na = ARRNELEMS(a);
nb = ARRNELEMS(b);
da = ARRPTR(a);
db = ARRPTR(b);
i = j = 0;
while (i < na && j < nb)
{
if (da[i] < db[j])
i++;
else if (da[i] == db[j])
return TRUE;
else
j++;
}
return FALSE;
}
开发者ID:kjkszpj,项目名称:PG-SQL,代码行数:29,代码来源:_int_tool.c
示例6: tsvector_strip
Datum
tsvector_strip(PG_FUNCTION_ARGS)
{
TSVector in = PG_GETARG_TSVECTOR(0);
TSVector out;
int i,
len = 0;
WordEntry *arrin = ARRPTR(in),
*arrout;
char *cur;
for (i = 0; i < in->size; i++)
len += arrin[i].len;
len = CALCDATASIZE(in->size, len);
out = (TSVector) palloc0(len);
SET_VARSIZE(out, len);
out->size = in->size;
arrout = ARRPTR(out);
cur = STRPTR(out);
for (i = 0; i < in->size; i++)
{
memcpy(cur, STRPTR(in) + arrin[i].pos, arrin[i].len);
arrout[i].haspos = 0;
arrout[i].len = arrin[i].len;
arrout[i].pos = cur - STRPTR(out);
cur += arrout[i].len;
}
PG_FREE_IF_COPY(in, 0);
PG_RETURN_POINTER(out);
}
开发者ID:bocap,项目名称:postgres,代码行数:32,代码来源:tsvector_op.c
示例7: inner_int_contains
/* arguments are assumed sorted & unique-ified */
bool
inner_int_contains(ArrayType *a, ArrayType *b)
{
int na,
nb;
int i,
j,
n;
int *da,
*db;
na = ARRNELEMS(a);
nb = ARRNELEMS(b);
da = ARRPTR(a);
db = ARRPTR(b);
i = j = n = 0;
while (i < na && j < nb)
{
if (da[i] < db[j])
i++;
else if (da[i] == db[j])
{
n++;
i++;
j++;
}
else
break; /* db[j] is not in da */
}
return (n == nb) ? TRUE : FALSE;
}
开发者ID:kjkszpj,项目名称:PG-SQL,代码行数:34,代码来源:_int_tool.c
示例8: silly_cmp_tsvector
/*
* Order: haspos, len, word, for all positions (pos, weight)
*/
static int
silly_cmp_tsvector(const TSVector a, const TSVector b)
{
if (VARSIZE(a) < VARSIZE(b))
return -1;
else if (VARSIZE(a) > VARSIZE(b))
return 1;
else if (a->size < b->size)
return -1;
else if (a->size > b->size)
return 1;
else
{
WordEntry *aptr = ARRPTR(a);
WordEntry *bptr = ARRPTR(b);
int i = 0;
int res;
for (i = 0; i < a->size; i++)
{
if (aptr->haspos != bptr->haspos)
{
return (aptr->haspos > bptr->haspos) ? -1 : 1;
}
else if ((res = tsCompareString(STRPTR(a) + aptr->pos, aptr->len, STRPTR(b) + bptr->pos, bptr->len, false)) != 0)
{
return res;
}
else if (aptr->haspos)
{
WordEntryPos *ap = POSDATAPTR(a, aptr);
WordEntryPos *bp = POSDATAPTR(b, bptr);
int j;
if (POSDATALEN(a, aptr) != POSDATALEN(b, bptr))
return (POSDATALEN(a, aptr) > POSDATALEN(b, bptr)) ? -1 : 1;
for (j = 0; j < POSDATALEN(a, aptr); j++)
{
if (WEP_GETPOS(*ap) != WEP_GETPOS(*bp))
{
return (WEP_GETPOS(*ap) > WEP_GETPOS(*bp)) ? -1 : 1;
}
else if (WEP_GETWEIGHT(*ap) != WEP_GETWEIGHT(*bp))
{
return (WEP_GETWEIGHT(*ap) > WEP_GETWEIGHT(*bp)) ? -1 : 1;
}
ap++, bp++;
}
}
aptr++;
bptr++;
}
}
return 0;
}
开发者ID:bocap,项目名称:postgres,代码行数:62,代码来源:tsvector_op.c
示例9: inner_int_union
ArrayType *
inner_int_union(ArrayType *a, ArrayType *b)
{
ArrayType *r = NULL;
CHECKARRVALID(a);
CHECKARRVALID(b);
if (ARRISEMPTY(a) && ARRISEMPTY(b))
return new_intArrayType(0);
if (ARRISEMPTY(a))
r = copy_intArrayType(b);
if (ARRISEMPTY(b))
r = copy_intArrayType(a);
if (!r)
{
int na = ARRNELEMS(a),
nb = ARRNELEMS(b);
int *da = ARRPTR(a),
*db = ARRPTR(b);
int i,
j,
*dr;
r = new_intArrayType(na + nb);
dr = ARRPTR(r);
/* union */
i = j = 0;
while (i < na && j < nb)
{
if (da[i] == db[j])
{
*dr++ = da[i++];
j++;
}
else if (da[i] < db[j])
*dr++ = da[i++];
else
*dr++ = db[j++];
}
while (i < na)
*dr++ = da[i++];
while (j < nb)
*dr++ = db[j++];
r = resize_intArrayType(r, dr - ARRPTR(r));
}
if (ARRNELEMS(r) > 1)
r = _int_unique(r);
return r;
}
开发者ID:kjkszpj,项目名称:PG-SQL,代码行数:56,代码来源:_int_tool.c
示例10: copy_intArrayType
ArrayType *
copy_intArrayType(ArrayType *a)
{
ArrayType *r;
int n = ARRNELEMS(a);
r = new_intArrayType(n);
memcpy(ARRPTR(r), ARRPTR(a), n * sizeof(int4));
return r;
}
开发者ID:kjkszpj,项目名称:PG-SQL,代码行数:10,代码来源:_int_tool.c
示例11: g_int_decompress
Datum
g_int_decompress(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *retval;
ArrayType *r;
int *dr,
lenr;
ArrayType *in;
int lenin;
int *din;
int i,
j;
in = (ArrayType *) PG_DETOAST_DATUM(entry->key);
if (ARRISVOID(in))
PG_RETURN_POINTER(entry);
lenin = ARRNELEMS(in);
if (lenin < 2 * MAXNUMRANGE || ISLEAFKEY(in))
{ /* not compressed value */
if (in != (ArrayType *) DatumGetPointer(entry->key))
{
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(in),
entry->rel, entry->page, entry->offset, VARSIZE(in), FALSE);
PG_RETURN_POINTER(retval);
}
PG_RETURN_POINTER(entry);
}
din = ARRPTR(in);
lenr = internal_size(din, lenin);
r = new_intArrayType(lenr);
dr = ARRPTR(r);
for (i = 0; i < lenin; i += 2)
for (j = din[i]; j <= din[i + 1]; j++)
if ((!i) || *(dr - 1) != j)
*dr++ = j;
if (in != (ArrayType *) DatumGetPointer(entry->key))
pfree(in);
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE);
PG_RETURN_POINTER(retval);
}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:53,代码来源:_int_gist.c
示例12: subarray
Datum
subarray(PG_FUNCTION_ARGS)
{
ArrayType *a = (ArrayType *) PG_GETARG_ARRAYTYPE_P(0);
int32 start = PG_GETARG_INT32(1);
int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int32 end = 0;
int32 c;
ArrayType *result;
start = (start > 0) ? start - 1 : start;
CHECKARRVALID(a);
if (ARRISEMPTY(a))
{
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(new_intArrayType(0));
}
c = ARRNELEMS(a);
if (start < 0)
start = c + start;
if (len < 0)
end = c + len;
else if (len == 0)
end = c;
else
end = start + len;
if (end > c)
end = c;
if (start < 0)
start = 0;
if (start >= end || end <= 0)
{
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(new_intArrayType(0));
}
result = new_intArrayType(end - start);
if (end - start > 0)
memcpy(ARRPTR(result), ARRPTR(a) + start, (end - start) * sizeof(int32));
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(result);
}
开发者ID:50wu,项目名称:gpdb,代码行数:49,代码来源:_int_op.c
示例13: hstorePairs
HStore *
hstorePairs(Pairs *pairs, int4 pcount, int4 buflen)
{
HStore *out;
HEntry *entry;
char *ptr;
char *buf;
int4 len;
int4 i;
len = CALCDATASIZE(pcount, buflen);
out = palloc(len);
SET_VARSIZE(out, len);
HS_SETCOUNT(out, pcount);
if (pcount == 0)
return out;
entry = ARRPTR(out);
buf = ptr = STRPTR(out);
for (i = 0; i < pcount; i++)
HS_ADDITEM(entry, buf, ptr, pairs[i]);
HS_FINALIZE(out, pcount, buf, ptr);
return out;
}
开发者ID:d,项目名称:gpdb,代码行数:28,代码来源:hstore_io.c
示例14: hstore_send
Datum
hstore_send(PG_FUNCTION_ARGS)
{
HStore *in = PG_GETARG_HS(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendint(&buf, count, 4);
for (i = 0; i < count; i++)
{
int32 keylen = HS_KEYLEN(entries, i);
pq_sendint(&buf, keylen, 4);
pq_sendtext(&buf, HS_KEY(entries, base, i), keylen);
if (HS_VALISNULL(entries, i))
{
pq_sendint(&buf, -1, 4);
}
else
{
int32 vallen = HS_VALLEN(entries, i);
pq_sendint(&buf, vallen, 4);
pq_sendtext(&buf, HS_VAL(entries, base, i), vallen);
}
}
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
开发者ID:d,项目名称:gpdb,代码行数:35,代码来源:hstore_io.c
示例15: gin_extract_tsvector
Datum
gin_extract_tsvector(PG_FUNCTION_ARGS)
{
TSVector vector = PG_GETARG_TSVECTOR(0);
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
Datum *entries = NULL;
*nentries = vector->size;
if (vector->size > 0)
{
int i;
WordEntry *we = ARRPTR(vector);
entries = (Datum *) palloc(sizeof(Datum) * vector->size);
for (i = 0; i < vector->size; i++)
{
text *txt;
txt = cstring_to_text_with_len(STRPTR(vector) + we->pos, we->len);
entries[i] = PointerGetDatum(txt);
we++;
}
}
PG_FREE_IF_COPY(vector, 0);
PG_RETURN_POINTER(entries);
}
开发者ID:bjornharrtell,项目名称:postgres,代码行数:29,代码来源:tsginidx.c
示例16: intarray_concat_arrays
ArrayType *
intarray_concat_arrays(ArrayType *a, ArrayType *b)
{
ArrayType *result;
int32 ac = ARRNELEMS(a);
int32 bc = ARRNELEMS(b);
CHECKARRVALID(a);
CHECKARRVALID(b);
result = new_intArrayType(ac + bc);
if (ac)
memcpy(ARRPTR(result), ARRPTR(a), ac * sizeof(int32));
if (bc)
memcpy(ARRPTR(result) + ac, ARRPTR(b), bc * sizeof(int32));
return result;
}
开发者ID:kjkszpj,项目名称:PG-SQL,代码行数:16,代码来源:_int_tool.c
示例17: hstore_to_plperl
Datum
hstore_to_plperl(PG_FUNCTION_ARGS)
{
HStore *in = PG_GETARG_HS(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
HV *hv;
hv = newHV();
for (i = 0; i < count; i++)
{
const char *key;
SV *value;
key = pnstrdup(HS_KEY(entries, base, i), HS_KEYLEN(entries, i));
value = HS_VALISNULL(entries, i) ? newSV(0) : cstr2sv(pnstrdup(HS_VAL(entries, base, i), HS_VALLEN(entries, i)));
(void) hv_store(hv, key, strlen(key), value, 0);
}
return PointerGetDatum(newRV((SV *) hv));
}
开发者ID:DBInsight,项目名称:postgres,代码行数:25,代码来源:hstore_plperl.c
示例18: boolop
Datum
boolop(PG_FUNCTION_ARGS)
{
ArrayType *val = (ArrayType *) PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(0));
QUERYTYPE *query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_POINTER(1));
CHKVAL chkval;
bool result;
CHECKARRVALID(val);
if (ARRISVOID(val))
{
pfree(val);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(false);
}
PREPAREARR(val);
chkval.arrb = ARRPTR(val);
chkval.arre = chkval.arrb + ARRNELEMS(val);
result = execute(
GETQUERY(query) + query->size - 1,
&chkval, true,
checkcondition_arr
);
pfree(val);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(result);
}
开发者ID:markwkm,项目名称:postgres,代码行数:29,代码来源:_int_bool.c
示例19: findkey
static HEntry *
findkey(HStore * hs, char *key, int keylen)
{
HEntry *StopLow = ARRPTR(hs);
HEntry *StopHigh = StopLow + hs->size;
HEntry *StopMiddle;
int difference;
char *base = STRPTR(hs);
while (StopLow < StopHigh)
{
StopMiddle = StopLow + (StopHigh - StopLow) / 2;
if (StopMiddle->keylen == keylen)
difference = strncmp(base + StopMiddle->pos, key, StopMiddle->keylen);
else
difference = (StopMiddle->keylen > keylen) ? 1 : -1;
if (difference == 0)
return StopMiddle;
else if (difference < 0)
StopLow = StopMiddle + 1;
else
StopHigh = StopMiddle;
}
return NULL;
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:28,代码来源:hstore_op.c
示例20: hstoreValidOldFormat
/*
* Validity test for an old-format hstore.
* 0 = not valid
* 1 = valid but with "slop" in the length
* 2 = exactly valid
*/
static int
hstoreValidOldFormat(HStore *hs)
{
int count = hs->size_;
HOldEntry *entries = (HOldEntry *) ARRPTR(hs);
int vsize;
int lastpos = 0;
int i;
if (hs->size_ & HS_FLAG_NEWVERSION)
return 0;
/* New format uses an HEntry for key and another for value */
StaticAssertStmt(sizeof(HOldEntry) == 2 * sizeof(HEntry),
"old hstore format is not upward-compatible");
if (count == 0)
return 2;
if (count > 0xFFFFFFF)
return 0;
if (CALCDATASIZE(count, 0) > VARSIZE(hs))
return 0;
if (entries[0].pos != 0)
return 0;
/* key length must be nondecreasing */
for (i = 1; i < count; ++i)
{
if (entries[i].keylen < entries[i - 1].keylen)
return 0;
}
/*
* entry position must be strictly increasing, except for the first entry
* (which can be ""=>"" and thus zero-length); and all entries must be
* properly contiguous
*/
for (i = 0; i < count; ++i)
{
if (entries[i].pos != lastpos)
return 0;
lastpos += (entries[i].keylen
+ ((entries[i].valisnull) ? 0 : entries[i].vallen));
}
vsize = CALCDATASIZE(count, lastpos);
if (vsize > VARSIZE(hs))
return 0;
if (vsize != VARSIZE(hs))
return 1;
return 2;
}
开发者ID:kasoku,项目名称:jpug-doc,代码行数:66,代码来源:hstore_compat.c
注:本文中的ARRPTR函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论