CN115098733A - Mobile terminal data reading method and device and mobile terminal - Google Patents

Mobile terminal data reading method and device and mobile terminal Download PDF

Info

Publication number
CN115098733A
CN115098733A CN202210654404.7A CN202210654404A CN115098733A CN 115098733 A CN115098733 A CN 115098733A CN 202210654404 A CN202210654404 A CN 202210654404A CN 115098733 A CN115098733 A CN 115098733A
Authority
CN
China
Prior art keywords
data
pointer
tail pointer
head pointer
tail
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.)
Granted
Application number
CN202210654404.7A
Other languages
Chinese (zh)
Other versions
CN115098733B (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 Yiwen Technology Co ltd
Original Assignee
Shenzhen Yiwen Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Yiwen Technology Co ltd filed Critical Shenzhen Yiwen Technology Co ltd
Priority to CN202210654404.7A priority Critical patent/CN115098733B/en
Publication of CN115098733A publication Critical patent/CN115098733A/en
Application granted granted Critical
Publication of CN115098733B publication Critical patent/CN115098733B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • 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)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a mobile terminal data reading method, which comprises the following steps: s1, acquiring a head pointer and a tail pointer of the data; s2, calculating the number of data between the head pointer and the tail pointer; and S3, reading the data according to the number of the data. According to the invention, when data is read and written, the data is read and written according to the head pointer and the tail pointer of the data, the data with a preset length can be read and written only by moving the head pointer and the tail pointer when the data is read and written, and the head pointer and the tail pointer are updated after the data is read and written, so that the efficiency of reading and writing the data is improved.

Description

