Information reading method and device, equipment and storage medium

By generating scan control instructions based on the file attribute information and historical attribute information of the peripheral in the Android system, files are scanned only when necessary, and the problem of low reading efficiency in the on-board system is solved every time the peripheral is plugged in, and the implementation of More efficient information reading and lower system overhead.

CN119440864AActive Publication Date: 2025-02-14CHENGDU CELIS TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411424329.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2025-02-14
Estimated Expiration
2044-10-12

AI Technical Summary

Technical Problem

In the on-board system, every time a USB flash drive or other peripheral is removed, the Android system must re-read the file information stored in the peripheral, resulting in low reading efficiency and triggering full scanning when the file is not updated. , increase system overhead.

Method used

By listening to peripheral insertion events, reading file attribute information and historical attribute information, and generating scan control instructions. Only complete or target scans are performed when the file attribute information and historical attribute information are not at the same time, avoid file scanning without updates, and use producer threads and consumer threads to work in parallel to improve efficiency.

Benefits of technology

Reduces unnecessary file scanning, improves information reading efficiency, reduces system overhead, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440864A_ABST
    Figure CN119440864A_ABST
Patent Text Reader

Abstract

The invention relates to an information reading method and device, equipment and a storage medium. The method comprises the steps that after an insertion event corresponding to a peripheral is monitored, file attribute information corresponding to the peripheral is read from the peripheral, and historical attribute information corresponding to the peripheral is acquired locally; generating a scanning control instruction according to the file attribute information and the historical attribute information; when the type of the scanning control instruction is a scanning starting type, scanning a file stored in the peripheral by utilizing a producer thread, and adding file information corresponding to the file into a producer queue; analyzing the file information in the producer queue by using a consumer thread and storing the analyzed file information in a local storage space; the producer thread and the consumer thread work in parallel. According to the method and the device, the file stored in the peripheral is scanned only when the type of the scanning control instruction is the scanning starting type, so that the problem that the information reading efficiency is reduced due to the fact that the peripheral is scanned under the condition that the file stored in the peripheral is not changed is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle technology, and in particular to an information reading method, device, equipment and storage medium. Background Art

[0002] As the entertainment functions of smart cars become more and more abundant, users have an increasing demand for the in-vehicle system to read file information stored in peripherals. For example, more and more users will store media, pictures and other files in USB flash drives, and during driving, the in-vehicle system will read the media, pictures and other files in the USB flash drive for playback and browsing. At present, the underlying system of most smart cars uses the Android system. Reading the file information stored in the peripheral includes: after the Android system detects that the USB flash drive is inserted, the Media Scanner module in the Android system first fully scans all the files in the USB flash drive and stores the file information of each file in the preset queue during the scanning process. After the full scan is completed, the file information stored in the queue is parsed one by one and the parsed file information is stored in the in-vehicle system.

[0003] However, in the vehicle scenario, users often plug in and out peripherals such as USB flash drives, and each time the peripherals are plugged in and out, the Android system must re-read the file information stored in the peripherals, which results in low efficiency when the Android system reads the file information stored in the peripherals. Furthermore, when the files in the peripherals have not been updated, regardless of whether the files in the peripherals have been fully scanned before, the Android system will still trigger the full scan function each time it monitors the plugging and unplugging of the peripherals, thereby generating additional system overhead and affecting the efficiency of information reading. When performing a full scan, if there are many media, pictures and other files in the peripherals, the full scan time is relatively long, resulting in low scanning efficiency and affecting the user experience. In addition, a full scan requires scanning of all file types, even file types that the user does not need, which further reduces the scanning efficiency. Summary of the invention

[0004] The present application provides an information reading method, apparatus, device and storage medium to solve the problem that the Android system has to re-read the file information stored in the peripheral each time the peripheral is unplugged or plugged in, resulting in low efficiency when the Android system reads the file information stored in the peripheral.

[0005] In view of the above technical problems, the technical solution of this application is solved by the following embodiments:

[0006] An embodiment of the present application provides an information reading method, comprising: after monitoring an insertion event corresponding to a peripheral device, reading file attribute information corresponding to the peripheral device from the peripheral device and acquiring historical attribute information corresponding to the peripheral device locally; generating a scan control instruction according to the file attribute information and the historical attribute information; when the type of the scan control instruction is a start scan type, using a preset producer thread, scanning files stored in the peripheral device and adding file information corresponding to the files to a preset producer queue; using a preset consumer thread, parsing the file information in the producer queue and storing the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0007] Among them, generating a scanning control instruction according to the file attribute information and the historical attribute information includes: if the file attribute information and the historical attribute information are different, generating a scanning control instruction of a start scanning type; if the file attribute information and the historical attribute information are the same, querying whether there is file information corresponding to the peripheral device in the local storage space; if the file information corresponding to the peripheral device exists in the local storage space, generating a scanning control instruction of a prohibit scanning type; if the file information corresponding to the peripheral device does not exist in the local storage space, generating a scanning control instruction of a start scanning type.

