CN105955727A - Creation method and access method for universal memory entity - Google Patents

Creation method and access method for universal memory entity Download PDF

Info

Publication number
CN105955727A
CN105955727A CN201610261521.1A CN201610261521A CN105955727A CN 105955727 A CN105955727 A CN 105955727A CN 201610261521 A CN201610261521 A CN 201610261521A CN 105955727 A CN105955727 A CN 105955727A
Authority
CN
China
Prior art keywords
attribute
entity
description
current
address
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
CN201610261521.1A
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.)
GUANGDONG KAITONG SOFTWARE DEVELOPMENT Co Ltd
Original Assignee
GUANGDONG KAITONG SOFTWARE DEVELOPMENT 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 GUANGDONG KAITONG SOFTWARE DEVELOPMENT Co Ltd filed Critical GUANGDONG KAITONG SOFTWARE DEVELOPMENT Co Ltd
Priority to CN201610261521.1A priority Critical patent/CN105955727A/en
Publication of CN105955727A publication Critical patent/CN105955727A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System (AREA)

Abstract

The invention discloses a creation method and an access method for a universal memory entity. According to the creation method for the universal memory entity, the created universal memory entity is that entity description is separated from the entity, namely, the entity description and data of the entity are separately stored, only one entity description is stored, the data of the entity can be stored in a plurality of entities, and the entity description is associated with the entity through a pointer, so that the storage consumption of a memory is greatly reduced by the structure. In addition, the attribute length and sequence of the entity are fixed, an attribute address of an attribute is obtained directly through an offset of the attribute, and the attribute is directly subjected to reading/writing operation according to the attribute address of the attribute, so that the entity access efficiency is greatly improved.

Description

