opal/mca/dstore/zht/dstore_zht.c
/* pack the kvs record to string, in order to put it to ZHT */
pack the kvs record to string, in order to put it to ZHT
pack the kvs record to string in order to put it to ZHT
static char* pack_kvs(opal_buffer_t *buffer, opal_value_t *val)
{
    if (NULL == buffer || NULL == val) {
	    opal_output_verbose(1, -1, "either the "
                  "buffer or the value to be packed is NULL");
        return NULL;
    }
    if (OPAL_SUCCESS != opal_dss.pack(buffer, &val, 1, OPAL_VALUE)) {
        return NULL;
    }
    char *str_val;
    while (NULL == (str_val =
        (char*)calloc(buffer->bytes_used + 1, sizeof(char)))) {
        opal_output_verbose(1, -1, "unable to allocate memory of size:%d",
                            buffer->bytes_used + 1);
        sleep(1);
    }
    memcpy(str_val, buffer->base_ptr, buffer->bytes_used);
    return str_val;
}
static char * pack_kvs ( opal_buffer_t * buffer , opal_value_t * val ) { if ( NULL == buffer || NULL == val ) { opal_output_verbose ( 1 , -1 , " " " " ) ; return NULL ; } if ( OPAL_SUCCESS != opal_dss . pack ( buffer , & val , 1 , OPAL_VALUE ) ) { return NULL ; } char * str_val ; while ( NULL == ( str_val = ( char * ) calloc ( buffer -> bytes_used + 1 , sizeof ( char ) ) ) ) { opal_output_verbose ( 1 , -1 , " " , buffer -> bytes_used + 1 ) ; sleep ( 1 ) ; } memcpy ( str_val , buffer -> base_ptr , buffer -> bytes_used ) ; return str_val ; }
pack the kvs record to string, in order to put it to ZHT
pack the kvs record to string in order to put it to ZHT
/* Can we pack the val all together like this:*/ /* Or should we pack the val item by item like this: */ /*opal_dss.pack(buffer, &(val->key), 1, OPAL_STRING);
	opal_dss.pack(buffer, &(val->data.flag), 1, OPAL_BOOL);
	opal_dss.pack(buffer, &(val->data.byte), 1, OPAL_BYTE);
	opal_dss.pack(buffer, &(val->data.string), 1, OPAL_STRING);
	opal_dss.pack(buffer, &(val->data.size), 1, OPAL_SIZE);
	opal_dss.pack(buffer, &(val->data.pid), 1, OPAL_PID);
	opal_dss.pack(buffer, &(val->data.integer), 1, OPAL_INT);
	opal_dss.pack(buffer, &(val->data.int8), 1, OPAL_INT8);
	opal_dss.pack(buffer, &(val->data.int16), 1, OPAL_INT16);
	opal_dss.pack(buffer, &(val->data.int32), 1, OPAL_INT32);
	opal_dss.pack(buffer, &(val->data.int64), 1, OPAL_INT64);
	opal_dss.pack(buffer, &(val->data.uint), 1, OPAL_UINT);
	opal_dss.pack(buffer, &(val->data.uint8), 1, OPAL_UINT8);
	opal_dss.pack(buffer, &(val->data.uint16), 1, OPAL_UINT16);
	opal_dss.pack(buffer, &(val->data.uint32), 1, OPAL_UINT32);
	opal_dss.pack(buffer, &(val->data.uint64), 1, OPAL_UINT64);
	opal_dss.pack(buffer, &(val->data.bo), 1, OPAL_BYTE_OBJECT);
	opal_dss.pack(buffer, &(val->data.fval), 1, OPAL_FLOAT);
	opal_dss.pack(buffer, &(val->data.dval), 1, OPAL_DOUBLE);
	opal_dss.pack(buffer, &(val->data.tv), 1, OPAL_TIMEVAL);
	opal_dss.pack(buffer, &(val->data.name), 1, OPAL_NAME);
	opal_dss.pack(buffer, &(val->data.flag_array), 1, OPAL_BOOL_ARRAY);
	opal_dss.pack(buffer, &(val->data.byte_array), 1, OPAL_UINT8_ARRAY);
	opal_dss.pack(buffer, &(val->data.string_array), 1, OPAL_STRING_ARRAY);
	opal_dss.pack(buffer, &(val->data.size_array), 1, OPAL_SIZE_ARRAY);
	opal_dss.pack(buffer, &(val->data.integer_array), 1, OPAL_INT_ARRAY);
	opal_dss.pack(buffer, &(val->data.int8_array), 1, OPAL_INT8_ARRAY);
	opal_dss.pack(buffer, &(val->data.int16_array), 1, OPAL_INT16_ARRAY);
	opal_dss.pack(buffer, &(val->data.int32_array), 1, OPAL_INT32_ARRAY);
	opal_dss.pack(buffer, &(val->data.int64_array), 1, OPAL_INT64_ARRAY);
	opal_dss.pack(buffer, &(val->data.uint_array), 1, OPAL_UINT_ARRAY);
	opal_dss.pack(buffer, &(val->data.uint8_array), 1, OPAL_UINT8_ARRAY);
	opal_dss.pack(buffer, &(val->data.uint16_array), 1, OPAL_UINT16_ARRAY);
	opal_dss.pack(buffer, &(val->data.uint32_array), 1, OPAL_UINT32_ARRAY);
	opal_dss.pack(buffer, &(val->data.uint64_array), 1, OPAL_UINT64_ARRAY);
	opal_dss.pack(buffer, &(val->data.bo_array), 1, OPAL_BYTE_OBJECT_ARRAY);
	opal_dss.pack(buffer, &(val->data.fval_array), 1, OPAL_FLOAT_ARRAY);
	opal_dss.pack(buffer, &(val->data.dval_array), 1, OPAL_DOUBLE_ARRAY);
	opal_dss.pack(buffer, &(val->data.pid_array), 1, OPAL_PID_ARRAY);
	opal_dss.pack(buffer, &(val->data.tv_array), 1, OPAL_TIMEVAL_ARRAY);*/