[0008] Among them, the scanning control instruction of the start scanning type includes: a target scanning control instruction and a full scanning control instruction; the using of a preset producer thread to scan the files stored in the peripheral device includes: if the scanning control instruction is a target type scanning control instruction of the start scanning type, then using the producer thread to scan the files stored in the peripheral device that meet the preset conditions; if the scanning control instruction is a full type scanning control instruction of the start scanning type, then using the producer thread to scan all files stored in the peripheral device.

[0009] Among them, the consumer thread includes: a parsing consumer thread and a storage consumer thread; the use of the preset consumer thread to parse the file information in the producer queue and store the parsed file information to the preset local storage space includes: using the parsing consumer thread to parse the file information in the producer queue and adding the parsed file information to the preset consumer queue; using the storage consumer thread to generate a label value corresponding to the file information in the consumer queue, and storing the file information to the local storage space according to the label value corresponding to the file information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0010] Among them, the consumer thread includes: a parsing consumer thread and a storage consumer thread; the use of the preset consumer thread to parse the file information in the producer queue and store the parsed file information in the preset local storage space includes: using the parsing consumer thread to parse the preset fields of the file information in the producer queue and adding the parsed field information to the preset consumer queue; using the storage consumer thread to generate a label value corresponding to the field information in the consumer queue, and storing the field information in the local storage space according to the label value corresponding to the field information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0011] The utilizing a preset consumer thread to parse the file information in the producer queue includes: utilizing the consumer thread to call a preset third-party processing framework; and parsing the file information in the producer queue through the third-party processing framework.

[0012] The method further includes: if the file attribute information and the historical attribute information are different, updating the historical attribute information according to the file attribute information.

[0013] An embodiment of the present application also provides an information reading device, including: a reading and acquisition module, which is used to read the file attribute information corresponding to the peripheral from the peripheral and obtain the historical attribute information corresponding to the peripheral locally after monitoring the insertion event corresponding to the peripheral; a generation module, which is used to generate a scan control instruction according to the file attribute information and the historical attribute information; a scanning and adding module, which is used to use a preset producer thread to scan the files stored in the peripheral and add the file information corresponding to the files to a preset producer queue when the type of the scan control instruction is a start scan type; a parsing and storage module, which is used to use a preset consumer thread to parse the file information in the producer queue and store the parsed file information to a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0014] An embodiment of the present application also provides an information reading device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to: execute an information reading program stored in the memory to implement any of the above-described information reading methods.

[0015] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed to implement any of the above-mentioned information reading methods.

[0016] The above-mentioned technical scheme provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application can read the file attribute information corresponding to the peripheral device from the peripheral device and obtain the historical attribute information corresponding to the peripheral device locally after monitoring the insertion event corresponding to the peripheral device; generate a scanning control instruction according to the file attribute information and the historical attribute information; when the type of the scanning control instruction is the start scanning type, use a preset producer thread to scan the files stored in the peripheral device and add the file information corresponding to the file to a preset producer queue; use a preset consumer thread to parse the file information in the producer queue and store the parsed file information in a preset local storage space; wherein, the producer thread and the consumer thread work in parallel. After monitoring the insertion event corresponding to the peripheral device, the embodiment of the present application does not scan the files stored in the peripheral device in all cases, and generates a suitable type of scanning control instruction based on the file attribute information and historical attribute information used to reflect whether the files stored in the peripheral device have changed. The files stored in the peripheral device are scanned only when the type of the scanning control instruction is a start scanning type. In this way, the problem of reducing the information reading efficiency by scanning the peripheral device when the files stored in the peripheral device have not changed can be avoided. In addition, the embodiment of the present application adopts dual threads to scan files and parse file information respectively, which can further improve the information reading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0019] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0020] Figure 1is a flow chart of an information reading method according to an embodiment of the present application;

[0021] Figure 2 is a flow chart of steps for generating a scan control instruction according to an embodiment of the present application;

[0022] Figure 3 A schematic diagram of the operation of a thread according to an embodiment of the present application;

[0023] Figure 4 is a structural diagram of an information reading device according to an embodiment of the present application;

[0024] Figure 5 is a structural diagram of an information reading device according to an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0026] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0027] The present application embodiment provides an information reading method. The present application embodiment is executed on the vehicle side. Figure 1 FIG. 1 is a flow chart of an information reading method according to an embodiment of the present application.

[0028] Step S110, after monitoring the insertion event corresponding to the peripheral device, reading the file attribute information corresponding to the peripheral device from the peripheral device and acquiring the historical attribute information corresponding to the peripheral device locally.

