CN113760894A - Data calling method and device, electronic equipment and storage medium - Google Patents

Data calling method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113760894A
CN113760894A CN202110036733.0A CN202110036733A CN113760894A CN 113760894 A CN113760894 A CN 113760894A CN 202110036733 A CN202110036733 A CN 202110036733A CN 113760894 A CN113760894 A CN 113760894A
Authority
CN
China
Prior art keywords
target
data
file
header
information
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202110036733.0A
Other languages
Chinese (zh)
Inventor
任侨
吴正轩
樊建刚
白雄雄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110036733.0A priority Critical patent/CN113760894A/en
Publication of CN113760894A publication Critical patent/CN113760894A/en
Pending legal-status Critical Current

Links

Images

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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2219Large Object storage; Management thereof

Landscapes

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

Abstract

The invention discloses a data calling method, a data calling device, electronic equipment and a storage medium, wherein the method comprises the following steps: when the triggering operation of storing the data in the target file into the database is detected, determining the target header file from a file set comprising the header file according to the list header information of the target file; determining a target list header to be read according to the list header information and a predefined list header in the target list header file, and determining column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information; sequentially reading current row data according to the index information aiming at the row data in the target file, and correspondingly storing the column data in the current row data and the target attribute name into the reusable component; and generating a data set based on the reusable components corresponding to the data of each row, and storing the data set in the database. The technical scheme of the embodiment of the invention realizes the technical effect of rapidly and conveniently storing the data in the target file into the database.

Description

