CN117251416B - File scanning method, device, computer equipment and storage medium - Google Patents

File scanning method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN117251416B
CN117251416B CN202311490232.5A CN202311490232A CN117251416B CN 117251416 B CN117251416 B CN 117251416B CN 202311490232 A CN202311490232 A CN 202311490232A CN 117251416 B CN117251416 B CN 117251416B
Authority
CN
China
Prior art keywords
data
file
variable
scanning
fileitem
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.)
Active
Application number
CN202311490232.5A
Other languages
Chinese (zh)
Other versions
CN117251416A (en
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.)
Shenzhen Ruan Niu Technology Group Co ltd
Original Assignee
Shenzhen Ruan Niu Technology Group 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 Shenzhen Ruan Niu Technology Group Co ltd filed Critical Shenzhen Ruan Niu Technology Group Co ltd
Priority to CN202311490232.5A priority Critical patent/CN117251416B/en
Publication of CN117251416A publication Critical patent/CN117251416A/en
Application granted granted Critical
Publication of CN117251416B publication Critical patent/CN117251416B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • 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/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies
    • 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/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • 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/178Techniques for file synchronisation in file systems
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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)
  • Library & Information Science (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a file scanning method, a device, computer equipment and a storage medium, wherein the method comprises the following steps: creating a data management structure and a data model through a code construction tool; creating a rootNodeDic dictionary, traversing json file data which are thrown out by a file scanning management class once, obtaining the NodeType type of the json file data, and storing a rootNodeDic dictionary corresponding to the NodeType type; traversing to obtain a RootNode object in a RootNode Dic dictionary, generating a FileItem object, and storing the FileItem object in a variable DataManager allFileItems; synchronously transmitting the FileItem object to a file root node data model, and carrying out screening type assembly by the file root node data model; responding to a search request of a user, traversing the variable DataManager allFileItems based on the search request to obtain a corresponding search result; and/or responding to the scanning request of the user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result. The invention can realize the searching and screening effects of the file tree nodes and improve the applicability of file scanning.

Description

File scanning method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer software technologies, and in particular, to a method and apparatus for scanning a file, a computer device, and a storage medium.
Background
In some current document scanning software, the interaction of document searching and type screening is subject to the user's backlog. In the long searching process, the user cannot quickly screen out the required file types, and cannot quickly search out the matched file names according to the keywords, so that the operation experience of the user is greatly reduced. For example, in a conventional file scanning process, the algorithm flow for creating the file tree node is generally: traversing the current scanned file by using a for loop, traversing the existing tree structure by using a recursion mode, and then finding a corresponding father node in the tree structure according to the path information of the current file traversed by the for loop, and inserting the father node into the child node. The disadvantage of this algorithm is the time complexity O (N)O (k≡log N)), i.e. the temporal complexity is high. Also, the specific time complexity is also affected by the shape of the tree and the nature of the operation, so the efficiency of such algorithms is relatively low. In the process of scanning the file, the method does not support operations such as searching and type screening on the file, or even if the searching operation is supported, the searched data cannot be synchronized in time, so that the using effect is poor.
Disclosure of Invention
The embodiment of the invention provides a file scanning method, a device, computer equipment and a storage medium, which aim to realize the searching and screening effects on file tree nodes and improve the file scanning applicability.
In a first aspect, an embodiment of the present invention provides a file scanning method, including:
creating a data management structure and a data model through a code construction tool; the data management structure comprises a data management class, a file scanning management class and a data screening management class, wherein the data management class comprises a variable DataManager allFileItems, the file scanning management class comprises a variable fileQueue, and the data screening management class comprises a variable fileType; the data model comprises a folder node data model and a file root node data model, wherein the file root node data model comprises variable total Filter FileItems;
creating a rootNodeDic dictionary, traversing json file data which are thrown out by a file scanning management class once to obtain the NodeType of the json file data, and storing a rootNodeDic dictionary corresponding to the NodeType;
traversing to obtain the RootNode object in the RootNode Dic dictionary, generating a FileItem object according to the traversing obtaining result, and storing the FileItem object in a variable DataManager allFileItems;
Synchronously transmitting the FileItem object to a file root node data model, and carrying out screening type assembly by the file root node data model;
responding to a search request of a user, traversing the variable DataManager allFileItems based on the search request to obtain a corresponding search result; and/or responding to a scanning request of a user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result.
In a second aspect, an embodiment of the present invention provides a document scanning apparatus, including:
a data creation unit for creating a data management structure and a data model by a code construction tool; the data management structure comprises a data management class, a file scanning management class and a data screening management class, wherein the data management class comprises a variable DataManager allFileItems, the file scanning management class comprises a variable fileQueue, and the data screening management class comprises a variable fileType; the data model comprises a folder node data model and a file root node data model, wherein the file root node data model comprises variable total Filter FileItems;
the dictionary creation unit is used for creating a rootNodeDic dictionary, traversing json file data which are thrown out by the file scanning management class once to obtain the NodeType type of the json file data, and storing the rootNodeDic dictionary corresponding to the NodeType type;
The first object generating unit is used for traversing and acquiring the RootNode objects in the RootNode Dic dictionary, generating FileItem objects according to traversing and acquiring results, and storing the FileItem objects in a variable DataManager allFileItems;
the screening and assembling unit is used for synchronously transmitting the FileItem object to the file root node data model and carrying out screening type assembling by the file root node data model;
the search scanning unit is used for responding to a search request of a user, traversing the variable DataManager allFileItems based on the search request and obtaining a corresponding search result; and/or responding to a scanning request of a user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result.
In a third aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the file scanning method according to the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, where a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the method of scanning a file according to the first aspect is implemented.
The embodiment of the invention fully embodies a single responsibility principle through good data model construction and data management class division, can support the establishment of tree nodes and the rapid response of the operation demands of users to be simultaneously carried out in the current scanning process while reducing the complexity of data assembly time, and supports the search and screening operation of the users to be displayed in real time, thereby achieving the search and screening effects on the tree nodes of the file and improving the scanning applicability of the file.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a file scanning method according to an embodiment of the present invention;
FIG. 2 is a schematic block diagram of a document scanning device according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a data management structure and a data model created in a file scanning method according to an embodiment of the present invention;
Fig. 4 is a schematic node assembly diagram in a file scanning method according to an embodiment of the present invention;
fig. 5 is a schematic diagram of hash classification in a file scanning method according to an embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating another node assembly in a method for scanning a file according to an embodiment of the present invention;
fig. 7 is a schematic diagram of type screening in a file scanning method according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flow chart of a file scanning method according to an embodiment of the present invention, which specifically includes: steps S101 to S105.
S101, creating a data management structure and a data model through a code construction tool; the data management structure comprises a data management class, a file scanning management class and a data screening management class, wherein the data management class comprises a variable DataManager allFileItems, the file scanning management class comprises a variable fileQueue, and the data screening management class comprises a variable fileType; the data model comprises a folder node data model and a file root node data model, wherein the file root node data model comprises variable total Filter FileItems;
S102, creating a rootNodeDic dictionary, traversing json file data which are thrown out by a file scanning management class once to obtain the NodeType of the json file data, and storing a rootNodeDic dictionary corresponding to the NodeType;
s103, traversing to obtain the RootNode object in the RootNode Dictionary, generating a FileItem object according to the traversing obtaining result, and storing the FileItem object in a variable DataManager allFileItems;
s104, synchronously transmitting the FileItem object to a file root node data model, and carrying out screening type assembly by the file root node data model;
s105, responding to a search request of a user, traversing the variable DataManager allFileItems based on the search request, and obtaining a corresponding search result; and/or responding to a scanning request of a user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result.
In this embodiment, a data model and a data management structure are first created by a code construction tool (e.g., xcode), where the data model specifically includes a plurality of different models, such as a folder node data model and a file root node data model, and the data management structure specifically includes a plurality of different classes, such as a data management class, a file scan management class, and a data filtering management class. Traversing the json file data thrown once based on each data model and each data management structure, and storing the RootNode object corresponding to the json file data into the created rootnodyc dictionary. And traversing the rootNodeDic dictionary to generate a FileItem object and storing the FileItem object in DataManager allFileItems so as to realize tree node assembly. And simultaneously synchronously transmitting the FileItem object to a file root node data model to realize screening type assembly. When a search request or a scanning request of a user is received, traversing the corresponding variables DataManager allFileItems and totalFilterFileItems, thereby obtaining corresponding search results and scanning results.
According to the embodiment, through good data model construction and data management class division, a single responsibility principle is fully embodied, the complexity of data assembly time is reduced, the operation requirements of establishing tree nodes and fast responding users in the current scanning process can be simultaneously met, and searching and screening operations of the users are displayed in real time, so that the searching and screening effects on the tree nodes of the file are achieved, and the file scanning applicability is improved.
In one embodiment, as shown in connection with FIG. 3, (1) a file node data model FileItem is created using Xcode, the model containing the following data:
FileNodeparentNode, wherein, ">"indicates a pointer variable, a pantnode is the name of this variable, this variable is Filenode type data, filenode +.>The pantnode is used for storing which folder node the file belongs to;
long nodeSize for saving file size, where long is a 64 bit integer data;
double modifyTime, a timestamp for file modification;
NodeType nodeType for confirming the type of the file;
NSStringnodeName, wherein, ">"means pointer changeThe quantity, nodeName, is the name of the variable, which is NSString type, NSString means a static plain text Unicode string, NSString +. >The nodeName contains path information of the file.
(2) Creating a folder node data model FileNode using Xcode, the model containing the following data:
NSMutableArrayfileHildrenNodes, wherein, "-is->"indicates pointer variable, fileHildenNodes is variable name, the variable is NSMutableArray type, NSMutableArray indicates array of variable size, which stores FileItem model data, NSMutableArray->The filecaldrennnodes are used for storing file node data;
NSMutableArrayFolderChildrenNodes, wherein, ">"indicates pointer variable, folderchildrenNodes is variable name, the variable is NSMutableArray type, NSMutableArray indicates array of variable size, it stores FileNode model data, NSMutableArray->The folderchild nodes are used for storing the folder node data;
FileNodeparentNode, wherein, ">"indicates a pointer variable, and pantnode is the name of this variable, which is the data of Filenode type, filenode +.>The pantnode is used to point to the parent node.
(3) Creating a file root node data model DiskPartification and inherited FileNode by using Xcode, wherein the model newly comprises the following data:
NSMutableSetasembleFilterSet, wherein, " >"represents a pointer variable, asssembleFilterSet is a variable name, the variable is NSMutableset type, NSMutableset represents a variable-sized collection, data of FileItem model is stored, the data collection cannot contain the same data, NSMutableset->The asssembleFilterSet is used for storing data waiting to be assembled after screening in the scanning process;
NSMutableArraytotal filters fileitems, wherein, ">"indicates pointer variable, totalFilterItems is variable name, the variable is NSMutableArray type, NSMutableArray indicates array of changeable size, and FileItem model data is stored, NSMutableArray->the total FilterFileItems are used for storing all file objects screened;
with reference to fig. 4, fileitem, fileNode, diskPartition, when assembled, creates the tree node relationship shown in fig. 4. It will be appreciated that this is by way of example only, and that in practice the specifications of real tree nodes are much larger.
(4) Creating a node data model RootNode using Xcode, the model containing the following data:
NSMutableDictionarysamePathNode, wherein, ">"represents a pointer variable, samepothnode is a variable name, the variable is NSMutableDictionary type, NSMutableDictionary represents a dictionary of variable size, and the dictionary represents key values: key-value data set, NSMutabledictionary- >The samePathNode is used for storing file information of the same path in single cast data.
(5) Creating a file scanning management class DiskEntityManager by using Xcode, wherein the management class DiskEntityManager is responsible for scanning disk file data and comprises the following variables:
NSOperationQueuefileQueue, wherein, "-is->"represents a pointer variable, fileQueue is a variable name, the variable is of the NSOperation Queue type, NSOperation Queue is an operation queue that can execute specified code in a row, NSOperation Queue->fileQueue is used to asynchronously construct tree nodes,
BOOL isAssembling, wherein BOOL represents a Boolean variable, which has only two values: true and false, isAssembling is a variable name, BOOL isAssembling to identify whether fileQueue is assembling a node.
(6) Creating a data management class DataManager by using the Xcode, wherein the data management class DataManager is used for storing data nodes and nodes in a scanning process and comprises the following data:
DiskPartitiontreeleotonode, wherein, "-is->"indicates pointer variable, treenotNode is variable name, the variable is DiskPartity type, diskPartity +.>treeRootNode is taken as a root node of a disk file directory;
NSMutableDictionarytreenode cache, wherein, "-is->"represents a pointer variable, trenodecache is a variable name, the variable is nsmusabledictionary type, nsmusabledictionary represents a dictionary of variable size, and the dictionary represents key values: key-value data set, NSMutabledictionary- >the treeNodeCache is used for caching all file node objects of the folder node in the scanning process;
NSMutableSetallFileItems, wherein, "-is->"represents a pointer variable, allFileItems is a variable name, the variable is NSMubleSet type, NSMubleSet represents a variable-sized collection, data of FileItem model is stored, the data collection cannot contain the same data, NSMubleDictionary>the treeNodeCache is used for caching all file information;
NSStringsearchKeyWord, wherein, "-j->"represents pointer variable, searchKeyWord is variable name, this variable is NSString type, NSString represents a static plain text Unicode string, NSString>The searchKeyWord is used for storing search keywords input by the user interface;
NSMutableSetsearchItems, wherein, ">"indicates pointer variable, searchItems is variable name, this variable is NSMutableset type, NSMutableset indicates a variable-sized collection, data of FileItem model is stored, this data collection cannot contain the same data, NSMutableset->The searchItems are used for storing the searched file object FileItem;
NSMutableArraySearchFilterItems, wherein, ">"represents pointer variable, searchFilterItems is variable name, this variable is NSMutableArray type, NSMutableArray represents array whose size can be changed, and stored is FileItem model data, NSMutableArray- >The searchFilterItems are used to save filter data on a search basis.
(7) And creating a data screening management class FilterManager by using the Xcode, which is responsible for relevant data processing of file type screening and provides screening according to the file size, the file creation time and the file tag type. Comprising the following data:
FilterType filterType, wherein the fileType is a variable name, the FilterType is a custom filter enumeration type, filterType filterType represents a file type of the filter,
DiskPartitioncurrentFilterNode, wherein, "-is->"indicates pointer variable, currentFilterNode is variable name, diskPartitation +.>currentFilterNode represents the root node of the file currently being screened.
In one embodiment, the step S102 includes:
setting the variable isAssembling of the file scanning management class as true, traversing to obtain json file data which is thrown out by the file scanning management class once, and judging whether the variable fileQueue is paused;
if the variable fileQueue is judged to be suspended, adding the operation code block into a queue of the variable fileQueue to wait for execution;
if the variable fileQueue is judged not to be suspended, a rootNodeDic dictionary for storing the RootNode object is created;
traversing json file data to obtain corresponding file information, and confirming the NodeType type of the json file data according to the file information;
Judging whether a RootNode dictionary has a corresponding type of RootNode object or not;
if the corresponding type of the Roonode object does not exist, the Roonode object is created in the Roonode Dic dictionary and stored, and then the file information is stored in a samePathNode array of the Roonode object.
In conjunction with fig. 5, the present embodiment reduces the number of file searches for the folder node during the data assembly process by hashing the single data. Specifically, diskEntityManager isAssembling is first set to true, which indicates that the file scan management class disktitymanager is assembling process data. And traversing to obtain json file data which is thrown out by the DiskEntityManager once, and judging whether the fileQueue is paused or not. Here, json file data is captured by a code block of a fileQueue, and the fileQueue, as a queue, captures a plurality of json file data and performs serial processing, that is, the subsequently captured data needs to wait for the currently processed data to be processed after the execution is completed. If the fileQueue is paused, an operation block code block is added to the fileQueue for waiting to be executed, wherein the block code block is an encoding mode of an Objective-C programming language, and can capture variables of a code context, and the advantage is that: even after the current function is executed, the variables are not destroyed because they have been captured. If the fileQueue is not paused, the data processing is directly performed. That is, a dictionary named rootnoddic is created for saving rootnoddic, then json data is traversed to obtain single file information, and the file information is confirmed to belong to which type of NodeType, for example, the type of NodeType can be judged according to fields type, is_exists, is_lost_location and name, so that whether the rootnoddic has the rootnoddic of the type is confirmed, if not, the rootnoddic is created and saved, and then the file information is saved in a rootnodode array of the rootnodiode object samePathNode.
In one embodiment, the step S103 includes:
traversing the rootnodyc dictionary to obtain all RootNode objects in the rootnodyc dictionary;
traversing all the samePathNode attributes corresponding to the RootNode to obtain all the file information;
judging whether the treeNodeCache of the data management class has a corresponding folder cache FileNode according to the file path in the file information;
if the corresponding folder cache FileNode exists, generating a FileItem object from each file information, and storing the FileItem object into the FileNode's fileHildrenNodes attribute and DataManager allFileItems;
if it is judged that the corresponding folder cache FileNode does not exist, searching a last cached folder node according to the file path sequence in the file information, sequentially creating FileNode objects according to the rest of the non-created path nodes, and then storing the FileNode objects in the FileNode attribute folderChildrenNodes of the last path node;
when the file information is saved to the last FileNode, all the file information is generated into a FileItem object, and the FileHildrenNodes attribute and DataManager allFileItems of the last FileNode are saved.
In this embodiment, the data management class DataManager further processes the rootnodic to perform tree node assembly. Specifically, referring to fig. 6, first, the rootNodeDic is traversed to obtain all the RootNode objects therein, then the samepothnode attribute of the RootNode is traversed to obtain all the file information, and then whether the treenode cache of the DataManager has the corresponding folder cache FileNode is determined according to the file path. If the cache exists, generating a FileItem object from each file information, and storing the FileItem object into the FileHildrenNodes attribute and DataManager allFileItems of the cache FileNode. If the buffer memory does not exist, searching the last buffered file folder node according to the sequence from the tail to the head of the file path, sequentially creating the file node objects according to the rest path nodes which are not created, storing the file node objects into the file node attribute folderchild nodes of the last path node, generating all file information into file item objects when the file node is stored into the last file node, and storing the file item objects into the filichilrennodes attribute and DataManager allFileItems of the last file node.
In one embodiment, the step S104 includes:
synchronously transmitting the FileItem object to a file root node data model, and storing the file root node data model into a corresponding set according to the object information of the FileItem object;
judging whether the variable filetype of the data screening management class is empty or not, and when the variable filetype is not empty, adding a FileItem object into an assaileselterset attribute of an attribute currentFilterNode of the data screening management class, and waiting for assembly after all data processing is finished;
and judging whether the variable searchKeyWord of the data management class is empty or not, and adding the FileItem object into the attribute searchFilterItems of the data management class when the variable searchKeyWord is not empty.
While adding FileItem, the embodiment also synchronously transmits the FileItem to the root node (DiskPartition class) for filtering type assembly. Specifically, in connection with fig. 7, the root node stores information such as the size nodeSize, modification time modifier time, and label nodeType of the FileItem into the corresponding set. If the FilterManager attribute fileType is not null, judging whether the FileItem accords with the current screening rule, then adding the FileItem into an assaileFilterSet attribute of the FilterManager attribute currentFilterNode, and waiting for assembly after all data processing is completed. Further, if DataManager searchKeyWord is not null, it is determined whether the FileItem conforms to the current filtering rule and contains a search key, and if so, it is added to the DataManager attribute searchFilterItems.
Further, it is determined whether DataManager searchKeyWord is empty, if not, it is further determined whether the file name nodeName of the file object FileItem contains a search key, and if so, it is added to DataManager searchItems. The variable isAssembling is then reset and DiskEntityManager isAssembling is set to false, indicating that a single node is assembled.
In one embodiment, the step S105 includes:
extracting a search keyword based on the search request;
traversing the variable DataManager allFileItems to obtain a search FileItem object containing a search key;
and adding the searching FileItem object into variable searchItems, and carrying out interface updating by taking the variable searchItems as a searching data source.
In this embodiment, when the user inputs a search keyword on the operation interface, the search function in the scanning process is triggered. I.e., traverse DataManager allFileItems, find all FileItem objects whose file names contain search keywords, and then add to the searchItems. When the next time the scan data continues to be thrown, the step of adding to search is performed, and the interface component takes the searchItems as a data source and performs interface updating.
In an embodiment, the step S105 further includes:
extracting screening conditions based on the scanning request, screening treRootNode objects of the data management class according to the screening conditions to obtain screening results, and storing the screening results to a variable total Filter FileItem;
generating a copy of the screening result by using a variable treeRootNode, and assigning the copy to a variable currentFilterNode of a data screening management class;
traversing the variable total Filter FileItems to obtain all FileItem model data, and judging whether a variable treeNodeCache of the data screening management class has a corresponding folder cache FileNode according to a file path in the FileItem model data;
if the corresponding folder cache FileNode exists, storing the FileItem model data into the fileHildrenNodes attribute of the cache FileNode;
if the corresponding folder cache FileNode does not exist, creating a screening FileNode object according to the FileItem model data, and storing the FileItem model data into the fileHildrenNodes attribute of the screening FileNode object;
and updating the interface by taking the variable currentFilter node of the data screening management class as a scanning data source.
In some alternative embodiments, before the step of traversing the variable totalFilterFileItems to obtain all FileItem model data, the step of:
pausing a variable fileQueue of the file scanning management class, and judging whether a variable isAssembling of the file scanning management class is in an assembled data state or not;
if the variable isAssembling is in an assembled data state, waiting for a current assembled state;
and if the variable isAssembling is not in the assembled data state, clearing the last screening condition and the last screening data.
In this embodiment, when the user selects the file type at the operation interface, the screening function in the scanning process is triggered. Specifically, the disktitymanager's fileQueue is paused first, so that the data thrown by the subsequent scan will be added to the queue for assembly and not immediately executed. Then, it is determined DiskEntityManager isAssembling whether data is being assembled, and if data is being assembled, it is waited for the completion of the present assembly. And then clearing the last screening condition and data, and storing the data in a total filter files items after screening according to the screening condition by the DataManager treeRootNode object, generating a copy by the treeleotonode, and assigning the copy to FilterManager currentFilterNode. And traversing the total FilterFileItems to obtain all the FileItem model data, and judging whether the treeNodeCache of the FilterManager has a corresponding folder cache FileNode according to the file path nodeName in the model data. If the cache exists, storing the FileItem model data into the fileHildrenNodes attribute of the cache FileNode; if the buffer memory does not exist, searching a last buffered file folder node according to the sequence from the tail to the head of the file path, sequentially creating a FileNode object according to the rest path nodes which are not created, storing the FileNode object into the FileNode attribute folderChildrenNodes of the last path node, and storing the FileItem model data into the fileHildrenNodes attribute of the last FileNode when the last FileNode is stored. After the assembly is completed, the interface component refreshes the interface for the data source according to FilterManager currentFilterNode, displays the screening data, then resumes the fileQueue, and continues to assemble the data. Through the above process, the data of the FilterManager and the DataManager can be assembled and isolated at the same time, and the FilerManager or the DataManager is selected for interface updating according to whether the user sets the screening conditions.
It will be appreciated that after the user performs the search, the data is saved in DataManager searchItems, and if the filtering operation is performed at this time, only the searchItems need to be traversed, and the searchItems are updated after the data is filtered according to the filtering condition, and then the interface component is refreshed.
Fig. 2 is a schematic block diagram of a document scanning apparatus 200 according to an embodiment of the present invention, where the apparatus 200 includes:
a data creation unit 201 for creating a data management structure and a data model by a code construction tool; the data management structure comprises a data management class, a file scanning management class and a data screening management class, wherein the data management class comprises a variable DataManager allFileItems, the file scanning management class comprises a variable fileQueue, and the data screening management class comprises a variable fileType; the data model comprises a folder node data model and a file root node data model, wherein the file root node data model comprises variable total Filter FileItems;
the dictionary creation unit 202 is configured to create a rootnodyc dictionary, traverse json file data that is thrown out by the file scanning management class once, obtain a NodeType type of the json file data, and store a rootnodyc object corresponding to the NodeType type in the rootnodyc dictionary;
A first object generating unit 203, configured to traverse and acquire a RootNode object in the rootnodyc dictionary, generate a FileItem object according to a traversing and acquiring result, and store the FileItem object in a variable DataManager allFileItems;
the filtering and assembling unit 204 is configured to synchronously transfer the FileItem object to the file root node data model, and perform filtering type assembling by using the file root node data model;
a search scanning unit 205, configured to respond to a search request of a user, and traverse a variable DataManager allFileItems based on the search request to obtain a corresponding search result; and/or responding to a scanning request of a user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result.
In an embodiment, the dictionary creating unit 202 includes:
the pause judging unit is used for setting the variable isAssembling of the file scanning management class to be true, traversing to obtain json file data which is thrown out by the file scanning management class once, and judging whether the variable fileQueue is paused or not;
a suspension determination unit, configured to, if it is determined that the variable fileQueue is suspended, add the operation code block to a queue of the variable fileQueue for waiting for execution;
The non-suspension judging unit is used for creating a rootnodyc dictionary for storing the RootNode object if the judging variable fileQueue is not suspended;
the type confirming unit is used for traversing the json file data to obtain corresponding file information and confirming the NodeType type of the json file data according to the file information;
the object judging unit is used for judging whether the rootnodyc dictionary has a corresponding type of rootnod object;
and the information storage unit is used for creating the RootNode object in the RootNodeDic dictionary and storing the RootNode object if the RootNode object of the corresponding type does not exist, and then storing the file information into a samePathNode array of the RootNode object.
In an embodiment, the first object generating unit 203 includes:
the dictionary traversing unit is used for traversing the rootNodeDic dictionary to obtain all the rootNodeDic objects;
the attribute traversing unit is used for traversing all the samePathNode attributes corresponding to the RootNode to acquire all the file information;
the buffer judgment unit is used for judging whether the treNodeCache of the data management class has a corresponding folder buffer FileNode according to the file path in the file information;
the first object caching unit is used for generating a FileItem object from each file information if the corresponding folder cache FileNode exists, and storing the FileItem object into the FileHildrenNodes attribute and DataManager allFileItems of the cache FileNode;
The second object caching unit is used for searching the last cached folder node according to the file path sequence in the file information if the corresponding folder cache folder node is judged not to exist, sequentially creating the folder node objects according to the rest of the non-created path nodes, and then storing the folder node objects in the folder child nodes of the last path node;
and the second object generating unit is used for generating the FileItem object from all the file information when the last FileNode is saved, and saving the FileHildrenNodes attribute and DataManager allFileItems of the last FileNode.
In one embodiment, the screening assembly unit 204 includes:
the synchronous transfer unit is used for synchronously transferring the FileItem object to the file root node data model, and storing the FileItem object into a corresponding set by the file root node data model according to the object information of the FileItem object;
the first object adding unit is used for judging whether the variable filetype of the data screening management class is empty or not, adding the FileItem object into an assureFilterSet attribute of an attribute currentFilterNode of the data screening management class when the variable filetype is not empty, and waiting for assembly after all data are processed;
And the second object adding unit is used for judging whether the variable searchKeyWord of the data management class is empty or not, and adding the FileItem object into the attribute searchFilterItems of the data management class when the variable searchKeyWord is not empty.
In one embodiment, the search scanning unit 205 includes:
a keyword extraction unit configured to extract a search keyword based on the search request;
a search object obtaining unit for traversing the variable DataManager allFileItems to obtain a search FileItem object containing a search keyword;
and the first interface updating unit is used for adding the search FileItem object into the variable searchItems and carrying out interface updating by taking the variable searchItems as a search data source.
In an embodiment, the search scanning unit 205 further includes:
the condition extraction unit is used for extracting screening conditions based on the scanning request, screening treRootNode objects of the data management class according to the screening conditions to obtain screening results, and storing the screening results to a variable total Filter FileItem;
the copy generation unit is used for generating a copy of the screening result by using a variable treeRootNode and assigning the copy to a variable currentFilterNode of a data screening management class;
The model data acquisition unit is used for traversing the variable total Filter FileItems to acquire all FileItem model data, and judging whether a variable treeNodeCache of the data screening management class has a corresponding folder cache FileNode according to a file path in the FileItem model data;
the first model saving unit is used for saving the FileItem model data to the fileHildrenNodes attribute of the buffer FileNode if the corresponding folder buffer FileNode exists;
the second model saving unit is used for creating a filter file node object according to the file item model data if the corresponding file folder cache file node does not exist, and saving the file item model data to the filefolder renNodes attribute of the filter file node object;
and the second interface updating unit is used for updating the interface by taking the variable currentFilter node of the data screening management class as a scanning data source.
In an embodiment, the search scanning unit 205 further includes:
the assembly judging unit is used for suspending the variable fileQueue of the file scanning management class and judging whether the variable isAssembling of the file scanning management class is in an assembly data state or not;
the assembly waiting unit is used for waiting for the current assembly state if the variable isAssembling is in the assembly data state;
And the screening and emptying unit is used for emptying the last screening condition and screening data if the variable isAssembling is not in the assembled data state.
Since the embodiments of the apparatus portion and the embodiments of the method portion correspond to each other, the embodiments of the apparatus portion are referred to the description of the embodiments of the method portion, and are not repeated herein.
The embodiment of the present invention also provides a computer readable storage medium having a computer program stored thereon, which when executed can implement the steps provided in the above embodiment. The storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The embodiment of the invention also provides a computer device, which can comprise a memory and a processor, wherein the memory stores a computer program, and the processor can realize the steps provided by the embodiment when calling the computer program in the memory. Of course, the computer device may also include various network interfaces, power supplies, and the like.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section. It should be noted that it would be obvious to those skilled in the art that various improvements and modifications can be made to the present application without departing from the principles of the present application, and such improvements and modifications fall within the scope of the claims of the present application.
It should also be noted that in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A document scanning method, comprising:
creating a data management structure and a data model through a code construction tool; the data management structure comprises a data management class, a file scanning management class and a data screening management class, wherein the data management class comprises a variable DataManager allFileItems, the file scanning management class comprises a variable fileQueue, and the data screening management class comprises a variable fileType; the data model comprises a folder node data model and a file root node data model, wherein the file root node data model comprises variable total Filter FileItems;
Creating a rootNodeDic dictionary, traversing json file data which are thrown out by a file scanning management class once to obtain the NodeType of the json file data, and storing a rootNodeDic dictionary corresponding to the NodeType;
traversing to obtain the RootNode object in the RootNode Dic dictionary, generating a FileItem object according to the traversing obtaining result, and storing the FileItem object in a variable DataManager allFileItems;
synchronously transmitting the FileItem object to a file root node data model, and carrying out screening type assembly by the file root node data model;
responding to a search request of a user, traversing the variable DataManager allFileItems based on the search request to obtain a corresponding search result; and/or responding to a scanning request of a user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result.
2. The method of claim 1, wherein creating a rootnodic dictionary, traversing json file data that is thrown out by a file scan management class once to obtain a NodeType of the json file data, and storing a RootNode object corresponding to the NodeType in the rootnodic dictionary, comprises:
Setting the variable isAssembling of the file scanning management class as true, traversing to obtain json file data which is thrown out by the file scanning management class once, and judging whether the variable fileQueue is paused;
if the variable fileQueue is judged to be suspended, adding the operation code block into a queue of the variable fileQueue to wait for execution;
if the variable fileQueue is judged not to be suspended, a rootNodeDic dictionary for storing the RootNode object is created;
traversing json file data to obtain corresponding file information, and confirming the NodeType type of the json file data according to the file information;
judging whether a RootNode dictionary has a corresponding type of RootNode object or not;
if the corresponding type of the Roonode object does not exist, the Roonode object is created in the Roonode Dic dictionary and stored, and then the file information is stored in a samePathNode array of the Roonode object.
3. The method of claim 1, wherein the traversing obtains the RootNode object in the RootNode dic dictionary, generates a FileItem object according to a traversing obtaining result, and stores the FileItem object in a variable DataManager allFileItems, and comprises:
traversing the rootnodyc dictionary to obtain all RootNode objects in the rootnodyc dictionary;
Traversing all the samePathNode attributes corresponding to the RootNode to obtain all the file information;
judging whether the treeNodeCache of the data management class has a corresponding folder cache FileNode according to the file path in the file information;
if the corresponding folder cache FileNode exists, generating a FileItem object from each file information, and storing the FileItem object into the FileNode's fileHildrenNodes attribute and DataManager allFileItems;
if it is judged that the corresponding folder cache FileNode does not exist, searching a last cached folder node according to the file path sequence in the file information, sequentially creating FileNode objects according to the rest of the non-created path nodes, and then storing the FileNode objects in the FileNode attribute folderChildrenNodes of the last path node;
when the file information is saved to the last FileNode, all the file information is generated into a FileItem object, and the FileHildrenNodes attribute and DataManager allFileItems of the last FileNode are saved.
4. The method of claim 1, wherein the step of synchronously transferring the FileItem object to the fileroot node data model and assembling the filter types by the fileroot node data model comprises:
Synchronously transmitting the FileItem object to a file root node data model, and storing the file root node data model into a corresponding set according to the object information of the FileItem object;
judging whether the variable filetype of the data screening management class is empty or not, and when the variable filetype is not empty, adding a FileItem object into an assaileselterset attribute of an attribute currentFilterNode of the data screening management class, and waiting for assembly after all data processing is finished;
and judging whether the variable searchKeyWord of the data management class is empty or not, and adding the FileItem object into the attribute searchFilterItems of the data management class when the variable searchKeyWord is not empty.
5. The method of claim 1, wherein responding to the search request of the user, traversing the variable DataManager allFileItems based on the search request, and obtaining the corresponding search result comprises:
extracting a search keyword based on the search request;
traversing the variable DataManager allFileItems to obtain a search FileItem object containing a search key;
and adding the searching FileItem object into variable searchItems, and carrying out interface updating by taking the variable searchItems as a searching data source.
6. The method for scanning files according to claim 1, wherein responding to the scanning request of the user, traversing variable total filterfileitems based on the scanning request to obtain corresponding scanning results, includes:
extracting screening conditions based on the scanning request, screening treRootNode objects of the data management class according to the screening conditions to obtain screening results, and storing the screening results to a variable total Filter FileItem;
generating a copy of the screening result by using a variable treeRootNode, and assigning the copy to a variable currentFilterNode of a data screening management class;
traversing the variable total Filter FileItems to obtain all FileItem model data, and judging whether a variable treeNodeCache of the data screening management class has a corresponding folder cache FileNode according to a file path in the FileItem model data;
if the corresponding folder cache FileNode exists, storing the FileItem model data into the fileHildrenNodes attribute of the cache FileNode;
if the corresponding folder cache FileNode does not exist, creating a screening FileNode object according to the FileItem model data, and storing the FileItem model data into the fileHildrenNodes attribute of the screening FileNode object;
And updating the interface by taking the variable currentFilter node of the data screening management class as a scanning data source.
7. The method of claim 6, wherein before the step of traversing the variable totalfilefileitems to obtain all FileItem model data, comprising:
pausing a variable fileQueue of the file scanning management class, and judging whether a variable isAssembling of the file scanning management class is in an assembled data state or not;
if the variable isAssembling is in an assembled data state, waiting for a current assembled state;
and if the variable isAssembling is not in the assembled data state, clearing the last screening condition and the last screening data.
8. A document scanning apparatus, comprising:
a data creation unit for creating a data management structure and a data model by a code construction tool; the data management structure comprises a data management class, a file scanning management class and a data screening management class, wherein the data management class comprises a variable DataManager allFileItems, the file scanning management class comprises a variable fileQueue, and the data screening management class comprises a variable fileType; the data model comprises a folder node data model and a file root node data model, wherein the file root node data model comprises variable total Filter FileItems;
The dictionary creation unit is used for creating a rootNodeDic dictionary, traversing json file data which are thrown out by the file scanning management class once to obtain the NodeType type of the json file data, and storing the rootNodeDic dictionary corresponding to the NodeType type;
the first object generating unit is used for traversing and acquiring the RootNode objects in the RootNode Dic dictionary, generating FileItem objects according to traversing and acquiring results, and storing the FileItem objects in a variable DataManager allFileItems;
the screening and assembling unit is used for synchronously transmitting the FileItem object to the file root node data model and carrying out screening type assembling by the file root node data model;
the search scanning unit is used for responding to a search request of a user, traversing the variable DataManager allFileItems based on the search request and obtaining a corresponding search result; and/or responding to a scanning request of a user, traversing the variable total Filter items based on the scanning request, and obtaining a corresponding scanning result.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of scanning a file as claimed in any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the file scanning method according to any of claims 1 to 7.
CN202311490232.5A 2023-11-10 2023-11-10 File scanning method, device, computer equipment and storage medium Active CN117251416B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311490232.5A CN117251416B (en) 2023-11-10 2023-11-10 File scanning method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311490232.5A CN117251416B (en) 2023-11-10 2023-11-10 File scanning method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117251416A CN117251416A (en) 2023-12-19
CN117251416B true CN117251416B (en) 2024-03-29

Family

ID=89137127

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311490232.5A Active CN117251416B (en) 2023-11-10 2023-11-10 File scanning method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117251416B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112579151A (en) * 2019-09-30 2021-03-30 北京京东尚科信息技术有限公司 Method and device for generating model file
WO2022057460A1 (en) * 2020-09-18 2022-03-24 苏州浪潮智能科技有限公司 Mass file retrieval method and apparatus based on ai training platform, and device
CN114527991A (en) * 2022-02-09 2022-05-24 腾讯科技(深圳)有限公司 Code scanning method, device, equipment, storage medium and program product
CN115473969A (en) * 2022-08-23 2022-12-13 苏州乐众信息技术有限公司 Method and device for scanning file, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112579151A (en) * 2019-09-30 2021-03-30 北京京东尚科信息技术有限公司 Method and device for generating model file
WO2022057460A1 (en) * 2020-09-18 2022-03-24 苏州浪潮智能科技有限公司 Mass file retrieval method and apparatus based on ai training platform, and device
CN114527991A (en) * 2022-02-09 2022-05-24 腾讯科技(深圳)有限公司 Code scanning method, device, equipment, storage medium and program product
CN115473969A (en) * 2022-08-23 2022-12-13 苏州乐众信息技术有限公司 Method and device for scanning file, computer equipment and storage medium

Also Published As

Publication number Publication date
CN117251416A (en) 2023-12-19

Similar Documents

Publication Publication Date Title
US11288231B2 (en) Reproducing datasets generated by alert-triggering search queries
CA2722320C (en) Paging hierarchical data
WO2007085187A1 (en) Method of data retrieval, method of generating index files and search engine
CN111858760B (en) Data processing method and device for heterogeneous database
CN111859132A (en) Data processing method and device, intelligent equipment and storage medium
CN111722984A (en) Alarm data processing method, device, equipment and computer storage medium
CN110704861B (en) Method, device and system for real-time desensitization based on open interface
CN112667860A (en) Sub-graph matching method, device, equipment and storage medium
CN112491609A (en) System application architecture discovery method and system based on business service
US9390131B1 (en) Executing queries subject to different consistency requirements
CN117251416B (en) File scanning method, device, computer equipment and storage medium
CN106844553B (en) Data detection and expansion method and device based on sample data
CN107577809A (en) Offline small documents processing method and processing device
CN110659295B (en) Method, apparatus and medium for recording valid data based on HAWQ
CN115827702B (en) Software white list query method based on bloom filter
CN108121807B (en) Method for realizing multi-dimensional Index structure OBF-Index in Hadoop environment
CN111046106A (en) Cache data synchronization method, device, equipment and medium
CN110389939A (en) A kind of Internet of Things storage system based on NoSQL and distributed file system
CN114579059A (en) File data migration method, device, equipment and storage medium
CN112765200A (en) Data query method and device based on Elasticissearch
CN106933826B (en) Data preprocessing method and device
CN111984807B (en) Content screening and storing method and system
CN115422245A (en) Reordering method for graph data locality mining
CN113988282A (en) Programmable access engine architecture for graph neural networks and graph applications
CN117453812A (en) Method and device for synchronizing data of database in real time

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
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: 1301-1310, building 2, jinlitong financial center building, 1100 Xingye Road, Haiwang community, Xin'an street, Bao'an District, Shenzhen, Guangdong 518000

Applicant after: Shenzhen Ruan Niu Technology Group Co.,Ltd.

Address before: 1301-1310, building 2, jinlitong financial center building, 1100 Xingye Road, Haiwang community, Xin'an street, Bao'an District, Shenzhen, Guangdong 518000

Applicant before: AFIRSTSOFT CO.,LTD.

Country or region before: China

GR01 Patent grant
GR01 Patent grant