Add hits, score fields to edge struct

This commit is contained in:
c9s 2014-05-22 16:37:53 +08:00
parent 2b331ecc8f
commit d6b2e52567
2 changed files with 10 additions and 3 deletions

View file

@ -37,8 +37,8 @@ typedef struct _node node;
typedef struct _route route; typedef struct _route route;
struct _node { struct _node {
edge ** edges; edge ** edges;
route ** routes; route ** routes;
uint32_t edge_len; uint32_t edge_len;
uint32_t edge_cap; uint32_t edge_cap;
uint32_t route_len; uint32_t route_len;
@ -60,13 +60,16 @@ struct _node {
void * data; void * data;
uint8_t endpoint; uint8_t endpoint;
}; };
struct _edge { struct _edge {
char * pattern; char * pattern;
int pattern_len; int pattern_len;
bool has_slug;
node * child; node * child;
uint64_t hits;
float score;
bool has_slug:1;
}; };
typedef struct { typedef struct {

View file

@ -28,6 +28,10 @@ edge * r3_edge_create(char * pattern, int pattern_len, node * child) {
e->pattern = pattern; e->pattern = pattern;
e->pattern_len = pattern_len; e->pattern_len = pattern_len;
e->child = child; e->child = child;
// default stats
e->hits = 0;
e->score = 0;
return e; return e;
} }