int FileSystem::addInformationToFile()
{//Обозначаем переменные
	string FileName;
	int InformationCount;//Кол-во добавляемой информации, 
	int CountLength=8;
	int resultCode = 1;
	int lenCritical = 48;
	int CntCritical = 2 ^ 16;
	//int BlockNf, SegmNf, BlockNs, SegmNs; //Номер блока , номер сегмента
	FileDescriptor AddFile;
	FileDescriptor NextFile;
	//FileDescriptor LastFile;
	int ResultCount;
	int freeSpace; //кол-во свободных блоков перед следующим файлом
	int RecordNumber,NextRecordNumber; //Номер изменяемой записи, номер следующей записи
	int i; //Счетчик

	//Собствено функция
	cout << "Введите имя файла" << endl;
	cin >> FileName;
	if (getRecordNumber(FileName)==0)//Проверка ввода имени
		return(1);

	cout << "Введите кол-во добавляемой информации" << endl;
	cin >> InformationCount;
	InformationCount=InformationCount/512+1;

	AddFile = getRecord(FileName);
	if ((AddFile.descriptorType) == "0010000000000000")					//!!!!!!!в дескрипторе число блоков сделал интом!!!!!!
		return(1);
	RecordNumber=getRecordNumber(FileName);
	NextRecordNumber=RecordNumber+1;
	NextFile=getRecord(NextRecordNumber);
	
	
	if ((toInt(AddFile.firstBlockNumber) + AddFile.blockCount + InformationCount) > (toInt(NextFile.firstBlockNumber)))
	{
		//LastFile=AddFile;
		//LastFile.blockCount+=InformationCount;
		AddFile.blockCount+=InformationCount;
		for(i=217;((getRecord(i).fileType)=="");i--)
		//LastFile.firstBlockNumber=toString((toInt(getRecord(i).firstBlockNumber)+getRecord(i).blockCount+1),8);
		AddFile.firstBlockNumber=toString((toInt(getRecord(i).firstBlockNumber)+getRecord(i).blockCount+1),8);
		deleteRecord(FileName);
		//writeRecord(LastFile);
		writeRecord(AddFile);
		resultCode=0;
	}
	else 
	{
		AddFile.blockCount=(AddFile.blockCount+InformationCount);
		deleteRecord(FileName);
		writeRecord(AddFile,RecordNumber);
		resultCode=0;
	}
	return(resultCode);
};
Esempio n. 2
0
void StocksDialog::createDataPage ()
{
    QWidget *w = new QWidget(this);

    Q3VBoxLayout *vbox = new Q3VBoxLayout(w);
    vbox->setMargin(5);
    vbox->setSpacing(0);

    barEdit = new BarEdit(w);
    QString s = tr("Open");
    QString s2 = "Open";
    barEdit->createField(s, s2, FALSE);
    s = tr("High");
    s2 = "High";
    barEdit->createField(s, s2, FALSE);
    s = tr("Low");
    s2 = "Low";
    barEdit->createField(s, s2, FALSE);
    s = tr("Close");
    s2 = "Close";
    barEdit->createField(s, s2, FALSE);
    s = tr("Volume");
    s2 = "Volume";
    barEdit->createField(s, s2, FALSE);
    connect(barEdit, SIGNAL(signalDeleteRecord()), this, SLOT(deleteRecord()));
    connect(barEdit, SIGNAL(signalSaveRecord()), this, SLOT(saveRecord()));
    connect(barEdit, SIGNAL(signalSearch(QDateTime)), this, SLOT(slotDateSearch(QDateTime)));
    connect(barEdit, SIGNAL(signalFirstRecord()), this, SLOT(slotFirstRecord()));
    connect(barEdit, SIGNAL(signalLastRecord()), this, SLOT(slotLastRecord()));
    connect(barEdit, SIGNAL(signalPrevRecord()), this, SLOT(slotPrevRecord()));
    connect(barEdit, SIGNAL(signalNextRecord()), this, SLOT(slotNextRecord()));
    vbox->addWidget(barEdit);

    addTab(w, tr("Data"));
}
Esempio n. 3
0
/*
 * destructor, free all ressources
 *
 */
