WO2016101528A1 - Method and device for processing data in memory database - Google Patents

Method and device for processing data in memory database Download PDF

Info

Publication number
WO2016101528A1
WO2016101528A1 PCT/CN2015/080111 CN2015080111W WO2016101528A1 WO 2016101528 A1 WO2016101528 A1 WO 2016101528A1 CN 2015080111 W CN2015080111 W CN 2015080111W WO 2016101528 A1 WO2016101528 A1 WO 2016101528A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
database
physical space
identifier
new
Prior art date
Application number
PCT/CN2015/080111
Other languages
French (fr)
Chinese (zh)
Inventor
吴冬林
曹义
王刚
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016101528A1 publication Critical patent/WO2016101528A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • This paper relates to the field of in-memory database technology, and in particular to a data processing method and device for an in-memory database.
  • An in-memory database is a database that stores data in memory and can be directly manipulated, including data model definitions, data content itself, indexes, and so on.
  • the c library is used to store the pre-processed data when the user is configured
  • the r-c library is used to store the submitted configuration data.
  • the operation flow is as follows: first check the legality of the operation in the c library, modify the c library data after checking, the user then submits the operation, and overwrites the old data in the r library with the new data in the c library. After the operation is completed, the c library The same data exists in the r library. This method occupies more memory, and when other projects use the platform, due to the tight hardware memory resources, the database needs to occupy as little memory as possible.
  • the embodiment of the invention provides a data processing method and device for an in-memory database, the main purpose of which is to reduce the space occupied by the in-memory database.
  • a data processing method for an in-memory database comprising:
  • the deletion is performed.
  • the new data stored in the temporary physical space, the identifier of the data content corresponding to the keyword in the new data stored in the second database is set as a merge identifier
  • the method further includes:
  • the keywords in the new data match the index information of the first database and the index information of the second database, determine the data content and the content of the new data stored in the temporary physical space. Whether the data content of the second database corresponding to the keyword in the new data is the same;
  • the step of deleting the new data stored in the temporary physical space and setting the identifier of the data content corresponding to the keyword in the new data stored in the second database as a merged identifier is performed.
  • the method further includes:
  • the new data is written into the temporary physical space, the keywords in the new data are acquired, and the index information of the first database is matched; if matched, the generated The correspondence between the keyword in the new data and the temporary physical space address is saved in the index information of the first database, and the information of the successful insertion is returned; if not, the temporary physical space is deleted.
  • the stored new data returns information that the insertion failed.
  • the method further includes:
  • the keyword in the new data matches the index information of the first database but does not match the index information of the second database, generating a keyword in the new data and the temporary physical space address The correspondence between the two is stored in the index information of the first database.
  • the method further includes:
  • the method further includes:
  • the identifier of the first data is a merge identifier, modifying the merge identifier to an identifier of the first database;
  • the keyword in the first data When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the index information of the first database is updated, and the modified data of the first data stored in the new temporary physical space is deleted.
  • the method further includes:
  • the identifier of the first data is the identifier of the second database, returning information that fails to modify the first data
  • the identifier of the first data is the identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
  • the keyword in the first data When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the first database, and the modification data of the first data stored in the new temporary physical space.
  • the method further includes:
  • the method further includes:
  • the identifier of the second data is optimized, and the identifier of the second data is the merge identifier, the identifier of the second data is modified to an identifier of the second database;
  • the index information related to the second data of the first database is deleted.
  • the method further includes:
  • the in-memory database is optimized and the identifier of the second data is an identifier of the first database, deleting the second data in the first database, and deleting the first database and the second data Index information about the data;
  • the in-memory database is optimized and the identifier of the second data is an identifier of the second database, the information that the deletion fails is returned.
  • the method further includes:
  • the cursor is moved to the next record.
  • a data processing device for an in-memory database comprising:
  • a first creating unit configured to create a temporary physical space when inserting new data in the first database
  • a first setting unit configured to set an identifier of the first database in the temporary physical space if the in-memory database needs to be optimized, and write the new data into the temporary physical space;
  • a first deleting unit configured to: if the keyword in the new data matches the index information of the first database and the index information of the second database, and the data of the new data stored in the temporary physical space And the content is the same as the data content of the second database corresponding to the keyword in the new data, deleting the new data stored in the temporary physical space, and storing the new data in the second database
  • the identifier of the data content corresponding to the keyword in the keyword is set as the merge identifier
  • a first generating unit configured to generate a correspondence between a keyword in the new data and a physical space address of a data content corresponding to a keyword stored in the second data in the second database, and save the The index information of the first database.
  • the device further includes:
  • a first acquiring unit configured to acquire a keyword in the new data, and match the index information of the first database and the index information of the second database;
  • a first determining unit configured to determine, if the keyword in the new data matches the index information of the first database and the index information of the second database, the new storage in the temporary physical space Whether the data content of the data is the same as the data content of the second database corresponding to the keyword in the new data;
  • the first deleting unit performs the deleting the new data stored in the temporary physical space when the determination result of the first determining unit is the same, and storing the new data in the second database.
  • the identifier of the data content corresponding to the keyword is set to the operation of merging the identifier.
  • the device further includes:
  • a second determining unit configured to determine whether the in-memory database needs to be optimized after the temporary physical space is created when the first setting unit inserts new data in the first database
  • a writing unit configured to write the new data into the temporary physical space if the judgment result of the second determining unit is that the in-memory database does not need to be optimized; and acquire a keyword in the new data And matching the index information of the first database; if matching, generating a correspondence between the keyword in the new data and the temporary physical space address, and saving in the index information of the first database Returning the information of the successful insertion; if not, deleting the new data stored in the temporary physical space, and returning the information of the insertion failure.
  • the device further includes:
  • a second deleting unit configured to delete the new data stored in the temporary physical space if the keyword in the new data does not match the index information of the first database, and return information that the insertion fails;
  • a second generating unit configured to generate a keyword in the new data if the keyword in the new data matches the index information of the first database but does not match the index information of the second database
  • the correspondence relationship with the temporary physical space address is stored in the index information of the first database.
  • the device further includes:
  • a third generation unit configured to: if the determination result of the second determination unit is the temporary physics Generating the data content of the new data stored in the space and the data content in the second database corresponding to the keyword in the new data, generating a keyword between the new data and the temporary physical space address The corresponding relationship is saved in the index information of the first database.
  • the device further includes:
  • a third determining unit configured to determine whether the memory database exists to be optimized when the first data of the first database is modified
  • a second obtaining unit configured to acquire an identifier of the first data if a result of the determining by the third determining unit is that the in-memory database is optimized;
  • a first modifying unit configured to: if the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database;
  • a second creating unit configured to create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space to generate Updating a mapping relationship between the keyword in the first data and the new physical space address, and updating index information of the second database;
  • a storage unit configured to create a new temporary physical space, and store the modified data of the first data in the new temporary physical space
  • a fourth generating unit configured to determine, when the keyword in the first data is modified, whether a keyword in the modified data of the first data matches an index information of the first database, and if yes, Transmitting the modified data of the first data into a physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a location of the first data Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
  • the device further includes:
  • the identifier of the first data is the identifier of the second database, returning information that fails to modify the first data
  • a third creating unit configured to: if the identifier of the first data is an identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical space
  • a fifth generating unit configured to determine, when the keyword in the first data is modified, whether a keyword in the modified data of the first data matches an index information of the first database, and if yes, Transmitting the modified data of the first data into a physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a location of the first data Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
  • the device further includes:
  • a fourth determining unit configured to determine, after deleting the modified data of the first data stored in the new temporary physical space, whether the modified data of the first data has the same data content in the second database ;
  • a sixth generating unit configured to delete the same data content in the second database and generate the modified data in the first data if the determination result of the fourth determining unit is that the same data content exists Updating the correspondence between the keyword and the physical space address of the first data in the first database, updating the index information of the second database, and identifying the data content of the modified data of the first data Set to merge ID.
  • the device further includes:
  • a fifth determining unit configured to determine whether the memory database has an optimization when deleting the second data of the first database
  • a second modifying unit configured to: if the result of the determining by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the merged identifier, modify the identifier of the second data to Describe the identifier of the second database;
  • a third deleting unit configured to delete the index information related to the second data of the first database.
  • the third deleting unit is further configured to:
  • the result of the determination by the fifth determining unit is that the in-memory database does not have an optimization, deleting the second data in the first database, and deleting the index information related to the second data in the first database ;
  • the judgment result of the fifth determining unit is that the in-memory database exists optimized and the second
  • the identifier of the data is the identifier of the first database, the second data in the first database is deleted, and the index information related to the second data in the first database is deleted;
  • the result of the determination by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
  • the device further includes a searching unit, where the searching unit is configured to:
  • the cursor is moved to the next record.
  • the embodiment of the present invention when new data is inserted into a database, if the new data already has the same data content in another database, only the merge identifier is set for the data content, and no new data is added. Reduce the space occupied by the data itself; and make the two memory models define the same in-memory database to retain only one, which also reduces the space occupied by the data model definition, and achieves the purpose of reducing the space occupied by the in-memory database.
  • different processing methods are available for whether or not there is a need for memory optimization, and it is compatible with a plurality of different projects. Optimizing the in-memory database using the embodiment of the present invention can save about 30% of memory.
  • FIG. 1 is a schematic flow chart of a first embodiment of a data processing method of an in-memory database
  • FIG. 2 is a schematic flow chart of a second embodiment of a data processing method of an in-memory database
  • FIG. 3 is a schematic flow chart of a third embodiment of a data processing method of an in-memory database
  • FIG. 4 is a schematic flow chart of a fourth embodiment of a data processing method of an in-memory database
  • FIG. 5 is a schematic flowchart diagram of a fifth embodiment of a data storage method of an in-memory database
  • FIG. 6 is a schematic flowchart of a sixth embodiment of a data processing method of an in-memory database
  • FIG. 7 is a schematic flowchart of a seventh embodiment of a data processing method of an in-memory database
  • FIG. 8 is a schematic flowchart diagram of an eighth embodiment of a data processing method of an in-memory database
  • FIG. 9 is a schematic flowchart diagram of a ninth embodiment of a data processing method of an in-memory database
  • FIG. 10 is a schematic flowchart of a tenth embodiment of a data processing method of an in-memory database
  • FIG. 11 is a schematic diagram of functional modules of a first embodiment of a data processing apparatus of an in-memory database
  • FIG. 12 is a schematic diagram of functional modules of a second embodiment of a data processing apparatus of an in-memory database
  • FIG. 13 is a schematic diagram of functional modules of a third embodiment of a data processing apparatus of an in-memory database
  • FIG. 14 is a schematic diagram of functional modules of a fourth embodiment of a data processing apparatus of an in-memory database
  • 15 is a schematic diagram of functional modules of a fifth embodiment of a data processing apparatus of an in-memory database
  • 16 is a schematic diagram of functional blocks of a sixth embodiment of a data processing apparatus of an in-memory database
  • 17 is a schematic diagram of functional blocks of a seventh embodiment of a data processing apparatus of an in-memory database
  • 18 is a schematic diagram of functional modules of an eighth embodiment of a data processing apparatus of an in-memory database
  • 19 is a schematic diagram of functional blocks of a ninth embodiment of a data processing apparatus of an in-memory database
  • 20 is a schematic diagram of functional blocks of a tenth embodiment of a data processing apparatus of an in-memory database.
  • Embodiments of the present invention provide a data processing method for an in-memory database.
  • FIG. 1 is a schematic flowchart diagram of a first embodiment of a data processing method of an in-memory database.
  • the data processing method of the in-memory database includes:
  • Step 101 Create a temporary physical space when inserting new data in the first database
  • a database is created, a user table definition is created, and two indexes are created on the user table, that is, the index of the c database is retrieved and the index of the r database is retrieved.
  • the rcflag field is added to each user table as an identifier.
  • the rcflag field has three values, namely c, r, and rc, c represents that the record belongs to the c database, r represents the record belongs to the r database, and rc is the merge identifier, and the representative record belongs to
  • the c database belongs to the r database.
  • the first database is the r database
  • the second database is the c database as an example.
  • Step 102 If the in-memory database needs to be optimized, set an identifier of the first database in the temporary physical space, and write the new data into the temporary physical space;
  • the first field of the temporary physical space may be set to an rcflag field, and the rcflag field is assigned to r, to identify that new data stored in the temporary physical space needs to be inserted into the r database.
  • Step 103 If the keywords in the new data match the index information of the first database and the index information of the second database, and the data content and location of the new data stored in the temporary physical space If the data content of the second database corresponding to the keyword in the new data is the same, the new data stored in the temporary physical space is deleted, and the keyword stored in the second database and the new data is deleted.
  • the identifier of the corresponding data content is set as a merge identifier
  • key and database index information match has two meanings.
  • the meaning of the match is "if the keyword corresponds to a unique index, the new data and the keyword content in the modified data cannot be combined with the existing data.
  • the keyword content is the same.”
  • the meaning of the match is "you can find the data that matches the criteria based on the keyword.”
  • the keyword in the data of "Zhang San with the student number 10001" is "student number 10001", and matches the index information of the r database and the c database, that is, the "study number” is searched from the r database and the c database. 10001" data.
  • the new data stored in the temporary physical space is deleted, and the new data will be deleted.
  • the rcflag field in the corresponding data content in the c database is set to rc with the "student number 10001" as a key, that is, the identifier is set as the merge identifier.
  • Step 104 Generate a correspondence between a keyword in the new data and a physical space address of the data content corresponding to the keyword in the new data stored in the second database, and save the first In the index information of the database.
  • the correspondence between the "student number 10001" and the physical space address of the "study number 10001" stored in the c database is stored in the index information of the r database.
  • a temporary physical space is created; an identifier of the first database is set in the temporary physical space, and the new data is written into the temporary physical space; Determining keywords in the new data, and matching the index information of the first database and the index information of the second database; if the keywords in the new data and the index information of the first database and If the index information of the second database matches, the data content of the new data stored in the temporary physical space is determined to be the same as the data content of the second database corresponding to the keyword; if the same, the temporary data is deleted.
  • the new data stored in the physical space the identifier of the data content corresponding to the keyword stored in the second database, such as the rcflag field, is set as a merge identifier; generating keywords and keywords in the new data
  • Corresponding relationship between physical space addresses of data contents corresponding to keywords in the new data stored in the second database is saved in Said first index information database, thus reducing the space occupied by the data itself, achieve the purpose of optimizing memory footprint database.
  • FIG. 2 is a schematic flowchart of a second embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 105 Acquire a keyword in the new data, and match the index information of the first database and the index information of the second database.
  • Step 106 If the keywords in the new data match the index information of the first database and the index information of the second database, determine the data content and the new data of the temporary physical space. Whether the data content of the second database corresponding to the keyword in the new data is the same, and if the same, the step 103 is performed.
  • the method further includes:
  • Step 107 Determine whether the in-memory database needs to be optimized.
  • step 107' If the in-memory database does not require optimization, proceed to step 107';
  • the new data is written into the temporary physical space, the keywords in the new data are acquired, and the index information of the first database is matched; if matched, the key in the new data is generated.
  • Corresponding relationship between the word and the temporary physical space address is stored in the index information of the first database, and the information of the successful insertion is returned; if not, the new data stored in the temporary physical space is deleted, Returns information that the insertion failed.
  • the "Zhang San with the student number 10001" is written in the r database, it is judged that the current in-memory database does not need to be optimized, and the "study number 10001 is written from the first field of the temporary physical space. If the data of Zhang San” does not have the data of "Study 10001" in the r database, it is considered to match the r database, and the correspondence between "Student 10001" and the temporary physical space address is generated, and the index information stored in the r database is stored. If the data of "Student 10001" already exists, the data of "Zhang San of 10001" in the temporary physical space is deleted, and the information of the insertion failure is returned.
  • FIG. 3 is a schematic flowchart of a third embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 108 If the keyword in the new data does not match the index information of the first database, delete the new data stored in the temporary physical space, and return information that the insertion fails;
  • the keyword in the new data matches the index information of the first database but does not match the index information of the second database, generating a keyword in the new data and the temporary physical space address The correspondence between the two is stored in the index information of the first database.
  • FIG. 4 is a schematic flowchart diagram of a fourth embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 109 If the data content stored in the temporary physical space and the data content in the second database corresponding to the keyword in the new data are different, generate a keyword in the new data and the temporary Correspondence between physical space addresses is stored in the index information of the first database.
  • FIG. 5 is a schematic flowchart diagram of a fifth embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 501 Determine, in a case where the first data of the first database is modified, whether there is optimization in the in-memory database;
  • Step 502 If the in-memory database is optimized, obtain an identifier of the first data.
  • the identifier of the data content of the r database "Wang 5 with the student number 10003" is obtained.
  • Step 503 If the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database.
  • the rc identifier is modified to the r identifier.
  • Step 504 Create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space, and generate the first Updating the index information of the second database by a correspondence between a keyword in a data and the new physical space address;
  • creating a new physical space writing the "King of the Academy number 10003" into the new physical space, and setting the identifier of the c database in the new physical space address, and generating "learning"
  • the number 10003 corresponds to the new physical space address, and updates the index information of the c database.
  • Step 505 Create a new temporary physical space, and store the modified data of the first data in a new temporary physical space.
  • Step 506 When the keyword in the first data is modified, determine whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, the first The modified data of the data is written into the physical space of the first data in the first database, and generates a keyword in the modified data of the first data and the first data in the first database Corresponding relationship between physical space addresses, updating index information of the first database, and deleting modification data of the first data stored in the new temporary physical space.
  • the modified data of the first data is written into the physical space of the first data, and the modified data of the first data stored in the new temporary physical space is deleted; for example, it needs to be stored in r
  • the data content of "Wangwu with the student number 10003" in the database was changed to "Wang Liu with the student number 10003", and the “Wang Liu with the student number 10003” was written into the "Wang Wu with the student number 10003".
  • FIG. 6 is a schematic flowchart diagram of a sixth embodiment of a data processing method of a database.
  • the method further includes:
  • Step 507 If the identifier of the first data is the second database identifier, return information that fails to modify the first data.
  • the keyword in the first data When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the first database, and the modification data of the first data stored in the new temporary physical space. For example, the data content of "King No. 10003" stored in the r database needs to be changed to "Wang 5 with the student number 10009". If the "King of the school number 10003" stored in the r database is c The identifier of the database returns the information that failed to modify the r database.
  • the "K5 of the student number 10003" stored in the r database is the identifier of the r database, a new temporary physical space is created, and the "King of the school number 10009" is stored in the new temporary physical space. Judging whether the "student number 10009" is stored in the r database, if not stored (ie: matching with the r database), the "king five with the student number 10009” is written in "the king five with the student number 10003" in the r database. In the physical space, the correspondence between the "student number 10009” and the physical space address of the original "king five of the student number 10003" is generated, and the index information of the r database is updated. Delete the "King of the Academy number 10009" in the new temporary physical space.
  • the modified data of the first data is written into the physical space of the first data, and the modified data of the first data stored in the new temporary physical space is deleted; for example, it needs to be stored in r
  • the data content of the "King No. 10003" was changed to "Wang Six with the student number 10003", and the "Wang Six with the student number 10003” was stored in the new temporary physics.
  • the space after writing the physical space where the "King of the Academy number 10003" is located, delete the "Wang Six with the student number 10003" in the new temporary physical space.
  • FIG. 7 is a schematic flowchart diagram of a seventh embodiment of a data processing method of a database.
  • the method further includes:
  • Step 508 Determine whether the modified data of the first data has the same data content in the second database.
  • the identifier of the data content of the modified data of the first data is set as a merge identifier
  • FIG. 8 is a schematic flowchart diagram of an eighth embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 901 Determine, in the case that the second data of the first database is deleted, whether the memory database has an optimization.
  • Step 902 If the in-memory database is optimized and the identifier of the second data is the merge identifier, modify the identifier of the second data to an identifier of the second database.
  • the in-memory database is optimized and the identifier of the "study number 10006" is rc, the "six-six with the student number 10006" is modified to c.
  • Step 903 deleting the index information related to the first database and the second data (the deleted index information is a correspondence between a keyword of the second data and a physical space address of the data content of the second data) ).
  • the index information in the r database is deleted, and the deleted index information is a correspondence between the physical space addresses where the "study number 10006" and the "study number 10006" are located.
  • FIG. 9 is a schematic flowchart diagram of a ninth embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 904 if there is no optimization in the in-memory database, deleting the second data in the first database, and deleting the index information related to the second data in the first database;
  • the "six number 6 of the student number 10006" in the r database is directly deleted, and the index information of the r database is deleted, and the deleted index information is "study".
  • the identifier of the first database is optimized, and the identifier of the second data is the identifier of the first database, the second data in the first database is deleted, and the second data and the second data are deleted. Relevant index information;
  • the deleted index information is the correspondence between the physical space addresses where "student number 10006" and "study number 10006" are located.
  • the memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
  • the information indicating that the "six-six number of the student number 10006" has been deleted is returned.
  • FIG. 10 is a schematic flowchart diagram of a tenth embodiment of a data processing method of an in-memory database.
  • the method further includes:
  • Step 1101 in the case of searching for the record of the first database, moving the cursor to the first record
  • the cursor is first moved to the first record.
  • Step 1102 If the identifier of the first record is an identifier of the first database or a merge identifier, send the information of the first record.
  • the information of the first record is sent.
  • Step 1103 If the identifier of the first record is the identifier of the second database, move the cursor to the next record.
  • the cursor is moved to the next record.
  • Embodiments of the present invention provide a data processing apparatus for an in-memory database.
  • FIG. 11 is a first embodiment of a data processing apparatus for an in-memory database according to an embodiment of the present invention.
  • a schematic diagram of the functional modules of the example. The device includes:
  • the first creating unit 1201 is configured to create a temporary physical space when inserting new data in the first database
  • a database is created, a user table definition is created, and two indexes are created on the user table, that is, the index of the c database is retrieved and the index of the r database is retrieved.
  • the rcflag field is added to each user table as an identifier.
  • the rcflag field has three values, namely c, r, and rc, c represents that the record belongs to the c database, r represents the record belongs to the r database, and rc is the merge identifier, and the representative record belongs to
  • the c database belongs to the r database.
  • the first database is the r database
  • the second database is the c database as an example.
  • you want to insert a student information in the r database such as Zhang San with the student number 10001
  • the index information is the student number.
  • the first setting unit 1202 is configured to: if the in-memory database needs to be optimized, set an identifier of the first database in the temporary physical space, and write the new data into the temporary physical space;
  • the first field of the temporary physical space may be set to an rcflag field, and the rcflag field is assigned to r, to identify that new data stored in the temporary physical space needs to be inserted into the r database.
  • the keyword for obtaining the data of "Zhang San with the student number 10001" is "student number 10001", and matches the index information of the r database and the c database, that is, searching for the "study number 10001" from the r database and the c database. information.
  • the first deleting unit 1203 is configured to: if the keyword in the new data matches the index information of the first database and the index information of the second database, and the new data stored in the temporary physical space And the data content is the same as the data content of the second database corresponding to the keyword in the new data, deleting the new data stored in the temporary physical space, storing the new data in the second database
  • the identifier of the data content corresponding to the keyword in the data is set as the merge identifier;
  • the rcflag field in the corresponding data content of the keyword “student number 10001" in the c database is used. Set to rc.
  • the first generating unit 1204 is configured to generate a correspondence between a keyword in the new data and a physical space address of the data content corresponding to the keyword stored in the new data in the second database, and save the In the index information of the first database.
  • the physical space address stored in the c database is recorded in the data content corresponding to the keyword "student number 10001", and the keyword “student number 10001" and the “study number 10001” are stored in the c database.
  • the correspondence of the physical space addresses is stored in the index information of the r database.
  • FIG. 12 is a schematic diagram of functional modules of a second embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the first obtaining unit 1301 is configured to acquire a keyword in the new data, and match the index information of the first database and the index information of the second database;
  • the first determining unit 1302 is configured to determine, if the keyword in the new data matches the index information of the first database and the index information of the second database, the storage of the temporary physical space Whether the data content of the new data is the same as the data content of the second database corresponding to the keyword in the new data;
  • the identifier of the data content corresponding to the keyword in the data is set as the operation of merging the identifier.
  • the apparatus further includes: the second determining unit 1304 is configured to determine whether the in-memory database needs to be optimized after the first creating unit 1201 creates the temporary physical space;
  • the writing unit 1303 is configured to write the new data into the temporary physical space if the result of the determination by the second determining unit 1304 is that the in-memory database does not need to be optimized; and acquire the new data. a keyword matching the index information of the first database; if matched, generating a correspondence between a keyword in the new data and the temporary physical space address, and storing an index in the first database In the message, the information that the insertion was successful is returned; if it does not match, the deletion is deleted. In addition to the new data stored in the temporary physical space, information that the insertion failed is returned.
  • FIG. 13 is a functional block diagram of a third embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the second deleting unit 1401 is configured to delete the new data stored in the temporary physical space if the keyword in the new data does not match the index information of the first database, and return information that the insertion fails;
  • the second generating unit 1402 is configured to generate a key in the new data if the keyword in the new data matches the index information of the first database but does not match the index information of the second database.
  • the correspondence between the word and the temporary physical space address is stored in the index information of the first database.
  • FIG. 14 is a schematic diagram of functional modules of a fourth embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the third generating unit 1501 is configured to: if the determination result of the second determining unit is the data content of the new data stored in the temporary physical space and the data corresponding to the keyword in the new data in the second database If the content is different, generating keywords in the new data and the temporary physics The correspondence between the spatial addresses is stored in the index information of the first database.
  • FIG. 15 is a schematic diagram of functional modules of a fifth embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the third determining unit 1601 is configured to determine, if the first data of the first database is modified, whether the memory database has an optimization
  • the second obtaining unit 1602 is configured to acquire an identifier of the first data if the result of the determining by the third determining unit is that the in-memory database is optimized;
  • the identifier of the data content of the r database "Wang 5 with the student number 10003" is obtained.
  • the first modifying unit 1603 is configured to: if the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database;
  • the rc identifier is modified to the r identifier.
  • a second creating unit 1604 configured to create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space, Generating a correspondence between a keyword in the first data and the new physical space address, and updating index information of the second database;
  • creating a new physical space writing the "King of 10003" to the new physical space, and setting the identifier of the c database in the new physical space address, and generating a keyword " The correspondence between the student number 10003" and the new physical space address is stored in the index information of the c database.
  • the storage unit 1605 is configured to create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
  • the fourth generating unit 1606 is configured to determine, when the keyword in the first data is modified, whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, And modifying the modified data of the first data into the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and the first data Corresponding relationship between physical space addresses in the first database, updating index information of the first database; deleting modification data of the first data stored in the new temporary physical space.
  • FIG. 16 is a schematic diagram of functional blocks of a sixth embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the returning unit 1701 is configured to: if the identifier of the first data is the second database identifier, return information that fails to modify the first data;
  • the third creating unit 1702 is configured to: if the identifier of the first data is the identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical In space
  • the fifth generating unit 1703 is configured to determine, when the keyword in the first data is modified, whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, And modifying the modified data of the first data into the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and the first data in the Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
  • the "king five with the student number 10009” is written in "the king with the student number 10003". Five" in the physical space in the r database, and generate a correspondence between the keyword "study number 10009” and "king five with the student number 10009", update the index information of the r database, delete the new The "King of the Academy number 10009" in the temporary physical space. .
  • Reference 17 which is a functional block diagram of a seventh embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the fourth determining unit 1801 is configured to determine, after deleting the modified data of the first data stored in the new temporary physical space, whether the modified data of the first data has the same data in the second database. content;
  • the sixth generating unit 1802 is configured to delete the same data content in the second database and generate the modified data of the first data if the determination result of the fourth determining unit is that the same data content exists. Keyword and physical space of the first data in the first database Corresponding relationship between the addresses, updating the index information of the second database, setting an identifier of the data content of the modified data of the first data as a merge identifier.
  • FIG. 18 is a schematic diagram of functional blocks of an eighth embodiment of a data processing apparatus of an in-memory database.
  • the device further includes:
  • the fifth determining unit 2001 is configured to determine, if the second data of the first database is deleted, whether the memory database has an optimization (ie, whether an rcflag field exists);
  • the second modifying unit 2002 is configured to modify the identifier of the second data to be determined if the result of the determining by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the merge identifier The identifier of the second database;
  • the in-memory database is optimized and the identifier of the "six-six" with the student number 10006 is the rc flag, the "six-six" with the student number 10006 is modified to the c-identification.
  • the third deleting unit 2003 is configured to delete the index information related to the second data of the first database.
  • the correspondence between the keyword "student number 10006" and the physical space address of the "study number 10006" is deleted.
  • FIG. 19 is a schematic diagram of functional blocks of a ninth embodiment of a data processing apparatus of an in-memory database.
  • the third deleting unit 2101 is further configured to:
  • the result of the determination by the fifth determining unit 2001 is that the in-memory database is optimized and the identifier of the second data is the identifier of the first database, deleting the second data in the first database, and deleting Index information related to the second data of the first database;
  • the identifier of the "six-six with the student number 10006" is r, delete the "six-six number of the student number 10006" in the r database, and delete the index information of the r database, the key The correspondence between the word “study number 10006" and the physical space address of the "study number 10006".
  • the result of the determination by the fifth determining unit 2001 is that the in-memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
  • FIG. 20 is a schematic diagram of functional modules of a tenth embodiment of a data processing apparatus of an in-memory database.
  • the apparatus further includes a searching unit 2201, and the searching unit 2201 is configured to:
  • the cursor is first moved to the first record.
  • the information of the first record is sent.
  • the cursor is moved to the next record.
  • the cursor is moved to the next record.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A method and device for processing data in a memory database. The method comprises: a temporary physical space is created when the new data is inserted into a first database; if the memory database needs to be optimized, then the identification of the first database is set in the temporary physical space, and the new data is written into the temporary physical space; if the keywords in the new data match with the index information of the first database and the index information of a second database, and the data content of the new data stored in the temporary physical space is the same with the data content in the second database which corresponds to the keywords in the new data, then the new data stored in the temporary physical space is deleted, and the identification of the data content which is stored in the second database and corresponds to the keywords in the new data is set to be a combined identification; the relationship between the keywords in the new data and the physical space address of the data content which corresponds to the keywords in the new data and is stored in the second database, is generated and saved into the index information of the first database.

