return match;
}
-
static int ingest_to_cluster(struct client *cl,
xmlDoc *xdoc,
xmlNode *root,
int record_no,
const char *mergekey_norm);
+static int ingest_sub_record(struct client *cl, xmlDoc *xdoc, xmlNode *root,
+ int record_no, NMEM nmem,
+ struct session_database *sdb)
+{
+ int ret = 0;
+ const char *mergekey_norm;
+ struct session *se = client_get_session(cl);
+ struct conf_service *service = se->service;
+
+ if (!check_record_filter(root, sdb))
+ {
+ session_log(se, YLOG_LOG, "Filtered out record no %d from %s", record_no, sdb->database->id);
+ xmlFreeDoc(xdoc);
+ return -2;
+ }
+
+ mergekey_norm = get_mergekey(xdoc, cl, record_no, service, nmem,
+ se->mergekey);
+ if (!mergekey_norm)
+ {
+ session_log(se, YLOG_WARN, "Got no mergekey");
+ xmlFreeDoc(xdoc);
+ return -1;
+ }
+ session_enter(se, "ingest_sub_record");
+ if (client_get_session(cl) == se && se->relevance)
+ ret = ingest_to_cluster(cl, xdoc, root, record_no, mergekey_norm);
+ session_leave(se, "ingest_sub_record");
+
+ xmlFreeDoc(xdoc);
+ return ret;
+}
+
/** \brief ingest XML record
\param cl client holds the result set for record
\param rec record buffer (0 terminated)
int record_no, NMEM nmem)
{
struct session *se = client_get_session(cl);
- int ret = 0;
struct session_database *sdb = client_get_database(cl);
struct conf_service *service = se->service;
xmlDoc *xdoc = normalize_record(se, sdb, service, rec, nmem);
xmlNode *root;
- const char *mergekey_norm;
if (!xdoc)
return -1;
root = xmlDocGetRootElement(xdoc);
- if (!check_record_filter(root, sdb))
+ if (!strcmp((const char *) root->name, "cluster"))
{
- session_log(se, YLOG_LOG, "Filtered out record no %d from %s", record_no, sdb->database->id);
- xmlFreeDoc(xdoc);
- return -2;
+ root = root->children;
+ return ingest_sub_record(cl, xdoc, root, record_no, nmem, sdb);
}
-
- mergekey_norm = get_mergekey(xdoc, cl, record_no, service, nmem,
- se->mergekey);
- if (!mergekey_norm)
+ else if (!strcmp((const char *) root->name, "record"))
{
- session_log(se, YLOG_WARN, "Got no mergekey");
- xmlFreeDoc(xdoc);
+ return ingest_sub_record(cl, xdoc, root, record_no, nmem, sdb);
+ }
+ else
+ {
+ session_log(se, YLOG_WARN, "Bad pz root element: %s",
+ (const char *) root->name);
return -1;
}
- session_enter(se, "ingest_record");
- if (client_get_session(cl) == se && se->relevance)
- ret = ingest_to_cluster(cl, xdoc, root, record_no, mergekey_norm);
- session_leave(se, "ingest_record");
-
- xmlFreeDoc(xdoc);
- return ret;
}
+
// struct conf_metadata *ser_md = &service->metadata[md_field_id];
// struct record_metadata *rec_md = record->metadata[md_field_id];
static int match_metadata_local(struct conf_service *service,