CN109901796A - Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory - Google Patents

Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory Download PDF

Info

Publication number
CN109901796A
CN109901796A CN201910125544.3A CN201910125544A CN109901796A CN 109901796 A CN109901796 A CN 109901796A CN 201910125544 A CN201910125544 A CN 201910125544A CN 109901796 A CN109901796 A CN 109901796A
Authority
CN
China
Prior art keywords
record
keyword
target
file
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910125544.3A
Other languages
Chinese (zh)
Inventor
王防修
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Polytechnic University
Original Assignee
Wuhan Polytechnic University
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 Wuhan Polytechnic University filed Critical Wuhan Polytechnic University
Priority to CN201910125544.3A priority Critical patent/CN109901796A/en
Publication of CN109901796A publication Critical patent/CN109901796A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a kind of sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory is read local non-ordered data sequence by peripheral storage device, extracts the ascending order keyword in the non-ordered data sequence;Goal ordering selection strategy is determined according to the ascending order keyword;The non-ordered data sequence is ranked up according to the goal ordering selection strategy, memory headroom can be saved, reduces the time that data import memory, avoids frequent data item write operation of the insertion sort in sequencer procedure, the speed and efficiency of reading and writing data are improved, the user experience is improved.

Description

Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory
Technical field
The present invention relates to field of traffic more particularly to a kind of sequencing selection method, apparatus based on external memory, peripheral storage device And storage medium.
Background technique
Existing selected and sorted mode is internal sort and external sorting, regardless of be internal sort or external sorting, it is collated Journey deposits into capable including being all;Wherein, external sorting is due to consideration that data volume is too big and usually not will appear memory headroom seriously not The situation of foot is usually that data are imported memory in batches to be ranked up at this time;Due to current selected and sorted can only in memory into Row, can have memory headroom and largely consume, and data import memory time longer problem.
Summary of the invention
The sequencing selection method, apparatus that the main purpose of the present invention is to provide a kind of based on external memory, peripheral storage device and Storage medium, it is intended to solve selected and sorted in the prior art and carry out consuming there are memory headroom greatly, when data import in memory Between long technical problem.
To achieve the above object, the present invention provides a kind of sequencing selection method based on external memory, the row based on external memory Sequence selection method the following steps are included:
Peripheral storage device reads local non-ordered data sequence, extracts the ascending order keyword in the non-ordered data sequence;
Goal ordering selection strategy is determined according to the ascending order keyword;
The non-ordered data sequence is ranked up according to the goal ordering selection strategy.
Preferably, described that the non-ordered data sequence is ranked up according to the goal ordering selection strategy, it is specific to wrap It includes:
In goal ordering selection strategy ascending sort strategy preferential for low level, determine the ascending order keyword for number According to the smallest keyword of amount, and the corresponding initial storage position of the ascending order keyword is determined from the target data file;
Obtain the file size of the corresponding target data file of the non-ordered data sequence and the target data file, root The record strip number in the target data file is obtained according to the file size;
File pointer is zeroed, data record is read from current file pointer position and is used as original records, and by institute State original records deposit temporary folder;
The file pointer is moved on to from the initial storage position and increases the corresponding storage position of default bias unit, from Current file pointer position reads data record and is used as target record, obtains the target keyword of the target record;
By the target keyword compared with the ascending order keyword, it is greater than in the data volume of the target keyword described When the data volume of ascending order keyword, the target record is stored in the temporary folder;
The file pointer is persistently moved to increasing the corresponding next storage position of the default bias unit, and reads phase The record answered, until each record in the target data file is sequentially stored into the number of the temporary folder according to sequencing Until amount reaches the record strip number.
Preferably, described that the non-ordered data sequence is ranked up according to the goal ordering selection strategy, it is specific to wrap It includes:
When the goal ordering selection strategy is high priority ascending sort strategy, determine the ascending order keyword for number According to the maximum keyword of amount, and the corresponding initial storage position of the ascending order keyword is determined from the target data file;
Obtain the file size of the corresponding target data file of the non-ordered data sequence and the target data file, root The record strip number in the target data file is obtained according to the file size;
File pointer is zeroed, data record is read from current file pointer position and is used as original records, and by institute State original records deposit temporary folder;
The file pointer is moved on to from the initial storage position and reduces the corresponding storage position of default bias unit, from Current file pointer position reads data record and is used as target record, obtains the target keyword of the target record;
By the target keyword compared with the ascending order keyword, it is less than in the data volume of the target keyword described When the data volume of ascending order keyword, the target record is stored in the temporary folder;
The file pointer is persistently moved to reducing the corresponding next storage position of the default bias unit, and reads phase The record answered, until each record in the target data file is sequentially stored into the number of the temporary folder according to sequencing Until amount reaches the record strip number.
Preferably, described that the non-ordered data sequence is ranked up according to the goal ordering selection strategy, it is specific to wrap It includes:
When the goal ordering selection strategy is high-low-position ascending sort strategy simultaneously, determine that the ascending order keyword is The maximum keyword of data volume and the smallest keyword of data volume, and determine that the ascending order is crucial from the target data file The corresponding first initial storage position of word and the second initial storage position;
Obtain the file size of the corresponding target data file of the non-ordered data sequence and the target data file, root The record strip number in the target data file is obtained according to the file size;
First file pointer and the second file pointer are zeroed, read data note from the first current file pointer position Record is used as the first original records, reads data record from the second current file pointer position and is used as the second original records, and First original records and second original records are stored in temporary folder;
According to the high-low-position simultaneously ascending sort strategy by first file pointer from the described first initial storage position It sets and is deviated, second file pointer is deviated from the described second initial storage position, according to the storage after offset Corresponding record is stored in the temporary folder by position, until each record in the target data file is according to sequencing Be sequentially stored into the temporary folder quantity reach the record strip number until.
Preferably, it is described according to the high-low-position simultaneously ascending sort strategy by first file pointer from described first Initial storage position is deviated, and second file pointer is deviated from the described second initial storage position, according to inclined Corresponding record is stored in the temporary folder by the storage position after shifting, until each record in the target data file is pressed Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder, specifically include:
The high-low-position simultaneously ascending sort strategy be low level to a high position ascending sort strategy when, by first file Pointer moves on to from the described first initial storage position and reduces the corresponding first object storage position of default bias unit, by described the Two file pointers move on to from the described second initial storage position and reduce default bias unit corresponding second target storage position;
Data record is read as first object from the first object storage position to record, and obtains first mesh The first object keyword for marking record reads data record as the second target from second target storage position and remembers Record obtains the second target keyword of second target record;
The first object keyword and second target keyword are compared, in the first object keyword Data volume be greater than second target keyword data volume when, by the first object record and second target record It is stored in the temporary folder simultaneously;
It is corresponding to the default bias unit is increased persistently to move first file pointer and second file pointer Next storage position, and read corresponding record, until each in the target data file record according to sequencing according to Until the quantity of the secondary deposit temporary folder reaches the record strip number.
Preferably, it is described according to the high-low-position simultaneously ascending sort strategy by first file pointer from described first Initial storage position is deviated, and second file pointer is deviated from the described second initial storage position, according to inclined Corresponding record is stored in the temporary folder by the storage position after shifting, until each record in the target data file is pressed Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder, specifically include:
When ascending sort strategy is that a high position arrives low level ascending sort strategy to the high-low-position simultaneously, by first file Pointer moves on to from the described first initial storage position and reduces the corresponding first object storage position of default bias unit, by described the Two file pointers move on to from the described second initial storage position and reduce default bias unit corresponding second target storage position;
Data record is read as first object from the first object storage position to record, and obtains first mesh The first object keyword for marking record reads data record as the second target from second target storage position and remembers Record obtains the second target keyword of second target record;
The first object keyword and second target keyword are compared, in the first object keyword Data volume be greater than second target keyword data volume when, by the first object record and second target record It is stored in the temporary folder simultaneously;
It is corresponding to the default bias unit is reduced persistently to move first file pointer and second file pointer Next storage position, and read corresponding record, until each in the target data file record according to sequencing according to Until the quantity of the secondary deposit temporary folder reaches the record strip number.
Preferably, described that goal ordering selection strategy is determined according to the ascending order keyword, it specifically includes:
In ascending order keyword keyword the smallest for data volume in the non-ordered data sequence, the target is determined Sequencing selection strategy is the preferential ascending sort strategy of low level;
In ascending order keyword keyword maximum for data volume in the non-ordered data sequence, the target is determined Sequencing selection strategy is high-order ascending sort strategy;
It is that the smallest keyword of data volume and data volume are maximum in the non-ordered data sequence in the ascending order keyword When keyword, determine that the goal ordering selection strategy is high-low-position ascending sort strategy simultaneously.
In addition, to achieve the above object, the present invention also proposes that a kind of peripheral storage device, the peripheral storage device include: to deposit Reservoir, processor and the sequencing selection journey based on external memory that is stored on the memory and can run on the processor Sequence, the sequencing selection program based on external memory are arranged for carrying out the step of the sequencing selection method as described above based on external memory Suddenly.
In addition, to achieve the above object, the present invention also proposes a kind of storage medium, it is stored with and is based on the storage medium The sequencing selection program of external memory, the sequencing selection program based on external memory realize base as described above when being executed by processor In the sequencing selection method of external memory the step of.
In addition, to achieve the above object, the present invention also provides a kind of sequencing selection device based on external memory is described based on outer The sequencing selection device deposited includes: keyword extracting module, strategy selection module and sorting module;
Wherein, the keyword extracting module, reads local non-ordered data sequence for peripheral storage device, described in extraction Ascending order keyword in non-ordered data sequence;
The strategy selection module, for determining goal ordering selection strategy according to the ascending order keyword;
The sorting module, for being ranked up according to the goal ordering selection strategy to the non-ordered data sequence.
Sequencing selection method proposed by the present invention based on external memory reads local non-ordered data sequence by peripheral storage device Column, extract the ascending order keyword in the non-ordered data sequence;Goal ordering selection strategy is determined according to the ascending order keyword; The non-ordered data sequence is ranked up according to the goal ordering selection strategy, memory headroom can be saved, reduce number According to the time for importing memory, frequent data item write operation of the insertion sort in sequencer procedure is avoided, reading and writing data is improved Speed and efficiency, the user experience is improved.
Detailed description of the invention
Fig. 1 is the peripheral storage device structural schematic diagram for the hardware running environment that the embodiment of the present invention is related to;
Fig. 2 is that the present invention is based on the flow diagrams of the sequencing selection method first embodiment of external memory;
Fig. 3 is that the present invention is based on the flow diagrams of the sequencing selection method second embodiment of external memory;
Fig. 4 is that the present invention is based on the flow diagrams of the sequencing selection method 3rd embodiment of external memory;
Fig. 5 is that the present invention is based on the flow diagrams of the sequencing selection method fourth embodiment of external memory;
Fig. 6 is that the present invention is based on the functional block diagrams of the sequencing selection device first embodiment of external memory.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The solution of the embodiment of the present invention is mainly: the present invention reads local non-ordered data sequence by peripheral storage device Column, extract the ascending order keyword in the non-ordered data sequence;Goal ordering selection strategy is determined according to the ascending order keyword; The non-ordered data sequence is ranked up according to the goal ordering selection strategy, memory headroom can be saved, reduce number According to the time for importing memory, frequent data item write operation of the insertion sort in sequencer procedure is avoided, reading and writing data is improved Speed and efficiency, the user experience is improved, solves selected and sorted in the prior art and carries out that there are memory headrooms to disappear in memory Consumption is big, and data import time long technical problem.
Referring to Fig.1, Fig. 1 is the peripheral storage device structural representation for the hardware running environment that the embodiment of the present invention is related to Figure.
As shown in Figure 1, the peripheral storage device may include: processor 1001, such as central processing unit (Central Processing Unit, CPU), communication bus 1002, user interface 1003, network interface 1004, memory 1005.Wherein, Communication bus 1002 is for realizing the connection communication between these components.User interface 1003 may include that the wired of standard connects Mouth, wireless interface.Network interface 1004 optionally may include standard wireline interface and wireless interface (such as Wireless Fidelity (WIreless-FIdelity, WI-FI) interface).Memory 1005 can be the random access memory (Random of high speed Access Memory, RAM) memory, it is also possible to stable memory (Non-volatile Memory, NVM), such as magnetic Disk storage.Memory 1005 optionally can also be the storage device independently of aforementioned processor 1001.
It will be understood by those skilled in the art that peripheral storage device structure shown in Fig. 1 is not constituted and is set to the external storage Standby restriction may include perhaps combining certain components or different component layouts than illustrating more or fewer components.
As shown in Figure 1, as may include operating system, network communication mould in a kind of memory 1005 of storage medium Block, user terminal interface module and the sequencing selection program based on external memory.
It is the sequencing selection equipment based on external memory, the external memory the present invention is based on the peripheral storage device of the sequencing selection of external memory Storage equipment calls the sequencing selection program based on external memory stored in memory 1005 by processor 1001, and executes the present invention The sequencing selection method based on external memory that embodiment provides.
The present embodiment through the above scheme, local non-ordered data sequence is read by peripheral storage device, extracts the nothing Ascending order keyword in sequence data sequence;Goal ordering selection strategy is determined according to the ascending order keyword;According to the target Sequencing selection strategy is ranked up the non-ordered data sequence, can save memory headroom, reduces data and imports memory Time avoids frequent data item write operation of the insertion sort in sequencer procedure, improves the speed and efficiency of reading and writing data, mention User experience is risen.
Based on above-mentioned hardware configuration, propose that the present invention is based on the sequencing selection embodiments of the method for external memory.
It is that the present invention is based on the flow diagrams of the sequencing selection method first embodiment of external memory referring to Fig. 2, Fig. 2.
In the first embodiment, the sequencing selection method based on external memory the following steps are included:
Step S10, peripheral storage device reads local non-ordered data sequence, extracts the ascending order in the non-ordered data sequence Keyword.
It should be noted that the non-ordered data sequence is pre-set for data to be carried out with the sequence of selected and sorted Column, the non-ordered data sequence are unordered external memory file sequence, and ascending order keyword can be extracted from non-ordered data sequence, thus Data sorting can be carried out according to the ascending order keyword, ascending order selected and sorted can be carried out by the non-ordered data sequence.
Further, the step S10 specifically includes the following steps:
In ascending order keyword keyword the smallest for data volume in the non-ordered data sequence, the target is determined Sequencing selection strategy is the preferential ascending sort strategy of low level;
In ascending order keyword keyword maximum for data volume in the non-ordered data sequence, the target is determined Sequencing selection strategy is high-order ascending sort strategy;
It is that the smallest keyword of data volume and data volume are maximum in the non-ordered data sequence in the ascending order keyword When keyword, determine that the goal ordering selection strategy is high-low-position ascending sort strategy simultaneously.
It is understood that data of the ascending order keyword generally by each data element in non-ordered data sequence It measures size to determine, each data element can be word or word, be also possible to other elements, determine generally by element indicator Each data element is data volume size.
In the concrete realization, the difference of ascending order keyword corresponds to different ascending sort strategies, the non-ordered data sequence Usually needing to form non-ordered data sequence after initialization can be with shape after initializing to the non-ordered data sequence At unordered external memory file sequence, if the non-ordered data sequence that a length is nIt is an external memory text Part, if after depositing into capable selected and sorted outside by n-1 times, obtained data sequence It is the external memory file of a keyword ascending order, then the sequencer procedure is ascending order selected and sorted.
Step S20, goal ordering selection strategy is determined according to the ascending order keyword.
It should be noted that corresponding goal ordering selection strategy can be determined by the ascending order keyword, it is different Ascending order keyword corresponds to different sequencing selection strategies, and in the present embodiment, it is excellent that the sequencing selection strategy can be divided into low level First ascending sort strategy, high priority ascending sort strategy, low level to high-order ascending sort strategy and the high-order low level ascending order that arrives are arranged Sequence strategy, naturally it is also possible to be other sequencing selection strategies, the present embodiment is without restriction to this.
Step S30, the non-ordered data sequence is ranked up according to the goal ordering selection strategy.
It should be understood that different goal ordering selection strategies corresponds to different ascending sort modes, and then to described Non-ordered data sequence is ranked up, in goal ordering selection strategy ascending sort strategy preferential for low level, to the nothing The sequence data sequence ascending order selected and sorted preferential according to low level;It is high priority ascending sort in the goal ordering selection strategy When tactful, to the non-ordered data sequence according to the ascending order selected and sorted of high priority;It is in the goal ordering selection strategy When low level is to high-order ascending sort strategy, to the non-ordered data sequence according to low level to the ascending order selected and sorted of a high position;Institute State goal ordering selection strategy for it is high-order to low level ascending sort strategy when, low level is arrived according to a high position to the non-ordered data sequence Ascending order selected and sorted.
In the concrete realization, if by non-ordered data sequenceBy the 1st ascending order selected and sorted The database file obtained afterwards isWhereinIt is the ascending sequence of a keyword, andIt is a pass The unordered sequence of keyword is then the preferential ascending order selected and sorted of low level;On the contrary, if by non-ordered data sequenceThe database file obtained after the 1st ascending order selected and sorted isWhereinIt is one The ascending sequence of a keyword, andIt is the unordered sequence of a keyword, then is high priority ascending order selected and sorted Method.
The present embodiment through the above scheme, local non-ordered data sequence is read by peripheral storage device, extracts the nothing Ascending order keyword in sequence data sequence;Goal ordering selection strategy is determined according to the ascending order keyword;According to the target Sequencing selection strategy is ranked up the non-ordered data sequence, can save memory headroom, reduces data and imports memory Time avoids frequent data item write operation of the insertion sort in sequencer procedure, improves the speed and efficiency of reading and writing data, mention User experience is risen.
Further, Fig. 3 is that the present invention is based on the flow diagrams of the sequencing selection method second embodiment of external memory, is such as schemed Shown in 3, propose that the present invention is based on the sequencing selection method second embodiments of external memory based on first embodiment, in the present embodiment, The step S30 the following steps are included:
Step S311, in goal ordering selection strategy ascending sort strategy preferential for low level, the ascending order is determined Keyword is the smallest keyword of data volume, and determines that the ascending order keyword is corresponding initial from the target data file Storage position.
It should be noted that the initial storage position is raw bits of the ascending order keyword in non-ordered data sequence It sets, it can be understood as the record storage position of the keyword data in peripheral storage device;In the goal ordering selection strategy When ascending sort strategy preferential for low level, it can determine that the ascending order keyword is the smallest keyword of data volume, and then determine The corresponding initial storage position of the ascending order keyword, opens the unordered tree in the peripheral storage device usually with read-write mode According to sequence, to obtain the data parameters in the wireless data sequence, in actual operation, element indicator i is usually enabled =1, indicate the smallest record storage position of keyword in selection non-ordered data sequence, i.e. the smallest keyword of data volume is described Ascending order keyword and corresponding original position.
Step S312, the text of the corresponding target data file of non-ordered data sequence and the target data file is obtained Part size obtains the record strip number in the target data file according to the file size.
In the concrete realization, if the size of corresponding each data file respectively recorded is in the non-ordered data sequence Size, then when being written and read to the non-ordered data sequence, the middle size that can detecte out the non-ordered data sequence is Fsize, then the corresponding record strip number of each data file is n=fsize/size, i.e. record strip number in the non-ordered data sequence Equal to file total size divided by the quotient of record size, naturally it is also possible to determine that the target data file is corresponding by other means Record strip number, the present embodiment is without restriction to this.
Step S313, file pointer is zeroed, reads data record as initial note from current file pointer position Record, and the original records are stored in temporary folder.
It should be noted that the temporary folder is pre-set for temporarily storing the file of file data, Even file pointer zero element indicator i=1 is indicated the smallest record storage position of keyword in non-ordered data sequence; Enable element indicator l=1;File pointer is moved on to the place for being (i-1) size apart from file first offset amount, is referred to from current file Pin position reads a record x as original records, indicates that file pointer is located at initial storage position at this time, at this time remembers data Record is as original records and is stored in temporary folder, and ascending order keyword at this time is temp.key=x.
Step S314, the file pointer is moved on into increase from the initial storage position default bias unit is corresponding deposits Position is put, data record is read from current file pointer position and is used as target record, obtain the target of the target record Keyword.
It is understood that default bias unit is pre-set offset unit, 1 offset generally can be set to Amount, naturally it is also possible to be set as other offsets, the present embodiment is without restriction to this, by the file pointer from described initial Storage position, which moves on to, increases the corresponding storage position of default bias unit, even element indicator j=i+1;File pointer is moved To the place for being (j-1) size apart from file first offset amount, data record y is read as mesh from current file pointer position Label is recorded, and then the target keyword y.key of the target record is obtained from above-mentioned target record.
Step S315, by the target keyword compared with the ascending order keyword, in the data of the target keyword When amount is greater than the data volume of the ascending order keyword, the target record is stored in the temporary folder.
It should be understood that by the target keyword compared with the ascending order keyword, it can be according to keyword size Relationship determine collating sequence, i.e., temp.key is compared with the data volume of y.key, in temp.key > y.key, then Make temp=y and l=j, i.e., it, will be described when the data volume of the target keyword is greater than the data volume of the ascending order keyword Target record is stored in the temporary folder.
Step S316, the file pointer is persistently moved to increasing the corresponding next storage position of the default bias unit It sets, and reads corresponding record, until each record in the target data file is sequentially stored into described face according to sequencing When file quantity reach the record strip number until.
It is understood that by lasting mobile file pointer, and then persistently completing record ordering can be to avoid mistake row Sequence or generation the case where miss respective record, have ensured that the accuracy and integrality of data sorting make j in actual operation =j+1;It repeats to move on to the file pointer from the initial storage position and increases the corresponding storage position of default bias unit, Data record is read from current file pointer position and is used as target record, obtains the target keyword of the target record, By the target keyword compared with the ascending order keyword, it is crucial to be greater than the ascending order in the data volume of the target keyword When the data volume of word, the target record is stored in the temporary folder, until each record in the target data file Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder, if l ≠ i, carry out Following operation:
(a) file pointer is moved on to the place for being (i-1) size apart from file first offset amount;
(b) file pointer pointed location is written into record temp;
(c) file pointer is moved on to the place for being (l-1) size apart from file first offset amount;
(d) file pointer pointed location is written into record x;
Make i=i+1;File pointer is persistently moved in repetition, and continues to complete the operation of record ordering, until the number of targets Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder according to each record in file.
In the concrete realization, in goal ordering selection strategy ascending sort strategy preferential for low level, the low level Preferential ascending sort strategy is general are as follows: by non-ordered data sequenceBecome having for a keyword ascending order Preface part sequenceElement i.e. in sequence meetsNon-ordered data sequenceThrough The process for crossing n-1 ascending order selected and sorted is as follows:
Step 1: the element indicator i=1 of initialization sequence is indicated from non-ordered data sequence Select the smallest element of keyword;
Step 2: enabling l=i, it is assumed that current 1st element is that keyword i-th is small;
Step 3: the element of i-th of position is read from non-ordered data sequence
Step 4: enabling j=i+1, allow j indicator element
Step 5: the element of j-th of position is read from non-ordered data sequence
Step 6: ifThen, l=j is enabled, l is allowed always to indicate the smallest element of keyword;
Step 7: repeating step 4 to step 6, until j=n;
Step 8: having at this time
Step 9: if l ≠ i,I.e. by elementWrite-inPosition hereof It sets, and by elementWrite-inPosition hereof;
Step 10: the data sequence of external memory file is at this timeWherein,It is the ascending sequence of a keyword, i.e.,AndIt is an also unsorted unordered sequence in external memory file data sequence;
Step 11: if i < n-1, i=i+1 and repeating step 2 to step 10;
Step 12:It is the external memory file of an according to keyword ascending sort.
The present embodiment through the above scheme, by the goal ordering selection strategy be the preferential ascending sort strategy of low level When, determine that the ascending order keyword is the smallest keyword of data volume, and the ascending order is determined from the target data file The corresponding initial storage position of keyword;Obtain the corresponding target data file of the non-ordered data sequence and the target data The file size of file obtains the record strip number in the target data file according to the file size;File pointer is returned Zero, data record is read from current file pointer position and is used as original records, and the original records are stored in interim text Part folder;The file pointer is moved on to from the initial storage position and increases the corresponding storage position of default bias unit, from working as Preceding document pointer position reads data record and is used as target record, obtains the target keyword of the target record;By institute Target keyword is stated compared with the ascending order keyword, is greater than the ascending order keyword in the data volume of the target keyword When data volume, the target record is stored in the temporary folder;It is described default to increasing persistently to move the file pointer The corresponding next storage position of offset identity, and corresponding record is read, until each record in the target data file is pressed Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder, can to avoid mistake sequence or Person misses the generation of the case where respective record, has ensured the accuracy and integrality of data sorting, can save memory headroom, reduces Data import the time of memories, avoid frequent data item write operation of the insertion sort in sequencer procedure, improve data reading The speed and efficiency write, the user experience is improved.
Further, Fig. 4 is that the present invention is based on the flow diagrams of the sequencing selection method 3rd embodiment of external memory, is such as schemed Shown in 4, propose that the present invention is based on the sequencing selection method 3rd embodiments of external memory based on first embodiment, in the present embodiment, The step S30 specifically includes the following steps:
Step S321, when the goal ordering selection strategy is high priority ascending sort strategy, the ascending order is determined Keyword is the maximum keyword of data volume, and determines that the ascending order keyword is corresponding initial from the target data file Storage position.
It should be noted that the initial storage position is raw bits of the ascending order keyword in non-ordered data sequence It sets, it can be understood as the record storage position of the keyword data in peripheral storage device;In the goal ordering selection strategy When for high priority ascending sort strategy, it can determine that the ascending order keyword is the maximum keyword of data volume, and then determine The corresponding initial storage position of the ascending order keyword, opens the unordered tree in the peripheral storage device usually with read-write mode According to sequence, to obtain the data parameters in the wireless data sequence, in actual operation, element indicator i is usually enabled =n indicates the maximum record storage position of keyword in selection non-ordered data sequence, i.e. the maximum keyword of data volume is described Ascending order keyword and corresponding original position.
Step S322, the text of the corresponding target data file of non-ordered data sequence and the target data file is obtained Part size obtains the record strip number in the target data file according to the file size.
In the concrete realization, if the size of corresponding each data file respectively recorded is in the non-ordered data sequence Size, then when being written and read to the non-ordered data sequence, the middle size that can detecte out the non-ordered data sequence is Fsize, then the corresponding record strip number of each data file is n=fsize/size, i.e. record strip number in the non-ordered data sequence Equal to file total size divided by the quotient of record size, naturally it is also possible to determine that the target data file is corresponding by other means Record strip number, the present embodiment is without restriction to this.
Step S323, file pointer is zeroed, reads data record as initial note from current file pointer position Record, and the original records are stored in temporary folder.
It should be noted that the temporary folder is pre-set for temporarily storing the file of file data, Even file pointer zero element indicator i=n is indicated the maximum record storage position of keyword in non-ordered data sequence; Enable element indicator h=1;File pointer is moved on to the place for being (i-1) size apart from file first offset amount, is referred to from current file Pin position reads a record x as original records, indicates that file pointer is located at initial storage position at this time, at this time remembers data Record is as original records and is stored in temporary folder, and ascending order keyword at this time is temp.key=x.
Step S324, the file pointer is moved on into reduction from the initial storage position default bias unit is corresponding deposits Position is put, data record is read from current file pointer position and is used as target record, obtain the target of the target record Keyword.
It is understood that default bias unit is pre-set offset unit, 1 offset generally can be set to Amount, naturally it is also possible to be set as other offsets, the present embodiment is without restriction to this, by the file pointer from described initial Storage position, which moves on to, reduces the corresponding storage position of default bias unit, even element indicator j=i-1;File pointer is moved To the place for being (j-1) size apart from file first offset amount, data record y is read as mesh from current file pointer position Label is recorded, and then the target keyword y.key of the target record is obtained from above-mentioned target record.
Step S325, by the target keyword compared with the ascending order keyword, in the data of the target keyword When amount is less than the data volume of the ascending order keyword, the target record is stored in the temporary folder.
It should be understood that by the target keyword compared with the ascending order keyword, it can be according to keyword size Relationship determine collating sequence, i.e., temp.key is compared with the data volume of y.key, in temp.key < y.key, then Make temp=y and h=j, i.e., it, will be described when the data volume of the target keyword is greater than the data volume of the ascending order keyword Target record is stored in the temporary folder.
Step S326, the file pointer is persistently moved to reducing the corresponding next storage position of the default bias unit It sets, and reads corresponding record, until each record in the target data file is sequentially stored into described face according to sequencing When file quantity reach the record strip number until.
It is understood that by lasting mobile file pointer, and then persistently completing record ordering can be to avoid mistake row Sequence or generation the case where miss respective record, have ensured that the accuracy and integrality of data sorting make j in actual operation =j-1;It repeats to move on to the file pointer from the initial storage position and reduces the corresponding storage position of default bias unit, Data record is read from current file pointer position and is used as target record, obtains the target keyword of the target record, By the target keyword compared with the ascending order keyword, it is crucial to be less than the ascending order in the data volume of the target keyword When the data volume of word, the target record is stored in the temporary folder, until each record in the target data file Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder, if l ≠ i, carry out Following operation:
(a) file pointer is moved on to the place for being (i-1) size apart from file first offset amount;
(b) file pointer pointed location is written into record temp;
(c) file pointer is moved on to the place for being (h-1) size apart from file first offset amount;
(d) file pointer pointed location is written into record x;
Make i=i+1;File pointer is persistently moved in repetition, and continues to complete the operation of record ordering, until the number of targets Until reaching the record strip number according to the quantity that sequencing is sequentially stored into the temporary folder according to each record in file.
In the concrete realization, when the goal ordering selection strategy is high priority ascending sort strategy, the high position Preferential ascending sort strategy is general are as follows: by non-ordered data sequenceBecome having for a keyword ascending order Preface part sequenceElement i.e. in sequence meetsNon-ordered data sequenceProcess by n-1 ascending order selected and sorted is as follows:
Step 1: the element indicator i=n of initialization sequence is indicated from non-ordered data sequence Select the maximum element of keyword;
Step 2: enabling h=i, it is assumed that current 1st element is the n-th-i+1 of keyword big;
Step 3: the element of i-th of position is read from non-ordered data sequence
Step 4: enabling j=i-1, allow j indicator element
Step 5: the element of j-th of position is read from non-ordered data sequence
Step 6: ifH=j is then enabled, h is allowed always to indicate the maximum member of keyword Element;
Step 7: repeating step 4 to step 6, until j=1;
Step 8: having at this time
Step 9: if h ≠ i,I.e. by elementWrite-inHereof Position, and by elementWrite-inPosition hereof;
Step 10: the data sequence of external memory file is at this timeIts In,It is the ascending sequence of a keyword, i.e.,AndIt is in external memory file data sequence One also unsorted unordered sequence;
Step 11: if i > 2, i=i-1 and repeating step 2 to step 10;
Step 12:Be one according to keyword ascending sort external memory text Part.
The present embodiment through the above scheme, by by the target keyword compared with the ascending order keyword, described When the data volume of target keyword is less than the data volume of the ascending order keyword, the target record is stored in the temporary file Folder;The file pointer is persistently moved to reducing the corresponding next storage position of the default bias unit, and is read corresponding Record, until each record in the target data file is reached according to the quantity that sequencing is sequentially stored into the temporary folder Until the record strip number, data sorting can have been ensured to avoid wrong the case where sorting or missing respective record generation Accuracy and integrality, memory headroom can be saved, reduce data import memory time, avoid insertion sort and arranging Frequent data item write operation in program process improves the speed and efficiency of reading and writing data, and the user experience is improved.
Further, Fig. 5 is that the present invention is based on the flow diagrams of the sequencing selection method fourth embodiment of external memory, is such as schemed Shown in 5, propose that the present invention is based on the sequencing selection method fourth embodiments of external memory based on first embodiment, in the present embodiment, The step S30 specifically includes the following steps:
Step S331, when the goal ordering selection strategy is high-low-position ascending sort strategy simultaneously, the liter is determined Sequence keyword is the maximum keyword of data volume and the smallest keyword of data volume, and institute is determined from the target data file State the corresponding first initial storage position of ascending order keyword and the second initial storage position.
It should be noted that the first initial storage position and the second initial storage position are the maximum ascending order of data volume The home position of keyword and the smallest keyword of data volume in non-ordered data sequence;It is in the goal ordering selection strategy When high-low-position while ascending sort strategy, it can determine that the ascending order keyword is the maximum keyword of data volume, and then determine The corresponding initial storage position of the ascending order keyword, opens the unordered tree in the peripheral storage device usually with read-write mode According to sequence, to obtain the data parameters in the wireless data sequence, by high-low-position, ascending sort strategy can have simultaneously Effect reduces the reading times of data, further improves the speed and efficiency of reading and writing data, the user experience is improved.
Step S332, the text of the corresponding target data file of non-ordered data sequence and the target data file is obtained Part size obtains the record strip number in the target data file according to the file size.
In the concrete realization, if the size of corresponding each data file respectively recorded is in the non-ordered data sequence Size, then when being written and read to the non-ordered data sequence, the middle size that can detecte out the non-ordered data sequence is Fsize, then the corresponding record strip number of each data file is n=fsize/size, i.e. record strip number in the non-ordered data sequence Equal to file total size divided by the quotient of record size, naturally it is also possible to determine that the target data file is corresponding by other means Record strip number, the present embodiment is without restriction to this.
Step S333, the first file pointer and the second file pointer are zeroed, are read from the first current file pointer position One data record is used as the first original records, reads data record as at the beginning of second from the second current file pointer position Begin record, and first original records and second original records are stored in temporary folder.
It should be noted that the temporary folder is pre-set for temporarily storing the file of file data, Even file pointer zero element indicator i=1 and j=n is indicated the note that keyword is minimum and maximum in non-ordered data sequence Record storage position;Enable element indicator l=i and h=j;It is (i-1) size's that file pointer, which is moved on to apart from file first offset amount, First record x1 is read as the first original records from current file pointer position in place, and ascending order keyword at this time is Temp1.key=x1 indicates that file pointer is located at the first initial storage position at this time, file pointer is moved on to first partially apart from file Shifting amount is the place of (j-1) size, reads Article 2 record x2 as the second original records, at this time from current file pointer position Ascending order keyword be temp2.key=x2, the first original records and the second original records are stored in temporary file simultaneously at this time Folder.
Step S334, according to the high-low-position, ascending sort strategy will be at the beginning of first file pointer from described first simultaneously Beginning storage position is deviated, and second file pointer is deviated from the described second initial storage position, according to offset Corresponding record is stored in the temporary folder by storage position afterwards, until each in the target data file record according to Until the quantity that sequencing is sequentially stored into the temporary folder reaches the record strip number.
It is understood that by lasting mobile file pointer, and then persistently completing record ordering can be to avoid mistake row Sequence or generation the case where miss respective record, have ensured the accuracy and integrality of data sorting.
Further, the step S334 specifically includes the following steps:
The high-low-position simultaneously ascending sort strategy be low level to a high position ascending sort strategy when, by first file Pointer moves on to from the described first initial storage position and reduces the corresponding first object storage position of default bias unit, by described the Two file pointers move on to from the described second initial storage position and reduce default bias unit corresponding second target storage position;
Data record is read as first object from the first object storage position to record, and obtains first mesh The first object keyword for marking record reads data record as the second target from second target storage position and remembers Record obtains the second target keyword of second target record;
The first object keyword and second target keyword are compared, in the first object keyword Data volume be greater than second target keyword data volume when, by the first object record and second target record It is stored in the temporary folder simultaneously;
It is corresponding to the default bias unit is increased persistently to move first file pointer and second file pointer Next storage position, and read corresponding record, until each in the target data file record according to sequencing according to Until the quantity of the secondary deposit temporary folder reaches the record strip number.
In the concrete realization, the high-low-position simultaneously ascending sort strategy be low level to a high position ascending sort strategy when, If the ascending order keyword temp2.key of the ascending order keyword original records of temp1.key > second of the first original records, makes l =j, h=i, temp2=x2 and temp1=x1;Enable k=i+1;It is (k-1) that file pointer, which is moved on to apart from file first offset amount, The place of size;A record y is read from current file pointer position;If temp1.key > y.key, make temp1=y and L=k;If temp2.key > y.key makes temp2=y and h=k;Make k=k+1;It repeats the file pointer from described Initial storage position, which moves on to, reduces the corresponding storage position of default bias unit, i.e., persistently moves first file pointer and institute The second file pointer is stated to the corresponding next storage position of the default bias unit is increased, until k > j-1;Refer to from current file Pin position reads data record and is used as target record, the target keyword of the target record is obtained, by first mesh Mark keyword and second target keyword are compared, and are greater than described second in the data volume of the first object keyword When the data volume of target keyword, first object record and second target record are stored in the temporary file simultaneously Folder;It is corresponding next to the default bias unit is increased persistently to move first file pointer and second file pointer Storage position, until each record in the target data file is sequentially stored into the number of the temporary folder according to sequencing Until amount reaches the record strip number, if l ≠ i, proceed as follows:
If (a) l=j makes x2=x1;
(b) file pointer is moved on to the place for being (i-1) size apart from file first offset amount;
(c) file pointer pointed location is written into record temp1;
(d) file pointer is moved on to the place for being (l-1) size apart from file first offset amount;
(e) file pointer pointed location is written into record x1;
If h ≠ j is proceeded as follows:
If (a) h=i makes x1=x2;
(b) file pointer is moved on to the place for being (j-1) size apart from file first offset amount;
(c) file pointer pointed location is written into record temp2;
(d) file pointer is moved on to the place for being (h-1) size apart from file first offset amount;
(e) file pointer pointed location is written into record x2;
If h=i is proceeded as follows:
(a) file pointer is moved on to the place for being (i-1) size apart from file first offset amount;
(b) file pointer pointed location is written into record temp1;
(c) file pointer is moved on to the place for being (l-1) size apart from file first offset amount;
(d) file pointer pointed location is written into record x1;
Make i=i+1 and j=j-1;It repeats the file pointer moving on to reduction default bias from the initial storage position The corresponding storage position of unit, until i >=j;
In the concrete realization, in high-low-position ascending sort strategy simultaneously, the high-low-position while ascending sort plan It is slightly general are as follows: by non-ordered data sequenceBecome the order file sequence of a keyword ascending order(when n be even number) or(work as n For odd number), i.e., the element in sequence meetsIn the height Low level simultaneously ascending sort strategy be low level to a high position ascending sort strategy when, non-ordered data sequenceByIt is secondary orThe process of ascending order selected and sorted is as follows:
Step 1: element the indicator i=1 and j=n of initialization sequence are respectively indicated from non-ordered data sequenceIn lowest order and highest order, i.e. the minimum and maximum element of selection keyword;
Step 2: enabling l=i and h=j, indicate the smallest element position of keyword in unsorted sequence with l, and indicated with h The maximum element position of keyword in unsorted sequence;
Step 3: the element of first of position is read from non-ordered data sequenceWith the element of h-th of position
Step 4: ifThen makeWith
Step 5: enabling k=i+1, allow k indicator element
Step 6: the element of k-th of position is read from non-ordered data sequence
Step 7: ifL=k is then enabled, l is allowed always to indicate the smallest element of keyword;
Step 8: ifH=k is then enabled, l is allowed always to indicate the maximum element of keyword;
Step 9: enabling k=k+1;
Step 10: repeating step 6 to step 9, until k=j-1;
Step 11: having at this timeWith
Step 12: if l ≠ i,I.e. by elementWrite-inHereof Position, and by elementWrite-inPosition hereof;
Step 13: if h ≠ j,I.e. by elementWrite-inPosition hereof It sets, and by elementWrite-inPosition hereof;
Step 14: the data sequence of external memory file is at this timeWherein,WithIt is the ascending sequence of keyword, i.e.,WithAndBe in external memory file data sequence one do not arrange also The unordered sequence of sequence, and
Step 15: making i=i+1 and j=j+1;
Step 16: if i < j, repeating step 2 to step 15;
Step 17:(when n be odd number) or(when n be even number) be one according to keywords ascending sort external memory text Part.
Further, the step S334 specifically includes the following steps:
When ascending sort strategy is that a high position arrives low level ascending sort strategy to the high-low-position simultaneously, by first file Pointer moves on to from the described first initial storage position and reduces the corresponding first object storage position of default bias unit, by described the Two file pointers move on to from the described second initial storage position and reduce default bias unit corresponding second target storage position;
Data record is read as first object from the first object storage position to record, and obtains first mesh The first object keyword for marking record reads data record as the second target from second target storage position and remembers Record obtains the second target keyword of second target record;
The first object keyword and second target keyword are compared, in the first object keyword Data volume be greater than second target keyword data volume when, by the first object record and second target record It is stored in the temporary folder simultaneously;
It is corresponding to the default bias unit is reduced persistently to move first file pointer and second file pointer Next storage position, and read corresponding record, until each in the target data file record according to sequencing according to Until the quantity of the secondary deposit temporary folder reaches the record strip number.
In the concrete realization, when ascending sort strategy is that a high position arrives low level ascending sort strategy to the high-low-position simultaneously, If the ascending order keyword temp2.key of the ascending order keyword original records of temp1.key > second of the first original records, makes l =j, h=i, temp1=x2 and temp2=x1;Enable k=j-1;It is (k-1) that file pointer, which is moved on to apart from file first offset amount, The place of size;A record y is read from current file pointer position;If temp1.key > y.key, make temp1=y and L=k;If temp2.key > y.key makes temp2=y and h=k;Make k=k-1;It repeats the file pointer from described Initial storage position, which moves on to, reduces the corresponding storage position of default bias unit, i.e., persistently moves first file pointer and institute The second file pointer is stated to the corresponding next storage position of the default bias unit is increased, until k < i-1;Refer to from current file Pin position reads data record and is used as target record, the target keyword of the target record is obtained, by first mesh Mark keyword and second target keyword are compared, and are greater than described second in the data volume of the first object keyword When the data volume of target keyword, first object record and second target record are stored in the temporary file simultaneously Folder;It is corresponding next to the default bias unit is reduced persistently to move first file pointer and second file pointer Storage position, until each record in the target data file is sequentially stored into the number of the temporary folder according to sequencing Until amount reaches the record strip number, if h ≠ j, proceed as follows:
If (a) h=i makes x1=x2;
(b) file pointer is moved on to the place for being (j-1) size apart from file first offset amount;
(c) file pointer pointed location is written into record temp2;
(d) file pointer is moved on to the place for being (h-1) size apart from file first offset amount;
(e) file pointer pointed location is written into record x2;
If l ≠ i is proceeded as follows:
If (a) l=j makes x2=x1;
(b) file pointer is moved on to the place for being (i-1) size apart from file first offset amount;
(c) file pointer pointed location is written into record temp1;
(d) file pointer is moved on to the place for being (l-1) size apart from file first offset amount;
(e) file pointer pointed location is written into record x1;
If l=j is proceeded as follows:
(a) file pointer is moved on to the place for being (j-1) size apart from file first offset amount;
(b) file pointer pointed location is written into record temp2;
(c) file pointer is moved on to the place for being (h-1) size apart from file first offset amount;
(d) file pointer pointed location is written into record x2;
Make i=i+1 and j=j-1;It repeats the file pointer moving on to reduction default bias from the initial storage position The corresponding storage position of unit, until i >=j;
In the concrete realization, when ascending sort strategy is that a high position arrives low level ascending sort strategy to the high-low-position simultaneously, Non-ordered data sequenceByIt is secondary orThe process of ascending order selected and sorted is as follows:
Step 1: element the indicator i=1 and j=n of initialization sequence are respectively indicated from non-ordered data sequenceIn lowest order and highest order, i.e. the minimum and maximum element of selection keyword;
Step 2: enabling l=i and h=j, indicate the smallest element position of keyword in unsorted sequence with l, and indicated with h The maximum element position of keyword in unsorted sequence;
Step 3: the element of first of position is read from non-ordered data sequenceWith the element of h-th of position
Step 4: ifThen makeWith
Step 5: enabling k=j-1, allow k indicator element
Step 6: the element of k-th of position is read from non-ordered data sequence
Step 7: ifL=k is then enabled, l is allowed always to indicate the smallest element of keyword;
Step 8: ifH=k is then enabled, l is allowed always to indicate the maximum element of keyword;
Step 9: enabling k=k-1;
Step 10: repeating step 6 to step 9, until k=j+1;
Step 11: having at this timeWith
Step 12: if l ≠ i,I.e. by elementWrite-inHereof Position, and by elementWrite-inPosition hereof;
Step 13: if h ≠ j,I.e. by elementWrite-inPosition hereof It sets, and by elementWrite-inPosition hereof;
Step 14: the data sequence of external memory file is at this timeWherein,WithIt is the ascending sequence of keyword, i.e.,WithAndBe in external memory file data sequence one do not arrange also The unordered sequence of sequence, and
Step 15: making i=i+1 and j=j+1;
Step 16: if i < j, repeating step 2 to step 15;
Step 17:(when n be odd number) or(when n be even number) be one according to keywords ascending sort external memory text Part.
The present embodiment is through the above scheme, current from first by the way that the first file pointer and the second file pointer are zeroed File pointer position reads data record and is used as the first original records, reads a number from the second current file pointer position The second original records are used as according to record, and first original records and second original records are stored in temporary folder; According to the high-low-position, ascending sort strategy is inclined from the described first initial storage position progress by first file pointer simultaneously It moves, second file pointer is deviated from the described second initial storage position, it will be right according to the storage position after offset The record answered is stored in the temporary folder, until each record in the target data file is sequentially stored into according to sequencing Until the quantity of the temporary folder reaches the record strip number, the feelings of respective record can be sorted or missed to avoid mistake Condition occur, ensured the accuracy and integrality of data sorting, memory headroom can be saved, reduce data import memory when Between, frequent data item write operation of the insertion sort in sequencer procedure is avoided, the speed and efficiency of reading and writing data are improved, is promoted User experience.
Based on the embodiment of the above-mentioned sequencing selection method based on external memory, the present invention further provides a kind of based on external memory Sequencing selection device.
It is that the present invention is based on the functional block diagrams of the sequencing selection device first embodiment of external memory referring to Fig. 6, Fig. 6.
The present invention is based in the sequencing selection device first embodiment of external memory, it is somebody's turn to do the sequencing selection device packet based on external memory It includes: keyword extracting module 10, strategy selection module 20 and sorting module 30;
Wherein, the keyword extracting module 10 reads local non-ordered data sequence for peripheral storage device, extracts institute State the ascending order keyword in non-ordered data sequence;
The strategy selection module 20, for determining goal ordering selection strategy according to the ascending order keyword;
The sorting module 30, for being arranged according to the goal ordering selection strategy the non-ordered data sequence Sequence.
Wherein, the step of each Implement of Function Module of the sequencing selection device based on external memory can refer to that the present invention is based on outer The each embodiment for the sequencing selection method deposited, details are not described herein again.
In addition, the embodiment of the present invention also proposes a kind of storage medium, the row based on external memory is stored on the storage medium Sequence option program, the sequence based on external memory as described above when the sequencing selection program based on external memory is executed by processor The step of selection method.
The present embodiment through the above scheme, local non-ordered data sequence is read by peripheral storage device, extracts the nothing Ascending order keyword in sequence data sequence;Goal ordering selection strategy is determined according to the ascending order keyword;According to the target Sequencing selection strategy is ranked up the non-ordered data sequence, can save memory headroom, reduces data and imports memory Time avoids frequent data item write operation of the insertion sort in sequencer procedure, improves the speed and efficiency of reading and writing data, mention User experience is risen.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or device.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of sequencing selection method based on external memory, which is characterized in that the sequencing selection method based on external memory includes:
Peripheral storage device reads local non-ordered data sequence, extracts the ascending order keyword in the non-ordered data sequence;
Goal ordering selection strategy is determined according to the ascending order keyword;
The non-ordered data sequence is ranked up according to the goal ordering selection strategy.
2. the sequencing selection method based on external memory as described in claim 1, which is characterized in that described according to the goal ordering Selection strategy is ranked up the non-ordered data sequence, specifically includes:
In goal ordering selection strategy ascending sort strategy preferential for low level, determine that the ascending order keyword is data volume The smallest keyword, and the corresponding initial storage position of the ascending order keyword is determined from the target data file;
The file size for obtaining the corresponding target data file of the non-ordered data sequence and the target data file, according to institute It states file size and obtains record strip number in the target data file;
File pointer is zeroed, data record is read from current file pointer position and is used as original records, and will be described first Begin record deposit temporary folder;
The file pointer is moved on to from the initial storage position and increases the corresponding storage position of default bias unit, from current File pointer position reads data record and is used as target record, obtains the target keyword of the target record;
By the target keyword compared with the ascending order keyword, it is greater than the ascending order in the data volume of the target keyword When the data volume of keyword, the target record is stored in the temporary folder;
The file pointer is persistently moved to increasing the corresponding next storage position of the default bias unit, and is read corresponding Record, until each record in the target data file is reached according to the quantity that sequencing is sequentially stored into the temporary folder Until the record strip number.
3. the sequencing selection method based on external memory as described in claim 1, which is characterized in that described according to the goal ordering Selection strategy is ranked up the non-ordered data sequence, specifically includes:
When the goal ordering selection strategy is high priority ascending sort strategy, determine that the ascending order keyword is data volume Maximum keyword, and the corresponding initial storage position of the ascending order keyword is determined from the target data file;
The file size for obtaining the corresponding target data file of the non-ordered data sequence and the target data file, according to institute It states file size and obtains record strip number in the target data file;
File pointer is zeroed, data record is read from current file pointer position and is used as original records, and will be described first Begin record deposit temporary folder;
The file pointer is moved on to from the initial storage position and reduces the corresponding storage position of default bias unit, from current File pointer position reads data record and is used as target record, obtains the target keyword of the target record;
By the target keyword compared with the ascending order keyword, it is less than the ascending order in the data volume of the target keyword When the data volume of keyword, the target record is stored in the temporary folder;
The file pointer is persistently moved to reducing the corresponding next storage position of the default bias unit, and is read corresponding Record, until each record in the target data file is reached according to the quantity that sequencing is sequentially stored into the temporary folder Until the record strip number.
4. the sequencing selection method based on external memory as described in claim 1, which is characterized in that described according to the goal ordering Selection strategy is ranked up the non-ordered data sequence, specifically includes:
When the goal ordering selection strategy is high-low-position ascending sort strategy simultaneously, determine that the ascending order keyword is data Maximum keyword and the smallest keyword of data volume are measured, and determines the ascending order keyword pair from the target data file The initial storage position of first answered and the second initial storage position;
The file size for obtaining the corresponding target data file of the non-ordered data sequence and the target data file, according to institute It states file size and obtains record strip number in the target data file;
First file pointer and the second file pointer are zeroed, data record is read from the first current file pointer position and makees For the first original records, data record is read from the second current file pointer position and is used as the second original records, and by institute State the first original records and second original records deposit temporary folder;
According to the high-low-position simultaneously ascending sort strategy by first file pointer from the described first initial storage position into Line displacement deviates second file pointer from the described second initial storage position, according to the storage position after offset Corresponding record is stored in the temporary folder, until each in the target data file records according to sequencing successively Be stored in the temporary folder quantity reach the record strip number until.
5. the sequencing selection method based on external memory as claimed in claim 4, which is characterized in that described same according to the high-low-position When ascending sort strategy first file pointer is deviated from the described first initial storage position, by second file Pointer is deviated from the described second initial storage position, will be faced described in the deposit of corresponding record according to the storage position after offset When file, until each record in the target data file is sequentially stored into the number of the temporary folder according to sequencing Until amount reaches the record strip number, specifically include:
The high-low-position simultaneously ascending sort strategy be low level to a high position ascending sort strategy when, by first file pointer It is moved on to from the described first initial storage position and reduces the corresponding first object storage position of default bias unit, by second text Part pointer moves on to from the described second initial storage position and reduces default bias unit corresponding second target storage position;
Data record is read as first object from the first object storage position to record, and obtains the first object note The first object keyword of record reads data record from second target storage position and is used as the second target record, obtains Take the second target keyword of second target record;
The first object keyword and second target keyword are compared, in the number of the first object keyword When being greater than the data volume of second target keyword according to amount, simultaneously with second target record by first object record It is stored in the temporary folder;
Persistently move first file pointer and second file pointer to increase the default bias unit it is corresponding under One storage position, and corresponding record is read, until each record in the target data file is successively deposited according to sequencing Enter the temporary folder quantity reach the record strip number until.
6. the sequencing selection method based on external memory as claimed in claim 4, which is characterized in that described same according to the high-low-position When ascending sort strategy first file pointer is deviated from the described first initial storage position, by second file Pointer is deviated from the described second initial storage position, will be faced described in the deposit of corresponding record according to the storage position after offset When file, until each record in the target data file is sequentially stored into the number of the temporary folder according to sequencing Until amount reaches the record strip number, specifically include:
When ascending sort strategy is that a high position arrives low level ascending sort strategy to the high-low-position simultaneously, by first file pointer It is moved on to from the described first initial storage position and reduces the corresponding first object storage position of default bias unit, by second text Part pointer moves on to from the described second initial storage position and reduces default bias unit corresponding second target storage position;
Data record is read as first object from the first object storage position to record, and obtains the first object note The first object keyword of record reads data record from second target storage position and is used as the second target record, obtains Take the second target keyword of second target record;
The first object keyword and second target keyword are compared, in the number of the first object keyword When being greater than the data volume of second target keyword according to amount, simultaneously with second target record by first object record It is stored in the temporary folder;
Persistently move first file pointer and second file pointer to reduce the default bias unit it is corresponding under One storage position, and corresponding record is read, until each record in the target data file is successively deposited according to sequencing Enter the temporary folder quantity reach the record strip number until.
7. such as the sequencing selection method of any of claims 1-6 based on external memory, which is characterized in that described according to institute It states ascending order keyword and determines goal ordering selection strategy, specifically include:
In ascending order keyword keyword the smallest for data volume in the non-ordered data sequence, the goal ordering is determined Selection strategy is the preferential ascending sort strategy of low level;
In ascending order keyword keyword maximum for data volume in the non-ordered data sequence, the goal ordering is determined Selection strategy is high-order ascending sort strategy;
It is the smallest keyword of data volume and the maximum key of data volume in the non-ordered data sequence in the ascending order keyword When word, determine that the goal ordering selection strategy is high-low-position ascending sort strategy simultaneously.
8. a kind of sequencing selection device based on external memory, which is characterized in that described device includes: keyword extracting module, strategy Selecting module and sorting module;
Wherein, the keyword extracting module reads local non-ordered data sequence for peripheral storage device, extracts described unordered Ascending order keyword in data sequence;
The strategy selection module, for determining goal ordering selection strategy according to the ascending order keyword;
The sorting module, for being ranked up according to the goal ordering selection strategy to the non-ordered data sequence.
9. a kind of peripheral storage device, which is characterized in that the peripheral storage device includes: memory, processor and is stored in described On memory and the sequencing selection program based on external memory that can run on the processor, the sequencing selection based on external memory Program is arranged for carrying out the step of sequencing selection method based on external memory as described in any one of claims 1 to 7.
10. a kind of storage medium, which is characterized in that be stored with the sequencing selection program based on external memory, institute on the storage medium State when the sequencing selection program based on external memory is executed by processor realize as described in any one of claims 1 to 7 based on outer The step of sequencing selection method deposited.
CN201910125544.3A 2019-02-19 2019-02-19 Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory Pending CN109901796A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910125544.3A CN109901796A (en) 2019-02-19 2019-02-19 Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910125544.3A CN109901796A (en) 2019-02-19 2019-02-19 Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory

