CN112035572B - Static method, device, computer equipment and storage medium for creating form instance - Google Patents
Static method, device, computer equipment and storage medium for creating form instance Download PDFInfo
- Publication number
- CN112035572B CN112035572B CN202010855568.7A CN202010855568A CN112035572B CN 112035572 B CN112035572 B CN 112035572B CN 202010855568 A CN202010855568 A CN 202010855568A CN 112035572 B CN112035572 B CN 112035572B
- Authority
- CN
- China
- Prior art keywords
- instance
- data
- redis
- creating
- class
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 97
- 230000003068 static effect Effects 0.000 title claims abstract description 50
- 230000008859 change Effects 0.000 claims description 47
- 230000008569 process Effects 0.000 claims description 22
- 238000001514 detection method Methods 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 7
- 230000006870 function Effects 0.000 description 30
- QOSSAOTZNIDXMA-UHFFFAOYSA-N Dicylcohexylcarbodiimide Chemical compound C1CCCCC1N=C=NC1CCCCC1 QOSSAOTZNIDXMA-UHFFFAOYSA-N 0.000 description 27
- 238000012545 processing Methods 0.000 description 20
- 230000004044 response Effects 0.000 description 15
- 230000001360 synchronised effect Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 11
- 238000013507 mapping Methods 0.000 description 8
- 230000007246 mechanism Effects 0.000 description 6
- 239000008186 active pharmaceutical agent Substances 0.000 description 5
- 238000006243 chemical reaction Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 239000002131 composite material Substances 0.000 description 4
- 230000003993 interaction Effects 0.000 description 4
- 238000004458 analytical method Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 238000011068 loading method Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000007792 addition Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000010276 construction Methods 0.000 description 2
- 230000008878 coupling Effects 0.000 description 2
- 238000010168 coupling process Methods 0.000 description 2
- 238000005859 coupling reaction Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000005538 encapsulation Methods 0.000 description 2
- 238000003780 insertion Methods 0.000 description 2
- 230000037431 insertion Effects 0.000 description 2
- 238000012544 monitoring process Methods 0.000 description 2
- 230000010076 replication Effects 0.000 description 2
- 102100039371 ER lumen protein-retaining receptor 1 Human genes 0.000 description 1
- 101000812437 Homo sapiens ER lumen protein-retaining receptor 1 Proteins 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013523 data management Methods 0.000 description 1
- 238000013499 data model Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000007667 floating Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000000047 product Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 239000013589 supplement Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2379—Updates performed during online database operations; commit processing
- G06F16/2386—Bulk updating operations
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a static method, a device, computer equipment and a storage medium for creating a table instance, wherein the method comprises the steps of dynamically constructing the table instance on a heap, and storing an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests; establishing a data connection between the form instance and the REDIS database, and enabling the form instance to transmit information from the REDIS database to a user; creating a subscription sub-object for establishing data connection between the form instance and the REDIS database, enabling the subscription sub-object to establish connection with the REDIS database, and acquiring all messages on a data channel named by form names by utilizing the subscription sub-object; and acquiring the address of the table instance by using the intelligent pointer, and completing the creation of the table instance. Through the return value of the method, two scenes of success and failure of creation can be accurately identified, and the table instance is used through the intelligent pointer more safely and conveniently.
Description
Technical Field
The present invention relates to the field of memory database caching technologies, and in particular, to a static method, an apparatus, a computer device, and a storage medium for creating a table instance.
Background
With the rapid development of internet technology, the distributed architecture system is continuously perfected, and higher requirements are put on the response speed of software and the overall performance of the system by users. The cache mechanism is adopted to solve the problems of high concurrent requests and hot spot data storage, and becomes a popular preferred scheme. The caching mechanism stores data in the memory by utilizing the high-speed read-write characteristic of the memory so as to improve the data access speed and reduce the performance loss of the system in the data read-write part.
Redis (Remote Dictionary Server) is a non-relational memory database which uses Key-Value as a data model, is free of source and supports high-performance concurrent reading and writing, can support various data storage structures such as character strings, lists, sets, ordered sets and hash tables, provides a publishing and subscribing message communication mode, and has strong data management capability widely applied to the scenes such as cache, data publishing and subscribing. REDIS hash types are mapping tables of fields and value fields of a string type, whose (key-field-value) structure is similar to that of an object (identifier-attribute name-attribute value), and can be used to store objects that are structurally simple and have no complex relationship query.
REDIS has the advantages of distributed storage of key values, no coupling between data, strong expandability, high searching speed and the like, but the stored data is unstructured and has no coupling, and the data is only of a binary type, so that the REDIS has a very obvious disadvantage. When a developer uses a language associated with a strong type such as C/c++, it is necessary to handle conversion between a programming language associated data type such as integer, floating point, boolean, etc. and REDIS data type, and it is not easy to understand the relevance and cohesiveness of service data. Meanwhile, redis provides a plurality of client commands for performing operations such as adding, deleting, checking and the like on the REDIS server, and provides client APIs of multiple programming languages so as to complete interaction with the Redis database in the software development process. Hirdis is a lightweight C language client function library accessing the Redis database, and basically realizes minimum support for the Redis protocol. The Hiredis comprises a synchronous API and an asynchronous API, and the use method of the native interface is flexible. The asynchronous API needs to work with a third party asynchronous event library. For example, libevent is an open source, lightweight, cross-platform, high performance event notification library written in C language, supporting event driven and multiple I/O multiplexing techniques, and is widely used as a bottom layer network library.
In summary, a great deal of time and effort are required for the software developer to learn the REDIS command and the application method of the client API before using the REDIS, so that the time and labor costs are high, the overall progress of software development is affected to a certain extent, and the complexity of the later maintenance of the software is increased.
Based on the above reasons, the applicant provides an automatic table data synchronization method, but in the flow of the table synchronization method, two scenes of success and failure of creation cannot be accurately identified when the table instance is created, and the address of the table instance is not easy to obtain, so that inconvenience is brought to the use of a user.
The information disclosed in this background section is only for enhancement of understanding of the general background of the invention and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person skilled in the art.
For the above reasons, the applicant proposes a static method, apparatus, computer device, storage medium for creating a table instance.
Disclosure of Invention
In order to meet the above requirements, a first object of the present invention is to provide a static method of creating a table instance.
A second object of the present invention is to provide a static apparatus for creating a table instance.
A third object of the present invention is to provide a computer device.
A fourth object of the present invention is to provide a non-transitory computer readable storage medium.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
in one aspect, an embodiment of the present application provides a static method for creating a table instance, including the following steps:
dynamically constructing a table instance on a heap, and storing an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests;
establishing a data connection between the form instance and the REDIS database, and enabling the form instance to transmit information from the REDIS database to a user;
creating a subscription sub-object for establishing data connection between the form instance and the REDIS database, enabling the subscription sub-object to establish connection with the REDIS database, and acquiring all messages on a data channel named by the form name by utilizing the subscription sub-object;
and acquiring the address of the table instance by using the intelligent pointer, and completing the creation of the table instance.
In one possible implementation, the step of initializing the table instance with internal data includes initializing a row set, a column set, a REDIS client instance, and a subscription instance within the table instance.
In one possible implementation, the step of initializing the row set, the column set, the REDIS client instance, and the subscription instance inside the table instance includes dynamically creating a null data row set class instance to initialize the row set, and dynamically creating a null data column set class instance to initialize the column set.
In one possible implementation manner, the step of establishing a connection between the subscription sub-object and the REDIS database includes establishing an asynchronous connection relationship between the subscription sub-object and the REDIS server.
In one possible implementation, the step of using the subscription sub-object to obtain all messages on the data channel named by the table name includes causing the table instance to execute a REDIS subscription command and initiate an asynchronous event processing thread for perceiving changes to the table data.
In one possible embodiment, before the step of dynamically building the table instance on the heap, creating a table object in the process memory, and setting a data change detection mode for the table.
In one possible implementation manner, the acquiring all the messages on the data channel named by the table name by using the subscription sub-object further includes triggering the data change detection mode according to the acquired data change message on the data channel named by the table name, and sending a data change notification to a table user.
In one possible implementation, the table instance makes data changes from the data obtained from the REDIS database.
In another aspect, an embodiment of the present application further provides a static apparatus for creating a table instance, including:
a table instance creation unit, configured to dynamically construct a table instance on a heap, and store an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests;
a connection establishing unit, configured to establish a data connection between the table instance and the REDIS database, so that the table instance realizes transmitting information from the REDIS database to a user;
a message subscription acquisition unit, configured to create a subscription sub-object for establishing data connection between the table instance and the REDIS database, so that the subscription sub-object establishes connection with the REDIS database, and acquire all messages on a data channel named by a table name by using the subscription sub-object;
and the address acquisition unit is used for acquiring the address of the table instance by using the intelligent pointer and completing the creation of the table instance.
In a third aspect, an embodiment of the present application further proposes a computer device, including a memory, a processor, and a static program for creating a table instance stored on the memory and executable on the processor, where the static program for creating a table instance implements the static method for creating a table instance as described in any one of the above when executed by the processor.
In a fourth aspect, embodiments of the present application provide a non-transitory computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a static method of creating a table instance as described in any of the above.
Compared with the prior art, the invention has the beneficial effects that: according to the static method for creating the table instance, a series of synchronous and asynchronous initialization operations are packaged in the table instance when the table is created, so that complexity of a software developer for accessing the REDIS database can be reduced, a user does not need to know a detailed REDIS command, and interaction with the REDIS database can be completed according to a method similar to a conventional two-dimensional table. Through the return value of the method provided by the embodiment of the application, the caller can accurately identify two scenes of successful creation and failed creation. Moreover, the caller uses the form instance through the intelligent pointer more safely and conveniently.
The invention is further described below with reference to the drawings and specific embodiments.
Drawings
FIG. 1 is a flow chart of a static method for creating a table instance according to an embodiment of the present application;
FIG. 2 is a block diagram of a two-dimensional table of a specific application scenario of a static method for creating a table instance according to an embodiment of the present application;
FIG. 3 is a schematic diagram of attributes and methods defined by the cell class of the table of FIG. 2;
FIG. 4 is a schematic diagram of attributes and methods defined by the cell set class of the table of FIG. 2;
FIG. 5 is a schematic diagram of attributes and methods defined by the data row class of the table of FIG. 2;
FIG. 6 is a schematic diagram of attributes and methods defined by the data line set class of the table of FIG. 2;
FIG. 7 is a schematic diagram of attributes and methods of class definition of the table of FIG. 2;
FIG. 8 is a schematic block diagram of a static apparatus for creating a form instance provided by an embodiment of the present application;
fig. 9 is a schematic block diagram of a computer device provided in an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flow chart of a specific embodiment of a static method for creating a table instance according to an embodiment of the present application, which includes the following steps:
step S101, dynamically constructing a table instance on a heap, and storing an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests;
specifically, in this embodiment, to complete the initialization of the table instance, the row set, column set, REDIS client instance, and subscription instance inside the table instance need to be initialized. Essentially comprising dynamically creating an empty data row set class instance to initialize the row set, and dynamically creating an empty data column set class instance to initialize the column set.
The intelligent pointer is used for conveniently managing the dynamic memory and avoiding memory leakage. Storage in a sequential container may facilitate indexing cells with subscripts; the storage in the association container can establish a mapping relation between the column names and the cells, so that the cells can be conveniently searched according to the column names.
The set table attribute and the table operation request can be an operation class and an interface for setting a table row and a table column, and when the data of the table is required to be changed, related call can be made.
Step S102, establishing data connection between the form instance and REDIS database, and enabling the form instance to transmit information from the REDIS database to a user;
step S103, creating a subscription sub-object for establishing data connection between the form instance and the REDIS database, so that the subscription sub-object is connected with the REDIS database, and acquiring all messages on a data channel named by the form name by using the subscription sub-object;
specifically, in order to timely sense the change of the table data, after the table instance is created, a subscription sub-object needs to be initialized, so that the asynchronous connection between the subscription sub-object and the REDIS server is ensured to be established normally, simultaneously, the REDIS SUBSCRIBE command is successfully executed, an asynchronous event processing thread is started normally, and all messages on a channel named by the table name are subscribed.
Step S104, the intelligent pointer is utilized to acquire the address of the table instance, and the creation of the table instance is completed.
Specifically, in some embodiments, after the table object is created successfully and all initializations are completed, the static method returns the table instance address to the user. The user can obtain the address of the form instance, namely a variable, and can call the form instance through the variable and the input parameters.
In some embodiments, the user enters parameters such as REDIS server IP, port, password, form name, database index, and subscription flag into the interface that invokes the static method of creating form instances of embodiments of the present application. The REDIS server IP is an IP address for deploying REDIS service, the port is a REDIS service monitoring port, and the password is an authentication password when the REDIS client is connected with the REDIS server. The subscription flag indicates whether to turn on the subscription form data change function, and is turned on when the value is true, and turned off when the value is false. If the caller does not transmit the database index and the subscription flag parameter to the interface, the interface uses a default value, wherein the database index default value is 0, namely, default table data is stored in a No. 0 database of the REDIS server; the subscription flag default value is true, i.e., the form instance defaults to turn on the subscription data change function.
In some embodiments, to complete the real-time update of the table data and to timely notify of the change of the usage table data, the following steps are further included:
creating a table object in a process memory, and setting a data change detection mode for the table; in the step of creating a table object in the process memory, a table class for operating a table is also required to be created, where the table class provides a common operation interface: setting a list name of a table, setting an index field, loading all data of the table from a REDIS server-side appointed database, obtaining the number of rows and the number of columns of the table, judging the existence of the data table with a certain name in the REDIS database, adding a plurality of rows in batches, modifying a plurality of rows in batches, deleting a plurality of rows in batches, adding a plurality of columns in batches, deleting a plurality of columns in batches, querying a port of the row, registering a data change notification callback and the like. The table class of the table object provided by the embodiment can reduce the complexity of accessing the REDIS database by a software developer, and a user can complete interaction with the REDIS database according to a using method similar to that of a traditional two-dimensional table without knowing a detailed REDIS command. The automatic synchronization of data within a form object ensures consistency of data in a plurality of software cells. The optional registration notification callback is convenient for users to timely perceive data change and self-define processing logic for the change information.
Creating a data subscription request for requesting form data from a REDIS client, and sending the data subscription request to the REDIS client, wherein the REDIS client obtains relay data which needs to be updated to the form from a REDIS database; specifically, if the REDIS client needs to return data, the step of obtaining, by the REDIS client, relay data that needs to be updated to a table from a REDIS database includes that the REDIS client sends a data request to a REDIS server, and the REDIS server returns corresponding data to the REDIS client. I.e. the REDIS server needs to interact with REDIS client data.
Updating the table data by using the table object according to the relay data; specifically, the relay data is data processed by the REDIS client and the REDIS server, and the relay data can be transferred to the table after corresponding processing is needed to prevent data confusion.
And sending a data change notification to a table user according to the detection result of the data change detection mode. Because the step of setting the data change detection mode for the form can detect whether the form data change occurs in real time, when the form data change occurs, a form user can be immediately notified, and the use is convenient for the user.
In this embodiment, parameters such as an address, a port, an authentication password, a database index, a subscription flag, a data table name and the like of the incoming REDIS server may create a table object, through which REDIS server data may be read and written. If the table is used to temporarily load REDIS data scenes, the subscription flag may be set to false, closing the subscription function. If the subscription function is started during the creation of the table object, a SUBSCRIBE command of REDIS is executed, an asynchronous event processing thread is started to monitor a channel named by the name of the table, all changes of the table data with the same name are received in the lifetime, and the changes are automatically updated into the memory of the object.
The following describes a specific implementation procedure of an embodiment of the present invention with a specific example:
referring to fig. 2-7, fig. 2 is a block diagram of a two-dimensional table in a specific application scenario according to an embodiment of the present application, fig. 3 is an attribute and a method defined by a cell class of the table of fig. 2 in this example, fig. 4 is an attribute and a method defined by a cell set class of the table of fig. 2 in this example, fig. 5 is an attribute and a method defined by a data line class of the table of fig. 2 in this example, fig. 6 is an attribute and a method defined by a data line set class of the table of fig. 2 in this example, and fig. 7 is an attribute defined by a two-dimensional table class in this example and a method according to this embodiment.
The purpose of the embodiment is to realize a thread-safe distributed virtual two-dimensional table based on REDIS, namely, the specific application scene of the static method for creating the table instance provided by the embodiment of the application aims to package a series of synchronous and asynchronous initialization operations when the table is created by using the method, and a caller can accurately identify two scenes of successful creation and failure by returning a value through the method. The caller uses the form instance through the intelligent pointer more safely and conveniently.
The cells and rows provided in this example describe a two-dimensional tabular model, organizing data in rows and columns, and are logically more convenient for users to understand. The form is internally provided with a plurality of interfaces for users to use by realizing the integral function in cooperation with a plurality of classes. The functions provided by the table include creating the table, designing the table fields and indexes, adding in batches, modifying, deleting, querying row data, obtaining the number of rows and columns of the table, emptying the table, registering change notification callbacks, and the like.
In order to realize the table function, the technical scheme adopted by the embodiment comprises three modules, namely table definition, asynchronous subscription and REDIS operation. The table definition module comprises a cell class, a cell set class, a data row set class and a two-dimensional table class definition. The asynchronous subscription module uses Hiredis and Libevent open source software to connect REDIS server end in an asynchronous mode, executes SUBSCRIBE command to SUBSCRIBE channel data named by table names, starts event threads to asynchronously receive subscription response data, and timely informs outer users. The REDIS operation module comprises REDIS command class, synchronous client class and response analysis class definition, wherein the command class stores all parameters of one REDIS command; the response analysis class is responsible for completing the conversion from REDIS server side response to self-defined response structure; the synchronous client class uses Hiredis to connect with REDIS server in synchronous mode, execute multiple commands in pipeline mode, and return REDIS response parameters.
In this example, a static implementation is provided for creating a table instance, where the scheme designs the relevant classes in the c++ language and encapsulates a series of interfaces that are available for external use.
The scheme also comprises design and encapsulation of REDIS command class, REDIS synchronous client class, REDIS response analysis class, REDIS asynchronous subscription class, cell collection class, data row class, row collection class, table class and the like.
The REDIS server is deployed as a master-slave environment in a single-machine mode, and REDIS synchronous client class encapsulates an interface for interaction between a synchronous mode and the REDIS server. The REDIS asynchronous subscription class realizes the connection of the REDIS server in an asynchronous mode, takes the name of the table as a channel name, executes the change notification of the REDIS subscription command subscription table, and notifies the table update data after receiving the change message.
Each row record of the created table may be mapped to a key value pair in the REDIS database whose value type is a hash table. The mapping relationship is explained as follows: assuming that a table instance dt_person storing personal information is named Person, three columns of Name, age, city are defined in the table, and information of two persons a and B, i.e., { a,10, sie }, { B,18, guangzhou }, are stored, the two information will be stored in the hash table of the REDIS database through the REDIS HMSET command. The command corresponding to the user A is: HMSET Person 1Name A Age 10City Western An. Wherein the number 1 in the key Person 1 represents the row number of the record in the Person table. The mapping mode of the user B is the same as that of the user A.
The invention will be described in detail below with reference to the drawings and the detailed description.
REDIS command class is named REDIS Command, which stores all elements of a REDIS command in a dynamic string array, including command name, key name, and parameters thereof. Redis command uses template function technology to realize the function of converting non-character string types such as numerical value, boolean, etc. into character string types, defines dynamically adding parameters into REDIS command through reload < < and () > operators, and returns the interface of new Redis command instance, through which user can dynamically splice REDIS command parameters in an additional mode.
The REDIS synchronous client class is named as REDISHA, the REDIS server is connected in a synchronous mode, a series of REDIS commands are executed on the REDIS server in a pipeline mode, and the execution result returned by the REDIS server is analyzed.
REDIS response parsing class is responsible for uniformly converting response messages (redisReply) returned by Hiredis open source software into a self-defined response structure. The custom response structure is named Redis Reply and comprises a dynamic array of data types, integer values, string values and Redis Reply types. The data types correspond to 6 return types of character strings, arrays, integer, null, state and failure defined by REDIS protocol. When the response data type is integer, storing the value in an integer value attribute of the Redis reply class; when the response data type is character string, state or failure, storing the value in the character string value attribute of the Redis reply class; when the response data type is an array, the value is stored in the dynamic array attribute of the Redis Reply class, and the value of the array element Redis Reply type is stored according to the rule.
REDIS asynchronous subscription class is named Redis Subscriber, and defined core data members include a Libevent event object, a Hidis asynchronous object, an initialization notification callback, and a message notification callback. The subscription class initialization process needs to be completed as follows: firstly, a REDIS server is connected in an asynchronous mode to acquire a Hiredis asynchronous object, connection and disconnection callbacks are set, a Libevent event object instance is created and bound to the asynchronous object, and REDIS asynchronous callback is associated with an event; secondly, the user needs to register an initialization notification callback and a message notification callback to the subscription class; thirdly, starting independent thread to start event distribution processing; fourthly, the table name is taken as a channel name, the REDIS SUBSCRIBE command SUBSCRIBEs to the change notification of the table, and the command feedback callback is registered. And the command feedback callback is used for differentially processing the SUBSCRIBE command execution result and the subscription message. And after receiving the subscription information, calling the change callback registered by the outer layer user to notify the outer layer of the change data.
The cell class is named Datacell, abbreviated as DC in this document. The cells are basic data units in a two-dimensional table, and have attributes such as cell names (string types), stored values (string types), change flags (boolean types), and tables where the cells are located (weak_ptr types).
The interfaces provided by the cell classes are shown in table 1.
Table 1 cell class interface table
The DCI_3 is a DC class assignment operator reload interface, and the interface resets the internal data of the current object according to the parametering object. For a unique pointer data member within a DC class, i.e., the table to which it belongs, the assignment operation simply resets its value.
DCI_4 is a DC class copy construction function, and the interface directly calls the DCI_3 interface to realize the function.
DCI_8 is an interface for acquiring cell values of the DC class, and the interface uses a function template of C++ language and a reloading technology to realize the conversion of character string values stored in cells into various basic data types, so that a user can acquire values according to actual required types.
DCI_9 is an interface for setting cell values of a DC class, and the interface uses function templates, reloads and character streaming technologies to uniformly convert a plurality of different input parameter types into character string types for storage in order to support a plurality of C++ language basic data types input by a user.
Dci_14 is a comparison function interface of a cell class encapsulation, the function defining two arguments, argument 1 being a string type, for storing relational operators such as: ">", "> =", "<", "<=", |! = "," like "," betwen "," in "; the argument 2 is a string array type for storing relational operator parameters. The method calls a relationship operator interface of the internal reload of the DC class, and compares the relationship between the stored values in the two cells.
The cell collection class is named Datacell collection, abbreviated as DCC in this document. A set of cells consisting of a plurality of cells, the set being logically equivalent to a row or a column; the order and association container used within the DCC class stores a plurality of cell addresses (shared_ptr < DataCell >). The intelligent pointer is used for conveniently managing the dynamic memory and avoiding memory leakage. Storage in a sequential container may facilitate indexing cells with subscripts; the storage in the association container can establish a mapping relation between the column names and the cells, so that the cells can be conveniently searched according to the column names.
The interfaces provided by the cell collection class are shown in table 2.
Table 2 cell set class interface table
The DCCI_3 is a heavy load interface of a DCC class assignment operator, the DCCI_4 is a copy construction function interface of the DCC class, the two interfaces define a copy control mechanism of the DC class, and the class object copy process is required to construct completely independent copies, namely, a deep copy mode is required to be adopted for cell object pointers stored in the class.
Dcci_7 is an interface defined by DCC class that obtains its location index from the cell name. The position index of a cell within a collection is defined as the subscript of the cell object in the sequential container.
The dcci_8 interface detects whether a named cell exists within the set of cells.
Dcci_9 is the first add operation interface defined by DCC class, which mainly implements the function of inserting a specified cell at a specified location of a current object. The default parameter identification is only incremented on the current row. Assuming that the user invokes the dcci_9 interface through the DCC class object C, a DC object address a and an insertion position P are input, and the detailed processing procedure of the dcci_9 interface is as follows:
step 1, judging whether the table of the cell object A to be inserted is the same as the table of the set C to be inserted. If the same, a is considered to be already in C, and the process ends.
And 2, judging whether the insertion position P is out of range. If the boundary is exceeded, the process is terminated.
And 3, assigning the table address of the table associated with the C object to the A object. And acquiring the shared_ptr intelligent pointer of the C object. The dcci_10 interface is invoked.
And step 4, judging whether the C object is associated with the data table. If not, the process is terminated.
And 5, judging whether the data in the C object association data table exists or not. If not, the process is terminated.
And 6, inserting the reference cell object A in the appointed positions of all rows of the C object association table.
Dcci_10 is a second type of add operation interface defined by DCC class, which mainly implements a function of inserting a specified cell at a specified location of a specified cell collection object. The default parameter entering unit lattice, the inserting position and the parameter of the parameter entering unit lattice set of the interface are legal, and the parameter entering unit lattice object is added into the parameter entering unit lattice set by directly calling the insert method of the sequence container and the associated container.
Dcci_11 is a third add operation interface defined by DCC class, which appends cells to the set, i.e., inserts at the end position.
Dcci_12 is a fourth add operation interface defined by DCC class, and a designated name cell is added to the set, and the interface firstly constructs a cell object according to the name of the participating cell, and then invokes dcci_11 interface;
dcci_13 is the first delete operation interface defined by the DCC class that deletes a cell of a specified name in the collection. For example: the user calls the DCCI_13 interface through the DCC class object C, a cell name N is transmitted, the DCCI_13 interface firstly acquires a cell index from the container according to the cell name N, and then calls the DCCI_14 interface;
DCCI 14 is a second delete operation interface defined by DCC class that deletes cells in a set that specify an index. For example: the user calls the DCCI-14 interface through the DCC object C, a cell position index P is transmitted, the DCCI-14 interface judges whether the parameter entering index P is out of range, if so, the processing is terminated; the cell object pointer ObjPtr is obtained from the sequence container according to the index P. And searching the cell object name pointed by the ObjPtr in the association container, and if no corresponding element is found in the association container, deleting the designated index element from the sequence container. If found in the association container, it is also deleted from the association container. If the C object has associated a table, each row of the associated table invokes the DCCI_15 interface.
DCCI 15 is an internal delete operation interface defined by DCC class that deletes cells of a specified index in a specified set.
Dcci_16 is a third delete operation interface defined by DCC class that deletes a cell object in the current set that is named with the entry reference. For example: the user calls the DCCI_16 interface through the DCC class object C, a cell object Obj is transmitted in, the DCCI_16 interface obtains a cell name N through the cell object Obj, and then calls the DCCI_13 interface;
DCCI 17 is a copy interface of DCC class definitions that enables copying of the cell from which the current set designation index begins into the reference designated set. The user calls the DCCI_17 interface through the DCC class object C, and transmits a starting position S and a cell set M, and the DCCI_17 interface firstly checks whether the starting position S is legal in the object C; if not, the process is terminated. Object M loops to call dcci_9 interface to append cell object copies in the C set sequentially at the end.
Dcci_18 is an interface provided by the DCC class to obtain a copy of a cell object based on a cell name.
DCCI 19 is an interface provided by DCC class to obtain a copy of a cell object from a cell index.
The data line class is named DataRow, abbreviated DR in this document. The data line class describes the attributes and methods that a single line should possess. A single row should have at least one set of cells and two attributes of the table.
The interfaces provided by the row classes are shown in table 3.
Table 3 data line class interface table
DRI_2 is a DR class assignment operator reload interface, DRI_3 is a DR class copy constructor interface, the two interfaces define a replication control mechanism of the DR class, and the class object replication process is required to construct completely independent replicas, namely, cell object pointers stored in the class must adopt a deep copy mode.
DRI_5 is the first search cell interface provided by the DR class, which is searched from within the row according to the cell name, and the interface internally calls the DCCI_18 interface of the cell collection class directly.
DRI_6 is a second type of search cell interface provided by the DR class, which is searched from within the row based on cell location, with the interface internal directly invoking the DCCI_19 interface of the cell collection class.
DRI_7 is the interface provided by the DR class to acquire the in-row cell collection object.
DRI_8 is an interface for the DR class to obtain a row number, and each row object in the table has a unique row number in the table, i.e., the row number is equivalent to the table primary key.
DRI_9 is the interface for DR class setup row object identification.
DRI_10 is the interface for DR class to obtain the line primary key value, the primary key of the line object is "Table name: line number".
DRI_11 is the interface provided by the DR class to obtain all field names in the row.
DRI_12 is an interface provided by the DR class to obtain all field names and values in the row, and F1-V1-F2-V2 … are sequentially stored in the returned dynamic array.
The data line collection class is named DataRowCollection, abbreviated DRC in this document. DRC class describes the properties and methods that a plurality of rows should possess. The row set class has a plurality of rows of element sets and a table attribute; a plurality of line object pointers (shared_ptr < DR >) are managed through a doubly linked list container, a line set index table is managed through a secondary hash table, a primary hash table uses column names as keys, a value field is also a hash table, and the secondary hash table uses column unit lattice object storage values as keys, and the value field is a line object pointer.
The interfaces provided by the line set class are shown in table 4.
Table 4 data line set class interface table
/>
The row set class needs to support setting a plurality of index fields simultaneously, and in order to realize the function, the index table adopts a two-stage hash table structure, the primary hash table takes a column name as a key, and the secondary hash table as a value. The secondary hash table uses column values as keys and row class examples to which the column values belong as values. DRCI_7 is an interface for setting an index of the DRC class, and when the index is set by the line set class, if the number of lines of the table to which the DRCI_7 belongs is 0, only the mapping relation between the column names and the empty secondary hash table is required to be added into the primary hash table. If the table row is not 0, a secondary hash table is also constructed according to each row of data in the table.
Drci_9 is an interface provided by the DRC class to add a single row. And adding a new row in the row set, and if the table is provided with an index, synchronously updating the index table. The specific treatment process comprises the following steps: traversing an index table, and acquiring a cell object corresponding to an index column name from the row object to be added; acquiring a storage value from the cell object, and searching whether the storage value exists in an index list value corresponding to the current list name; if the new line exists, namely the index field value conflicts, the new line addition fails. If the new column value does not exist, the corresponding relation between the new column value and the new row is inserted into the index table corresponding to the current column name. And finally, inserting a new row into the row set container.
Drci_10 is the first interface provided by the DRC class to delete a single line. When deleting a row object from the row set, if the table has an index set, the index table also needs to be updated. The specific treatment process comprises the following steps: checking whether an index column exists in the row object to be deleted; if the mapping relation exists, deleting the mapping relation between the corresponding column value and the row object from the index table; if not, searching the appointed row object from the row set container and deleting the appointed row object;
the drci_11 is a row interface provided by the row set class that deletes rows according to index field names and values.
DRCI_12 is a row set class that provides a way to retrieve rows according to location. The detailed processing process is as follows: checking whether the index of the incoming position crosses the boundary, if so, terminating the processing; otherwise, the incoming position index is corresponding to the relative position of the row object in the row set list, and the row object at the specified position is returned.
The drci_13 is an interface provided by the row set class to acquire row objects from row identifications.
The drci_14 is an interface provided by the row set class to obtain row objects from index field names and values.
DRCI_15 is an interface for updating row data provided by the row-set class.
DRCI_16 is an interface provided by the row set class to find rows that meet a user specified set of conditions.
Drci_17 is an interface for row-by-row traversal provided by the row-set class.
DRCI_18 is a row presence interface provided by the row set class that determines the presence of a row based on the row identification.
The table class describes a two-dimensional table model comprising rows and columns for temporarily storing virtual table data in memory, where the rows and columns are each defined as a set of cells. A two-dimensional table is made up of multiple rows and columns. The rows are represented by a row set, which contains a plurality of row instances, each row instance contains a cell set instance, one cell set instance contains a plurality of cell instances, and each cell instance stores a valid name and value. The columns are represented by a set of cells, the set of column cells containing a plurality of cell instances, each cell instance having a valid name and not storing a meaningful value. The table also has attributes such as name, number, subscription sub-object, and REDIS client terminal object.
The table class is named DataTable, abbreviated as DT in this document, and can be created and used independently. The interfaces provided by the table classes are shown in table 5.
Table 5 table class interface table
/>
/>
Dti_3 shown in the table is a static method for creating a table instance provided by the DT class, and is also a specific implementation of the static method for creating a table instance in the embodiment of the present application, and the internal processing flow of the method is shown on the right side of fig. 7. The user transmits parameters such as REDIS server IP, port, password, form name, database index and subscription flag to the interface. The REDIS server IP is an IP address for deploying REDIS service, the port is a REDIS service monitoring port, and the password is an authentication password when the REDIS client is connected with the REDIS server. The subscription flag indicates whether to turn on the subscription form data change function, and is turned on when the value is true, and turned off when the value is false. If the caller does not transmit the database index and the subscription flag parameter to the interface, the interface uses a default value, wherein the database index default value is 0, namely, default table data is stored in a No. 0 database of the REDIS server; the subscription flag default value is true, i.e., the form instance defaults to turn on the subscription data change function.
The static method for creating the table instance in the embodiment of the application firstly dynamically constructs a table instance on a heap, and stores an instance address in an intelligent pointer. After the table is instantiated, the internal data including row set, column set, REDIS client instance and subscription instance are initialized. The initially created table has no structure, i.e. no column names are set, nor are any row data stored. Therefore, initializing a row set requires dynamic creation of a null DRC instance, initializing a column name set requires dynamic creation of a null DCC instance. In order that the form instance can be used as a bridge between a user and the REDIS database, the REDIS client terminal object needs to be initialized when the form is initially created, so that the connection establishment between the REDIS client terminal object and the REDIS server terminal is ensured to be normal. In order to timely sense the change of the table data, after the table instance is created, a subscription sub-object is initialized, so that the asynchronous connection between the subscription sub-object and REDIS server is ensured to be established normally, simultaneously, a REDIS SUBSCRIBE command is successfully executed, an asynchronous event processing thread is started normally, and all messages on a channel named by the table name are subscribed. After the table object is successfully created and all initializations are completed, the static method returns the table instance address to the user. The user can obtain the table instance address, i.e., a shared_ptr < DT > type variable. Examples of static method calls are as follows:
shared_ptr<DT>PTR=DT::CreateDataTable(“192.168.1.1”,6973,“123456”,“TestTbl”,true,1)。
Dti_5 is the interface for the DT class set table column field name. After the user obtains the table instance address, if a brand new data table is required to be designed, the column name of the data stored in the interface setting table can be called through the table instance address according to the application scene. For example, set 3 column names as F1, F2, and F3, respectively, then call is performed: vector < string > heads= { "F1", "F2", "F3" }; PTR- > SetHead (heads); the interface traverses the input column name array, sequentially takes out each element, calls the input parameters of the DCC class DCCI_12 interface as a table column cell set object, and circularly increases the cells with specified names.
Dti_6 is the interface for the DT class to set the table index field, the index is an optional setting item, allowing the table to be index-free. The user can create the index for the table instance at any time according to the service requirement, allow the index to be created on a plurality of columns, allow the index to be set for a plurality of times, and can select two modes of resetting or adding when setting. The index information before the resetting mode is emptied, and an index table is built again according to the table data; the additional mode can keep the original index information and supplement the index table data according to the newly set index column. Although one table is allowed to set a plurality of index columns, search is allowed only on one column, and multi-column combined search is not supported. The interface of the table class setting index directly calls the line set class setting index interface.
Dti_8 is the DT class setting table name interface.
Dti_9 is the DT class get table name interface. The table name is case-wise and the default value is null.
Dti_10 is the DT class get table number interface. The table number is obtained by adding the static variable of the table class, and the table number is unique in a single process and can be the same among multiple processes.
Dti_11 is the DT class load table full data interface. If the user does not need to set a new table, and only needs to load the existing table data from the REDIS database, the dti_11 interface of the table class is called through the table instance address, and an example is called: auto ret = PTR- > LoadData (); the method for loading table data first needs to execute the REDIS SCAN command through REDIS client terminal object of table class to obtain all keys related to table instance. Assuming that the table name is TestTbl, the TestTbl table data in the REDIS in-memory database is stored in a plurality of hash tables with keys TestTbl: N, where N represents a unique row number in the data table, and the meaning of the unique row number is equivalent to the primary key of the data table, so that a row of data can be uniquely determined. Therefore, the SCAN command to be executed is SCAN cursor MATCH TableName, the initial value of cursor is 0, and each time the command is executed, the cursor searched for next time and the current search result satisfying the matching mode will be returned. When the return cursor is 0, this indicates that the SCAN command completes one complete traversal. All KEYS retrieved during the SCAN traversal are saved to the container, assuming tbl_keys. If the container is not empty, the first element is fetched, assuming TestTbl 1, and executing the REDIS HKEYS command obtains all field names in the TestTbl 1 key, i.e., column names of the table TestTbl. The dti_8 interface is called to set the table column name. And circularly traversing each key element in the TBL_KEYS, completing the conversion operation from the key value to the row object, and finally calling a table class batch addition data row interface to add all rows created according to the TBL_KEYS into the table. Since the data is already loaded from the REDIS database, the batch addition operation here does not need to synchronize the REDIS database. The data loading method returns the number of rows and columns successfully loaded to the caller.
The conversion operation from REDIS key to row object firstly executes REDIS HGETALL command to obtain all fields and values in key, analyzes row number RID from key value of "table name: row number" format, creates a new row object whose row number RID is identical with cell name in row and table column cell, and fills all fields and values in key into cells in new row object.
Dti_12 is the DT class get table rank interface.
Dti_13 is a DT class empty table row data interface.
Dti_15 is the DT class get table new line number interface. Each table specifies a globally unique row number identifier name. For example, a table instance may be named tableNameA and a row number identifier of the table may be defined as tableNameA_SEQ. The method of generating the new line number requires that the line number identifier name is first entered, and then the INCR command of REDIS is executed to add 1 to the KEY as the value stored in TableNameA_SEQ. The REDIS mechanism ensures that if the specified KEY does not exist in the REDIS database, the value of the specified KEY is initialized to 0, the INCR operation is performed, the KEY is stored in the REDIS database, and the result after the INCR operation is performed is returned to the client. The REDIS single-wire Cheng Chuanhang processing mechanism ensures that no data race problem occurs when new row numbers of the same table are concurrently generated in a multi-threaded environment.
Dti_16 is the DT class create table new row object interface. The new line object creating method includes creating one empty new line object dynamically on the pile, copying list cell set of the new line object to the new line object, setting the data table associated with the new line object as the current line object, and returning the new line object address to the user for setting line data.
Dti_17 is the DT class batch add-on interface.
Dti_18 is the DT class bulk delete line interface.
Dti_19 is the DT class batch modify line interface. Batch operations are executed in a transactional manner, with success being all successful and failure being all failed. When the batch is added, deleted or modified, the table data is firstly locked, then the data backup is carried out, and the backup is used for backing up the table data when part of the row operation fails. And after the backup is finished, calling the addition, deletion or modification of the row set class definition to circularly process the incoming rows of the single row interface. After all the rows are successfully processed, the table data is unlocked first, and then whether REDIS databases are synchronously updated is selected according to service requirements.
The REDIS database updating method needs to be transmitted with batch line data to be updated and operation identifiers, and the operation identifiers can be set to be added, deleted or modified. According to the method, each line of data is firstly analyzed into a subscription and release data structure, and then the subscription and release structure is converted into REDIS commands according to operation identifiers. If the operation is identified as an add or modify, the data is converted to REDIS's HMSET KEY F V1[ F2V 2 … ] command. If the operation is identified as delete, the data is converted to REDIS's HDEL KEY F1[ F2 … ] command. The KEY in the command is "table name: row number", and Fn and Vn correspond to the name and value of each cell in the row. All lines to be operated are converted into REDIS commands according to rules, then the whole publishing and subscribing structure is serialized, and a PUBLISH CHANNEL MESSAGE command is added to a REDIS command set to be executed, wherein CHANNEL is a table name, and MESSAGE is serialized publishing and subscribing data. Executing all REDIS commands in a channel mode, analyzing the execution result, and returning success or failure to the caller according to the command execution result.
The publish-subscribe data structure is defined as a composite type that includes an operation identifier, a database index, a table name, a table number, and change line data. The row data comprises a row number and a row attribute set; the line attribute data includes an attribute name and an attribute value. The table instance of the publish-subscribe composite structure is serialized into a JSON string, and the table instance of the subscribe-change notification is inversely serialized into a composite structure.
Dti_20 is the DT class data polling interface. The row query method allows a user to input a custom query function object, custom row query conditions are defined in the function object, and a query function object interface is defined as a bool (DR &). The line inquiry method circularly traverses all lines in the table, takes each line as an input parameter of an inquiry function object, executes an inquiry function and judges whether the input line meets the inquiry condition according to the return value. If so, a copy of the incoming row is placed into the query result set. And finally, returning the query result set to the caller.
Dti_21 is the DT class batch add-on interface.
Dti_22 is the DT class bulk delete column interface. And circularly calling interfaces of the cells in the cell set in the batch adding or deleting method of the table, wherein the list cell set of the table stores the table address, and if the rows exist in the table when the cells are added or deleted, the cells are added or deleted in the cell set corresponding to each row.
Dti_23 is a row-by-row traversal interface provided by the DT class.
Dti_24 is the DT class registration line add notification callback interface.
Dti_25 is the DT class registration line delete notification callback interface.
Dti_26 is the DT class registration line modification notification callback interface. In order to realize the automatic synchronization function of the form data, the form needs to realize a data change callback method. When the asynchronous event processing thread subscribing the sub-objects in the form receives the change message, the data change callback registered by the form class is called. The change callback of the form class can synchronously update the self memory data according to the operation identification in the subscription message body. The user can selectively register the callback interface of the table data to add, modify or delete the change callback interface, and when the table updates the object memory data due to receiving the subscription change message, the callback interface registered by the user is called, and the user can customize the processing logic of the change data in the callback interface.
Dti_27 is a DT class registration subscription notification callback interface. The table class is an upper layer user of the subscription class, and has to register a subscription notification callback with the subscription class in order to receive the table data change notification message in time. After receiving the data change notification, the form class firstly deserializes the received JSON character string into a composite structure, and then performs addition, deletion or modification processing according to the operation identifier. When the number of the line in the change data is increased, the existence of the line number in the table instance memory is checked, and if the line number does not exist, the change data is increased. Otherwise, the processing is ignored. When modifying and deleting, if the line number exists in the table instance memory, updating or deleting the corresponding line data, otherwise, ignoring the processing. The form data change which is passively received and triggered is not synchronized to the REDIS database, and the form instance which actively issues the change completes the REDIS database data change.
Dti_28 is a DT class check form presence interface. The user can check the REDIS database for the presence of any form data by way of the form instance. For example, PTR- > TableExist ("Testcheck") may be performed by the TestTbl table instance detecting whether a Testcheck table already exists; if the entry table name is not specified, the existence of the table instance itself is checked by default, i.e., PTR- > TableExist () is equivalent to PTR- > TableExist ("TestTbl").
Dti_29 is the DT class interfaces to the search line according to the index field name value pair. The use of an index table search row allows searching on only one column, and does not support multi-column combined searching.
Fig. 8 is a schematic block diagram of a static apparatus for creating a table instance provided by an embodiment of the present invention. As shown in fig. 8, the present invention also provides a static apparatus for creating a table instance, corresponding to the above static method for creating a table instance. The static means for creating a form instance comprises means for performing the static means for creating a form instance described above, which means can be arranged in a desktop computer, a tablet computer, a laptop computer, etc. Specifically, referring to fig. 8, the static apparatus 200 for creating a table instance includes:
a table instance creation unit 201, configured to dynamically construct a table instance on a heap, and store an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests;
A connection establishing unit 202, configured to establish a data connection between the table instance and the REDIS database, and enable the table instance to transfer information from the REDIS database to a user;
a message subscription obtaining unit 203, configured to create a subscription sub-object for establishing a data connection between the table instance and the REDIS database, and enable the subscription sub-object to establish a connection with the REDIS database, and obtain all messages on a data channel named by a table name by using the subscription sub-object;
and the address obtaining unit 204 is configured to obtain the address of the table instance by using the intelligent pointer, and complete creation of the table instance.
It should be noted that, as will be clearly understood by those skilled in the art, the specific implementation process of each unit of the static device 200 for creating a table example may refer to the corresponding description in the foregoing method embodiment, and for convenience and brevity of description, the description is omitted here.
The static means 300 for creating a table instance described above may be embodied in the form of a computer program which may be run on a computer device as shown in fig. 9.
With reference to FIG. 9, the computer device 300 includes a processor 302, a memory, and a network interface 305, which are connected by a system bus 301, wherein the memory may include a non-volatile storage medium 303 and an internal memory 304.
The non-volatile storage medium 303 may store an operating system 3031 and a computer program 3032. The computer program 3032 includes program instructions that, when executed, cause the processor 302 to perform a static method of creating a table instance.
The processor 302 is used to provide computing and control capabilities to support the operation of the overall computer device 300.
The internal memory 304 provides an environment for the execution of a computer program 3032 in the non-volatile storage medium 303, which computer program 3032, when executed by the processor 302, causes the processor 302 to perform a static method of creating a table instance.
The network interface 305 is used for network communication with other devices. It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the present application and does not constitute a limitation of the computer device 300 to which the present application is applied, and that a particular computer device 300 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
The storage medium may be a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, or other various computer-readable storage media that can store program codes.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed.
The steps in the method of the embodiment of the invention can be sequentially adjusted, combined and deleted according to actual needs. The units in the device of the embodiment of the invention can be combined, divided and deleted according to actual needs. In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The integrated unit may be stored in a storage medium if implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a terminal, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.
Claims (10)
1. A static method of creating a form instance, comprising the steps of:
dynamically constructing a table instance on a heap, and storing an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests;
establishing a data connection between the form instance and the REDIS database, and enabling the form instance to transmit information from the REDIS database to a user;
creating a subscription sub-object for establishing data connection between the form instance and the REDIS database, enabling the subscription sub-object to establish connection with the REDIS database, and acquiring all messages on a data channel named by the form name by utilizing the subscription sub-object;
the intelligent pointer is utilized to acquire the address of the table instance, and the creation of the table instance is completed;
before the step of dynamically constructing the table instance on the heap, creating a table object in a process memory, and setting a data change detection mode for the table; in the step of creating the table object in the process memory, a table class for operating the table is also required to be created, wherein the table class provides a common operation interface, and the interface receives parameters of the REDIS server.
2. The static method of creating a table instance of claim 1, wherein the step of initializing the table instance for internal data comprises initializing a row set, a column set, a REDIS client instance, and a subscription instance internal to the table instance.
3. The static method of creating table instances of claim 2, wherein the step of initializing row sets, column sets, REDIS client instances, and subscription instances within a table instance comprises dynamically creating a null data row set class instance to initialize the row sets, and dynamically creating a null data column set class instance to initialize the column sets.
4. The static method of creating a table instance of claim 1, wherein said step of connecting said subscription sub-object to a REDIS database comprises establishing an asynchronous connection relationship between said subscription sub-object and a REDIS server.
5. The static method of creating a form instance of claim 1, wherein the step of utilizing the subscription sub-object to obtain all messages on a data channel named by a form name comprises causing the form instance to execute a REDIS subscription command and initiate an asynchronous event handling thread for perceiving changes to form data.
6. The static method for creating a table instance according to claim 1, wherein the acquiring all messages on the data channel named by the table name by using the subscription sub-object further comprises triggering the data change detection mode according to the acquired data change message on the data channel named by the table name, and sending a data change notification to a table user.
7. The static method of creating a form instance of claim 6, wherein the form instance makes data changes from data obtained from the REDIS database.
8. A static apparatus for creating a table instance, comprising the following elements:
creating a table object in a process memory, creating a table class for operating a table, and setting a data change detection mode for the table;
a table instance creation unit, configured to dynamically construct a table instance on a heap, and store an address of the table instance in an intelligent pointer; initializing the internal data of the table instance, and setting table attributes and table operation requests;
a connection establishing unit, configured to establish a data connection between the table instance and the REDIS database, so that the table instance realizes transmitting information from the REDIS database to a user;
A message subscription acquisition unit, configured to create a subscription sub-object for establishing data connection between the table instance and the REDIS database, so that the subscription sub-object establishes connection with the REDIS database, and acquire all messages on a data channel named by a table name by using the subscription sub-object;
and the address acquisition unit is used for acquiring the address of the table instance by using the intelligent pointer and completing the creation of the table instance.
9. A computer device comprising a memory, a processor and a static program stored on the memory and executable on the processor to create a table instance, wherein the static program to create a table instance when executed by the processor implements the static method of creating a table instance as claimed in any one of claims 1-7.
10. A non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a static method of creating a table instance as claimed in any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010855568.7A CN112035572B (en) | 2020-08-21 | 2020-08-21 | Static method, device, computer equipment and storage medium for creating form instance |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010855568.7A CN112035572B (en) | 2020-08-21 | 2020-08-21 | Static method, device, computer equipment and storage medium for creating form instance |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112035572A CN112035572A (en) | 2020-12-04 |
CN112035572B true CN112035572B (en) | 2024-03-12 |
Family
ID=73580616
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010855568.7A Active CN112035572B (en) | 2020-08-21 | 2020-08-21 | Static method, device, computer equipment and storage medium for creating form instance |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112035572B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113885873B (en) * | 2021-09-29 | 2022-09-16 | 中国科学院软件研究所 | Lightweight OpenHarmony operating system application development object management system and application method thereof |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB0823187D0 (en) * | 2008-12-18 | 2009-01-28 | Veda Technology Ltd | Data processing apparatus |
CN108289055A (en) * | 2018-01-05 | 2018-07-17 | 创盛视联数码科技(北京)有限公司 | A kind of distributed live chat system and method based on Redis subscription services |
CN108418894A (en) * | 2018-03-26 | 2018-08-17 | 威创软件南京有限公司 | A kind of Distributed Data Synchronization method based on push technologies |
CN110321360A (en) * | 2019-07-08 | 2019-10-11 | 深圳市智慧郎数码科技有限公司 | The processing method and relevant device of list data |
CN111125126A (en) * | 2019-11-29 | 2020-05-08 | 浪潮(北京)电子信息产业有限公司 | Storage state management method, system, electronic equipment and storage medium |
-
2020
- 2020-08-21 CN CN202010855568.7A patent/CN112035572B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB0823187D0 (en) * | 2008-12-18 | 2009-01-28 | Veda Technology Ltd | Data processing apparatus |
CN108289055A (en) * | 2018-01-05 | 2018-07-17 | 创盛视联数码科技(北京)有限公司 | A kind of distributed live chat system and method based on Redis subscription services |
CN108418894A (en) * | 2018-03-26 | 2018-08-17 | 威创软件南京有限公司 | A kind of Distributed Data Synchronization method based on push technologies |
CN110321360A (en) * | 2019-07-08 | 2019-10-11 | 深圳市智慧郎数码科技有限公司 | The processing method and relevant device of list data |
CN111125126A (en) * | 2019-11-29 | 2020-05-08 | 浪潮(北京)电子信息产业有限公司 | Storage state management method, system, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112035572A (en) | 2020-12-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111966756B (en) | Automatic form data synchronization method, device, computer equipment and storage medium | |
CN111966690B (en) | Method, device, computer equipment and storage medium for loading form full data | |
US7769789B2 (en) | High performant row-level data manipulation using a data layer interface | |
US7533136B2 (en) | Efficient implementation of multiple work areas in a file system like repository that supports file versioning | |
US7325007B2 (en) | System and method for supporting non-native data types in a database API | |
US6947950B2 (en) | Techniques for managing multiple hierarchies of data from a single interface | |
KR101159378B1 (en) | System and method for storing and retrieving a field of a user defined type outside of a database store in which the type is defined | |
WO2009043033A4 (en) | Network operating system | |
KR20060048418A (en) | System and method for delayed fetching of designated members of a user defined type | |
CN111984663B (en) | REDIS database updating method, REDIS database updating device, REDIS database updating computer equipment and REDIS database storage medium | |
WO2018035799A1 (en) | Data query method, application and database servers, middleware, and system | |
JP6613320B2 (en) | System and method for providing distributed caching in a transaction processing environment | |
Tauro et al. | A comparative analysis of different nosql databases on data model, query model and replication model | |
JP2018531439A6 (en) | System and method for providing distributed caching in a transaction processing environment | |
CN112035572B (en) | Static method, device, computer equipment and storage medium for creating form instance | |
US6725213B1 (en) | Method and mechanism for providing external procedures to a database system | |
KR101286284B1 (en) | QoS-aware Web Service Composition method using On-the-fly Learning-based Search | |
CN112000739B (en) | Cell designated insertion method, device, computer equipment and storage medium | |
US11222003B1 (en) | Executing transactions for a hierarchy of data objects stored in a non-transactional data store | |
CN112347794B (en) | Data translation method, device, equipment and computer storage medium | |
CN113946574A (en) | Data processing method and device, electronic equipment and storage medium | |
EP3091447B1 (en) | Method for modifying root nodes and modifying apparatus | |
Bhargava et al. | Design and implementation of the Raid V2 distributed database system | |
CN110647535A (en) | Method, terminal and storage medium for updating service data to Hive | |
JPH117445A (en) | Integrated document management device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |