void Transaction::on_payBackButton_clicked() { PayBack payBack; payBack.setPrimaryKey(getPrimaryKey()); payBack.exec(); loadLCD(getPrimaryKey()); return ; }
void Transaction::on_loanButton_clicked() { Loan loan; loan.setPrimaryKey(getPrimaryKey()); loan.exec(); loadLCD(getPrimaryKey()); return ; }
void Transaction::on_saveButton_clicked() { Save save; save.setPrimaryKey(getPrimaryKey()); save.exec(); loadLCD(getPrimaryKey()); return ; }
void Transaction::on_witthdrawButton_clicked() { Withdraw withdraw; withdraw.setPrimaryKey(getPrimaryKey()); withdraw.exec(); loadLCD(getPrimaryKey()); return ; }
void Transaction::on_otherButton_clicked() { Other other; other.setPrimaryKey(getPrimaryKey()); other.exec(); return ; }
/** * Remove record from table */ void destroy() { std::map<std::string, std::string> where = { {getPrimaryKey(), mAttributes[getPrimaryKey()]} }; mAdapter->destroy(getTableName(), where); if (mCommitFlag) commit(); mIsNew = true; }
void TupleTrackerManager::getTopKPerPart(int k){ if (isTupleTrackingInfoExtracted == false) extractTupleTrackingInfo(); // extract and sort per partition ofstream SLfile; // site load file std::stringstream ss ; ss << "siteLoadPID_"<<partitionId<<".del" ; std::string fileName=ss.str(); SLfile.open (fileName.c_str()); SLfile <<partitionId<< "\t" << summedAccessFreq; SLfile.close(); ofstream HTfile; // hot tuples file std::stringstream ss2 ; ss2 << "hotTuplesPID_"<<partitionId<<".del" ; fileName=ss2.str(); HTfile.open (fileName.c_str()); std::vector<TupleTrackingInfo>::const_iterator iter = v_tupleTrackingInfo.begin(); int ratio = 100; // %1 long int kk = (v_tupleTrackingInfo.size()/ratio + (v_tupleTrackingInfo.size() % ratio != 0)); // ceil (size * (1/ratio) ) //header first line //HTfile << " k = " << kk<<" of "<<v_tupleTrackingInfo.size()<<"\n"; HTfile << " |Table Name"; HTfile << " |Tuple ID"; HTfile << " |Frequency|"; HTfile << "\n"; // print top k in myfile1 int i = 0; while (iter != v_tupleTrackingInfo.end() && i < kk) { HTfile << iter->tableName<<"\t"; //HTfile << iter->tupleID<<"("<<getPrimaryKey(iter->tableName,iter->tupleID)<<")"<<"\t"; // offset(PKey) HTfile << getPrimaryKey(iter->tableName,iter->tupleID) <<"\t"; HTfile << iter->frequency<<"\n"; i++; iter++; } HTfile.close(); }
/** * Save model (insert/update record) */ bool save() { try { if(mIsNew) { mAdapter->insert(getTableName(), mAttributes); mIsNew = false; } else { std::map<std::string, std::string> where = { {getPrimaryKey(), mAttributes[getPrimaryKey()]} }; mAdapter->update(getTableName(), mAttributes, where); } } catch (const std::exception& e) { return false; } return true; }
/** * Update many attributes * @param attributes_I map attributes hash * @return bool */ bool update(std::map<std::string, std::string> attributes_I) { try { if (!mIsNew) { std::map<std::string, std::string> where = { {getPrimaryKey(), mAttributes[getPrimaryKey()]} }; mAdapter->update(getTableName(), attributes_I, where); if (mCommitFlag) commit(); return true; } } catch (const std::exception& e) { return false; } return false; }
char handleMessage(char* message) { char collectionStatus; unsigned long startTime; unsigned long measureTime; Key primaryKey; Key secondKey; getPrimaryKey(&primaryKey, message); switch (getMessageStatus(message)) { case MESSAGE_TYPE_REGULAR: { startTime = getULongNano(); collectionStatus = collection.find(&primaryKey); measureTime = calcOffsetULong(startTime); if (FIND_SUCCESS == collectionStatus) logPrimary(measureTime); else kLog("Unsuccess find", &primaryKey); } break; case MESSAGE_TYPE_ALTER: { getSecondKey(&secondKey, message); startTime = getULongNano(); collectionStatus = collection.alter(&primaryKey, &secondKey); measureTime = calcOffsetULong(startTime); if (ALTER_SUCCESS != collectionStatus) dkLog("Unsuccess alter", &primaryKey, &secondKey); else logSecondary(measureTime); } break; default: printf("%s", "Invalid message type\n"); return MESSAGE_INVALID; } return MESSAGE_VALID; }
/** * Packages the data in tTupleData into a string of the format * FieldName='value text' where any quotes inside of value text * are escaped with a backslash and any backslashes in value text * are esacped by a second back slash. * * tTupleDesc should be a description of the tuple stored in * tTupleData. * * eFieldUsage specifies which fields to use. * PRIMARY implies include only primary key fields. * NONPRIMARY implies include only non-primary key fields. * ALL implies include all fields. */ char * packageData(HeapTuple tTupleData, TupleDesc tTupleDesc, Oid tableOid, enum FieldUsage eKeyUsage) { int iNumCols; int2vector *tpPKeys = NULL; int iColumnCounter; char *cpDataBlock; int iDataBlockSize; int iUsedDataBlock; iNumCols = tTupleDesc->natts; if (eKeyUsage != ALL) { tpPKeys = getPrimaryKey(tableOid); if (tpPKeys == NULL) return NULL; } if (tpPKeys != NULL) debug_msg("dbmirror:packageData have primary keys"); cpDataBlock = SPI_palloc(BUFFER_SIZE); iDataBlockSize = BUFFER_SIZE; iUsedDataBlock = 0; /* To account for the null */ for (iColumnCounter = 1; iColumnCounter <= iNumCols; iColumnCounter++) { int iIsPrimaryKey; int iPrimaryKeyIndex; char *cpUnFormatedPtr; char *cpFormatedPtr; char *cpFieldName; char *cpFieldData; if (eKeyUsage != ALL) { /* Determine if this is a primary key or not. */ iIsPrimaryKey = 0; for (iPrimaryKeyIndex = 0; iPrimaryKeyIndex < tpPKeys->dim1; iPrimaryKeyIndex++) { if (tpPKeys->values[iPrimaryKeyIndex] == iColumnCounter) { iIsPrimaryKey = 1; break; } } if (iIsPrimaryKey ? (eKeyUsage != PRIMARY) : (eKeyUsage != NONPRIMARY)) { /** * Don't use. */ debug_msg("dbmirror:packageData skipping column"); continue; } } /* KeyUsage!=ALL */ if (tTupleDesc->attrs[iColumnCounter - 1]->attisdropped) { /** * This column has been dropped. * Do not mirror it. */ continue; } cpFieldName = DatumGetPointer(NameGetDatum (&tTupleDesc->attrs [iColumnCounter - 1]->attname)); debug_msg2("dbmirror:packageData field name: %s", cpFieldName); while (iDataBlockSize - iUsedDataBlock < strlen(cpFieldName) + 6) { cpDataBlock = SPI_repalloc(cpDataBlock, iDataBlockSize + BUFFER_SIZE); iDataBlockSize = iDataBlockSize + BUFFER_SIZE; } sprintf(cpDataBlock + iUsedDataBlock, "\"%s\"=", cpFieldName); iUsedDataBlock = iUsedDataBlock + strlen(cpFieldName) + 3; cpFieldData = SPI_getvalue(tTupleData, tTupleDesc, iColumnCounter); cpUnFormatedPtr = cpFieldData; cpFormatedPtr = cpDataBlock + iUsedDataBlock; if (cpFieldData != NULL) { *cpFormatedPtr = '\''; iUsedDataBlock++; cpFormatedPtr++; } else { sprintf(cpFormatedPtr, " "); iUsedDataBlock++; cpFormatedPtr++; continue; } debug_msg2("dbmirror:packageData field data: \"%s\"", cpFieldData); debug_msg("dbmirror:packageData starting format loop"); while (*cpUnFormatedPtr != 0) { while (iDataBlockSize - iUsedDataBlock < 2) { cpDataBlock = SPI_repalloc(cpDataBlock, iDataBlockSize + BUFFER_SIZE); iDataBlockSize = iDataBlockSize + BUFFER_SIZE; cpFormatedPtr = cpDataBlock + iUsedDataBlock; } if (*cpUnFormatedPtr == '\\' || *cpUnFormatedPtr == '\'') { *cpFormatedPtr = '\\'; cpFormatedPtr++; iUsedDataBlock++; } *cpFormatedPtr = *cpUnFormatedPtr; cpFormatedPtr++; cpUnFormatedPtr++; iUsedDataBlock++; } SPI_pfree(cpFieldData); while (iDataBlockSize - iUsedDataBlock < 3) { cpDataBlock = SPI_repalloc(cpDataBlock, iDataBlockSize + BUFFER_SIZE); iDataBlockSize = iDataBlockSize + BUFFER_SIZE; cpFormatedPtr = cpDataBlock + iUsedDataBlock; } sprintf(cpFormatedPtr, "' "); iUsedDataBlock = iUsedDataBlock + 2; debug_msg2("dbmirror:packageData data block: \"%s\"", cpDataBlock); } /* for iColumnCounter */ if (tpPKeys != NULL) SPI_pfree(tpPKeys); debug_msg3("dbmirror:packageData returning DataBlockSize:%d iUsedDataBlock:%d", iDataBlockSize, iUsedDataBlock); memset(cpDataBlock + iUsedDataBlock, 0, iDataBlockSize - iUsedDataBlock); return cpDataBlock; }