The creation method of a kind of universal memory entity and access method
Technical field
The present invention relates to field of software development, particularly relate to the establishment of a kind of universal memory entity Method and access method
Background technology
In software development, the data that entity is made up of a series of attributes.Such as there is a class Being " student ", this class has attribute " student number ", " sex ", " title " and " age ", Its simply description scheme the most in logic.When there being one piece of internal storage data in internal memory, its structure comprises The concrete numerical value of the attribute of " student " class, then this block internal storage data is exactly " student " class An entity.Wherein, " student " generic attribute is fixing, but in software development process, Many times the attribute of class cannot be previously obtained, and is just to determine in running, this time Need a method and realize dynamic class and its entity.Common method has text side Formula, KEY-VALUE and TLV mode, these modes have a respective shortcoming:
1, text mode read-write efficiency ratio is relatively low, reads to be required for resolving text every time and obtains attribute Value, amendment is required for reconfiguring text every time.
2, KEY-VALUE mode committed memory is the most, because realizing the tree of KEY-VALUE Structure takies extra internal memory.
3, TLV mode committed memory is the most, because each entity contains T and L, and Real preservation data are V.TLV mode random reading attributes efficiency comparison is low, wants every time Start to read by TLV structure from first, until finding the attribute needing to read.
Summary of the invention
An object of the present invention is to propose the creation method of a kind of universal memory entity, its energy Solve the problem that during entity storage in software development, memory consumption is the biggest.
The two of the purpose of the present invention are to propose the access method of a kind of universal memory entity, its energy Solve the problem of access entity attribute inefficiency in software development.
One of in order to achieve the above object, the technical solution adopted in the present invention is as follows:
The invention provides the creation method of a kind of universal memory entity, including creating entity description Step and create entity step, the step of described establishment entity description includes:
S101: initialize entity description;
S102: obtain first attribute to be added, preserves first attribute to be added to described In entity description;Wherein, attribute to be added includes attribute length and attribute excursion amount, first The attribute excursion amount of attribute to be added is zero;
S103: obtain next attribute to be added and be designated as current attribute to be added, will currently treat Adding attribute to preserve to described entity description, then proceeding to perform S103, until being needed Add attribute to preserve to described entity description;Wherein, during solid data size is entity description The attribute length sum of all properties preserved, the attribute excursion amount of current attribute to be added is Solid data size corresponding to current entity description;
The method of described establishment entity includes:
S201: according to the solid data size obtained from entity description and distributed by system The size of pointer to system application one memory block, the size of this memory block be solid data size with The size sum of pointer;
S202: described pointer is saved in the original position of described memory block;
S203: obtain first attribute from entity description, and be designated as current attribute, then obtain Take the attribute excursion amount of described current attribute and be calculated the attribute address of current attribute;
S204: according to the attribute address of described current attribute and get from system current Current attribute is carried out initializing structure and being stored in described interior by the attribute data that Attribute Relative is answered In counterfoil;
S205: obtain next attribute from entity description, and be designated as current attribute, then obtain Take the attribute excursion amount of this current attribute and be calculated the attribute address of current attribute, performing S204;Until all properties in entity description all being initialized structure be stored in described memory block In.
Preferably, described attribute to be added also includes Property Name;Will in described step S102 When first attribute to be added preserves to described entity description, it is judged that first attribute to be added Property Name be whether empty, when described Property Name be sky, then exit.
Preferably, described in described step S103, current attribute is preserved to described attribute array Time middle, it is judged that whether the Property Name of current attribute is empty or Property Name has existed In described entity description, when the entitled sky of attribute or Property Name have existed and described entity Time in description, then exit.
Preferably, pointer described in described S201 is for pointing to the address of described entity description. Preferably, described attribute address is the memory address of entity, attribute excursion amount and the size of pointer Three's sum.
Two in order to achieve the above object, the technical solution adopted in the present invention is as follows:
Present invention also offers the access method of a kind of universal memory entity, this access method is should For the creation method of described universal memory entity provided by the present invention created general in Deposit entity, including:
It is inclined that attribute to be visited according to entity gets the attribute of attribute to be visited in entity description Shifting amount;
The attribute excursion amount of block address memory, the size of pointer and attribute to be visited according to entity Obtain the attribute address of this attribute to be visited;
Treat access attribute by the attribute address of described attribute to be visited and be written and read operation.
There is advantages that the structure of entity in the entity that the present invention is created Describing the data with entity to be stored separately, the structure of entity describes and only initializes once, entity Data can preserve many parts according to actual situation, in the case of entity object is relatively more significantly Save internal memory.In the efficiency of access entity, owing to entity attributes size and order are fixing, The direct memory address being obtained attribute by the side-play amount of attribute, the then attribute of access entity, Substantially increase the efficiency of access entity.
Accompanying drawing explanation
Fig. 1 is the flow chart of steps creating entity description that the present invention provides an embodiment;
Fig. 2 is the flow chart of steps creating entity that the present invention provides an embodiment;
Fig. 3 is the flow chart that the present invention provides the access method of an embodiment.
Detailed description of the invention
Below, in conjunction with accompanying drawing and detailed description of the invention, the present invention is described further:
The invention provides the creation method of a kind of universal memory entity, entity refers to by a series of The data of attribute composition, the entity that the method is created is by entity description and entity separation, also Being i.e. the data that the attribute description in entity is concrete with entity to be stored separately, entity description is only Needing to initialize once, that is to say its only one of which, the data of entity can divide multiple entity to enter Row storage, and in physical memory block, preserve a pointer and this pointer is pointed to the ground of entity description Location, thus entity description is associated with the data of entity, so more at entity object In the case of, it is greatly saved the memory space of internal memory.Described creation method includes that creating entity retouches The step stated and the step of establishment entity, as it is shown in figure 1, the step of described establishment entity description Including:
S101: initialize entity description.
S102: obtain first attribute to be added, preserves first attribute to be added to described In entity description;Wherein, attribute to be added includes attribute length and attribute excursion amount, first The attribute excursion amount of attribute to be added is zero.
Wherein, Property Name, attribute length, genus are at least included for each attribute description Property type and attribute excursion amount, attribute excursion amount refer to Attribute Relative in the position of entity, therefore Also be not added with attribute in this entity description, then the attribute excursion amount of first attribute to be added is i.e. Zero.Described attribute type refers to the data type of the value of this attribute, such as a student's The value of attribute " name " is character string type.It addition, for the feature of attribute: attribute-name Can not be called empty and can not repeat, therefore add described first attribute to be added to this reality Time in body description, should first judge whether the Property Name of described first attribute to be added is empty, The most then illustrate that this entity attributes is illegal, then report an error or exit.
S103: obtain next attribute to be added and be designated as current attribute to be added, will currently treat Adding attribute to preserve to described entity description, then proceeding to perform S103, until being needed Add attribute to preserve to described entity description;Wherein, during solid data size is entity description Having preserved the attribute length sum of all properties, the attribute excursion amount of current attribute to be added is for working as Solid data size corresponding to front entity description.
Array or team can be passed through preferably for its preserving type of the attribute in entity description The form of row preserves.
Wherein, described solid data size is the attribute of all properties preserved in entity description Length sum.When getting an attribute A to be added, then the attribute of this attribute A to be added is inclined Shifting amount is to that is to say the solid data size corresponding to current entity description, and described here is current Entity description refers to that this current attribute to be added is not also saved in described entity description.Equally , if the Property Name of this attribute A to be added is empty, then reports an error or exit.It addition, Owing to the Property Name of attribute can not repeat, if the Property Name of attribute A to be added and entity Description has been added the Property Name of attribute identical time, then this attribute A can not be preserved to entity In description.
As in figure 2 it is shown, the step of described establishment entity includes:
S201: according to the solid data size obtained from entity description and distributed by system The size of pointer to system application one memory block, the size of this memory block be solid data size with The size sum of pointer.Wherein, solid data size refers to the genus of all properties in entity description Property length sum.Described pointer is automatically to be distributed by system, the size of different its pointers of machine Difference, is generally calculated automatically from by compiler, such as in the system of 32, pointer Size is 4 bytes, and in the system of 64, the size of pointer is 8 bytes.Work as needs When creating entity, from entity description, first get all of attribute, then according to attribute Attribute length draws solid data size, and the size further according to solid data size and pointer draws The size of entity committed memory, to internal memory application one memory block, the size of this memory block is entity The size of committed memory, that is to say the size sum of solid data size and pointer.
S202: described pointer is saved in the original position of described memory block.In this step, The original position of memory block preserves described pointer, and this pointer is for pointing to the interior of described entity description Deposit address, that is to say that entity description is associated by this pointer with entity.
S203: obtain first attribute from entity description, and be designated as current attribute, then obtain Take the attribute excursion amount of described current attribute and be calculated the attribute address of current attribute.
S204: according to described attribute address and the attribute data that gets from system to currently Attribute carries out initializing structure and being stored in described memory block;
S205: obtain next attribute from entity description, and be designated as current attribute, then obtain Take the attribute excursion amount of this current attribute and be calculated the attribute address of current attribute, performing S204, until initializing structure all properties in entity description to be stored in described memory block In.
Wherein, step S203 and S204 be the attribute preserved according to entity description successively and from The attribute data got in system initializes and constructs all of attribute.That is to say successively from reality One attribute of acquisition in body description, and obtain the attribute excursion amount of this attribute, then according to this genus The size of attribute excursion amount, the memory address of entity and the pointer of property calculates the genus of this attribute Property address, carry out initializing structure further according to the attribute address of this attribute and attribute data and obtain This attribute is also stored in described memory block.The memory address of described entity refers to that system is divided automatically The memory address of dispensing entity.When the attribute obtained from entity description is last, then All of attribute all construction completes are described, then exit.
Such as a class, then the entity description only one of which created, but for a class Object have a lot, when to preserve such object, it is only necessary to according to such entity description Its corresponding entity is set up for each object.Such as " student " class, entity description is only There is one, but " student " may have a lot of objects, as " little in " little quick " " Xiao Ming " Lee " etc., a corresponding entity can be created for each object, each object Entity be all to be associated by the entity description of a pointer with described class.For actual utilization In, if when the object of class is more, this universal memory entity can greatly reduce entity storage Time internal memory consumption.
As it is shown on figure 3, present invention also offers the access method of a kind of universal memory entity, should Method is that the universal memory being applied to be created such as the creation method of described universal memory entity is real Body, comprising:
S1: get the attribute of attribute to be visited in entity description according to the attribute to be visited of entity Side-play amount.Wherein, entity description is inquired about attribute to be visited, and obtains attribute to be visited Property Name, attribute length, attribute excursion amount and attribute type etc..
S2: big according to attribute excursion amount, the memory address of entity and the pointer of attribute to be visited The little attribute address drawing attribute to be visited.Calculate the attribute address of attribute to be visited, should Attribute address is the attribute excursion amount of attribute to be visited, the memory address of entity and the size of pointer Three's sum.Wherein, the memory address of entity gets from system.
S3: treat access attribute by the attribute address of attribute to be visited and be written and read operation.Root Treat access attribute according to attribute address obtained above and be written and read operation.
Such as, for entity class " student ", there is attribute " student number " " name " " age ", The attribute length of three attributes is 12,13,10, then add three attributes to entity successively In description, and show that the attribute excursion amount of three attributes is respectively 0,12,25, and this is real Volume data size is 35." student " should there is object entity " Xiao Li " " Xiao Ming " " little quick ".
Nowadays need to access " name " this attribute of " Xiao Li ", first retouch from entity In stating, the attribute excursion amount of " name " this attribute is (due to entity " Xiao Li " and " student " Entity description between by pointer association, be therefore easy to draw the entity description of this entity), Memory address and the size of pointer of this entity " Xiao Li " is may know that from system, interior by this The size depositing address, attribute excursion amount and pointer draws the attribute address of this attribute " name ", Then it is written and read operating to attribute " name " by this attribute address and attribute type. It addition, attribute description preserves when, not only preserve Property Name, attribute length and genus Property side-play amount, attribute type to be preserved.Obtaining attribute excursion amount when, obtain attribute Corresponding attribute type, so when carrying out data access, it is easy to knows the number of this attribute According to type, then attribute it is read out or writes.
Due to creating entity description and entity when, for entity attributes size and order It is all fixing, therefore can access entity attributes by the attribute excursion amount of this attribute, because of This this access method is greatly improved in terms of access efficiency.
It addition, based on this universal memory entity, present invention also offers a kind of based on universal memory The destroying method of entity, comprising:
First from the beginning of the first of entity attribute, in order attribute is processed, and obtain Taking the attribute address of each attribute, attribute address is the size of the memory address of entity, pointer And attribute excursion amount three's sum of attribute.
Then according to the attribute address of each attribute, it is carried out destructed, until all of genus Property is the most destructed to be completed.
Finally the memory block of entity is returned to system, complete the destruction of whole solid data.
This destroying method has only to the attribute address of each attribute according to entity to be destroyed Carry out destructed one by one, then the memory block of entity is returned to system, be not related to reality Body description and other entity, it is ensured that the safety of system.
For a person skilled in the art, can technical scheme as described above and structure Think, make other various corresponding changes and deformation, and all these changes and deformation Within all should belonging to the protection domain of the claims in the present invention.