AutoFocus::~AutoFocus()
{
	for (uint32_t i=0; i<hashSize; i++) {
		if (listIPRecords[i].size()==0) continue;

		list<IPRecord*>::iterator iter = listIPRecords[i].begin();
		while (iter != listIPRecords[i].end()) {
			std::map<report_enum,af_attribute*>::iterator iter2 = (*iter)->m_attributes.begin();

			while (iter2 != (*iter)->m_attributes.end())	
			{
				delete (iter2->second);	
				iter2++;
			}
			delete *iter;
			iter++;
		}
		listIPRecords[i].clear();
	}

	delete[] listIPRecords;

	for (uint32_t i = 0; i < numTrees;i++)
	{
		if (m_treeRecords[i] != NULL)
			deleteRecord(i);

	}
	msg(MSG_FATAL,"Autofocus is done");
}
Esempio n. 4
0
    void RocksRecordStore::cappedDeleteAsNeeded(OperationContext* txn) {
        if (!cappedAndNeedDelete())
            return;
        // This persistent iterator is necessary since you can't read your own writes
        boost::scoped_ptr<rocksdb::Iterator> iter( _db->NewIterator( _readOptions( txn ),
                                                                     _columnFamily ) );
        iter->SeekToFirst();

        // XXX TODO there is a bug here where if the size of the write batch exceeds the cap size
        // then iter will not be valid and it will crash. To fix this we need the ability to
        // query the write batch, and delete the oldest record in the write batch until the
        // size of the write batch is less than the cap

        // XXX PROBLEMS
        // 2 threads could delete the same document
        // multiple inserts using the same snapshot will delete the same document
        while ( cappedAndNeedDelete() && iter->Valid() ) {
            invariant(_numRecords > 0);

            rocksdb::Slice slice = iter->key();
            DiskLoc oldest = _makeDiskLoc( slice );

            if ( _cappedDeleteCallback )
                uassertStatusOK(_cappedDeleteCallback->aboutToDeleteCapped(txn, oldest));

            deleteRecord(txn, oldest);
            iter->Next();
        }
    }
