WO2012174906A1 - 一种数据存储、查找方法及装置 - Google Patents

一种数据存储、查找方法及装置 Download PDF

Info

Publication number
WO2012174906A1
WO2012174906A1 PCT/CN2012/072846 CN2012072846W WO2012174906A1 WO 2012174906 A1 WO2012174906 A1 WO 2012174906A1 CN 2012072846 W CN2012072846 W CN 2012072846W WO 2012174906 A1 WO2012174906 A1 WO 2012174906A1
Authority
WO
WIPO (PCT)
Prior art keywords
performance
performance data
data
file
index information
Prior art date
Application number
PCT/CN2012/072846
Other languages
English (en)
French (fr)
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 WO2012174906A1 publication Critical patent/WO2012174906A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/907Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually

Definitions

  • the present invention relates to the field of data storage technologies, and in particular, to a data storage, searching method and apparatus. Background technique
  • a collection point is a physical entity on the device that provides performance data collection and statistics. It is the source of the specified performance data on the device. These performance data are stored in some sort of persistence. When the scale is large, the stored data is massive. In the massive data, it is often necessary to conduct some queries. These query conditions include one or a small number of collection point identifiers, the collection time range of performance data, and the numerical range of performance data. These data are queried in the form of graphs or charts. Displayed on the Graphical User Interface (GUI), these all involve random reading of performance data.
  • the collection point identifier refers to a number that can uniquely identify a collection point, and can be a string, etc.
  • the technical problem to be solved by the present invention is to provide a data storage and searching method and apparatus for solving the problem of inefficient querying data in massive data due to random storage of performance data in the prior art.
  • the present invention provides a data storage method, the method comprising:
  • the performance data collected during each data collection period is stored in a different performance data classification in the performance file according to the business feature classification;
  • the index information corresponding to each of the performance data categorizations is stored in a categorization index file corresponding to the performance file.
  • the index information corresponding to the performance data classification includes: a classified service category identifier corresponding to the performance data classification, and a storage location of the first performance data in the performance file in the performance data classification And the size of the performance data categorized.
  • the method further includes:
  • Each piece of performance data is stored only in one type of performance data categorization; and performance data belonging to the same performance data categorization is stored in order of data collection.
  • the present invention also provides a data search method, the method comprising:
  • searching for the performance data to be checked in the performance file according to the index information includes:
  • the location after which is located as the query end position, and the performance data to be checked is searched between the query start position and the query end position.
  • the present invention provides a data storage device, including: a performance data storage unit and an index information storage unit;
  • a performance data storage unit configured to store the performance data collected in each data collection period according to the service characteristics in different performance data classifications in the performance file;
  • the index information storage unit is configured to store index information corresponding to each of the performance data categorizations in a categorization index file corresponding to the performance file.
  • the index information corresponding to the performance data classification includes: a classified service category identifier corresponding to the performance data classification, and a storage location of the first performance data in the performance file in the performance data classification And the size of the performance data categorized.
  • the performance data storage unit is further configured to: store each performance data only in one type of performance data classification; and store performance data belonging to the same performance data classification in order of data collection.
  • the present invention further provides a data query device, including: a performance data classification determining unit, an index information searching unit, and a performance data searching unit to be checked;
  • a performance data categorization determining unit configured to determine, according to the performance data to be checked, the performance data categorized by the performance data to be checked;
  • An index information searching unit configured to search, in the categorization index file, index information corresponding to the performance data categorization;
  • the performance data searching unit is configured to search for the performance data to be checked in the performance file according to the index information.
  • the to-be-checked performance data searching unit further includes: an index information acquiring subunit and a searching subunit; wherein
  • An index information obtaining subunit configured to obtain, according to the index information, a storage location of the first performance data in the performance data classification in the performance file, and a size of the performance data classification;
  • a searching subunit configured to use a storage location of the first piece of performance data in the performance file as a query start location, and offset a storage location of the first piece of performance data in the performance file The location where the performance data is categorized is used as the query end location, and the to-be-checked performance data is searched between the query start location and the query end location.
  • the present invention stores the performance data in a performance file by categorizing the performance data, and stores the storage location of each type of performance data in the performance file in the categorization index file, so that when the performance data is searched, it can be in the categorization index file.
  • the storage location of the performance data in the performance file is found, and the performance data to be checked can be quickly found, so that the query data is concentrated, thereby improving query efficiency, reducing 10 operations, and reducing the complexity of the search.
  • the overhead of most head movement and seek in large data files is avoided, which greatly improves the performance of random read and write of the disk, thereby improving the availability of the system.
  • FIG. 1 is a flowchart of a data storage method in an embodiment of the present invention
  • FIG. 1 is a flowchart of a data search method in an embodiment of the present invention
  • 3 is a schematic structural diagram of a data storage device according to an embodiment of the present invention
  • 4 is a schematic structural diagram of a data search device according to an embodiment of the present invention. detailed description
  • the present invention provides a data storage, searching method and device, and the present invention is implemented below with reference to the accompanying drawings and embodiments. Further details. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
  • the invention overcomes a large amount of addressing consumption caused by random read and write caused by the use of a relational database as a permanent storage medium, performance data conditional query and periodic performance data increase due to performance data in the prior art, thereby causing low system performance.
  • the problem is to provide a storage method for performing performance data conforming to a specific application characteristic of the performance acquisition system.
  • two types of files are used for storage, specifically, performance.
  • Files are used to store performance records, and categorization index files are used to store location information for performance records in performance files.
  • Each performance file is equipped with a collation index file, and the collation index file is categorized as a performance record, not a performance record.
  • the performance records are categorized before the performance file is written, and the records are sequentially appended to the end of the file according to the categorization, or non-randomly written; and one write, multiple random read reads; By categorizing performance data before writing to disk, it is sequentially appended to the end of the file, thereby avoiding the overhead of most head movement and seek in large data files.
  • sexuality is established by categorization, rather than an index method based on performance data.
  • an embodiment of the present invention relates to a data storage method, including the following steps: Step S101: classify performance data collected in each data collection period according to service characteristics in a performance file, and classify different performance data. in; In this step, the performance data collected during each collection period or during the data collection time point or time period is stored in the same performance file, and the performance data collected in different collection periods are stored in different performance files.
  • performance data can also be referred to as performance records.
  • each performance data collected has a performance record identifier
  • all performance data can be categorized according to the performance record identifier, that is, the performance data is classified into different performance data categories.
  • the method of categorization is based on the characteristics of the business. In principle, the number of records in each categorization is allocated as evenly as possible, and one performance record can only belong to one categorization.
  • a performance data refers to the performance data of a collection point.
  • the classification method is based on the service characteristics.
  • categorization index file for each performance file, which is used to store the index of the performance record categorization in the performance file, that is, the location information.
  • the mapping between the performance file and the categorization index file you need to set the mapping between the performance file name and the corresponding categorization index file name.
  • the categorization index file corresponding to the performance file can be quickly found.
  • the performance file is *****.dat, then the index file name is *****.idx, except for the suffix name, the file name is the same, of course, you can also choose other corresponding methods.
  • All performance data is stored in order according to the classification: For each type of performance data classification, the remaining records of the classification are stored in the performance file in turn, that is, the performance data belonging to the same performance data classification is in order of data collection. Deposit. Once all the categorizations have been stored, the performance files are stored.
  • Step S102 Store index information corresponding to each of the performance data categorizations in a categorization index file corresponding to the performance file.
  • each performance file has a corresponding collation index file.
  • the collection point number is Entryid_i_s_p (performance record identifier), where i is the device ip address, string, for example 10.32.35.67, s is the slot number, is 1 to 64, and p is the port number is 1.
  • the collection point is shaped like: Entryid_10.32.35.67_l_l.
  • the classified service category is identified as grp—i—s, where i and s have the same meaning. Then the classified service category identifier is shaped like grp_10.3 2 .35.67_l.
  • Each performance data categorization in the performance file has an index information in the categorization index file, and the index information corresponding to each type of performance data categorization includes: a categorization service category identifier corresponding to the performance data categorization, The location in the performance data categorization where the first performance data is stored in the performance file and the size of the performance data categorized.
  • the size of the performance data categorization refers to: The number of bytes of performance data contained in the performance data categorization in the performance file.
  • the classification service category identifier and the performance are stored in the index information corresponding to the classification in the classification index file.
  • the displacement of the data in the performance file, and then the remaining records of the collation are stored in the performance file in turn.
  • the storage displacement of the last performance data in the performance file and the storage displacement of the first performance data in the classification file in the classification file are used to obtain a difference, and the difference is obtained as The size of the performance data classification is stored in the above index information. In this way, all categories are stored.
  • the above embodiment compares with the prior art directly using the database table of the relational database to save the performance record.
  • the service characteristics of the collected data of the collection system two types of files are used for storage, and the performance file is used to store performance records and records.
  • the categorization index file is used to save the location information of the performance records in the performance file; classify the performance records to ensure that the performance records are written in an append manner according to the categorization; and use the record categorization index file to assist in locating the corresponding performance files.
  • Read Location greatly improves the performance of disk random read and write, which greatly improves the system's usability.
  • Step S201 Determine, according to performance data to be checked, a performance data classification to which the performance data to be checked belongs;
  • each performance data collected has a performance record identifier, and the classification in the performance file is also classified according to the performance record identifier. Therefore, according to the performance record identifier of the performance data to be checked, the The classified service category identifier of the performance data to be checked, and then it can be known which type of performance data belongs to the performance data to be checked.
  • Step S202 searching, in the categorization index file, index information corresponding to the performance data categorization;
  • Step S203 Search for performance data to be checked in the performance file according to the index information.
  • the storage location of the first performance data in the performance file is used as the query start position, and the location where the first performance data is classified after the storage location offset performance data in the performance file is used as the query end position.
  • Find the performance data to be checked in the performance file It can be searched by means of random reading, or it can be searched by reading in sequence. Since the specific query position has been defined, the search speed is fast, and the search efficiency is greatly improved.
  • the categorization index file is used to describe the index information of the performance data classification, including: the categorization service category identifier corresponding to the categorization, and the first record in the categorization record in the performance file.
  • the displacement in , and the size of the collation With these index information, when reading the performance record, the corresponding position of the performance file can be directly located, and there is no need to traverse the file header to find the end of the file for searching, which makes the search efficiency high.
  • the collection point number is Entryid_i_s_p, where i is the device ip address, the string, for example, 10.32.35.67, s is the slot number, 1 to 64, p is the port number from 1 to 32, and the collection point is as follows: In turn, EntryId_10.32.35.67 1 L 500,000 collection points are distributed on about 250 devices, that is, 250 IP addresses. If you select a slot as a categorization, the categorization index is 16,000, and the categorization service category is identified as grp_i_s. The meanings of i and s are the same as above.
  • the displacement identified in the collation information by reading the collation index file, that is, the displacement identified in the collation information, that is, the starting position of the collation in the performance file, and then read the entire collation based on the collation size, and then Find out the performance record corresponding to Entryid_10.32.35.67_l_17. If the 500,000 records are not classified and stored randomly, then the record query time for a collection point is uncertain. If the collection point is stored at the end of the file, then the file must be traversed to find, each record The search time is relatively stable and fast.
  • the storage and query are performed in the manner of performance data classification, instead of storing and querying each performance data, so that the index file is classified, and a balance is obtained in the occupied space and the disk seek.
  • 25 performance data belongs to a categorization.
  • the size of the index file is one-fifth of the prior art, and this value can be based on specific The business characteristics of the application, as well as the memory of the machine and the number of bytes occupied by a performance record.
  • the classification of the performance record is formulated according to the service characteristics, and the number of performance records of each classification can be ensured as much as possible, and the balance between the index size and the query efficiency is balanced, and not a certain classification. Larger, a smaller category. Avoid larger categorization due to reading It takes up memory and affects efficiency. It also avoids the problem of inefficiencies caused by 10 frequent categorizations due to the need to read more categorizations. For example, all port collection points in a slot are classified as a performance, so that each category contains more performance. And because it is classified according to service characteristics and conforms to the service query feature, it can also ensure a high hit rate and reduce complexity in random queries. For example, queries for certain ports in a certain slot are classified according to slots. When you only need to read one collation, you can get all the appropriate records.
  • the embodiment of the present invention further relates to a data storage device, including: a performance data storage unit 301, configured to store performance data collected in each data collection period according to service characteristics in different performance files. Performance data classification;
  • the index information storage unit 302 is configured to store index information corresponding to each type of the performance data categorization in a categorization index file corresponding to the performance file.
  • the index information corresponding to each type of the performance data categorization includes: a categorization service category identifier corresponding to the performance data categorization, and a storage location of the first performance data in the performance data categorization in the performance file And the size of the performance data categorized.
  • the performance data storage unit 301 stores each performance data in only one type of performance data classification; and stores the performance data belonging to the same performance data classification in the order of data collection.
  • an embodiment of the present invention further relates to a data query apparatus, including: a performance data classification determining unit 401, configured to determine, according to performance data to be checked, performance data classification to which the performance data to be checked belongs;
  • the index information searching unit 402 is configured to search, in the categorization index file, index information corresponding to the performance data categorization;
  • the to-be-checked performance data searching unit 403 is configured to search the performance data to be checked in the performance file according to the index information.
  • the performance data search unit 403 to be checked may further include:
  • the index information obtaining sub-unit 4031 is configured to obtain, according to the index information, a storage location of the first performance data in the performance data classification in the performance file, and a size of the performance data classification;
  • the finding subunit 4032 is configured to use a storage location of the first piece of performance data in the performance file as a query start location, and shift the storage location of the first piece of performance data in the performance file by the performance The location after the data is categorized is used as the query end location, and the performance data to be checked is searched in the performance file.
  • the present invention stores the performance data in the performance file by storing the performance data, and stores the storage location of each type of performance data in the performance file in the classification index file, so that when the performance data is searched,
  • the storage location of the performance data in the performance file can be found in the categorization index file, and the performance data to be checked can be quickly found, so that the queried data is concentrated, thereby improving query efficiency, reducing 10 operations, and reducing The complexity of the lookup.
  • the overhead of most head movement and seek in large data files is avoided, which greatly improves the performance of random read and write of the disk, thereby improving the availability of the system.