[0029] Peripherals refer to external storage devices. Types of peripherals include but are not limited to: USB flash drives.

[0030] Insertion event refers to the event triggered when a peripheral is inserted. For example, after a USB flash drive is inserted into the vehicle interface, the USB flash drive mounting module detects the insertion of the USB flash drive and triggers the insertion event.

[0031] The file attribute information is the attribute information of the file currently stored in the peripheral device. The file attribute information includes but is not limited to: the file name corresponding to the file stored in the peripheral device at the current time and the modification date corresponding to the file.

[0032] The historical attribute information is the attribute information of the files stored historically in the peripheral. The historical attribute information includes, but is not limited to: the file name corresponding to the file stored by the peripheral before the current time and the modification date corresponding to the file. Furthermore, the historical attribute information corresponding to the peripheral is stored locally in the vehicle (the local storage space of the vehicle). If the historical attribute information corresponding to the peripheral is not obtained, it can be determined that the historical attribute information corresponding to the peripheral is a null value.

[0033] In the embodiment of the present application, if the unplug event corresponding to the peripheral device is monitored, a notification of the unplugging of the peripheral device is issued, and the execution of the information reading method of the present application does not need to be triggered. If the insertion event corresponding to the peripheral device is monitored, it is queried whether there is a file stored in the peripheral device; if it is determined that there is a file stored in the peripheral device, the file attribute information is read from the peripheral device; if it is determined that there is no file stored in the peripheral device, a notification that there is no file in the peripheral device is issued.

[0034] Step S120: Generate a scan control instruction according to the file attribute information and the history attribute information.

[0035] The scanning control instruction is used to instruct to start scanning or prohibit scanning for files stored in the peripheral device. Among them, the types of scanning control instructions include: start scanning type and prohibit scanning type. The scanning control instruction of the start scanning type is used to instruct to start scanning for files stored in the peripheral device. The scanning control instruction of the prohibit scanning type is used to instruct to prohibit scanning for files stored in the peripheral device.

[0036] The specific steps of how to generate the scan control instruction in the embodiment of the present application will be described later, so it will not be repeated here.

[0037] Step S130, when the type of the scan control instruction is a start scan type, using a preset producer thread, scans the files stored in the peripheral device and adds the file information corresponding to the files to a preset producer queue.

[0038] The producer thread is used to scan the files stored in the peripheral device, obtain the file information corresponding to the file, and store the file information corresponding to the file in the producer queue.

[0039] File information refers to the information required to play or view a file.

[0040] The producer queue is used to cache file information corresponding to the file.

[0041] Step S140, using a preset consumer thread, parsing the file information in the producer queue and storing the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0042] The consumer thread is used to parse each file information in the producer queue in sequence, and store each parsed file information in the local storage space to complete the reading of the file information in the peripheral device.

[0043] Parsing refers to identifying file information and converting it into information that can be recognized by the vehicle side.

[0044] The local storage space is used to store the parsed file information corresponding to each file in the peripheral device. Of course, the historical attribute information corresponding to the peripheral device can be stored in the local storage space.

[0045] In the embodiment of the present application, the producer thread and the consumer thread work in parallel, the producer thread scans the file and obtains the file information corresponding to the file, while the consumer thread parses the file information corresponding to the file. Compared with the existing single-thread mode, that is, a single thread first sequentially scans all files, and after the file information corresponding to all files is added to the queue, the single thread sequentially parses each file information in the queue, the scanning and parsing time of the embodiment of the present application is shorter, so that the information reading process is more efficient.

[0046] In an embodiment of the present application, after an insertion event corresponding to a peripheral device is monitored, file attribute information corresponding to the peripheral device is read from the peripheral device and historical attribute information corresponding to the peripheral device is obtained locally; a scan control instruction is generated based on the file attribute information and the historical attribute information; when the type of the scan control instruction is a start scan type, a preset producer thread is used to scan files stored in the peripheral device and file information corresponding to the files is added to a preset producer queue; a preset consumer thread is used to parse the file information in the producer queue and store the parsed file information in a preset local storage space; wherein, the producer thread and the consumer thread work in parallel. After monitoring the insertion event corresponding to the peripheral device, the embodiment of the present application does not scan the files stored in the peripheral device in all cases, and generates a suitable type of scanning control instruction based on the file attribute information and historical attribute information used to reflect whether the files stored in the peripheral device have changed. The files stored in the peripheral device are scanned only when the type of the scanning control instruction is a start scanning type. In this way, the problem of reducing the information reading efficiency by scanning the peripheral device when the files stored in the peripheral device have not changed can be avoided. In addition, the embodiment of the present application adopts dual threads to scan files and parse file information respectively, which can further improve the information reading efficiency.