Description

内存数据库的数据处理方法及装置Data processing method and device for in-memory database 技术领域Technical field
本文涉及内存数据库技术领域,尤其涉及一种内存数据库的数据处理方法及装置。This paper relates to the field of in-memory database technology, and in particular to a data processing method and device for an in-memory database.
背景技术Background technique
内存数据库是将数据存放在内存中并且可以直接操作的数据库,主要包括数据模型定义、数据内容本身、索引等。An in-memory database is a database that stores data in memory and can be directly manipulated, including data model definitions, data content itself, indexes, and so on.
目前平台在实现某个功能时,需要创建两个用户表定义相同的数据库c和数据库r,c库用来存储用户配置时的预处理数据,r库用来存储提交后的配置数据。操作流程为:先在c库中检查操作的合法性,通过检查后修改c库数据,用户再进行提交操作,用c库中的新数据覆盖r库中的旧数据,操作完成后,c库和r库中存在相同的数据。这种方式占用内存较多,且当其他项目使用该平台时,由于硬件内存资源紧张,所以,需要数据库尽可能少地占用内存。At present, when the platform implements a certain function, it is necessary to create two database tables and database r with the same user table definition. The c library is used to store the pre-processed data when the user is configured, and the r-c library is used to store the submitted configuration data. The operation flow is as follows: first check the legality of the operation in the c library, modify the c library data after checking, the user then submits the operation, and overwrites the old data in the r library with the new data in the c library. After the operation is completed, the c library The same data exists in the r library. This method occupies more memory, and when other projects use the platform, due to the tight hardware memory resources, the database needs to occupy as little memory as possible.
发明内容Summary of the invention
本发明实施例提供一种内存数据库的数据处理方法及装置,主要目的在于减少内存数据库占用空间。The embodiment of the invention provides a data processing method and device for an in-memory database, the main purpose of which is to reduce the space occupied by the in-memory database.
为实现上述目的,采用如下技术方案:In order to achieve the above objectives, the following technical solutions are adopted:
一种内存数据库的数据处理方法,包括:A data processing method for an in-memory database, comprising:
在第一数据库中插入新数据时,创建临时物理空间;Create a temporary physical space when inserting new data in the first database;
若所述内存数据库需要优化,则在所述临时物理空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;If the in-memory database needs to be optimized, setting an identifier of the first database in the temporary physical space, and writing the new data into the temporary physical space;
若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,且所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容相同,则删除所 述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识;If the keywords in the new data match the index information of the first database and the index information of the second database, and the data content of the new data stored in the temporary physical space and the new data If the data content of the second database corresponding to the keyword in the same is the same, the deletion is performed. The new data stored in the temporary physical space, the identifier of the data content corresponding to the keyword in the new data stored in the second database is set as a merge identifier;
生成所述新数据中的关键字和所述第二数据库中存储的与所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。Generating a correspondence between a keyword in the new data and a physical space address of the data content corresponding to the keyword in the new data stored in the second database, and storing an index in the first database Information.
可选地,删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识之前,还包括:Optionally, deleting the new data stored in the temporary physical space, and setting the identifier of the data content corresponding to the keyword in the new data to the merged identifier in the second database, the method further includes:
获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;Obtaining a keyword in the new data, and matching the index information of the first database and the index information of the second database;
若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的所述新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容是否相同;If the keywords in the new data match the index information of the first database and the index information of the second database, determine the data content and the content of the new data stored in the temporary physical space. Whether the data content of the second database corresponding to the keyword in the new data is the same;
若相同,则执行删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识的步骤。If the same is the same, the step of deleting the new data stored in the temporary physical space and setting the identifier of the data content corresponding to the keyword in the new data stored in the second database as a merged identifier is performed.
可选地,所述在第一数据库中插入新数据时,创建临时物理空间之后,还包括:Optionally, after the new physical data is inserted in the first database, after the temporary physical space is created, the method further includes:
判断所述内存数据库是否需要优化;Determining whether the in-memory database needs to be optimized;
若所述内存数据库不需要优化,则将所述新数据写入所述临时物理空间,获取所述新数据中的关键字,和所述第一数据库的索引信息进行匹配;若匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,返回插入成功的信息;若不匹配,则删除所述临时物理空间存储的所述新数据,返回插入失败的信息。If the in-memory database does not need to be optimized, the new data is written into the temporary physical space, the keywords in the new data are acquired, and the index information of the first database is matched; if matched, the generated The correspondence between the keyword in the new data and the temporary physical space address is saved in the index information of the first database, and the information of the successful insertion is returned; if not, the temporary physical space is deleted. The stored new data returns information that the insertion failed.
可选地,获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配之后,还包括:Optionally, after the keyword in the new data is acquired and matched with the index information of the first database and the index information of the second database, the method further includes:
若所述新数据中的关键字与所述第一数据库的索引信息不匹配,则删除 所述临时物理空间存储的所述新数据,并且返回插入失败的信息;If the keyword in the new data does not match the index information of the first database, delete The temporary physical space stores the new data, and returns information of the insertion failure;
若所述新数据中的关键字与所述第一数据库的索引信息匹配,但与所述第二数据库的索引信息不匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。If the keyword in the new data matches the index information of the first database but does not match the index information of the second database, generating a keyword in the new data and the temporary physical space address The correspondence between the two is stored in the index information of the first database.
可选地,判断所述临时物理空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容是否相同之后,还包括:Optionally, after determining whether the data content of the new data stored in the temporary physical space and the data content in the second database that are corresponding to the keywords in the new data are the same, the method further includes:
若所述临时物理空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容不相同,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库索引信息中。Generating a keyword in the new data and the temporary if the data content of the new data stored in the temporary physical space is different from the data content in the second database corresponding to the keyword in the new data Corresponding relationships between physical space addresses are stored in the first database index information.
可选地,所述的方法还包括:Optionally, the method further includes:
在修改所述第一数据库的第一数据时,判断所述内存数据库是否存在优化;When modifying the first data of the first database, determining whether the in-memory database has an optimization;
若所述内存数据库存在优化,则获取所述第一数据的标识;Obtaining an identifier of the first data if the in-memory database is optimized;
若所述第一数据的标识为合并标识,则将所述合并标识修改为所述第一数据库的标识;If the identifier of the first data is a merge identifier, modifying the merge identifier to an identifier of the first database;
创建新的物理空间,将所述第一数据的数据内容写入所述新的物理空间,并在所述新的物理空间中设置所述第二数据库的标识,生成所述第一数据中的关键字与所述新的物理空间地址之间的对应关系,更新所述第二数据库的索引信息;Creating a new physical space, writing data content of the first data into the new physical space, and setting an identifier of the second database in the new physical space, generating the first data Updating the index information of the second database by the correspondence between the keyword and the new physical space address;
创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;Creating a new temporary physical space, and storing the modified data of the first data in the new temporary physical space;
当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息,删除所述新的临时物理空间存储的所述第一数据的修改数据。 When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the index information of the first database is updated, and the modified data of the first data stored in the new temporary physical space is deleted.
可选地,获取所述第一数据的标识之后,还包括:Optionally, after obtaining the identifier of the first data, the method further includes:
若所述第一数据的标识为所述第二数据库的标识,则返回修改所述第一数据失败的信息;If the identifier of the first data is the identifier of the second database, returning information that fails to modify the first data;
若所述第一数据的标识为所述第一数据库的标识,则创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;If the identifier of the first data is the identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the first database, and the modification data of the first data stored in the new temporary physical space.
可选地,在所述删除所述新的临时物理空间存储的所述第一数据的修改数据之后,还包括:Optionally, after the deleting the modified data of the first data stored in the new temporary physical space, the method further includes:
判断所述第一数据的修改数据在所述第二数据库中是否存在相同的数据内容;Determining whether the modified data of the first data has the same data content in the second database;
若存在相同的数据内容,则删除所述第二数据库中的相同的数据内容,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第二数据库的索引信息,将所述第一数据的修改数据的数据内容的标识设置为合并标识。If the same data content exists, delete the same data content in the second database, and generate a keyword in the modified data of the first data and a physicality of the first data in the first database Corresponding relationship between the spatial addresses, updating index information of the second database, and setting an identifier of the data content of the modified data of the first data as a merge identifier.
可选地,所述的方法还包括:Optionally, the method further includes:
在删除所述第一数据库的第二数据时,判断所述内存数据库是否存在优化;Determining whether the in-memory database has an optimization when deleting the second data of the first database;
若所述内存数据库存在优化且所述第二数据的标识为所述合并标识,则将所述第二数据的标识修改为所述第二数据库的标识;And if the identifier of the second data is optimized, and the identifier of the second data is the merge identifier, the identifier of the second data is modified to an identifier of the second database;
删除所述第一数据库的和所述第二数据有关的索引信息。The index information related to the second data of the first database is deleted.
可选地,所述的方法还包括:Optionally, the method further includes:
在删除所述第一数据库的第二数据时,若所述内存数据库不存在优化,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二 数据有关的索引信息;Deleting the second data in the first database and deleting the second data and the second data in the first database when the second data of the first database is deleted Index information about the data;
若所述内存数据库存在优化且所述第二数据的标识为所述第一数据库的标识,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the in-memory database is optimized and the identifier of the second data is an identifier of the first database, deleting the second data in the first database, and deleting the first database and the second data Index information about the data;
若所述内存数据库存在优化且所述第二数据的标识为所述第二数据库的标识,则返回删除失败的信息。If the in-memory database is optimized and the identifier of the second data is an identifier of the second database, the information that the deletion fails is returned.
可选地,所述的方法还包括:Optionally, the method further includes:
在查找所述第一数据库的记录时,将游标移到第一记录;Moving the cursor to the first record when looking up the record of the first database;
若所述第一记录的标识为所述第一数据库的标识或者合并标识,则发送所述第一记录的信息;Sending information of the first record if the identifier of the first record is an identifier of the first database or a merge identifier;
若所述第一记录的标识为所述第二数据库的标识,则将游标移到下一个记录。If the identifier of the first record is the identifier of the second database, the cursor is moved to the next record.
一种内存数据库的数据处理装置,包括:A data processing device for an in-memory database, comprising:
第一创建单元,设置成在第一数据库中插入新数据时,创建临时物理空间;a first creating unit, configured to create a temporary physical space when inserting new data in the first database;
第一设置单元,设置成若所述内存数据库需要优化,则在所述临时物理空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;a first setting unit, configured to set an identifier of the first database in the temporary physical space if the in-memory database needs to be optimized, and write the new data into the temporary physical space;
第一删除单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,且所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容相同,则删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识;a first deleting unit, configured to: if the keyword in the new data matches the index information of the first database and the index information of the second database, and the data of the new data stored in the temporary physical space And the content is the same as the data content of the second database corresponding to the keyword in the new data, deleting the new data stored in the temporary physical space, and storing the new data in the second database The identifier of the data content corresponding to the keyword in the keyword is set as the merge identifier;
第一生成单元,设置成生成所述新数据中的关键字与所述第二数据库中存储所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。a first generating unit configured to generate a correspondence between a keyword in the new data and a physical space address of a data content corresponding to a keyword stored in the second data in the second database, and save the The index information of the first database.
可选地,所述的装置还包括: Optionally, the device further includes:
第一获取单元,设置成获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;a first acquiring unit, configured to acquire a keyword in the new data, and match the index information of the first database and the index information of the second database;
第一判断单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的所述新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容是否相同;a first determining unit, configured to determine, if the keyword in the new data matches the index information of the first database and the index information of the second database, the new storage in the temporary physical space Whether the data content of the data is the same as the data content of the second database corresponding to the keyword in the new data;
所述第一删除单元当所述第一判断单元的判断结果为相同时,执行所述删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识的操作。The first deleting unit performs the deleting the new data stored in the temporary physical space when the determination result of the first determining unit is the same, and storing the new data in the second database. The identifier of the data content corresponding to the keyword is set to the operation of merging the identifier.
可选地,所述的装置还包括:Optionally, the device further includes:
第二判断单元,设置成在所述第一设置单元在第一数据库中插入新数据时,创建临时物理空间之后判断所述内存数据库是否需要优化;a second determining unit, configured to determine whether the in-memory database needs to be optimized after the temporary physical space is created when the first setting unit inserts new data in the first database;
写入单元,设置成在所述第二判断单元的判断结果为所述内存数据库不需要优化的情况下,将所述新数据写入所述临时物理空间;获取所述新数据中的关键字,和所述第一数据库的索引信息进行匹配;若匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,返回插入成功的信息;若不匹配,则删除所述临时物理空间存储的所述新数据,返回插入失败的信息。a writing unit, configured to write the new data into the temporary physical space if the judgment result of the second determining unit is that the in-memory database does not need to be optimized; and acquire a keyword in the new data And matching the index information of the first database; if matching, generating a correspondence between the keyword in the new data and the temporary physical space address, and saving in the index information of the first database Returning the information of the successful insertion; if not, deleting the new data stored in the temporary physical space, and returning the information of the insertion failure.
可选地,所述的装置还包括:Optionally, the device further includes:
第二删除单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息不匹配,则删除所述临时物理空间存储的所述新数据,并且返回插入失败的信息;a second deleting unit, configured to delete the new data stored in the temporary physical space if the keyword in the new data does not match the index information of the first database, and return information that the insertion fails;
第二生成单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息匹配,但与所述第二数据库的索引信息不匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。a second generating unit, configured to generate a keyword in the new data if the keyword in the new data matches the index information of the first database but does not match the index information of the second database The correspondence relationship with the temporary physical space address is stored in the index information of the first database.
可选地,所述的装置还包括:Optionally, the device further includes:
第三生成单元,设置成若所述第二判断单元的判断结果为所述临时物理 空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容不相同,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。a third generation unit, configured to: if the determination result of the second determination unit is the temporary physics Generating the data content of the new data stored in the space and the data content in the second database corresponding to the keyword in the new data, generating a keyword between the new data and the temporary physical space address The corresponding relationship is saved in the index information of the first database.
可选地,所述的装置还包括:Optionally, the device further includes:
第三判断单元,设置成在修改所述第一数据库的第一数据时,判断所述内存数据库是否存在优化;a third determining unit, configured to determine whether the memory database exists to be optimized when the first data of the first database is modified;
第二获取单元,设置成若所述第三判断单元的判断结果为所述内存数据库存在优化,则获取所述第一数据的标识;a second obtaining unit, configured to acquire an identifier of the first data if a result of the determining by the third determining unit is that the in-memory database is optimized;
第一修改单元,设置成若所述第一数据的标识为合并标识,则将所述合并标识修改为所述第一数据库的标识;a first modifying unit, configured to: if the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database;
第二创建单元,设置成创建新的物理空间,将所述第一数据的数据内容写入所述新的物理空间,并在所述新的物理空间中设置所述第二数据库的标识,生成所述第一数据中的关键字与所述新的物理空间地址之间的对应关系,更新所述第二数据库的索引信息;a second creating unit, configured to create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space to generate Updating a mapping relationship between the keyword in the first data and the new physical space address, and updating index information of the second database;
存储单元,设置成创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;a storage unit, configured to create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
第四生成单元,设置成当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,则将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据的在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。a fourth generating unit, configured to determine, when the keyword in the first data is modified, whether a keyword in the modified data of the first data matches an index information of the first database, and if yes, Transmitting the modified data of the first data into a physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a location of the first data Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
可选地,所述的装置还包括:Optionally, the device further includes:
返回单元,设置成若所述第一数据的标识为所述第二数据库的标识,则返回修改所述第一数据失败的信息;Returning to the unit, if the identifier of the first data is the identifier of the second database, returning information that fails to modify the first data;
第三创建单元,设置成若所述第一数据的标识为所述第一数据库的标识,则创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中; a third creating unit, configured to: if the identifier of the first data is an identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical space Medium
第五生成单元,设置成当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,则将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据的在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。a fifth generating unit, configured to determine, when the keyword in the first data is modified, whether a keyword in the modified data of the first data matches an index information of the first database, and if yes, Transmitting the modified data of the first data into a physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a location of the first data Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
可选地,所述的装置还包括:Optionally, the device further includes:
第四判断单元,设置成在删除所述新的临时物理空间存储的所述第一数据的修改数据之后,判断所述第一数据的修改数据在所述第二数据库中是否存在相同的数据内容;a fourth determining unit, configured to determine, after deleting the modified data of the first data stored in the new temporary physical space, whether the modified data of the first data has the same data content in the second database ;
第六生成单元,设置成若所述第四判断单元的判断结果为存在相同的数据内容,则删除所述第二数据库中的相同的数据内容,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第二数据库的索引信息中,将所述第一数据的修改数据的数据内容的标识设置为合并标识。a sixth generating unit, configured to delete the same data content in the second database and generate the modified data in the first data if the determination result of the fourth determining unit is that the same data content exists Updating the correspondence between the keyword and the physical space address of the first data in the first database, updating the index information of the second database, and identifying the data content of the modified data of the first data Set to merge ID.
可选地,所述的装置还包括:Optionally, the device further includes:
第五判断单元,设置成在删除所述第一数据库的第二数据时,判断所述内存数据库是否存在优化;a fifth determining unit, configured to determine whether the memory database has an optimization when deleting the second data of the first database;
第二修改单元,设置成若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述合并标识,则将所述第二数据的标识修改为所述第二数据库的标识;a second modifying unit, configured to: if the result of the determining by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the merged identifier, modify the identifier of the second data to Describe the identifier of the second database;
第三删除单元,设置成删除所述第一数据库的和所述第二数据有关的索引信息。And a third deleting unit, configured to delete the index information related to the second data of the first database.
可选地,所述第三删除单元还设置成:Optionally, the third deleting unit is further configured to:
若所述第五判断单元的判断结果是所述内存数据库不存在优化,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the result of the determination by the fifth determining unit is that the in-memory database does not have an optimization, deleting the second data in the first database, and deleting the index information related to the second data in the first database ;
若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二 数据的标识为所述第一数据库的标识,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the judgment result of the fifth determining unit is that the in-memory database exists optimized and the second The identifier of the data is the identifier of the first database, the second data in the first database is deleted, and the index information related to the second data in the first database is deleted;
若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述第二数据库的标识,则返回删除失败的信息。If the result of the determination by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
可选地,所述的装置,还包括查找单元,所述查找单元设置成:Optionally, the device further includes a searching unit, where the searching unit is configured to:
在查找所述第一数据库的记录时,将游标移到第一记录;Moving the cursor to the first record when looking up the record of the first database;
若所述第一记录的标识为所述第一数据库的标识或者合并标识,则发送所述第一记录的信息;Sending information of the first record if the identifier of the first record is an identifier of the first database or a merge identifier;
若所述第一记录的标识为所述第二数据库的标识,则将游标移到下一个记录。If the identifier of the first record is the identifier of the second database, the cursor is moved to the next record.
本发明实施例中,在向一个数据库插入新数据时,如果所述新数据在另一个数据库中已存在相同的数据内容,则只为该数据内容设置合并标识,而不新增数据,这样能够减少数据本身占用的空间;而且使得两个数据模型定义相同的内存数据库可以只保留一个,也减少了数据模型定义占用的空间,达到了减少内存数据库占用空间的目的。另外,对于是否需要/存在内存优化采用不同处理方式,可以兼容多个不同的项目。采用本发明实施例对内存数据库进行优化,大约可以节约30%内存。In the embodiment of the present invention, when new data is inserted into a database, if the new data already has the same data content in another database, only the merge identifier is set for the data content, and no new data is added. Reduce the space occupied by the data itself; and make the two memory models define the same in-memory database to retain only one, which also reduces the space occupied by the data model definition, and achieves the purpose of reducing the space occupied by the in-memory database. In addition, different processing methods are available for whether or not there is a need for memory optimization, and it is compatible with a plurality of different projects. Optimizing the in-memory database using the embodiment of the present invention can save about 30% of memory.
附图概述BRIEF abstract
图1为内存数据库的数据处理方法第一实施例的流程示意图;1 is a schematic flow chart of a first embodiment of a data processing method of an in-memory database;
图2为内存数据库的数据处理方法第二实施例的流程示意图;2 is a schematic flow chart of a second embodiment of a data processing method of an in-memory database;
图3为内存数据库的数据处理方法第三实施例的流程示意图;3 is a schematic flow chart of a third embodiment of a data processing method of an in-memory database;
图4为内存数据库的数据处理方法第四实施例的流程示意图;4 is a schematic flow chart of a fourth embodiment of a data processing method of an in-memory database;
图5为内存数据库的数据存储方法第五实施例的流程示意图;FIG. 5 is a schematic flowchart diagram of a fifth embodiment of a data storage method of an in-memory database;
图6为内存数据库的数据处理方法第六实施例的流程示意图;6 is a schematic flowchart of a sixth embodiment of a data processing method of an in-memory database;
图7为内存数据库的数据处理方法第七实施例的流程示意图;7 is a schematic flowchart of a seventh embodiment of a data processing method of an in-memory database;
图8为内存数据库的数据处理方法第八实施例的流程示意图; 8 is a schematic flowchart diagram of an eighth embodiment of a data processing method of an in-memory database;
图9为内存数据库的数据处理方法第九实施例的流程示意图;9 is a schematic flowchart diagram of a ninth embodiment of a data processing method of an in-memory database;
图10为内存数据库的数据处理方法第十实施例的流程示意图;10 is a schematic flowchart of a tenth embodiment of a data processing method of an in-memory database;
图11为内存数据库的数据处理装置第一实施例的功能模块示意图;11 is a schematic diagram of functional modules of a first embodiment of a data processing apparatus of an in-memory database;
图12为内存数据库的数据处理装置第二实施例的功能模块示意图;12 is a schematic diagram of functional modules of a second embodiment of a data processing apparatus of an in-memory database;
图13为内存数据库的数据处理装置第三实施例的功能模块示意图;13 is a schematic diagram of functional modules of a third embodiment of a data processing apparatus of an in-memory database;
图14为内存数据库的数据处理装置第四实施例的功能模块示意图;14 is a schematic diagram of functional modules of a fourth embodiment of a data processing apparatus of an in-memory database;
图15为内存数据库的数据处理装置第五实施例的功能模块示意图;15 is a schematic diagram of functional modules of a fifth embodiment of a data processing apparatus of an in-memory database;
图16为内存数据库的数据处理装置第六实施例的功能模块示意图;16 is a schematic diagram of functional blocks of a sixth embodiment of a data processing apparatus of an in-memory database;
图17为内存数据库的数据处理装置第七实施例的功能模块示意图;17 is a schematic diagram of functional blocks of a seventh embodiment of a data processing apparatus of an in-memory database;
图18为内存数据库的数据处理装置第八实施例的功能模块示意图;18 is a schematic diagram of functional modules of an eighth embodiment of a data processing apparatus of an in-memory database;
图19为内存数据库的数据处理装置第九实施例的功能模块示意图;19 is a schematic diagram of functional blocks of a ninth embodiment of a data processing apparatus of an in-memory database;
图20为内存数据库的数据处理装置第十实施例的功能模块示意图。20 is a schematic diagram of functional blocks of a tenth embodiment of a data processing apparatus of an in-memory database.
本发明的较佳实施方式Preferred embodiment of the invention
本发明实施例提供一种内存数据库的数据处理方法。Embodiments of the present invention provide a data processing method for an in-memory database.
参照图1,图1为内存数据库的数据处理方法第一实施例的流程示意图。Referring to FIG. 1, FIG. 1 is a schematic flowchart diagram of a first embodiment of a data processing method of an in-memory database.
在第一实施例中,该内存数据库的数据处理方法包括:In the first embodiment, the data processing method of the in-memory database includes:
步骤101,在第一数据库中插入新数据时,创建临时物理空间;Step 101: Create a temporary physical space when inserting new data in the first database;
其中,开启内存优化时,创建一个数据库,一份用户表定义,用户表上创建两份索引,即检索c数据库的索引和检索r数据库的索引。Among them, when memory optimization is enabled, a database is created, a user table definition is created, and two indexes are created on the user table, that is, the index of the c database is retrieved and the index of the r database is retrieved.
每张用户表中增加rcflag字段来作为标识,rcflag字段有三种取值,分别为c、r和rc,c代表记录属于c数据库,r代表记录属于r数据库,rc为合并标识,代表记录既属于c数据库又属于r数据库。以第一数据库为r数据库,第二数据库为c数据库为例进行说明。假设要在r数据库中插入一条学生信息,如学号为10001的张三,学号字段上已经创建了唯一索引,即学生信息中,学号是关键字。先创建临时物理空间存储“学号为10001的张三”的数 据。The rcflag field is added to each user table as an identifier. The rcflag field has three values, namely c, r, and rc, c represents that the record belongs to the c database, r represents the record belongs to the r database, and rc is the merge identifier, and the representative record belongs to The c database belongs to the r database. The first database is the r database, and the second database is the c database as an example. Suppose you want to insert a student information in the r database. For example, Zhang San with the student number 10001, a unique index has been created on the student number field. In the student information, the student number is a keyword. First create a temporary physical space to store the number of "Zhang San with the student number 10001" according to.
步骤102,若所述内存数据库需要优化的情况下,在所述临时物理空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;Step 102: If the in-memory database needs to be optimized, set an identifier of the first database in the temporary physical space, and write the new data into the temporary physical space;
比如,可以将所述临时物理空间的第一字段设置为rcflag字段,并赋值rcflag字段为r,用以标识所述临时物理空间存储的新数据需要插入r数据库。For example, the first field of the temporary physical space may be set to an rcflag field, and the rcflag field is assigned to r, to identify that new data stored in the temporary physical space needs to be inserted into the r database.
步骤103,若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,且所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容相同,则删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识;Step 103: If the keywords in the new data match the index information of the first database and the index information of the second database, and the data content and location of the new data stored in the temporary physical space If the data content of the second database corresponding to the keyword in the new data is the same, the new data stored in the temporary physical space is deleted, and the keyword stored in the second database and the new data is deleted. The identifier of the corresponding data content is set as a merge identifier;
其中,“关键字与数据库的索引信息匹配”有两种含义。在新增或修改数据的数据库(比如上述第一数据库)中,匹配的含义是“如果关键字对应的是唯一索引,需要新数据和修改后的数据中的关键字内容不能和已有数据的关键字内容相同”。在另一个数据库中,匹配的含义是“根据关键字能找到符合条件的数据”。Among them, "keyword and database index information match" has two meanings. In a database that adds or modifies data (such as the first database described above), the meaning of the match is "if the keyword corresponds to a unique index, the new data and the keyword content in the modified data cannot be combined with the existing data. The keyword content is the same." In another database, the meaning of the match is "you can find the data that matches the criteria based on the keyword."
比如,获取“学号为10001的张三”的数据中的关键字为“学号10001”,并和r数据库和c数据库的索引信息进行匹配,即从r数据库和c数据库中查找“学号10001”的数据。For example, the keyword in the data of "Zhang San with the student number 10001" is "student number 10001", and matches the index information of the r database and the c database, that is, the "study number" is searched from the r database and the c database. 10001" data.
在r数据库中判断是否预先存储“学号10001”,若未存储则认为和r数据库的索引信息匹配,在c数据库中查找“学号10001”的数据,如果c数据库中存在“学号10001”,则认为和c数据库的索引信息也匹配,继续判断所述临时物理空间储存的新数据的数据内容和以学号10001为关键字在c数据库中找到的记录中的数据内容(即:c数据库中学号10001对应的数据内容)是否相同。It is judged whether the "study number 10001" is stored in advance in the r database, and if it is not stored, it is considered to match the index information of the r database, and the data of "student number 10001" is searched in the c database, if "study number 10001" exists in the c database. Then, it is considered that the index information of the c database also matches, and the data content of the new data stored in the temporary physical space and the data content in the record found in the c database with the student number 10001 as keywords are continuously judged (ie: c database) Whether the data content corresponding to the middle school number 10001) is the same.
若相同,即以“学号10001”为关键字在c数据库中找到的记录中的数据内容为“学号为10001的张三”,则删除所述临时物理空间存储的所述新数据,将以“学号10001”为关键字在c数据库中对应的数据内容中的rcflag字段设置为rc,即:将标识设置为合并标识。 If they are the same, that is, the data content in the record found in the c database with the "study number 10001" as the key is "Zhang San of the student number 10001", the new data stored in the temporary physical space is deleted, and the new data will be deleted. The rcflag field in the corresponding data content in the c database is set to rc with the "student number 10001" as a key, that is, the identifier is set as the merge identifier.
步骤104,生成所述新数据中的关键字和所述第二数据库中存储的与所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。Step 104: Generate a correspondence between a keyword in the new data and a physical space address of the data content corresponding to the keyword in the new data stored in the second database, and save the first In the index information of the database.
比如,生成“学号10001”和在c数据库中存储“学号为10001的张三”的物理空间地址之间的对应关系,存储在r数据库的索引信息中。For example, the correspondence between the "student number 10001" and the physical space address of the "study number 10001" stored in the c database is stored in the index information of the r database.
本实施例通过在第一数据库中插入新数据时,创建临时物理空间;在所述临时物理空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的新数据的数据内容和与所述关键字对应的所述第二数据库的数据内容是否相同;若相同,则删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述关键字对应的数据内容的标识(比如所述rcflag字段)设置为合并标识;生成所述新数据中的关键字和所述第二数据库中存储的与所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,这样减少了数据本身占用的空间,达到了优化内存数据库占用空间的目的。In this embodiment, when a new data is inserted in the first database, a temporary physical space is created; an identifier of the first database is set in the temporary physical space, and the new data is written into the temporary physical space; Determining keywords in the new data, and matching the index information of the first database and the index information of the second database; if the keywords in the new data and the index information of the first database and If the index information of the second database matches, the data content of the new data stored in the temporary physical space is determined to be the same as the data content of the second database corresponding to the keyword; if the same, the temporary data is deleted. The new data stored in the physical space, the identifier of the data content corresponding to the keyword stored in the second database, such as the rcflag field, is set as a merge identifier; generating keywords and keywords in the new data Corresponding relationship between physical space addresses of data contents corresponding to keywords in the new data stored in the second database is saved in Said first index information database, thus reducing the space occupied by the data itself, achieve the purpose of optimizing memory footprint database.
参考2,图2为内存数据库的数据处理方法第二实施例的流程示意图。Referring to FIG. 2, FIG. 2 is a schematic flowchart of a second embodiment of a data processing method of an in-memory database.
在第二实施例中,在第一实施例的基础上,在步骤103之前还包括:In the second embodiment, based on the first embodiment, before step 103, the method further includes:
步骤105,获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;Step 105: Acquire a keyword in the new data, and match the index information of the first database and the index information of the second database.
步骤106,若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容是否相同,如果相同则进行所述步骤103。Step 106: If the keywords in the new data match the index information of the first database and the index information of the second database, determine the data content and the new data of the temporary physical space. Whether the data content of the second database corresponding to the keyword in the new data is the same, and if the same, the step 103 is performed.
可选地,在第二实施例中,在步骤101之后还包括:Optionally, in the second embodiment, after step 101, the method further includes:
步骤107,判断所述内存数据库是否需要优化;Step 107: Determine whether the in-memory database needs to be optimized.
如果需要优化,则进行步骤102; If optimization is needed, proceed to step 102;
如果所述内存数据库不需要优化则进行步骤107’;If the in-memory database does not require optimization, proceed to step 107';
107’,将所述新数据写入所述临时物理空间,获取所述新数据中的关键字,和所述第一数据库的索引信息进行匹配;若匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,返回插入成功的信息;若不匹配,则删除所述临时物理空间存储的所述新数据,返回插入失败的信息。107', the new data is written into the temporary physical space, the keywords in the new data are acquired, and the index information of the first database is matched; if matched, the key in the new data is generated. Corresponding relationship between the word and the temporary physical space address is stored in the index information of the first database, and the information of the successful insertion is returned; if not, the new data stored in the temporary physical space is deleted, Returns information that the insertion failed.
比如,若在r数据库中写入“学号为10001的张三”时,判断当前内存数据库不需要优化,则从所述临时物理空间的第一字段开始写入所述“学号为10001的张三”的数据,若r数据库中没有“学号10001”的数据,则认为和r数据库匹配,生成“学号10001”和临时物理空间地址之间的对应关系,保存在r数据库的索引信息中,返回插入成功;若已存在“学号10001”的数据,则删除临时物理空间中所述“学号为10001的张三”的数据,返回插入失败的信息。For example, if the "Zhang San with the student number 10001" is written in the r database, it is judged that the current in-memory database does not need to be optimized, and the "study number 10001 is written from the first field of the temporary physical space. If the data of Zhang San" does not have the data of "Study 10001" in the r database, it is considered to match the r database, and the correspondence between "Student 10001" and the temporary physical space address is generated, and the index information stored in the r database is stored. If the data of "Student 10001" already exists, the data of "Zhang San of 10001" in the temporary physical space is deleted, and the information of the insertion failure is returned.
参照图3,图3为内存数据库的数据处理方法第三实施例的流程示意图。Referring to FIG. 3, FIG. 3 is a schematic flowchart of a third embodiment of a data processing method of an in-memory database.
在第三实施例中,在第二实施例的基础上,在步骤105之后还包括:In the third embodiment, based on the second embodiment, after step 105, the method further includes:
步骤108,若所述新数据中的关键字与所述第一数据库的索引信息不匹配,则删除所述临时物理空间存储的所述新数据,并且返回插入失败的信息;Step 108: If the keyword in the new data does not match the index information of the first database, delete the new data stored in the temporary physical space, and return information that the insertion fails;
若所述新数据中的关键字与所述第一数据库的索引信息匹配,但与所述第二数据库的索引信息不匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。If the keyword in the new data matches the index information of the first database but does not match the index information of the second database, generating a keyword in the new data and the temporary physical space address The correspondence between the two is stored in the index information of the first database.
比如,若在r数据库中写入“学号为10001的张三”时,在r数据库中已存在“学号10001”的数据,则认为和r数据库不匹配,删除所述“学号为10001的张三”的数据,返回插入失败的信息。若在r数据库中写入“学号为10001的张三”时,在r数据库中没有“学号10001”的数据,且c数据库中未有“学号10001”的数据,则认为和r数据库匹配,和c数据库不匹配,生成存储“学号为10001的张三”的临时物理空间地址与所述“学号10001”的对应关系,存储在r数据库的索引信息中。For example, if the "study number 10001" is written in the r database, if the data of "study number 10001" already exists in the r database, it is considered that the data does not match the r database, and the "study number 10001 is deleted. The data of Zhang San" returns the information of the failed insertion. If the "study number 10001" is written in the r database, there is no "study number 10001" data in the r database, and there is no "study number 10001" data in the c database, then the r database is considered. The matching does not match the c database, and the correspondence between the temporary physical space address storing the "Zhang San of the student number 10001" and the "student number 10001" is generated and stored in the index information of the r database.
参照图4,图4为内存数据库的数据处理方法第四实施例的流程示意图。 Referring to FIG. 4, FIG. 4 is a schematic flowchart diagram of a fourth embodiment of a data processing method of an in-memory database.
在第四实施例中,在第三实施例的基础上,在步骤106之后还包括:In the fourth embodiment, based on the third embodiment, after step 106, the method further includes:
步骤109,若所述临时物理空间存储的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容不相同,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。Step 109: If the data content stored in the temporary physical space and the data content in the second database corresponding to the keyword in the new data are different, generate a keyword in the new data and the temporary Correspondence between physical space addresses is stored in the index information of the first database.
比如,若在r数据库中写入“学号为10001的张三”时,c库中存储“学号10001”的数据,但数据内容不是“张三”,则生成存储“学号为10001的张三”的临时物理空间地址与所述“学号10001”的对应关系,存储在r数据库的索引信息中。For example, if "Zhang San of 10001" is written in the r database, the data of "Student 10001" is stored in the c library, but the data content is not "Zhang San", then the storage "Study number 10001" is generated. The correspondence between the temporary physical space address of Zhang San and the "student number 10001" is stored in the index information of the r database.
参照图5,图5为内存数据库的数据处理方法第五实施例的流程示意图。Referring to FIG. 5, FIG. 5 is a schematic flowchart diagram of a fifth embodiment of a data processing method of an in-memory database.
在第一至第四实施例中任一个的基础上,所述方法还包括:On the basis of any one of the first to fourth embodiments, the method further includes:
步骤501,在修改所述第一数据库的第一数据的情况下,判断所述内存数据库是否存在优化;Step 501: Determine, in a case where the first data of the first database is modified, whether there is optimization in the in-memory database;
比如,若修改r数据库的数据内容“学号为10003的王五”时,判断所述内存数据库是否存在优化(即是否存在rcflag字段)。For example, if the data content of the r database "Wang 5 with the student number 10003" is modified, it is judged whether there is optimization in the in-memory database (that is, whether the rcflag field exists).
步骤502,若所述内存数据库存在优化,则获取所述第一数据的标识;Step 502: If the in-memory database is optimized, obtain an identifier of the first data.
比如,若所述内存数据库存在优化,则获取所述r数据库的数据内容“学号为10003的王五”的标识。For example, if there is optimization in the in-memory database, the identifier of the data content of the r database "Wang 5 with the student number 10003" is obtained.
步骤503,若所述第一数据的标识为合并标识,则将所述合并标识修改为所述第一数据库的标识;Step 503: If the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database.
比如,若所述“学号为10003的王五”的标识为rc标识,则将所述rc标识修改为r标识。For example, if the identifier of the "Wang 5 with the student number 10003" is the rc identifier, the rc identifier is modified to the r identifier.
步骤504,创建新的物理空间,将所述第一数据的数据内容写入所述新的物理空间,并在所述新的物理空间中设置所述第二数据库的标识,并生成所述第一数据中的关键字与所述新的物理空间地址之间的对应关系,更新所述第二数据库的索引信息;Step 504: Create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space, and generate the first Updating the index information of the second database by a correspondence between a keyword in a data and the new physical space address;
比如,创建新的物理空间,将所述“学号为10003的王五”写入所述新的物理空间,并在所述新的物理空间地址中设置c数据库的标识,并生成“学 号10003”与所述新的物理空间地址的对应关系,更新c数据库的索引信息。For example, creating a new physical space, writing the "King of the Academy number 10003" into the new physical space, and setting the identifier of the c database in the new physical space address, and generating "learning" The number 10003" corresponds to the new physical space address, and updates the index information of the c database.
步骤505,创建新的临时物理空间,将所述第一数据的修改数据存储在新的临时物理空间中;Step 505: Create a new temporary physical space, and store the modified data of the first data in a new temporary physical space.
比如,若需要将存储在r数据库中的“学号为10003的王五”的数据内容修改为“学号为10003的王六”或“学号为10009的王五”,则将“学号为10003的王六”或“学号为10009的王五”存储在新的临时物理空间中。For example, if you need to change the data content of "Wang 5 with the student number 10003" stored in the r database to "Wang 6 with the student number 10003" or "Wang 5 with the student number 10009", then the student number will be It is stored in the new temporary physical space for the King of the 10003 or the King of the School of the 10009.
步骤506,当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息,删除所述新的临时物理空间存储的所述第一数据的修改数据。Step 506: When the keyword in the first data is modified, determine whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, the first The modified data of the data is written into the physical space of the first data in the first database, and generates a keyword in the modified data of the first data and the first data in the first database Corresponding relationship between physical space addresses, updating index information of the first database, and deleting modification data of the first data stored in the new temporary physical space.
比如需要将存储在r数据库中的“学号为10003的王五”的数据内容修改为“学号为10009的王五”,先检查r数据库中“学号10009”是否已被占用,如果没有,将“学号为10009的王五”写入“学号为10003的王五”所在的物理空间,生成“学号10009”和原来“学号为10003的王五”所在的物理空间地址的对应关系,更新r数据库的索引信息,删除新的临时物理空间中的“学号为10009的王五”。For example, it is necessary to modify the data content of "King No. 10003" stored in the r database to "Wang 5 with the student number 10009", first check whether the "student number 10009" in the r database is occupied, if not Write the "Wang Wu with the student number 10009" into the physical space where the "King Wu No. 10003" is located, and generate the physical space address of "Student No. 10009" and the original "King Wu with the student number 10003". Correspondence relationship, update the index information of the r database, and delete the "Wang 5 with the student number 10009" in the new temporary physical space.
修改的不是关键字时,将第一数据的修改数据写入所述第一数据的物理空间,删除所述新的临时物理空间存储的所述第一数据的修改数据;比如需要将存储在r数据库中的“学号为10003的王五”的数据内容修改为“学号为10003的王六”,将“学号为10003的王六”写入所述“学号为10003的王五”所在的物理空间。删除新的临时物理空间中的“学号为10003的王六”。When the modified is not a keyword, the modified data of the first data is written into the physical space of the first data, and the modified data of the first data stored in the new temporary physical space is deleted; for example, it needs to be stored in r The data content of "Wangwu with the student number 10003" in the database was changed to "Wang Liu with the student number 10003", and the "Wang Liu with the student number 10003" was written into the "Wang Wu with the student number 10003". The physical space in which it is located. Delete the "Wang Six with the student number 10003" in the new temporary physical space.
参照图6,图6为数据库的数据处理方法第六实施例的流程示意图。Referring to FIG. 6, FIG. 6 is a schematic flowchart diagram of a sixth embodiment of a data processing method of a database.
在第五实施例中,步骤502之后还包括:In the fifth embodiment, after step 502, the method further includes:
步骤507,若所述第一数据的标识为所述第二数据库标识,则返回修改所述第一数据失败的信息;Step 507: If the identifier of the first data is the second database identifier, return information that fails to modify the first data.
若所述第一数据的标识为所述第一数据库的标识,则创建新的临时物理 空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;Creating a new temporary physics if the identifier of the first data is an identifier of the first database Space, storing the modified data of the first data in the new temporary physical space;
当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。比如需要将存储在r数据库中的“学号为10003的王五”的数据内容修改为“学号为10009的王五”,若r数据库中存储的“学号为10003的王五”为c数据库的标识,则返回修改所述r数据库失败的信息。若r数据库中存储的“学号为10003的王五”为r数据库的标识,则创建新的临时物理空间,将“学号为10009的王五”存储在新的临时物理空间中。判断r数据库中是否存储“学号10009”,若未存储(即:与r数据库匹配),将“学号为10009的王五”写入“学号为10003的王五”在所述r数据库中的物理空间中,并生成“学号10009”和原来“学号为10003的王五”的物理空间地址之间的对应关系,更新r数据库的索引信息,。删除新的临时物理空间中的“学号为10009的王五”。When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the first database, and the modification data of the first data stored in the new temporary physical space. For example, the data content of "King No. 10003" stored in the r database needs to be changed to "Wang 5 with the student number 10009". If the "King of the school number 10003" stored in the r database is c The identifier of the database returns the information that failed to modify the r database. If the "K5 of the student number 10003" stored in the r database is the identifier of the r database, a new temporary physical space is created, and the "King of the school number 10009" is stored in the new temporary physical space. Judging whether the "student number 10009" is stored in the r database, if not stored (ie: matching with the r database), the "king five with the student number 10009" is written in "the king five with the student number 10003" in the r database. In the physical space, the correspondence between the "student number 10009" and the physical space address of the original "king five of the student number 10003" is generated, and the index information of the r database is updated. Delete the "King of the Academy number 10009" in the new temporary physical space.
修改的不是关键字时,将第一数据的修改数据写入所述第一数据的物理空间,删除所述新的临时物理空间存储的所述第一数据的修改数据;比如需要将存储在r数据库中的“学号为10003的王五”的数据内容(为r数据库的标识)修改为“学号为10003的王六”,将“学号为10003的王六”存储在新的临时物理空间中,写入所述“学号为10003的王五”所在的物理空间后,删除新的临时物理空间中的“学号为10003的王六”。When the modified is not a keyword, the modified data of the first data is written into the physical space of the first data, and the modified data of the first data stored in the new temporary physical space is deleted; for example, it needs to be stored in r In the database, the data content of the "King No. 10003" (for the logo of the r database) was changed to "Wang Six with the student number 10003", and the "Wang Six with the student number 10003" was stored in the new temporary physics. In the space, after writing the physical space where the "King of the Academy number 10003" is located, delete the "Wang Six with the student number 10003" in the new temporary physical space.
参照图7,图7为数据库的数据处理方法第七实施例的流程示意图。Referring to FIG. 7, FIG. 7 is a schematic flowchart diagram of a seventh embodiment of a data processing method of a database.
在第六实施例的基础上,步骤507之后还包括:Based on the sixth embodiment, after step 507, the method further includes:
步骤508,判断所述第一数据的修改数据在所述第二数据库中是否存在相同的数据内容;Step 508: Determine whether the modified data of the first data has the same data content in the second database.
若存在相同的数据内容,则删除所述第二数据库中的相同的数据内容,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第二数据库的索引信息,将 所述第一数据的修改数据的数据内容的标识设置为合并标识;If the same data content exists, delete the same data content in the second database, and generate a keyword in the modified data of the first data and a physicality of the first data in the first database Corresponding relationship between the spatial addresses, updating the index information of the second database, The identifier of the data content of the modified data of the first data is set as a merge identifier;
比如,判断“学号为10003的王六”在c数据库中是否存储相同的数据内容,若是,则删除c数据库的数据内容,并生成“学号为10003的王六”存储在r数据库中的物理空间地址和“学号10003”之间的对应关系,更新c数据库的索引信息,并将r数据库中所述“学号为10003的王六”的标识设置为合并标识。For example, judging whether "Wang Six with the student number 10003" stores the same data content in the c database, and if so, deletes the data content of the c database, and generates "Wang 6 with the student number 10003" stored in the r database. The correspondence between the physical space address and the "student number 10003" is updated, and the index information of the c database is updated, and the identifier of the "King of the school number 10003" in the r database is set as the merge identifier.
参照图8,图8为内存数据库的数据处理方法第八实施例的流程示意图。Referring to FIG. 8, FIG. 8 is a schematic flowchart diagram of an eighth embodiment of a data processing method of an in-memory database.
在第一至第四实施例中任一个的基础上,所述方法还包括:On the basis of any one of the first to fourth embodiments, the method further includes:
步骤901,在删除所述第一数据库的第二数据的情况下,判断所述内存数据库是否存在优化;Step 901: Determine, in the case that the second data of the first database is deleted, whether the memory database has an optimization.
比如,假设需要删除r数据库的“学号为10006的张六”的情况下,判断所述内存数据库是否存在优化(即是否存在rcflag字段)。For example, if it is necessary to delete the "six-six" of the r database of the r database, it is judged whether there is optimization in the in-memory database (that is, whether or not the rcflag field exists).
步骤902,若所述内存数据库存在优化且所述第二数据的标识为所述合并标识,则将所述第二数据的标识修改为所述第二数据库的标识;Step 902: If the in-memory database is optimized and the identifier of the second data is the merge identifier, modify the identifier of the second data to an identifier of the second database.
比如,若所述内存数据库存在优化且所述“学号为10006的张六”的标识为rc,则将所述“学号为10006的张六”修改为c。For example, if the in-memory database is optimized and the identifier of the "study number 10006" is rc, the "six-six with the student number 10006" is modified to c.
步骤903,删除所述第一数据库和所述第二数据有关的索引信息(所删除的索引信息为所述第二数据的关键字和第二数据的数据内容所在物理空间地址之间的对应关系)。 Step 903, deleting the index information related to the first database and the second data (the deleted index information is a correspondence between a keyword of the second data and a physical space address of the data content of the second data) ).
比如,删除r数据库中的索引信息,所删除的索引信息为“学号10006”和“学号为10006的张六”所在的物理空间地址之间的对应关系。For example, the index information in the r database is deleted, and the deleted index information is a correspondence between the physical space addresses where the "study number 10006" and the "study number 10006" are located.
参照图9,图9为内存数据库的数据处理方法第九实施例的流程示意图。Referring to FIG. 9, FIG. 9 is a schematic flowchart diagram of a ninth embodiment of a data processing method of an in-memory database.
在第九实施例的基础上,步骤901之后还包括:On the basis of the ninth embodiment, after step 901, the method further includes:
步骤904,所述内存数据库不存在优化,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息; Step 904, if there is no optimization in the in-memory database, deleting the second data in the first database, and deleting the index information related to the second data in the first database;
比如,若所述内存数据库不存在优化,则直接删除r数据库中的“学号为10006的张六”,并删除r数据库的索引信息,所删除的索引信息为“学 号10006”和“学号为10006的张六”所在的物理空间地址之间的对应关系。For example, if there is no optimization in the in-memory database, the "six number 6 of the student number 10006" in the r database is directly deleted, and the index information of the r database is deleted, and the deleted index information is "study". The correspondence between the physical space address where the number 10006" and the "six number six of the student number 10006" are located.
所述内存数据库存在优化且所述第二数据的标识为所述第一数据库的标识,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the identifier of the first database is optimized, and the identifier of the second data is the identifier of the first database, the second data in the first database is deleted, and the second data and the second data are deleted. Relevant index information;
比如,所述内存数据库存在优化且所述“学号为10006的张六”的标识为r,则删除所述r数据库中的“学号为10006的张六”,并删除所述r数据库的索引信息,所删除的索引信息为“学号10006”和“学号为10006的张六”所在的物理空间地址之间的对应关系。For example, if the identifier of the in-memory database is optimized and the identifier of the "six-six" of the student number 10006 is r, the "six-six number of the student number 10006" in the r-database is deleted, and the r-database is deleted. Index information, the deleted index information is the correspondence between the physical space addresses where "student number 10006" and "study number 10006" are located.
所述内存数据库存在优化且所述第二数据的标识为所述第二数据库的标识,则返回删除失败的信息。If the memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
比如,所述内存数据库存在优化且所述“学号为10006的张六”的标识为c标识,则返回删除所述“学号为10006的张六”失败的信息。For example, if the identifier of the in-memory database is optimized and the identifier of the "six-six" with the student number 10006 is the c-identification, the information indicating that the "six-six number of the student number 10006" has been deleted is returned.
参照图10,图10为内存数据库的数据处理方法第十实施例的流程示意图。Referring to FIG. 10, FIG. 10 is a schematic flowchart diagram of a tenth embodiment of a data processing method of an in-memory database.
在第一至第四实施例中任一个的基础上,所述方法还包括:On the basis of any one of the first to fourth embodiments, the method further includes:
步骤1101,在查找所述第一数据库的记录的情况下,将游标移到第一记录; Step 1101, in the case of searching for the record of the first database, moving the cursor to the first record;
比如,在查找r数据库的记录的情况下,先将游标移到第一记录。For example, in the case of finding a record of the r database, the cursor is first moved to the first record.
步骤1102,若所述第一记录的标识为所述第一数据库的标识或者合并标识,则发送所述第一记录的信息;Step 1102: If the identifier of the first record is an identifier of the first database or a merge identifier, send the information of the first record.
比如,若所述第一记录的标识为r或者rc,则发送所述第一记录的信息。For example, if the identifier of the first record is r or rc, the information of the first record is sent.
步骤1103,若所述第一记录的标识为所述第二数据库的标识,则将游标移到下一个记录。Step 1103: If the identifier of the first record is the identifier of the second database, move the cursor to the next record.
比如,若所述第一记录的标识为c,则将游标移到下一个记录。For example, if the identifier of the first record is c, the cursor is moved to the next record.
本发明实施例提供一种内存数据库的数据处理装置。Embodiments of the present invention provide a data processing apparatus for an in-memory database.
参考图11,图11为本发明实施例内存数据库的数据处理装置第一实施 例的功能模块示意图。所述装置包括:Referring to FIG. 11, FIG. 11 is a first embodiment of a data processing apparatus for an in-memory database according to an embodiment of the present invention. A schematic diagram of the functional modules of the example. The device includes:
第一创建单元1201,设置成在第一数据库中插入新数据时,创建临时物理空间;The first creating unit 1201 is configured to create a temporary physical space when inserting new data in the first database;
其中,开启内存优化时,创建一个数据库,一份用户表定义,用户表上创建两份索引,即检索c数据库的索引和检索r数据库的索引。Among them, when memory optimization is enabled, a database is created, a user table definition is created, and two indexes are created on the user table, that is, the index of the c database is retrieved and the index of the r database is retrieved.
每张用户表中增加rcflag字段来作为标识,rcflag字段有三种取值,分别为c、r和rc,c代表记录属于c数据库,r代表记录属于r数据库,rc为合并标识,代表记录既属于c数据库又属于r数据库。以第一数据库为r数据库,第二数据库为c数据库为例进行说明。假设要在r数据库中插入一条学生信息,如学号为10001的张三,索引信息为学号,先创建临时物理空间存储“学号为10001的张三”的数据。The rcflag field is added to each user table as an identifier. The rcflag field has three values, namely c, r, and rc, c represents that the record belongs to the c database, r represents the record belongs to the r database, and rc is the merge identifier, and the representative record belongs to The c database belongs to the r database. The first database is the r database, and the second database is the c database as an example. Suppose you want to insert a student information in the r database, such as Zhang San with the student number 10001, and the index information is the student number. First create a temporary physical space to store the data of "Zhang San with the student number 10001".
第一设置单元1202,设置成若所述内存数据库需要优化的情况下,在所述临时物理空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;The first setting unit 1202 is configured to: if the in-memory database needs to be optimized, set an identifier of the first database in the temporary physical space, and write the new data into the temporary physical space;
比如,可以将所述临时物理空间的第一字段设置为rcflag字段,并赋值rcflag字段为r,用以标识所述临时物理空间存储的新数据需要插入r数据库。For example, the first field of the temporary physical space may be set to an rcflag field, and the rcflag field is assigned to r, to identify that new data stored in the temporary physical space needs to be inserted into the r database.
获取“学号为10001的张三”的数据的关键字为“学号10001”,并和r数据库和c数据库的索引信息进行匹配,即从r数据库和c数据库中查找“学号10001”的信息。The keyword for obtaining the data of "Zhang San with the student number 10001" is "student number 10001", and matches the index information of the r database and the c database, that is, searching for the "study number 10001" from the r database and the c database. information.
若关键字“学号10001”在r数据库和c数据库中均匹配,则判断所述临时物理空间储存的新数据和“学号10001”在c数据库中对应的记录中的数据内容是否相同。If the keyword "student number 10001" matches in both the r database and the c database, it is judged whether the new data stored in the temporary physical space and the data content in the corresponding record of the "student number 10001" in the c database are the same.
第一删除单元1203,设置成若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,且所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容相同,则删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识; The first deleting unit 1203 is configured to: if the keyword in the new data matches the index information of the first database and the index information of the second database, and the new data stored in the temporary physical space And the data content is the same as the data content of the second database corresponding to the keyword in the new data, deleting the new data stored in the temporary physical space, storing the new data in the second database The identifier of the data content corresponding to the keyword in the data is set as the merge identifier;
比如,若关键字“学号10001”在c数据库中对应的数据内容为“学号为10001的张三”,则将关键字“学号10001”在c数据库中对应的数据内容中的rcflag字段设置为rc。For example, if the corresponding data content of the keyword "student number 10001" in the c database is "Zhang San with the student number 10001", the rcflag field in the corresponding data content of the keyword "student number 10001" in the c database is used. Set to rc.
第一生成单元1204,设置成生成所述新数据中的关键字与所述第二数据库中存储所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。The first generating unit 1204 is configured to generate a correspondence between a keyword in the new data and a physical space address of the data content corresponding to the keyword stored in the new data in the second database, and save the In the index information of the first database.
具体的,记录关键字“学号10001”对应的数据内容在c数据库中存储的物理空间地址,将关键字“学号10001”和所述“学号为10001的张三”在c数据库中存储的物理空间地址的对应关系存储在r数据库的索引信息中。Specifically, the physical space address stored in the c database is recorded in the data content corresponding to the keyword "student number 10001", and the keyword "student number 10001" and the "study number 10001" are stored in the c database. The correspondence of the physical space addresses is stored in the index information of the r database.
参考12,图12为内存数据库的数据处理装置第二实施例的功能模块示意图。Referring to FIG. 12, FIG. 12 is a schematic diagram of functional modules of a second embodiment of a data processing apparatus of an in-memory database.
在装置第一实施例的基础上,所述装置还包括:Based on the first embodiment of the device, the device further includes:
第一获取单元1301,设置成获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;The first obtaining unit 1301 is configured to acquire a keyword in the new data, and match the index information of the first database and the index information of the second database;
第一判断单元1302,设置成若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的所述新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容是否相同;The first determining unit 1302 is configured to determine, if the keyword in the new data matches the index information of the first database and the index information of the second database, the storage of the temporary physical space Whether the data content of the new data is the same as the data content of the second database corresponding to the keyword in the new data;
所述第一删除单元1203当所述第一判断单元1302的判断结果为相同时,执行所述删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识的操作。The first deleting unit 1203, when the determination result of the first determining unit 1302 is the same, performing the deleting the new data stored in the temporary physical space, storing the new data in the second database The identifier of the data content corresponding to the keyword in the data is set as the operation of merging the identifier.
可选地,所述装置还包括第二判断单元1304设置成在所述第一创建单元1201创建临时物理空间之后判断所述内存数据库是否需要优化;Optionally, the apparatus further includes: the second determining unit 1304 is configured to determine whether the in-memory database needs to be optimized after the first creating unit 1201 creates the temporary physical space;
写入单元1303,设置成在所述第二判断单元1304的判断结果为所述内存数据库不需要优化的情况下,将所述新数据写入所述临时物理空间;获取所述新数据中的关键字,和所述第一数据库的索引信息进行匹配;若匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,返回插入成功的信息;若不匹配,则删 除所述临时物理空间存储的所述新数据,返回插入失败的信息。The writing unit 1303 is configured to write the new data into the temporary physical space if the result of the determination by the second determining unit 1304 is that the in-memory database does not need to be optimized; and acquire the new data. a keyword matching the index information of the first database; if matched, generating a correspondence between a keyword in the new data and the temporary physical space address, and storing an index in the first database In the message, the information that the insertion was successful is returned; if it does not match, the deletion is deleted. In addition to the new data stored in the temporary physical space, information that the insertion failed is returned.
比如,若在r数据库中写入“学号为10001的张三”时,判断当前内存数据库不需要数据优化,则从所述临时物理空间的第一字段开始写入所述“学号为10001的张三”。For example, if the "study number 10001" is written in the r database, it is judged that the current in-memory database does not need data optimization, and the "study number is 10001" is written from the first field of the temporary physical space. Zhang San".
参考13,图13为内存数据库的数据处理装置第三实施例的功能模块示意图。Referring to FIG. 13, FIG. 13 is a functional block diagram of a third embodiment of a data processing apparatus of an in-memory database.
在装置第二实施例的基础上,所述装置还包括:On the basis of the second embodiment of the device, the device further includes:
第二删除单元1401,设置成若所述新数据中的关键字与所述第一数据库的索引信息不匹配,则删除所述临时物理空间存储的所述新数据,并且返回插入失败的信息;The second deleting unit 1401 is configured to delete the new data stored in the temporary physical space if the keyword in the new data does not match the index information of the first database, and return information that the insertion fails;
第二生成单元1402,设置成若所述新数据中的关键字与所述第一数据库的索引信息匹配,但与所述第二数据库的索引信息不匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。The second generating unit 1402 is configured to generate a key in the new data if the keyword in the new data matches the index information of the first database but does not match the index information of the second database. The correspondence between the word and the temporary physical space address is stored in the index information of the first database.
比如,若在r数据库中写入“学号为10001的张三”时,在r数据库中已存在“学号为10001”的索引信息,则认为和r数据库不匹配,删除所述临时物理空间存储的“学号为10001的张三”的数据,返回插入失败的信息。若在r数据库中写入“学号为10001的张三”时,在r数据库中没有“学号为10001”的索引信息,且c数据库中未有“学号为10001”索引信息,则认为和r数据库匹配,和c数据库不匹配,生成存储“学号为10001的张三”的临时物理空间地址与所述关键字“学号为10001”的对应关系,存储在r数据库的索引信息中。For example, if the "Zhangsan with the student number 10001" is written in the r database, if the index information of the "study number 10001" already exists in the r database, it is considered that the r-database does not match, and the temporary physical space is deleted. The stored data of "Zhang San of 10001" returns the information of the failed insertion. If "Zhang San with the student number 10001" is written in the r database, there is no index information of "study number 10001" in the r database, and there is no "study number 10001" index information in the c database. Matches with the r database, and does not match the c database, and generates a correspondence between the temporary physical space address storing the "Zhangsan of the student number 10001" and the keyword "student number 10001", and is stored in the index information of the r database. .
参考14,图14为内存数据库的数据处理装置第四实施例的功能模块示意图。Referring to FIG. 14, FIG. 14 is a schematic diagram of functional modules of a fourth embodiment of a data processing apparatus of an in-memory database.
在装置第三实施例的基础上,所述装置还包括:On the basis of the third embodiment of the device, the device further includes:
第三生成单元1501,设置成若所述第二判断单元的判断结果为所述临时物理空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容不相同,则生成所述新数据中的关键字与所述临时物理 空间地址之间的对应关系,保存在所述第一数据库的索引信息中。The third generating unit 1501 is configured to: if the determination result of the second determining unit is the data content of the new data stored in the temporary physical space and the data corresponding to the keyword in the new data in the second database If the content is different, generating keywords in the new data and the temporary physics The correspondence between the spatial addresses is stored in the index information of the first database.
比如,若在r数据库中写入“学号为10001的张三”时,c库中存储“学号为10001”的索引信息,但数据内容不是“张三”,则生成存储“学号为10001的张三”的临时物理空间地址与关键字“学号为10001”的对应关系,存储在r数据库的物理空间地址关系表中。For example, if "Zhang San with the student number 10001" is written in the r database, the index information of "study number 10001" is stored in the c library, but the data content is not "Zhang San", then the storage "student number is The correspondence between the temporary physical space address of the "three" of 10001 and the keyword "study number 10001" is stored in the physical space address relationship table of the r database.
参考15,图15为内存数据库的数据处理装置第五实施例的功能模块示意图。Referring to FIG. 15, FIG. 15 is a schematic diagram of functional modules of a fifth embodiment of a data processing apparatus of an in-memory database.
在装置第一至第四实施例任一个的基础上,所述装置还包括:On the basis of any one of the first to fourth embodiments of the device, the device further includes:
第三判断单元1601,设置成在修改所述第一数据库的第一数据的情况下,判断所述内存数据库是否存在优化;The third determining unit 1601 is configured to determine, if the first data of the first database is modified, whether the memory database has an optimization;
比如,若修改r数据库的“学号为10003的王五”时,判断是否需要优化所述内存数据库。For example, if the "K5 of the student number 10003" of the r database is modified, it is judged whether it is necessary to optimize the in-memory database.
第二获取单元1602,设置成若所述第三判断单元的判断结果为所述内存数据库存在优化,则获取所述第一数据的标识;The second obtaining unit 1602 is configured to acquire an identifier of the first data if the result of the determining by the third determining unit is that the in-memory database is optimized;
比如,若所述内存数据库存在优化,则获取所述r数据库的数据内容“学号为10003的王五”的标识。For example, if there is optimization in the in-memory database, the identifier of the data content of the r database "Wang 5 with the student number 10003" is obtained.
第一修改单元1603,设置成若所述第一数据的标识为合并标识,则将所述合并标识修改为所述第一数据库的标识;The first modifying unit 1603 is configured to: if the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database;
比如,若所述“学号为10003的王五”的标识为rc标识,则将所述rc标识修改为r标识。For example, if the identifier of the "Wang 5 with the student number 10003" is the rc identifier, the rc identifier is modified to the r identifier.
第二创建单元1604,设置成创建新的物理空间,将所述第一数据的数据内容写入所述新的物理空间,并在所述新的物理空间中设置所述第二数据库的标识,生成所述第一数据中的关键字与所述新的物理空间地址之间的对应关系,更新所述第二数据库的索引信息;a second creating unit 1604, configured to create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space, Generating a correspondence between a keyword in the first data and the new physical space address, and updating index information of the second database;
比如,创建新的物理空间,将所述“学号为10003的王五”写入所述新的物理空间,并在所述新的物理空间地址中设置c数据库的标识,并生成关键字“学号为10003”与所述新的物理空间地址的对应关系,存储在所述c数据库的索引信息中。 For example, creating a new physical space, writing the "King of 10003" to the new physical space, and setting the identifier of the c database in the new physical space address, and generating a keyword " The correspondence between the student number 10003" and the new physical space address is stored in the index information of the c database.
存储单元1605,设置成创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;The storage unit 1605 is configured to create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
比如,若需要将存储在r数据库中的“学号为10003的王五”修改为“学号为10003的王六”或“学号为10009的王五”,则将“学号为10003的王六”或“学号为10009的王五”存储在新的临时物理空间中。For example, if you need to change the "Wang 5 with the student number 10003" stored in the r database to "Wang 6 with the student number 10003" or "Wang 5 with the student number 10009", then the student number is 10003. Wang Liu” or “Wang Wu with the student number 10009” is stored in the new temporary physical space.
第四生成单元1606,设置成当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,则将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据的在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的第一数据的修改数据。The fourth generating unit 1606 is configured to determine, when the keyword in the first data is modified, whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, And modifying the modified data of the first data into the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and the first data Corresponding relationship between physical space addresses in the first database, updating index information of the first database; deleting modification data of the first data stored in the new temporary physical space.
比如需要将存储在r数据库中的“学号为10003的王五”修改为“学号为10009的王五”,先检查r数据库中“学号10009”是否已被占用,如果没有,则修改数据的关键字和r数据库的索引信息匹配,将“学号为10009的王五”写入“学号为10003的王五”所在的物理空间,更新r数据库的索引信息,包括:将r数据库的索引信息中“学号10001”与物理空间地址的对应关系,更新为“学号10009”和物理空间地址的对应关系。For example, you need to change the "Wang 5 with the student number 10003" stored in the r database to "Wang 5 with the student number 10009". First check whether the "student number 10009" in the r database is occupied. If not, modify it. The keyword of the data matches the index information of the r database, and the "King of the school number 10009" is written into the physical space where the "King of the Academy number 10003" is located, and the index information of the r database is updated, including: the r database The correspondence between "student number 10001" and the physical space address in the index information is updated to the correspondence between "student number 10009" and the physical space address.
在不修改第一数据的关键字的情况下,比如需要将存储在r数据库中的“学号为10003的王五”的数据内容修改为“学号为10003的王六”,则将“学号为10003的王六”写入所述“学号为10003的王五”所在的物理空间。In the case of not modifying the keyword of the first data, for example, if the data content of the "King No. 10003" stored in the r database needs to be modified to "Wang 6 with the student number 10003", then "learning" Wang 6, numbered 10003, is written in the physical space where the "King of the Academy number 10003" is located.
参考16,图16为内存数据库的数据处理装置第六实施例的功能模块示意图。Referring to FIG. 16, FIG. 16 is a schematic diagram of functional blocks of a sixth embodiment of a data processing apparatus of an in-memory database.
在装置第五实施例的基础上,所述装置还包括:On the basis of the fifth embodiment of the device, the device further includes:
返回单元1701,设置成若所述第一数据的标识为所述第二数据库标识,则返回修改所述第一数据失败的信息;The returning unit 1701 is configured to: if the identifier of the first data is the second database identifier, return information that fails to modify the first data;
第三创建单元1702,设置成若所述第一数据的标识为所述第一数据库的标识,则创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中; The third creating unit 1702 is configured to: if the identifier of the first data is the identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical In space
第五生成单元1703,设置成当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,则将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。The fifth generating unit 1703 is configured to determine, when the keyword in the first data is modified, whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, And modifying the modified data of the first data into the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and the first data in the Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
比如需要将存储在r数据库中的“学号为10003的王五”修改为“学号为10009的王五”,若r数据库中存储的“学号为10003的王五”为c数据库的标识,则返回修改所述r数据库失败的信息。若r数据库存储的“学号为10003的王五”为r数据库的标识,则创建新的临时物理空间,将“学号为10009的王五”存储在新的临时物理空间中。判断r数据库中是否存储“学号为10009”的索引信息,若未存储(即:关键字与r数据库匹配),则将“学号为10009的王五”写入“学号为10003的王五”在所述r数据库中的物理空间中,并生成关键字“学号为10009”和“学号为10009的王五”之间的对应关系,更新r数据库的索引信息,删掉新的临时物理空间中的“学号为10009的王五”。。For example, you need to change the "Wangwu with the student number 10003" stored in the r database to "Wangwu with the student number 10009". If the "King of the school number 10003" stored in the r database is the identifier of the c database. , return the information that failed to modify the r database. If the "K5 of the student number 10003" stored in the r database is the identifier of the r database, a new temporary physical space is created, and the "King 5 with the student number 10009" is stored in the new temporary physical space. Determine whether the index information of "study number 10009" is stored in the r database. If it is not stored (ie, the keyword matches the r database), the "king five with the student number 10009" is written in "the king with the student number 10003". Five" in the physical space in the r database, and generate a correspondence between the keyword "study number 10009" and "king five with the student number 10009", update the index information of the r database, delete the new The "King of the Academy number 10009" in the temporary physical space. .
在不修改第一数据的关键字的情况下,比如需要将存储在r数据库中的“学号为10003的王五”修改为“学号为10003的王六”,则将“学号为10003的王六”写入所述“学号为10003的王五”所在的物理空间。In the case of not modifying the keyword of the first data, for example, if the "Wang 5 with the student number 10003" stored in the r database needs to be modified to "Wang 6 with the student number 10003", then the student number is 10003. The "Wang Liu" is written in the physical space where the "King Wu with the student number 10003" is located.
参考17,图17为内存数据库的数据处理装置第七实施例的功能模块示意图。Reference 17, which is a functional block diagram of a seventh embodiment of a data processing apparatus of an in-memory database.
在装置第六实施例的基础上,所述装置还包括:On the basis of the sixth embodiment of the device, the device further includes:
第四判断单元1801,设置成在删除所述新的临时物理空间存储的所述第一数据的修改数据之后,判断所述第一数据的修改数据在所述第二数据库中是否存在相同的数据内容;The fourth determining unit 1801 is configured to determine, after deleting the modified data of the first data stored in the new temporary physical space, whether the modified data of the first data has the same data in the second database. content;
第六生成单元1802,设置成若所述第四判断单元的判断结果为存在相同的数据内容,则删除所述第二数据库中的相同的数据内容,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间 地址之间的对应关系,更新所述第二数据库的索引信息中,将所述第一数据的修改数据的数据内容的标识设置为合并标识。The sixth generating unit 1802 is configured to delete the same data content in the second database and generate the modified data of the first data if the determination result of the fourth determining unit is that the same data content exists. Keyword and physical space of the first data in the first database Corresponding relationship between the addresses, updating the index information of the second database, setting an identifier of the data content of the modified data of the first data as a merge identifier.
比如,若所述内存数据库存在优化,判断修改数据“学号为10003的王六”在c数据库中是否存储相同的数据内容,若是,则删除c数据库的数据内容,并生成“学号为10003的王六”存储在r数据库中的物理空间地址和“学号为10003的王六”之间的对应关系,更新c数据库的索引关系,并将r数据库中所述“学号为10003的王六”的标识设置为合并标识,删除所述新的临时物理空间存储的“学号为10003的王六”。For example, if there is optimization in the in-memory database, it is judged whether the modified data "Wang 6 with the student number 10003" stores the same data content in the c database, and if so, the data content of the c database is deleted, and the "student number is 10003" is generated. "Wang Liu" stores the correspondence between the physical space address in the r database and the "Wang Six" with the student number 10003, updates the index relationship of the c database, and the "King of 10003" in the r database The identifier of the six" is set to merge the identifier, and the "king six of the student number 10003" of the new temporary physical space storage is deleted.
参考18,图18为内存数据库的数据处理装置第八实施例的功能模块示意图。Referring to FIG. 18, FIG. 18 is a schematic diagram of functional blocks of an eighth embodiment of a data processing apparatus of an in-memory database.
在装置第一至第四实施例中任一个的基础上,所述装置还包括:On the basis of any one of the first to fourth embodiments of the device, the device further includes:
第五判断单元2001,设置成在删除所述第一数据库的第二数据的情况下,判断所述内存数据库是否存在优化(即是否存在rcflag字段);The fifth determining unit 2001 is configured to determine, if the second data of the first database is deleted, whether the memory database has an optimization (ie, whether an rcflag field exists);
比如,假设需要删除r数据库的“学号为10006的张六”的情况下,判断所述内存数据库是否存在优化。For example, if it is necessary to delete the "six-six" of the r database of the r database, it is judged whether there is optimization in the in-memory database.
第二修改单元2002,设置成若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述合并标识,则将所述第二数据的标识修改为所述第二数据库的标识;The second modifying unit 2002 is configured to modify the identifier of the second data to be determined if the result of the determining by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the merge identifier The identifier of the second database;
比如,若所述内存数据库存在优化且所述“学号为10006的张六”的标识为rc标,则将所述“学号为10006的张六”修改为c标识。For example, if the in-memory database is optimized and the identifier of the "six-six" with the student number 10006 is the rc flag, the "six-six" with the student number 10006 is modified to the c-identification.
第三删除单元2003,设置成删除所述第一数据库的和所述第二数据有关的索引信息。The third deleting unit 2003 is configured to delete the index information related to the second data of the first database.
比如,删除r数据库的索引信息中,关键字“学号为10006”与所述“学号为10006的张六”的物理空间地址之间的对应关系。For example, in the index information of the r database, the correspondence between the keyword "student number 10006" and the physical space address of the "study number 10006" is deleted.
参考19,图19为内存数据库的数据处理装置第九实施例的功能模块示意图。Referring to FIG. 19, FIG. 19 is a schematic diagram of functional blocks of a ninth embodiment of a data processing apparatus of an in-memory database.
在装置第九实施例的基础上,所述第三删除单元2101,还设置成:On the basis of the ninth embodiment of the device, the third deleting unit 2101 is further configured to:
若所述第五判断单元2001的判断结果是所述内存数据库不存在优化,则 删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the result of the determination by the fifth determining unit 2001 is that the in-memory database does not have an optimization, then Deleting the second data in the first database, and deleting index information related to the second data of the first database;
比如,若所述内存数据库不存在优化,则直接删除r数据库中的“学号为10006的张六”,并删除r数据库的索引信息中,关键字“学号为10006”与所述“学号为10006的张六”的物理空间地址之间的对应关系。For example, if there is no optimization in the in-memory database, the "study number 10006" in the r database is directly deleted, and the index information of the r database is deleted, and the keyword "student number is 10006" and the "learning" The correspondence between the physical space addresses of the number 6 of Zhang Liu.
若所述第五判断单元2001的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述第一数据库的标识,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the result of the determination by the fifth determining unit 2001 is that the in-memory database is optimized and the identifier of the second data is the identifier of the first database, deleting the second data in the first database, and deleting Index information related to the second data of the first database;
比如,若所述“学号为10006的张六”的标识为r,则删除所述r数据库中的“学号为10006的张六”,并删除所述r数据库的索引信息中中,关键字“学号为10006”与所述“学号为10006的张六”的物理空间地址之间的对应关系。For example, if the identifier of the "six-six with the student number 10006" is r, delete the "six-six number of the student number 10006" in the r database, and delete the index information of the r database, the key The correspondence between the word "study number 10006" and the physical space address of the "study number 10006".
若所述第五判断单元2001的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述第二数据库的标识,则返回删除失败的信息。If the result of the determination by the fifth determining unit 2001 is that the in-memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
比如,若所述“学号为10006的张六”的标识为c,则返回删除所述“学号为10006的张六”失败的信息。For example, if the identifier of the "six-six with the student number 10006" is c, then the information that the "six-six number of the student number 10006" fails is returned.
参考20,图20为内存数据库的数据处理装置第十实施例的功能模块示意图。Referring to FIG. 20, FIG. 20 is a schematic diagram of functional modules of a tenth embodiment of a data processing apparatus of an in-memory database.
在装置第一至第四实施例中任一个的基础上,所述装置还包括查找单元2201,所述查找单元2201设置成:On the basis of any one of the first to fourth embodiments of the apparatus, the apparatus further includes a searching unit 2201, and the searching unit 2201 is configured to:
在查找所述第一数据库的记录的情况下,将游标移到第一记录;In the case of finding the record of the first database, moving the cursor to the first record;
比如,在查找r数据库的记录的情况下,先将游标移到第一记录。For example, in the case of finding a record of the r database, the cursor is first moved to the first record.
若所述第一记录的标识为所述第一数据库的标识或者合并标识,则发送所述第一记录的信息;Sending information of the first record if the identifier of the first record is an identifier of the first database or a merge identifier;
比如,若所述第一记录的标识为r数据库的标识或者rc标识,则发送所述第一记录的信息。For example, if the identifier of the first record is an identifier of the r database or an rc identifier, the information of the first record is sent.
若所述第一记录的标识为所述第二数据库的标识,则将游标移到下一个记录。 If the identifier of the first record is the identifier of the second database, the cursor is moved to the next record.
比如,若所述第一记录的标识为c数据库的标识,则将游标移到下一个记录。For example, if the identifier of the first record is the identifier of the c database, the cursor is moved to the next record.
工业实用性Industrial applicability
本发明实施例中,在向一个数据库插入新数据时,如果所述新数据在另一个数据库中已存在相同的数据内容,则只为该数据内容设置合并标识,而不新增数据,这样能够减少数据本身占用的空间;而且使得两个数据模型定义相同的内存数据库可以只保留一个,也减少了数据模型定义占用的空间,达到了减少内存数据库占用空间的目的。另外,对于是否需要/存在内存优化采用不同处理方式,可以兼容多个不同的项目。 In the embodiment of the present invention, when new data is inserted into a database, if the new data already has the same data content in another database, only the merge identifier is set for the data content, and no new data is added. Reduce the space occupied by the data itself; and make the two memory models define the same in-memory database to retain only one, which also reduces the space occupied by the data model definition, and achieves the purpose of reducing the space occupied by the in-memory database. In addition, different processing methods are available for whether or not there is a need for memory optimization, and it is compatible with a plurality of different projects.