QList<QAction *> DataTableEditController::createEditActions()
{
    Q_ASSERT(addAction==0);

    QList<QAction*> actions;

    addAction = new QAction(IconUtil::getIcon("add"), tr("Add record"), this);
    connect(addAction, SIGNAL(triggered()), this, SLOT(addRecord()));
    actions.append(addAction);

    deleteAction = new QAction(IconUtil::getIcon("delete"), tr("Delete record"), this);
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRecord()));
    actions.append(deleteAction);

    actions.append(WidgetHelper::createSeparatorAction(this));

    commitAction = new QAction(IconUtil::getIcon("commit"), tr("Commit changes"), this);
    connect(commitAction, SIGNAL(triggered()), this, SLOT(commit()));
    actions.append(commitAction);

    rollbackAction = new QAction(IconUtil::getIcon("rollback"), tr("Reset changes"), this);
    connect(rollbackAction, SIGNAL(triggered()), this, SLOT(reset()));
    actions.append(rollbackAction);

    showDmlAction = new QAction(IconUtil::getIcon("query"), tr("Show commit DML"), this);
    connect(showDmlAction, SIGNAL(triggered()), this, SLOT(showDml()));
    actions.append(showDmlAction);

    return actions;
}
Esempio n. 6
0
bool DataOp::updateRecord(QString record)
{
    QString id, oldRecord;
    id  = getId(record);
    //保存旧数据
    oldRecord = selectRecord(id);
    if(oldRecord==""){
        qDebug() << "更新失败,未找到该条数据"<< record;
        return 0;
    }
    //删除原记录
    if(!deleteRecord(getId(record))){
        return 0;
    }
    //添加新记录
    if(!insertRecord(record)){
        qDebug() << "更新失败,尝试恢复旧数据";
        if(!insertRecord(oldRecord)){
            qDebug() << "数据重大错误";
        }
        return 0;
    }else{
        return 1;
    }
    return 0;
}
Esempio n. 7
0
void
ReportEdit::doubleClicked( const QModelIndex & index )
{
	const int row = index.row();

	const QDateTime key = m_model->index( row, 0 ).data().toDateTime();

	switch ( index.column() ) {
		case 1:
			if ( QMessageBox::question( this, "Подтверджение", "Удалить запись?",
						QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes ) {
				deleteRecord( key, row );
			}
			break;

		case 2:
			modifyNumText( key, row );
			break;

		case 3:
			modifyNum( key, row );
			break;

		case 4: {
			toggleZakaz( key );
			break;
		}

		default:
			;
	}
}
Esempio n. 8
0
/*
 * test3 -- 削除
 */
Result test3()
{
    Condition condition;

    /*
     * 以下のクエリを実行
     * delete from TABLE_NAME where name != 'Mickey'
     */
    strcpy(condition.name, "name");
    condition.dataType = TYPE_VARCHAR;
    condition.operator = OPR_NOT_EQUAL;
    strcpy(condition.val.stringVal, "Mickey");

    if (deleteRecord(TABLE_NAME, &condition) != OK) {
        fprintf(stderr, "Cannot delete records.\n");
        return NG;
    }

    printf("delete from TABLE_NAME where name != 'Mickey'\n");
    /* データを表示する */
    printTableData(TABLE_NAME);

    printf("\n");

    /*
     * 以下のクエリを実行
     * delete from TABLE_NAME
     */
    strcpy(condition.name, "");
    condition.dataType = TYPE_UNKNOWN;
    condition.operator = OPR_UNKNOWN;
    strcpy(condition.val.stringVal, "");
    condition.val.intVal = 0;

    if (deleteRecord(TABLE_NAME, &condition) != OK) {
        fprintf(stderr, "Cannot delete records.\n");
        return NG;
    }

    printf("delete from TABLE_NAME\n");
    /* データを表示する */
    printTableData(TABLE_NAME);

    return OK;
}
Esempio n. 9
0
Card::Card(QSqlQueryModel *personModel, QSqlQueryModel *responseModel, QWidget *parent) : CardUI(parent){
    setFormPersonMap(personModel);
    setFormResponseMap(responseModel);

    connect(submitNew, SIGNAL(clicked()), this, SLOT(addRecord()));
    connect(submitEdit, SIGNAL(clicked()), this, SLOT(editRecord()));
    connect(submitReset, SIGNAL(clicked()), this, SLOT(clearFields()));
    connect(submitDelete,SIGNAL(clicked()), this, SLOT(deleteRecord()));
}
Esempio n. 10
0
int main()
{ 
   FILE *cfPtr; /* credit.dat file pointer */
   int choice;  /* user's choice */

   /* fopen opens the file; exits if file cannot be opened */
   if ( ( cfPtr = fopen( "credit.dat", "rb+" ) ) == NULL ) {
      printf( "File could not be opened.\n" );
   } /* end if */
   else { 

      /* enable user to specify action */
      while ( ( choice = enterChoice() ) != 6 ) { 

         switch ( choice ) { 

            /* create text file from record file */
            case 1:
               textFile( cfPtr );
               break;

            /* update record */
            case 2:
               updateRecord( cfPtr );
               break;

            /* create record */
            case 3:
               newRecord( cfPtr );
               break;

            /* delete existing record */
            case 4:
               deleteRecord( cfPtr );
               break;

			/* sum up balances of valid records and record sum in text file */
			case 5:
				sumRecords( cfPtr );
				break;

            /* display message if user does not select valid choice */
            default:
               printf( "Incorrect choice\n" );
               break;
       
         } /* end switch */

      } /* end while */

      fclose( cfPtr ); /* fclose closes the file */
   } /* end else */
 
   return 0; /* indicates successful termination */

} /* end main */
Esempio n. 11
0
void IDBServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
{
    LOG(IndexedDB, "IDBServer::deleteRecord");

    auto transaction = m_transactions.get(requestData.transactionIdentifier());
    if (!transaction)
        return;

    transaction->deleteRecord(requestData, keyRangeData);
}
//Ìî³äPBFriendAgreeReceive
int cProcUserAgreeFriend::setPBFriendAgreeReceive(PBFriendAgreeReceive& u_PBFriendAgreeReceive,const string& u_strToken,\
							 const unsigned int& u_friendId)
{
	unsigned int u_userId = 0;
	int u_result = 0;
	if (!getUserIdbyToken(u_strToken,u_userId))
	{
		g_cMyGlog.errorlogRecord("procUserAddFriend getUserIdbyToken error:Token:%s\n",u_strToken.c_str());
		return K_ACCOUNT_UNNORMAL;
	}
	if (!isUserExist(u_friendId))
	{
		deleteRecord(u_userId,u_friendId);
		return K_FRIEND_IS_NOT_EXIST;
	}
	if (hasHistoryRecord(u_userId,u_friendId))
	{
		deleteRecord(u_userId,u_friendId);
		return K_OPPOSIT_IS_FRIEND;
	}
	else
	{
		if (!insertRecord(u_userId,u_friendId) || !insertRecord(u_friendId,u_userId))
		{
			u_result = -1;
		}
		else
		{
			deleteRecord(u_userId,u_friendId);
			u_PBFriendAgreeReceive.set_agreeresult(ADD_FRIEND_SUCCESS);
			PBWaitingFriend* u_PBWaitingFriend;
			u_PBWaitingFriend = u_PBFriendAgreeReceive.mutable_waitings();
			g_cProcUserWaitingFriend.getUserWaitingFriend(*u_PBWaitingFriend,u_userId);

			PBAllFriend* u_PBAllFriend;
			u_PBAllFriend = u_PBFriendAgreeReceive.mutable_friends();
			g_cProcUserGetAllFriend.getAllFriendByUserId(*u_PBAllFriend,u_userId);

		}
	}
	return u_result;
	
}
Esempio n. 13
0
void FileRecordMergeMgr::deleteAllMergedItemsButKey(RecordKeyVector &recList) {
	//if the key is also in the list, this method won't delete it.
	for (RecordKeyVector::const_iterator_type iter = recList.begin(); iter != recList.end(); iter = recList.next()) {
		if (*iter == recList.getKey()) {
			continue;
		}
		deleteRecord(*iter);
	}
	recList.clearVector();
}
vector<Address> RecordManager::findAllRecord(string fileName, const vector<int>& op, const vector<vector<char>>& value,
	const vector<int>& begin, const vector<int>& end, const vector<int> &type, int recordSize, 
	vector<vector<char>>& returnRecord, int toDelete){
	vector<Address> returnAddr;
	vector<Address> nullAddr;
	vector<char> nextBlock;
	vector<char> nextOffset;
	vector<char> tempRecord;
	Address addr;

	if (bmanager.getFileBlockNumber(fileName) == 0){
		return nullAddr;
	}

	Address head(fileName, 0, 0);
	int headSize;
	if (recordSize < 20)
		headSize = 20;
	else
		headSize = recordSize;
	vector<char> headRecord = bmanager.read(head, headSize);
	setNextAddr(headRecord, nextBlock, nextOffset, headSize - 8);
	int size = getSize(headRecord);
	//cout << "findallrecord: size: " << size << endl;

	for (int i = 0; i < size; i++){
		addr.setAddr(fileName, char4ToInt(nextBlock), char4ToInt(nextOffset));
		tempRecord = bmanager.read(addr,recordSize);
		int flag = 0;
		for (int j = 0; j < op.size(); j++){//取一条记录i和j个条件比
			int n=compareVc(value[j], tempRecord, begin[j], end[j], type[j]);
			if (n == 0 && (op[j] == 0 || op[j] == 3 || op[j] == 4))
				continue;
			else if (n == 1 && (op[j] == 1 || op[j] == 3 || op[j] == 5))
				continue;
			else if (n == 2 && (op[j] == 2 || op[j] == 4 || op[j] == 5))
				continue;
			else{
				flag = 1;
				break;
			}
		}
		//cout <<"flag: "<< flag << endl;
		if (flag==0){
			if (toDelete){
				//printvc(tempRecord);
				deleteRecord(tempRecord, fileName, recordSize, 1);
			}
			returnRecord.push_back(tempRecord);
			returnAddr.push_back(addr);
		}
		setNextAddr(tempRecord, nextBlock, nextOffset, recordSize - 8);
	}
	return returnAddr;
}
Esempio n. 15
0
RC testTombstone(void)
{
	RM_TableData *table = (RM_TableData *)malloc(sizeof(RM_TableData));
	TestRecord inserts[] = {
		{ 1, "aaaa", 3 },
		{ 2, "bbbb", 2 },
		{ 3, "cccc", 1 },
		{ 4, "dddd", 3 },
		{ 5, "eeee", 5 },
		{ 6, "ffff", 1 },
		{ 7, "gggg", 3 },
		{ 8, "hhhh", 3 },
		{ 9, "iiii", 2 },
		{ 10, "jjjj", 5 },
	};
	int numInserts = 10, numUpdates = 3, numDeletes = 5, numFinal = 5, i;
	Record *r;
	RID *rids;
	Schema *schema;
	testName = "test creating a new table and insert,update,delete tuples";
	schema = testSchema();
	rids = (RID *)malloc(sizeof(RID) * numInserts);

	TEST_CHECK(initRecordManager(NULL));
	TEST_CHECK(createTable("test_table_r", schema));
	TEST_CHECK(openTable(table, "test_table_r"));

	// insert rows into table
	for (i = 0; i < numInserts; i++)
	{
		r = fromTestRecord(schema, inserts[i]);
		TEST_CHECK(insertRecord(table, r));
		rids[i] = r->id;
	}

	TEST_CHECK(deleteRecord(table, rids[9]));
	RID id;
	id.page = rids[9].page;
	id.slot = rids[10].slot;
	int isTombstone = checkIfTombstoneEncountered(table, rids[9]);

	TEST_CHECK(closeTable(table));
	TEST_CHECK(deleteTable("test_table_r"));
	TEST_CHECK(shutdownRecordManager());

	free(table);
	if (isTombstone == 1) {
		return RC_OK;
	}
	else {
		return RC_NOT_A_TOMBSTONE;
	}

}
void CustomsManage::createAction()
{

    alterAct=new QAction(QIcon(":/image/alter.png"),tr("修改"),this);
    connect(alterAct,SIGNAL(triggered()),this,SLOT(alterRecord()));

    deleteAct=new QAction(QIcon(":/image/alter.png"),tr("删除"),this);
    connect(deleteAct,SIGNAL(triggered()),this,SLOT(deleteRecord()));


}
Esempio n. 17
0
void FileRecordMergeMgr::addToStorage(Record *record) {
	//if the strand requirements are strict, and the record doesn't match,
	//store in the "round file".

	if ((_desiredStrand == SAME_STRAND_FORWARD && record->getStrandVal() != Record::FORWARD) ||
			(_desiredStrand == SAME_STRAND_REVERSE && record->getStrandVal() != Record::REVERSE) ||
			(_desiredStrand != ANY_STRAND && record->getStrandVal() == Record::UNKNOWN)) {
		deleteRecord(record);
		return;
	}
	_storedRecords.push(record);
}
Esempio n. 18
0
    void HeapRecordStore::cappedDeleteAsNeeded(OperationContext* txn) {
        while (cappedAndNeedDelete()) {
            invariant(!_records.empty());

            DiskLoc oldest = _records.begin()->first;

            if (_cappedDeleteCallback)
                uassertStatusOK(_cappedDeleteCallback->aboutToDeleteCapped(txn, oldest));

            deleteRecord(txn, oldest);
        }
    }
Esempio n. 19
0
    Status RocksRecordStore::truncate( OperationContext* txn ) {
        // XXX once we have readable WriteBatch, also delete outstanding writes to
        // this collection in the WriteBatch
        //AFB add Clear(ColumnFamilyHandle*)
        boost::scoped_ptr<RecordIterator> iter( getIterator( txn ) );
        while( !iter->isEOF() ) {
            DiskLoc loc = iter->getNext();
            deleteRecord( txn, loc );
        }

        return Status::OK();
    }
Esempio n. 20
0
void DatabaseManager::deleteRecordWithCount(const StringPimpl &key,
											const StringPimpl &value)
{
	vector<StringPimpl> files;

	//decrement the size by one
	if(recordCountExists(key, value))
	{
		int size = getRecordTotalCount(key);
		addRecord(m_reserved + key + "_@size_@", StringPimpl::getString(size - 1));
		deleteRecord(m_reserved + key + "_@existence_@" + value);
	}
}
    Status KVRecordStore::truncate( OperationContext* txn ) {
        // This is not a very performant implementation of truncate.
        //
        // At the time of this writing, it is only used by 'emptycapped', a test-only command.
        const bool forward = true;
        for (boost::scoped_ptr<KVRecordCursor> iter(getKVCursor(txn, forward));
             !iter->isEOF(); ) {
            RecordId id = iter->getNext();
            deleteRecord(txn, id);
        }

        return Status::OK();
    }
void MemoryObjectStore::deleteRange(const IDBKeyRangeData& inputRange)
{
    LOG(IndexedDB, "MemoryObjectStore::deleteRange");

    ASSERT(m_writeTransaction);

    if (inputRange.isExactlyOneKey()) {
        deleteRecord(inputRange.lowerKey);
        return;
    }

    IDBKeyRangeData range = inputRange;
    while (true) {
        auto key = lowestKeyWithRecordInRange(range);
        if (key.isNull())
            break;

        deleteRecord(key);

        range.lowerKey = key;
        range.lowerOpen = true;
    }
}
Esempio n. 23
0
 void KVRecordStoreCapped::temp_cappedTruncateAfter(OperationContext* txn,
                                                    RecordId end,
                                                    bool inclusive) {
     WriteUnitOfWork wu( txn );
     // Not very efficient, but it should only be used by tests.
     for (boost::scoped_ptr<RecordIterator> iter(KVRecordStore::getIterator(txn, end)); !iter->isEOF(); ) {
         RecordId loc = iter->getNext();
         if (!inclusive && loc == end) {
             continue;
         }
         deleteRecord(txn, loc);
     }
     wu.commit();
 }
Esempio n. 24
0
static void reserveSpace (git_uint32 n)
{
    UndoRecord * u = gUndo;
    if (u == NULL)
        return;

    // Find the oldest undo record.

    while (u->prev)
        u = u->prev;

    // Delete records until we've freed up the required amount of space.

    while (gUndoSize + n > gMaxUndoSize)
    {
        if (u->next)
        {
            assert (u->next->prev == u);
            u = u->next;

            deleteRecord (u->prev);
            u->prev = NULL;
        }
        else
        {
            assert (u == gUndo);
            if (n > 0)
            {
                gUndo = NULL;

                deleteRecord (u);
                assert (gUndoSize == 0);
            }
            break;
        }
    }
}
Esempio n. 25
0
int main()
{
    int choice;
    init_mass_struct();
    for(;;)
    {
        printf("Hello, user. What do you want?\n\n");
        printf("1. Create new DB.\n");
        printf("2. Add record.\n");
        printf("3. Delete record.\n");
        printf("4. Sort DB.\n");
        printf("5. Save DB.\n");
        printf("6. Load DB.\n");
        printf("0. Exit.\n");
        scanf("%d", &choice);

        switch (choice)
        {
        case 1:
            createDB();
            break;
        case 2:
            addRecord();
            break;
        case 3:
            deleteRecord();
            break;
        case 4:
            sortDB();
            break;
        case 5:
            saveDB();
            break;
      case 6:
           loadDB();
            break;
        case 0:
            system("cls");
            printf("Bye-bye, user.");
            return 0;
            break;
        default:
            system("cls");
            printf("Error! Please, enter correct menu number, or 0 to exit.\n\n");
            break;
        }
    }
    return 0;
}
Esempio n. 26
0
void WiredTigerRecordStore::temp_cappedTruncateAfter(OperationContext* txn,
                                                     RecordId end,
                                                     bool inclusive) {
    WriteUnitOfWork wuow(txn);
    Cursor cursor(txn, *this);
    while (auto record = cursor.next()) {
        RecordId loc = record->id;
        if (end < loc || (inclusive && end == loc)) {
            if (_cappedDeleteCallback)
                uassertStatusOK(_cappedDeleteCallback->aboutToDeleteCapped(txn, loc, record->data));
            deleteRecord(txn, loc);
        }
    }
    wuow.commit();
}
Esempio n. 27
0
void displayMenu()
{
    int mode;

    puts("Выберите команду:");
    puts("1 - Создать файл");
    puts("2 - Показать содержимое файла");
    puts("3 - Добавить запись в файл");
    puts("4 - Удалить запись из файла");
    puts("5 - Изменить запись из файла");
    puts("6 - Отсортировать по фамилии и отобразить");
    puts("7 - Показать количество телефонов с определенного года");
    scanf("%d", &mode);

    switch (mode)
    {
        case 1:
            createFile();
            displayMenu();
            break;
        case 2:
            displayFileContent();
            displayMenu();
            break;
        case 3:
            createRecord();
            displayMenu();
            break;
        case 4:
            deleteRecord();
            displayMenu();
            break;
        case 5:
            updateRecord();
            displayMenu();
            break;
        case 6:
            displayBySurname();
            displayMenu();
            break;
        case 7:
            displayCountSinceYear();
            displayMenu();
            break;
        default:
            puts("Выходим...");
    }
}
Esempio n. 28
0
    void RocksRecordStore::temp_cappedTruncateAfter( OperationContext* txn,
                                                     DiskLoc end,
                                                     bool inclusive ) {
        boost::scoped_ptr<RecordIterator> iter(
                getIterator( txn, maxDiskLoc, false, CollectionScanParams::BACKWARD ) );

        while( !iter->isEOF() ) {
            WriteUnitOfWork wu( txn );
            DiskLoc loc = iter->getNext();
            if ( loc < end || ( !inclusive && loc == end))
                return;

            deleteRecord( txn, loc );
            wu.commit();
        }
    }
Esempio n. 29
0
void Page::updateRecord(const RecordId& record_id,
                        const std::string& record_data) {
  validateRecordId(record_id);
  const PageSlot* slot = getSlot(record_id.slot_number);
  const std::size_t free_space_after_delete =
      getFreeSpace() + slot->item_length;
  if (record_data.length() > free_space_after_delete) {
    throw InsufficientSpaceException(
        page_number(), record_data.length(), free_space_after_delete);
  }
  // We have to disallow slot compaction here because we're going to place the
  // record data in the same slot, and compaction might delete the slot if we
  // permit it.
  deleteRecord(record_id, false /* allow_slot_compaction */);
  insertRecordInSlot(record_id.slot_number, record_data);
}
Esempio n. 30
0
int main()
{
    Student table[SIZE];
    int ch;
    int flag = 1;
    
    initializeTable(table);
    
    do
    {
        printf("\n 1. Add Record ");
        printf("\n 2. Modify Record ");        
        printf("\n 3. Delete Record ");
        printf("\n 4. Search Record ");
        printf("\n 5. View All Record ");
        printf("\n 6. Exit ");
        printf("\n Enter Choice ");
        scanf("%d", &ch);
        
        switch(ch)
        {
            case 1: //add record
                addRecord(table);
                break;
            case 2: //modify record
                modify(table);
                break;
            case 3: //delete record
                deleteRecord(table);
                break;
            case 4: //search record
                search(table);
                break;
            case 5: //view all records
                viewAll(table);
                break;
            case 6: //exit
                flag = 0;
                break;
            default:
                printf("\n Wrong choice ");
                break;
        }//switch
    }while(flag == 1);
    
    return 0;
}