Claims (6)

1. the creation method of a universal memory entity, it is characterised in that include that creating entity retouches The step stated and the step of establishment entity, the step of described establishment entity description includes:
S101: initialize entity description;
S102: obtain first attribute to be added, preserves first attribute to be added to described In entity description;Wherein, attribute to be added includes attribute length and attribute excursion amount, first The attribute excursion amount of attribute to be added is zero;
S103: obtain next attribute to be added and be designated as current attribute to be added, will currently treat Adding attribute to preserve to described entity description, then proceeding to perform S103, until being needed Add attribute to preserve to described entity description;Wherein, during solid data size is entity description The attribute length sum of all properties preserved, the attribute excursion amount of current attribute to be added is Solid data size corresponding to current entity description;
The method of described establishment entity includes:
S201: according to the solid data size obtained from entity description and distributed by system The size of pointer to system application one memory block, the size of this memory block be solid data size with The size sum of pointer;
S202: described pointer is saved in the original position of described memory block;
S203: obtain first attribute from entity description, and be designated as current attribute, then obtain Take the attribute excursion amount of described current attribute and be calculated the attribute address of current attribute;
S204: according to the attribute address of described current attribute and get from system current Current attribute is carried out initializing structure and being stored in described interior by the attribute data that Attribute Relative is answered In counterfoil;
S205: obtain next attribute from entity description, and be designated as current attribute, then obtain Take the attribute excursion amount of described current attribute and be calculated the attribute address of current attribute, performing S204;Until all properties in entity description all being initialized structure be stored in described memory block In.
2. the creation method of universal memory entity as claimed in claim 1, it is characterised in that institute State attribute to be added and also include Property Name;By first genus to be added in described step S102 Property preserve to time in described entity description, it is judged that whether the Property Name of first attribute to be added For sky, when described Property Name is empty, then exit.
3. the creation method of universal memory entity as claimed in claim 2, it is characterised in that institute State time in current attribute preservation to described attribute array described in step S103, it is judged that current Whether the Property Name of attribute is empty or the most described entity of Property Name is retouched In stating, when the entitled sky of attribute or Property Name existed with described entity description in time, then Exit.
4. the creation method of universal memory entity as claimed in claim 1, it is characterised in that institute State pointer described in S201 for pointing to the address of described entity description.
5. the creation method of universal memory entity as claimed in claim 1, it is characterised in that institute State the size that attribute address is the memory address of entity, attribute excursion amount and pointer three and.
6. an access method for universal memory entity, this access method is to be applied to right such as want Seek the universal memory entity that the creation method of the arbitrary described universal memory entity of 1-5 is created, its It is characterised by, including:
It is inclined that attribute to be visited according to entity gets the attribute of attribute to be visited in entity description Shifting amount;
The attribute excursion amount of block address memory, the size of pointer and attribute to be visited according to entity Obtain the attribute address of this attribute to be visited;
Treat access attribute by the attribute address of described attribute to be visited and be written and read operation.
CN201610261521.1A 2016-04-22 2016-04-22 Creation method and access method for universal memory entity Pending CN105955727A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610261521.1A CN105955727A (en) 2016-04-22 2016-04-22 Creation method and access method for universal memory entity

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610261521.1A CN105955727A (en) 2016-04-22 2016-04-22 Creation method and access method for universal memory entity