Claims (22)

  1. 一种内存数据库的数据处理方法,包括:A data processing method for an in-memory database, comprising:
    在第一数据库中插入新数据时,创建临时物理空间;Create a temporary physical space when inserting new data in the first database;
    若所述内存数据库需要优化,则在所述临时物理空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;If the in-memory database needs to be optimized, setting an identifier of the first database in the temporary physical space, and writing the new data into the temporary physical space;
    若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,且所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容相同,则删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识;If the keywords in the new data match the index information of the first database and the index information of the second database, and the data content of the new data stored in the temporary physical space and the new data If the data content of the second database corresponding to the keyword in the same is the same, deleting the new data stored in the temporary physical space, and storing the data corresponding to the keyword in the new data stored in the second database The identity of the content is set to the merged identity;
    生成所述新数据中的关键字和所述第二数据库中存储的与所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。Generating a correspondence between a keyword in the new data and a physical space address of the data content corresponding to the keyword in the new data stored in the second database, and storing an index in the first database Information.
  2. 根据权利要求1所述的方法,其中,删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识之前,还包括:The method according to claim 1, wherein the new data stored in the temporary physical space is deleted, and an identifier of the data content corresponding to the keyword in the new data stored in the second database is set as a merge Before the logo, it also includes:
    获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;Obtaining a keyword in the new data, and matching the index information of the first database and the index information of the second database;
    若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的所述新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容是否相同;If the keywords in the new data match the index information of the first database and the index information of the second database, determine the data content and the content of the new data stored in the temporary physical space. Whether the data content of the second database corresponding to the keyword in the new data is the same;
    若相同,则执行删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识的步骤。If the same is the same, the step of deleting the new data stored in the temporary physical space and setting the identifier of the data content corresponding to the keyword in the new data stored in the second database as a merged identifier is performed.
  3. 根据权利要求1所述的方法,其中,所述在第一数据库中插入新数据时,创建临时物理空间之后,还包括:The method according to claim 1, wherein after the new data is inserted in the first database, after the temporary physical space is created, the method further includes:
    判断所述内存数据库是否需要优化; Determining whether the in-memory database needs to be optimized;
    若所述内存数据库不需要优化,则将所述新数据写入所述临时物理空间,获取所述新数据中的关键字,和所述第一数据库的索引信息进行匹配;若匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,返回插入成功的信息;若不匹配,则删除所述临时物理空间存储的所述新数据,返回插入失败的信息。If the in-memory database does not need to be optimized, the new data is written into the temporary physical space, the keywords in the new data are acquired, and the index information of the first database is matched; if matched, the generated The correspondence between the keyword in the new data and the temporary physical space address is saved in the index information of the first database, and the information of the successful insertion is returned; if not, the temporary physical space is deleted. The stored new data returns information that the insertion failed.
  4. 根据权利要求2所述的方法,其中,获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配之后,还包括:The method of claim 2, wherein after the keyword in the new data is acquired and matched with the index information of the first database and the index information of the second database, the method further includes:
    若所述新数据中的关键字与所述第一数据库的索引信息不匹配,则删除所述临时物理空间存储的所述新数据,并且返回插入失败的信息;If the keyword in the new data does not match the index information of the first database, deleting the new data stored in the temporary physical space, and returning information that the insertion fails;
    若所述新数据中的关键字与所述第一数据库的索引信息匹配,但与所述第二数据库的索引信息不匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。If the keyword in the new data matches the index information of the first database but does not match the index information of the second database, generating a keyword in the new data and the temporary physical space address The correspondence between the two is stored in the index information of the first database.
  5. 根据权利要求2所述的方法,其中,判断所述临时物理空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容是否相同之后,还包括:The method according to claim 2, wherein after determining whether the data content of the new data stored in the temporary physical space and the data content in the second database corresponding to the keywords in the new data are the same, :
    若所述临时物理空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容不相同,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库索引信息中。Generating a keyword in the new data and the temporary if the data content of the new data stored in the temporary physical space is different from the data content in the second database corresponding to the keyword in the new data Corresponding relationships between physical space addresses are stored in the first database index information.
  6. 根据权利要求1至5任意一项所述的方法,还包括:The method of any one of claims 1 to 5, further comprising:
    在修改所述第一数据库的第一数据时,判断所述内存数据库是否存在优化;When modifying the first data of the first database, determining whether the in-memory database has an optimization;
    若所述内存数据库存在优化,则获取所述第一数据的标识;Obtaining an identifier of the first data if the in-memory database is optimized;
    若所述第一数据的标识为合并标识,则将所述合并标识修改为所述第一数据库的标识;If the identifier of the first data is a merge identifier, modifying the merge identifier to an identifier of the first database;
    创建新的物理空间,将所述第一数据的数据内容写入所述新的物理空间,并在所述新的物理空间中设置所述第二数据库的标识,生成所述第一数据中 的关键字与所述新的物理空间地址之间的对应关系,更新所述第二数据库的索引信息;Creating a new physical space, writing data content of the first data to the new physical space, and setting an identifier of the second database in the new physical space, generating the first data Update the index information of the second database by the correspondence between the keyword and the new physical space address;
    创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;Creating a new temporary physical space, and storing the modified data of the first data in the new temporary physical space;
    当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息,删除所述新的临时物理空间存储的所述第一数据的修改数据。When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the index information of the first database is updated, and the modified data of the first data stored in the new temporary physical space is deleted.
  7. 根据权利要求6所述的方法,其中,获取所述第一数据的标识之后,还包括:The method of claim 6, wherein after obtaining the identifier of the first data, the method further comprises:
    若所述第一数据的标识为所述第二数据库的标识,则返回修改所述第一数据失败的信息;If the identifier of the first data is the identifier of the second database, returning information that fails to modify the first data;
    若所述第一数据的标识为所述第一数据库的标识,则创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;If the identifier of the first data is the identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
    当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。When the keyword in the first data is modified, determining whether the keyword in the modified data of the first data matches the index information of the first database, and if yes, modifying the first data Writing data to the physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a physical space address of the first data in the first database Corresponding relationship between the first database, and the modification data of the first data stored in the new temporary physical space.
  8. 根据权利要求7所述的方法,其中,在所述删除所述新的临时物理空间存储的所述第一数据的修改数据之后,还包括:The method according to claim 7, wherein after the deleting the modified data of the first data stored in the new temporary physical space, the method further comprises:
    判断所述第一数据的修改数据在所述第二数据库中是否存在相同的数据内容;Determining whether the modified data of the first data has the same data content in the second database;
    若存在相同的数据内容,则删除所述第二数据库中的相同的数据内容,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据 库中的物理空间地址之间的对应关系,更新所述第二数据库的索引信息,将所述第一数据的修改数据的数据内容的标识设置为合并标识。If the same data content exists, deleting the same data content in the second database, and generating a keyword in the modified data of the first data and the first data in the first data Corresponding relationship between physical space addresses in the library, updating index information of the second database, and setting an identifier of the data content of the modified data of the first data as a merge identifier.
  9. 根据权利要求1至5任意一项所述的方法,还包括:The method of any one of claims 1 to 5, further comprising:
    在删除所述第一数据库的第二数据时,判断所述内存数据库是否存在优化;Determining whether the in-memory database has an optimization when deleting the second data of the first database;
    若所述内存数据库存在优化且所述第二数据的标识为所述合并标识,则将所述第二数据的标识修改为所述第二数据库的标识;And if the identifier of the second data is optimized, and the identifier of the second data is the merge identifier, the identifier of the second data is modified to an identifier of the second database;
    删除所述第一数据库的和所述第二数据有关的索引信息。The index information related to the second data of the first database is deleted.
  10. 根据权利要求9所述的方法,还包括:The method of claim 9 further comprising:
    在删除所述第一数据库的第二数据时,若所述内存数据库不存在优化,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;When the second data of the first database is deleted, if there is no optimization in the in-memory database, deleting the second data in the first database, and deleting the first database is related to the second data Index information;
    若所述内存数据库存在优化且所述第二数据的标识为所述第一数据库的标识,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the in-memory database is optimized and the identifier of the second data is an identifier of the first database, deleting the second data in the first database, and deleting the first database and the second data Index information about the data;
    若所述内存数据库存在优化且所述第二数据的标识为所述第二数据库的标识,则返回删除失败的信息。If the in-memory database is optimized and the identifier of the second data is an identifier of the second database, the information that the deletion fails is returned.
  11. 根据权利要求1至5任意一项所述的方法,还包括:The method of any one of claims 1 to 5, further comprising:
    在查找所述第一数据库的记录时,将游标移到第一记录;Moving the cursor to the first record when looking up the record of the first database;
    若所述第一记录的标识为所述第一数据库的标识或者合并标识,则发送所述第一记录的信息;Sending information of the first record if the identifier of the first record is an identifier of the first database or a merge identifier;
    若所述第一记录的标识为所述第二数据库的标识,则将游标移到下一个记录。If the identifier of the first record is the identifier of the second database, the cursor is moved to the next record.
  12. 一种内存数据库的数据处理装置,包括:A data processing device for an in-memory database, comprising:
    第一创建单元,设置成在第一数据库中插入新数据时,创建临时物理空间;a first creating unit, configured to create a temporary physical space when inserting new data in the first database;
    第一设置单元,设置成若所述内存数据库需要优化,则在所述临时物理 空间设置所述第一数据库的标识,并将所述新数据写入所述临时物理空间;a first setting unit, configured to: if the in-memory database needs to be optimized, in the temporary physics Setting an identifier of the first database and writing the new data to the temporary physical space;
    第一删除单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,且所述临时物理空间存储的新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容相同,则删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识;a first deleting unit, configured to: if the keyword in the new data matches the index information of the first database and the index information of the second database, and the data of the new data stored in the temporary physical space And the content is the same as the data content of the second database corresponding to the keyword in the new data, deleting the new data stored in the temporary physical space, and storing the new data in the second database The identifier of the data content corresponding to the keyword in the keyword is set as the merge identifier;
    第一生成单元,设置成生成所述新数据中的关键字与所述第二数据库中存储所述新数据中的关键字对应的数据内容的物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。a first generating unit configured to generate a correspondence between a keyword in the new data and a physical space address of a data content corresponding to a keyword stored in the second data in the second database, and save the The index information of the first database.
  13. 根据权利要求12所述的装置,还包括:The apparatus of claim 12, further comprising:
    第一获取单元,设置成获取所述新数据中的关键字,并和所述第一数据库的索引信息以及第二数据库的索引信息进行匹配;a first acquiring unit, configured to acquire a keyword in the new data, and match the index information of the first database and the index information of the second database;
    第一判断单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息以及与所述第二数据库的索引信息均匹配,则判断所述临时物理空间存储的所述新数据的数据内容和与所述新数据中的关键字对应的所述第二数据库的数据内容是否相同;a first determining unit, configured to determine, if the keyword in the new data matches the index information of the first database and the index information of the second database, the new storage in the temporary physical space Whether the data content of the data is the same as the data content of the second database corresponding to the keyword in the new data;
    所述第一删除单元当所述第一判断单元的判断结果为相同时,执行所述删除所述临时物理空间存储的所述新数据,将所述第二数据库存储的与所述新数据中的关键字对应的数据内容的标识设置为合并标识的操作。The first deleting unit performs the deleting the new data stored in the temporary physical space when the determination result of the first determining unit is the same, and storing the new data in the second database. The identifier of the data content corresponding to the keyword is set to the operation of merging the identifier.
  14. 根据权利要求12所述的装置,还包括:The apparatus of claim 12, further comprising:
    第二判断单元,设置成在所述第一设置单元在第一数据库中插入新数据时,创建临时物理空间之后判断所述内存数据库是否需要优化;a second determining unit, configured to determine whether the in-memory database needs to be optimized after the temporary physical space is created when the first setting unit inserts new data in the first database;
    写入单元,设置成在所述第二判断单元的判断结果为所述内存数据库不需要优化的情况下,将所述新数据写入所述临时物理空间;获取所述新数据中的关键字,和所述第一数据库的索引信息进行匹配;若匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中,返回插入成功的信息;若不匹配,则删除所述临时物理空间存储的所述新数据,返回插入失败的信息。 a writing unit, configured to write the new data into the temporary physical space if the judgment result of the second determining unit is that the in-memory database does not need to be optimized; and acquire a keyword in the new data And matching the index information of the first database; if matching, generating a correspondence between the keyword in the new data and the temporary physical space address, and saving in the index information of the first database Returning the information of the successful insertion; if not, deleting the new data stored in the temporary physical space, and returning the information of the insertion failure.
  15. 根据权利要求13所述的装置,还包括:The apparatus of claim 13 further comprising:
    第二删除单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息不匹配,则删除所述临时物理空间存储的所述新数据,并且返回插入失败的信息;a second deleting unit, configured to delete the new data stored in the temporary physical space if the keyword in the new data does not match the index information of the first database, and return information that the insertion fails;
    第二生成单元,设置成若所述新数据中的关键字与所述第一数据库的索引信息匹配,但与所述第二数据库的索引信息不匹配,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。a second generating unit, configured to generate a keyword in the new data if the keyword in the new data matches the index information of the first database but does not match the index information of the second database The correspondence relationship with the temporary physical space address is stored in the index information of the first database.
  16. 根据权利要求12所述的装置,还包括:The apparatus of claim 12, further comprising:
    第三生成单元,设置成若所述第二判断单元的判断结果为所述临时物理空间存储的新数据的数据内容和所述第二数据库中与所述新数据中的关键字对应的数据内容不相同,则生成所述新数据中的关键字与所述临时物理空间地址之间的对应关系,保存在所述第一数据库的索引信息中。a third generating unit, configured to: if the determination result of the second determining unit is the data content of the new data stored in the temporary physical space and the data content corresponding to the keyword in the new data in the second database If not, the correspondence between the keyword in the new data and the temporary physical space address is generated and stored in the index information of the first database.
  17. 根据权利要求12至16任意一项所述的装置,还包括:The apparatus according to any one of claims 12 to 16, further comprising:
    第三判断单元,设置成在修改所述第一数据库的第一数据时,判断所述内存数据库是否存在优化;a third determining unit, configured to determine whether the memory database exists to be optimized when the first data of the first database is modified;
    第二获取单元,设置成若所述第三判断单元的判断结果为所述内存数据库存在优化,则获取所述第一数据的标识;a second obtaining unit, configured to acquire an identifier of the first data if a result of the determining by the third determining unit is that the in-memory database is optimized;
    第一修改单元,设置成若所述第一数据的标识为合并标识,则将所述合并标识修改为所述第一数据库的标识;a first modifying unit, configured to: if the identifier of the first data is a merge identifier, modify the merge identifier to an identifier of the first database;
    第二创建单元,设置成创建新的物理空间,将所述第一数据的数据内容写入所述新的物理空间,并在所述新的物理空间中设置所述第二数据库的标识,生成所述第一数据中的关键字与所述新的物理空间地址之间的对应关系,更新所述第二数据库的索引信息;a second creating unit, configured to create a new physical space, write data content of the first data into the new physical space, and set an identifier of the second database in the new physical space to generate Updating a mapping relationship between the keyword in the first data and the new physical space address, and updating index information of the second database;
    存储单元,设置成创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;a storage unit, configured to create a new temporary physical space, and store the modified data of the first data in the new temporary physical space;
    第四生成单元,设置成当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若 匹配,则将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据的在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。a fourth generating unit, configured to determine, when the keyword in the first data is modified, whether the keyword in the modified data of the first data matches the index information of the first database, if Matching, the modified data of the first data is written into a physical space of the first data in the first database, and a keyword and a first data in the modified data of the first data are generated. And updating the index information of the first database in the corresponding relationship between the physical space addresses in the first database; and deleting the modified data of the first data stored in the new temporary physical space.
  18. 根据权利要求17所述的装置,还包括:The apparatus of claim 17 further comprising:
    返回单元,设置成若所述第一数据的标识为所述第二数据库的标识,则返回修改所述第一数据失败的信息;Returning to the unit, if the identifier of the first data is the identifier of the second database, returning information that fails to modify the first data;
    第三创建单元,设置成若所述第一数据的标识为所述第一数据库的标识,则创建新的临时物理空间,将所述第一数据的修改数据存储在所述新的临时物理空间中;a third creating unit, configured to: if the identifier of the first data is an identifier of the first database, create a new temporary physical space, and store the modified data of the first data in the new temporary physical space in;
    第五生成单元,设置成当所述第一数据中的关键字被修改时,判断所述第一数据的修改数据中的关键字与所述第一数据库的索引信息是否匹配,若匹配,则将所述第一数据的修改数据写入所述第一数据在所述第一数据库中的物理空间,并生成所述第一数据的修改数据中的关键字与所述第一数据的在所述第一数据库中的物理空间地址之间的对应关系,更新所述第一数据库的索引信息;删除所述新的临时物理空间存储的所述第一数据的修改数据。a fifth generating unit, configured to determine, when the keyword in the first data is modified, whether a keyword in the modified data of the first data matches an index information of the first database, and if yes, Transmitting the modified data of the first data into a physical space of the first data in the first database, and generating a keyword in the modified data of the first data and a location of the first data Determining a correspondence between physical space addresses in the first database, updating index information of the first database; and deleting modification data of the first data stored in the new temporary physical space.
  19. 根据权利要求18所述的装置,还包括:The apparatus of claim 18, further comprising:
    第四判断单元,设置成在删除所述新的临时物理空间存储的所述第一数据的修改数据之后,判断所述第一数据的修改数据在所述第二数据库中是否存在相同的数据内容;a fourth determining unit, configured to determine, after deleting the modified data of the first data stored in the new temporary physical space, whether the modified data of the first data has the same data content in the second database ;
    第六生成单元,设置成若所述第四判断单元的判断结果为存在相同的数据内容,则删除所述第二数据库中的相同的数据内容,并生成所述第一数据的修改数据中的关键字与所述第一数据在所述第一数据库中的物理空间地址之间的对应关系,更新所述第二数据库的索引信息中,将所述第一数据的修改数据的数据内容的标识设置为合并标识。a sixth generating unit, configured to delete the same data content in the second database and generate the modified data in the first data if the determination result of the fourth determining unit is that the same data content exists Updating the correspondence between the keyword and the physical space address of the first data in the first database, updating the index information of the second database, and identifying the data content of the modified data of the first data Set to merge ID.
  20. 根据权利要求12至16任意一项所述的装置,还包括:The apparatus according to any one of claims 12 to 16, further comprising:
    第五判断单元,设置成在删除所述第一数据库的第二数据时,判断所述内存数据库是否存在优化; a fifth determining unit, configured to determine whether the memory database has an optimization when deleting the second data of the first database;
    第二修改单元,设置成若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述合并标识,则将所述第二数据的标识修改为所述第二数据库的标识;a second modifying unit, configured to: if the result of the determining by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the merged identifier, modify the identifier of the second data to Describe the identifier of the second database;
    第三删除单元,设置成删除所述第一数据库的和所述第二数据有关的索引信息。And a third deleting unit, configured to delete the index information related to the second data of the first database.
  21. 根据权利要求20所述的装置,其中,所述第三删除单元还设置成:The apparatus according to claim 20, wherein said third deleting unit is further configured to:
    若所述第五判断单元的判断结果是所述内存数据库不存在优化,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the result of the determination by the fifth determining unit is that the in-memory database does not have an optimization, deleting the second data in the first database, and deleting the index information related to the second data in the first database ;
    若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述第一数据库的标识,则删除所述第一数据库中的第二数据,并删除所述第一数据库的和所述第二数据有关的索引信息;If the result of the determination by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the identifier of the first database, deleting the second data in the first database, and deleting the Index information related to the second data of the first database;
    若所述第五判断单元的判断结果是所述内存数据库存在优化且所述第二数据的标识为所述第二数据库的标识,则返回删除失败的信息。If the result of the determination by the fifth determining unit is that the in-memory database is optimized and the identifier of the second data is the identifier of the second database, the information that the deletion fails is returned.
  22. 根据权利要求12至16任意一项所述的装置,还包括查找单元,所述查找单元设置成:The apparatus according to any one of claims 12 to 16, further comprising a lookup unit configured to:
    在查找所述第一数据库的记录时,将游标移到第一记录;Moving the cursor to the first record when looking up the record of the first database;
    若所述第一记录的标识为所述第一数据库的标识或者合并标识,则发送所述第一记录的信息;Sending information of the first record if the identifier of the first record is an identifier of the first database or a merge identifier;
    若所述第一记录的标识为所述第二数据库的标识,则将游标移到下一个记录。 If the identifier of the first record is the identifier of the second database, the cursor is moved to the next record.
