A self-defined identifier writing method, device, storage medium and electronic equipment
By rewriting methods in Elasticsearch-Hadoop to enable the writing of custom identifiers, the problem of users being unable to define custom identifiers is solved, thus improving data retrieval and management efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING HONGTENG INTELLIGENT TECH CO LTD
- Filing Date
- 2024-12-25
- Publication Date
- 2026-06-26
Smart Images

Figure CN122286016A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, storage medium, and electronic device for writing custom identifiers in the field of computers. Background Technology
[0002] To enable data interaction between the Elasticsearch search engine and the Hadoop big data processing framework, existing technologies use tools like Elasticsearch-Hadoop. Elasticsearch-Hadoop can extract a field from the transmitted data and set it as an identifier for that data, facilitating retrieval during subsequent use. However, Elasticsearch-Hadoop can only recognize fields in the transmitted data and cannot support user-defined identifiers, causing inconvenience for users using Elasticsearch and Hadoop. Therefore, a method that allows users to set custom identifiers is needed. Summary of the Invention
[0003] This application provides a method, apparatus, storage medium, and electronic device for writing custom identifiers. This method can extract and write custom identifiers into the metadata attributes of transmitted data by rewriting various methods in Elasticsearch-Hadoop, so that the transmitted data can be identified and indexed using custom identifiers, thereby realizing personalized settings for identifiers by users.
[0004] In a first aspect, embodiments of this application provide a method for writing a custom identifier, the method comprising:
[0005] Receive user-defined identifiers for transmitted data;
[0006] Based on the target metadata extraction class, obtain the metadata attributes of the transmitted data;
[0007] Based on the write method in the target record write class, the custom identifier is written to the metadata attribute;
[0008] The metadata attributes and the transmission data are transmitted together.
[0009] The above technical solution enables the extraction and writing of user-inputted custom identifiers into the metadata attributes of transmitted data, allowing the use of custom identifiers to identify and index transmitted data, thereby realizing personalized settings for identifiers by users.
[0010] In conjunction with the first aspect, in some possible implementations, receiving a custom identifier input by the user for the transmitted data includes:
[0011] Based on the setting method in the target metadata extraction class, the user's custom identifier for the transmitted data is obtained, and the custom identifier is written into the first variable. The target metadata extraction class is constructed based on the metadata extraction abstract class.
[0012] Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable.
[0013] The above technical solutions can encapsulate the internal data of an object, which helps maintain the object's internal data structure and constraints, and also ensures that the value of a custom identifier can be correctly written and retrieved.
[0014] In conjunction with the first aspect, in some possible implementations, writing the custom identifier to the metadata attribute based on the write method in the target record write class includes:
[0015] The custom identifier is assigned to the second variable based on the target record writing class, wherein the target record writing class is constructed based on the record writing base class;
[0016] Based on the write method in the target record write class, the custom identifier in the second variable is written into the metadata attribute of the transmitted data.
[0017] The above technical solution can encapsulate the instantiated object of the target metadata extraction class inside a second variable, making object management more centralized.
[0018] In conjunction with the first aspect, in some possible implementations, the step of writing the custom identifier within the second variable into the metadata attribute of the transmitted data based on the write method in the target record write class includes:
[0019] By calling the metadata attribute dynamic setting method in the write method of the target record write class, the custom identifier in the second variable is written into the metadata attribute.
[0020] The above technical solution enables the writing of custom identifiers into metadata attributes to facilitate the retrieval and processing of transmitted data based on the custom identifiers.
[0021] In conjunction with the first aspect, in some possible implementations, the method further includes:
[0022] The association between the custom identifier and the input data is established by calling the data identifier setting method in the write method within the target record write class.
[0023] The above technical solution enables the association of custom identifiers with input data, serving as unique identifiers for the input data.
[0024] In conjunction with the first aspect, in some possible implementations, the process of transmitting the metadata attributes and the transmission data together includes:
[0025] Based on the target output format class, the metadata attributes and the transmitted data are transmitted together, wherein the target output format class is constructed based on the output format base class.
[0026] In conjunction with the first aspect, in some possible implementations, the method further includes:
[0027] In the target metadata extraction class, a method for obtaining the instantiated object using the singleton pattern is implemented.
[0028] The above technical solution utilizes the Singleton pattern to save resources, control access to shared resources, and avoid unnecessary object creation, thereby improving system performance.
[0029] Secondly, embodiments of this application provide a custom identifier writing device, the device comprising:
[0030] The identifier acquisition unit is used to receive custom identifiers input by the user for the transmitted data;
[0031] Metadata extraction unit, used to obtain metadata attributes of the transmitted data based on the target metadata extraction class;
[0032] The identifier writing unit is used to write the custom identifier into the metadata attribute based on the write method in the target record writing class;
[0033] A transmission processing unit is configured to transmit the metadata attributes and the transmission data together. Thirdly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading and executing the above-described method steps by a processor.
[0034] Fourthly, embodiments of this application provide an electronic device that may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the above-described method steps.
[0035] In one or more embodiments of this application, a custom identifier input by a user for transmitted data is received; based on a target metadata extraction class, the metadata attributes of the transmitted data are obtained; based on a write method in a target record writing class, the custom identifier is written into the metadata attributes; and the metadata attributes and the transmitted data are transmitted together. By writing the user-inputted custom identifier into the metadata attributes of the transmitted data, the transmitted data can be identified and indexed using the custom identifier, thereby realizing the user's personalized settings for the identifier. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a schematic diagram illustrating an example of writing a custom identifier provided in an embodiment of this application;
[0038] Figure 2 This is a flowchart illustrating a custom identifier writing method provided in an embodiment of this application;
[0039] Figure 3 This is a flowchart illustrating a custom identifier writing method provided in an embodiment of this application;
[0040] Figure 4 This is a schematic diagram of the structure of a custom identifier writing device provided in an embodiment of this application;
[0041] Figure 5 This is a schematic diagram of the structure of a custom identifier writing device provided in an embodiment of this application;
[0042] Figure 6 This is a schematic diagram of the structure of an identifier writing unit provided in an embodiment of this application;
[0043] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0044] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0045] Elasticsearch is an elastic search engine capable of fast retrieval and fact analysis of large-scale text data. Hadoop is a distributed computing framework capable of distributed data storage and large-scale data processing tasks. Elasticsearch-Hadoop acts as a connector between Elasticsearch and Hadoop, enabling more efficient data exchange between them. It allows data to be imported from Hadoop into Elasticsearch or extracted from Elasticsearch into Hadoop, combining Elasticsearch's real-time search capabilities with Hadoop's big data processing power for more efficient data analysis. To distinguish each transmitted data and facilitate indexing, Elasticsearch-Hadoop can set identifiers for the transmitted data. Currently, Elasticsearch-Hadoop can set a specific field in the document (doc) of the transmitted data as the identifier, or retrieve an identifier automatically generated by Elasticsearch for that transmitted data. However, current Elasticsearch-Hadoop technologies cannot recognize characters other than those set by Elasticsearch or the document itself, thus failing to support user-defined identifiers for transmitted data.
[0046] It is understandable that customizing the identifiers for transmitted data allows users to personalize their settings, enabling them to better retrieval, classification, and analysis of transmitted data according to their individual habits, thereby improving the efficiency of using Elasticsearch and Hadoop. Therefore, this application provides a custom identifier writing device that rewrites the writing method in Elasticsearch-Hadoop, allowing Elasticsearch-Hadoop to obtain and recognize the custom identifier input by the user for the transmitted data and write it into the metadata (meta) attribute of the transmitted data. This obtains the custom identifier as the identifier for the transmitted data. The meta attribute can include version information, document name, etc., which can serve as an Elasticsearch index for identifying and manipulating documents and retrieving transmitted data, thereby improving the management efficiency of all transmitted data. The custom identifier writing method provided in this application can be implemented using a computer program and can run on a custom identifier writing device based on the von Neumann architecture. This computer program can be integrated into an application or run as a standalone utility application.
[0047] For example, please see also Figure 1 This embodiment of the application provides an example of writing a custom identifier. For instance, when a user wants to transfer data from Hadoop to Elasticsearch, the modified Elasticsearch-Hadoop in this embodiment can obtain the custom identifier input by the user for the transferred data. The custom identifier can be an identifier set by the user based on their personal habits. Elasticsearch-Hadoop can then write the obtained custom identifier into the meta attribute of the transferred data, and then write the transferred data containing the custom identifier into Elasticsearch. This allows Elasticsearch and Hadoop to use the user-input custom identifier when performing data analysis and indexing on the transferred data in the future.
[0048] The following detailed description of the custom identifier writing method provided in this application, with reference to specific embodiments, provides a detailed explanation.
[0049] Please see Figure 2 This is a flowchart illustrating a custom identifier writing method provided in an embodiment of this application. Figure 2 As shown, the method described in this application embodiment may include the following steps S101-S104.
[0050] S101, receives a user-defined identifier for the transmitted data.
[0051] Specifically, when a user wants to transfer data between Hadoop and Elasticsearch, in addition to specifying the data to be transferred, they can also input a custom identifier for the transferred data. The custom identifier writing device can receive the custom identifier input by the user for the transferred data.
[0052] S102, based on the target metadata extraction class, obtain the metadata attributes of the transmitted data.
[0053] Specifically, the custom identifier writing device can construct a target metadata extraction class based on the metadata extraction abstract class. That is, the target metadata extraction class inherits from the metadata extraction (org.elasticsearch.hadoop.serialization.bulk.PerEntityPoolingMetadataExtractor) abstract class, which can be used to extract meta attributes from transmitted data. It can handle the extraction and management of meta attributes of each transmitted data in batch operations. By processing the meta attributes of each transmitted data independently, the data processing efficiency can be improved.
[0054] S103, based on the write method in the target record write class, write the custom identifier to the metadata attribute.
[0055] Specifically, the custom identifier writing device can construct a target record writing class, which can inherit from the base record writing class (EsRecordWriter). EsRecordWriter writes the transmitted data output by Hadoop to Elasticsearch and ensures that the transmitted data conforms to Elasticsearch's requirements, such as converting the transmitted data into a suitable JSON format. The target record writing class, inheriting from EsRecordWriter, can retain its data writing functionality and instantiate a target metadata extraction class based on the EsRecordWriter class to successfully call the user-inputted custom identifier. The custom identifier writing device can write the custom identifier into the meta attribute based on the write method in the target record writing class. For example, the custom identifier writing device can implement the write method in the target record writing class. The original write method can write data to the meta attribute of the transmitted data, but it cannot read or recognize the user-inputted custom identifier. Therefore, the write method in the target record writing class can be overridden to enable the write method to read the custom identifier and write it into the meta attribute of the transmitted data.
[0056] S104, transmits metadata attributes and transmission data together.
[0057] Specifically, the custom identifier writing device can transmit the meta attribute and the transmitted data together. Since the custom identifier is written to the meta attribute, the custom identifier is transmitted together with the transmitted data and serves as an identifier for the transmitted data, thus realizing the customization of the identifier.
[0058] In this embodiment, a custom identifier input by a user for transmitted data is received. Based on a target metadata extraction class, the metadata attributes of the transmitted data are obtained. Using a write method in a target record writing class, the custom identifier is written into the metadata attributes. The metadata attributes and the transmitted data are then transmitted together. By writing the user-inputted custom identifier into the metadata attributes of the transmitted data, the transmitted data can be identified and indexed using the custom identifier, thus enabling personalized settings for the identifier by the user.
[0059] Please see Figure 3 This is a flowchart illustrating a custom identifier writing method provided in an embodiment of this application. Figure 3 As shown, the method described in this application embodiment may include the following steps S201-S207.
[0060] S201, Based on the setting method in the target metadata extraction class, obtain the user's custom identifier for the transmitted data, and write the custom identifier into the first variable.
[0061] Specifically, the custom identifier writing device can construct a target metadata extraction class based on the metadata extraction abstract class. That is, the target metadata extraction class inherits from the org.elasticsearch.hadoop.serialization.bulk.PerEntityPoolingMetadataExtractor abstract class, which can be used to extract meta attributes from transmitted data. It can handle the extraction and management of meta attributes of each transmitted data in batch operations. By processing the meta attributes of each transmitted data independently, the data processing efficiency can be improved. The target metadata extraction class inherits from the abstract class `org.elasticsearch.hadoop.serialization.bulk.PerEntityPoolingMetadataExtractor`. The custom identifier writing device can retain its functionality such as extracting meta attributes, and obtain the custom identifier entered by the user for the transmitted data based on the set method in the target metadata extraction class. The custom identifier is the identifier entered by the user for the transmitted data, which is a user-defined identifier. The custom identifier writing device can implement the set method in the target metadata extraction class. The set method allows external code to pass in new values through the set method, thereby modifying the internal state of the object, obtaining the user-entered custom identifier, and storing the custom identifier in the first variable.
[0062] S202, based on the value retrieval method in the target metadata extraction class, calls the custom identifier in the first variable.
[0063] Specifically, after obtaining the user's externally inputted custom identifier, the custom identifier writing device can call the custom identifier in the first variable based on the getValue method in the target metadata extraction class. For example, the custom identifier writing device can implement the getValue method in the target metadata extraction class. The getValue method is used to read the value of the object, allowing external code to access the object's state without modifying it. This makes it possible for subsequent objects to call the custom identifier in the first variable without changing its value, thereby improving the security of the user's custom identifier.
[0064] Optionally, the `set` method allows external code to pass in new values, thereby modifying the object's internal state. The `set` method implemented in the target metadata extraction class by the custom identifier writer can retrieve the user-inputted custom identifier and store it in a first variable. The `getValue` method is used to read the object's value, allowing external code to access the object's state without modifying it. The `getValue` method implemented in the target metadata extraction class can retrieve the custom identifier from the first variable. Through the `getValue` method, the custom identifier writer can control how the object's state is exposed. The `set` method can be used to write custom identifiers, while the `getValue` method is used to read them from the first variable. By implementing these two methods, the object's internal data can be encapsulated. External code cannot directly access or modify attribute values; instead, these methods are used. This helps maintain the object's internal data structure and constraints and ensures that the value of the custom identifier can be correctly written and retrieved, thus guaranteeing the consistency and integrity of the custom identifier before and after its creation.
[0065] Optionally, in the set method to be implemented, the custom identifier writing device can also add additional logic, such as verifying the validity of the input custom identifier, triggering events, etc., so as to ensure the security of the custom identifier.
[0066] S203, based on the target metadata extraction class, obtain the metadata attributes of the transmitted data.
[0067] Specifically, the target metadata extraction class inherits from the metadata extraction abstract class. It can extract meta attributes from transmitted data and can handle the extraction and management of meta attributes for each transmitted data in batch operations, processing each transmitted meta attribute independently.
[0068] Optionally, the custom identifier writing device can implement a method for obtaining the instantiated object in the target metadata extraction class using the singleton pattern. Based on the abstract class org.elasticsearch.hadoop.serialization.bulk.PerEntityPoolingMetadataExtractor, the custom identifier writing device can implement a method for obtaining the instantiated object in the singleton pattern. That is, the target metadata extraction class uses the singleton pattern, which means that there is only one instance of the target metadata extraction class in the entire program. The singleton pattern can save resources, control access to shared resources, avoid unnecessary object creation, and thus improve system performance.
[0069] Optionally, the singleton pattern can be implemented using the getInstance method, which internally uses double-checked locking to ensure thread safety. The getInstance method is used to return a unique instance of the class. Each time the getInstance method is called, it checks whether an instance already exists. If it does not exist, a new instance is created; otherwise, the existing instance is returned.
[0070] S204, Assign a custom identifier to a second variable based on the target record write class.
[0071] Specifically, the custom identifier writing device can construct a target record writing class based on the EsRecordWriter class. The target record writing class inherits from the EsRecordWriter class and retains the data writing functions of the EsRecordWriter class. This allows for the addition of custom behaviors and functions without modifying the original EsRecordWriter class code, separating custom logic from basic logic, improving code organization and maintainability, and ensuring the normal operation of the original functions. The custom identifier writing device can instantiate a target metadata extraction class in the target record writing class and assign the instantiated object of the target metadata extraction class to a second variable for use in subsequent operations. It can be understood that the value returned by the instantiated object of the target metadata extraction class is the custom identifier, so the value stored in the second variable is the custom identifier. Encapsulating the instantiated object of the target metadata extraction class inside the second variable allows for more centralized object management.
[0072] S205, based on the write method in the target record write class, write the custom identifier in the second variable into the metadata attribute of the transmitted data.
[0073] Specifically, the custom identifier writing device can write the custom identifier in the second variable to the meta attribute of the transmitted data based on the write method in the target record writing class. For example, the write method can be implemented in the target record writing class to write the custom identifier in the second variable to the meta attribute of the transmitted data. The original write method in the EsRecordWriter class can write data to the meta attribute of the transmitted data, but it cannot read or recognize the custom identifier entered by the user. Therefore, the write method can be overridden in the target record writing class so that the write method can read the custom identifier from the second variable and write the custom identifier to the meta attribute of the transmitted data.
[0074] Optionally, the custom identifier writing device can write the custom identifier from the second variable into the metadata attribute by calling the metadata attribute dynamic setting method in the write method of the target record writing class. The custom identifier writing device can call the metadata attribute dynamic setting (repository.addRuntimeFieldExtractor) method in the write method of the target record writing class. The repository.addRuntimeFieldExtractor method can dynamically generate or extract fields during the data transmission process between Hadoop and Elasticsearch. It's understandable that the original repository.addRuntimeFieldExtractor method in the write method of the EsRecordWriter class cannot read or recognize the custom identifier entered by the user. Therefore, in the target record writing class, the custom identifier writing device can rewrite the repository.addRuntimeFieldExtractor method so that it can obtain the custom identifier from the second variable and write it into the meta attribute of the transmitted data.
[0075] S206, By calling the data identifier setting method in the write method in the target record write class, the association between the custom identifier and the input data is established.
[0076] Specifically, the custom identifier writing device can call the `customMetadataExtractor.setMetaId` method in the write method of the target record writing class to establish the association between the custom identifier and the input data. In Elastics earch-Hadoop, the `customMetadataExtractor.setMetaId` method can be used to assign a unique identifier to the transmitted data for tracking and management during data processing and storage. The `customMetadataExtractor.setMetaId` method implemented by the custom identifier writing device in the target record writing class can obtain the custom identifier and use it as the unique identifier for the transmitted data.
[0077] Optionally, the process of implementing the `write` method in the target record writing class by the custom identifier writing device may include: the custom identifier writing device may call the parent class's `init` method in the target record writing class to prepare necessary resources or perform configuration; calling it in the subclass ensures that all initialization logic inherited from the parent class is executed, thereby providing the object with a correct starting state. The custom identifier is extracted from the `key` parameter of the `write` method, where `key` is a unique identifier or key-value pair of the transferred data to be written to Elasticsearch, ensuring that each transferred data has a unique identifier in Elasticsearch, which helps to correctly store and retrieve the transferred data.
[0078] Then, the custom identifier writing device can call the customMetadataExtractor.setMetaId method to obtain the custom identifier and use it as the unique identifier for transmitting data. For example, the custom identifier writing device can obtain the custom identifier and name it documentId, and then call customMetadataExtractor.setMetaId(documentId) to use the custom identifier in the second variable as the unique identifier for transmitting data.
[0079] The custom identifier writing device can call the repository.addRuntimeFieldExtractor method to identify the custom identifier and write it into the meta property of the transmitted data. For example, the custom identifier writing device can encapsulate the instantiated object of the target metadata extraction class into the second variable customMetadataExtractor, and then call repository.addRuntimeFieldExtractor(customMetadataExtractor) to write the custom identifier into the meta property of the transmitted data.
[0080] Understandably, the repository.addRuntimeFieldExtractor method implemented by the custom identifier writing device can still extract fields as identifiers from the data document being transmitted, or obtain the identifiers set by Elasticsearch. That is, it expands the functionality by recognizing the user-inputted custom identifiers and writing them into meta attributes while retaining the original functionality.
[0081] S207, based on the target output format class, transmits metadata attributes and transmission data together.
[0082] Specifically, the custom identifier writing device can transmit the meta attribute along with the data. Because the custom identifier is written to the meta attribute, it achieves the purpose of transmitting the custom identifier along with the data, serving as an identifier for the transmitted data and realizing the customization of the identifier. The custom identifier writing device can construct a target output format class, which can inherit from the output format (org.elasticsearch.hadoop.mr.EsOutputFormat) base class. The org.elasticsearch.hadoop.mr.EsOutputFormat class is used to write the transmitted data output from Hadoop to Elasticsearch, which can simplify the data import process and improve data storage efficiency. The target output format class inherits from the org.elasticsearch.hadoop.mr.EsOutputFormat class, which retains its data writing functionality. Based on the org.elasticsearch.hadoop.mr.EsOutputFormat class, a target record writing class is instantiated to write the user-inputted custom identifier into the meta attribute of the transmitted data and then transmit the data. This allows for the writing of custom identifiers into the meta attribute of the transmitted data without changing the Elasticsearch-Hadoop source code or retaining the original Elasticsearch-Hadoop functionality, thus enabling the customization of identifiers.
[0083] In this embodiment, based on the setting method in the target metadata extraction class, a custom identifier input by the user for the transmitted data is obtained and written into a first variable. Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable, implementing the setting and retrieval methods for the custom identifier. This encapsulates the object's internal data, maintains the object's internal data structure and constraints, and ensures that the value of the custom identifier can be correctly written and retrieved, thus guaranteeing the consistency and integrity of the custom identifier before and after. Based on the target metadata extraction class, the metadata attributes of the transmitted data are obtained. In the target metadata extraction class, a method for obtaining instantiated objects using the singleton pattern is implemented. The singleton pattern saves resources, controls access to shared resources, avoids unnecessary object creation, and thus improves system performance. Based on the target record writing class, the custom identifier is assigned to a second variable. Based on the write method in the target record writing class, the custom identifier in the second variable is written into the metadata attributes of the transmitted data. The data identifier setting method is called to establish the association between the custom identifier and the input data, which helps to correctly store and retrieve the transmitted data. Based on the target output format class, the metadata attributes and the transmitted data are processed together during transmission. By rewriting various methods in Elasticsearch-Hadoop, the extraction and writing of custom identifiers into the metadata attributes of the transmitted data is realized, enabling the use of custom identifiers to identify and index the transmitted data, thereby realizing the personalized settings of identifiers by users.
[0084] The following will be combined with the appendix Figure 4 -Appendix Figure 6 This application provides a detailed description of the custom identifier writing device provided in the embodiments. It should be noted that... Figure 4 -Appendix Figure 6 The custom identifier writing device in the application is used to execute this application. Figures 1-3 The methods shown in the embodiments are for illustrative purposes only, illustrating the parts relevant to the embodiments of this application. For specific technical details not disclosed, please refer to this application. Figures 1-3 The example shown.
[0085] Please see Figure 4 This illustration shows a schematic diagram of a custom identifier writing device provided in an exemplary embodiment of this application. The custom identifier writing device can be implemented as all or part of a device through software, hardware, or a combination of both. The device 1 includes an identifier acquisition unit 11, a metadata extraction unit 12, an identifier writing unit 13, and a transmission processing unit 14.
[0086] The identifier acquisition unit 11 is used to receive a user-inputted custom identifier for transmitted data;
[0087] Metadata extraction unit 12 is used to obtain the metadata attributes of the transmitted data based on the target metadata extraction class;
[0088] The identifier writing unit 13 is used to write the custom identifier into the metadata attribute based on the writing method in the target record writing class;
[0089] The transmission processing unit 14 is used to transmit the metadata attributes and the transmission data together.
[0090] In this embodiment, a custom identifier input by the user for the transmitted data is received. Based on the target metadata extraction class, the metadata attributes of the transmitted data are obtained. Based on the write method in the target record writing class, the custom identifier is written into the metadata attributes. The metadata attributes and the transmitted data are then transmitted together. By writing the user-inputted custom identifier into the metadata attributes of the transmitted data, the transmitted data can be identified and indexed using the custom identifier, thereby realizing the user's personalized settings for the identifier.
[0091] Please see Figure 5 This illustration shows a schematic diagram of a custom identifier writing device provided in an exemplary embodiment of this application. The custom identifier writing device can be implemented as all or part of a device through software, hardware, or a combination of both. The device 1 includes an identifier acquisition unit 11, a metadata extraction unit 12, an identifier writing unit 13, a data identification unit 15, a singleton pattern unit 16, and a transmission processing unit 14.
[0092] The identifier acquisition unit 11 is used to receive a user-inputted custom identifier for transmitted data;
[0093] Optionally, the identifier acquisition unit 11 is specifically used to acquire the user's custom identifier for the transmitted data based on the setting method in the target metadata extraction class, and write the custom identifier into the first variable, wherein the target metadata extraction class is constructed based on the metadata extraction abstract class;
[0094] Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable.
[0095] Metadata extraction unit 12 is used to obtain the metadata attributes of the transmitted data based on the target metadata extraction class;
[0096] The identifier writing unit 13 is used to write the custom identifier into the metadata attribute based on the writing method in the target record writing class;
[0097] Optional, please see also Figure 6 A schematic diagram of an identifier writing unit is provided for an embodiment of this application. As shown in the figure, the identifier writing unit 13 may include:
[0098] The identifier assignment subunit 131 is used to assign the custom identifier to the second variable based on the target record writing class, wherein the target record writing class is constructed based on the record writing base class;
[0099] The identifier writing subunit 132 is used to write the custom identifier in the second variable into the metadata attribute of the transmitted data based on the writing method in the target record writing class.
[0100] Optionally, the identifier writing subunit 132 is specifically used to write the custom identifier in the second variable into the metadata attribute by calling the metadata attribute dynamic setting method in the writing method in the target record writing class.
[0101] Data identification unit 15 is used to establish the association between the custom identifier and the input data by calling the data identification setting method in the writing method in the target record writing class;
[0102] Singleton pattern unit 16 is used to implement a method for obtaining an instantiated object in the singleton pattern in the target metadata extraction class;
[0103] The transmission processing unit 14 is used to transmit the metadata attributes and the transmission data together.
[0104] Optionally, the transmission processing unit 14 is specifically used to transmit the metadata attributes and the transmission data together based on the target output format class, wherein the target output format class is constructed based on the output format base class.
[0105] In this embodiment, based on the setting method in the target metadata extraction class, a custom identifier input by the user for the transmitted data is obtained and written into a first variable. Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable, implementing the setting and retrieval methods for the custom identifier. This encapsulates the object's internal data, maintains the object's internal data structure and constraints, and ensures that the value of the custom identifier can be correctly written and retrieved, thus guaranteeing the consistency and integrity of the custom identifier before and after. Based on the target metadata extraction class, the metadata attributes of the transmitted data are obtained. In the target metadata extraction class, a method for obtaining instantiated objects using the singleton pattern is implemented. The singleton pattern saves resources, controls access to shared resources, avoids unnecessary object creation, and thus improves system performance. Based on the target record writing class, the custom identifier is assigned to a second variable. Based on the write method in the target record writing class, the custom identifier in the second variable is written into the metadata attributes of the transmitted data. The data identifier setting method is called to establish the association between the custom identifier and the input data, which helps to correctly store and retrieve the transmitted data. Based on the target output format class, the metadata attributes and the transmitted data are processed together during transmission. By rewriting various methods in Elasticsearch-Hadoop, the extraction and writing of custom identifiers into the metadata attributes of the transmitted data is realized, enabling the use of custom identifiers to identify and index the transmitted data, thereby realizing the personalized settings of identifiers by users.
[0106] It should be noted that the custom identifier writing device provided in the above embodiments is only illustrated by the division of the above functional modules when executing the custom identifier writing method. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the custom identifier writing device and the custom identifier writing method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.
[0107] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0108] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figures 1-3 The custom identifier writing method described in the illustrated embodiment can be found in the following documentation for a detailed execution process: Figures 1-3 The specific details of the illustrated embodiments will not be elaborated here.
[0109] This application also provides a computer program product storing at least one instruction, which is loaded and executed by the processor as described above. Figures 1-3 The custom identifier writing method described in the illustrated embodiment can be found in the following documentation for a detailed execution process: Figures 1-3 The specific details of the illustrated embodiments will not be elaborated here.
[0110] Please refer to Figure 7 This diagram illustrates a structural block diagram of an electronic device provided in an exemplary embodiment of this application. The electronic device in this application may include one or more components such as a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, memory 120, input device 130, and output device 140 may be connected via the bus 150.
[0111] Processor 110 may include one or more processing cores. Processor 110 connects to various parts of the electronic device using various interfaces and lines, and executes various functions of terminal 100 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 120, and by calling data stored in memory 120. Optionally, processor 110 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 110 may integrate one or more of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user page, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 110 and may be implemented separately using a communication chip.
[0112] The memory 120 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 120 may include non-transitory computer-readable storage medium. The memory 120 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described above, etc. The operating system may be the Android system, including systems deeply developed based on the Android system, the iOS system developed by Apple Inc., including systems deeply developed based on the iOS system, or other systems.
[0113] The memory 120 can be divided into operating system space and user space. The operating system runs in the operating system space, while native and third-party applications run in user space. To ensure that different third-party applications can achieve good running performance, the operating system allocates corresponding system resources for each application. However, different application scenarios within the same third-party application have different requirements for system resources. For example, in local resource loading scenarios, third-party applications have high requirements for disk read speed; in animation rendering scenarios, third-party applications have high requirements for GPU performance. Since the operating system and third-party applications are independent of each other, the operating system often cannot promptly perceive the current application scenario of a third-party application, resulting in the operating system's inability to adapt system resources accordingly.
[0114] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to establish data communication between the third-party applications and the operating system. This would allow the operating system to obtain the current scenario information of the third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.
[0115] The input device 130 is used to receive input instructions or data, and includes, but is not limited to, a keyboard, mouse, camera, microphone, or touch device. The output device 140 is used to output instructions or data, and includes, but is not limited to, a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 can be a touch display screen.
[0116] The touch display screen can be designed as a full-screen, curved screen, or irregularly shaped screen. It can also be designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen; however, this application does not limit the specific design in this regard.
[0117] In addition, those skilled in the art will understand that the structure of the electronic device shown in the above figures does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the electronic device may also include radio frequency circuits, input units, sensors, audio circuits, Wireless Fidelity (WiFi) modules, power supplies, Bluetooth modules, etc., which will not be described in detail here.
[0118] exist Figure 7 In the illustrated electronic device, processor 110 can be used to call a custom identifier stored in memory 120 to write to an application program, and specifically perform the following operations:
[0119] Receive user-defined identifiers for transmitted data;
[0120] Based on the target metadata extraction class, obtain the metadata attributes of the transmitted data;
[0121] Based on the write method in the target record write class, the custom identifier is written to the metadata attribute;
[0122] The metadata attributes and the transmission data are transmitted together.
[0123] In one embodiment, when the processor 110 executes the operation of receiving a custom identifier from the user for transmitted data, it specifically performs the following operations:
[0124] Based on the setting method in the target metadata extraction class, the user's custom identifier for the transmitted data is obtained, and the custom identifier is written into the first variable. The target metadata extraction class is constructed based on the metadata extraction abstract class.
[0125] Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable.
[0126] In one embodiment, when the processor 110 executes the write method based on the target record write class to write the custom identifier to the metadata attribute, it specifically performs the following operations:
[0127] The custom identifier is assigned to the second variable based on the target record writing class, wherein the target record writing class is constructed based on the record writing base class;
[0128] Based on the write method in the target record write class, the custom identifier in the second variable is written into the metadata attribute of the transmitted data.
[0129] In one embodiment, when the processor 110 executes the write method based on the target record write class to write the custom identifier in the second variable into the metadata attribute of the transmitted data, it specifically performs the following operations:
[0130] By calling the metadata attribute dynamic setting method in the write method of the target record write class, the custom identifier in the second variable is written into the metadata attribute.
[0131] In one embodiment, when executing the custom identifier writing method, the processor 110 also performs the following operations:
[0132] The association between the custom identifier and the input data is established by calling the data identifier setting method in the write method within the target record write class.
[0133] In one embodiment, when the processor 110 performs the process of transmitting the metadata attributes and the transmission data together, it specifically performs the following operations:
[0134] Based on the target output format class, the metadata attributes and the transmitted data are transmitted together, wherein the target output format class is constructed based on the output format base class.
[0135] In one embodiment, when executing the custom identifier writing method, the processor 110 also performs the following operations:
[0136] In the target metadata extraction class, a method for obtaining the instantiated object using the singleton pattern is implemented.
[0137] In this embodiment, based on the setting method in the target metadata extraction class, a custom identifier input by the user for the transmitted data is obtained and written into a first variable. Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable, implementing the setting and retrieval methods for the custom identifier. This encapsulates the object's internal data, maintains the object's internal data structure and constraints, and ensures that the value of the custom identifier can be correctly written and retrieved, thus guaranteeing the consistency and integrity of the custom identifier before and after. Based on the target metadata extraction class, the metadata attributes of the transmitted data are obtained. In the target metadata extraction class, a method for obtaining instantiated objects using the singleton pattern is implemented. The singleton pattern saves resources, controls access to shared resources, avoids unnecessary object creation, and thus improves system performance. Based on the target record writing class, the custom identifier is assigned to a second variable. Based on the write method in the target record writing class, the custom identifier in the second variable is written into the metadata attributes of the transmitted data. The data identifier setting method is called to establish the association between the custom identifier and the input data, which helps to correctly store and retrieve the transmitted data. Based on the target output format class, the metadata attributes and the transmitted data are processed together during transmission. By rewriting various methods in Elasticsearch-Hadoop, the extraction and writing of custom identifiers into the metadata attributes of the transmitted data is realized, enabling the use of custom identifiers to identify and index the transmitted data, thereby realizing the personalized settings of identifiers by users.
[0138] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0139] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
[0140] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the custom identifiers involved in this specification were all obtained under full authorization.
Claims
1. A self-defined identifier writing method, characterized by, The method includes: Receive user-defined identifiers for transmitted data; Based on the target metadata extraction class, obtain the metadata attributes of the transmitted data; Based on the write method in the target record write class, the custom identifier is written to the metadata attribute; The metadata attributes and the transmission data are transmitted together.
2. The method of claim 1, wherein, The user-inputted custom identifier for the transmitted data includes: Based on the setting method in the target metadata extraction class, the user's custom identifier for the transmitted data is obtained, and the custom identifier is written into the first variable. The target metadata extraction class is constructed based on the metadata extraction abstract class. Based on the value retrieval method in the target metadata extraction class, the custom identifier is called in the first variable.
3. The method of claim 1, wherein, The write method in the target record write class, which writes the custom identifier into the metadata attribute, includes: The custom identifier is assigned to the second variable based on the target record writing class, wherein the target record writing class is constructed based on the record writing base class; Based on the write method in the target record write class, the custom identifier in the second variable is written into the metadata attribute of the transmitted data.
4. The method of claim 3, wherein, The write method based on the target record write class, which writes the custom identifier in the second variable into the metadata attribute of the transmitted data, includes: By calling the metadata attribute dynamic setting method in the write method of the target record write class, the custom identifier in the second variable is written into the metadata attribute.
5. The method of claim 4, wherein, The method further includes: The association between the custom identifier and the input data is established by calling the data identifier setting method in the write method within the target record write class.
6. The method of claim 1, wherein, The process of transmitting the metadata attributes and the transmission data together includes: Based on the target output format class, the metadata attributes and the transmitted data are transmitted together, wherein the target output format class is constructed based on the output format base class.
7. The method of claim 1, wherein, The method further includes: In the target metadata extraction class, a method for obtaining the instantiated object using the singleton pattern is implemented.
8. A custom identifier writing apparatus, characterized by, The device includes: The identifier acquisition unit is used to receive custom identifiers input by the user for the transmitted data; Metadata extraction unit, used to obtain metadata attributes of the transmitted data based on the target metadata extraction class; The identifier writing unit is used to write the custom identifier into the metadata attribute based on the write method in the target record writing class; A transmission processing unit is used to process the metadata attributes and the transmission data together for transmission.
9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, which are adapted to be loaded by a processor and executed as method steps as claimed in any one of claims 1 to 7.
10. An electronic device, comprising: include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the method steps as claimed in any one of claims 1 to 7.