Publications (1)

Publication Number Publication Date
CN105955727A true CN105955727A (en) 2016-09-21

Family

ID=56916527

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610261521.1A Pending CN105955727A (en) 2016-04-22 2016-04-22 Creation method and access method for universal memory entity

Country Status (1)

Country Link
CN (1) CN105955727A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434938A (en) * 2021-06-29 2021-09-24 广联达科技股份有限公司 BIM (building information modeling) model checking method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1862542A (en) * 2006-06-09 2006-11-15 无锡永中科技有限公司 Method of shared object attribute
CN101046805A (en) * 2006-04-19 2007-10-03 华为技术有限公司 Physical attributes data process device and method
CN101126984A (en) * 2007-09-30 2008-02-20 北大方正集团有限公司 Object attribute description method
CN102053841A (en) * 2011-01-06 2011-05-11 国电南京自动化股份有限公司 Embedded active memory object database design method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046805A (en) * 2006-04-19 2007-10-03 华为技术有限公司 Physical attributes data process device and method
CN1862542A (en) * 2006-06-09 2006-11-15 无锡永中科技有限公司 Method of shared object attribute
CN101126984A (en) * 2007-09-30 2008-02-20 北大方正集团有限公司 Object attribute description method
CN102053841A (en) * 2011-01-06 2011-05-11 国电南京自动化股份有限公司 Embedded active memory object database design method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434938A (en) * 2021-06-29 2021-09-24 广联达科技股份有限公司 BIM (building information modeling) model checking method and device, computer equipment and storage medium
CN113434938B (en) * 2021-06-29 2024-02-13 广联达科技股份有限公司 BIM model checking method, BIM model checking device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN103034544A (en) Management method and device for user mode and kernel mode to share memory
CN104423982B (en) The processing method and processing equipment of request
CN108037967A (en) A kind of menu loading method and electronic equipment based on more parent-child structures
CN103226591B (en) A kind of support multiple key quick access method and device
CN104750727A (en) Column type memory storage and query device and column type memory storage and query method
CN106326499A (en) Data processing method and device
CN104424030A (en) Sharing memory multi-process operation method and device
CN106156070A (en) A kind of querying method, Piece file mergence method and relevant apparatus
CN105809389A (en) Method and apparatus for generating BOM trees
CN108241676A (en) Realize the method and apparatus that data synchronize
CN108733324A (en) A kind of data read-write method of solid state disk, device, equipment and storage medium
CN105159950A (en) Mass data real-time sorting and inquiring method and system
CN107451054A (en) A kind of memory pool adjustment method being used in linux environment
CN104881461A (en) Rapid data storage method
CN114117992B (en) Serialization and deserialization method and device and electronic equipment
CN102880620B (en) Method for creating spreadsheet
US20100281082A1 (en) Subordinate Multiobjects
CN105955727A (en) Creation method and access method for universal memory entity
CN106503186A (en) A kind of data managing method, client and system
CN103294714B (en) The defining method of the memory location of the field attribute value of index field and device
CN103761316A (en) Data compression storage method and device based on sparse matrix
CN110018457B (en) Method for designing satellite-borne SAR echo data frame header identifier detection functional module
CN105095478A (en) Method and device for obtaining establishing time of file in distributed file system
CN109697234A (en) More attribute information storages, querying method, device, server and the medium of entity
CN112035380B (en) Data processing method, device and equipment and readable storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 1001 room 1101, room 12, 510000, Third Street, Luogang District Development Zone, Guangzhou, Guangdong

Applicant after: Guangdong Kaitong Polytron Technologies Inc

Address before: 901, 510000, 1001 and 1101 rooms, No. 12, 3rd Street, Luogang District Development Zone, Guangzhou, Guangdong, China

Applicant before: Guangdong Kaitong Software Development Co., Ltd.

COR Change of bibliographic data
CB02 Change of applicant information

Address after: 510000 Room 1001, Room 1101, Room 901, 12 Kehui Sanjie, Luogang District Development Zone, Guangzhou City, Guangdong Province

Applicant after: Kaitong Technology Co., Ltd.

Address before: 510000 Room 1001, Room 1101, No. 12, Kehui Third Street, Luogang District Development Zone, Guangzhou City, Guangdong Province

Applicant before: Guangdong Kaitong Polytron Technologies Inc

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20160921

RJ01 Rejection of invention patent application after publication