/// <summary> /// Test the data structure /// </summary> void testDataPoints() { struct dataPoint *head = getNewDataPoint(10, 1); printf("Start of tests\n"); printf("First: Value: %lu\t timestamp: %lu\n\n", head->value, head->timestamp); head = insertData(head, 20, 2); // Insert new element printf("Second inserted\n"); printf("Head: \t\tValue %lu\t timestamp %lu\n", head->value, head->timestamp); printf("Head->next: \tValue %lu\t timestamp %lu\n\n", head->next->value, head->next->timestamp); // Deletion tests printf("Before deletion:\tHead->next: %p\n", head->next); deleteLastDataPoint(head); printf("After deletion: \tHead->next: %p\n\n", head->next); // Insert a new element again. printf("Head: Value %lu\n", head->value); head = insertData(head, 30, 3); printf("Insert 30: Value %lu\n", head->value); printf("Head->next: Value %lu\n", head->next->value); printf("\nEnd of tests"); }
int main(){ LinkedList* list = creatList(); insertData(list,12); insertData(list,13); insertData(list,14); insertData(list,16); insertData(list,17); printList(list); reverseList(list); printList(list); }
int writeApplePartitionMap(int pNum, AbstractFile* file, Partition* partitions, unsigned int BlockSize, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources, NSizResource** nsizIn) { AbstractFile* bufferFile; BLKXTable* blkx; ChecksumToken uncompressedToken; Partition* buffer; NSizResource* nsiz; CSumResource csum; size_t realPartitionSize = (PARTITION_SIZE * SECTOR_SIZE) / BlockSize * BlockSize; buffer = (Partition*) malloc(realPartitionSize); memcpy(buffer, partitions, realPartitionSize); memset(&uncompressedToken, 0, sizeof(uncompressedToken)); flipPartition(buffer, TRUE, BlockSize); bufferFile = createAbstractFileFromMemory((void**)&buffer, realPartitionSize); blkx = insertBLKX(file, bufferFile, PARTITION_OFFSET * BlockSize / SECTOR_SIZE, realPartitionSize / SECTOR_SIZE, pNum, CHECKSUM_CRC32, &BlockCRC, &uncompressedToken, dataForkChecksum, dataForkToken, NULL, 0); bufferFile->close(bufferFile); *((uint32_t*)blkx->checksum.data) = uncompressedToken.crc; csum.version = 1; csum.type = CHECKSUM_MKBLOCK; csum.checksum = uncompressedToken.block; char pName[100]; sprintf(pName, "Apple (Apple_partition_map : %d)", pNum + 1); *resources = insertData(*resources, "blkx", pNum, pName, (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL); *resources = insertData(*resources, "cSum", 0, "", (const char*) (&csum), sizeof(csum), 0); nsiz = (NSizResource*) malloc(sizeof(NSizResource)); memset(nsiz, 0, sizeof(NSizResource)); nsiz->isVolume = FALSE; nsiz->blockChecksum2 = uncompressedToken.block; nsiz->partitionNumber = 0; nsiz->version = 6; nsiz->next = NULL; if((*nsizIn) == NULL) { *nsizIn = nsiz; } else { nsiz->next = (*nsizIn)->next; (*nsizIn)->next = nsiz; } free(buffer); free(blkx); return pNum + 1; }
void test_insert_string_data_in_queue1() { Queue* queue = createQueue(); string data1 = "shital" , data2 = "shweta" , data3 = "shabarin"; insertData(queue , &data1 , 1); insertData(queue , &data2 , 5); insertData(queue , &data3 , 2); insertData(queue , &data3 , 3); checkPriority(queue); ASSERT(queue->length == 4); }
void test_insert_float_data_in_queue1() { Queue* queue = createQueue(); Node* node; float data1 = 10.5 , data2 = 20.5 , data3 = 30.5; insertData(queue , &data1 , 1); insertData(queue , &data2 , 5); insertData(queue , &data3 , 2); insertData(queue , &data3 , 3); checkPriority(queue); ASSERT(queue->length == 4); }
void test_insert_integer_data_in_queue1() { Queue* queue = createQueue(); Node* node; int data1 = 10 , data2 = 20 , data3 = 30; insertData(queue , &data1 , 1); insertData(queue , &data2 , 3); insertData(queue , &data3 , 2); insertData(queue , &data3 , 1); checkPriority(queue); ASSERT(queue->length == 4); }
void test_delete_integer_data_in_queue1() { Queue* queue = createQueue(); int removedData; int data1 = 10 , data2 = 20 , data3 = 30; insertData(queue , &data1 , 1); insertData(queue , &data2 , 3); insertData(queue , &data3 , 2); ASSERT(queue->length == 3); removedData =*(int*)deleteData(queue); ASSERT(queue->length == 2); ASSERT(removedData == 10); }
void AddClientDialog::loadQuery() { ThreadControl *tc = qobject_cast<ThreadControl *>( sender() ); if( !tc ) return; int i = tc->getIndexOfLastQuery( qList ); if( i < 0 ) return; QStringList list = tc->getDataList(); switch(i) { case 0: { checkData( list ); break; } case 1: { if( list.count() > 0 ) insertData( list.first() ); break; } } }
int writeDriverDescriptorMap(int pNum, AbstractFile* file, DriverDescriptorRecord* DDM, unsigned int BlockSize, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources) { AbstractFile* bufferFile; BLKXTable* blkx; ChecksumToken uncompressedToken; DriverDescriptorRecord* buffer; buffer = (DriverDescriptorRecord*) malloc(DDM_SIZE * BlockSize); memcpy(buffer, DDM, DDM_SIZE * BlockSize); memset(&uncompressedToken, 0, sizeof(uncompressedToken)); flipDriverDescriptorRecord(buffer, TRUE); bufferFile = createAbstractFileFromMemory((void**)&buffer, DDM_SIZE * BlockSize); blkx = insertBLKX(file, bufferFile, DDM_OFFSET, DDM_SIZE, DDM_DESCRIPTOR, CHECKSUM_CRC32, &CRCProxy, &uncompressedToken, dataForkChecksum, dataForkToken, NULL, 0); blkx->checksum.data[0] = uncompressedToken.crc; char pName[100]; sprintf(pName, "Driver Descriptor Map (DDM : %d)", pNum + 1); *resources = insertData(*resources, "blkx", pNum, pName, (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL); free(buffer); bufferFile->close(bufferFile); free(blkx); pNum++; if((DDM_SIZE * BlockSize / SECTOR_SIZE) - DDM_SIZE > 0) pNum = writeFreePartition(pNum, file, DDM_SIZE, (DDM_SIZE * BlockSize / SECTOR_SIZE) - DDM_SIZE, resources); return pNum; }
void test_delete_string_data_in_queue() { Queue* queue = createQueue(); string deletedData; string data1 = "shital" , data2 = "shweta" , data3 = "shabarin"; insertData(queue , &data1 , 1); insertData(queue , &data2 , 5); insertData(queue , &data3 , 2); insertData(queue , &data3 , 3); ASSERT(queue->length == 4); checkPriority(queue); strcpy(deletedData , *(string*)deleteData(queue)); ASSERT(!strcmp(deletedData , "shital")); ASSERT(queue->length == 3); }
void test_delete_float_data_in_queue1() { Queue* queue = createQueue(); float deletedData; float data1 = 10.5 , data2 = 20.5 , data3 = 30.5; insertData(queue , &data1 , 1); insertData(queue , &data2 , 5); insertData(queue , &data3 , 2); insertData(queue , &data3 , 3); ASSERT(queue->length == 4); checkPriority(queue); deletedData = *(float*)deleteData(queue); ASSERT(queue->length == 3); ASSERT(deletedData == 10.5); }
void TestSqliteController::onInsertTable(yhge::Event* event) { CCLOG("####insert table#####"); insertData("test1","testa",1,1.1); // insertData("test2","testb",2,2.2); // insertData("test3","testc",3,3.3); }
// Create a Recurring bool QuasarDB::create(Recurring& recurring) { if (!validate(recurring)) return false; QString cmd = insertCmd("recurring", "recurring_id", "gltx_id," "description,frequency,day1,day2,max_post," "last_posted,post_count,group_id"); Stmt stmt(_connection, cmd); insertData(recurring, stmt); stmtSetId(stmt, recurring.gltxId()); stmtSetString(stmt, recurring.description()); stmtSetInt(stmt, recurring.frequency()); stmtSetInt(stmt, recurring.day1()); stmtSetInt(stmt, recurring.day2()); stmtSetInt(stmt, recurring.maxPostings()); stmtSetDate(stmt, recurring.lastPosted()); stmtSetInt(stmt, recurring.postingCount()); stmtSetId(stmt, recurring.cardGroup()); if (!execute(stmt)) return false; commit(); dataSignal(DataEvent::Insert, recurring); return true; }
// Create a Slip bool QuasarDB::create(Slip& slip) { if (!validate(slip)) return false; // Auto allocate slip number if (slip.number().stripWhiteSpace() == "#") { fixed number = uniqueNumber("slip", "number"); slip.setNumber(number.toString()); } QString cmd = insertCmd("slip", "slip_id", "vendor_id,number," "waybill,carrier,ship_date,store_id," "inv_num,num_pieces,status,post_date"); Stmt stmt(_connection, cmd); insertData(slip, stmt); stmtSetId(stmt, slip.vendorId()); stmtSetString(stmt, slip.number()); stmtSetString(stmt, slip.waybill()); stmtSetString(stmt, slip.carrier()); stmtSetDate(stmt, slip.shipDate()); stmtSetId(stmt, slip.storeId()); stmtSetString(stmt, slip.invoiceNumber()); stmtSetInt(stmt, slip.numPieces()); stmtSetString(stmt, slip.status()); stmtSetDate(stmt, slip.postDate()); if (!execute(stmt)) return false; if (!sqlCreateLines(slip)) return false; commit(); dataSignal(DataEvent::Insert, slip); return true; }
// TODO: optimize and check if pattern is just one byte, so memset can be used // TODO: see if copying larger chunks with memcpy is faster, so QMimeData* ByteArraySequenceGenerator::generateData() { const Okteta::Byte firstByte = 0; const Okteta::Byte lastByte = 255; const int insertDataSize = lastByte-firstByte+1; QByteArray insertData( insertDataSize, '\0' ); Okteta::Byte byte = firstByte; for( int i=0; i < insertDataSize; ++i, ++byte ) insertData[i] = byte; QMimeData* mimeData = new QMimeData; mimeData->setData( mimeType(), insertData ); // TODO: a method to get the description of the change, e.g. #if 0 Okteta::ChangesDescribable *changesDescribable = qobject_cast<Okteta::ChangesDescribable*>( mByteArrayModel ); if( changesDescribable ) changesDescribable->openGroupedChange( i18n("Sequence inserted.") ); mByteArrayView->insert( insertData ); // mByteArrayModel->replace( filteredSection, filterResult ); if( changesDescribable ) changesDescribable->closeGroupedChange(); #endif return mimeData; }
// TODO: use different RNG, with multiple characteristics and offer them in the config QMimeData* ByteArrayRandomDataGenerator::generateData() { qsrand( (unsigned int)time(0) ); const int insertDataSize = mSettings.size; QByteArray insertData( insertDataSize, '\0' ); for( int i=0; i < insertDataSize; ++i ) insertData[i] = qrand() % 256; // TODO: modulo is expensive, even if easy to use QMimeData* mimeData = new QMimeData; mimeData->setData( mimeType(), insertData ); // TODO: a method to get the description of the change, e.g. #if 0 Okteta::ChangesDescribable *changesDescribable = qobject_cast<Okteta::ChangesDescribable*>( mByteArrayModel ); if( changesDescribable ) changesDescribable->openGroupedChange( i18n("RandomData inserted.") ); mByteArrayView->insert( insertData ); // mByteArrayModel->replace( filteredSection, filterResult ); if( changesDescribable ) changesDescribable->closeGroupedChange(); #endif return mimeData; }
// TODO: optimize and check if pattern is just one byte, so memset can be used // TODO: see if copying larger chunks with memcpy is faster, so QMimeData* ByteArrayPatternGenerator::generateData() { const int patternSize = mSettings.pattern.size(); const int insertDataSize = mSettings.count * patternSize; QByteArray insertData( insertDataSize, '\0' ); char* rawInsertData = insertData.data(); const char* rawPatternData = mSettings.pattern.constData(); for( int i=0; i < insertDataSize; i+= patternSize ) memcpy( &rawInsertData[i], rawPatternData, patternSize ); QMimeData* mimeData = new QMimeData; mimeData->setData( mimeType(), insertData ); // TODO: a method to get the description of the change, e.g. #if 0 Okteta::ChangesDescribable *changesDescribable = qobject_cast<Okteta::ChangesDescribable*>( mByteArrayModel ); if( changesDescribable ) changesDescribable->openGroupedChange( i18n("Pattern inserted.") ); mByteArrayView->insert( insertData ); // mByteArrayModel->replace( filteredSection, filterResult ); if( changesDescribable ) changesDescribable->closeGroupedChange(); #endif return mimeData; }
ex_expr::exp_return_type ExpLOBload::eval(char *op_data[], CollHeap*h, ComDiagsArea** diagsArea) { ex_expr::exp_return_type err = ex_expr::EXPR_OK; char * handle = getExeGlobals()->lobGlobals()->lobLoadInfo()->lobHandle(lobNum()); Lng32 handleLen = getExeGlobals()->lobGlobals()->lobLoadInfo()->lobHandleLen(lobNum()); if (handle == NULL) return ex_expr::EXPR_ERROR; if (fromLoad()) { char * clientFile = op_data[1]; // call ExLoadApi Lng32 rc = LOBsql2loaderInterface (clientFile, strlen(clientFile), (char*)"loaderPort", strlen("loaderPort"), handle, handleLen, lobStorageLocation(), strlen(lobStorageLocation())); } else { err = insertData(handleLen, handle, op_data, h, diagsArea); } return err; }
void writeDriverDescriptorMap(AbstractFile* file, DriverDescriptorRecord* DDM, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources) { AbstractFile* bufferFile; BLKXTable* blkx; ChecksumToken uncompressedToken; DriverDescriptorRecord* buffer; buffer = (DriverDescriptorRecord*) malloc(DDM_SIZE * SECTOR_SIZE); memcpy(buffer, DDM, DDM_SIZE * SECTOR_SIZE); memset(&uncompressedToken, 0, sizeof(uncompressedToken)); flipDriverDescriptorRecord(buffer, TRUE); bufferFile = createAbstractFileFromMemory((void**)&buffer, DDM_SIZE * SECTOR_SIZE); blkx = insertBLKX(file, bufferFile, DDM_OFFSET, DDM_SIZE, DDM_DESCRIPTOR, CHECKSUM_CRC32, &CRCProxy, &uncompressedToken, dataForkChecksum, dataForkToken, NULL); blkx->checksum.data[0] = uncompressedToken.crc; *resources = insertData(*resources, "blkx", -1, "Driver Descriptor Map (DDM : 0)", (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL); free(buffer); bufferFile->close(bufferFile); free(blkx); }
int insertDataPage(string fname,string data) { ifstream fd; fd.open(fname.c_str(),ios::binary); if(!fd) { cerr<<"\n File does not exist....."; return -2; } fd.seekg(0,ios::end); int fileSize = fd.tellg(); cout<<"\n File size: "<<fileSize; int no_Pages = fileSize/PAGESIZE; int result; for(int i=1;i<=fileSize;i++) { result = insertData(fname,i,data); if(result == 1) break; } return 1; }
void writeATAPI(AbstractFile* file, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources, NSizResource** nsizIn) { AbstractFile* bufferFile; BLKXTable* blkx; ChecksumToken uncompressedToken; NSizResource* nsiz; CSumResource csum; char* atapi; memset(&uncompressedToken, 0, sizeof(uncompressedToken)); atapi = (char*) malloc(ATAPI_SIZE * SECTOR_SIZE); printf("malloc: %p %d\n", atapi, ATAPI_SIZE * SECTOR_SIZE); fflush(stdout); memcpy(atapi, atapi_data, ATAPI_SIZE * SECTOR_SIZE); bufferFile = createAbstractFileFromMemory((void**)&atapi, ATAPI_SIZE * SECTOR_SIZE); blkx = insertBLKX(file, bufferFile, ATAPI_OFFSET, ATAPI_SIZE, 1, CHECKSUM_CRC32, &BlockCRC, &uncompressedToken, dataForkChecksum, dataForkToken, NULL); bufferFile->close(bufferFile); free(atapi); blkx->checksum.data[0] = uncompressedToken.crc; csum.version = 1; csum.type = CHECKSUM_MKBLOCK; csum.checksum = uncompressedToken.block; *resources = insertData(*resources, "blkx", 1, "Macintosh (Apple_Driver_ATAPI : 2)", (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL); *resources = insertData(*resources, "cSum", 1, "", (const char*) (&csum), sizeof(csum), 0); nsiz = (NSizResource*) malloc(sizeof(NSizResource)); memset(nsiz, 0, sizeof(NSizResource)); nsiz->isVolume = FALSE; nsiz->blockChecksum2 = uncompressedToken.block; nsiz->partitionNumber = 1; nsiz->version = 6; nsiz->next = NULL; if((*nsizIn) == NULL) { *nsizIn = nsiz; } else { nsiz->next = (*nsizIn)->next; (*nsizIn)->next = nsiz; } free(blkx); }
int main () { queue_t* queuePtr; random_t* randomPtr; long data[] = {3, 1, 4, 1, 5}; long numData = sizeof(data) / sizeof(data[0]); long i; randomPtr = random_alloc(); assert(randomPtr); random_seed(randomPtr, 0); puts("Starting tests..."); queuePtr = queue_alloc(-1); assert(queue_isEmpty(queuePtr)); for (i = 0; i < numData; i++) { insertData(queuePtr, &data[i]); } assert(!queue_isEmpty(queuePtr)); for (i = 0; i < numData; i++) { long* dataPtr = (long*)queue_pop(queuePtr); printf("Removing %li: ", *dataPtr); printQueue(queuePtr); } assert(!queue_pop(queuePtr)); assert(queue_isEmpty(queuePtr)); puts("All tests passed."); for (i = 0; i < numData; i++) { insertData(queuePtr, &data[i]); } for (i = 0; i < numData; i++) { printf("Shuffle %li: ", i); queue_shuffle(queuePtr, randomPtr); printQueue(queuePtr); } assert(!queue_isEmpty(queuePtr)); queue_free(queuePtr); return 0; }
void MemoryTablePrivate::updateValue(const value_type &value, quint32 valueSize, quint32 offset, TableMetadata *table) { Allocation *allocation = allocationAt(offset, table); Q_ASSERT(allocation->size >= requiredSpace(valueSize)); allocation->dataSize = valueSize; insertData(allocation->data, allocation->dataSize, value); }
void CharacterDataImpl::replaceData(unsigned int offset, unsigned int count, const DOMString &dat) { if (isReadOnly()) throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); deleteData(offset, count); insertData(offset, dat); };
void MySQLLayer::dropTable(std::string schemaName, std::string tableName) { std::string sqlQuery = "DROP TABLE "; sqlQuery += schemaName; sqlQuery += "."; sqlQuery += tableName; sqlQuery += ";"; insertData(sqlQuery); }
int Krls::estimate(Data<double> data){ sample_type m; m(0) = getTime(data); cout << "Krls -> " << data.type << " esperada: " << krlsTest(m) << endl; cout << "Krls -> " << data.type << " real: " << data.value << endl; int status = abs(krlsTest(m) - (double) data.value) > LIMIT? 4 : 0; insertData(data); return status; }
void test_insert_integer_data_in_Start_of_queue() { Queue* queue = createQueue(); int data = 10; int priority = 1; insertData(queue , &data , priority); ASSERT(queue->head->priority == 1); ASSERT(*(int*)queue->head->data == 10); ASSERT(queue->length == 1); }
void DOMCharacterDataImpl::replaceData(const DOMNode *node, XMLSize_t offset, XMLSize_t count, const XMLCh *dat) { if (castToNodeImpl(node)->isReadOnly()) throw DOMException( DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMCharacterDataImplMemoryManager); deleteData(node, offset, count); insertData(node, offset, dat); }
bool TutFile::insertData(int tutID, const QString &path) { QFile f(path); if(f.open(QIODevice::ReadOnly)) { insertData(tutID, f.readAll()); f.close(); return true; } return false; }
void Wykres::zdarzenie(Obserwowany *o) { //QMessageBox::information(0, "info", "obserwator(WYKRES) powiadomiony"); if(insertData(Wydatnik::getInstance()->getData())) { rysuj = true; } else { rysuj = false; } }