Landscapes

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

Abstract

本发明公开了一种数据存储、查找方法及装置。数据存储方法包括:将每个数据采集周期内采集的性能数据按业务特征分类存储在性能文件中不同的性能数据归类中;将每类性能数据归类对应的索引信息存储在与性能文件对应的归类索引文件中。数据查找方法包括:根据待查性能数据,确定待查性能数据所属的性能数据归类;在归类索引文件中,查找与性能数据归类对应的索引信息;根据索引信息,在性能文件中查找待查性能数据。本发明可以对性能数据进行快速查找,查询效率高,并且减少IO操作,降低了查找的复杂性,提升了磁盘随机读写的性能,从而提升了系统的可用性。

Description

一种数据存储、 查找方法及装置 技术领域
本发明涉及数据存储技术领域, 特别是涉及一种数据存储、 查找方法 及装置。 背景技术
在性能采集系统中, 往往需要周期性地从设备的多个采集点上采集多 种性能数据。 采集点是指设备上可以提供性能数据采集和统计的物理实体, 是设备上指定的获取性能数据的来源。 这些性能数据会以某种持久化的方 式被存储起来, 采集规模较大时, 存储的数据是海量的。 在海量的数据中 常常需要进行一些查询, 这些查询条件包括某个或者少量采集点标识、 性 能数据的采集时间范围、 以及性能数据的数值范围等, 这些数据被查询出 来将以图形或图表的形式显示在图形用户界面 (GUI , Graphical User Interface )上, 这些都涉及到性能数据的随机读取。 这里, 所述采集点标识 是指能唯一标识某个采集点的编号, 可以为字串等
目前的系统往往都是将性能数据保存在关系数据库中, 比如 SQLSERVER, ORACLE等,可是由于这些数据表最终都是存储在同一个或 者少数几个文件(当支持对物理表的逻辑分表时) 中。 一般来讲, 由于受 到磁头移动和寻道的影响, 在这样的大数据文件中基于磁盘的随机读写性 能往往比较低效。 数据库虽然可以帮助建立相应的索引, 但是性能采集系 统的数据具有自身的业务特征, 这样的索引不足以提高随机查询时的效率, 不能确保查询数据的集中性, 从而不能减少相应的输入输出 (10, Input Output )操作, 以至于效率较低; 同时所占的空间开销也较大。 数据库的数 据插入对文件来说也不能保证顺序追加, 从而产生磁头移动和寻道, 而这 些对一次写入、 多次读取的性能数据来说都是不必要的。 特别是查询某些 给定查询条件的性能数据时, 为了要读出性能数据, 会有大量的随机读取 操作, 导致查询性能极为低下, 用户体验不好; 关系型数据库对数据的存 储方式、 以及结构^ i查询语言 (SQL, Structured Query Language ) 的查询 已经不适合目前海量级别的性能数据。 发明内容
本发明要解决的技术问题是提供一种数据存储、 查找方法及装置, 用 以解决现有技术中由于性能数据随机存储而造成在海量级数据中查询数据 效率低下的问题。
为解决上述技术问题, 一方面, 本发明提供一种数据存储方法, 该方 法包括:
将每个数据采集周期内采集的性能数据按业务特征分类存储在性能文 件中不同的性能数据归类中;
将每个所述性能数据归类对应的索引信息存储在与所述性能文件对应 的归类索引文件中。
进一步, 所述性能数据归类对应的索引信息包括: 与所述性能数据归 类对应的归类业务类别标识、 所述性能数据归类中第一条性能数据在所述 性能文件中的存储位置、 以及所述性能数据归类的大小。
进一步, 在将每个数据采集周期内采集的性能数据按业务特征分类存 储在性能文件中不同的性能数据归类中时, 该方法进一步包括:
每条性能数据只存储于一类性能数据归类中; 且属于同一性能数据归 类中的性能数据按照数据采集的前后顺序依次存入。
另一方面, 本发明还提供一种数据查找方法, 该方法包括:
根据待查性能数据, 确定所述待查性能数据所属的性能数据归类; 在归类索引文件中, 查找与所述性能数据归类对应的索引信息; 根据所述索弓!信息, 在性能文件中查找所述待查性能数据。
进一步, 所述根据所述索引信息, 在性能文件中查找所述待查性能数 据, 包括:
根据所述索引信息, 获取所述性能数据归类中第一条性能数据在所述 性能文件中的存储位置、 以及所述性能数据归类的大小;
将所述第一条性能数据在所述性能文件中的存储位置作为查询起始位 置, 并将所述第一条性能数据在所述性能文件中的存储位置偏移所述性能 数据归类大小之后所处的位置作为查询结束位置, 在所述查询起始位置与 查询结束位置之间查找所述待查性能数据。
再一方面, 本发明还提供一种数据存储装置, 包括: 性能数据存储单 元及索引信息存储单元; 其中,
性能数据存储单元, 用于将每个数据采集周期内采集的性能数据按业 务特征分类存储在性能文件中不同的性能数据归类中;
索引信息存储单元, 用于将每个所述性能数据归类对应的索引信息存 储在与所述性能文件对应的归类索引文件中。
进一步, 所述性能数据归类对应的索引信息包括: 与所述性能数据归 类对应的归类业务类别标识、 所述性能数据归类中第一条性能数据在所述 性能文件中的存储位置、 以及所述性能数据归类的大小。
进一步, 所述性能数据存储单元进一步用于: 将每条性能数据只存储 于一类性能数据归类中; 且将属于同一性能数据归类中的性能数据按照数 据采集的前后顺序依次存入。
再一方面, 本发明还提供一种数据查询装置, 包括: 性能数据归类确 定单元、 索引信息查找单元、 以及待查性能数据查找单元; 其中,
性能数据归类确定单元, 用于根据待查性能数据, 确定所述待查性能 数据所属的性能数据归类; 索引信息查找单元, 用于在归类索引文件中查找与所述性能数据归类 对应的索引信息;
待查性能数据查找单元, 用于根据所述索引信息, 在性能文件中查找 所述待查性能数据。
进一步, 所述待查性能数据查找单元进一步包括: 索引信息获取子单 元及查找子单元; 其中,
索引信息获取子单元, 用于根据所述索引信息, 获取所述性能数据归 类中第一条性能数据在所述性能文件中的存储位置、 以及所述性能数据归 类的大小;
查找子单元, 用于将所述第一条性能数据在所述性能文件中的存储位 置作为查询起始位置, 并将所述第一条性能数据在所述性能文件中的存储 位置偏移所述性能数据归类大小之后所处的位置作为查询结束位置, 在所 述查询起始位置与查询结束位置之间查找所述待查性能数据。
本发明有益效果如下:
本发明通过对性能数据归类存储在性能文件中, 并将每类性能数据在 性能文件中的存储位置存储在归类索引文件中, 这样, 查找性能数据时, 就可以在归类索引文件中查找到这一类性能数据在性能文件中的存储位 置, 进而可以快速查找到待查的性能数据, 使得查询的数据较为集中, 从 而提高查询效率, 减少 10操作, 降低了查找的复杂性。 另外, 避免了在超 大数据文件中绝大多数的磁头移动和寻道的开销, 极大地提升了磁盘随机 读写的性能, 从而提升了系统的可用性。 附图说明
图 1 是本发明实施例中一种数据存储方法的流程图;
图 1是本发明实施例中一种数据查找方法的流程图;
图 3 是本发明实施例中一种数据存储装置的结构示意图; 图 4是本发明实施例中一种数据查找装置的结构示意图。 具体实施方式
为了解决现有技术中由于性能数据随机存储而造成在海量级数据中查 询数据效率低下的问题, 本发明提供了一种数据存储、 查找方法及装置, 以下结合附图以及实施例, 对本发明进行进一步详细说明。 应当理解, 此 处所描述的具体实施例仅仅用以解释本发明, 并不限定本发明。
本发明为克服现有技术中由于性能数据采用关系数据库作为永久存储 介质 , 性能数据条件查询以及周期性地性能数据增加涉及到的随机读写带 来的大量寻址消耗, 从而引起的系统性能低下的问题, 提供一种符合性能 采集系统这样一种特定应用特色的进行性能数据的存储方法, 根据性能数 据一次写入、 多次读取的特性, 用两类文件来进行存储, 具体地, 性能文 件用来存储性能记录, 归类索引文件用来保存性能文件中的性能记录的位 置信息。 每个性能文件都配备一个归类索引文件, 归类索引文件以性能记 录归类, 而不是一条性能记录为单位来计算。 在写入性能文件前对性能记 录进行归类, 按照归类将记录顺序地追加(append )到文件尾部, 或者, 非 随机写入; 且一次写入、 多次随机查询读取; 这种算法通过在写入磁盘前 对性能数据进行归类, 使其顺序地追加到文件的末尾, 从而避免了在超大 数据文件中绝大多数的磁头移动和寻道的开销, 另外, 根据业务特征有针 对性的建立以归类, 而不是以一条性能数据为单位的索引方法, 在保证高 写入性能的同时, 也大大提升了随机查询的效率, 使得查询的数据较为集 中从而提高命中率, 减少 10操作, 降低了查找的复杂性, 同时索引本身的 空间开销也非常小; 在索引规模和复杂性以及查找效率上取得平衡。
如图 1所示, 本发明实施例涉及一种数据存储方法, 包括以下步驟: 步驟 S101 , 将每个数据采集周期内采集的性能数据按业务特征分类存 储在性能文件中不同的性能数据归类中; 本步驟中, 每个采集周期内或者为数据的采集时间点或时间段内采集 的性能数据都储存在同一个性能文件中, 不同采集周期内采集的性能数据 存储在不同的性能文件中。 这里, 性能数据也可以称为性能记录。
在存储采集的性能数据之前, 首先需要对存储在性能文件中的性能数 据进行归类设置。 由于采集的每一条性能数据都带有性能记录标识, 因此, 可以根据性能纪录标识对所有性能数据进行归类, 即: 将性能数据分成不 同的性能数据归类。 归类的方式根据业务特征来制定, 原则上尽量保证每 个归类中记录的个数平均分配, 且一个性能记录仅能隶属于一个归类。 一 条性能数据指的是某个采集点的性能数据, 归类的方式根据业务特征来制 定, 例如: 可以根据采集点编号的简单运算、 采集点所在的设备 ΙΡ、 采集 点所在的设备名称、 采集点所在设备的框号、 采集点所在设备的槽位等, 但是要保证一个采集点上的性能数据仅能隶属于一个归类。
在进行归类设置之后, 为了保证性能文件随机读取的性能, 还需要为 每个性能文件配备一个归类索引文件, 用来存放性能文件中性能记录归类 的索引, 也就是位置信息。 为了保证性能文件与归类索引文件的对应关系, 需要设置好性能文件名称和对应的归类索引文件名称的对应关系; 为了保 证能快速找到性能文件对应的归类索引文件, 两个文件名称作好约定, 例 如: 性能文件为 *****.dat , 那么索引文件名称为 *****.idx, 除后缀名外, 文件名称一致, 当然还可以选择其它的对应方式。
按照归类依次存储所有性能数据: 对于每一类性能数据归类, 依次在 性能文件中储存该归类的剩余记录, 即: 属于同一性能数据归类中的性能 数据按照数据采集的前后顺序依次存入。 所有归类存储完毕, 则性能文件 存储完毕。
步驟 S102, 将每个所述性能数据归类对应的索引信息存储在与所述性 能文件对应的归类索引文件中。 本步驟中, 每一个性能文件都有一个与其对应的归类索引文件。
由于需要对每一类性能数据归类进行识别, 因此, 需要为每个归类定 义归类业务类别标识, 标识的命名以能够快速判断一个性能数据是否隶属 于该归类。 例如: 假设采集点编号为 Entryid— i— s_p (性能记录标识), 其中 i为设备 ip地址, 字串, 例如 10.32.35.67, s为槽位号, 为 1到 64, p为端 口号为 1到 32, 采集点形如: Entryid_10.32.35.67_l_l。 如果选择一个槽位 作为一个归类, 归类业务类别标识为 grp— i— s , i和 s的含义同上。 那么归类 业务类别标识形如 grp_10.32.35.67_l。
性能文件中的每一个性能数据归类都在归类索引文件中对应有一条索 引信息, 每类性能数据归类对应的索引信息包括: 与该性能数据归类对应 的归类业务类别标识、 该性能数据归类中第一条性能数据在性能文件中的 存储位置、 以及该性能数据归类的大小。 该性能数据归类的大小是指: 该 性能数据归类中包含的性能数据在性能文件中所占的字节数。
在存储性能数据时, 开始存储每个性能数据归类 (简称归类) 第一条 性能数据时, 在归类索引文件中与该归类对应的索引信息中存储归类业务 类别标识以及该性能数据在性能文件中的位移, 然后依次在性能文件中储 存该归类的剩余记录。 存储该性能数据归类的最后一条性能数据完毕后, 用最后一条性能数据在性能文件中的存储位移和该归类中第一条性能数据 在性能文件中的存储位移求差, 所得差值作为该性能数据归类的大小存入 上述索引信息中。 以此方法, 对所有归类进行存储。
以上实施例与现有技术直接用关系数据库的数据库表格来保存性能记 录的方案相比, 根据采集系统的采集数据的业务特性, 用两类文件来进行 存储, 性能文件用来存储性能记录, 记录归类索引文件用来保存性能文件 中的性能记录的位置信息; 对性能记录进行归类, 保证性能记录按照归类 以追加的方式写入; 用记录归类索引文件来协助定位性能文件的相应读取 位置; 极大地提升了磁盘随机读写的性能, 从而极大地提升了系统的可用 性。
如图 2所示, 本发明实施例还涉及一种数据查找方法, 包括以下步驟: 步驟 S201 , 根据待查性能数据, 确定所述待查性能数据所属的性能数 据归类;
本步驟中, 由于采集的每一条性能数据都带有性能记录标识, 而性能 文件中的归类也是依据性能记录标识进行分类的, 因此, 根据待查性能数 据的性能记录标识, 就可以知道该待查性能数据的归类业务类别标识, 进 而可以知道该待查性能数据属于哪一类性能数据归类。
步驟 S202, 在归类索引文件中, 查找与所述性能数据归类对应的索引 信息;
步驟 S203 , 根据索引信息, 在性能文件中查找待查性能数据。
本步驟中, 具体为:
根据所述索引信息, 获取所述性能数据归类中第一条性能数据在性能 文件中的存储位置、 以及所述性能数据归类的大小;
将第一条性能数据在性能文件中的存储位置作为查询起始位置, 将第 一条性能数据在性能文件中的存储位置偏移性能数据归类大小之后所处的 位置, 作为查询结束位置, 在性能文件中查找待查性能数据。 可以采用随 机读取的方式进行查找, 也可以采用依次遍历的读取方式进行查找, 由于 已经限定了具体的查询位置, 因此, 查找速度很快, 大大提高了查找效率。
本发明上述实施例提供的方案中, 归类索引文件用来描述性能数据归 类的索引信息, 包括: 与该归类对应的归类业务类别标识、 该归类中第一 条记录在性能文件中的位移、 以及该归类的大小等。 有了这些索引信息, 读取性能记录时就可以直接定位到性能文件的相应位置, 而不需要从文件 头一直遍历寻找到文件尾进行查找, 使得查找效率高。 例如, 某个采集时 刻, 对 50 万个采集点即 50 万条性能记录来说, 假设采集点编号为 Entryid— i—s_p, 其中 i为设备 ip地址, 字串, 例如 10.32.35.67, s为槽位号, 为 1 到 64 , p 为端口号为 1 到 32 , 采集点形如: 依次为 Entryid_10.32.35.67 1 L 50万采集点分布在大约 250个设备上,也就是 250 个 IP地址上。如果选择一个槽位作为一个归类,那么归类索引共 16000条, 归类业务类别标识为 grp— i— s , i和 s的含义同上。 那么归类业务类别标识形 如 : grp— 10.32.35.67— 1 。 那 么 , Entryid— 10.32.35.67— 1—1 , Entryid_10.32.35.67_l_2, …直到 Entryid_10.32.35.67_l_32将被归类到业务 类别标识 grp— 10.32.35.67— 1 中 ; 假设现在要找采集点编号为 Entryid_10.32.35.67_l_17 的性能数据, 就可以直接定位到业务类别标识 grp— 10.32.35.67— 1的归类中。通过读取归类索引文件获取 grp— 10.32.35.67— 1 归类信息中标识的位移, 即该归类在性能文件中的起始位置, 然后根据归 类大小读出整个归类的内容, 再从其中找出 Entryid_10.32.35.67_l_17对应 的性能记录即可。 如果这 50万记录不加归类, 随机存放, 那么对某个采集 点的记录查询时间就是不确定的, 如果这个采集点存储在文件最后, 那么 就要遍历完文件才能找到, 每个记录的查找时间都是相对稳定且较快的。
本发明实施例提供的上述方案中, 以性能数据归类的方式进行存储和 查询, 而不是以每一条性能数据进行存储和查询, 使得归类索引文件, 在 占用空间和磁盘寻道中取得一个平衡, 例如: 25个性能数据属于一个归类, 与现有技术的一个性能数据属于一个归类相比, 使得索引文件的大小是现 有技术的二十五分之一, 而这个值可以根据具体应用的业务特性以及机器 的内存和一条性能记录的占用字节数来决定。
本发明实施例的方案, 性能记录的归类是按照业务特征来制定的, 能 够尽量保证每个归类的性能记录个数平均, 在索引规模和查询效率上取得 平衡, 不至于某个归类较大, 某个归类较小。 避免了较大的归类由于读取 时比较占用内存, 影响效率的问题; 同时也避免了较小的归类由于需要读 取较多的归类, 导致 10频繁引发的低效问题。 例如, 某个槽位上所有的端 口采集点作为一个性能归类, 这样每个归类包含的性能个数较为均勾。 并 且由于按照业务特征来归类, 符合业务查询特性, 也能保证在随机查询时 的命中率较高、 降低复杂性, 例如对某个槽位上的某些端口的查询在按照 槽位归类时, 只需要读取一个归类就能获取到所有合适的记录。
如图 3所示, 本发明实施例还涉及一种数据存储装置, 包括: 性能数据存储单元 301 ,用于将每个数据采集周期内采集的性能数据按 业务特征分类存储在性能文件中不同的性能数据归类中;
索引信息存储单元 302 ,用于将每类所述性能数据归类对应的索引信息 存储在与所述性能文件对应的归类索引文件中。
其中, 每类所述性能数据归类对应的索引信息包括: 与该性能数据归 类对应的归类业务类别标识、 该性能数据归类中第一条性能数据在所述性 能文件中的存储位置、 以及该性能数据归类的大小。
性能数据存储单元 301 将每一条性能数据只存储于一类性能数据归类 中; 且将属于同一性能数据归类中的性能数据按照数据采集的前后顺序依 次存入。
如图 4所示, 本发明实施例还涉及一种数据查询装置, 包括: 性能数据归类确定单元 401 , 用于根据待查性能数据,确定所述待查性 能数据所属的性能数据归类;
索引信息查找单元 402 ,用于在归类索引文件中查找与所述性能数据归 类对应的索引信息;
待查性能数据查找单元 403 , 用于根据所述索引信息,在性能文件中查 找所述待查性能数据。
其中, 待查性能数据查找单元 403还可以进一步包括: 索引信息获取子单元 4031 , 用于根据索引信息, 获取所述性能数据归 类中第一条性能数据在性能文件中的存储位置、 以及所述性能数据归类的 大小;
查找子单元 4032, 用于将第一条性能数据在所述性能文件中的存储位 置作为查询起始位置, 将所述第一条性能数据在所述性能文件中的存储位 置偏移所述性能数据归类大小之后所处的位置作为查询结束位置, 在所述 性能文件中查找所述待查性能数据。
由上述实施例可以看出, 本发明通过对性能数据归类存储在性能文件 中, 并将每类性能数据在性能文件中的存储位置存储在归类索引文件中, 这样, 查找性能数据时, 就可以在归类索引文件中查找到这一类性能数据 在性能文件中的存储位置, 进而可以快速查找到待查的性能数据, 使得查 询的数据较为集中从而提高查询效率,减少 10操作,降低了查找的复杂性。 另外, 避免了在超大数据文件中绝大多数的磁头移动和寻道的开销, 极大 地提升了磁盘随机读写的性能, 从而提升了系统的可用性。
尽管为示例目的, 已经公开了本发明的优选实施例, 本领域的技术人 员将意识到各种改进、 增加和取代也是可能的, 因此, 本发明的范围应当 不限于上述实施例。