Publications (1)

Publication Number Publication Date
CN109901796A true CN109901796A (en) 2019-06-18

Family

ID=66945051

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910125544.3A Pending CN109901796A (en) 2019-02-19 2019-02-19 Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory

Country Status (1)

Country Link
CN (1) CN109901796A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110955696A (en) * 2019-11-12 2020-04-03 中国经济信息社有限公司 Data reading method, device, equipment and storage medium
CN113468122A (en) * 2021-06-24 2021-10-01 广东全芯半导体有限公司 TF card reading equipment with Bluetooth function

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107122222A (en) * 2017-04-20 2017-09-01 深圳大普微电子科技有限公司 The search system and method for a kind of character string
CN108228634A (en) * 2016-12-15 2018-06-29 杭州华为数字技术有限公司 A kind of data processing method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108228634A (en) * 2016-12-15 2018-06-29 杭州华为数字技术有限公司 A kind of data processing method and device
CN107122222A (en) * 2017-04-20 2017-09-01 深圳大普微电子科技有限公司 The search system and method for a kind of character string

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王 敏: "改进的双向选择排序算法", 《信息技术》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110955696A (en) * 2019-11-12 2020-04-03 中国经济信息社有限公司 Data reading method, device, equipment and storage medium
CN113468122A (en) * 2021-06-24 2021-10-01 广东全芯半导体有限公司 TF card reading equipment with Bluetooth function

