WO2015024474A1 - 基于缓存数据多线程处理的电力可靠性指标快速计算方法 - Google Patents

基于缓存数据多线程处理的电力可靠性指标快速计算方法 Download PDF

Info

Publication number
WO2015024474A1
WO2015024474A1 PCT/CN2014/084369 CN2014084369W WO2015024474A1 WO 2015024474 A1 WO2015024474 A1 WO 2015024474A1 CN 2014084369 W CN2014084369 W CN 2014084369W WO 2015024474 A1 WO2015024474 A1 WO 2015024474A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
basic
calculation
list
indicator
Prior art date
Application number
PCT/CN2014/084369
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 WO2015024474A1 publication Critical patent/WO2015024474A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the invention relates to a fast calculation method of power reliability index based on multi-thread processing of cache data, and mainly relates to an information construction application field of power reliability index analysis.
  • the low efficiency of power reliability index calculation is mainly reflected in the low speed of reading basic data from physical disk.
  • the traditional technical solution is to calculate the intermediate result of the reliability indicator by using the time interval of the business space (usually in units of days). When the user submits the reliability indicator calculation request, the calculation is based on the intermediate result of the indicator, which can be reduced when the calculation is performed. The amount of data increases the efficiency of computational responses.
  • the premise of the above-mentioned conventional technical solution application is that the basic data involved in the calculation of the power reliability index is no longer or rarely changed.
  • the basic data involved in the calculation of the power reliability index will continue to supplement the information to meet the power reliability index calculations of different dimensions.
  • the traditional technical solution can only reflect the reliability level before the completion of the calculation of the intermediate results of the last indicator, and it cannot reflect the current level of power reliability, and it is still difficult to meet the timeliness requirements of the power reliability management service. Summary of the invention
  • the present invention provides a fast calculation method of power reliability index based on cache data multi-thread processing, which utilizes data reading speed in memory and multi-thread parallel processing technology under the condition of massive basic data. , improve the efficiency of the calculation of power reliability indicators.
  • a method for quickly calculating a power reliability index based on multi-threaded processing of cache data characterized in that the method comprises the following steps:
  • the data in the data block retrieved from the calculation is averagely cut into multiple groups, and a plurality of basic indicator calculation threads and a basic indicator merge thread are created;
  • the basic indicator merge thread combines the results of the basic indicators calculated by the basic indicator calculation threads to calculate the comprehensive reliability indicators of the management units at all levels.
  • the above step (1) creates a data buffer in the memory, and buffering the basic data includes the following steps: (1 a) dividing the service data type, creating a service memory object in the data cache, and initializing; the initialized information includes the specified object data. Source, fields to be read, data sort fields in the set data block, filter conditions used to extract data;
  • the internal data sorting manner of the basic data area in the data block is: the device registration data is sorted according to the device registration date, and the device running data is sorted according to the power failure start time.
  • the above step (2) establishes a data change buffer in each data block, and clearing the buffer includes the following steps:
  • step (3) the following steps are included:
  • (3b) traversing the data blocks of all the service memory objects, and filtering the data blocks according to the start time of the data block primary key information and the indicator calculation;
  • step (4) the following steps are included:
  • (4a) determining the number of data groups according to the maximum number of threads currently set by the system and the total number of basic data records participating in the calculation of the data block list, and the average number of basic data contained in each data group after cutting;
  • step (4b) traversing all the data blocks in the calculation data block list, and traversing the data block while creating the average data capacity of the basic data capacity as described in step (4a), if the basic data amount included in the current data block is larger than the current data When the remaining capacity of the group is used, the base data in the split data block is filled with the current data group first, and then the remaining basic data is added to the new data group; if the basic data amount contained in the current data block is smaller than the current data When the remaining capacity of the group is not split, it is added directly to the current data group; (4c) according to the number of data groups, create a plurality of basic indicator calculation threads, and form a basic indicator calculation task list; submit each set of data to the created basic indicator calculation thread, and calculate the task status setting of the basic indicator corresponding to the thread For calculation;
  • step (5) the following steps are included:
  • each basic indicator calculation thread traverses each of the basic data in the processed data group, and the data in the new list of change buffers in the corresponding data block, and judges the memory object according to the condition of the selected basic data. Whether the basic data is involved in the calculation. If the calculation is involved, the data is submitted to the basic indicator calculation unit for calculation. The calculation result is stored in the basic indicator result list. If not, the next basic data is processed until the data is completely processed. ;
  • the method of the invention caches the basic data by using multiple data blocks, designs the cache data structure according to the characteristics of the power reliability service, improves the efficiency of data retrieval during the calculation of the power reliability index, and establishes a basic data change synchronization mechanism, setting changes. Buffer, improve the efficiency of change data synchronization; use the basic data grouping in the index calculation, use the multi-threading technology to complete the calculation of the basic indicators, and finally combine the results of multiple basic indicators to calculate the reliability index results that meet the requirements. The speed of calculation of the power reliability index is guaranteed.
  • the invention adopts the technical means of multi-block cache service data, data change buffer and multi-thread processing, improves the basic data retrieval and calculation efficiency of the power reliability service, and realizes the fast calculation of the power reliability index.
  • Figure 1 is a data structure diagram of a data buffer area in the present invention
  • FIG. 1 Cooperation diagram of each functional module in the present invention
  • FIG. 3 is a flowchart of loading a cache data in an embodiment of the present invention.
  • Figure 4 Flow chart of changing data synchronization in the embodiment of the present invention.
  • FIG. 5 is a flowchart of a change buffer data merge in the embodiment of the present invention.
  • FIG. 6 is a flowchart of an indicator calculation request processing in an embodiment of the present invention.
  • FIG. 7 is a flow chart of index calculation in the embodiment of the present invention.
  • the data structure of the data buffer area is as shown in FIG. 1 , and the service memory object is created according to the service data type in the data buffer area.
  • Each business memory object includes: object basic information consisting of an attribute list, a source data table, a sort attribute, and unique identification information; the management unit, the device registration year or month, or the power failure occurrence year and month as the primary key, and the data block address indicator is a value
  • a list of data blocks consisting of key-value pairs multiple data blocks consisting of a base data area and a change buffer.
  • the data sorting mode in the basic data area of the data block is as follows: The device registration data is sorted according to the device registration date, and the device running data is sorted according to the power failure start time; the change buffer in the data block includes a new list, a modified list, and a deletion. The list is used to record the newly added basic data, the underlying data whose attributes have been modified, and the deleted basic data.
  • the technical solution further comprises a data loading module, a data updating module, an index computing task management module and an index computing module, and the cooperation relationship of each module is as shown in FIG. 2 .
  • the cardinality data in the data block base data area is uniformly loaded by the data loading module at startup, and the buffer is changed.
  • the data is read by the data update module corresponding to each data block to periodically read the data change index table record in the database, read the data information from the basic data table according to the basic data primary key of the change, and write the basic data according to the data change type. Enter a new list, modify a list, or delete a list.
  • the data update module also periodically starts the change buffer data and the basic data area data merge task, updates the basic data area to the latest basic data, and clears the change buffer.
  • the index calculation task management module is responsible for obtaining the reliability index calculation request submitted by the user from the database, converting the calculation condition input by the request into a memory object for screening the basic data condition, and traversing the data block of all the business data memory objects, according to the data block primary key.
  • the information and indicator calculation involves the start time screening data block, and the qualified data block is added to the calculation data block list; then, according to the maximum number of threads currently set by the system and the basis of the calculation in the calculation data block list
  • the total number of data records determines the number of data groups, and the average number of basic data contained in each data group after cutting, and cuts the data blocks in the calculated data block list to form multiple data groups; finally, according to the number of data groups, Create multiple base metrics calculation threads and form a base metric calculation task list.
  • Each set of data is submitted to the created base indicator calculation thread, and the base indicator calculation task status corresponding to the thread is set to calculation, and a base indicator merge thread is created.
  • the indicator calculation module is responsible for providing the basic indicator calculation and the basic indicator merge business logic, and calculating the reliability index of the plurality of basic indicator calculation threads and the basic indicator merge thread created by the task management module according to the indicator, and outputting the result.
  • FIG. 3 illustrates a cache data loading process in an embodiment of the present invention, including the following steps:
  • Step 301 Generate a service data type list that needs to be cached according to the configuration file;
  • Step 302 Obtain a service data type list iterator;
  • Step 303 Determine whether the service data type list iterator includes the next service data type, if yes, execute step 304, if not, the cache data loading ends;
  • Step 304 Create a service memory object, establish an object basic information area and an empty data block list.
  • Step 305 Initialize the service memory object basic information, including: a service memory object attribute list, a source data table, an attribute for sorting the underlying data in the data block, and a unique identifier of the business memory object;
  • Step 306 Read the basic data from the source data table of the business memory object to form a basic data set;
  • Step 307 Traverse the basic data set Data, create or join existing data blocks according to information such as the unit of basic data, and add new data block address information to the data block list;
  • Step 308 Return to step 303.
  • the present invention adds a data update module, which starts two timed execution tasks and respectively completes the changes in the source data table.
  • the data is read into the change buffer of the data block and the data of the change buffer is merged into the base data area.
  • Step 401 Read data from a data change index table in a database to form a change record set
  • Step 402 traverse the change record set, according to the change
  • the index information reads the basic data from the basic data table, and saves the changed basic data group according to the service type;
  • Step 403 Traversing the basic data in each packet in the above step, and adding to the new list, the modification list, or the deletion list of the corresponding data block change buffer according to the change type of the data.
  • FIG. 5 is a schematic diagram of the process of changing the buffer data merge in the embodiment of the present invention, including the following steps: Step 501: Obtain a list of service memory objects of the change buffer;
  • Step 502 Determine whether there is a next service memory object, if yes, execute step 503, and if not, end;
  • Step 503 Obtain a data block list of the foregoing service memory object.
  • Step 504 Determine whether there is a next data block, if yes, execute step 505, if not, execute step 502;
  • Step 505 Obtain a new list in the data block change buffer.
  • Step 506 Traversing the above new list, adding data in the list to the basic data area of the existing or new data block;
  • Step 507 Acquire a modified list in the data block change buffer.
  • Step 508 traversing the modified list to modify basic data in the basic data area of the data block;
  • Step 509 Acquire a deleted list in the data block change buffer;
  • Step 510 Traverse the above deletion list, and delete the corresponding basic data in the basic data area of the data block.
  • the above three processing flows, cache data loading, change data synchronization, and change buffer data merging jointly realize that the basic data in all data blocks of the data buffer can be consistent with the data in the source data table in time, thereby ensuring the calculation of the index.
  • the integrity and accuracy of the underlying data The setting of the change buffer solves the problem that updating the data changes directly to the basic data area of the data block requires more business logic processing, which is inefficient and cannot satisfy a large number of data changes.
  • the data in the change buffer is also involved in the corresponding index calculation, and the accuracy of the guaranteed index calculation results.
  • FIG. 6 is a schematic diagram of a process for processing an index calculation request in an embodiment of the present invention, including the following steps: Step 601: Acquire an index calculation request from a database;
  • Step 602 Generate a memory object for filtering basic data according to the condition information included in the index calculation request.
  • Step 603 According to the filter condition memory object generated in the above step 602, the data block participating in the calculation is selected from the data buffer area, and a calculation data block list is formed;
  • Step 604 Determine the number of data groups and the amount of basic data included in each data group according to the maximum number of threads currently set by the system and the amount of basic data in the list of calculated data blocks generated in step 603 above;
  • Step 605 cutting data blocks in the calculation data block list according to the determined number of data groups and the number of basic data included, to form a corresponding data group;
  • Step 606 Create a plurality of basic indicator calculation threads according to the number of data groups, and form a basic indicator calculation task list. Submit each data group to the created basic indicator calculation thread, and set the basic indicator calculation task status corresponding to the thread to the calculation, and create a basic indicator merge thread; Step 607: Each basic indicator calculation thread traverses the basic data in the corresponding data group, completes the calculation of the basic indicator, and updates the execution status of the basic indicator calculation task executed by the basic index calculation thread according to the execution situation;
  • Step 608 The basic indicator merge thread periodically accesses each basic indicator to calculate the execution status of the thread calculation task
  • Step 609 It is determined whether all the calculation tasks corresponding to the basic index calculation thread are completed, if not all are completed, step 610 is performed, and if all are completed, step 611 is performed;
  • Step 610 Sleep 1s, return to step 609;
  • Step 611 Combine the basic indicator results returned by the multiple threads, calculate and generate a unit reliability comprehensive index, and write a reliability indicator result list;
  • Step 612 Write the unit reliability comprehensive index of each level into the database according to the data of the reliability index result list, and feed back to the user.
  • FIG. 7 illustrates a flow of calculating an indicator in an embodiment of the present invention, including the following steps:
  • Step 701 Acquire an basic data iterator in the data group, where the iterator includes the basic data in the basic data area of each data block in the data group, and the iteration of the basic data in the newly added list in the change buffer;
  • Step 702 Determining whether there is a next piece of data in the base data iterator, if yes, executing step 703, and if not, ending;
  • Step 703 Read the basic data of the strip
  • Step 704 Determine whether the basic data of the strip exists in the modified list of the buffer, if yes, go to step 705, if not, go to step 706;
  • Step 705 Read the basic data in the change buffer modification list, instead of the data in step 703;
  • Step 706 Whether the basic data exists in the delete list of the buffer, if yes, execute step 702, if If not, proceed to step 707;
  • Step 707 Determine whether the basic data meets the user submission calculation condition. If yes, perform step 708. If not, perform step 702.
  • the embodiment of the invention caches the basic data by using multiple data blocks, designs the cache data structure according to the characteristics of the power reliability service, improves the efficiency of data retrieval during the calculation of the power reliability index, and establishes a basic data change synchronization mechanism, setting changes. Buffer, improve the efficiency of change data synchronization; use the basic data grouping in the index calculation, use the multi-threading technology to complete the calculation of the basic indicators, and finally combine the results of multiple basic indicators to calculate the reliability index results that meet the requirements. The speed of calculation of the power reliability index is guaranteed.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