Claims

权利要求书
1、 一种数据存储方法, 其特征在于, 该方法包括:
将每个数据采集周期内采集的性能数据按业务特征分类存储在性能文 件中不同的性能数据归类中;
将每个所述性能数据归类对应的索引信息存储在与所述性能文件对应 的归类索引文件中。
2、 根据权利要求 1所述的数据存储方法, 其特征在于, 所述性能数据 归类对应的索引信息包括: 与所述性能数据归类对应的归类业务类别标识、 所述性能数据归类中第一条性能数据在所述性能文件中的存储位置、 以及 所述性能数据归类的大小。
3、 根据权利要求 1或 2所述的数据存储方法, 其特征在于, 在将每个 数据采集周期内采集的性能数据按业务特征分类存储在性能文件中不同的 性能数据归类中时, 该方法进一步包括:
每条性能数据只存储于一类性能数据归类中; 且属于同一性能数据归 类中的性能数据按照数据采集的前后顺序依次存入。
4、 一种数据查找方法, 其特征在于, 该方法包括:
根据待查性能数据, 确定所述待查性能数据所属的性能数据归类; 在归类索引文件中, 查找与所述性能数据归类对应的索引信息; 根据所述索 !信息 , 在性能文件中查找所述待查性能数据。
5、 根据权利要求 4所述的数据查找方法, 其特征在于, 所述根据所述 索引信息, 在性能文件中查找所述待查性能数据, 包括:
根据所述索引信息, 获取所述性能数据归类中第一条性能数据在所述 性能文件中的存储位置、 以及所述性能数据归类的大小;
将所述第一条性能数据在所述性能文件中的存储位置作为查询起始位 置, 并将所述第一条性能数据在所述性能文件中的存储位置偏移所述性能 数据归类大小之后所处的位置作为查询结束位置, 在所述查询起始位置与 查询结束位置之间查找所述待查性能数据。
6、 一种数据存储装置, 其特征在于, 该装置包括: 性能数据存储单元 及索引信息存储单元; 其中,
性能数据存储单元, 用于将每个数据采集周期内采集的性能数据按业 务特征分类存储在性能文件中不同的性能数据归类中;
索引信息存储单元, 用于将每个所述性能数据归类对应的索引信息存 储在与所述性能文件对应的归类索引文件中。
7、 根据权利要求 6所述的数据存储装置, 其特征在于, 所述性能数据 归类对应的索引信息包括: 与所述性能数据归类对应的归类业务类别标识、 所述性能数据归类中第一条性能数据在所述性能文件中的存储位置、 以及 所述性能数据归类的大小。
8、 根据权利要求 6或 7所述的数据存储装置, 其特征在于, 所述性能 数据存储单元进一步用于: 将每条性能数据只存储于一类性能数据归类中; 且将属于同一性能数据归类中的性能数据按照数据采集的前后顺序依次存 入。
9、 一种数据查询装置, 其特征在于, 包括: 性能数据归类确定单元、 索引信息查找单元、 以及待查性能数据查找单元; 其中,
性能数据归类确定单元, 用于根据待查性能数据, 确定所述待查性能 数据所属的性能数据归类;
索引信息查找单元, 用于在归类索引文件中查找与所述性能数据归类 对应的索引信息;
待查性能数据查找单元, 用于根据所述索引信息, 在性能文件中查找 所述待查性能数据。
10、 根据权利要求 9所述的数据查询装置, 其特征在于, 所述待查性 能数据查找单元进一步包括: 索引信息获取子单元及查找子单元; 其中, 索引信息获取子单元, 用于根据所述索引信息, 获取所述性能数据归 类中第一条性能数据在所述性能文件中的存储位置、 以及所述性能数据归 类的大小;
查找子单元, 用于将所述第一条性能数据在所述性能文件中的存储位 置作为查询起始位置, 并将所述第一条性能数据在所述性能文件中的存储 位置偏移所述性能数据归类大小之后所处的位置作为查询结束位置, 在所 述查询起始位置与查询结束位置之间查找所述待查性能数据。
PCT/CN2012/072846 2011-06-21 2012-03-22 一种数据存储、查找方法及装置 WO2012174906A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2011101671442A CN102222099A (zh) 2011-06-21 2011-06-21 一种数据存储、查找方法及装置
CN201110167144.2 2011-06-21