Mobile terminal data reading method and device and mobile terminal
Technical Field
The invention belongs to the technical field of data storage, and particularly relates to a mobile terminal data reading method and device and a mobile terminal.
Background
With the development of science and technology, mobile terminals have become indispensable tools in modern life, however, in order to meet the portability requirement of mobile terminals, the data storage capacity of mobile terminals is limited, and if the storage capacity of mobile terminals is used up, data cannot be written into the mobile terminals, so that the data during reading may not be the actually latest data to be written into the mobile terminals.
Therefore, a method is needed to improve the time sequence and timeliness of the data read/write of the mobile terminal and improve the use efficiency of the mobile terminal.
Disclosure of Invention
In order to solve the problems in the background art, the invention provides a mobile terminal data reading method, a mobile terminal data reading device and a mobile terminal, which can improve the time sequence and timeliness of the mobile terminal data reading and writing and improve the service efficiency of the mobile terminal.
In order to achieve the above object, a first aspect of the present invention provides a data reading method for a mobile terminal, including:
s1, acquiring a head pointer and a tail pointer of the data;
wherein, before step S1, the method includes:
s11, acquiring a current head pointer and a current tail pointer of the data, and starting to write the data according to the current tail pointer;
s12, updating the tail pointer according to the written data;
the tail pointer is updated according to the following formula:
T n =T n-1 +Size×Write_num
wherein, T n Is the tail pointer;
T n-1 is the current tail pointer, n ═ 1, 2.... n;
size is the number of bytes of unit data;
write _ num is the number of data stripes written.
S2, calculating the number of data between the head pointer and the tail pointer;
and S3, reading the data according to the number of the data.
As a further description of the above technical solution: the step S12, updating the tail pointer according to the written data, further includes:
when T is n -H m-1 When MAX × Size, the head pointer is updated at the same time according to the following formula:
H n =H m-1 +Size×Write_num
wherein H n Is a write head pointer, n ═ 1, 2.... n;
T n is the tail pointer;
H m-1 is the current head pointer, m ═ 1, 2.... m;
size is the number of bytes of unit data;
write _ num is the number of data pieces written.
As a further description of the above technical solution: the step S2, calculating the number of data pieces between the head pointer and the tail pointer, includes:
step S21, when H m-1 <T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure BDA0003688689570000021
step S22, when H is reached m-1 >T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure BDA0003688689570000031
wherein num is the number of data pieces between the head pointer and the tail pointer;
T n is a tail pointer, n ═ 1, 2.. no;
H m-1 is the current head pointer, m ═ 0, 1, 2,... m;
size is the number of bytes of unit data;
MAX is the maximum number of pieces of storable data.
As a further description of the above technical solution: the step S3, reading data according to the number of data pieces, includes:
step S31, the number of data between the head pointer and the tail pointer is not more than the maximum number of data read and written at one time;
step S32, reading all data between head pointer and tail pointer;
step S33, updating the head pointer;
step S34, the head pointer and the tail pointer are overlapped, and the head pointer and the tail pointer are both assigned to be 0;
in step S35, the head pointer and the tail pointer are updated.
As a further description of the above technical solution: the step S33, updating the head pointer, includes:
step S331, the head pointer is updated according to the following formula:
H m =H m-1 +Size×Read_num
wherein H m Is a head pointer;
H m-1 is the current head pointer, m ═ 0, 1, 2.... m;
size is the number of bytes of unit data;
read _ num is the number of data pieces Read.
In a second aspect of the present invention, a data reading apparatus for a mobile terminal is provided, including:
the writing module is used for acquiring a current head pointer and a current tail pointer of the data and starting to write the data according to the current tail pointer;
a write update module for updating the tail pointer when writing, the module comprising: the tail pointer is updated according to the following formula:
T n =T n-1 +Size×Write_num
wherein, T n Is the tail pointer;
T n-1 is the current tail pointer, n ═ 1, 2.. no;
size is the number of bytes of unit data;
write _ num is the number of data stripes written;
the acquisition module is used for acquiring a head pointer and a tail pointer of the data;
the calculation module is used for calculating the number of data between the head pointer and the tail pointer;
and the storage module is used for reading data.
As a further description of the above technical solution: the calculation module comprises:
when H is present m-1 <T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure BDA0003688689570000041
when H is present m-1 >T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure BDA0003688689570000042
num is the number of data pieces between the head pointer and the tail pointer;
T n is a tail pointer, n ═ 1, 2.. no; (ii) a
H m Is the current head pointer, m ═ 1, 2.
Size is the number of bytes of unit data;
MAX is the maximum number of pieces of storable data.
In a third aspect of the present invention, a mobile terminal is provided, which stores instructions that when executed by a processor implement the steps of the mobile terminal data reading method as described above.
Compared with the prior art, the invention has the beneficial effects that:
according to the invention, when data is read and written, the data is read and written according to the head pointer and the tail pointer of the data, the data with a preset length can be read and written only by moving the head pointer and the tail pointer when the data is read and written, and the head pointer and the tail pointer are updated after the data is read and written, so that the efficiency of reading and writing the data is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the description below are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a data reading method of a mobile terminal according to a first embodiment of the present invention;
fig. 2 is a flowchart of a data reading method of a mobile terminal according to a second embodiment of the present invention;
fig. 3 is a flowchart of a step S3 of a data reading method for a mobile terminal according to the present invention;
fig. 4 is a schematic structural diagram of a mobile terminal data reading device according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
To help understand the technical solution of the present invention, the terms referred to in the present invention are explained as follows:
h, head pointer: the position of the data head, i.e. at what byte the data head is, for example, at the 10 th byte, H is 10, and in the present invention, the value of H is an integer multiple of the number of bytes of unit data, and the multiple is not less than 0.
T, tail pointer: the position where the data ends, that is, how many bytes the data ends, for example, the data ends at 1000 th byte, T is 1000, and in the present invention, the value of T is an integer multiple of the number of bytes of unit data, and the multiple is not less than 0.
Size, number of bytes of data: the single datum contains parameters (such as longitude, latitude, elevation, speed, direction, time and the like) corresponding to the number of bytes. For example: the parameters such as longitude and latitude are set to occupy 4 bytes, the parameters such as elevation, speed and direction occupy 2 bytes, the time parameter occupies 6 bytes, if a single data contains 6 parameters such as longitude, latitude, elevation, speed, direction and time (for example, location data), the number of bytes of the data per unit data is 20 (namely 4 × 2+2 × 3+6 equals 20), and if the data also contains parameters such as alarm information, the number of bytes per unit number is more, in the invention, the data refers to data with the same number of bytes per unit data (for example, unified as location data).
The number of data strips between the head pointer and the tail pointer of hum refers to how many pieces of unit data are currently stored, and the product of the number of bytes of the unit data and the number of bytes of the unit data is the number of bytes of the currently stored data.
MAX, maximum number of storable data pieces: this may be determined by the storage capacity of the mobile terminal, since the mobile terminal may be used to store multiple types of data at the same time, it is determined by the storage space allocated to the data, which is the storage space allocated to the data divided by the number of bytes of data. For example, if the storage space allocated to the data is 10M and the number of bytes per unit data is 20, the maximum number of pieces of data that can be stored is: 500.
write _ num, number of data pieces written: the product of the number of unit data bytes written at this time and the number of unit data bytes is the number of data bytes written at this time.
Read _ num, number of data pieces Read: the product of the number of the unit data bytes read this time and the number of the unit data bytes is the number of the data bytes read this time.
Read _ MAX, maximum number of data pieces Read and written at one time: the maximum number of pieces of storable data may be set to a value not greater than the maximum number MAX of pieces of storable data.
In a first aspect of the present invention, a method for reading data of a mobile terminal is provided:
referring to fig. 1, the method includes:
and S1, acquiring a head pointer and a tail pointer of the data.
Referring to fig. 2, before this step, the method further includes:
step S11, a current head pointer and a current tail pointer of the data are obtained, and data writing is started according to the current tail pointer.
Specifically, a tail pointer of data, i.e., a position where data ends, a head pointer of data, i.e., a position where data starts, a tail pointer and a head pointer are updated and recorded when data is read and written. In general, when data is written, the data is written from the position where the data currently ends (i.e., the tail pointer), the tail pointer is updated after the writing is completed, and when the data is read, the data is read from the current head pointer of the data, and the head pointer is updated after the reading is completed. When data is read, when the head pointer and the tail pointer are overlapped, the fact that the data between the head pointer and the tail pointer is completely read can be shown, at the moment, the tail pointer and the head pointer can be reset to be initial values, therefore, when the data is read and written, the data can be read according to the time sequence of data writing without extra judgment steps, namely, the data is firstly read when the data is written, and then the written data is read, even if the data is written in an overlaying mode, the disorder of the data reading and the data writing caused by different time sequences can not be caused, the use efficiency of a storage space is effectively improved, and the time sequence of the data is effectively improved.
In step S12, the tail pointer is updated according to the data written this time.
Further, the method comprises the following steps:
the tail pointer is updated according to the following formula:
T n =T n-1 +Size×Write_num
wherein, T n Is the tail pointer;
T n-1 is the current tail pointer, i.e., the current tail pointer acquired in step S11;
size is the number of bytes of unit data;
write _ num is the number of data stripes written;
n is the number of data writes, and n is 1, 2.
In one embodiment, when n is 1, T is set n-1 =0。
Specifically, writing data may cause the tail pointer to move backward (increase), and because of the limited storage capacity of the mobile terminal and the requirement of the actual situation, all data may not be written all at once, at this time, the tail pointer after the previous data is written is required to be recorded, so that the next writing is facilitated, and thus, when writing data, no matter how many times the data is written, the sequence of data writing cannot be disturbed.
In an embodiment, in this step, the method further includes:
step S121, acquiring the number of data to be written currently.
In this step, the number of data to be written currently can be directly obtained, for example, when position data is written, one piece of position data is written at a set interval of 10 seconds, and when the time interval of updating is 5 minutes, 30 pieces of position data need to be written.
In one embodiment, the number of data pieces for a single write can be preset.
Step S122, when (T) n-1 When + Size × Write _ num) - (Size × MAX) ≦ 0, that is, when the storage space required by the current data to be written is not larger than the Size of the set storage space, all the data to be written is written once.
Step S123, when (T) n-1 When + Size × Write _ num) - (Size × MAX) > 0, that is, when the storage space required by the current data to be written is larger than the set Size of the storage space, the maximum number of pieces of data to be written and written at one time is used as a unit pairAnd splitting the current data to be written according to a time sequence, and repeating the steps S121 to S123 until all the current data to be written are written.
Wherein, T n-1 N is the number of data writes, n is 1, 2.. No. n; size is the number of bytes of unit data; write _ num is the number of data stripes written; MAX is the maximum number of pieces of data that can be stored.
In one embodiment, when the number of data pieces written equals the maximum number of storable data pieces, T n -H m-1 When the data is read, the head pointer and the tail pointer need to be kept in a superposed state, that is, the tail pointer and the head pointer need to be moved simultaneously, and the number of data pieces between the head pointer and the tail pointer is kept to be the maximum number of storable data pieces, until the data is read, at this time, the head pointer needs to be updated simultaneously according to the following formula:
H n =H m-1 +Size×Write_num
wherein H n Is a write head pointer;
T n is the tail pointer;
H m-1 is the current head pointer, is the head pointer acquired in step S11;
size is the number of bytes of unit data;
write _ num is the number of data stripes written;
n is the number of data writes, and n is 1, 2.
m is the number of data reads, and m is 0, 1, 2.
In one embodiment, when the number of data reads is 0, i.e., m is 0, H is m-1 =0。
The data writing and reading time sequence cannot be influenced when the data cannot be read in time, the written data is always kept as the actual latest written data, and the readable data can be stored to the maximum extent.
By the arrangement, the problem that the data cannot be uploaded to the server without recovering the network connection for a long time by the mobile terminal, and the data cannot be continuously written after the storage space of the mobile terminal is full, so that the data uploaded by the mobile terminal is not the latest written data actually needed after the network connection is recovered again, and data errors are caused can be solved.
In step S124, after the data is successfully written, the tail pointer is updated.
In one embodiment, the initial value of the tail pointer is set to 0 when data is written for the first time, i.e. T is set to 1 when n n-1 Is set to 0.
In one embodiment, when T is n -H m-1 When MAX × Size, the head pointer is updated at the same time.
In an embodiment, in step S1, the obtained head pointer may be the current head pointer H in step S11 m-1 The acquired tail pointer is the tail pointer T in step S12 n
In another embodiment, when T n -H m-1 At MAX × Size, since the tail pointer and the head pointer are updated at the same time when data is written, the head pointer acquired in step S1 is the write head pointer H in step S12 n The acquired tail pointer is the tail pointer T in step S12 n
S2, the number of data pieces between the head pointer and the tail pointer is calculated.
Further, the method also comprises the following steps:
step S21, when the head pointer is before the tail pointer, i.e. H m-1 <T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula:
Figure BDA0003688689570000091
step S22, when the head pointer is behind the tail pointer, H m >T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula:
Figure BDA0003688689570000092
wherein num is the number of data pieces between the head pointer and the tail pointer;
T n is the tail pointer;
H m-1 is the current head pointer;
size is the number of bytes of unit data;
MAX is the maximum number of storable data pieces;
m is the number of data reads, and m is 0, 1, 2.
n is the number of data writes, and n is 1, 2.
In one embodiment, when H m-1 =T n Time, indicates that there is no data between the head and tail pointers.
In one embodiment, when num is MAX, it indicates that the amount of data between the head pointer and the tail pointer reaches the maximum storable amount, and when data is read, data is still read from the head pointer to the end of the tail pointer, and at this time, the number of data between the head pointer and the tail pointer is calculated according to the following formula:
Figure BDA0003688689570000101
num is the number of data pieces between the head pointer and the tail pointer;
H n is a write head pointer;
T n is the tail pointer;
size is the number of bytes of unit data;
n is the number of data writes, and n is 1, 2.
And S3, reading the data according to the number of the data.
Referring to fig. 3, the step further includes:
in step S31, the number of data pieces between the head pointer and the tail pointer is not greater than the maximum number of data pieces read and written at one time.
In step S32, data between all head and tail pointers is read.
In an embodiment, when the number of data between the head pointer and the tail pointer is greater than the maximum number of data read/write once, the number of data between the head pointer and the tail pointer is split in units of the maximum number of data read/write once, and then steps S31 to S32 are repeated until the data is completely read.
In step S33, the head pointer is updated.
Further, in this step, the method further includes:
the head pointer is updated according to the following formula:
H m =H m-1 +Size×Read_num
wherein H m Is a head pointer;
H m-1 the current head pointer refers to the head pointer updated last time;
size is the number of bytes of unit data;
read _ num is the number of data pieces Read;
m is the number of data reads, and m is 0, 1, 2.
In one embodiment, when the initial value of the head pointer is set to 0, i.e., m is 1, H is m-1 =0。
In another embodiment, when m is 1, H m-1 =H n In which H is n Is a write head pointer.
Further, when the number of data pieces between the head pointer and the tail pointer is equal to the maximum storable number of data pieces, i.e., T n -H n When MAX × Size, the head pointer is updated according to the following formula:
H m =H n +Size×Read_num
wherein H m Is a head pointer;
H n is a write head pointer;
size is the number of bytes of unit data;
read _ num is the number of data pieces Read;
n is the number of data writes, and n is 1, 2.
m is the number of data reads, and m is 0, 1, 2.
In step S34, the head pointer and the tail pointer coincide, and both the head pointer and the tail pointer are assigned to 0.
Specifically, when the data is completely read, the head pointer and the tail pointer may coincide, and if the head pointer and the tail pointer do not coincide, it indicates that the data is not completely read, in which case, steps S31 to S33 may be repeated until the head pointer and the tail pointer coincide.
In step S35, the head pointer and the tail pointer are updated.
At this time, the values of the head pointer and the tail pointer are both 0, i.e., H m =0,T n 0, wherein H m Is a head pointer, m ═ 0, 1, 2 n Is a tail pointer, n ═ 1, 2.
In an embodiment, after the head pointer and the tail pointer are assigned to 0, the values of m and n are also set to 0, that is, the next writing and reading are respectively set to the first writing and the first reading, so that the calculation of the head pointer and the tail pointer is more concise and efficient.
The method further comprises the following steps: the read data is stored to a designated location or transferred to another storage device (such as a server).
Referring to fig. 4, in a second aspect of the present invention, a data reading apparatus for a mobile terminal is provided, including:
and the obtaining module 41 is configured to obtain a head pointer and a tail pointer of the data.
Further, the method also comprises the following steps: the writing module is used for acquiring a current head pointer and a current tail pointer of the data and starting to write the data according to the current tail pointer;
further, the method also comprises the following steps: and the write-in updating module is used for updating the tail pointer during writing.
This module includes:
the tail pointer is updated according to the following formula:
T n =T n-1 +Size×Write_num
wherein, T n Is the tail pointer;
T n-1 is the current tail pointer, n ═ 1, 2.. no;
size is the number of bytes of unit data;
write _ num is the number of data stripes written.
In one embodiment, the method further comprises: when T is n -H m-1 When MAX × Size, the head pointer is updated at the same time according to the following formula:
H n =H m-1 +Size×Write_num
wherein H n Is a write head pointer, n ═ 1, 2.... n;
T n is the tail pointer;
H m-1 is the current head pointer, m ═ 0, 1, 2,... m;
size is the number of bytes of unit data;
write _ num is the number of data stripes written.
And a calculating module 42 for calculating the number of data pieces between the head pointer and the tail pointer.
Specifically, in this module, the method further includes:
when the head pointer precedes the tail pointer, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure BDA0003688689570000131
when the head pointer follows the tail pointer, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure BDA0003688689570000132
when H is present m-1 =T n Time, indicates that there is no data between the head and tail pointers.
When num is MAX, it indicates that the data amount between the head pointer and the tail pointer reaches the maximum storable amount, when reading data, the data is still read from the head pointer to the end of the tail pointer, at this time, the number of data between the head pointer and the tail pointer is calculated according to the following formula:
Figure BDA0003688689570000133
num is the number of data pieces between the head pointer and the tail pointer;
H n is a write head pointer;
T n is the tail pointer;
size is the number of bytes of unit data;
MAX is the maximum number of storable data pieces;
m is the number of data reads, and m is 0, 1, 2.
n is the number of data writes, and n is 1, 2.
And a storage module 43 for reading data.
Further, the method also comprises the following steps:
the reading module is used for reading data between all head pointers and all tail pointers;
further, the module further comprises: when the number of data between the head pointer and the tail pointer is not more than the maximum number of data read and written at one time; data between all head and tail pointers is read.
Further, the module further comprises: when the number of data between the head pointer and the tail pointer is larger than the maximum number of data read and written at one time, the data is split and read by taking the maximum number of data read and written at one time as a unit until the data is completely read.
Further, the method also comprises the following steps: and the updating module is used for updating the head pointer and the tail pointer.
Further, in this module, the method further includes:
the head pointer is updated according to the following formula:
H m =H m-1 +Size×Read_num
wherein H m Is a head pointer;
H m-1 is the current head pointer;
size is the number of bytes of unit data;
read _ num is the number of data pieces Read;
m is the number of data reads, and m is 0, 1, 2.
Further, when the number of data pieces between the head pointer and the tail pointer is equal to the maximum storable number of data pieces, i.e., T n -H n When MAX × Size, the head pointer is updated according to the following formula:
H m =H n +Size×Read_num
wherein H m Is a head pointer;
H n is a write head pointer;
size is the number of bytes of unit data;
read _ num is the number of data pieces Read;
n is the number of data writes, and n is 1, 2.. ·.n;
m is the number of data reads, and m is 0, 1, 2.
Specifically, when the data is completely read, the head pointer and the tail pointer coincide, and if the head pointer and the tail pointer do not coincide, it indicates that the data is not completely read, and the data needs to be read again until the head pointer and the tail pointer coincide.
Further, the method also comprises the following steps: and the determining module assigns the head pointer and the tail pointer to be 0 when the head pointer and the tail pointer are overlapped.
Further, the method also comprises the following steps: and the transmission module is used for storing or transmitting the read data to another storage device (such as a server).
In a third aspect of the present invention, a mobile terminal is provided, which stores instructions that when executed by a processor implement the steps of the mobile terminal data reading method as described above.
The invention reads and writes files according to the head pointer and the tail pointer of the data when reading and writing the data, the data with preset length can be read and written only by moving the head pointer and the tail pointer when reading and writing the data, and the head pointer and the tail pointer are updated once every time of reading and writing, thereby improving the reading and writing efficiency of the data.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the system is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the wireless terminal may refer to the corresponding process in the foregoing method embodiments, and is not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided by the present invention, it should be understood that the disclosed system/terminal device and method may be implemented in other ways. For example, the above-described system/terminal device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when the actual implementation is performed, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, systems or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, that is, may be located in one place, or may also be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and configured for individual product sale or use, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or system capable of carrying said computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, etc. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein.