PCT/CN2015/080111 2014-12-26 2015-05-28 Method and device for processing data in memory database WO2016101528A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410837463.3A CN105786939A (en) 2014-12-26 2014-12-26 Memory database optimization method and apparatus
CN201410837463.3 2014-12-26

Publications (1)

Publication Number Publication Date
WO2016101528A1 true WO2016101528A1 (en) 2016-06-30

Family

ID=56149100

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/080111 WO2016101528A1 (en) 2014-12-26 2015-05-28 Method and device for processing data in memory database

Country Status (2)

Country Link
CN (1) CN105786939A (en)
WO (1) WO2016101528A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113748388A (en) * 2019-03-01 2021-12-03 西门子股份公司 Method and apparatus for computer-aided optimization of tool occupancy of library space
CN114003491A (en) * 2021-10-15 2022-02-01 赛轮集团股份有限公司 Test equipment parameter modification method and device, electronic equipment and storage medium

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107145582B (en) * 2017-05-09 2022-01-04 深圳Tcl新技术有限公司 Control method of database cursor and database system
CN107452209A (en) * 2017-07-26 2017-12-08 江苏本能科技有限公司 Radio frequency identification and video identification integration method and system, equipment, storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102024051A (en) * 2010-12-17 2011-04-20 北京世纪互联工程技术服务有限公司 Data updating method for distributed memory database
CN102542054A (en) * 2011-12-29 2012-07-04 厦门雅迅网络股份有限公司 Method utilizing cache tables to improve insertion performance of data in database

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101315628B (en) * 2007-06-01 2011-01-05 华为技术有限公司 Internal memory database system and method and device for implementing internal memory data base
US8966171B2 (en) * 2012-04-16 2015-02-24 Renmin University Of China Access optimization method for main memory database based on page-coloring
CN103309819B (en) * 2013-05-30 2016-06-22 苏州亮智科技有限公司 Embedded system and internal memory method for managing security therein

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102024051A (en) * 2010-12-17 2011-04-20 北京世纪互联工程技术服务有限公司 Data updating method for distributed memory database
CN102542054A (en) * 2011-12-29 2012-07-04 厦门雅迅网络股份有限公司 Method utilizing cache tables to improve insertion performance of data in database

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113748388A (en) * 2019-03-01 2021-12-03 西门子股份公司 Method and apparatus for computer-aided optimization of tool occupancy of library space
CN114003491A (en) * 2021-10-15 2022-02-01 赛轮集团股份有限公司 Test equipment parameter modification method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN105786939A (en) 2016-07-20