Publications (1)

Publication Number Publication Date
WO2012174906A1 true WO2012174906A1 (zh) 2012-12-27

Family

ID=44778651

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/072846 WO2012174906A1 (zh) 2011-06-21 2012-03-22 一种数据存储、查找方法及装置

Country Status (2)

Country Link
CN (1) CN102222099A (zh)
WO (1) WO2012174906A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104408151A (zh) * 2014-12-03 2015-03-11 天津南大通用数据技术股份有限公司 支持用户自定义的列存数据库函数索引创建方法及装置
CN104615594A (zh) * 2013-11-01 2015-05-13 阿里巴巴集团控股有限公司 一种数据更新方法及装置
CN105426410A (zh) * 2015-11-02 2016-03-23 东软集团股份有限公司 数据采集系统和用于数据采集系统的分析方法

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222099A (zh) * 2011-06-21 2011-10-19 中兴通讯股份有限公司 一种数据存储、查找方法及装置
WO2013075306A1 (zh) * 2011-11-24 2013-05-30 华为技术有限公司 数据访问方法和装置
CN103701859A (zh) * 2013-12-04 2014-04-02 中安消技术有限公司 一种追溯视频文件来源的方法和系统
CN103745262A (zh) * 2013-12-30 2014-04-23 远光软件股份有限公司 一种数据归集方法和装置
CN103902698B (zh) * 2014-03-31 2018-04-13 北京皮尔布莱尼软件有限公司 一种数据存储系统和存储方法
CN103902701B (zh) * 2014-03-31 2017-12-29 北京皮尔布莱尼软件有限公司 一种数据存储系统和存储方法
CN105975213A (zh) * 2016-05-17 2016-09-28 成都四象联创科技有限公司 一种高效的大规模数据存储装置
CN106202416B (zh) * 2016-07-11 2018-10-02 腾讯科技(深圳)有限公司 列表数据写方法和装置、列表数据读取方法和装置
CN107656967B (zh) * 2017-08-31 2021-12-24 深圳市盛路物联通讯技术有限公司 一种场景信息处理方法及装置
CN109240607B (zh) * 2018-08-21 2022-02-18 郑州云海信息技术有限公司 一种文件读取方法和装置
CN112328544B (zh) * 2020-09-18 2022-01-11 广州中望龙腾软件股份有限公司 一种多学科仿真数据分类方法、设备及存储介质
CN112434125A (zh) * 2020-11-30 2021-03-02 中国人寿保险股份有限公司 索引结构、非结构化数据的检索方法、装置和设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040117468A1 (en) * 2002-12-12 2004-06-17 Linghsaio Wang Subscribing different quality of service by simple classification
CN101790257A (zh) * 2009-01-22 2010-07-28 大唐移动通信设备有限公司 一种存储数据的方法和网管系统
CN101840400A (zh) * 2009-03-19 2010-09-22 北大方正集团有限公司 一种多级分类检索方法及系统
CN102222099A (zh) * 2011-06-21 2011-10-19 中兴通讯股份有限公司 一种数据存储、查找方法及装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080288324A1 (en) * 2005-08-31 2008-11-20 Marek Graczynski Computer system and method for evaluating scientific institutions, professional staff and work products
US7639542B2 (en) * 2006-05-15 2009-12-29 Apple Inc. Maintenance operations for multi-level data storage cells
CN101247271A (zh) * 2008-03-24 2008-08-20 中兴通讯股份有限公司 性能数据的存储方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040117468A1 (en) * 2002-12-12 2004-06-17 Linghsaio Wang Subscribing different quality of service by simple classification
CN101790257A (zh) * 2009-01-22 2010-07-28 大唐移动通信设备有限公司 一种存储数据的方法和网管系统
CN101840400A (zh) * 2009-03-19 2010-09-22 北大方正集团有限公司 一种多级分类检索方法及系统
CN102222099A (zh) * 2011-06-21 2011-10-19 中兴通讯股份有限公司 一种数据存储、查找方法及装置

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104615594A (zh) * 2013-11-01 2015-05-13 阿里巴巴集团控股有限公司 一种数据更新方法及装置
CN104615594B (zh) * 2013-11-01 2018-04-03 阿里巴巴集团控股有限公司 一种数据更新方法及装置
CN104408151A (zh) * 2014-12-03 2015-03-11 天津南大通用数据技术股份有限公司 支持用户自定义的列存数据库函数索引创建方法及装置
CN105426410A (zh) * 2015-11-02 2016-03-23 东软集团股份有限公司 数据采集系统和用于数据采集系统的分析方法
CN105426410B (zh) * 2015-11-02 2018-11-09 东软集团股份有限公司 数据采集系统和用于数据采集系统的分析方法