Claims (8)

1. A data reading method of a mobile terminal is characterized by comprising the following steps:
s1, acquiring a head pointer and a tail pointer of the data,
wherein, step S1 includes before:
s11, acquiring a current head pointer and a current tail pointer of the data, and starting to write the data according to the current tail pointer;
s12, updating the tail pointer according to the data written this time, including updating the tail pointer according to the following formula:
T n =T n-1 +Size×Write_num
wherein, T n Is the tail pointer;
T n-1 is the current tail pointer, n ═ 1, 2, … … n;
size is the number of bytes of unit data;
write _ num is the number of data stripes written;
s2, calculating the number of data between the head pointer and the tail pointer;
and S3, reading the data according to the number of the data.
2. The method according to claim 1, wherein said step S12 for updating the tail pointer according to the written data further comprises:
when T is n -H m-1 When MAX × Size, the head pointer is updated at the same time according to the following formula:
H n =H m-1 +Size×Write_num
wherein H n Is a write head pointer, n ═ 1, 2, … … n;
T n is the tail pointer;
H m-1 is the current head pointer, m is 0, 1, 2, … … m;
size is the number of bytes of unit data;
write _ num is the number of data stripes written.
3. The data reading method of claim 1, wherein the step S2 of calculating the number of data pieces between the head pointer and the tail pointer comprises:
step S21, when H is reached m-1 <T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure FDA0003688689560000021
step S22, when H is reached m-1 >T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure FDA0003688689560000022
num is the number of data pieces between the head pointer and the tail pointer;
T n is tail pointer, n is 1, 2, … … n;
H m-1 is the current head pointer, m is 0, 1, 2, … … m;
size is the number of bytes of unit data;
MAX is the maximum number of pieces of storable data.
4. The method for reading data of a mobile terminal according to claim 1, wherein said step S3, reading data according to the number of data pieces, comprises:
step S31, the number of data between the head pointer and the tail pointer is not more than the maximum number of data read and written at one time;
step S32, reading all data between head pointer and tail pointer;
step S33, updating the head pointer;
step S34, the head pointer and the tail pointer are overlapped, and the head pointer and the tail pointer are both assigned to be 0;
in step S35, the head pointer and the tail pointer are updated.
5. The method for reading data of a mobile terminal according to claim 4, wherein said step S33, updating the head pointer, comprises:
step S331, the head pointer is updated according to the following formula:
H m =H m-1 +Size×Read_num
wherein H m Is a head pointer;
H m-1 is the current head pointer, m is 0, 1, 2, … … m;
size is the number of bytes of unit data;
read _ num is the number of data pieces Read.
6. A mobile terminal data reading apparatus, comprising:
the writing module is used for acquiring a current head pointer and a current tail pointer of the data and starting to write the data according to the current tail pointer;
a write update module for updating a tail pointer when writing, the module comprising: the tail pointer is updated according to the following formula:
T n =T n-1 +Size×Write_num
wherein, T n Is the tail pointer;
T n-1 is the current tail pointer, n is 1, 2, … … n;
size is the number of bytes of unit data;
write _ num is the number of data stripes written;
the acquisition module is used for acquiring a head pointer and a tail pointer of the data;
the calculation module is used for calculating the number of data between the head pointer and the tail pointer;
and the storage module is used for reading data.
7. The device according to claim 6, wherein the computing module comprises:
when H is present m-1 <T n Then, the head pointer is calculated according to the following formulaAnd the number of data pieces between the tail pointer,
Figure FDA0003688689560000031
when H is present m-1 >T n Then, the number of data pieces between the head pointer and the tail pointer is calculated according to the following formula,
Figure FDA0003688689560000032
num is the number of data pieces between the head pointer and the tail pointer;
T n is tail pointer, n is 1, 2, … … n;
H m-1 is the current head pointer, m is 0, 1, 2, … … m;
size is the number of bytes of unit data;
MAX is the maximum number of pieces of storable data.
8. A mobile terminal, characterized in that it stores instructions that, when executed by a processor, implement the steps of a mobile terminal data reading method according to any one of claims 1 to 5.
CN202210654404.7A 2022-06-10 2022-06-10 Mobile terminal data reading method and device and mobile terminal Active CN115098733B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210654404.7A CN115098733B (en) 2022-06-10 2022-06-10 Mobile terminal data reading method and device and mobile terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210654404.7A CN115098733B (en) 2022-06-10 2022-06-10 Mobile terminal data reading method and device and mobile terminal

