Exemple #1
0
/**
 * @brief Get the mapping between the input vertex in the space space 0 .. stinger_vertices_max_vertices_get()-1 and its representative
 *	string if it exists.
 *
 * This function assumes that the input buffer might could already be allocated, but will allocate / reallocate as needed.
 *
 * @param S Pointer to the stinger graph.
 * @param vertexID The vertex from which to get the string.
 * @param outbuffer Output buffer where you would like the data to be placed.
 * @param outbufferlength The length of the output buffer (will be set or increased if allocated / reallocated or if string is shorter).
 * @retrun 0 on success, -1 on failure.
 */
int
stinger_physmap_id_get(stinger_physmap_t * p, stinger_vertices_t * v, vindex_t vertexID, char ** outbuffer, int64_t * outbufferlength)
{
  char * name = stinger_names_lookup_name(p, vertexID);
  if(name) {
    int len = strlen(name);

    if(*outbuffer == NULL || *outbufferlength == 0){
      *outbuffer = xmalloc(len * sizeof(char));
      if(NULL == *outbuffer) {
	return -1;
      }
    } else if(*outbufferlength < len) {
      void * tmp = xrealloc(*outbuffer, len);
      if(tmp) {
	*outbuffer = tmp;
      } else {
	return -1;
      }
    }
    memcpy(*outbuffer, name, len);
    *outbufferlength = len;
    return 0;
  }
  return -1;
}
Exemple #2
0
void
stinger_physmap_id_to_json(const stinger_physmap_t * p, vindex_t v, FILE * out, int64_t indent_level) {
  JSON_INIT(out, indent_level);
  JSON_OBJECT_START_UNLABELED();
  JSON_STRING(id, stinger_names_lookup_name(p, v));
  JSON_OBJECT_END();
  JSON_END();
}
Exemple #3
0
int
stinger_physmap_id_direct(stinger_physmap_t * p, stinger_vertices_t * v, vindex_t vertexID, char ** out_ptr, int64_t * out_len)
{
  char * name = stinger_names_lookup_name(p, vertexID);
  if(name) {
    *out_len = strlen(name);
    *out_ptr = name;
    return 0;
  }
  return -1;
}
Exemple #4
0
inline void
stinger_vertex_to_json_with_type_strings(const stinger_vertices_t * vertices, const stinger_names_t * tn, stinger_physmap_t * phys, vindex_t v, FILE * out, int64_t indent_level) {
  const stinger_vertex_t * vout = VTX(v);

  JSON_INIT(out, indent_level);
  JSON_OBJECT_START_UNLABELED();
  JSON_INT64(vid, v);
  char * vtype = stinger_names_lookup_name(tn,vout->type);
  if(vtype) {
    JSON_STRING(vtype, vtype);
  } else {
    JSON_INT64(vtype, vout->type);
  }
  JSON_VWEIGHT(vweight, vout->weight);
  JSON_INT64(inDegree, vout->inDegree);
  JSON_INT64(outDegree, vout->outDegree);
  JSON_SUBOBJECT(physID);
  stinger_physmap_id_to_json(phys, v, out, indent_level+1);
#if defined(STINGER_VERTEX_KEY_VALUE_STORE)
  /* TODO attributes */
#endif
  JSON_OBJECT_END();
  JSON_END();
}