An extensible data structure for massive streaming graphs
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
stinger-physmap.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "stinger-physmap.h"
#include "stinger-atomics.h"

Macros

#define MARKERINT   INT64_MAX
#define CHILDREN_COUNT   256

Typedefs

typedef struct tree_node tree_node_t

Functions

tree_node_tallocateTreeNode (stinger_physmap_t *map, tree_node_t *parent, uint64_t depth, char value)
int insertIntoTree (stinger_physmap_t *map, tree_node_t **node, char *string, uint64_t length)
stinger_physmap_tstinger_physmap_create ()
 Allocate and initialize a new physical mapper.
void stinger_physmap_delete (stinger_physmap_t *map)
 Free a physical mapper.
uint64_t stinger_physmap_create_mapping (stinger_physmap_t *map, char *string, uint64_t length)
 Create a new mapping from a binary data string to a vertex ID.
uint64_t stinger_physmap_get_mapping (stinger_physmap_t *map, char *string, uint64_t length)
 Lookup a mapping from a binary data string to a vertex ID.
int stinger_physmap_get_key (stinger_physmap_t *map, char **outbuffer, uint64_t *outbufferlength, uint64_t vertexID)
 Lookup the string mapped to a particular vertex ID.
uint64_t stinger_physmap_remove_mapping (stinger_physmap_t *map, uint64_t vertexID)

Variables

uint64_t MARKER_
void * MARKER = (void *)&MARKER_

Macro Definition Documentation

#define CHILDREN_COUNT   256
#define MARKERINT   INT64_MAX

Typedef Documentation

typedef struct tree_node tree_node_t

Function Documentation

tree_node_t * allocateTreeNode ( stinger_physmap_t map,
tree_node_t parent,
uint64_t  depth,
char  value 
)

References MAX_NODES.

Referenced by insertIntoTree(), and stinger_physmap_create().

int insertIntoTree ( stinger_physmap_t map,
tree_node_t **  node,
char *  string,
uint64_t  length 
)
stinger_physmap_t* stinger_physmap_create ( )

Allocate and initialize a new physical mapper.

The user is responsible for freeing via stinger_physmap_delete().

Returns
A new physical mapper.

References allocateTreeNode().

uint64_t stinger_physmap_create_mapping ( stinger_physmap_t map,
char *  string,
uint64_t  length 
)

Create a new mapping from a binary data string to a vertex ID.

This function will uniquely map an arbitrary binary string or character string to a vertex ID in the space of 0 to NV where NV is the number of unique strings that have been mapped thus far (in other words the vertex ID space is compact). It will return -1 on error or if the mapping already exists. It is safe to call this function in parallel with any other physical mapper function. To determine if a -1 result is from an error, call stinger_physmap_get_mapping() on the same string. If it also returns -1, then an error has occurred.

Parameters
mapThe physical mapper.
stringThe binary or character data string.
lengthThe length of the string.
Returns
A unique vertex ID or -1 if the mapping exists or an error occurs.

References insertIntoTree(), MARKERINT, and MAX_VTXID.

void stinger_physmap_delete ( stinger_physmap_t map)

Free a physical mapper.

Parameters
mapThe physical mapper to be freed.
int stinger_physmap_get_key ( stinger_physmap_t map,
char **  outbuffer,
uint64_t *  outbufferlength,
uint64_t  vertexID 
)

Lookup the string mapped to a particular vertex ID.

This function will lookup and return a previously created mapping. It will return -1 no mapping exists or a reallocation of the output buffer fails. If the output buffer is not long enough, this function will reallocate the buffer and update the output buffer length. It is safe to call this function in parallel with any other physical mapper function.

Parameters
mapThe physical mapper.
outbufferA buffer to store the output string.
outbufferlengthThe length of the buffer.
vertexIDThe vertex ID to reverse lookup.
Returns
0 on success, -1 on failure.
uint64_t stinger_physmap_get_mapping ( stinger_physmap_t map,
char *  string,
uint64_t  length 
)

Lookup a mapping from a binary data string to a vertex ID.

This function will lookup and return a previously created mapping. It will return -1 if no mapping exists. It is safe to call this function in parallel with any other physical mapper function.

Parameters
mapThe physical mapper.
stringThe binary or character data string.
lengthThe length of the string.
Returns
A unique vertex ID or -1 if the mapping does not exist.
uint64_t stinger_physmap_remove_mapping ( stinger_physmap_t map,
uint64_t  vertexID 
)

Variable Documentation

void* MARKER = (void *)&MARKER_
uint64_t MARKER_

 

comments powered by Disqus