Publications (2)

Publication Number Publication Date
CN115098733A true CN115098733A (en) 2022-09-23
CN115098733B CN115098733B (en) 2023-04-07

Family

ID=83290765

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210654404.7A Active CN115098733B (en) 2022-06-10 2022-06-10 Mobile terminal data reading method and device and mobile terminal

Country Status (1)

Country Link
CN (1) CN115098733B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5418973A (en) * 1992-06-22 1995-05-23 Digital Equipment Corporation Digital computer system with cache controller coordinating both vector and scalar operations
CN103514261A (en) * 2013-08-13 2014-01-15 江苏华大天益电力科技有限公司 Data asynchronization storage and access mechanism applied to industrial control system
CN111625376A (en) * 2017-04-01 2020-09-04 北京忆芯科技有限公司 Method and message system for queue communication through proxy
CN112235206A (en) * 2019-12-20 2021-01-15 青岛鼎信通讯股份有限公司 Annular buffer queue data receiving mechanism based on single chip microcomputer
US10969996B1 (en) * 2019-02-06 2021-04-06 Marvell Israel (M.I.S.L) Ltd. Extendable hardware queue structure and method of operation thereof
CN112948292A (en) * 2015-09-14 2021-06-11 三星电子株式会社 Storage device and interrupt generation method thereof

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5418973A (en) * 1992-06-22 1995-05-23 Digital Equipment Corporation Digital computer system with cache controller coordinating both vector and scalar operations
CN103514261A (en) * 2013-08-13 2014-01-15 江苏华大天益电力科技有限公司 Data asynchronization storage and access mechanism applied to industrial control system
CN112948292A (en) * 2015-09-14 2021-06-11 三星电子株式会社 Storage device and interrupt generation method thereof
CN111625376A (en) * 2017-04-01 2020-09-04 北京忆芯科技有限公司 Method and message system for queue communication through proxy
US10969996B1 (en) * 2019-02-06 2021-04-06 Marvell Israel (M.I.S.L) Ltd. Extendable hardware queue structure and method of operation thereof
CN112235206A (en) * 2019-12-20 2021-01-15 青岛鼎信通讯股份有限公司 Annular buffer queue data receiving mechanism based on single chip microcomputer

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张荣华;田泽;韩炜;: "基于链表的动态存储器管理设计与实现" *
杨阳;: "异构双核系统中多媒体应用的智能任务控制器" *