Similar Documents

Publication Publication Date Title
CN110019647B (en) Keyword searching method and device and search engine
CN110351318A (en) Using the method, terminal and computer storage medium of recommendation
CN109901796A (en) Sequencing selection method, apparatus, peripheral storage device and storage medium based on external memory
CN112860937B (en) KNN and word embedding based mixed music recommendation method, system and equipment
CN103995817A (en) Information processing device and storage medium
CN109726858A (en) Heat load prediction method and device based on dynamic time warping
CN101493340B (en) Method for quickly searching interested point information in navigation system for vehicles
CN104636349A (en) Method and equipment for compression and searching of index data
CN103345469A (en) Storing and inquiring method and device of number sets
CN102831224A (en) Creating method for data index base and searching suggest generation method and device
CN109669917A (en) A kind of Waveform storage method based on priority packet
CN106598919A (en) Document generation method and device
US20030159010A1 (en) Method, device and computer program product for processing information in a memory
CN109885476A (en) Automated testing method and device, terminal and computer readable storage medium
CN106384389A (en) Method for texture combination of model data
CN105550254B (en) A kind of method of ICD Automatic generation of information ICD information database
CN100334582C (en) Method and apparatus for storing and searching data in hand-held device
CN107122805A (en) A kind of user clustering method and apparatus
CN109448697A (en) Poem melody generation method, electronic device and computer readable storage medium
CN109597934A (en) Determine method, apparatus, storage medium and the electronic equipment clicked and recommend word
CN103425829B (en) A kind of method of quick reading domain
CN109815534B (en) Flash memory life prediction method and system based on decision tree algorithm
CN102981607A (en) Computer-implemented method of arranging text items in a predefined order
WO2005043589A3 (en) Method and system for enhancing the endurance of memory cells
CN107389071A (en) A kind of improved indoor positioning KNN methods

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190618