Similar Documents

Publication Publication Date Title
US8910044B1 (en) Playlist incorporating tags
CN109766341B (en) Method, device and storage medium for establishing Hash mapping
WO2017201977A1 (en) Data writing and reading method and apparatus, and distributed object storage cluster
US9952783B2 (en) Data processing method and apparatus, and shared storage device
CN109101516B (en) A kind of data query method and server
US20180144061A1 (en) Edge store designs for graph databases
WO2016101528A1 (en) Method and device for processing data in memory database
WO2015110062A1 (en) Distributed data storage method, device and system
WO2016066108A1 (en) Route access method, route access system and user terminal
CN104850565B (en) A kind of metadata management method based on K-V storage systems
JP2013196565A (en) Database processing method, and database processor
CN105373541A (en) Processing method and system for data operation request of database
CN107506484B (en) Operation and maintenance data association auditing method, system, equipment and storage medium
CN103226591B (en) A kind of support multiple key quick access method and device
CN103020262A (en) Data storage method, system and data storage equipment
CN110008738A (en) For the caching method of block chain contract data, device, medium and calculate equipment
WO2016086695A1 (en) Multipath device naming method, device, host and communication system
JP2018028905A5 (en)
WO2023202394A1 (en) Partition table creation method and apparatus, data writing method and apparatus for partition table, and data reading method and apparatus for partition table
CN109871338B (en) Data storage method and device and computer equipment
KR101588375B1 (en) Method and system for managing database
JP2018526740A5 (en)
US20180144060A1 (en) Processing deleted edges in graph databases
US20160154812A1 (en) Hybrid database management system
WO2018000785A1 (en) Method for remote file access, server, client terminal, and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15871604

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15871604

Country of ref document: EP

Kind code of ref document: A1