基于缓存数据多线程处理的电力可靠性指标快速计算方法,其方法解决了电力可靠性指标分析计算效率过低的问题。该方法包括:在内存中创建数据缓存区,按业务数据类型划分,以管理单位、设备注册年月或停电发生年月为主键建立数据块;在每个数据块中建立变更缓冲区,记录数据变更,并定时将变更缓冲区数据与基础数据合并;将指标计算所涉及的数据平均分配给多个线程进行基础指标计算,然后将每个线程的基础指标计算结果合并,计算各级管理单位可靠性综合指标。采用多数据块缓存业务数据、数据变更缓冲区和多线程处理的技术手段,提高了电力可靠性业务基础数据检索和计算效率,从而实现了电力可靠性指标的快速计算。

Description

说 明 书 基于緩存数据多线程处理的电力可靠性指标快速计算方法 技术领域
本发明涉及一种基于緩存数据多线程处理的电力可靠性指标快速计算方 法, 主要针对电力可靠性指标分析的信息化建设应用领域。
背景技术
电网规模不断扩大, 电力可靠性指标计算所涉及的基础数据随之快速增长, 电力可靠性指标计算响应效率低下的问题突显。 同时, 随着电力可靠性管理业 务在时效性方面的要求不断提高, 指标计算效率与业务管理时效性要求两者之 间的矛盾越来越尖锐。
在海量基础数据的条件下, 电力可靠性指标计算效率低下主要体现在从物 理磁盘读取基础数据的速度较低。 传统的技术解决方案是利用业务空间时间定 时(通常以天为单位)计算出可靠性指标中间结果, 当用户提交可靠性指标计算 请求时, 基于指标中间结果进行计算, 可以降低计算时所读取的数据量, 提高 计算响应效率。
但是, 上述传统的技术解决方案应用的前提条件是电力可靠性指标计算所 涉及的基础数据产生后不再或极少发生变更。 但在目前电力可靠性管理模式下, 电力可靠性指标计算所涉及到的基础数据产生后仍会不断地对其进行信息的补 充完善, 以满足不同維度的电力可靠性指标计算。 此外, 传统的技术解决方案 只能反映最后一次指标中间结果计算完成前的可靠性水平, 不能反映截止当前 时间电力可靠性水平, 仍难以满足电力可靠性管理业务在时效性方面的要求。 发明内容
为了解决上述问题, 本发明提供了一种基于緩存数据多线程处理的电力可 靠性指标快速计算方法, 利用内存中的数据读取速度和多线程并行处理的技术 手段, 在海量基础数据的条件下, 提高了电力可靠性指标计算的效率。
本发明的技术方案如下: 一种基于緩存数据多线程处理的电力可靠性指标快速计算方法, 其特征在 于, 该方法包括以下步骤:
( 1 ) 在内存中创建数据緩存区, 按业务数据类型划分, 以管理单位、 设备 注册年月或停电发生年月为主键建立数据块, 緩存基础数据;
(2)在每个数据块中建立变更緩冲区, 记录发生变更的数据, 并定时将变 更緩冲区数据与数据块中基础数据合并, 清空变更緩冲区;
(3)根据用户提交的可靠性指标计算请求所输入的条件, 在数据緩存区中 检索参与计算的数据块;
(4) 根据系统当前设定的最大线程数, 将检索出参与计算的数据块中数据 平均切割成多组, 并创建多个基础指标计算线程和一个基础指标合并线程;
(5)所有基础指标计算线程完成基础指标计算后, 由基础指标合并线程将 各基础指标计算线程计算出的基础指标结果进行合并, 计算各级管理单位可靠 性综合指标。
上述步骤 (1 ) 在内存中创建数据緩存区, 緩存基础数据包括以下步骤: ( 1 a ) 按业务数据类型划分, 在数据緩存区中创建业务内存对象, 并初始 化; 初始化的信息包括指定对象数据来源、 所需要读取的字段、 设定数据块内 数据排序字段、 抽取数据所用的过滤条件;
( 1 b ) 从外部数据源读取基础数据, 同时按管理单位、 注册日期或停电时 间进行排序, 在内存中形成原始数据记录集;
( 1 c ) 遍历步骤(1 b)中形成的原始数据记录集中的数据, 根据管理单位、 设备注册年月或停电发生年月新建数据块, 或将数据写入已有的数据块;
( 1 d ) 建立由管理单位、 设备注册年月或停电发生年月形成的主键与数据 块地址指针的数据块列表。
上述步骤 (1 ) 中, 所述的数据块中基础数据区内部数据排序方式为: 设备 注册数据按设备注册日期排序, 设备运行数据按停电开始时间排序。 上述步骤 (2) 在每个数据块中建立数据变更緩冲区, 清空緩冲区包括以下 步骤:
(2a ) 在每个数据块中建立数据变更緩冲区, 在变更緩冲区中创建三个列 表分别为新增列表、 修改列表和删除列表;
(2c ) 定时根据外部数据源提供的基础数据变更信息, 将发生变更的基础 数据按变更类型分别读取至新增列表、 修改列表和删除列表;
(2d ) 定时将新增列表、 修改列表和删除列表中的数据与数据块中基础数 据进行合并;
(2e) 清空新增列表、 修改列表和删除列表。
上述步骤 (3) 中, 包括如下步骤:
(3a ) 从数据库中获取用户提交的可靠性指标计算请求, 并将其转换成筛 选基础数据条件的内存对象;
(3b ) 遍历所有业务内存对象的数据块, 依据数据块主键信息和指标计算 所涉及的起始时间筛选数据块;
(3c ) 将筛选出的参与计算的数据块通过地址指针的方式添加至计算数据 块列表中。
上述步骤 (4) 中, 包括以下步骤:
(4a ) 根据系统当前设定的最大线程数和计算数据块列表中参与计算的基 础数据总记录数确定数据组的数目, 以及切割后每个数据组所含基础数据的平 均数量;
(4b ) 遍历计算数据块列表中所有数据块, 遍历数据块的同时创建基础数 据容量为步骤(4a)中所述平均数量的数据组, 如果当前数据块中所包含的基础 数据量大于当前数据组剩余容量时, 则拆分数据块中的基础数据先将当前数据 组填充满, 再将剩余的基础数据添加至新的数据组中; 如果当前数据块中所包 含的基础数据量小于当前数据组剩余容量时则不进行拆分, 直接将其添加至当 前数据组中; (4c ) 根据数据组的数量, 创建多个基础指标计算线程, 并形成基础指标 计算任务列表; 将每组数据提交至所创建的基础指标计算线程, 且将线程对应 的基础指标计算任务状态设置为计算中;
(4d ) 创建一个基础指标合并线程。
上述步骤 (5) 中, 包括以下步骤:
(5a ) 每个基础指标计算线程遍历所处理的数据组中每一条基础数据, 以 及相应数据块中的变更緩冲区新增列表中的数据, 并根据歸选基础数据条件的 内存对象判断该条基础数据是否参与计算, 如果参与计算则将该条数据提交基 础指标计算单元进行计算, 计算结果存入基础指标结果列表中, 如果不参与则 处理下一条基础数据, 直至该组数据全部处理完成;
(5b ) 每个基础指标计算线程完成后, 将该线程对应的计算任务状态设置 为完成;
(5c ) 遍历基础指标计算任务列表中的任务, 判断所有任务是否都已经执 行完成, 如果没有全部完成则休眠 1秒钟再后执行步骤 (5b), 如果全部完成则 执行步骤 (5d ) ;
(5d ) 遍历基础指标结果列表中的每一条结果记录, 将同一单位的结果记 录中的基础指标进行合并, 计算该管理单位的可靠性综合指标, 并将全部指标 结果写入可靠性指标结果列表中;
(5e) 将可靠性指标结果列表中的指标结果写入数据库, 反馈给用户。 本发明所达到的有益效果:
本发明的方法通过多数据块对基础数据进行緩存, 根据电力可靠性业务特 点设计了緩存数据结构, 提高了电力可靠性指标计算时数据检索的效率; 并建 立了基础数据变更同步机制, 设置变更緩冲区, 提高了变更数据同步的效率; 指标计算时采用基础数据分组, 利用多线程技术完成基础指标的计算, 最后对 多个基础指标结果进行合并, 计算出满足要的可靠性指标结果, 保证了电力可 靠性指标计算的速度。 本发明采用多数据块緩存业务数据、 数据变更緩冲区和多线程处理的技术 手段, 提高了电力可靠性业务基础数据检索和计算效率, 从而实现了电力可靠 性指标的快速计算。
附图说明
图 1 : 本发明中的数据緩存区数据结构图;
图 2 : 本发明中各功能模块协作关系图;
图 3 : 本发明实施例中的緩存数据加载流程图;
图 4 : 本发明实施例中的变更数据同步流程图;
图 5 : 本发明实施例中的变更緩冲数据合并流程图;
图 6 : 本发明实施例中的指标计算请求处理流程图;
图 7 : 本发明实施例中的指标计算流程图。
具体实施方式
下面结合附图对本发明作进一步描述。 以下实施例仅用于更加清楚地说明 本发明的技术方案, 而不能以此来限制本发明的保护范围。
数据緩存区的数据结构如图 1所示, 在数据緩存区中按业务数据类型划分, 创建业务内存对象。 每个业务内存对象包含: 由属性列表、 源数据表、 排序属 性、 唯一标识信息组成的对象基础信息; 由管理单位、 设备注册年月或停电发 生年月为主键, 数据块地址指标为值的键值对组成的数据块列表; 由基础数据 区和变更緩冲区组成的多个数据块。
其中: 数据块中的基础数据区内数据排序方式为: 设备注册数据按设备注 册日期排序, 设备运行数据按停电开始时间排序; 数据块中的变更緩冲区包括 新增列表、 修改列表和删除列表, 分别用于记录新增的基础数据、 属性发生修 改的基础数据和被删除的基础数据。
本技术方案中除数据緩存区外, 还包括数据加载模块、 数据更新模块、 指 标计算任务管理模块和指标计算模块组成, 各模块协作关系如图 2 所示。 数据 块基础数据区中的基数数据在启动时由数据加载模块统一加载, 变更緩冲区中 的数据由每个数据块对应的数据更新模块定时读取数据库中的数据变更索引表 记录, 根据发生变更的基础数据主键从基础数据表中读取数据信息, 并根据数 据变更类型将基础数据写入新增列表、 修改列表或删除列表。 数据更新模块还 定时启动变更緩冲区数据与基础数据区数据合并任务, 更新基础数据区中, 使 之为最新的基础数据, 并清空变更緩冲区。
指标计算任务管理模块负责从数据库中获取用户提交的可靠性指标计算请 求, 将请求所输入的计算条件转换成筛选基础数据条件的内存对象, 遍历所有 业务数据内存对象的数据块, 依据数据块主键信息和指标计算所涉及的起始时 间筛选数据块, 并将符合条件的数据块添加至计算数据块列表中; 然后, 根据 系统当前设定的最大线程数和计算数据块列表中参与计算的基础数据总记录数 确定数据组的数目, 以及切割后每个数据组所含基础数据的平均数量, 并切割 计算数据块列表中的数据块, 形成多个数据组; 最后, 根据数据组的数量, 创 建多个基础指标计算线程, 并形成基础指标计算任务列表。 将每组数据提交至 所创建的基础指标计算线程, 且将线程对应的基础指标计算任务状态设置为计 算中, 同时创建一个基础指标合并线程。
指标计算模块负责提供基础指标计算和基础指标合并业务逻辑, 根据指标 计算任务管理模块所创建的多个基础指标计算线程和基础指标合并线程完成可 靠性指标计算, 并输出结果。
以下结合附图 3至图 6, 对本发明的技术方案进行清楚、 完整的描述。 图 3 示意了本发明实施例中的緩存数据加载流程, 包括如下步骤:
步骤 301 : 根据配置文件, 生成需要进行数据緩存的业务数据类型列表; 步骤 302 : 获取业务数据类型列表迭代器;
步骤 303 : 判断业务数据类型列表迭代器中是否包含下一个业务数据类型, 如果有则执行步骤 304, 如果没有则緩存数据加载结束;
步骤 304: 创建业务内存对象, 建立对象基础信息区和空的数据块列表; 步骤 305 :初始化业务内存对象基础信息, 包括:业务内存对象的属性列表、 源数据表、 用于数据块内基础数据排序的属性和业务内存对象唯一标识; 步骤 306: 从业务内存对象的源数据表中读取基础数据, 形成基础数据集; 步骤 307 : 遍历基础数据集中的数据, 根据基础数据的单位等信息创建或加 入已有的数据块中, 并将新的数据块地址信息添加至数据块列表中;
步骤 308 : 返回步骤 303。
为了保持数据块中的基础数据始终为最新的业务数据, 与源数据保持一致, 本发明中添加了数据更新模块, 该模块启动两个定时执行的任务, 分别完成将 源数据表中发生变更的数据读取至数据块的变更緩冲区中和将变更緩冲区的数 据合并至基础数据区中。
图 4示意了本发明实施例中的变更数据同步流程, 包括如下步骤: 步骤 401 : 从数据库中的数据变更索引表中读取数据, 形成变更记录集; 步骤 402 : 遍历变更记录集, 根据变更索引信息从基础数据表中读取基础数 据, 并根据按业务类型将变更后的基础数据分组保存;
步骤 403 : 遍历上述步骤中每个分组内的基础数据, 根据该数据的变更类型 分别添加至相应数据块变更緩冲区的新增列表、 修改列表或删除列表中。
图 5示意了本发明实施例中的变更緩冲数据合并流程, 包括如下步骤: 步骤 501 : 获取变更緩冲区的业务内存对象列表;
步骤 502 : 判断是否存在下一个业务内存对象, 如果存在则执行步骤 503, 如果不存在则结束;
步骤 503 : 获取上述业务内存对象的数据块列表;
步骤 504: 判断是否存在下一个数据块, 如果存在则执行步骤 505, 如果不 存在则执行步骤 502 ;
步骤 505 : 获取数据块变更緩冲区中的新增列表;
步骤 506: 遍历上述新增列表, 将列表中的数据添加至已有或新数据块的基 础数据区; 步骤 507 : 获取数据块变更緩冲区中的修改列表;
步骤 508 : 遍历上述修改列表, 修改该数据块中基础数据区中的基础数据; 步骤 509 : 获取数据块变更緩冲区中的删除列表;
步骤 510 : 遍历上述删除列表, 删除该数据块中基础数据区中对应的基础数 据。
上述三个处理流程, 緩存数据加载、 变更数据同步、 变更緩冲数据合并共 同实现了数据緩存区所有数据块中的基础数据能够及时与源数据表中的数据保 持一致的目的, 保证了指标计算时的基础数据的完整性与准确性。 变更緩冲区 的设置解决了直接将数据的变化更新至数据块的基础数据区中需要进行较多的 业务逻辑处理, 效率较低, 无法满足大量的数据变化。 同时, 在指标计算的过 程中, 变更緩冲区中的数据也参与相应的指标计算, 保证的指标计算结果的准 确性。
图 6示意了本发明实施例中的指标计算请求处理流程, 包括如下步骤: 步骤 601 : 从数据库中获取指标计算请求;
步骤 602 : 根据指标计算请求中所包含的条件信息, 生成用于筛选基础数据 的内存对象;
步骤 603 : 依据上述步骤 602生成的筛选条件内存对象, 从数据緩存区中筛 选出参与计算的数据块, 并形成计算数据块列表;
步骤 604:根据系统当前设定的最大线程数和上述步骤 603中生成的计算数 据块列表中的基础数据量大小, 确定数据组的数目以及每个数据组所包含的基 础数据数量;
步骤 605 :根据确定的数据组的数目和所含基础数据的数量对计算数据块列 表中的数据块进行切割, 形成相应的数据组;
步骤 606: 根据数据组的数量, 创建多个基础指标计算线程, 并形成基础指 标计算任务列表。 将每个数据组提交至所创建的基础指标计算线程, 且将线程 对应的基础指标计算任务状态设置为计算中, 同时创建一个基础指标合并线程; 步骤 607: 每个基础指标计算线程遍历相应数据组中的基础数据, 完成基础 指标计算, 并根据执行情况, 更新本基础指标计算线程所执行基础指标计算任 务的执行状态;
步骤 608:基础指标合并线程定时访问每个基础指标计算线程计算任务的执 行状态;
步骤 609: 判断所有基础指标计算线程所对应的计算任务是否全部完成, 如 果没有全部完成, 则执行步骤 610, 如果全部完成, 则执行步骤 611;
步骤 610: 休眠 1s, 返回步骤 609;
步骤 611: 将多个线程返回的基础指标结果进行合并, 并计算生成各级单位 可靠性综合指标, 写可靠性指标结果列表;
步骤 612:根据可靠性指标结果列表的数据将各级单位可靠性综合指标写入 数据库, 以反馈给用户。
图 7示意了本发明实施例中的指标计算流程, 包括如下步骤:
步骤 701: 获取数据组中基础数据迭代器, 该迭代器包含了对该数据组中各 数据块基础数据区中基础数据, 以及变更緩冲区中新增列表中基础数据的迭代; 步骤 702: 判断基础数据迭代器中是否存在下一条数据, 如果存在, 则执行 步骤 703, 如果不存在, 则结束;
步骤 703: 读取该条基础数据;
步骤 704: 判断该条基础数据在緩冲区的修改列表中是否存在, 如果存在, 则执行步骤 705, 如果不存在, 则执行步骤 706;
步骤 705:读取变更緩冲区修改列表中的基础数据,替代步骤 703中的数据; 步骤 706: 该条基础数据在緩冲区的删除列表中是否存在, 如果存在, 则执 行步骤 702, 如果不存在, 则执行步骤 707;
步骤 707: 判断该基础数据是否符合用户提交计算条件, 如果符合, 则执行 步骤 708, 如果不符合, 则执行步骤 702。 本发明实施例通过多数据块对基础数据进行緩存, 根据电力可靠性业务特 点设计了緩存数据结构, 提高了电力可靠性指标计算时数据检索的效率; 并建 立了基础数据变更同步机制, 设置变更緩冲区, 提高了变更数据同步的效率; 指标计算时采用基础数据分组, 利用多线程技术完成基础指标的计算, 最后对 多个基础指标结果进行合并, 计算出满足要的可靠性指标结果, 保证了电力可 靠性指标计算的速度。 以上所述对本发明的目的、 技术方案和具体实施方式进行了详细说明, 所 应理解的是, 以上所述并不用以限制本发明, 凡在本发明的精神和原则之内, 所做的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。