Data calling method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a data calling method and device, electronic equipment and a storage medium.
Background
In the actual application process, data in the office software needs to be imported into the database, or the data in the database needs to be exported into the office software, and both the import and export processes need to be operated by the SDK of the Apache POI.
When the present invention is implemented based on the above-described embodiments, the inventors have found that the following problems occur:
data is imported or exported based on the SDK of the Apache POI, and a header needs to be identified based on a field written in the code, so that corresponding data is acquired. However, when the fields of the header are changed, for example, the field values are changed or the number of the fields is changed, the corresponding codes need to be rewritten, and then the corresponding header data is identified based on the updated codes, which has the problems of high code coupling degree and poor universality.
Disclosure of Invention
The invention provides a data calling method, a data calling device, electronic equipment and a storage medium, which can achieve the technical effect of quickly and conveniently importing or exporting data to a database under the condition of not changing program codes.
In a first aspect, an embodiment of the present invention provides a data caching method, where the method includes:
when the triggering operation of storing the data in the target file into the database is detected, determining the target header file from a file set comprising the header file according to the list header information of the target file; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header;
determining a target list header to be read according to the list header information and a predefined list header in the target list header file, and determining column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information;
sequentially reading current row data according to the index information aiming at the row data in the target file, and correspondingly storing the row data in the current row data and the target attribute name into a reusable component;
and generating a data set based on the reusable components corresponding to the data of each row, and storing the data set in the database.
In a second aspect, an embodiment of the present invention further provides a data retrieving method, where the method includes:
when detecting a trigger operation of exporting target data in a database to a target file, generating a target header file according to a target list header triggered by a user; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header;
generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information;
writing the target data filled in the attribute information of each reusable component into the file list head of the target file in sequence according to the index information; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
In a third aspect, an embodiment of the present invention further provides a data caching apparatus, where the apparatus includes:
the target header file determining module is used for determining a target header file from a file set comprising the header file according to the header information of the target file when the triggering operation of storing the data in the target file into the database is detected; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header;
a target list header information generating module, configured to determine a target list header to be read according to the list header information and a predefined list header in the target list header file, and determine column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information;
the attribute information determining module is used for sequentially reading current row data according to the index information aiming at the row data in the target file and correspondingly storing the column data in the current row data and the target attribute name into the reusable component;
and the reusable component generating module is used for generating a data set based on the reusable components corresponding to the data of each row and storing the data set in the database.
In a fourth aspect, an embodiment of the present invention further provides a data retrieving apparatus, where the apparatus includes:
the target header file generation module is used for generating a target header file according to a target list header triggered by a user when the triggering operation of exporting target data in the database to the target file is detected; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header;
the document list header generation module is used for generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information;
the data writing module is used for sequentially writing all target data filled in the attribute information of all the reusable components into the file list head of the target file according to the index information; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
In a fifth aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the data caching method and/or the data retrieval method according to any one of the embodiments of the present invention.
In a fourth aspect, the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the data caching method and/or the data retrieval method according to any one of the embodiments of the present invention.
According to the technical scheme of the embodiment of the invention, when the triggering operation of storing the data in the target file into the database is detected, the target header file is determined from the file set comprising the header file according to the header information of the target file, the target header is determined according to the header information of the target file and the predefined header in the target header file, the target attribute name corresponding to the index information and the index information of the target header in the target file is determined, after the information is determined, each row of data in the target file can be read in sequence, the row of data is written into the reusable component of the data in the current row, the row of data in the row of data corresponding to the target attribute name in the reusable component is reused, and the technical problems that corresponding program codes need to be written in the data introduced into the database in the prior art and the data introduction is complicated and complicated are solved, the technical effect of conveniently and efficiently importing the data into the database is achieved.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, a brief description is given below of the drawings used in describing the embodiments. It should be clear that the described figures are only views of some of the embodiments of the invention to be described, not all, and that for a person skilled in the art, other figures can be derived from these figures without inventive effort.
Fig. 1 is a schematic flow chart illustrating a data caching method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart illustrating a data caching method according to a second embodiment of the present invention;
fig. 3 is a schematic flow chart illustrating a data retrieving method according to a third embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a data retrieving method according to a fourth embodiment of the present invention;
fig. 5 is a schematic diagram of a data retrieving and/or caching method according to a fifth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a data caching apparatus according to a sixth embodiment of the present invention;
fig. 7 is a schematic structural diagram of a data retrieving device according to a seventh embodiment of the present invention;
fig. 8 is a schematic view of an electronic device according to an eighth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a schematic flow chart of a data caching method according to an embodiment of the present invention, where the embodiment is applicable to a case where data in a target file, such as an excel file, is imported into a database, and the method may be executed by a data caching apparatus, and the apparatus may be implemented in a form of software and/or hardware, where the hardware may be an electronic device, and optionally, the electronic device is a mobile terminal or a PC terminal, and the like.
Before the technical solution of the present embodiment is introduced, an application scenario is exemplarily described. When the uploaded data in the excel or the data in the excel file in the disk is imported into the database or other storage spaces, the method provided by the embodiment can be adopted to sequentially read each row of data in the excel, write the row of data into the reusable component, and further store the reusable component into the database, so that the technical effect of importing the data in the target file into the database is achieved.
As shown in fig. 1, the method of this embodiment includes:
s110, when the triggering operation of storing the data in the target file into the database is detected, determining the target header file from a file set comprising the header file according to the list header information of the target file; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header.
If the data in the file a needs to be read, or the data in the file a needs to be written into the database, the file a may be used as a target file, that is, a file to which the data to be written into the database belongs may be used as the target file. The list header information is the column field in the target file, colloquially, the list header information is the field in the first row and column cell in the target file. For example, the target file is an excel file, and the list header of the file includes: the item type, item price, and the like may be list header information. The header files corresponding to different service types comprise at least one, and the specific content in the header file is generated according to predefined list header information. The predefined list header information is determined according to fields concerned by different service types, for example, the fields concerned by the service type a are field a, field B and field C, and the list header file is generated based on the fields; the fields concerned by the service type B are field B, field C, and field E, and then the header file corresponding to the service type B may be generated based on the fields. In order to convert the fields into corresponding header files, reusable components javabeans can be created in advance, custom notes @ ExcelResources are added to attribute information of the reusable components javabeans, the attribute information of the notes comprises the sequence of the fields and the fields, and correspondingly, the header files are generated after the reusable components with the notes are processed. That is, the header file is a file generated after processing the JavaBean object and including the predefined list header and the predefined list header attribute name. The file collection includes a plurality of elements, each of which may be a header file. The target header file is a file that matches the list header information of the target file.
Specifically, when it is detected that a user triggers an operation of storing data in a target file in a database, or triggers an operation of storing data of a certain file in a disk in the database, the list header information of the target file may be obtained, and a target header file matched with the target file is determined from a plurality of header files stored in a file set according to the list header information.
In this embodiment, the determining a target header file from a file set including the header file according to the list header information of the target file includes: and determining a target header file from the file set according to the service type corresponding to the target file and the list header information.
It should be noted that a plurality of header files may be stored in the file set, each service type may correspond to one header file or a plurality of header files, and a specific number of users may be set according to actual requirements. Certainly, in the process of actual application, all fields required by a certain service type may be determined, and a corresponding header file is generated according to all the fields and stored in the file set.
Specifically, when the target file is uploaded or read from the disk, an interface for uploading the target file or an interface for reading the target file may be determined, and the service type of the target file may be determined according to the interface. And determining at least one header file to be determined corresponding to the service type from the file set according to the service type. Further, according to the list header information in the target file, the target list header file can be determined from at least one list header file to be determined.
In this embodiment, the determining a target header file from the file set according to the service type corresponding to the target file and the list header information includes: determining at least one target header file to be determined from the file set according to the service type of the target file; extracting the list header information in the target file based on a data reading tool, and determining the target list header file comprising the list header information or consistent with the list header information from the at least one target list header file to be determined based on the data reading tool.
The target header file to be determined is a header file matched with the service type of the target file. The data reading tool may be an SDK of a POI, and the POI provides an API for a java program to read and write data of a Microsoft Office format document. The list head information in the target file can be read based on the data reading tool, meanwhile, the attribute name information in the target list head file to be determined can be read, and the corresponding target list head file can be determined according to the list head information and the attribute name information. The header file comprises a predefined list header and an attribute name of the list header. Based on the attribute names, it can be determined which list headers correspond to data to be read.
Specifically, according to the service type of the target file, at least one target header file matched with the service type may be determined from the file set. Meanwhile, target list header information in the target file and attribute name information in each target list header file to be determined can be read based on the data reading tool. According to the target list header information and the attribute name information, a target list header file to be selected, which includes the target list header information or is identical to the target list header information, can be determined. If the number of the target list head files to be selected comprises a plurality of target list head files, the target list head files to be selected can be displayed on a display interface in a pop-up window or webpage mode for the user to select. The user can trigger the target header file to be selected on the display interface, and the finally triggered target header file to be selected is used as the target header file.
S120, determining a target list header to be read according to the list header information and a predefined list header in the target list header file, and determining column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information.
The target header file is generated by adding custom annotation @ excelResources to attribute information of a reusable component JavaBean which is created in advance and then processing the attribute information. Attributes may be specified in the annotation, including a predefined list header and an order of the predefined list header. After the attribute information of the reusable component JavaBean is processed through a reflection mechanism, a java object excelHeader can be generated, and the excelHeader is a header file. The header file comprises a predefined list header and an attribute name filedName of the predefined list header. The header information in the target file may be the same as the predefined header and the same header may be used as the target header. The index information may be column information of the target list header in the target file, e.g., the target list header is field a, the field a is the third column in the target file, and then the index information of field a may be 3. After determining the target list header information, the attribute name of the target list header may be determined from the target list header file, so that when creating a reusable component storing each row of data, the column data and the attribute name in the row of data may be stored correspondingly. The index information is a key, the index information is associated with a list header, and the attribute name of the list header may be a value associated with the key.
Specifically, the list header information in the target file is read based on the data reading tool, and meanwhile, the predefined list header in the target list header file is read. And taking the same list header information as a target list header, further determining the specific number of columns of the target list header in the target file and the attribute name of the target list header in the target list header file, taking the specific number of columns as the index information of the target file, and determining the target attribute name of the list header corresponding to the index information.
In this embodiment, the determining target header information according to the header information and a predefined header in the target header file, and determining index information of the target header information and an attribute name corresponding to the index information includes: when the list head information is consistent with a preset list head, taking the list head information as target list head information; determining the column number value of the target list header in the target file, and taking the column number value as the index information; and calling the attribute name of the target list header information, and establishing a corresponding relation between index information and the attribute name so as to store the read data under the corresponding attribute name based on the index information when the data is read.
It should be noted that, in order to read data in the target file, it is necessary to determine which list header information in the target file is included in the list header file, and further read data corresponding to the list header information in the target file.
Specifically, when it is detected that the list header information is the same as the predefined list header, the same list header may be used as the target list header, and the column number of the target list header in the target file, that is, which column of the target file the target list header is located in, may be determined. This column number may be used as index information. Further, in order to store the data corresponding to the target list header in the database, the target attribute name of the target list header may be determined, so that when reading each row of data, the corresponding data may be stored according to the index information and the corresponding attribute name.
Illustratively, fields corresponding to the list header information are field a, field B, field C, and field D in sequence, and the predetermined list header includes field a and field D, and the target list header may be determined to be field a and field D based on the data reading tool. Meanwhile, it may be determined that the column values of the field a and the field D in the target file are 1 and 4, and for subsequent data processing to be uniform, the column values may be counted from 0, the column value of the field a is 0, and the column value of the field D may be 3. After determining the column values, the attribute names of the target list headers may be determined according to the target file. The same list header is put into the Map set (key is the column value, value is the property name of the target list header filediname in ExcelHeader, JavaBean).
In this embodiment, this configuration is advantageous in that, when reading each row of data in the file, the column data in the row of data may be read based on the index information obtained as described above, and after creating the reusable component storing the row of data, the read column data and the attribute name corresponding to the index information are written into the reusable component in a corresponding manner.
S130, sequentially reading current row data according to the index information aiming at the row data in the target file, and correspondingly storing the column data in the current row data and the target attribute name into a reusable component.
After the column data, the column data index information, and the corresponding attribute names written in the database are obtained on the basis of S110 and S120, each column data in the row data may be sequentially read based on the above relationship, and the column data may be correspondingly stored according to the corresponding attribute names.
It should be noted that, for each row of data in the target file, data reading can be performed in this way, and this embodiment is described by taking reading of one row of data as an example.
The reusable component can be used as a carrier for storing each row of data, that is, each column of data in the row of data can be correspondingly stored into the reusable component according to the attribute name.
Specifically, for each line of data, an instance object of the JavaBean may be generated, that is, each line of data may generate an instance object of the JavaBean, and at this time, corresponding data is not written in the instance object of the JavaBean. The current row of data is sequentially read according to the index information, that is, a specific column data in the current row of data and an attribute name corresponding to the column data can be determined according to the index information, and the column data corresponding to the index information and a corresponding target attribute name can be written into an instance object of the JavaBean.
In this embodiment, the sequentially reading the current row of data according to the index information, and correspondingly storing the column data in the current row of data and the target attribute name into the attribute information of the reusable component includes: for each line of data in the row of data, reading the current line of data according to the index information, and determining a target attribute name corresponding to the index information; based on the column data and the target attribute name, attribute information of the reusable component corresponding to the current row of data is determined.
Specifically, each row of data includes a plurality of column data, the plurality of column data includes data stored in the database and data not written in the database, so that the column data to be written in the database in the current row of data can be read according to the index information, and the corresponding target attribute name is determined according to the index information. When the column data corresponding to the index information is read, the corresponding target attribute name can be called, and the column data and the target attribute name are correspondingly written into the attribute information of the JavaBean instance object, so that the effect of writing the row data into the JavaBean instance object is achieved.
And S140, generating a data set based on the reusable components corresponding to the data in each row and storing the data set in a database.
Based on S130, an instance object (reusable component) of the JavaBean corresponding to each line of data in the target file may be obtained, a data set (LIST) may be generated based on each reusable component, and the data set may be persisted to a database.
That is to say, a data set may be generated according to the reusable components corresponding to each line of data in the target file, and the data set is stored in the database and/or the file to be cached, where the file to be cached may also be a file in the database.
According to the technical scheme of the embodiment of the invention, when the triggering operation of storing the data in the target file into the database is detected, the target header file is determined from the file set comprising the header file according to the header information of the target file, the target header is determined according to the header information of the target file and the predefined header in the target header file, the target attribute name corresponding to the index information and the index information of the target header in the target file is determined, after the information is determined, each row of data in the target file can be read in sequence, the row of data is written into the reusable component of the data in the current row, the row of data in the row of data corresponding to the target attribute name in the reusable component is reused, and the technical problems that corresponding program codes need to be written in the data introduced into the database in the prior art and the data introduction is complicated and complicated are solved, the technical effect of conveniently and efficiently importing the data into the database is achieved.
Example two
Fig. 2 is a schematic flow chart of a data caching method according to a second embodiment of the present invention, and based on the foregoing embodiment, reusable components may be created in advance and a custom annotation may be added to the reusable components, and further, the reusable components with the annotation added thereto are converted into a header file, and the header file is stored in a file set. The specific implementation manner can be referred to the technical scheme of the embodiment. The technical terms that are the same as or corresponding to the above embodiments are not repeated herein.
As shown in fig. 2, the method includes:
s210, creating at least one predefined reusable component, and adding an annotation in attribute information of the at least one predefined reusable component; the annotated annotation attribute information includes a predefined list header.
Wherein the predefined reusable components may be pre-created JavaBean objects. In the actual application process, the Class of the javaBean can be established according to actual requirements, and the specific service object type can define the Class type of the javaBean. The number of the predefined reusable components may be multiple, and the specific number may be set according to actual requirements, optionally, one service type corresponds to one reusable component, or corresponds to multiple reusable components. The annotation information may be a custom annotation @ excel resources, which may be used on a property of JavaBean, and the property may be specified in the annotation, and the property may include a list header and an order corresponding to the list header, for example, the property in the annotation may be "title (predefined list header), order (order corresponding to the predefined list header)". Corresponding annotations may be added to the attribute information of each reusable component. The specific value of the predefined list header in the annotation may be determined according to the field concerned by the service type corresponding to the field.
Specifically, at least one reusable component JavaBean corresponding to each traffic type is created. For each reusable component, adding an annotation @ excelResources to the attribute information of the current reusable component, wherein the annotation information can comprise a predefined list header and sequence information of the predefined list header.
S220, aiming at each predefined reusable component, identifying annotation information in the predefined reusable component according to a reflection mechanism, and generating a header file according to the annotation information, wherein the header file comprises a predefined list head and an attribute name corresponding to the predefined list head.
The reusable component added with the annotation can be obtained, the attribute information of the predefined reusable component can be identified based on a reflection mechanism, and the annotation information in the attribute information is extracted, namely which annotations are marked on the reusable component, and optionally what a predefined list head in the annotations is. Meanwhile, the attribute information of each predefined reusable component can be processed based on a reflection mechanism, and an ExcelHeader of the Java object, namely, a header file, is generated. The header file may include a predefined header in the annotation, i.e., a specified header title in the self-defined annotation, a sequential order of the header, and a JavaBean attribute name filediname, i.e., an attribute name of a predetermined header. The header file ExcelHeader generated as described above may be stored in a file set (List).
In an actual application process, after the creation of the predefined reusable component is completed, the reusable component added with the annotation can be processed into a header file by using a reflection mechanism and stored into the file set. Or when detecting the operation of storing the data in the target file into the database, determining the target reusable component of the target file, processing the target reusable component into a header file, storing the header file into the file set, and finally searching the header file from the file set. The first implementation mode has the advantages that a reflection mechanism can be used in advance, the reusable component (JavaBean) added with the annotation is generated into an excelHeader file, when the target file is uploaded, the header file corresponding to the reusable component can be searched from the file set, the phenomenon that the predefined reusable component corresponding to the target file needs to be converted into the corresponding header file by using the reflection mechanism during each uploading is avoided, and therefore the technical effect of avoiding reducing resource consumption is achieved; the second embodiment has the advantage that the problem of redundant storage resources caused by more header files stored in the file set can be avoided.
S230, when the triggering operation of storing the data in the target file into the database is detected, determining the target header file from a file set comprising the header file according to the list header information of the target file; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header.
Specifically, when a trigger operation that triggers storing of data in the target file into the database is detected, the first line in the target file may be read by using the SDK of the data reading tool POI, and a field in the first line, that is, the list header information in the target file, may be acquired. And determining a target header file ExcelHeader, namely the target header file matched with the list header information, from headers in the file set according to the list header information in the target file.
S240, according to the list header information and a predefined list header in the target list header file, determining a target list header to be read, and determining the list index information corresponding to the target list header in the target file and the target attribute name corresponding to the list index information.
Specifically, based on the SDK traversing the predefined list header in the target header file ExcelHeader and the list header information in the target file, the same target list header information may be put into Map. Key in Map is the index of the target list header in the column of the cell of the target file, and value is the value of the filedName attribute of the target list header in excelHeader, that is, the annotated attribute name in JavaBean.
And S250, sequentially reading current row data according to the index information aiming at the row data in the target file, and correspondingly storing the column data in the current row data and the target attribute name into a reusable component.
Specifically, the target file may be an excel file, and for each line of data in the excel file, a data reading tool may be used to read the excel line of data. Before reading the line data, an instance object of each line data JavaBean may be generated based on a reflection mechanism, i.e. an object carrier storing the line data is created. The JavaBean can reuse the component.
For each row of data, when reading each column of data in the current row of data, an index value of the current column of data may be determined. If the index value is the same as the key value in the Map, the column data corresponding to the index value may be assigned to a value (attribute name) corresponding to the key using reflection, and the corresponding column data and the corresponding attribute name of the index value may be sequentially written to the instance object of the java bean created in advance. And repeating the step to obtain the JavaBean instance object corresponding to each line of data, wherein the obtained instance object is the data after the data is written.
And S260, generating a data set based on the reusable components corresponding to the data in each row and storing the data set in a database.
It should be noted that S250 may be repeatedly executed to read each line of data in the target file, and store the line of data into the corresponding instance object of the JavaBean.
Specifically, after the reusable components corresponding to each row of data are obtained, a data set may be generated and stored in the database, so that corresponding data may be subsequently retrieved from the database.
According to the technical scheme of the embodiment of the invention, when the triggering operation of storing the data in the target file into the database is detected, the target header file is determined from the file set comprising the header file according to the header information of the target file, the target header is determined according to the header information of the target file and the predefined header in the target header file, the target attribute name corresponding to the index information and the index information of the target header in the target file is determined, after the information is determined, each row of data in the target file can be read in sequence, the row of data is written into the reusable component of the data in the current row, the row of data in the row of data corresponding to the target attribute name in the reusable component is reused, and the technical problems that corresponding program codes need to be written in the data introduced into the database in the prior art and the data introduction is complicated and complicated are solved, the technical effect of conveniently and efficiently importing the data into the database is achieved.
EXAMPLE III
Fig. 3 is a schematic flow chart of a data retrieving method according to a third embodiment of the present invention, where the present embodiment is applicable to exporting data stored in a database or a file library to a target file, such as an excel file, and the method may be executed by a data reading device, where the data reading device may be implemented in the form of software and/or hardware, where the hardware may be an electronic device, and the electronic device may be a mobile terminal or a PC terminal, etc.
Before the technical solution of the present embodiment is introduced, an application scenario is exemplarily described. When the data stored in the database is imported into the office file, the method disclosed by the embodiment can be adopted to export the target data in the database to the corresponding document, and the technical effect that the data in the database can be exported to the corresponding file without modifying program codes is realized.
As shown in fig. 3, the method of this embodiment includes:
s310, when the triggering operation of exporting the target data in the database to the target file is detected, generating a target header file according to a target list header triggered by a user; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header.
The data stored in the database may be data imported in a manner based on the prior art, for example, data imported into the database based on written program code, and at this time, the data is mainly stored in rows; or storing each row of data into attribute information of the reusable component, namely, using the reusable component java bean as a carrier for storing the data. The data that the user currently needs to derive from the database may be targeted. The list head corresponding to each service type can be displayed on the same page, when the user exports data, the list head information on the page can be triggered, and the triggered list head is used as the target list head. After the target list head is selected, the target list head can be used as a title annotated in the attribute information of the reusable component, namely, the list head, and the target list head file can be generated by processing the target list head based on a reflection mechanism after the annotation is added. The header file comprises a triggered target list header, index information of the target list header and an attribute name of the target list header. The index information is the sequence of the target list head, and the attribute name corresponds to the triggered target list head.
Specifically, when it is detected that the user triggers the export of the target data, a list header may be selected on the list header display page, and the selected list header may be used as the target list header. The target header file may be generated from a target list header triggered by a user.
It should be noted that, if the derived target data is stored based on the JavaBean, the JavaBean instance object corresponding to the target data may be directly acquired. If the exported target data is stored based on program code, a header file may be generated from the triggered target list header.
Specifically, a target list header triggered by a user is obtained, a reconstructable component is created, and an annotation is added to the attribute information, wherein the annotation includes the target list header. Based on a reflection mechanism, the attribute of the JavaBean annotation custom annotation can be determined, and a Java object excelHeader is generated. The excelHeader comprises a target list head triggered by a user, the sequence of the target list head and the JavaBean attribute name filedName.
S320, generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information.
The index information is used for representing the sequence of the target list header, and based on the index information in the ExcelHeader, the list sequence information of the target list header in the target file can be determined. Traversing the target list header in the ExcelHeader, the first row of fields of the target file, that is, the list header information of the target file, can be generated.
In this embodiment, before generating the list header information in the target file, the method further includes: and calling a data reading tool, generating a document display style of the target document, and displaying the imported data based on the document display style.
The data retrieval tool can be an SDK of the POI, and based on the data retrieval tool, a target list header in the reusable component can be read, and a target document display style is generated according to the target list header. The display style may be the font of the list head in the target file, the color of the cell to which the list head belongs, and the like. It can be understood that the target file is an Excel file, and the value of the list header is filled by the title attribute value of the ExcelHeader object, so that the Excel file including the list header can be obtained.
Specifically, the SDK calling the POI generates a style headstyle of a list header in the target file, and based on the style, corresponding data, that is, information such as name, age, and the like, of the list header may be filled in the list header.
S330, sequentially writing the target data filled in the attribute information of each reusable component into the file list head of the target file according to the index information; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
On the basis of the above technical solution, after the list header information in the target file is generated, the target data may be imported into the corresponding list header information in the target file, that is, the data and the target list header are stored correspondingly.
Before data is imported into the target file, the target data can be stored in a database in a row form, the row data can be stored into the reusable component, and then the data is extracted from the reusable component and imported into the target file, because: when data is directly read, the list header information of the data in the target file is not determined, and therefore the data cannot be correctly written into the target file.
In this embodiment, before the sequentially writing the target data filled in the attribute information of each reusable component under the document list header of the target document according to the index information, the method further includes: aiming at each row of data in the target data, creating a reusable component to be used, acquiring a corresponding attribute name according to the index information, and taking the attribute name as the attribute information of the reusable component to be used; and sequentially reading the current row of data according to the index information aiming at each row of data, and correspondingly storing the row of data in the current row of data and the corresponding attribute name to obtain the reusable component.
It can be understood that after the target data is found from the database or the file, the target data can be transferred, that is, a java bean instantiated object storing the target data is created, and at this time, no data is stored in the instantiated object, the current row of data can be read according to the index information, and the column data and the attribute name in the current row of data, which are the same as the index information, are correspondingly stored in the reusable component, so that the technical effect of reading the data to the target file by reading the reusable component is achieved.
According to the technical scheme of the embodiment of the invention, when the target data is exported from the database, the target data is temporarily stored in the reusable component, the reusable component is processed based on the reflection mechanism, and the data stored in the reusable component is sequentially written into the target file, so that the data in the database can be exported to the target document without modifying corresponding program codes, and the technical effect of improving the data export efficiency is achieved.
Example four
As an alternative embodiment of the foregoing embodiment, fig. 4 is a schematic diagram of a data reading method according to a fourth embodiment of the present invention. On the basis of the foregoing embodiment, the data stored in the database may be stored with the reusable component as a carrier; the data may be imported into the database based on a code, and the stored data is mainly stored in the form of line data. When exporting data from a database or a file to an excel file, the specific implementation thereof can also refer to the technical solution of the present embodiment. The technical terms that are the same as or corresponding to the above embodiments are not repeated herein.
As shown in fig. 4, the method includes: when target data are extracted from a database or a file, the inquired data can be transferred to a list set, and if the data stored in the list set store the data by taking Javabean as a carrier, namely the list set comprises a Javabean example object set of the target data, the Javabean example object set can be traversed to generate a first line in an excel file. Based on a reflection mechanism, the Javabean instance objects are converted into header files, such as excelheaders, and the number of the excelheaders is the same as that of the Javabean instance objects. And traversing the data corresponding to the attribute names in the excelheaders, generating each column data in the current row, and sequentially reading the data corresponding to the attribute names in each excelheader to obtain the excel file comprising the target data. If the target data is not stored by taking the JavaBean as a carrier, the JavaBean object can be created, and the list head triggered by the list head selection page is added into the attribute information of the JavaBean object as an annotation. And reflecting the attribute of the annotation added in the JavaBean object based on a reflection mechanism to obtain the excelheader. The Excelheader records that the comment is a triggered list header, the annotation order is an index of the comment, and the filedname on which attribute the comment belongs to, that is, the data corresponding to which title needs to be read. Aiming at each row of data, a JavaBean object can be created, an attribute name is written into the created JavaBean object based on the excelheader, column data in the row of data and the attribute name are correspondingly stored, and the JavaBean object of each row of data is processed based on a reflection mechanism to obtain an excelheader instance object set of target data. And calling the SDK to read the excel header instance object set, generating row data of a first row in the excel file, namely column header information, and sequentially reading data corresponding to the attribute name in each excel header to obtain the excel file comprising the target data, thereby realizing the technical effect of exporting the target data from the database to the target file.
According to the technical scheme of the embodiment of the invention, when the target data is exported from the database, the target data is temporarily stored in the reusable component, the reusable component is processed based on the reflection mechanism, and the data stored in the reusable component is sequentially written into the target file, so that the data in the database can be exported to the target document without modifying corresponding program codes, and the technical effect of improving the data export efficiency is achieved.
EXAMPLE five
As an alternative embodiment of the foregoing embodiment, fig. 5 is a schematic diagram of a data caching or retrieving method according to an embodiment of the present invention. The technical terms that are the same as or corresponding to the above embodiments are not repeated herein.
As shown in fig. 5, the method includes: the document headers corresponding to different service types can be the same or different, the list headers of different service types can be predefined, the list headers of different documents can be set, and the list headers are used as custom notes @ excelResources. After determining the list header, a reusable component can be created, namely, data to be operated is packaged through a JavaBean object, and corresponding note @ excelResources is added in attribute information of the reusable component JavaBean object, wherein the note comprises corresponding list header title, the title value is a field of a first row in a table, and the order represents the sequence of the list header in an uploading file; at the same time, a reusable component JavaBean object can be created. Adding custom note @ excelResources in attribute information of the JavaBean object to specify attributes title and order, namely determining the specific value of the title, namely what the field is specifically according to actual requirements. And acquiring the property title and order set by the annotation on the JavaBean property based on a reflection mechanism, namely reflection in Java. If the method is applied to the condition that data in the file is stored in the database, a Map set is generated according to the relation between the excel list header to be imported and the corresponding JavaBean attribute, key in the Map set represents the number of columns of the same list header in the excel file, and value represents the attribute name corresponding to the list header. Each line data in the excel file can be traversed based on the Map set, and the line data is stored in the JavaBean object corresponding to the line, namely after the Map set is built, the JavaBean instantiation object of each line data is created, at this time, no data is stored in the JavaBean instantiation object, each line data can be read based on the Map set, and the line data is stored in the corresponding JavaBean object. After the excel data traversal is completed, the JavaBean objects with the same number as the number of the lines can be obtained. All JavaBean objects are persisted to the database.
If the data in the database are exported to the excel file, the JavaBean object carrying the data and the excel list head are associated, the list head information of the excel file is generated according to the annotation setting sequence in the JavaBean object, and meanwhile, the style of the list head is set based on the data reading tool. On the basis of the style, the JavaBean dataset can be traversed to generate each line of data corresponding to the excel, and then an excel file is generated or a response is sent to a browser for downloading by a client. If the data in the database is not stored based on the JavaBean instantiation object, the JavaBean object corresponding to each line of data can be created, and the JavaBean object is used as a carrier for storing the data, so that the data is acquired from the JavaBean object to the target file.
According to the technical scheme of the embodiment of the invention, when the triggering operation of storing the data in the target file into the database is detected, the target header file is determined from the file set comprising the header file according to the header information of the target file, the target header is determined according to the header information of the target file and the predefined header in the target header file, the target attribute name corresponding to the index information and the index information of the target header in the target file is determined, after the information is determined, each row of data in the target file can be read in sequence, the row of data is written into the reusable component of the data in the current row, the row of data in the row of data corresponding to the target attribute name in the reusable component is reused, and the technical problems that corresponding program codes need to be written in the data introduced into the database in the prior art and the data introduction is complicated and complicated are solved, the technical effect of conveniently and efficiently importing the data into the database is achieved.
EXAMPLE six
Fig. 6 is a schematic structural diagram of a data caching apparatus according to a sixth embodiment of the present invention, where the apparatus includes: a target header file determination module 610, a target list header information generation module 620, an attribute information determination module 630, and a reusable component generation module 640.
The target header file determining module 610 is configured to determine, when a trigger operation for storing data in a target file in a database is detected, a target header file from a file set including the header file according to header information of the target file; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header; a target list header information generating module 620, configured to determine a target list header to be read according to the list header information and a predefined list header in the target list header file, and determine column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information; an attribute information determining module 630, configured to, for row data in the target file, sequentially read current row data according to the index information, and store column data in the current row data and the target attribute name in a reusable component in a corresponding manner; the reusable component generating module 640 is configured to generate a data set based on the reusable components corresponding to each row of data, and store the data set in the database. On the basis of the above technical solution, the target header file determining module is further configured to determine a target header file from the file set according to the service type corresponding to the target file and the list header information.
On the basis of the above technical solution, the target header file determining module further includes: the first target header file generating unit is used for determining at least one target header file to be determined from the file set according to the service type of the target file; and the second target header file generating unit is used for extracting the header information in the target file based on a data reading tool and determining the target header file comprising the header information or consistent with the header information from the at least one target header file to be determined based on the data reading tool. On the basis of the technical scheme, the target list header information generating module comprises: a third list header generating unit configured to, when the list header information coincides with a predetermined list header, take the list header information as target list header information; determining the column number value of the target list header in the target file, and taking the column number value as the index information;
and calling the attribute name of the target list header information, and establishing a corresponding relation between index information and the attribute name so as to store the read data under the corresponding attribute name based on the index information when the data is read.
On the basis of the above technical solution, the attribute information determining module includes:
the target attribute name determining unit is used for reading the current line data according to the index information aiming at each line of data in the line data and determining a target attribute name corresponding to the index information;
and the attribute information determining unit is used for determining the attribute information of the reusable component corresponding to the current row of data based on the column data and the target attribute name.
On the basis of the above technical solution, the reusable component generating module further includes: the data set generating unit is used for generating a data set according to the reusable components corresponding to each row of data in the target file; and the data caching unit is used for caching the data set into a database and/or a file to be cached.
On the basis of the above technical solutions, the apparatus further includes:
the predefined reusable component creating module is used for creating at least one predefined reusable component and adding annotations to the attribute information of the at least one predefined reusable component; the annotated annotation attribute information comprises a predefined list header;
and the header file generating module is used for identifying annotation information in the predefined reusable components according to a reflection mechanism and generating a header file according to the annotation information, wherein the header file comprises a predefined list header and an attribute name corresponding to the predefined list header.
According to the technical scheme of the embodiment of the invention, when the triggering operation of storing the data in the target file into the database is detected, the target header file is determined from the file set comprising the header file according to the header information of the target file, the target header is determined according to the header information of the target file and the predefined header in the target header file, the target attribute name corresponding to the index information and the index information of the target header in the target file is determined, after the information is determined, each row of data in the target file can be read in sequence, the row of data is written into the reusable component of the data in the current row, the row of data in the row of data corresponding to the target attribute name in the reusable component is reused, and the technical problems that corresponding program codes need to be written in the data introduced into the database in the prior art and the data introduction is complicated and complicated are solved, the technical effect of conveniently and efficiently importing the data into the database is achieved.
The data caching device provided by the embodiment of the invention can execute the data caching method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
EXAMPLE seven
Fig. 7 is a schematic structural diagram of a data retrieving device according to a seventh embodiment of the present invention, where the device includes: a target header file generation module 710, a document list header generation module 720, and a data write module 730.
The target header file generating module 710 is configured to, when a trigger operation of exporting target data in a database to a target file is detected, generate the target header file according to a target list header triggered by a user; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header; a document list header generating module 720, configured to generate a document list header of the target document according to the attribute name corresponding to the target list header and the index information; the data writing module 730 is configured to sequentially write, according to the index information, each piece of target data filled in the attribute information of each reusable component into a file list header of the target file; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
On the basis of the above technical solution, before the target header file generation module is configured to generate the target header file according to the target list header triggered by the user when a trigger operation for exporting target data in the database to the target file is detected, the target header file generation module is further configured to:
aiming at each row of data in the target data, creating a reusable component to be used, acquiring a corresponding attribute name according to the index information, and taking the attribute name as the attribute information of the reusable component to be used; and sequentially reading the current row of data according to the index information aiming at each row of data, and correspondingly storing the row of data in the current row of data and the corresponding attribute name to obtain the reusable component.
On the basis of the technical solutions, the apparatus further includes a data writing module, configured to obtain, for each reusable component, data filled in each attribute name, and sequentially write the data below a document list header of the target document according to the index information.
On the basis of the foregoing technical solutions, before the data writing module is configured to generate the document list header of the target document according to the attribute name corresponding to the target list header and the index information, the data writing module is further configured to: and calling a data reading tool, generating a document display style of the target document, and displaying the imported data based on the document display style.
According to the technical scheme of the embodiment of the invention, when the target data is exported from the database, the target data is temporarily stored in the reusable component, the reusable component is processed based on the reflection mechanism, and the data stored in the reusable component is sequentially written into the target file, so that the data in the database can be exported to the target document without modifying corresponding program codes, and the technical effect of improving the data export efficiency is achieved.
The data calling device provided by the embodiment of the invention can execute the data calling method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
Example eight
Fig. 8 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. FIG. 8 illustrates a block diagram of an exemplary 80 electronic device 80 suitable for use in implementing embodiments of the present invention. The electronic device 80 shown in fig. 8 is an example only and should not impose any limitations on the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 8, the electronic device 80 is embodied in the form of a general purpose computing device 80. 80 Components of the electronic device 80 may include, but are not limited to: one or more processors or processing units 801, a system memory 802, and a bus 803 that couples various system components including the system memory 802 and the processing unit 801.
Bus 803 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
80 the electronic device 80 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by the electronic device 80 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 802 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)804 and/or cache memory 805. 80 the electronic device 80 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 806 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 8, and commonly referred to as a "hard drive"). Although not shown in FIG. 8, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 803 by one or more data media interfaces. Memory 802 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 808 having a set (at least one) of program modules 807 may be stored, for instance, in memory 802, such program modules 807 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may include an implementation of a network environment. Program modules 807 generally perform the functions and/or methodologies of embodiments of the present invention as described herein.
The electronic device 80 may also communicate with one or more external devices 809 (e.g., keyboard, pointing device, display 810, etc.), with one or more devices that enable a user to interact with the electronic device 80, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 80 to communicate with one or more other computing devices. Such communication may occur via an input/output (I/O) interface 811. Also, the electronic device 80 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) via the network adapter 812. As shown, the network adapter 812 communicates with the other modules of the electronic device 80 over the bus 803. It should be appreciated that although not shown in FIG. 8, other hardware and/or software modules may be used in conjunction with 80 electronic device 80, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 801 executes various functional applications and data processing by running programs stored in the system memory 802, for example, implementing a data caching method and/or a data retrieval method provided by an embodiment of the present invention.
Example nine
Embodiments of the present invention also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are used to perform a data caching method and/or a data retrieval method.
The data caching method comprises the following steps:
when the triggering operation of storing the data in the target file into the database is detected, determining the target header file from a file set comprising the header file according to the list header information of the target file; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header;
determining a target list header to be read according to the list header information and a predefined list header in the target list header file, and determining column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information;
sequentially reading current row data according to the index information aiming at the row data in the target file, and correspondingly storing the row data in the current row data and the target attribute name into a reusable component;
and generating a data set based on the reusable components corresponding to the data of each row, and storing the data set in the database.
Or the like, or, alternatively,
the data calling method comprises the following steps:
when detecting a trigger operation of exporting target data in a database to a target file, generating a target header file according to a target list header triggered by a user; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header;
generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information;
writing the target data filled in the attribute information of each reusable component into the file list head of the target file in sequence according to the index information; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (15)

