void LogStatistics::add(LogBufferElement *e) { log_id_t log_id = e->getLogId(); unsigned short size = e->getMsgLen(); mSizes[log_id] += size; ++mElements[log_id]; uid_t uid = e->getUid(); unsigned short dropped = e->getDropped(); android::hash_t hash = android::hash_type(uid); uidTable_t &table = uidTable[log_id]; ssize_t index = table.find(-1, hash, uid); if (index == -1) { UidEntry initEntry(uid); initEntry.add(size); initEntry.add_dropped(dropped); table.add(hash, initEntry); } else { UidEntry &entry = table.editEntryAt(index); entry.add(size); entry.add_dropped(dropped); } mSizesTotal[log_id] += size; ++mElementsTotal[log_id]; if (!enable) { return; } pid_t pid = e->getPid(); hash = android::hash_type(pid); index = pidTable.find(-1, hash, pid); if (index == -1) { PidEntry initEntry(pid, uid, android::pidToName(pid)); initEntry.add(size); initEntry.add_dropped(dropped); pidTable.add(hash, initEntry); } else { PidEntry &entry = pidTable.editEntryAt(index); if (entry.getUid() != uid) { entry.setUid(uid); entry.setName(android::pidToName(pid)); } else if (!entry.getName()) { char *name = android::pidToName(pid); if (name) { entry.setName(name); } } entry.add(size); entry.add_dropped(dropped); } }
void addSA(ENTRY* S1,ENTRY* S2,ENTRY* S3) { while(1) { if(empty(S1) && empty(S2)) break; if(nempty(S1) && empty(S2)) { while(1) { if (nempty(S1)) { e1 = S2; S3 = e1; } if (empty(S1)) break; } break; } if (empty(S1) && nempty(S2)) { while(1) { if (nempty(S2)) { e2 = S2; S3 = e2; } if (empty(S2)) break; } break; } if (nempty(S1) && nempty(S2)) { e1 = S1; e2 = S2; if ((e1.row == e2.row) && (e1.col == e2.col)) { e1 = S1; e2 = S2; initEntry(S3, e1.row, e1.col, e1.value + e2.value); } if ((e1.row < e2.row) || ((e1.row == e2.row) && (e1.col < e2.col))) { e1 = S1; S3 = e1; } else { e2 = S2; S3 = e2; } } } }
bool buildOverviews() { bool result = false; if(!initEntry()) return result; ossimRefPtr<ossimOverviewBuilderBase> builder = ossimOverviewBuilderFactoryRegistry::instance()->createBuilder(theOverviewType); if(!builder.valid()) { return result; } ossimPropertyInterface* builderProp = (ossimPropertyInterface*)builder.get(); builderProp->setProperty(ossimKeywordNames::OUTPUT_TILE_SIZE_KW, theOverviewTileSize.toString()); builderProp->setProperty(ossimKeywordNames::COMPRESSION_TYPE_KW, theCompressionType); builderProp->setProperty(ossimKeywordNames::COMPRESSION_QUALITY_KW, ossimString::toString(theCompressionQuality)); builder->setInputSource(theHandler.get()); if(!theQuietFlag) { builder->addListener((ossimProcessListener*)this); } else { // ossimPushNotifyFlags(); // ossimDisableNotify(); } if(theUseFastHistogramStagingFlag) { builder->setHistogramMode(OSSIM_HISTO_MODE_FAST); } else { builder->setHistogramMode(OSSIM_HISTO_MODE_NORMAL); } if(theOverviewFilename.path().isWriteable()) { result = true; theCurrentProcessInterface = builder.get(); builder->setOutputFile(theOverviewFilename); builder->execute(); } if(!theQuietFlag) { builder->removeListener((ossimProcessListener*)this); } else { // ossimPopNotifyFlags(); } theCurrentProcessInterface = 0; return result; }
static void insertHashRF(unsigned int *bitVector, pllHashTable *h, unsigned int vectorLength, int treeNumber, int treeVectorLength, hashNumberType position, int support, boolean computeWRF) { pllBipartitionEntry * e; pllHashItem * hitem; if(h->Items[position] != NULL) { for (hitem = h->Items[position]; hitem; hitem = hitem->next) { e = (pllBipartitionEntry *)(hitem->data); if (!memcmp(bitVector, e->bitVector, vectorLength * sizeof(unsigned int))) { e->treeVector[treeNumber / PLL_MASK_LENGTH] |= mask32[treeNumber % PLL_MASK_LENGTH]; if(computeWRF) { e->supportVector[treeNumber] = support; assert(0 <= treeNumber && treeNumber < treeVectorLength * PLL_MASK_LENGTH); } return; } } } e = initEntry(); rax_posix_memalign ((void **)&(e->bitVector), PLL_BYTE_ALIGNMENT, (size_t)vectorLength * sizeof(unsigned int)); memset(e->bitVector, 0, vectorLength * sizeof(unsigned int)); e->treeVector = (unsigned int*)rax_calloc((size_t)treeVectorLength, sizeof(unsigned int)); if(computeWRF) e->supportVector = (int*)rax_calloc((size_t)treeVectorLength * PLL_MASK_LENGTH, sizeof(int)); e->treeVector[treeNumber / PLL_MASK_LENGTH] |= mask32[treeNumber % PLL_MASK_LENGTH]; if(computeWRF) { e->supportVector[treeNumber] = support; assert(0 <= treeNumber && treeNumber < treeVectorLength * PLL_MASK_LENGTH); } memcpy(e->bitVector, bitVector, sizeof(unsigned int) * vectorLength); pllHashAdd (h, position, NULL, (void *)e); }
uid_t LogStatistics::pidToUid(pid_t pid) { uid_t uid; android::hash_t hash = android::hash_type(pid); ssize_t index = pidTable.find(-1, hash, pid); if (index == -1) { uid = android::pidToUid(pid); PidEntry initEntry(pid, uid, android::pidToName(pid)); pidTable.add(hash, initEntry); } else { PidEntry &entry = pidTable.editEntryAt(index); if (!entry.getName()) { char *name = android::pidToName(pid); if (name) { entry.setName(name); } } uid = entry.getUid(); } return uid; }
void setDefaults() { if(!theHandler.valid()) { initHandler(); initEntry(); } ossim::defaultTileSize(theOverviewTileSize); theStageHistogramFlag = false; theStageOverviewFlag = false; theHistogramFilename = ""; theOverviewFilename = ""; if(theHandler.valid()) { theStageOverviewFlag = !(theHandler->hasOverviews()); theOverviewFilename = theHandler->createDefaultOverviewFilename(); theHistogramFilename = theHandler->createDefaultHistogramFilename(); theStageHistogramFlag = !(theHistogramFilename.exists()); } }
bool buildHistograms() { if(!initEntry()) return false; ossimRefPtr<ossimImageHistogramSource> histoSource = new ossimImageHistogramSource; ossimRefPtr<ossimHistogramWriter> writer = new ossimHistogramWriter; histoSource->connectMyInputTo(0, theHandler.get()); histoSource->enableSource(); if (theUseFastHistogramStagingFlag) { histoSource->setComputationMode(OSSIM_HISTO_MODE_FAST); } writer->connectMyInputTo(0, histoSource.get()); writer->setFilename(theHistogramFilename); if(!theQuietFlag) { writer->addListener((ossimProcessListener*)this); } else { //ossimPushNotifyFlags(); //ossimDisableNotify(); } theCurrentProcessInterface = writer.get(); writer->execute(); if(!theQuietFlag) { writer->removeListener((ossimProcessListener*)this); } else { //ossimPopNotifyFlags(); } writer->disconnect(); histoSource->disconnect(); theCurrentProcessInterface = 0; return true; }
void P() { int i; ENTRY e, e1, e2; initEntry(sa1, 0, 1, -5); initEntry(sa1, 0, 3, 8); initEntry(sa1, 2, 0, 20); initEntry(sa1, 3, 3, -3); printf("Sparse array 1:\n"); printSA(sa1); initEntry(sa2, 0, 2, -2); initEntry(sa2, 0, 3, 5); initEntry(sa2, 2, 0, -15); printf("Sparse array 2:\n"); printSA(sa2); addSA(sa1, sa2, sa3); printf("Sparse array 3:\n"); printSA(sa3); }
// caller must free character string char *LogStatistics::pidToName(pid_t pid) { char *name; android::hash_t hash = android::hash_type(pid); ssize_t index = pidTable.find(-1, hash, pid); if (index == -1) { name = android::pidToName(pid); PidEntry initEntry(pid, android::pidToUid(pid), name ? strdup(name) : NULL); pidTable.add(hash, initEntry); } else { PidEntry &entry = pidTable.editEntryAt(index); const char *n = entry.getName(); if (n) { name = strdup(n); } else { name = android::pidToName(pid); if (name) { entry.setName(strdup(name)); } } } return name; }
static void insertHashRF(unsigned int *bitVector, hashtable *h, unsigned int vectorLength, int treeNumber, int treeVectorLength, hashNumberType position, int support, boolean computeWRF) { if(h->table[position] != NULL) { entry *e = h->table[position]; do { unsigned int i; for(i = 0; i < vectorLength; i++) if(bitVector[i] != e->bitVector[i]) break; if(i == vectorLength) { e->treeVector[treeNumber / MASK_LENGTH] |= mask32[treeNumber % MASK_LENGTH]; if(computeWRF) { e->supportVector[treeNumber] = support; assert(0 <= treeNumber && treeNumber < treeVectorLength * MASK_LENGTH); } return; } e = e->next; } while(e != (entry*)NULL); e = initEntry(); /*e->bitVector = (unsigned int*)calloc(vectorLength, sizeof(unsigned int));*/ e->bitVector = (unsigned int*)malloc_aligned(vectorLength * sizeof(unsigned int)); memset(e->bitVector, 0, vectorLength * sizeof(unsigned int)); e->treeVector = (unsigned int*)calloc(treeVectorLength, sizeof(unsigned int)); if(computeWRF) e->supportVector = (int*)calloc(treeVectorLength * MASK_LENGTH, sizeof(int)); e->treeVector[treeNumber / MASK_LENGTH] |= mask32[treeNumber % MASK_LENGTH]; if(computeWRF) { e->supportVector[treeNumber] = support; assert(0 <= treeNumber && treeNumber < treeVectorLength * MASK_LENGTH); } memcpy(e->bitVector, bitVector, sizeof(unsigned int) * vectorLength); e->next = h->table[position]; h->table[position] = e; } else { entry *e = initEntry(); /*e->bitVector = (unsigned int*)calloc(vectorLength, sizeof(unsigned int)); */ e->bitVector = (unsigned int*)malloc_aligned(vectorLength * sizeof(unsigned int)); memset(e->bitVector, 0, vectorLength * sizeof(unsigned int)); e->treeVector = (unsigned int*)calloc(treeVectorLength, sizeof(unsigned int)); if(computeWRF) e->supportVector = (int*)calloc(treeVectorLength * MASK_LENGTH, sizeof(int)); e->treeVector[treeNumber / MASK_LENGTH] |= mask32[treeNumber % MASK_LENGTH]; if(computeWRF) { e->supportVector[treeNumber] = support; assert(0 <= treeNumber && treeNumber < treeVectorLength * MASK_LENGTH); } memcpy(e->bitVector, bitVector, sizeof(unsigned int) * vectorLength); h->table[position] = e; } h->entryCount = h->entryCount + 1; }
void ringbufferEntry(RingBufferType t, uint64_t funcId, int offset) { (void) initEntry(t, funcId, offset); }
void ringbufferMsg(const char* msg, size_t msgLen, RingBufferType t) { RingBufferEntry* rb = initEntry(t); rb->m_msg = msg; rb->m_len = msgLen; }
void ringbufferEntry(RingBufferType t, uint64_t sk, uint64_t data) { (void) initEntry(t, sk, data); }