[0047] In order to make the embodiments of the present application easier to understand, the process of generating a scan control instruction in the embodiments of the present application is further described below.

[0048] In an embodiment of the present application, the file attribute information and the historical attribute information can be compared; if the file attribute information and the historical attribute information are different, a scan control instruction of the start scan type is generated; if the file attribute information and the historical attribute information are the same, a scan control instruction of the prohibit scan type is generated.

[0049] In an embodiment of the present application, the file attribute information and the historical attribute information can also be compared; if the file attribute information and the historical attribute information are different, a scan control instruction of a start scan type is generated; if the file attribute information and the historical attribute information are the same, it is queried whether there is file information corresponding to the peripheral device in the local storage space; if the file information corresponding to the peripheral device exists in the local storage space, a scan control instruction of a prohibit scan type is generated; if the file information corresponding to the peripheral device does not exist in the local storage space, a scan control instruction of a start scan type is generated.

[0050] Figure 2 4 is a flow chart of the steps of generating a scan control instruction according to an embodiment of the present application.

[0051] Step S210: comparing the file attribute information and the historical attribute information.

[0052] Step S220, determining whether the file attribute information and the historical attribute information are the same; if yes, executing step S230; if not, executing step S260.

[0053] The file attribute information and the historical attribute information are the same means that the file name included in the file attribute information and the file name included in the historical attribute information are the same and the modification time corresponding to the same file name in the file attribute information and the historical attribute information is the same.

[0054] Furthermore, the file names included in the file attribute information and the historical attribute information are all file names corresponding to the files in the root directory of the peripheral device.

[0055] Step S230, if the file attribute information and the historical attribute information are the same, query whether the file information corresponding to the peripheral device exists in the local storage space; if yes, execute step S240; if not, execute step S250.

[0056] The file information corresponding to the peripheral device stored in the local storage space refers to the file information corresponding to the file stored by the peripheral device before the current time. The file information is the information required to play or view the file on the vehicle side.

[0057] The local storage space may be a storage space used only to store file information corresponding to the peripheral device, or a storage space used to store file information corresponding to all peripheral devices, or a storage space used to store information of a preset type. For example, the local storage space is a storage space corresponding to a media database, and the storage space is used to store media file information.

[0058] Furthermore, the unique code corresponding to the peripheral device can be used to query whether the file information corresponding to the peripheral device is stored in the local storage space. For example, the ID of the peripheral device can be used to query whether the file information corresponding to the ID is stored in the local storage space.

[0059] Step S240: If the file information corresponding to the peripheral device exists in the local storage space, a scanning control instruction of a scanning prohibition type is generated.

[0060] After generating a scanning control instruction of the scanning prohibition type, a file scanning end notification is issued according to the scanning control instruction of the scanning prohibition type. After receiving the file scanning end notification, the application in the vehicle can read the file information corresponding to the peripheral device in the local storage space to play or scan the file in the peripheral device.

[0061] Step S250: If the file information corresponding to the peripheral device does not exist in the local storage space, a scan control instruction of a start scan type is generated.

[0062] Step S260: If the file attribute information and the history attribute information are different, a scan control instruction of a start scan type is generated.

[0063] After a scan control instruction of the start scan type is generated, a file scan and storage logic is executed for the peripheral device according to the scan control instruction of the start scan type.

[0064] In an embodiment of the present application, if the file attribute information and the historical attribute information are different, it means that the file stored in the peripheral device has changed. At this time, the file stored in the peripheral device needs to be scanned, so a scan control instruction of the start scan type is generated.

[0065] In an embodiment of the present application, if the file attribute information and the historical attribute information are the same, it means that the file stored in the peripheral device has not changed. In this case, in order to exclude the situation where the file information corresponding to the peripheral device has been deleted in the local storage space of the vehicle, it is also necessary to query whether the file information corresponding to the peripheral device exists in the local storage space; if the file information corresponding to the peripheral device exists in the local storage space, it means that the file information corresponding to the peripheral device has not been deleted in the local storage space of the vehicle, and there is no need to scan the files stored in the peripheral device again. The file information already stored in the local storage space can be directly used. At this time, a scanning control instruction of the scanning prohibition type is generated; if the file information corresponding to the peripheral device does not exist in the local storage space, it means that the file information corresponding to the peripheral device has been deleted in the local storage space of the vehicle, and the files stored in the peripheral device need to be scanned again. At this time, a scanning control instruction of the start scanning type is generated.