1. A method for caching data, comprising:
when the triggering operation of storing the data in the target file into the database is detected, determining the target header file from a file set comprising the header file according to the list header information of the target file; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header;
determining a target list header to be read according to the list header information and a predefined list header in the target list header file, and determining column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information;
sequentially reading current row data according to the index information aiming at the row data in the target file, and correspondingly storing the row data in the current row data and the target attribute name into a reusable component;
and generating a data set based on the reusable components corresponding to the data of each row, and storing the data set in the database.
2. The method of claim 1, wherein determining a target header file from a set of files comprising header files based on the header information of the target file comprises:
and determining a target header file from the file set according to the service type corresponding to the target file and the list header information.
3. The method according to claim 2, wherein the determining a target header file from the file set according to the service type corresponding to the target file and the list header information comprises:
determining at least one target header file to be determined from the file set according to the service type of the target file;
extracting the list header information in the target file based on a data reading tool, and determining the target list header file comprising the list header information or consistent with the list header information from the at least one target list header file to be determined based on the data reading tool.
4. The method according to claim 1, wherein the determining, according to the list header information and a predefined list header in the target list header file, a target list header to be read, and determining column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information, comprises:
when the list head information is consistent with a preset list head, taking the list head information as target list head information;
determining the column number value of the target list header in the target file, and taking the column number value as the index information;
and calling the attribute name of the target list header information, and establishing a corresponding relation between index information and the attribute name so as to store the read data under the corresponding attribute name based on the index information when the data is read.
5. The method according to claim 1, wherein the sequentially reading the current row of data according to the index information and storing the column data in the current row of data and the target attribute name into the reusable component correspondingly comprises:
for each line of data in the row of data, reading the current line of data according to the index information, and determining a target attribute name corresponding to the index information;
based on the column data and the target attribute name, attribute information of the reusable component corresponding to the current row of data is determined.
6. The method of claim 1, wherein generating and storing the data set into the database based on the reusable components corresponding to each row of data comprises:
generating a data set according to the reusable components corresponding to each row of data in the target file;
and caching the data set into a database and/or a file to be cached.
7. The method of claim 1, further comprising:
creating at least one predefined reusable component and adding annotations in attribute information of the at least one predefined reusable component; the annotated annotation attribute information comprises a predefined list header;
and for each predefined reusable component, identifying annotation information in the predefined reusable component according to a reflection mechanism, and generating a header file according to the annotation information, wherein the header file comprises a predefined list header and an attribute name corresponding to the predefined list header.
8. A method for retrieving data, comprising:
when detecting a trigger operation of exporting target data in a database to a target file, generating a target header file according to a target list header triggered by a user; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header;
generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information;
writing the target data filled in the attribute information of each reusable component into the file list head of the target file in sequence according to the index information; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
9. The method according to claim 8, before the writing, according to the index information, each piece of target data filled in the attribute information of each reusable component under a document list header of the target document in sequence, further comprising:
aiming at each row of data in the target data, creating a reusable component to be used, acquiring a corresponding attribute name according to the index information, and taking the attribute name as the attribute information of the reusable component to be used;
and sequentially reading the current row of data according to the index information aiming at each row of data, and correspondingly storing the row of data in the current row of data and the corresponding attribute name to obtain the reusable component.
10. The method according to claim 9, wherein the writing of the data filled in the attribute information of each reusable component in sequence under the document list header of the target document according to the index information comprises:
and acquiring the data filled in each attribute name aiming at each reusable component, and sequentially writing the data under the document list head of the target document according to the index information.
11. The method according to claim 8, further comprising, before the generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information:
and calling a data reading tool, generating a document display style of the target document, and displaying the imported data based on the document display style.
12. A data caching apparatus, comprising:
the target header file determining module is used for determining a target header file from a file set comprising the header file according to the header information of the target file when the triggering operation of storing the data in the target file into the database is detected; the header file comprises a predefined list header and an attribute name corresponding to the predefined list header;
a target list header information generating module, configured to determine a target list header to be read according to the list header information and a predefined list header in the target list header file, and determine column index information corresponding to the target list header in the target file and a target attribute name corresponding to the column index information;
the attribute information determining module is used for sequentially reading current row data according to the index information aiming at the row data in the target file and correspondingly storing the column data in the current row data and the target attribute name into the reusable component;
and the reusable component generating module is used for generating a data set based on the reusable components corresponding to the data of each row and storing the data set in the database.
13. A data retrieval device, comprising:
the target header file generation module is used for generating a target header file according to a target list header triggered by a user when the triggering operation of exporting target data in the database to the target file is detected; the target list header file comprises a triggered target list header, index information of the target list header and an attribute name corresponding to the target list header;
the document list header generation module is used for generating a document list header of the target document according to the attribute name corresponding to the target list header and the index information;
the data writing module is used for sequentially writing all target data filled in the attribute information of all the reusable components into the file list head of the target file according to the index information; the attribute information of the reusable component comprises an attribute name and data corresponding to the attribute name.
14. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a data caching method as claimed in any one of claims 1 to 7 or a data retrieval method as claimed in any one of claims 8 to 11.
15. A storage medium containing computer-executable instructions for performing the data caching method of any one of claims 1 to 7 or the data retrieval method of any one of claims 8 to 11 when executed by a computer processor.
CN202110036733.0A 2021-01-12 2021-01-12 Data calling method and device, electronic equipment and storage medium Pending CN113760894A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110036733.0A CN113760894A (en) 2021-01-12 2021-01-12 Data calling method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110036733.0A CN113760894A (en) 2021-01-12 2021-01-12 Data calling method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113760894A true CN113760894A (en) 2021-12-07

