CN115098733B - 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
CN115098733B
CN115098733B CN202210654404.7A CN202210654404A CN115098733B CN 115098733 B CN115098733 B CN 115098733B CN 202210654404 A CN202210654404 A CN 202210654404A CN 115098733 B CN115098733 B CN 115098733B
Authority
CN
China
Prior art keywords
data
pointer
head pointer
tail 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.)
Active
Application number
CN202210654404.7A
Other languages
Chinese (zh)
Other versions
CN115098733A (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)
  • Human Computer Interaction (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a data reading method of a mobile terminal, which comprises the following steps: s1, acquiring a head pointer and a tail pointer of data; s2, calculating the number of data between the head pointer and the tail pointer; and S3, reading 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 the mobile terminals is limited, and if the storage capacity of the mobile terminals is used up, data cannot be written again, so that the data during reading may not be the data that the mobile terminals actually need to be written in the latest.
Therefore, a method is needed to improve the time sequence and timeliness of the mobile terminal data read-write and improve the service 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 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 data;
wherein, include before step S1:
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 a 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 data according to the number of the data.
As a further description of the above technical solution: the step S12 of updating the tail pointer according to the data written this time 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 stripes written.
As a further description of the above technical solution: the step S2 of calculating the number of data between the head pointer and the tail pointer includes:
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 BDA0003688689570000021
step S22, 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 BDA0003688689570000031
num is the number of data pieces between the head pointer and the tail pointer;
T n is a tail pointer, n =1,2, ·. n;
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 data that can be stored.
As a further description of the above technical solution: the step S3 of 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-write once;
step S32, reading all data between the head pointer and the 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;
step S35, the head pointer and the tail pointer are updated.
As a further description of the above technical solution: the step S33 of 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 during 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, ·.. 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.
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, ·. n; (ii) a
H m Is the current head pointer, m =1,2, ·. m;
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 step S3 of a method for reading data from 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 obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to 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 start, i.e. at what byte the data start is, for example, at the 10 th byte, then H =10, and in the present invention, the value of H is an integer multiple of the number of bytes of unit data, the multiple being not less than 0.
T, tail pointer: where the data ends, i.e. how many bytes the data ends, for example, 1000 th byte, T =1000, and in the present invention, T is an integer multiple of the number of bytes of the 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 datum contains 6 parameters such as longitude, latitude, elevation, speed, direction and time (such as position data), the number of bytes of unit data of the datum is 20 (namely 4 × 2+2 × 3+6= 20), and if the datum also contains parameters such as alarm information, the number of bytes of unit data is more, and in the invention, the datum refers to a datum with consistent number of bytes of unit data (such as unified as position 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 simultaneously, this is determined by the storage space allocated to the data, which is = storage space allocated to the data ÷ 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 written in this time and the number of unit data bytes is the number of data bytes written in 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 storable number of pieces of data MAX may be set to a value not greater than the maximum storable number of pieces of data MAX.
In a first aspect of the present invention, a method for reading data of a mobile terminal is provided:
please refer to fig. 1, which includes:
s1, a head pointer and a tail pointer of the data are obtained.
Referring to fig. 2, before this step, the method further includes:
and 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.
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, and a tail pointer and a head pointer of data 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.
And step S12, updating the tail pointer according to the written data.
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 obtained 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, n =1,2.
In one embodiment, when n =1, T is set n-1 =0。
Specifically, the writing of data may cause the tail pointer to move backward (increase), and due to the limited storage capacity of the mobile terminal and the requirement of practical situations, all data may not be written in one time, and at this time, the tail pointer after the previous data is written in may need to be recorded so as to facilitate the next writing, so that no matter how many times the data is written in, the sequence of data writing may not be disturbed when writing data.
In one 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 writing the position data, a piece of position data is written at a set interval of 10 seconds, and when the update time interval is 5 minutes, 30 pieces of position data need to be written.
In one embodiment, the number of data pieces for a single write may be preset.
Step S122, when (T) n-1 And when the + Size multiplied by Write _ num) - (Size multiplied by MAX) is less than or equal to 0, namely when the storage space required by the current data to be written is not more than the Size of the set storage space, writing all the data to be written at one time.
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 Size of the set storage space, splitting the current data to be written according to a time sequence by taking the maximum number of pieces of once read-Write data as a unit, and repeating the steps S121 to S123 until all the current data to be written is written.
Wherein, T n-1 Is the current tail pointer, n =1,2,. N, n being the number of data writes; 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 written data pieces is equal to the maximum number of storable data pieces, i.e., T n -H m-1 If the data is not read, the head pointer and the tail pointer need to be kept in a superposed state, that is, the head pointer and the tail pointer need to be kept in a superposed state when the data is continuously writtenTo move the tail pointer and the head pointer at the same time, and keep the number of data pieces between the head pointer and the tail pointer as the maximum storable number of data pieces until the data is read, at this time, the head pointer needs to be updated according to the following formula at the same time:
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 obtained 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, n =1,2,... N;
m is the number of data reads, m =0,1,2.
In one embodiment, H is when the number of data reads is 0, i.e., m =0 m-1 =0。
By the arrangement, when data cannot be read in time, the time sequence of data writing and reading cannot be influenced, the written data is always kept as the actual latest written data, and the readable data can be stored to the maximum extent.
The data storage method and the data storage device can solve the problem that the mobile terminal cannot upload data to the server for a long time without recovering network connection, 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 data which needs to be written latest actually after the network connection is recovered again, and data errors are caused.
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 first written, i.e. T is set to 0 when n =1 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 one implementationIn step S1, the acquired head pointer may be the current head pointer H in step S11 m-1 The obtained tail pointer is the tail pointer T in step S12 n
In another embodiment, when T n -H m-1 In the case of = 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 obtained tail pointer is the tail pointer T in step S12 n
And S2, calculating the number of data between the head pointer and the tail pointer.
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 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, i.e. H m >T n 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, m =0,1,2.. No;
n is the number of data writes, n =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 = MAX, it indicates that the amount of data between the head pointer and the tail pointer reaches the maximum storable amount, and when reading data, 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, n =1,2.
And S3, reading data according to the number of the data.
Referring to fig. 3, the step further includes:
and 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.
In step S32, data between all head pointers and all 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/written once, the number of data between the head pointer and the tail pointer is split by taking the maximum number of data read/written once as a unit, and then steps S31 to S32 are repeated until all data are 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, m =0,1,2.
In one embodiment, the initial value of the head pointer is set to 0, i.e., H when m =1 m-1 =0。
In another embodiment, H when m =1 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, n =1, 2.. No.;
m is the number of data reads, m =0,1,2.
And step S34, the head pointer and the tail pointer are overlapped, and the head pointer and the tail pointer are assigned to be 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.
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 returned to 0, that is, the next writing and reading are set to be the first writing and the first reading, respectively, so that the calculation of the head pointer and the tail pointer is more concise and efficient.
This step further includes: 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 mobile terminal data reading apparatus 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 write-in.
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, ·.. N;
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 the 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 pointer and the tail pointer.
When num = MAX, it indicates that the data amount between the head pointer and the tail pointer reaches the maximum storable amount, and when reading data, data is still read from the head pointer to the end of the tail pointer, and at this time, the number of data pieces 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, m =0,1,2.. No;
n is the number of data writes, n =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; the 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, m =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 If = MAX × Size, the header is updated according to the following formulaA pointer:
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, n =1, 2.. No.;
m is the number of data reads, m =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 efficiency of reading and writing 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 should be clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional units and modules is only used for illustration, and in practical applications, the above functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the system may be divided into different functional units or modules to implement all or part of the above described 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 used for distinguishing one functional unit from another, 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 details are not repeated here.
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 in the present invention, it should be understood that the disclosed system/terminal device and method can 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 function division, and other divisions may be implemented in practice, 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 parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple 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 described above 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 suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will 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 substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (7)

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 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 written data, 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;
further comprising: when the number of written data pieces is equal to the maximum number of storable data pieces, i.e. T n -H m-1 When = MAX × Size, the positions of the head pointer and the tail pointer coincide, at this time, if data is not read, when data is continuously written, it is necessary to keep the state where the head pointer and the tail pointer coincide, that is, it is necessary to move the tail pointer and the head pointer at the same time, and keep the number of data pieces between the head pointer and the tail pointer as the maximum number of storable data pieces until the data is read, at this time, the head pointer needs to be 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;
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;
s2, calculating the number of data between the head pointer and the tail pointer;
and S3, reading data according to the number of the data.
2. The method according to 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 FDA0004077361160000021
step S22, 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 FDA0004077361160000022
num is the number of data pieces between the head pointer and the tail pointer;
T n is a tail pointer, n =1,2, ·. n;
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.
3. The method for reading data of a mobile terminal according to claim 1, wherein the step S3 of 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-write once;
step S32, reading all data between the head pointer and the 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;
step S35, the head pointer and the tail pointer are updated.
4. The method according to claim 3, wherein the step S33 of updating the head pointer comprises:
step S331, updating the head pointer 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.
5. 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 the tail pointer during write, 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,... N;
size is the number of bytes of unit data;
write _ num is the number of data stripes written;
further comprising: when the number of written data pieces is equal to the maximum number of storable data pieces, i.e. T n -H m-1 When = MAX × Size, the positions of the head pointer and the tail pointer coincide, at this time, if data is not read, when data is continuously written, it is necessary to keep the state where the head pointer and the tail pointer coincide, that is, it is necessary to move the tail pointer and the head pointer at the same time, and keep the number of data pieces between the head pointer and the tail pointer as the maximum number of storable data pieces until the data is read, at this time, the head pointer needs to be 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;
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;
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.
6. The device for reading data of a mobile terminal according to claim 5, wherein the computing 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 FDA0004077361160000041
/>
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 FDA0004077361160000042
num is the number of data pieces between the head pointer and the tail pointer;
T n is a tail pointer, n =1,2, ·. n;
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.
7. 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 4.
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 CN115098733A (en) 2022-09-23
CN115098733B true 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 (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (4)

* 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
CN103514261B (en) * 2013-08-13 2017-03-15 北京华电天益信息科技有限公司 A kind of asynchronous storage of data for being applied to industrial control system and access method
KR20170032502A (en) * 2015-09-14 2017-03-23 삼성전자주식회사 Storage device and interrupt generation method thereof
CN108664335B (en) * 2017-04-01 2020-06-30 北京忆芯科技有限公司 Method and device for queue communication through proxy

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
张荣华 ; 田泽 ; 韩炜 ; .基于链表的动态存储器管理设计与实现.计算机技术与发展.2011,(07),第250-253页. *
杨阳 ; .异构双核系统中多媒体应用的智能任务控制器.电子科技.2013,(06),第119-121,136页. *

Also Published As

Publication number Publication date
CN115098733A (en) 2022-09-23

Similar Documents

Publication Publication Date Title
CN108563711B (en) Time sequence data storage method based on time nodes
CN109508246A (en) Log recording method, system and computer readable storage medium
CN109802684B (en) Method and device for data compression
CN109885577B (en) Data processing method, device, terminal and storage medium
CN108255989B (en) Picture storage method and device, terminal equipment and computer storage medium
CN113553300B (en) File processing method and device, readable medium and electronic equipment
CN112954244A (en) Method, device and equipment for realizing storage of monitoring video and storage medium
CN110941514A (en) Data backup method, data recovery method, computer equipment and storage medium
CN107798063B (en) Snapshot processing method and snapshot processing device
CN110059088B (en) Data attribute identification method, device and equipment in block chain type account book
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
CN113127438B (en) Method, apparatus, server and medium for storing data
CN111797060A (en) Offline video recording method, device and equipment and computer readable storage medium
CN113360095B (en) Hard disk data management method, device, equipment and medium
CN112882659B (en) Information obtaining method and device, electronic equipment and storage medium
CN101742632B (en) Synchronous method, host computer, mobile terminal and synchronous system
CN113448922A (en) Data archiving method, data access method and respective devices
CN110795408A (en) Data processing method and device based on object storage, server and storage medium
CN110244910A (en) A kind of data processing method and electronic equipment
CN111914529B (en) Webpage process recording method and device
CN116303278A (en) File merging method, file reading method, device, equipment and storage medium
CN113596506B (en) Performance optimization method and system for live cache, electronic device and storage medium
CN113296683B (en) Data storage method, device, server and storage medium
US20060026337A1 (en) Method increasing seeking speed when accessing file stored in storage device, machine-readable medium thereof, and related apparatus

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