Claims

权 利 要 求 书
1.一种基于緩存数据多线程处理的电力可靠性指标快速计算方法, 其特征 在于, 该方法包括以下步骤:
(1) 在内存中创建数据緩存区, 按业务数据类型划分, 以管理单位、 设备 注册年月或停电发生年月为主键建立数据块, 緩存基础数据;
(2)在每个数据块中建立变更緩冲区, 记录发生变更的数据, 并定时将变 更緩冲区数据与数据块中基础数据合并, 清空变更緩冲区;
(3)根据用户提交的可靠性指标计算请求所输入的条件, 在数据緩存区中 检索参与计算的数据块;
(4) 根据系统当前设定的最大线程数, 将检索出参与计算的数据块中数据 平均切割成多组, 并创建多个基础指标计算线程和一个基础指标合并线程;
(5)所有基础指标计算线程完成基础指标计算后, 由基础指标合并线程将 各基础指标计算线程计算出的基础指标结果进行合并, 计算各级管理单位可靠 性综合指标。
2.根据权利要求 1 所述的基于緩存数据多线程处理的电力可靠性指标快速 计算方法, 其特征在于, 上述步骤 (1) 在内存中创建数据緩存区, 緩存基础数 据包括以下步骤:
(1a) 按业务数据类型划分, 在数据緩存区中创建业务内存对象, 并初始 化; 初始化的信息包括指定对象数据来源、 所需要读取的字段、 设定数据块内 数据排序字段、 抽取数据所用的过滤条件;
(1b) 从外部数据源读取基础数据, 同时按管理单位、 注册日期或停电时 间进行排序, 在内存中形成原始数据记录集;
(1c) 遍历步骤(1b)中形成的原始数据记录集中的数据, 根据管理单位、 设备注册年月或停电发生年月新建数据块, 或将数据写入已有的数据块;
(1d) 建立由管理单位、 设备注册年月或停电发生年月形成的主键与数据 块地址指针的数据块列表。
3. 根据权利要求 1所述的基于緩存数据多线程处理的电力可靠性指标快速 计算方法, 其特征在于, 上述步骤 (1 ) 中, 所述的数据块中基础数据区内部数 据排序方式为: 设备注册数据按设备注册日期排序, 设备运行数据按停电开始 时间排序。
4.根据权利要求 1 所述的基于緩存数据多线程处理的电力可靠性指标快速 计算方法, 其特征在于, 上述步骤 (2) 在每个数据块中建立数据变更緩冲区, 清空緩冲区包括以下步骤:
(2a ) 在每个数据块中建立数据变更緩冲区, 在变更緩冲区中创建三个列 表分别为新增列表、 修改列表和删除列表;
(2c ) 定时根据外部数据源提供的基础数据变更信息, 将发生变更的基础 数据按变更类型分别读取至新增列表、 修改列表和删除列表;
(2d ) 定时将新增列表、 修改列表和删除列表中的数据与数据块中基础数 据进行合并;
(2e) 清空新增列表、 修改列表和删除列表。
5. 根据权利要求 1所述的基于緩存数据多线程处理的电力可靠性指标快速 计算方法, 其特征在于, 上述步骤 (3) 中, 包括如下步骤:
(3a ) 从数据库中获取用户提交的可靠性指标计算请求, 并将其转换成筛 选基础数据条件的内存对象;
(3b ) 遍历所有业务内存对象的数据块, 依据数据块主键信息和指标计算 所涉及的起始时间筛选数据块;
(3c ) 将筛选出的参与计算的数据块通过地址指针的方式添加至计算数据 块列表中。
6. 根据权利要求 1所述的基于緩存数据多线程处理的电力可靠性指标快速 计算方法, 其特征在于, 上述步骤 (4) 中, 包括以下步骤:
(4a ) 根据系统当前设定的最大线程数和计算数据块列表中参与计算的基 础数据总记录数确定数据组的数目, 以及切割后每个数据组所含基础数据的平 均数量;
(4b ) 遍历计算数据块列表中所有数据块, 遍历数据块的同时创建基础数 据容量为步骤(4a)中所述平均数量的数据组, 如果当前数据块中所包含的基础 数据量大于当前数据组剩余容量时, 则拆分数据块中的基础数据先将当前数据 组填充满, 再将剩余的基础数据添加至新的数据组中; 如果当前数据块中所包 含的基础数据量小于当前数据组剩余容量时则不进行拆分, 直接将其添加至当 前数据组中;
(4c ) 根据数据组的数量, 创建多个基础指标计算线程, 并形成基础指标 计算任务列表; 将每组数据提交至所创建的基础指标计算线程, 且将线程对应 的基础指标计算任务状态设置为计算中;
(4d ) 创建一个基础指标合并线程。
7. 根据权利要求 1所述的基于緩存数据多线程处理的电力可靠性指标快速 计算方法, 其特征在于, 上述步骤 (5) 中, 包括以下步骤:
(5a ) 每个基础指标计算线程遍历所处理的数据组中每一条基础数据, 以 及相应数据块中的变更緩冲区新增列表中的数据, 并根据筛选基础数据条件的 内存对象判断该条基础数据是否参与计算, 如果参与计算则将该条数据提交基 础指标计算单元进行计算, 计算结果存入基础指标结果列表中, 如果不参与则 处理下一条基础数据, 直至该组数据全部处理完成;
(5b ) 每个基础指标计算线程完成后, 将该线程对应的计算任务状态设置 为完成;
(5c ) 遍历基础指标计算任务列表中的任务, 判断所有任务是否都已经执 行完成, 如果没有全部完成则休眠 1秒钟再后执行步骤 (5b), 如果全部完成则 执行步骤 (5d ) ;
(5d ) 遍历基础指标结果列表中的每一条结果记录, 将同一单位的结果记 录中的基础指标进行合并, 计算该管理单位的可靠性综合指标, 并将全部指标 结果写入可靠性指标结果列表中;
(5e) 将可靠性指标结果列表中的指标结果写入数据库, 反馈给用户。
PCT/CN2014/084369 2013-08-23 2014-08-14 基于缓存数据多线程处理的电力可靠性指标快速计算方法 WO2015024474A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310373229.5A CN103488684B (zh) 2013-08-23 2013-08-23 基于缓存数据多线程处理的电力可靠性指标快速计算方法
CN201310373229.5 2013-08-23