[0066] In an embodiment of the present application, if the file attribute information and the historical attribute information are different, the historical attribute information is updated according to the file attribute information. That is to say, in the local storage space, the historical attribute information corresponding to the peripheral is replaced with the file attribute information corresponding to the peripheral. Further, by comparing the file attribute information and the historical attribute information corresponding to the peripheral, it can be identified whether the file stored in the peripheral has changed; if the file attribute information and the historical attribute information are the same, it means that the file stored in the peripheral has not changed; if the file attribute information and the historical attribute information are different, it means that the file stored in the peripheral has changed. In this case, the historical attribute information corresponding to the peripheral needs to be updated in preparation for the next identification of whether the file stored in the peripheral has changed.

[0067] In the embodiment of the present application, since the peripheral device is used to store all files stored by the user, but not all types of files among these files are desired to be played or viewed by the user in the vehicle, multiple scanning strategies can be set in the embodiment of the present application, and different scanning strategies can be adopted for different scenarios.

[0068] Specifically, the number of producer threads may be one. The producer thread scans files stored in the peripheral device under the instruction of the scan control instruction of the start scan type. The types of scan control instructions of the start scan type include but are not limited to: target scan control instructions and full scan control instructions. Among them, the scan range of the target scan control instruction is different from the scan range of the full scan control instruction.

[0069] The target scan control instruction is used to instruct the producer thread to scan files stored in the peripheral device that meet the preset conditions. The preset conditions include but are not limited to: the file suffixes and file directories to be scanned. Other file suffixes and file directories other than the file suffixes and file directories to be ignored. In other words, only the specified file suffixes and file directories are scanned, as well as the file suffixes and file directories that do not need to be ignored.

[0070] The full scan control instruction is used to instruct the producer thread to scan all files stored in the peripheral device.

[0071] Furthermore, the scanning control instructions of the start scanning type corresponding to different scenarios can be set as target scanning control instructions or full scanning control instructions according to the scanning ranges corresponding to different scenarios. For example: if the file attribute information and the historical attribute information are different, a target scanning control instruction of the start scanning type is generated; if the file attribute information and the historical attribute information are the same, but the file information corresponding to the peripheral device does not exist in the local storage space, a full scanning control instruction of the start scanning type is generated.

[0072] In an embodiment of the present application, when scanning files, a producer thread is used to scan files stored in a peripheral device. If the scanning control instruction is a target-type scanning control instruction of the start scanning type, the producer thread is used to scan files stored in the peripheral device that meet preset conditions and add the file information corresponding to each file to a preset producer queue; if the scanning control instruction is a full-type scanning control instruction of the start scanning type, the producer thread is used to sequentially scan all files stored in the peripheral device and add the file information corresponding to each file to a preset producer queue.

[0073] In an embodiment of the present application, when scanning files, the producer thread can use the walkFileTree method of the Files tool class to traverse the files stored in the peripheral. The walkFileTree method can process the logic before, during, and after the directory or file traversal. In combination with the current vehicle-mounted needs, the file suffixes and file directories that need to be ignored can be customized. In this way, when traversing files, the walkFileTree method can be used to traverse files that meet the preset conditions, filter out other files, and improve file scanning efficiency. Among them, during the process of file traversal by the walkFileTree method, if a file access fails, access to the file can be abandoned.

[0074] In the embodiment of the present application, while the producer thread is used to scan the files stored in the peripheral device, the consumer thread is used to parse the file information in the producer queue and store the parsed file information in the preset local storage space. Figure 3 The figure shows a working diagram of a thread according to an embodiment of the present application. The producer thread corresponds to the producer queue, the consumer thread corresponds to the consumer queue, and the consumer queue corresponds to the local storage space; the producer thread sequentially scans the file information stored in the peripheral device and stores the scanned file information in the producer queue, the consumer thread sequentially parses the file information in the producer queue, stores the parsed file information in the consumer queue, and inserts the file information in the consumer queue into the file information corresponding to the peripheral device stored in the local storage space.

[0075] Furthermore, the consumer thread is used to parse the file information in the producer queue, including: the consumer thread can parse the entire content of the file information and store the parsed entire content of the file information in the local storage space, or parse the preset fields (partial content) of the file information and store the parsed preset fields of the file information in the local storage space.

[0076] The number of consumer threads can be multiple. Further, the types of consumer threads include but are not limited to: parsing consumer threads and storage consumer threads. The parsing consumer threads and storage consumer threads perform different tasks.

[0077] The parsing consumer thread is used to perform parsing tasks.

[0078] The storage class consumer thread is used to perform storage tasks.

[0079] In one method, the parsing class consumer thread is used to parse the file information in the producer queue (i.e., the entire content of the file information) and the parsed file information is added to a preset consumer queue; the storage class consumer thread is used to generate a label value corresponding to the file information in the consumer queue, and the file information is stored in the local storage space according to the label value corresponding to the file information; wherein the parsing class consumer thread and the storage class consumer thread work in parallel.