Also Published As

Publication number Publication date
CN102222099A (zh) 2011-10-19

Similar Documents

Publication Publication Date Title
WO2012174906A1 (zh) 一种数据存储、查找方法及装置
US9149054B2 (en) Prefix-based leaf node storage for database system
JP5996088B2 (ja) 暗号ハッシュ・データベース
CN105224546B (zh) 数据存储和查询方法及设备
KR20190119080A (ko) 다중-스트림 저장 장치를 위한 스트림 선택
CN105677826A (zh) 一种针对海量非结构化数据的资源管理方法
CN102725752B (zh) 处理脏数据的方法及装置
CN108280229B (zh) 内存数据读写方法和装置
WO2013152678A1 (zh) 元数据查询方法和装置
US20100235359A1 (en) File retrieval method and device and time stream file processor
WO2013071882A1 (zh) 用于机群文件系统的元数据存储系统和管理方法
CN103336849A (zh) 一种数据库检索系统中提高检索速度的方法及装置
CN105574093A (zh) 一种在基于HDFS的spark-sql大数据处理系统上建立索引的方法
WO2014101420A1 (zh) 一种元数据的构建系统及其方法
WO2018095299A1 (zh) 一种时序数据管理方法、设备和装置
US10095439B2 (en) Tiered storage system, storage controller and data location estimation method
CN104881481A (zh) 一种存取海量时间序列数据的方法及装置
CN104090962A (zh) 面向海量分布式数据库的嵌套查询方法
CN109240607B (zh) 一种文件读取方法和装置
WO2013075306A1 (zh) 数据访问方法和装置
CN104850564B (zh) 数据文件的索引查找方法和系统
CN101464901A (zh) 一种对象存储设备中的对象查找方法
WO2013091167A1 (zh) 日志存储方法及系统
WO2023179787A1 (zh) 分布式文件系统的元数据管理方法和装置
CN113297171A (zh) 数据库迁移方法及装置、数据库集群

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: 12802390

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: 12802390

Country of ref document: EP

Kind code of ref document: A1