Publications (1)

Publication Number Publication Date
WO2015024474A1 true WO2015024474A1 (zh) 2015-02-26

Family

ID=49828910

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/084369 WO2015024474A1 (zh) 2013-08-23 2014-08-14 基于缓存数据多线程处理的电力可靠性指标快速计算方法

Country Status (2)

Country Link
CN (1) CN103488684B (zh)
WO (1) WO2015024474A1 (zh)

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488684B (zh) * 2013-08-23 2016-12-28 国家电网公司 基于缓存数据多线程处理的电力可靠性指标快速计算方法
US9218185B2 (en) 2014-03-27 2015-12-22 International Business Machines Corporation Multithreading capability information retrieval
US9804846B2 (en) 2014-03-27 2017-10-31 International Business Machines Corporation Thread context preservation in a multithreading computer system
US9417876B2 (en) 2014-03-27 2016-08-16 International Business Machines Corporation Thread context restoration in a multithreading computer system
US9594660B2 (en) 2014-03-27 2017-03-14 International Business Machines Corporation Multithreading computer system and program product for executing a query instruction for idle time accumulation among cores
US10102004B2 (en) 2014-03-27 2018-10-16 International Business Machines Corporation Hardware counters to track utilization in a multithreading computer system
US9354883B2 (en) 2014-03-27 2016-05-31 International Business Machines Corporation Dynamic enablement of multithreading
US9921848B2 (en) 2014-03-27 2018-03-20 International Business Machines Corporation Address expansion and contraction in a multithreading computer system
CN106294371B (zh) 2015-05-15 2019-08-16 阿里巴巴集团控股有限公司 字符串值域切分方法及装置
CN106649311A (zh) * 2015-10-28 2017-05-10 阿里巴巴集团控股有限公司 一种业务数据同步方法及设备
CN106294607A (zh) * 2016-07-29 2017-01-04 北京奇虎科技有限公司 缓存数据的更新方法及更新装置
CN106528829A (zh) * 2016-11-14 2017-03-22 天津南大通用数据技术股份有限公司 一种海量数据的更新方法及装置
CN108241718B (zh) * 2016-12-27 2022-02-11 腾讯科技(北京)有限公司 一种数据并行处理的方法及服务器
CN107766554A (zh) * 2017-11-02 2018-03-06 山东浪潮通软信息科技有限公司 一种数据处理方法、装置及系统
CN110879744B (zh) * 2018-09-06 2022-08-16 第四范式(北京)技术有限公司 利用多线程执行计算图的方法和系统
CN112988858A (zh) * 2019-12-17 2021-06-18 北京达佳互联信息技术有限公司 数据处理方法、装置及设备和存储介质
CN111461895A (zh) * 2020-04-07 2020-07-28 中国建设银行股份有限公司 一种交互式的金融量化指标获取方法、装置及系统
CN112527811A (zh) * 2020-12-22 2021-03-19 山东鲁能软件技术有限公司 一种指标监控数据实时更新方法及系统
CN113051279B (zh) * 2021-03-05 2024-05-10 北京顺达同行科技有限公司 数据消息的存储方法、存储装置、电子设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887547A (zh) * 2010-06-30 2010-11-17 广西电网公司电力科学研究院 输变电设备状态检修及风险评估辅助决策系统
CN102903011A (zh) * 2012-09-25 2013-01-30 浙江图讯科技有限公司 一种用于面向工矿企业的安全生产云服务平台的海量数据处理系统
CN103488684A (zh) * 2013-08-23 2014-01-01 国家电网公司 基于缓存数据多线程处理的电力可靠性指标快速计算方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887547A (zh) * 2010-06-30 2010-11-17 广西电网公司电力科学研究院 输变电设备状态检修及风险评估辅助决策系统
CN102903011A (zh) * 2012-09-25 2013-01-30 浙江图讯科技有限公司 一种用于面向工矿企业的安全生产云服务平台的海量数据处理系统
CN103488684A (zh) * 2013-08-23 2014-01-01 国家电网公司 基于缓存数据多线程处理的电力可靠性指标快速计算方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
HAN, XIAOYUN ET AL.: "Research on Optimization of Performance Centralized Deployment-Based Information System", ELECTRIC POWER INFORMATION AND COMMUNICATION TECHNOLOGY, vol. 11, no. 7, 31 July 2013 (2013-07-31), pages 17 - 19 *

