示例#1
0
int DSProImpl::updateLearning (const char *pszMessageId, uint8 ui8Usage)
{
    const char *pszMethodName = "DSPro::updateLearning";
    if (pszMessageId == NULL) {
        return -1;
    }

    _m.lock (2018);
    if (0 != _pInfoStore->updateUsage (pszMessageId, ui8Usage)) {
        checkAndLogMsg (pszMethodName, Logger::L_MildError, "Unable to update 'usage' "
                        "value for message with id = <%s> \n", pszMessageId);
        _m.unlock (2018);
        return -2;
    }

    MetadataList *pMetadataList = _pInfoStore->getMetadataForData (pszMessageId);
    if (pMetadataList != NULL) {
        MetadataInterface *pCurr, *pNext;
        pNext = pMetadataList->getFirst ();
        for (unsigned int i = 0; ((pCurr = pNext) != NULL); i++) {
            pNext = pMetadataList->getNext ();

            IHMC_C45::C45AVList *pDataset = _pMetadataConf->getMetadataAsDataset (pCurr);
            if (pDataset == NULL) {
                checkAndLogMsg (pszMethodName, Logger::L_MildError, "Unable to convert the metadata "
                                "from message with id = <%s> to C45AVList class.\n", pszMessageId);
            }
            else {
                int rc = _pNodeContextMgr->updateClassifier (pDataset);
                if (rc < 0) {
                    checkAndLogMsg (pszMethodName, Logger::L_MildError, "Unable to use the metadata "
                                    "from message with id = <%s> as input for the learning algorithm.\n",
                                    pszMessageId);
                }
                delete pDataset;
            }
            delete pMetadataList->remove (pCurr);
        }
        delete pMetadataList;
    }

    _m.unlock (2018);
    return 0;
}
示例#2
0
int DSProQueryController::doQueryWithPropertyListOnApplicationMetadata (const void *pQuery, unsigned int uiQueryLen, const char *pszQueryQualifiers,
                                                                        PtrLList<const char> *pResultsList)
{
    const char *pszMethodName = "DSProQueryController::doQueryWithPropertyListOnApplicationMetadata";

    MetadataList *pMetadataList = getAllMetadata (pszQueryQualifiers);
    if (pMetadataList == nullptr) {
        checkAndLogMsg (pszMethodName, Logger::L_Warning, "\n");
        return -1;
    }

    PropertiesConditionsList *pPropertiesConditionsList = new PropertiesConditionsList();

    String query ((char *) pQuery, uiQueryLen);

    checkAndLogMsg (pszMethodName, Logger::L_Info, "Property conditions list = %s\n", query.c_str());

    char *pszTemp = nullptr;
    char *pszToken = nullptr;
    pszToken = strtok_mt (query.c_str(), ";", &pszTemp);
    while (pszToken) {
        int rc;
        if ((rc = pPropertiesConditionsList->addNewPropertyCondition (pszToken)) != 0) {
            checkAndLogMsg (pszMethodName, Logger::L_Warning, "Failed in adding the new property condition\n");
            return -2;
        }
        pszToken = strtok_mt (nullptr, ";", &pszTemp);
    }

    MetadataInterface *pCurr, *pNext;
    pNext = pMetadataList->getFirst();
    for (unsigned int i = 0; (pCurr = pNext) != nullptr; i++) {
        pNext = pMetadataList->getNext();
        char *pszBuffer = nullptr;
        if (pCurr->getFieldValue (MetadataInterface::APPLICATION_METADATA, (char **) &pszBuffer) == 0 && pszBuffer != nullptr) {
            matchPropertyListToApplicationMetadata (pszBuffer, pPropertiesConditionsList, pCurr, pResultsList);
            free (pszBuffer);
        }
        delete pMetadataList->remove (pCurr);
    }

    delete pMetadataList;
    return 0;
}