[0080] In another mode, the parsing consumer thread is used to parse the preset fields (i.e., part of the content of the file information) of the file information in the producer queue and the parsed field information is added to the preset consumer queue; the storage consumer thread is used to generate the tag value corresponding to the field information in the consumer queue, and the field information is stored in the local storage space according to the tag value corresponding to the field information; wherein the parsing consumer thread and the storage consumer thread work in parallel. The parsing consumer thread parses the file information while the storage consumer thread stores the parsed file information, which can further improve the information reading efficiency.

[0081] Furthermore, the consumer queue is used to store the parsed file information (all content or part of the content).

[0082] Furthermore, the preset fields may be information required when playing or viewing a file. The preset fields may be determined according to the requirements. For example, the preset fields include but are not limited to: file name, cover information, video resolution, bit rate, video encoding format, duration, audio encoding format, and audio sampling rate.

[0083] Furthermore, the tag value is unique. The tag value may be a hash value of the file information, such as an MD5 value. When storing file information (all or part of the content) in a local storage space, the file information may be inserted into the local storage space according to the size of the tag value corresponding to the file information, so that the file information stored in the local storage space is sorted according to the size of the tag value. A binary search algorithm may be used to compare the tag value corresponding to the file information with the tag values ​​corresponding to each file information stored by the peripheral device in the local storage space. If the tag value already exists, it indicates that the target file information is the original file information in the local storage space, and the target file information does not need to be inserted. Otherwise, it indicates that the target file information is new file information, and the target file information needs to be inserted into a suitable position in the local storage space, so that the tag value corresponding to the target file information and the tag values ​​corresponding to the file information before and after the target file information are sequential. In this embodiment of the present application, whether the order of the tag values ​​of each file information in the local storage space is from small to large or from large to small is not limited. For example: the label value corresponding to the target file information is 005, and file information with label value 004, file information with label value 006, and file information with label value 009 have already been stored in the local storage space. Then the target file information with label value 005 can be inserted between the file information with label value 004 and the file information with label value 006, so that 004, 005 and 006 are in ascending order, rather than being inserted between the file information with label value 006 and the file information with label value 009.

[0084] Furthermore, the number of storage class consumer threads may be one or more. Multiple storage class consumer threads may execute storage tasks in parallel.

[0085] Furthermore, in the process of storing file information in the local storage space, if there is useless file information in the local storage space, the useless file information is deleted. The useless file information refers to the file information that is not included in all the parsed file information. After deleting all the useless file information, the file information in the local storage space is consistent with the file information corresponding to the files stored in the peripheral device. For example: the local storage space includes the file information corresponding to song A, and after the peripheral device is inserted this time, song A has been deleted in the peripheral device. Then, after parsing the file information in the peripheral device, the file information corresponding to song A must not exist. At this time, the file information corresponding to song A can be deleted in the local storage space.

[0086] In an embodiment of the present application, two queues are created based on the producer and consumer model. The producer queue is used to store the scanned file information, and the consumer queue is used to store the file information after parsing. In an embodiment of the present application, a thread pool is created. The thread pool includes producer threads and consumer threads. The producer threads and consumer threads (parsing consumer threads and storage consumer threads) in the thread pool are processed simultaneously to improve the efficiency of file scanning, parsing and storage. In an embodiment of the present application, in the parsing stage of file information, according to the current vehicle-mounted application environment and business characteristics, it can be set to only scan files that meet preset conditions in the peripherals, such as: only scan audio and video files and picture files, and no scanning is required for other files. In this way, when scanning files, other files will be automatically ignored, such as: ignoring non-audio and video files and picture files, to improve scanning, parsing and storage efficiency.

[0087] In the embodiment of the present application, since the source and format of the files stored in the peripheral are unknown, and the native system (the current operating system of the vehicle) has poor compatibility, the file information may not be correctly parsed. To this end, the embodiment of the present application uses the consumer thread (such as the parsing consumer thread) to call a preset third-party processing framework; the file information in the producer queue is parsed by the third-party processing framework.

[0088] The third-party processing framework is used to parse file information. For example, when the Android system processes multimedia files such as audio and video, because the audio and video file information is compressed information, the parsing process is relatively time-consuming, and due to the compatibility of the Android system, the audio and video file information cannot be correctly parsed, thereby affecting the reading efficiency of the audio and video files. In order to deal with this problem, the embodiment of the present application calls a third-party processing framework to parse the file information.

[0089] Furthermore, before calling the third-party processing framework, the source code corresponding to the third-party processing framework is downloaded, and a dynamic library that can be used by the current operating system is compiled according to the source code through a preset compilation tool, and the dynamic library is integrated into the current operating system. In this way, when it is necessary to parse file information, the consumer thread can call the dynamic library corresponding to the third-party processing framework, and the dynamic library identifies the file type corresponding to the file information in the producer queue, searches for the decoder corresponding to the file type, and uses the parser to parse the file information. Among them, the fields to be parsed (i.e., preset fields) can be pre-set, and the decoder parses the corresponding fields of the file information according to the fields to be parsed. If the format of the file information is not recognizable by the current operating system, the parser or the preset function of the dynamic library can be used to convert the file information into a format recognizable by the current operating system.

