Expansible daily record data storage method and device
Technical field
The present invention relates to field of computer technology, more particularly to expansible daily record data storage method and device.
Background technology
Daily record data (English full name is log data) is exactly the inherent meaning of a daily record, i.e. daily record data is exactly one
It is used for showing generate the information of daily record why in daily record.General daily record data include the time, client ip, server-side IP,
The information such as client host name, server-side host name, user, operation, daily record preserve equipment receive after daily record data by data into
Row slitting, or global storage are disk file, its specific storage organization is as shown in Figure 1.
But having the data largely repeated in daily record data, such as IP, port, host name, action type, are operating
During store one by one these daily record datas can cause this portions of log data repeat record, so as to take a large amount of disk spaces.
To sum up, on daily record data, there are the problem of substantial amounts of information redundancy, there is no effectively in storing process at present
Solution.
The content of the invention
In view of this, the purpose of the embodiment of the present invention is the provision of expansible daily record data storage method and device,
By setting field dictionary and mode dictionary etc., efficiently solve daily record data information bulk redundancy in storing process and ask
Topic.
In a first aspect, an embodiment of the present invention provides expansible daily record data storage method, including:Compare daily record data
In each field change rate and the size of standards change rate set in advance;
When change rate is less than standards change rate, field is put into field dictionary and is stored, wherein, in field dictionary
The storage format of data includes Field ID and field contents, and Field ID is used for storing key assignments different in each field, in field
Hold and be used for storing numerical value different in each field;
When change rate is more than or equal to standards change rate, field is put into mode dictionary and is stored, wherein, pattern
The storage format of data includes pattern ID and mode contents in dictionary, and pattern ID is used for storing key assignments different in each field,
Pattern ID is used for storing key assignments different in each field, and mode contents are used for storing numerical value different in each field.
With reference to first aspect, an embodiment of the present invention provides the first possible embodiment of first aspect, wherein, side
Method further includes:
The storage format of data further includes Field counter in field dictionary, when change rate is less than standards change rate, word
Segment counter is used for storing the number that each field occurs;
When counting the number that each field occurs, number corresponding with static fields is extracted in Field counter.
With reference to first aspect, an embodiment of the present invention provides second of possible embodiment of first aspect, wherein, side
Method further includes:
The storage format of data further includes mode counter in mode dictionary, when change rate is more than or equal to standards change
During rate, mode counter is used for storing the number that each field occurs;
When counting the number that each field occurs, number corresponding with static fields is extracted in mode counter.
With reference to first aspect, an embodiment of the present invention provides the third possible embodiment of first aspect, wherein, side
Method further includes:
Establish field dictionary and mode dictionary respectively according to priori value.
With reference to first aspect, an embodiment of the present invention provides the 4th kind of possible embodiment of first aspect, wherein, side
Method further includes:
Field dictionary and mode dictionary are established according to field dynamic.
With reference to first aspect, an embodiment of the present invention provides the 5th kind of possible embodiment of first aspect, wherein, side
Method further includes:
When daily record data is from different application programs or different equipment, connect according to open architecture and unified
Mouth carries out the foundation of field dictionary and mode dictionary.
With reference to first aspect, an embodiment of the present invention provides the 6th kind of possible embodiment of first aspect, wherein, word
Section ID and pattern ID is represented with binary code.
Second aspect, an embodiment of the present invention provides expansible log data storage, including:
Change rate comparison module, for comparing the change rate of each field and standards change set in advance in daily record data
The size of rate;
Field memory module, for when change rate being less than standards change rate, field being put into field dictionary and is deposited
Storage, wherein, the storage format of data includes Field ID and field contents in field dictionary, and Field ID is used for storing in each field
Different key assignments, field contents are used for storing numerical value different in each field;
Pattern memory module, for when change rate is more than or equal to standards change rate, field to be put into mode dictionary
Stored, wherein, the storage format of data includes pattern ID and mode contents in mode dictionary, and pattern ID is used for storing each
Different key assignments in field, pattern ID are used for storing key assignments different in each field, and mode contents are used for storing each field
Middle different numerical value.
The third aspect, the embodiment of the present invention also provide a kind of terminal, including memory and processor, and memory is used to deposit
Storage supports processor to perform the program for the expansible daily record data storage method that above-mentioned aspect provides, and processor is configured as using
In performing the program that is stored in memory.
Fourth aspect, the embodiment of the present invention also provide a kind of computer-readable recording medium, computer-readable recording medium
On be stored with computer program, when computer program is run by processor perform any of the above-described method the step of.
Expansible daily record data storage method provided in an embodiment of the present invention and device, wherein, the expansible daily record
Date storage method includes:It is to compare the change rate of each field and standards change rate set in advance in daily record data first
Size is, it is necessary to illustrate, and standards change rate set in advance is a reference value, and its numerical values recited can be according to reality
Border usage scenario is flexibly set, and after above-mentioned comparison procedure, when change rate is less than standards change rate, field is put into
Stored in field dictionary, wherein, the storage format of data includes Field ID and field contents in field dictionary, and Field ID is used
To store key assignments different in each field, correspondingly, identical key assignments is represented in field dictionary with same Field ID,
So as to save in field dictionary the space waste stored one by one caused by key assignments, field contents are used for storing in each field
Different numerical value, afterwards, when change rate is more than or equal to standards change rate, is put into mode dictionary by field and is stored,
In this application, the storage format of data includes pattern ID and mode contents in mode dictionary, also, pattern ID is used for storing respectively
Different key assignments in a field, correspondingly, identical key assignments is represented in mode dictionary with same pattern ID, so as to
The space waste caused by key assignments is stored in save mode dictionary one by one, pattern ID is used for storing key different in each field
Value, mode contents are used for storing numerical value different in each field, and the storage form pair of above-mentioned key assignments-numerical value is used in the application
Daily record data is stored, and in the prior art, the pattern that each daily record data is stored one by one is compared, and reduces daily record
Data largely repeat the process of record, effectively save the size of the shared disk space of daily record data storage, and then avoid
The bulk redundancy phenomenon of daily record data information in storing process.
Other features and advantages of the present invention will illustrate in the following description, also, partly become from specification
Obtain it is clear that or being understood by implementing the present invention.The purpose of the present invention and other advantages are in specification, claims
And specifically noted structure is realized and obtained in attached drawing.
To enable the above objects, features and advantages of the present invention to become apparent, preferred embodiment cited below particularly, and coordinate
Appended attached drawing, is described in detail below.
Brief description of the drawings
, below will be to specific in order to illustrate more clearly of the specific embodiment of the invention or technical solution of the prior art
Embodiment or attached drawing needed to be used in the description of the prior art are briefly described, it should be apparent that, in describing below
Attached drawing is some embodiments of the present invention, for those of ordinary skill in the art, before not making the creative labor
Put, other attached drawings can also be obtained according to these attached drawings.
Fig. 1 shows the structure diagram of daily record data storage in the prior art;
Fig. 2 shows the first pass figure for the expansible daily record data storage method that the embodiment of the present invention is provided;
Fig. 3 shows the second flow chart for the expansible daily record data storage method that the embodiment of the present invention is provided;
Fig. 4 shows the structure connection figure for the expansible log data storage that the embodiment of the present invention is provided.
Icon:11- change rate comparison modules;12- field memory modules;13- pattern memory modules.
Embodiment
Below in conjunction with attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete
Ground describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.Usually exist
The component of the embodiment of the present invention described and illustrated in attached drawing can be arranged and designed with a variety of configurations herein.Cause
This, the detailed description of the embodiment of the present invention to providing in the accompanying drawings is not intended to limit claimed invention below
Scope, but it is merely representative of the selected embodiment of the present invention.Based on the embodiment of the present invention, those skilled in the art are not doing
Go out all other embodiments obtained on the premise of creative work, belong to the scope of protection of the invention.
At present, it is necessary to by the time of daily record data, client ip, server-side IP, client in daily record data storing process
The information such as end main frame name, server-side host name, user, operation are put into memory space one by one to be stored, i.e. daily record is preserved and set
Data are carried out slitting after daily record data by standby receive, or global storage is disk file.In this way, the major part in daily record data
The data repeated, such as IP, port, host name, action type, will be repeatedly recorded in storing process, so as to take big
Disk space is measured, serious information redundancy is caused while a large amount of memory spaces are wasted.
Based on this, an embodiment of the present invention provides expansible daily record data storage method and device, below by implementation
Example is described.
Embodiment 1
Referring to Fig. 2 and Fig. 3, the expansible daily record data storage method that the present embodiment proposes specifically includes following steps:
Step S101:Compare the change rate of each field and the size of standards change rate set in advance in daily record data.
Need exist for illustrating, standards change rate set in advance is a priori value, and the size of the priori value and storage are empty
Between size, the requirement etc. of information redundance it is information-related.The size for comparing the change rate of field be in order to will in daily record data it is each
A field distinguishes.
Step S102:When change rate is less than standards change rate, field is put into field dictionary and is stored, i.e. is right
In the storage of the less field of change put it into field dictionary, need exist for illustrating, number in field dictionary
According to storage format include Field ID and field contents, in implementation process, Field ID be used for store it is different in each field
Key assignments, i.e., each different key assignments take a Field ID, and identical key assignments takes same Field ID, in this way, implementing
Cheng Zhong, can represent its title, so as to effectively save the sky of disk when key assignments is repeated several times by same Field ID
Between size, and each corresponding concrete numerical value of key assignments stores respectively, i.e. field contents are for storing number different in each field
Value, when carrying out the lookup of daily record data, can be combined by Field ID and corresponding field contents.
Step S103:When change rate is more than or equal to standards change rate, field is put into mode dictionary and is stored,
That is, the storage of the field for changing greatly is put it into field dictionary, needs exist for illustrating, mode dictionary
The storage format of middle data includes pattern ID and mode contents, and pattern ID is usually referred to as fixed part, and fixed part can
Represent that this partial data is smaller for specific system change, or Limited Number with a character string mode, therefore, Ke Yijian
A mode dictionary is found, pattern ID is used for storing key assignments different in each field, i.e., each different key assignments takes a mould
Formulas I D, identical key assignments take same pattern ID, in this way, in implementation process, can be by same when key assignments is repeated several times
A pattern ID represents its title, so as to effectively save the space size of disk, and the corresponding concrete numerical value of each key assignments
Store respectively, mode contents are used for storing numerical value different in each field.I.e. with a series of pattern ID and the number changed greatly
According to combination store this partial data.
In addition, expansible daily record data storage method further includes:
Step S001:The storage format of data further includes Field counter in field dictionary, i.e., in specific implementation process,
Each field in daily record data is represented in the form of key assignments-numerical value-reference count, for the storage of above two field
Pattern, when change rate is less than standards change rate, Field counter is used for storing the number that each field occurs, i.e. field count
The total number of each identical Field ID is stored in device, when it is implemented, the corresponding Field ID of each field counts respectively, when having
When the Field ID repeated occurs again, count and add one again.
Step S002:When counting the number that each field occurs, extracted in Field counter corresponding to static fields
Number.When the occurrence number of Field ID is wanted to call in other application end, the word with statistics is extracted directly from Field counter
The corresponding Field ID number of section, it is convenient and efficient.
In addition, it is necessary to illustrate, above-mentioned Field ID and pattern ID are represented with binary code.Need exist for into
Row explanation, in digital circuit, binary number refers to use binary notation system, i.e., with 2 for radix number representation system table
The numeral shown, is usually represented with two different symbols 0 and 1.Represent to be stored easy to computer using binary code
And calling.
In addition, in the prior art in order to by daily record data come the problem of checking, it is necessary to go out to a certain data in daily record
Occurrence number is counted, and is counted again during the occurrence number of a certain data, it is necessary to scan all data so in statistical log
Number, efficiency are very low.Further included in the expansible daily record data storage method of the application:
(1) storage format of data further includes mode counter in mode dictionary, i.e., in specific implementation process, by daily record
Each field in data is represented in the form of key assignments-numerical value-reference count, when change rate is more than or equal to standards change
During rate, mode counter is used for storing the number that each field occurs, i.e., each identical pattern ID is stored in mode counter
Total number, when it is implemented, the corresponding pattern ID of each field is counted respectively, when the pattern ID for having repetition occurs again,
Count and add one again, count very convenient.
(2) when counting the number that each field occurs, number corresponding with static fields is extracted in mode counter.
Similarly, the field with statistics is extracted when the occurrence number of invocation pattern ID is thought at other application end, in direct slave pattern counter
ID number of corresponding pattern, it is convenient and efficient.
In addition, expansible daily record data storage method further includes:Establish field dictionary and pattern respectively according to priori value
Dictionary.There is illustrated a kind of method that field dictionary and mode dictionary are established, that is, field dictionary and mode dictionary are pre-established,
The foundation of foundation be before daily record data in multiple fields i.e. be known as priori value.By priori value and its frequency of appearance come
Field dictionary and mode dictionary are established respectively, can be that consumption, convenient fortune are saved in the daily record data processing occurred in application operation
The daily record data occurred in row is stored after field is directly matched from field dictionary and mode dictionary.
In addition, expansible daily record data storage method further includes:Field dictionary and pattern-word are established according to field dynamic
Allusion quotation.There is illustrated another method that field dictionary and mode dictionary are established, i.e., by field dynamic come establish field dictionary and
Mode dictionary, the field of the daily record data occurred in application operation are dynamically added in field dictionary and mode dictionary,
Field dictionary and mode dictionary become huge with the generation of daily record data.Due to, in application operation, field dictionary and mould
Formula dictionary also needs to store the field of corresponding daily record data while foundation, therefore, this kind of implementation processing speed is slower.
In addition, expansible daily record data storage method further includes:When daily record data from different application programs or
During different equipment, the foundation of field dictionary and mode dictionary is carried out according to open architecture and unified interface.Need exist for
Illustrate, open architecture has mutual between each node on the portability and tailorability, network of application system
Strong operability, also, be easily obtained.Field dictionary and mode dictionary are established by open architecture and unified interface, just
In the transplanting between different application programs and operate.
In conclusion expansible daily record data storage method provided in this embodiment includes:Compare daily record data before this
In each field change rate and the size of standards change rate set in advance, afterwards when change rate is less than standards change rate,
Field is put into field dictionary and is stored, in the present embodiment, the storage format of data includes Field ID in field dictionary
And field contents, Field ID are used for storing key assignments different in each field, field contents are used for storing different in each field
Numerical value, and when change rate is more than or equal to standards change rate, field is put into mode dictionary and is stored, correspondingly,
The storage format of data includes pattern ID and mode contents in mode dictionary, and pattern ID is used for storing key different in each field
Value, pattern ID are used for storing key assignments different in each field, and mode contents are used for storing numerical value different in each field, lead to
Each field in daily record data is stored separately by the form for crossing above-mentioned dictionary, thus effectively prevent the field of repetition repeatedly into
The phenomenon of row storage, has saved substantial amounts of disk space, and largely reduce daily record data in storing process
Information redundancy, it is convenient and efficient.
Embodiment 2
Referring to Fig. 4, present embodiments providing expansible log data storage includes:Change rate comparison module 11,
For comparing the change rate of each field and the size of standards change rate set in advance in daily record data.
Field memory module 12, for when change rate being less than standards change rate, field being put into field dictionary and is carried out
Storage, wherein, the storage format of data includes Field ID and field contents in field dictionary, and Field ID is used for storing each field
Middle different key assignments, field contents are used for storing numerical value different in each field.
Pattern memory module 13, for when change rate is more than or equal to standards change rate, field to be put into pattern-word
Allusion quotation is stored, wherein, the storage format of data includes pattern ID and mode contents in mode dictionary, and pattern ID is used for storing each
Different key assignments in a field, pattern ID are used for storing key assignments different in each field, and mode contents are used for storing each word
Different numerical value in section.
Expansible log data storage provided in an embodiment of the present invention, provides expansible with above-described embodiment
Daily record data storage method has identical technical characteristic, so can also solve identical technical problem, reaches identical technology
Effect.
The embodiment of the present invention additionally provides a kind of terminal, including memory and processor, and memory, which is used to store, to be supported
Processor performs the program of above-described embodiment method, and processor is configurable for performing the program stored in memory.
The embodiment of the present invention also provides a kind of computer-readable recording medium, and meter is stored with computer-readable recording medium
Calculation machine program, when computer program is run by processor the step of the method for execution any of the above-described.
It should be noted that each embodiment in this specification is described by the way of progressive, each embodiment weight
Point explanation is all difference with other embodiment, between each embodiment identical similar part mutually referring to.
The technique effect of the expansible daily record data storage method and device that the embodiment of the present invention is provided, its realization principle and generation
Identical with preceding method embodiment, to briefly describe, device embodiment part does not refer to part, refers to preceding method embodiment
Middle corresponding contents.
In several embodiments provided herein, it should be understood that disclosed apparatus and method, can also pass through
Other modes are realized.Device embodiment described above is only schematical, for example, flow chart and block diagram in attached drawing
Show the devices of multiple embodiments according to the present invention, method and computer program product architectural framework in the cards,
Function and operation.At this point, each square frame in flow chart or block diagram can represent the one of a module, program segment or code
Part, a part for the module, program segment or code include one or more and are used for realization holding for defined logic function
Row instruction.It should also be noted that at some as in the implementation replaced, the function that is marked in square frame can also with different from
The order marked in attached drawing occurs.For example, two continuous square frames can essentially perform substantially in parallel, they are sometimes
It can perform in the opposite order, this is depending on involved function.It is it is also noted that every in block diagram and/or flow chart
The combination of a square frame and block diagram and/or the square frame in flow chart, can use function or the dedicated base of action as defined in performing
Realize, or can be realized with the combination of specialized hardware and computer instruction in the system of hardware.
In addition, each function module or unit in each embodiment of the present invention can integrate and to form an independence
Part or modules individualism, can also two or more modules be integrated to form an independent portion
Point.
If the function is realized in the form of software function module and is used as independent production marketing or in use, can be with
It is stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially in other words
The part to contribute to the prior art or the part of the technical solution can be embodied in the form of software product, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be
People's computer, server, or network equipment etc.) perform all or part of step of each embodiment the method for the present invention.
And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only storage (ROM, Read-Only Memory), arbitrary access are deposited
Reservoir (RAM, Random Access Memory), magnetic disc or CD etc. are various can be with the medium of store program codes.
It should be noted that herein, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any this actual relation or order, can not be interpreted as indicating or implying relative importance.Moreover, term " bag
Include ", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion so that the mistake including a series of elements
Journey, method, article or equipment not only include those key elements, but also including other elements that are not explicitly listed, either
Further include as elements inherent to such a process, method, article, or device.In the absence of more restrictions, by sentence
The key element that "including a ..." limits, it is not excluded that also deposit in the process, method, article or apparatus that includes the element
In other identical element.
The foregoing is only a preferred embodiment of the present invention, is not intended to limit the invention, for the skill of this area
For art personnel, the invention may be variously modified and varied.Within the spirit and principles of the invention, that is made any repaiies
Change, equivalent substitution, improvement etc., should all be included in the protection scope of the present invention.It should be noted that:Similar label and letter exists
Similar terms is represented in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, is then not required in subsequent attached drawing
It is further defined and is explained.
The above description is merely a specific embodiment, but protection scope of the present invention is not limited thereto, any
Those familiar with the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all be contained
Cover within protection scope of the present invention.Therefore, protection scope of the present invention answers the scope of the claims of being subject to.