Also Published As

Publication number Publication date
CN103488684B (zh) 2016-12-28
CN103488684A (zh) 2014-01-01

Similar Documents

Publication Publication Date Title
WO2015024474A1 (zh) 基于缓存数据多线程处理的电力可靠性指标快速计算方法
CN110622152B (zh) 用于查询时间序列数据的可扩展数据库系统
US10180946B2 (en) Consistent execution of partial queries in hybrid DBMS
US9189506B2 (en) Database index management
CN107423422B (zh) 基于网格的空间数据分布式存储及检索方法和系统
Bortnikov et al. Accordion: Better memory organization for LSM key-value stores
US9311252B2 (en) Hierarchical storage for LSM-based NoSQL stores
CN102799679B (zh) 基于Hadoop的海量空间数据索引更新系统及方法
CN103176754A (zh) 一种海量小文件读取存储方法
CN110309233A (zh) 数据存储的方法、装置、服务器和存储介质
WO2018205151A1 (zh) 数据更新方法和存储装置
US20230418811A1 (en) Transaction processing method and apparatus, computing device, and storage medium
WO2015168988A1 (zh) 一种数据索引创建方法、装置及计算机存储介质
CN107665219A (zh) 一种日志管理方法及装置
Lu et al. TridentKV: A read-optimized LSM-tree based KV store via adaptive indexing and space-efficient partitioning
Chai et al. Adaptive lower-level driven compaction to optimize LSM-tree key-value stores
US10789234B2 (en) Method and apparatus for storing data
CN110858210A (zh) 数据查询方法及装置
CN115114294A (zh) 数据库存储模式的自适应方法、装置、计算机设备
CN104794567B (zh) 一种基于HBase的传染病数据管理方法
Li et al. FluteDB: An efficient and scalable in-memory time series database for sensor-cloud
CN114281989A (zh) 基于文本相似度的数据去重方法、装置及存储介质和服务器
Doekemeijer et al. Key-Value Stores on Flash Storage Devices: A Survey
CN110515897B (zh) Lsm存储系统读性能的优化方法及系统
Zhao et al. LS-AMS: An adaptive indexing structure for realtime search on microblogs

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

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

Ref document number: 14837740

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 14837740

Country of ref document: EP

Kind code of ref document: A1