From fdc1b01529b6ceb24ef51920473d8625e96d0c80 Mon Sep 17 00:00:00 2001 From: gzwongkk Date: Wed, 31 Dec 2014 21:20:36 +0800 Subject: [PATCH] improving --- DBMS/DBMS.v11.suo | Bin 38400 -> 38400 bytes DBMS/DBMS/globalVariable.h | 2 +- DBMS/DBMS/recordManage.cpp | 20 +++++++++----------- DBMS/DBMS/studentManage/studentinfo | Bin 32768 -> 32768 bytes 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/DBMS/DBMS.v11.suo b/DBMS/DBMS.v11.suo index 3cfcc4cbb8f18396b3ef7aca95d141a11eb4d99b..be023db2dbbfe87deefdafd93989c0c716a67c2a 100644 GIT binary patch delta 462 zcma*hKTpCy7zXg(ON#|W)EX2;g{tv?m_P@rg+vC@0S7l0!$1=kS)KRm3syM7@XB-#G7rfFYz zhOmq}0^6_(X^27$;t=Gg`n)rNY6Dha3TEL1Ojv~9zb&D5M&Da_XJL)sni>A0Cll(_ z5jw}q|f14GeNbl8VECa0!dM>AI|!dyE%09n06s2j|{n<+^y^rl-5J&z^=zmaJXfFm=9C F`UZCwf3g4o delta 571 zcmaiw%`Zbi6vf|+e!Z${w4vqUsiK6CQt|Ox6kXUf6;cbLVk5Cpv9j_9h>zZlmB_@> zMrUgwVNb%^(qF(vM4ds!&P#qdcg~%;bLQ<`@VyIuWHI+;qMzHf)AvG77Pw@6O`4`T zz(=`UZiZHaZqNu|m2052pdPeP*4B`iMb!pW*9)x!>a+{m0W6?;VW{(`jzZ(0mDb|^ zx9;IEr%bw+{ql+!J!%;V=?6#j; zWmjG&RApC*)c2bmo(@c40M+wBE3ffW!R2qR!BMFz zuHylVk|y51@=*Igfma?J&7vom7c57b%+<;ibql)3ttV8u>Gd kb~^UO92fPR=Cc9H93&~ZV#@6WFQe=95N7%0ZN^G}0*?ffC;$Ke diff --git a/DBMS/DBMS/globalVariable.h b/DBMS/DBMS/globalVariable.h index 38d798d..69b52e0 100644 --- a/DBMS/DBMS/globalVariable.h +++ b/DBMS/DBMS/globalVariable.h @@ -20,5 +20,5 @@ typedef unsigned char BYTE; #define STRING_TYPE 4 #define VARCHAR_TYPE 5 #define BOOLEAN_TYPE 6 - + #endif \ No newline at end of file diff --git a/DBMS/DBMS/recordManage.cpp b/DBMS/DBMS/recordManage.cpp index aae6cd2..7cc3e0e 100644 --- a/DBMS/DBMS/recordManage.cpp +++ b/DBMS/DBMS/recordManage.cpp @@ -122,18 +122,15 @@ void DBStorage::insertData(char* tablename, recordEntry record) { } } } - char* firstoffset = dataUtility::getbyte(pageInfo->data, pageInfo->header.firstFreeOffset, record.length); - char* data = new char[record.length]; - if (firstoffset[0] == 0 || pageInfo->header.freeCount == PAGE_SIZE) { - record.offset = pageInfo->header.firstFreeOffset+record.length; - data = record.getRecord(&record); + char* firstOffset = dataUtility::getbyte(pageInfo->data, pageInfo->header.firstFreeOffset+record.length-sizeof(int), sizeof(int)); + int firstFreeOffset = *(int*)firstOffset; + delete firstOffset; + if (firstFreeOffset == 0) { + pageInfo->header.firstFreeOffset += record.length; } else { - data = record.getRecord(&record); - int* temp = dataUtility::char_to_int(dataUtility::getbyte(firstoffset,record.length-4, 4)); - for(int i = 0; i < 4; i++) { - data[record.length-4+i] = firstoffset[record.length-4+i]; - } - pageInfo->header.firstFreeOffset = *temp; + pageInfo->header.firstFreeOffset = firstFreeOffset; + char* secondOffset = dataUtility::getbyte(pageInfo->data, firstFreeOffset+record.length-sizeof(int), sizeof(int)); + record.offset = *(int*)secondOffset; } pageInfo->header.freeCount -= record.length; cout << "fileid " << pageInfo->header.fileId << endl; @@ -145,3 +142,4 @@ void DBStorage::insertData(char* tablename, recordEntry record) { cout << readtest->header.fileId << endl; cout << "************************End Insert Data**********************" << endl; } + diff --git a/DBMS/DBMS/studentManage/studentinfo b/DBMS/DBMS/studentManage/studentinfo index 2653f6061b82062c399046c2ce3f57e31846b2a3..06e6f4ede350c73046bce4923efdb75a6cfaa7e6 100644 GIT binary patch delta 40 scmZo@U}|V!njj%6b95KO0pr~a945ONegN4Zz_QWsy!=E5mPHB)02y5kL;wH) delta 40 scmZo@U}|V!njj(i#`FS%fcXW62q3