void KGPGFile::addRecipient(const QString& recipient) { // skip a possible leading 0x in the id QString cmp = recipient; if (cmp.startsWith(QLatin1String("0x"))) cmp = cmp.mid(2); QStringList keylist; keyList(keylist, false, cmp); if (d->m_keys.size() > 0) d->m_recipients.push_back(d->m_keys.front()); }
QString KeyLogger::sequenceString(const Sequence & sequence) { QStringList keys; std::vector<int> keyList(sequence.cbegin(), sequence.cend()); std::sort(keyList.begin(), keyList.end(), std::greater<int>()); for(int keyCode : keyList) { auto stringFound = KEY_STRING_MAP.find(keyCode); keys << (stringFound != KEY_STRING_MAP.end() ? stringFound->second : KEY_TO_STRING(keyCode)); } return keys.join(" + "); }
QDateTime KGPGFile::keyExpires(const QString& name) { QDateTime expirationDate; // skip a possible leading 0x in the id QString cmp = name; if (cmp.startsWith(QLatin1String("0x"))) cmp = cmp.mid(2); QStringList keylist; keyList(keylist, false, cmp); // in case we have no or more than one matching key // or the key does not have subkeys, we return an invalid date if (d->m_keys.size() == 1 && d->m_keys[0].subkeys().size() > 0 && !d->m_keys[0].subkeys()[0].neverExpires()) { expirationDate.setTime_t(d->m_keys[0].subkeys()[0].expirationTime()); } return expirationDate; }
void NetworkStateNotifier::updateState() { // Assume that we're offline until proven otherwise. m_isOnLine = false; RetainPtr<CFStringRef> str(AdoptCF, SCDynamicStoreKeyCreateNetworkInterface(0, kSCDynamicStoreDomainState)); RetainPtr<CFPropertyListRef> propertyList(AdoptCF, SCDynamicStoreCopyValue(m_store.get(), str.get())); if (!propertyList) return; if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID()) return; CFArrayRef netInterfaces = (CFArrayRef)CFDictionaryGetValue((CFDictionaryRef)propertyList.get(), kSCDynamicStorePropNetInterfaces); if (CFGetTypeID(netInterfaces) != CFArrayGetTypeID()) return; for (CFIndex i = 0; i < CFArrayGetCount(netInterfaces); i++) { CFStringRef interface = (CFStringRef)CFArrayGetValueAtIndex(netInterfaces, i); if (CFGetTypeID(interface) != CFStringGetTypeID()) continue; // Ignore the loopback interface. if (CFStringFind(interface, CFSTR("lo"), kCFCompareAnchored).location != kCFNotFound) continue; RetainPtr<CFStringRef> key(AdoptCF, SCDynamicStoreKeyCreateNetworkInterfaceEntity(0, kSCDynamicStoreDomainState, interface, kSCEntNetIPv4)); RetainPtr<CFArrayRef> keyList(AdoptCF, SCDynamicStoreCopyKeyList(m_store.get(), key.get())); if (keyList && CFArrayGetCount(keyList.get())) { m_isOnLine = true; break; } } }
bool MCCacheWriter::preparePragmaList() { size_t pragmaCount = mpOwner->getPragmaCount(); size_t listSize = sizeof(MCO_PragmaList) + sizeof(MCO_Pragma) * pragmaCount; MCO_PragmaList *list = (MCO_PragmaList *)malloc(listSize); if (!list) { ALOGE("Unable to allocate for pragma list\n"); return false; } mpPragmaListSection = list; mpHeaderSection->pragma_list_size = listSize; list->count = pragmaCount; vector<char const *> keyList(pragmaCount); vector<char const *> valueList(pragmaCount); mpOwner->getPragmaList(pragmaCount, &*keyList.begin(), &*valueList.begin()); for (size_t i = 0; i < pragmaCount; ++i) { char const *key = keyList[i]; char const *value = valueList[i]; size_t keyLen = strlen(key); size_t valueLen = strlen(value); MCO_Pragma *pragma = &list->list[i]; pragma->key_strp_index = addString(key, keyLen); pragma->value_strp_index = addString(value, valueLen); } return true; }
int BlockMgr::findBlockedOverlaps(RecordKeyVector &hitList, bool useOverlappingSubBlocks) { RecordKeyVector keyList(hitList.getKey()); bool deleteKeyBlocks = true; getBlocks(keyList, deleteKeyBlocks); _overlapBases.clear(); int keyBlocksSumLength = getTotalBlockLength(keyList); //Loop through every database record the query intersected with RecordKeyVector::iterator_type hitListIter = hitList.begin(); for (; hitListIter != hitList.end();) { RecordKeyVector hitBlocks(*hitListIter); bool deleteHitBlocks = false; getBlocks(hitBlocks, deleteHitBlocks); //get all blocks for the hit record. int hitBlockSumLength = getTotalBlockLength(hitBlocks); //get total length of the bocks for the hitRecord. int totalHitOverlap = 0; bool hitHasOverlap = false; //loop through every block of the database record. RecordKeyVector::iterator_type hitBlockIter = hitBlocks.begin(); for (; hitBlockIter != hitBlocks.end(); hitBlockIter = hitBlocks.next()) { //loop through every block of the query record. RecordKeyVector::iterator_type keyListIter = keyList.begin(); for (; keyListIter != keyList.end(); keyListIter = keyList.next()) { const Record *keyBlock = *keyListIter; const Record *hitBlock = *hitBlockIter; int maxStart = max(keyBlock->getStartPos(), hitBlock->getStartPos()); int minEnd = min(keyBlock->getEndPos(), hitBlock->getEndPos()); int overlap = minEnd - maxStart; if (overlap > 0) { hitHasOverlap = true; totalHitOverlap += overlap; if (useOverlappingSubBlocks == true) { (*hitListIter)->block_starts.push_back(maxStart); (*hitListIter)->block_ends.push_back(minEnd); } } } } if (hitHasOverlap && useOverlappingSubBlocks == false) { bool enoughKeyOverlap = (float) totalHitOverlap / (float) keyBlocksSumLength >= _overlapFraction; bool enoughHitOverlap = (float) totalHitOverlap / (float) hitBlockSumLength >= _overlapFraction; if (enoughKeyOverlap) { if (_hasReciprocal && enoughHitOverlap) { //(*hitListIter)->setValid(true); _overlapBases.push_back(totalHitOverlap); hitListIter = hitList.next(); } else if (_hasReciprocal && !enoughHitOverlap) { hitList.erase(); //(*hitListIter)->setValid(false); } else if (!_hasReciprocal) { //(*hitListIter)->setValid(true); _overlapBases.push_back(totalHitOverlap); hitListIter = hitList.next(); } } else { hitList.erase(); //(*hitListIter)->setValid(false); } } else if (!hitHasOverlap && useOverlappingSubBlocks == false) { hitList.erase(); //(*hitListIter)->setValid(false); } else { hitListIter = hitList.next(); } if (deleteHitBlocks) { deleteBlocks(hitBlocks); } } // end for loop through main hits if (deleteKeyBlocks) { deleteBlocks(keyList); } return (int)hitList.size(); }
void RecordOutputMgr::printRecord(const Record *record) { RecordKeyVector keyList(record); printRecord(keyList); }
MVCandidatesForJBBSubsetPtr QRGroupLattice::search(QRJBBPtr queryJbb, MVCandidatesForJBBPtr mvCandidates, QRJoinSubGraphMapPtr map, ElementPtrList* minimizedGroupingList) { QRTRACER("QRGroupLattice::search()"); DescriptorDetailsPtr queryDetails = mvCandidates->getAllCandidates()->getQueryDetails(); LatticeKeyList keyList(heap_); if (minimizedGroupingList) { if (!elementListToKeyList(*minimizedGroupingList, keyList, map, queryDetails, FALSE)) return NULL; } else { // Get the grouping columns of the passed query JBB, and create a key list // from them. Return now if there are no grouping items -- a query without a // Group By can't match an MV that has one. QRGroupByPtr groupBy = queryJbb->getGroupBy(); if (!groupBy) return NULL; // An aggregate query with no GroupBy has an empty key list. if (!getGroupingLatticeKeys(keyList, map, queryDetails, queryJbb, TRUE, FALSE)) return NULL; } // Create the search node, disallowing the addition of any new keys to the hash // table used by the lattice; if the key isn't already used, the node can have // no supersets. QRLatticeIndexSearchNode searchNode(keyList, lattice_, TRUE, heap_); if (!searchNode.isValid()) // because a key wasn't added return NULL; NAString keysText; searchNode.dumpNode(keysText, *lattice_->getKeyArr()); QRLogger::log(CAT_GRP_LATTCE_INDX, LL_DEBUG, "Searching LatticeIndex for: %s.", keysText.data()); // Find the supersets of the query's group-by list in the MV group lattice // index. For each lattice index node returned, create an MVCandidate // corresponding to each MV represented by that node, and add it to the // candidate list passed by the caller. NAPtrList<QRLatticeIndexNodePtr> nodes; lattice_->findSupersets(searchNode, nodes); if (nodes.entries() == 0) { QRLogger::log(CAT_GRP_LATTCE_INDX, LL_DEBUG, "No match found."); return NULL; } MVCandidatesForJBBSubsetPtr jbbSubset = new(heap_) MVCandidatesForJBBSubset(mvCandidates, ADD_MEMCHECK_ARGS(heap_)); jbbSubset->setSubGraphMap(map); jbbSubset->setGroupBy(TRUE); if (minimizedGroupingList != NULL) jbbSubset->setMinimizedGroupingList(minimizedGroupingList); for (CollIndex i=0; i<nodes.entries(); i++) { QRLatticeIndexNodePtr thisNode = nodes[i]; const SubGraphMapList& matchingMVs = thisNode->getMVs(); NABoolean isPreferred = (*thisNode == searchNode); // preferred if exact match GroupingList* extraGroupingColumns = new(heap_) GroupingList(heap_); if (!isPreferred) { // For preferred match modes, there are no extraGroupingColumns. LatticeKeySubArray* diff = thisNode->computeDiff(searchNode, heap_); for(CollIndex i = 0; diff->nextUsed(i); i++) { LatticeIndexablePtr key = diff->element(i); QRElementPtr elem = keyToElement(key, map); extraGroupingColumns->insert(elem); } delete diff; } for (CollIndex j=0; j<matchingMVs.entries(); j++) { MVDetailsPtr mv = matchingMVs[j]->getMVDetails(); QRLogger::log(CAT_GRP_LATTCE_INDX, LL_DEBUG, "Found MV: %s!", mv->getMVName().data() ); jbbSubset->insert(mv, queryJbb, isPreferred, extraGroupingColumns, NULL, heap_); } } return jbbSubset; } // QRGroupLattice::search()