[0090] Furthermore, types of third-party processing frameworks include but are not limited to: ffmpeg.

[0091] The embodiment of the present application performs a precondition judgment on the peripheral file scan. The file scan will only be performed when the file attribute information is different from the historical attribute information, or the file attribute information is the same as the historical attribute, but the file information corresponding to the peripheral does not exist in the local storage space, thereby avoiding the step of scanning the file every time the peripheral is inserted, thereby reducing the excessive resource occupation caused by each insertion of the peripheral. The embodiment of the present application can effectively improve the file scanning efficiency and parsing effect of the peripheral, shorten the file scanning time and parsing time, and thus improve the information reading efficiency. For example, the time for scanning and parsing 1,000 files in a USB flash drive can be shortened from more than ten seconds to about 6 seconds.

[0092] The present application also provides an information reading device. Figure 4 , which is a structural diagram of an information reading device according to an embodiment of the present application.

[0093] The information reading device comprises:

[0094] The reading and obtaining module 410 is used to read the file attribute information corresponding to the peripheral device from the peripheral device and obtain the historical attribute information corresponding to the peripheral device locally after monitoring the insertion event corresponding to the peripheral device.

[0095] The generating module 420 is used to generate a scanning control instruction according to the file attribute information and the historical attribute information.

[0096] The scanning and adding module 430 is used to scan the files stored in the peripheral device and add the file information corresponding to the files to the preset producer queue by using the preset producer thread when the type of the scanning control instruction is the start scanning type.

[0097] The parsing and storage module 440 is used to parse the file information in the producer queue using a preset consumer thread and store the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0098] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiment and will not be repeated here.

[0099] The present application also provides an information reading device, such as Figure 5 , which is a structural diagram of an information reading device according to an embodiment of the present application.

[0100] The information reading device includes: a processor 510, a communication interface 520, a memory 530 and a communication bus 540. The processor 510, the communication interface 520 and the memory 530 communicate with each other via the communication bus 540.

[0101] The memory 530 is used to store computer programs.

[0102] In one embodiment of the present application, the processor 510, when executing the program stored in the memory 530, implements the information reading method provided by any of the aforementioned method embodiments, including: after monitoring an insertion event corresponding to a peripheral device, reading file attribute information corresponding to the peripheral device from the peripheral device and obtaining historical attribute information corresponding to the peripheral device locally; generating a scan control instruction based on the file attribute information and the historical attribute information; when the type of the scan control instruction is a start scan type, using a preset producer thread, scanning files stored in the peripheral device and adding file information corresponding to the files to a preset producer queue; using a preset consumer thread, parsing the file information in the producer queue and storing the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0103] Among them, generating a scanning control instruction according to the file attribute information and the historical attribute information includes: if the file attribute information and the historical attribute information are different, generating a scanning control instruction of a start scanning type; if the file attribute information and the historical attribute information are the same, querying whether there is file information corresponding to the peripheral device in the local storage space; if the file information corresponding to the peripheral device exists in the local storage space, generating a scanning control instruction of a prohibit scanning type; if the file information corresponding to the peripheral device does not exist in the local storage space, generating a scanning control instruction of a start scanning type.

[0104] Among them, the scanning control instruction of the start scanning type includes: a target scanning control instruction and a full scanning control instruction; the using of a preset producer thread to scan the files stored in the peripheral device includes: if the scanning control instruction is a target type scanning control instruction of the start scanning type, then using the producer thread to scan the files stored in the peripheral device that meet the preset conditions; if the scanning control instruction is a full type scanning control instruction of the start scanning type, then using the producer thread to scan all files stored in the peripheral device.

[0105] Among them, the consumer thread includes: a parsing consumer thread and a storage consumer thread; the use of the preset consumer thread to parse the file information in the producer queue and store the parsed file information to the preset local storage space includes: using the parsing consumer thread to parse the file information in the producer queue and adding the parsed file information to the preset consumer queue; using the storage consumer thread to generate a label value corresponding to the file information in the consumer queue, and storing the file information to the local storage space according to the label value corresponding to the file information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0106] Among them, the consumer thread includes: a parsing consumer thread and a storage consumer thread; the use of the preset consumer thread to parse the file information in the producer queue and store the parsed file information in the preset local storage space includes: using the parsing consumer thread to parse the preset fields of the file information in the producer queue and adding the parsed field information to the preset consumer queue; using the storage consumer thread to generate a label value corresponding to the field information in the consumer queue, and storing the field information in the local storage space according to the label value corresponding to the field information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0107] The utilizing a preset consumer thread to parse the file information in the producer queue includes: utilizing the consumer thread to call a preset third-party processing framework; and parsing the file information in the producer queue through the third-party processing framework.