Also Published As

Publication number Publication date
CN115098733B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN108563711B (en) Time sequence data storage method based on time nodes
CN109802684B (en) Method and device for data compression
CN108255989B (en) Picture storage method and device, terminal equipment and computer storage medium
CN109240607B (en) File reading method and device
CN110457305B (en) Data deduplication method, device, equipment and medium
CN106201778B (en) Information processing method and storage equipment
CN112954244A (en) Method, device and equipment for realizing storage of monitoring video and storage medium
CN110851474A (en) Data query method, database middleware, data query device and storage medium
CN112463020A (en) Data access method, device and equipment based on Flash
CN110059088B (en) Data attribute identification method, device and equipment in block chain type account book
CN110955639A (en) Data processing method and device
CN115098733B (en) Mobile terminal data reading method and device and mobile terminal
CN108304144A (en) Data write-in, read method and system, data read-write system
CN111143092A (en) Fault recording data processing method and system and terminal equipment
CN106980685B (en) Data processing method and data processing device
CN113360095B (en) Hard disk data management method, device, equipment and medium
CN111625502B (en) Data reading method and device, storage medium and electronic device
CN111399774B (en) Data processing method and device based on snapshot under distributed storage system
CN113448922A (en) Data archiving method, data access method and respective devices
CN109992701B (en) Chain table implementation method, device and equipment and readable storage medium
CN113051105A (en) Data processing method, device, equipment and storage medium
CN101742632A (en) Synchronous method, host computer, mobile terminal and synchronous system
CN111159244A (en) Data query method and device
CN110244910A (en) A kind of data processing method and electronic equipment
CN111914529B (en) Webpage process recording method and device

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
GR01 Patent grant
GR01 Patent grant