static DWORD _convertHashMapToSuperlogTable( PLW_HASHMAP pHashMap, PVMDIR_SUPERLOG_TABLE_COLUMN_SET pCols, PVMDIR_SUPERLOG_TABLE *ppTable ) { DWORD dwError = 0; DWORD dwCount = 0; PVMDIR_SUPERLOG_TABLE pTable = NULL; LW_HASHMAP_ITER iter = LW_HASHMAP_ITER_INIT; LW_HASHMAP_PAIR pair = {NULL, NULL}; unsigned int i = 0; unsigned int j; PVMDIR_SUPERLOG_TABLE_ROW pSrcRow = NULL; PVMDIR_SUPERLOG_TABLE_ROW pDstRow = NULL; dwCount = LwRtlHashMapGetCount(pHashMap); dwError = _allocateSuperlogTable(dwCount, pCols, &pTable); BAIL_ON_VMDIR_ERROR(dwError); while (LwRtlHashMapIterate(pHashMap, &iter, &pair)) { pSrcRow = pair.pValue; pDstRow = (PVMDIR_SUPERLOG_TABLE_ROW)&pTable->rows[i++]; pDstRow->count = pSrcRow->count; pDstRow->totalTime = pSrcRow->totalTime; for (j = 0; j < VMDIR_SUPERLOG_TABLE_COL_NUM; j++) { if (pSrcRow->colVals[j]) { dwError = VmDirAllocateStringA(pSrcRow->colVals[j], &pDstRow->colVals[j]); BAIL_ON_VMDIR_ERROR(dwError); } } dwError = VmDirAllocateStringPrintf( &pDstRow->colVals[AVG_TIME], "%lu", pDstRow->totalTime / pDstRow->count ); BAIL_ON_VMDIR_ERROR(dwError); } *ppTable = pTable; cleanup: return dwError; error: VmDirFreeSuperLogTable(pTable); goto cleanup; }
BOOLEAN VmDirLdapSchemaIsEmpty( PVDIR_LDAP_SCHEMA pSchema ) { BOOLEAN bEmpty = TRUE; if (pSchema) { if (LwRtlHashMapGetCount(pSchema->attributeTypes) || LwRtlHashMapGetCount(pSchema->objectClasses) || LwRtlHashMapGetCount(pSchema->contentRules) || LwRtlHashMapGetCount(pSchema->structureRules) || LwRtlHashMapGetCount(pSchema->nameForms)) { bEmpty = FALSE; } } return bEmpty; }
DWORD VmDirSchemaAttrIdMapUpdateDB( PVDIR_SCHEMA_ATTR_ID_MAP pAttrIdMap ) { DWORD dwError = 0; DWORD dwNumNewIds = 0; LW_HASHMAP_ITER iter = LW_HASHMAP_ITER_INIT; LW_HASHMAP_PAIR pair = {NULL, NULL}; PSTR pszMapStr = NULL; PVMDIR_STRING_LIST pMapStrList = NULL; VDIR_BACKEND_CTX beCtx = {0}; BOOLEAN bHasTxn = FALSE; if (!pAttrIdMap) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_VMDIR_ERROR(dwError); } dwNumNewIds = LwRtlHashMapGetCount(pAttrIdMap->pNewIds); if (dwNumNewIds == 0) { // No new Id goto cleanup; } dwError = VmDirStringListInitialize(&pMapStrList, dwNumNewIds); BAIL_ON_VMDIR_ERROR(dwError); while (LwRtlHashMapIterate(pAttrIdMap->pNewIds, &iter, &pair)) { dwError = VmDirAllocateStringPrintf(&pszMapStr, "%d%s%s", (USHORT)(uintptr_t)pair.pValue, SCHEMA_ATTR_ID_MAP_SEP, (PSTR)pair.pKey); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirStringListAdd(pMapStrList, pszMapStr); BAIL_ON_VMDIR_ERROR(dwError); } beCtx.pBE = VmDirBackendSelect(PERSISTED_DSE_ROOT_DN); dwError = beCtx.pBE->pfnBETxnBegin(&beCtx, VDIR_BACKEND_TXN_WRITE, &bHasTxn); BAIL_ON_VMDIR_ERROR( dwError ); dwError = beCtx.pBE->pfnBEDupKeySetValues(&beCtx, ATTR_ID_MAP_KEY, pMapStrList); BAIL_ON_VMDIR_ERROR(dwError); if (bHasTxn) { dwError = beCtx.pBE->pfnBETxnCommit(&beCtx); bHasTxn = FALSE; BAIL_ON_VMDIR_ERROR(dwError); } LwRtlHashMapResetIter(&iter); while (LwRtlHashMapIterate(pAttrIdMap->pNewIds, &iter, &pair)) { dwError = LwRtlHashMapInsert(pAttrIdMap->pStoredIds, pair.pKey, pair.pValue, NULL); BAIL_ON_VMDIR_ERROR(dwError); } LwRtlHashMapClear(pAttrIdMap->pNewIds, VmDirNoopHashMapPairFree, NULL); cleanup: VmDirBackendCtxContentFree(&beCtx); VmDirStringListFree(pMapStrList); return dwError; error: if (bHasTxn) { beCtx.pBE->pfnBETxnAbort(&beCtx); } VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "%s failed, error (%d)", __FUNCTION__, dwError ); goto cleanup; }