Family

ID=78786286

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110036733.0A Pending CN113760894A (en) 2021-01-12 2021-01-12 Data calling method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113760894A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114564928A (en) * 2022-02-25 2022-05-31 北京圣博润高新技术股份有限公司 File management method, device, equipment and storage medium for office system
CN114866531A (en) * 2022-04-02 2022-08-05 山东体育学院 Cross-network data transmission method and system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114564928A (en) * 2022-02-25 2022-05-31 北京圣博润高新技术股份有限公司 File management method, device, equipment and storage medium for office system
CN114564928B (en) * 2022-02-25 2024-02-27 北京圣博润高新技术股份有限公司 File management method, device, equipment and storage medium for office system
CN114866531A (en) * 2022-04-02 2022-08-05 山东体育学院 Cross-network data transmission method and system

Similar Documents

Publication Publication Date Title
CN111258966A (en) Data deduplication method, device, equipment and storage medium
CN106648569B (en) Target serialization realization method and device
CN112016273A (en) Document directory generation method and device, electronic equipment and readable storage medium
CN115061721A (en) Report generation method and device, computer equipment and storage medium
CN113407785B (en) Data processing method and system based on distributed storage system
CN112463800A (en) Data reading method and device, server and storage medium
CN111694561A (en) Interface management method, device, equipment and storage medium
CN113760894A (en) Data calling method and device, electronic equipment and storage medium
CN113760839A (en) Log data compression processing method and device, electronic equipment and storage medium
CN110990411A (en) Data structure generation method and device and calling method and device
CN113204345A (en) Page generation method and device, electronic equipment and storage medium
CN114564930A (en) Document information integration method, apparatus, device, medium, and program product
CN114201615B (en) Scientific research data change review method and server based on data snapshot
CN111651552A (en) Structured information determination method and device and electronic equipment
CN113282854A (en) Data request response method and device, electronic equipment and storage medium
CN111913922B (en) Binary structured log generation method, device, equipment and storage medium
CN113127776A (en) Breadcrumb path generation method and device and terminal equipment
CN115080684B (en) Network disk document indexing method and device, network disk and storage medium
CN113792138B (en) Report generation method and device, electronic equipment and storage medium
CN111447268B (en) File structure conversion method, device, equipment and storage medium
CN113885998A (en) Page rendering method and device, electronic equipment and storage medium
CN114385891A (en) Data searching method and device, electronic equipment and storage medium
CN114036431A (en) Page cache skipping method and device, electronic equipment and storage medium
CN113806556A (en) Method, device, equipment and medium for constructing knowledge graph based on power grid data
CN113420042A (en) Data statistics method, device, equipment and storage medium based on presentation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination