Background technology
Along with the continuous progress of science and technology, application of IC cards has become an indispensable part in people's life gradually.And along with the continuous popularization of application of IC cards with popularize, people are also more and more diversified to the functional requirement of smart card.
The development of smart card hardware technology is maked rapid progress, the continuous maturation of the Chip Operating System of smart card and perfect, make and to be applied to the smart card operating system that extended to that database technology on the traditional computer followed a well mapped-out plan, for better abundanter mobile data service provides a brand-new implementation platform, and data searching technology then is one of core in the database technology.
In the database retrieval technology of current popular, mainly comprise two classes: binary tree index (BTreeIndex) and bitmap index (Bitmap Index, BMI).Bitmap index mainly is used on line data analysis aspect, and data warehouse aspect just, purpose are to be to save storage space accelerating inquiry velocity.Generally, index all will expend bigger storage space, and bitmap has adopted compress technique to realize the disk space reduction.The binary tree index is used in high radix (promptly Lie data distinctiveness ratio is big) more, and bitmap is used in low radix row more.So search methods that adopt bitmap index when data are comparatively sparse more.
In the bitmap index structure of data warehouse, each the value v in the Attribute domain has a different bit vector Bv.If given Attribute domain comprises n value, then in the bitmap index every need the n position, i.e. n bit vector.If the property value of given row is v in the tables of data, then in the corresponding row of bitmap index, represent that the position of this value is 1, other position of this row is 0.
As shown in table 1, the value of each Attribute domain of bitmap index can represent that this vector is a bitmap with 0 and 1 vector of unit length.The line number of bitmap equates (promptly equaling to write down number) with the line number of table, the position in the bitmap is corresponding one by one with the row in showing.Attribute Value has two optional values in the table 1, i.e. A and B, A and B all can usefulness 0 as shown in table 2 and 1 vector represent.
Table 1
RecordID |
Value |
R1 |
A |
R2 |
B |
R3 |
B |
R4 |
A |
Table 2
RecordID |
A |
B |
R1 |
1 |
0 |
R2 |
0 |
1 |
R3 |
0 |
1 |
R4 |
1 |
0 |
Mainly carry out binary arithmetic when bitmap index is inquired about, be applicable to multidimensional data table with low radix feature.The radix of attribute A is meant the number of the different value of attribute A, and generally the radix with attribute A is designated as C (A), then the total individual bitmap of C (A) of the bitmap index on the attribute A.Bitmap index on the A is designated as B
A, establishing i is the value of A, B
AIn be designated as B with the corresponding bitmap of i
A iFor example in table 3 Sale (SN, GN, Num, the quantity of searching salesman T sell goods S in Price), then bitmap index can be expressed as B
SN T∧ B
GN S, corresponding those data recording by 1 of bitmap index are to be asked.
Table 3
The literary name section |
SN |
GN |
Num |
Price |
Describe |
Salesman's title |
Name of product |
Sales volume |
Selling price |
As depicted in figs. 1 and 2, prior art is after but the good operation note collection of foundation is target bit string indexing table, determine the target bit string according to index instruction, then whole leading target bit string and many succeeding target bit strings are carried out the vector logic computing, draw at last and carry out condition test after the indexed results and verify promptly whether indexed results meets the requirement of index instruction, if the result is correctly then exported in condition test, finish index operation.
In realizing process of the present invention, the inventor finds existing bitmap indexing method and smart card, and there are the following problems at least:
Existing bitmap computing is that whole leading target bit string and succeeding target bit string are carried out the vector logic computing, draw correlated results then and carry out condition test, need carry out computing in twos to the whole index vector of corresponding attribute, the operational data amount is big, if carry out many-valued or complicated conjunctive query, bitmap index computing committed memory resource can be more, and speed also can be slower.
Summary of the invention
The embodiment of the invention provides a kind of bitmap indexing method, and it is big to have solved existing bitmap indexing method operational data amount, the many technical matterss of bitmap index operation committed memory resource.
For achieving the above object, the embodiment of the invention adopts following technical scheme:
This bitmap indexing method may further comprise the steps:
Limit effective query region of target bit string;
Carry out the bitmap index operation in effective query region of described target bit string;
The concrete steps of effective query region of described qualification target bit string are: create the bitmap index handle according to the index order, and utilize this bitmap index handle to limit the effective query region of each target bit string when operating;
After creating the bitmap index handle, the memory headroom that application and effective query region are complementary;
Effective query region in described target bit string is carried out the bitmap index method of operating, specifically may further comprise the steps:
Read between effective interrogation zone of a target bit string memory headroom of application;
Read effective query region of the target bit string of not operating and the target bit string in the memory headroom one by one and carry out logical operation, and operation result is kept at memory headroom.
Compared with prior art, in the embodiment of the invention in the bitmap index operation of carrying out data retrieval, define effective query region of target bit string earlier, thereby for follow-up index operation provides the bounded access control, only need carry out the bitmap index operation and can obtain Query Result in effective query region of target bit string, and need not carry out the bitmap index operation in whole target bit string, so dwindled actual bitmap index scope, reduced the bitmap index amount of operational data, accelerated the speed of index, so it is big to have solved prior art operational data amount, the many technical matterss of bitmap index operation committed memory resource.
The smart card that the embodiment of the invention provides a kind of bitmap index unit and has been provided with this bitmap index unit, it is big to have solved smart card operating system bitmap index amount of operational data of the prior art, the many technical matterss of bitmap index operation committed memory resource.
For achieving the above object, the embodiment of the invention adopts following technical scheme:
A kind of bitmap index unit comprises:
Limit module, be used to limit effective query region of target bit string;
The index operation module is used for carrying out the bitmap index operation in effective query region of described target bit string;
Described qualification module also comprises creates the handle module, and described establishment handle module can be created the bitmap index handle according to the index order, and utilizes this bitmap index handle to limit the effective query region of each target bit string when operating;
Described qualification module also comprises the application memory modules, behind the establishment handle module creation bitmap index handle, and the memory headroom that the application of described application memory modules and effective query region are complementary;
Described index operation module comprises:
Read module is used to read between effective interrogation zone of a target bit string memory headroom to application;
Computing module is used for reading one by one the effective query region of the target bit string of not operating and the target bit string of memory headroom and carries out logical operation, and operation result is kept at memory headroom.
A kind of smart card comprises the bitmap index unit that the invention described above provides.
Compared with prior art, the bitmap index unit is when the bitmap index operation of carrying out data retrieval in the embodiment of the invention, limit effective query region of target bit string earlier, thereby done the bounded access control for follow-up index operation, only need carry out the bitmap index operation and can obtain Query Result in effective query region of target bit string, and need not carry out the bitmap index operation in whole target bit string, so dwindled actual bitmap index scope, reduced the bitmap index amount of operational data, accelerated the speed of index, so it is big to have solved smart card operating system bitmap index amount of operational data of the prior art, the many technical matterss of bitmap index operation committed memory resource.
Embodiment
The embodiment of the invention provides a kind of bitmap indexing method, and a kind of bitmap index unit, a kind of smart card also are provided.
Embodiments of the present invention is described in detail below in conjunction with accompanying drawing.
The bitmap indexing method that the embodiment of the invention provided, it is big to have solved existing bitmap indexing method operational data amount, the many technical matterss of bitmap index operation committed memory resource.
As shown in Figure 3 and Figure 4, embodiment of the invention bitmap indexing method may further comprise the steps:
Effective query region of S1, qualification target bit string;
S1 specifically may further comprise the steps in the embodiment of the invention:
A00, determine effective query region according to any one or the combination of search condition, record sort, operator's authority, dictionary preface;
A10, create the bitmap index handle, and utilize this bitmap index handle to limit the effective query region of each target bit string when operating according to the index order;
The memory headroom that a20, application and effective query region are complementary, memory headroom is a buffer zone;
The bitmap index handle comprises the upper bound and the lower bound of effective query region, wherein:
The upper bound is used to limit the upper bound of the query region of each target bit string;
Lower bound is used to limit the lower bound of the query region of each target bit string.
The logical organization of the memory headroom that the upper bound, lower bound and application and effective query region are complementary can be as giving a definition:
Struct?BMIContext{
NLowest; // the upper bound
NHighest; // lower bound
BMICTX[]; // buffer zone
};
Certainly, the logical organization of the definition upper bound and lower bound is except adopting the C language, the programming language that also can adopt other for example Fortran, Pascal, Cobol, C++, Basic, Ada, Java, C# etc. is used for definition, the type of the upper bound and lower bound also is not limited to integer (int) in addition, and the type of buffer zone also is not limited to character type (char).
Wherein, but the subclass that the upper bound and lower bound are used for setting on the operation note collection is effective query region of target bit string, if do not carry out special appointment, then defaults to i.e. all the complete target bit strings of record complete or collected works.Certainly, but only to define, create the subclass that the upper bound or lower bound also can be used for setting on the operation note collection be effective query region of target bit string.
The upper bound and lower bound can be adjusted according to the needs of bitmap index operation in the practical application, particularly at raw readings collection orderly in the database, for example: the record set in the database has carried out classification and ordination according to the characteristic of a certain data item, example as the quantity of in base table, searching salesman T sell goods S mentioned in the background technology, if the data recording in the database has been carried out classification and ordination according to sales force's title, in the practical application retrieval, when comprising sales force's title in the search condition, can be directly according to effective query region of sales force's title deterministic retrieval, determine the upper bound and the lower bound of bitmap index handle in view of the above, and count the corresponding memory headroom of application as buffer zone according to the record strip that effective query region comprises.The corresponding size of buffer zone is determined by the upper bound and lower bound, buffer zone on the one hand can be in the bitmap index operating process the current operated target bit string of buffer memory, the number of operations of frequent application memory headroom when reducing each computing, be beneficial to the quickening computing, can preserve the intermediate result of bitmap index operation on the other hand, for the realization of using is the result set search space that calling of index operation result directly provides public.
S2, as shown in Figure 4 carries out the bitmap index operation in effective query region of target bit string, specifically may further comprise the steps:
B10, read between effective interrogation zone of a target bit string memory headroom of application, and compress, specifically may further comprise the steps:
Effective query region of c10, target bit string is compressed:
Whether data recording is 0 entirely for the head of effective query region of c101, inspection target bit string and/or afterbody;
C102, if check that the head and/or the tail data record of effective query region of target bit string are 0 entirely, then the upper bound of effective query region of target bit string and/or lower bound are adjusted to data recording and are 1 position, and the corresponding value of revising the upper bound in the handle and/or lower bound.
Determined after effective query region, can further compress the scope of retrieval, dwindled the target zone of bitmap index operation greatly, improved arithmetic speed.
Certainly, this step can not compressed effective query region of reading in internal memory in reality is implemented yet, and is because the data of this moment are not carried out computing as yet, even do not compress, little to the speed general impacts that improve computing yet.
B20, read not effective query region of target bit string of operation and the target bit string in the memory headroom one by one and carry out logical operation, and operation result is kept at memory headroom, specifically may further comprise the steps.
D201, from external memory, read in a not effective query region of target bit string of operation, and this target bit string and the bit string that is kept in the internal memory are carried out the vector logic computing, preserve operation result in memory headroom;
Effective query region of the target bit string after compression this moment is leading target bit string, reads in a target bit string of not operating and be the succeeding target bit string from external memory.
D202, the bit string that is stored in memory headroom after each logical operation is compressed, specifically be may further comprise the steps:
Whether data recording is 0 entirely for e1, the head of checking bit string and/or afterbody;
E2, if the head of bit string and/or tail data record are 0 entirely, then the upper bound of bit string and/or lower bound are adjusted to data recording and are 1 position, and the corresponding value of revising the upper bound in the handle and/or lower bound.
Because the scope of bitmap index is compressed the resulting target bit string of middle computing all in the convergence indexed results after each computing, further compressed the target zone of bitmap index operation.Certainly, whether this compression step also can be carried out according to the actual conditions decision.
The repeating step b20 target bit string that all are not operated in external memory all participates in till the computing.
In the embodiment of the invention in the bitmap index operation of carrying out data retrieval, define effective query region of target bit string earlier, thereby for follow-up index operation provides the bounded access control, only need carry out the bitmap index operation and can obtain Query Result in effective query region of target bit string, and need not carry out the bitmap index operation in whole target bit string, dwindled actual bitmap index scope, reduced the bitmap index amount of operational data, so it is big to have solved prior art operational data amount, bitmap index operation committed memory resource is technical matters how, accelerated the speed of index simultaneously.
S3, call the net result that is saved in the memory headroom; Call the method that is saved in the net result in the memory headroom, comprising: Tabbed browsing, related contrast and data output.
Tabbed browsing refers to net result is checked for operating personnel by the mode that shows page by page on display screen;
Related contrast refers to that net result participates in other arithmetic operations, and for example whether validation verification, judged result meet the condition test of index instruction as a result;
Data output refers to net result is outputed to the specified position of call instruction from memory headroom.
S4, release bitmap index handle and described memory headroom; Judge whether the bitmap index operation is finished; If, then call respective function and discharge the bitmap index handle, whether decision operation result utilizes finishes, if, releasing memory space then.Memory headroom of being applied in the above-mentioned steps and bitmap index handle must discharge, otherwise will will take the internal memory of system always, influence system's arithmetic speed.
A kind of bitmap index unit that the embodiment of the invention provided and the smart card that is provided with this bitmap index unit, it is big to have solved smart card operating system bitmap index amount of operational data of the prior art, the many technical matterss of bitmap index operation committed memory resource.
As shown in Figure 6 and Figure 7, the bitmap index unit that present embodiment provided comprises: limit module, index operation module, calling module and release module, wherein:
Limit module, be used to limit effective query region of target bit string, can be according to any or the definite effective query region of combination of search condition, record sort, operator's authority, dictionary preface; Limit module and comprise establishment handle module and application memory modules, create the handle module and be used for definition, establishment bitmap index handle, and limit the effective query region of target bit string when operating by the bitmap index handle; The bitmap index handle comprises the upper bound and the lower bound of effective query region, and wherein: the upper bound is used to limit the upper bound of the query region of each target bit string; Lower bound is used to limit the lower bound of the query region of each target bit string.After creating handle module creation bitmap index handle, the memory headroom that the application memory modules is used to apply for and effective query region is complementary.Limit module in the embodiment of the invention, also can create the bitmap index handle, and utilize this bitmap index handle to limit the effective query region of each target bit string when operating according to the index order.
The index operation module is used for carrying out the bitmap index operation in effective query region of target bit string; The index operation module comprises: read module, compression module and computing module, and wherein: read module is used to read between effective interrogation zone of a target bit string memory headroom to application; Computing module is used for reading one by one effective query region of the target bit string of not operating and the target bit string of memory headroom is carried out logical operation, and operation result is kept at memory headroom.Read module and computing module cycling are till the target bit string that all are not operated all participates in computing and obtains the result.
Calling module is used for calling the net result that is saved in memory headroom, and calling module comprises: Tabbed browsing module, related contrast module and data outputting module; The Tabbed browsing module is used for net result is checked for operating personnel by the mode that shows page by page on display screen; Related contrast module is used for participating in other arithmetic operations with net result, and for example whether validation verification, judged result meet the condition test of index instruction as a result; Data outputting module is used for net result is outputed to the specified position of call instruction from memory headroom.
Compression module is used for the bit string of memory headroom is compressed, and compression module comprises: check module and adjusting module, wherein:
Check module, be used to check that whether effective query region of target bit string or head that the resulting bit string of computing module computing is intermediate result and/or afterbody exist the partial continuous data recording is 0 entirely;
If it is 0 entirely that there are the partial continuous data recording in the head effective query region or the resulting bit string of computing module computing of target bit string and/or afterbody, then to be used for data recording adjusted in the last item record of head article one record of effective query region of target bit string and/or afterbody be 1 position to adjusting module, the corresponding upper bound and/or the lower bound of adjusting the bitmap index handle.
Release module is used for discharging bitmap index handle and memory headroom after operating result uses.
The bitmap index unit is when the bitmap index operation of carrying out data retrieval in the embodiment of the invention, earlier by limiting effective query region that module limits the target bit string, thereby for follow-up index operation provides the bounded access control, only need carry out the bitmap index operation and can obtain Query Result in effective query region of target bit string, and need not carry out the bitmap index operation in whole target bit string, so dwindled actual bitmap index scope, reduced the bitmap index amount of operational data, accelerated the speed of index, it is big to have solved smart card operating system bitmap index amount of operational data of the prior art, the many technical matterss of bitmap index operation committed memory resource.
The smart card that the embodiment of the invention provided comprises the bitmap index unit that the invention described above embodiment is provided.Because the smart card that the embodiment of the invention provided has identical specified features with the bitmap index unit that the invention described above embodiment is provided, so both not only have unicity, and can also solve identical technical matters, obtain identical technique effect.
The above; be the specific embodiment of the present invention only, but protection scope of the present invention is not limited to this, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.