[0108] The method further includes: if the file attribute information and the historical attribute information are different, updating the historical attribute information according to the file attribute information.

[0109] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the information reading method provided in any of the aforementioned method embodiments are implemented. Since the information reading method has been described in detail above, for any details not fully described in the description of this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further description will be given here.

[0110] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0111] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0112] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0113] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A method for reading information, characterized in that: include: After monitoring an insertion event corresponding to the peripheral device, reading file attribute information corresponding to the peripheral device from the peripheral device and acquiring historical attribute information corresponding to the peripheral device locally; generating a scanning control instruction according to the file attribute information and the historical attribute information; When the type of the scan control instruction is a start scan type, using a preset producer thread, scanning files stored in the peripheral device and adding file information corresponding to the files to a preset producer queue; The file information in the producer queue is parsed by using a preset consumer thread and the parsed file information is stored in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

2. The method according to claim 1, characterized in that: The step of generating a scan control instruction according to the file attribute information and the historical attribute information includes: If the file attribute information and the history attribute information are different, generating a scan control instruction of a start scan type; If the file attribute information is the same as the historical attribute information, querying whether the file information corresponding to the peripheral device exists in the local storage space; If the file information corresponding to the peripheral device exists in the local storage space, generating a scanning control instruction of a scanning prohibition type; If the file information corresponding to the peripheral device does not exist in the local storage space, a scan control instruction of the start scan type is generated.

3. The method according to claim 1, characterized in that The scanning control instruction of the start scanning type includes: a target scanning control instruction and a full scanning control instruction; The step of using a preset producer thread to scan files stored in the peripheral device includes: If the scanning control instruction is a target-type scanning control instruction of a start scanning type, the producer thread is used to scan files stored in the peripheral device that meet preset conditions; If the scan control instruction is a full scan control instruction of the start scan type, all files stored in the peripheral device are scanned using the producer thread.

4. The method according to claim 1, characterized in that: The consumer threads include: parsing consumer threads and storage consumer threads; The method of utilizing a preset consumer thread to parse the file information in the producer queue and storing the parsed file information in a preset local storage space includes: Utilizing the parsing consumer thread, parsing the file information in the producer queue and adding the parsed file information to a preset consumer queue; The storage class consumer thread is used to generate a label value corresponding to the file information in the consumer queue, and the file information is stored in the local storage space according to the label value corresponding to the file information; wherein the parsing class consumer thread and the storage class consumer thread work in parallel.

5. The method according to claim 1, characterized in that The consumer threads include: parsing consumer threads and storage consumer threads; The method of utilizing a preset consumer thread to parse the file information in the producer queue and storing the parsed file information in a preset local storage space includes: Utilizing the parsing consumer thread, parsing the preset fields of the file information in the producer queue and adding the parsed field information to the preset consumer queue; The storage class consumer thread is used to generate a tag value corresponding to the field information in the consumer queue, and the field information is stored in the local storage space according to the tag value corresponding to the field information; wherein the parsing class consumer thread and the storage class consumer thread work in parallel.

6. The method according to claim 1, characterized in that The utilizing a preset consumer thread to parse the file information in the producer queue includes: Using the consumer thread to call a preset third-party processing framework; The file information in the producer queue is parsed through the third-party processing framework.

7. The method according to claim 1, characterized in that The method further comprises: If the file attribute information and the history attribute information are different, the history attribute information is updated according to the file attribute information.

8. An information reading device, characterized in that: include: A reading and obtaining module, configured to read file attribute information corresponding to the peripheral device from the peripheral device and obtain historical attribute information corresponding to the peripheral device from a local device after monitoring an insertion event corresponding to the peripheral device; A generating module, used for generating a scanning control instruction according to the file attribute information and the historical attribute information; A scanning and adding module, used for, when the type of the scanning control instruction is a start scanning type, using a preset producer thread, scanning files stored in the peripheral device and adding file information corresponding to the files to a preset producer queue; The parsing and storage module is used to parse the file information in the producer queue using a preset consumer thread and store the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

9. An information reading device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to: execute an information reading program stored in the memory to implement the information reading method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed to implement the information reading method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data processing method, device and system and computer readable storage medium

    CN112100414A

  • File scanning method and related device

    CN114116611A

  • File scanning method and device, terminal equipment and storage medium

    CN114706825A

  • Asset identification method, device and system, electronic device and storage medium

    CN114710341A

  • Multimedia file scanning method and device and electronic equipment

    CN115344406A