MACSio  0.9
Multi-purpose, Application-Centric, Scalable I/O Proxy App
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

Object for maintaining pointer to large, bulk data. More...

Macros

#define COPYNCAST_EXTARR_DATA(SRCT, SRCP, DSTT, DSTP, NVALS)
 
#define JSON_OBJECT_EXTARR_DATA_AS(DSTT, DSTN)
 

Functions

struct json_objectjson_object_new_extarr (void const *data, enum json_extarr_type type, int ndims, int const *dims)
 
struct json_objectjson_object_new_extarr_alloc (enum json_extarr_type etype, int ndims, int const *dims)
 
enum json_extarr_type json_object_extarr_type (struct json_object *jso)
 
int json_object_extarr_nvals (struct json_object *jso)
 
int json_object_extarr_valsize (struct json_object *obj)
 
int64_t json_object_extarr_nbytes (struct json_object *obj)
 
int json_object_extarr_ndims (struct json_object *jso)
 
int json_object_extarr_dim (struct json_object *jso, int dimidx)
 
void const * json_object_extarr_data (struct json_object *jso)
 

Detailed Description

Object for maintaining pointer to large, bulk data.

External array (or extarr) objects are an extension to JSON-C not available in nor likely to be appropriate for the original JSON-C implementation. HPC applications require external array objects defined here because the arrays HPC applications use are very, very large. In ordinary JSON arrays, each member of an array is a fully self-contained JSON object. For large arrays, that means a lot of unnecessary overhead. In addition, ordinary JSON arrays are single dimensional whereas HPC applications often require arrays that are multi-dimensional.

Here, extarr objects are implemented as an extension to JSON-C. Changes were made to JSON-C internals, parser and serialization methods to support extarr objects. This means that any serialized string of a JSON-C object that includes extarr objects within it, will be incompatible with any standard JSON implementation. Another route is to implement extarr objects on top of JSON-C and this may be more appropriate in a future implementation.

Macro Definition Documentation

#define COPYNCAST_EXTARR_DATA (   SRCT,
  SRCP,
  DSTT,
  DSTP,
  NVALS 
)
Value:
{ \
if (!strcmp(#SRCT, #DSTT)) \
memcpy(DSTP, SRCP, NVALS * sizeof(SRCT)); \
else \
{ \
int i; \
SRCT *psrc = (SRCT*) json_object_extarr_data(jso); \
DSTT *pdst = (DSTT*) DSTP; \
for (i = 0; i < NVALS; i++) \
pdst[i] = (DSTT) psrc[i]; \
} \
}
void const * json_object_extarr_data(struct json_object *jso)
Definition: json_object.c:1206

Definition at line 1212 of file json_object.c.

#define JSON_OBJECT_EXTARR_DATA_AS (   DSTT,
  DSTN 
)
Value:
int json_object_extarr_data_as_ ## DSTN(struct json_object* jso, DSTT **buf) \
{ \
int nvals; \
void const *srcp; \
\
if (buf == 0) return 0; \
if (!jso || !json_object_is_type(jso, json_type_extarr)) return 0; \
\
etype = json_object_extarr_type(jso); \
if (etype == json_extarr_type_null) return 0; \
nvals = json_object_extarr_nvals(jso); \
\
if (*buf == 0) \
*buf = (DSTT*) malloc(nvals * sizeof(DSTT)); \
srcp = json_object_extarr_data(jso); \
\
switch (etype) \
{ \
case json_extarr_type_byt08: COPYNCAST_EXTARR_DATA(unsigned char, srcp, DSTT, *buf, nvals); break; \
case json_extarr_type_int32: COPYNCAST_EXTARR_DATA(int, srcp, DSTT, *buf, nvals); break; \
case json_extarr_type_int64: COPYNCAST_EXTARR_DATA(int64_t, srcp, DSTT, *buf, nvals); break; \
case json_extarr_type_flt32: COPYNCAST_EXTARR_DATA(float, srcp, DSTT, *buf, nvals); break; \
case json_extarr_type_flt64: COPYNCAST_EXTARR_DATA(double, srcp, DSTT, *buf, nvals); break; \
default: return 0; \
} \
\
return 1; \
}
void const * json_object_extarr_data(struct json_object *jso)
Definition: json_object.c:1206
int json_object_is_type(struct json_object *jso, enum json_type type)
Definition: json_object.c:204
#define COPYNCAST_EXTARR_DATA(SRCT, SRCP, DSTT, DSTP, NVALS)
Definition: json_object.c:1212
json_extarr_type
Definition: json_object.h:120
int json_object_extarr_nvals(struct json_object *jso)
Definition: json_object.c:1149
enum json_extarr_type json_object_extarr_type(struct json_object *jso)
Definition: json_object.c:1143

Definition at line 1226 of file json_object.c.

Function Documentation

struct json_object* json_object_new_extarr ( void const *  data,
enum json_extarr_type  type,
int  ndims,
int const *  dims 
)

Create new external array object using existing buffer

Buffer data is not copied here. JSON-C does not take ownership of the buffer and will not free the buffer when the extarr object is deleted with json_object_put(). Caller is responsible for not freeing buffers out from underneath any respective JSON-C extarr objects but is responsible for freeing the buffer after it is no longer needed either by JSON-C or by caller. At any point before deleting the extarr object with json_object_put(), caller can obtain the buffer pointer with json_object_extarr_data().

Parameters
[in]dataThe array buffer pointer
[in]typeThe type of data in the array
[in]ndimsThe number of dimensions in the array
[in]dimsArray of length ndims of integer values holding the size in each dimension

Definition at line 1086 of file json_object.c.

struct json_object* json_object_new_extarr_alloc ( enum json_extarr_type  etype,
int  ndims,
int const *  dims 
)

Create new external array object and allocate associated buffer

Although the JSON-C library allocates the buffer, this is just a convenience. The caller is still responsible for freeing the buffer by getting its pointer using json_object_extarr_data(). Caller must do this before calling json_object_put() to delete the extarr object. The buffer is allocated but not initialized.

Parameters
[in]etypeThe type of data to be put into the buffer
[in]ndimsThe number of dimensions in the array
[in]dimsArray of length ndims of integer values holding the [in] in each dimension

Definition at line 1115 of file json_object.c.

enum json_extarr_type json_object_extarr_type ( struct json_object jso)

Definition at line 1143 of file json_object.c.

int json_object_extarr_nvals ( struct json_object jso)

Definition at line 1149 of file json_object.c.

int json_object_extarr_valsize ( struct json_object obj)

Definition at line 1161 of file json_object.c.

int64_t json_object_extarr_nbytes ( struct json_object obj)

Definition at line 1179 of file json_object.c.

int json_object_extarr_ndims ( struct json_object jso)

Definition at line 1190 of file json_object.c.

int json_object_extarr_dim ( struct json_object jso,
int  dimidx 
)

Definition at line 1196 of file json_object.c.

void const* json_object_extarr_data ( struct json_object jso)

Definition at line 1206 of file json_object.c.