# Patent

## Title
System for lightweight objects

## Abstract

Creating an object is disclosed. An instance of a sharable type is created. An instance of a lightweight type is created. The sharable type is designated as a parent of the lightweight type. The instance of the sharable type is designated as a parent of the instance of the lightweight type. The instance of the sharable type may be shared by one or more other instances of the lightweight type.

## Background
CROSS REFERENCE TO OTHER APPLICATIONS
This application is a continuation of U.S. patent application Ser. No. 13/161,580, now U.S. Pat. No. 8,560,572, entitled “SYSTEM FOR LIGHTWEIGHT OBJECTS”, filed Jun. 16, 2011, which is incorporated herein by reference for all purpose; which is a continuation of U.S. patent application Ser. No. 11/906,185, now U.S. Pat. No. 7,987,210, entitled “SYSTEM FOR LIGHTWEIGHT OBJECTS”, filed Sep. 28, 2007, which is incorporated herein by reference for all purposes.


BACKGROUND OF THE INVENTION
Object classes that have inherited class behavior(s) and/or other data typically have instances of the object represented in memory as an instance of the object and an instance of any class object from which the object inherits behavior(s) and/or data. Similarly, when storing the object, particularly when storing the object in a database, the object instance along with any class object instance inherited from are stored together. If objects inherit from the same class object, then the class object instance is stored for each of the objects. This duplication of stored class object instances leads to inefficient use of memory and/or storage space.



BRIEF DESCRIPTION OF THE DRAWINGS
Various embodiments of the invention are disclosed in the following detailed description and the accompanying drawings.
FIG. 1 is a block diagram of a system for lightweight objects.
FIG. 2 is a block diagram illustrating an embodiment of a heavyweight type and heavyweight instance.
FIG. 3 is a block diagram illustrating an embodiment of a heavyweight type and instance stored in a database.
FIG. 4A is a block diagram illustrating an embodiment of a lightweight type.
FIG. 4B is a block diagram illustrating an embodiment of a lightweight instance.
FIG. 5 is a block diagram illustrating an embodiment of a lightweight type, a sharable type, and a lightweight instance stored in a database.
FIG. 6 is a flow diagram illustrating an embodiment of a process for creating a lightweight instance.
FIG. 7A is a flow diagram illustrating an embodiment of a process for accessing a lightweight composite object instance.
FIG. 7B is a flow diagram illustrating an embodiment of a process for deleting a lightweight composite object instance.
FIG. 8 is a flow diagram illustrating an embodiment of a process for materializing a lightweight instance.
FIG. 9 is a flow diagram illustrating an embodiment of a process for converting heavyweight instance(s) to lightweight instance(s).
FIG. 10 is a flow diagram illustrating an embodiment of reparenting and materializing.



DETAILED DESCRIPTION
The invention can be implemented in numerous ways, including as a process, an apparatus, a system, a composition of matter, a computer readable medium such as a computer readable storage medium or a computer network wherein program instructions are sent over optical or communication links. In this specification, these implementations, or any other form that the invention may take, may be referred to as techniques. A component such as a processor or a memory described as being configured to perform a task includes both a general component that is temporarily configured to perform the task at a given time or a specific component that is manufactured to perform the task. In general, the order of the steps of disclosed processes may be altered within the scope of the invention.
A detailed description of one or more embodiments of the invention is provided below along with accompanying figures that illustrate the principles of the invention. The invention is described in connection with such embodiments, but the invention is not limited to any embodiment. The scope of the invention is limited only by the claims and the invention encompasses numerous alternatives, modifications and equivalents. Numerous specific details are set forth in the following description in order to provide a thorough understanding of the invention. These details are provided for the purpose of example and the invention may be practiced according to the claims without some or all of these specific details. For the purpose of clarity, technical material that is known in the technical fields related to the invention has not been described in detail so that the invention is not unnecessarily obscured.
A system for lightweight objects is disclosed. A sharable type includes shared class objects—for example, an object that provides to a plurality of lower lightweight type objects by way of inheritance its behaviors and other data. One or more “lightweight” type objects have a sharable type as a parent. Memory and storage savings are achieved by having a plurality of lightweight type objects (and instances thereof) refer to a single sharable type (and instance thereof) as a parent because only a single copy of the sharable type and/or its instance can be stored instead of a copy for each lightweight type composite object as is done for a “heavyweight” type object.
In some embodiments, a sharable type is declared (e.g., created or modified from a previously declared non-sharable type). A lightweight type is declared (e.g., created, modified from a previously declared heavyweight type, or created as a subtype of another lightweight type), where the sharable type is designated as a parent of the lightweight type. An instance is created of the sharable type. An instance is created of the lightweight type, where the instance of the sharable type is designated as the parent of the instance of the lightweight type.
In some embodiments, the composite of a lightweight type and a sharable type or instances thereof perform similarly to a heavyweight object. For example, access to data in the composite of the lightweight type and sharable type or instances thereof perform similarly to accesses to data of a similar heavyweight type. Further, the access produces similar results regardless of whether a user or an application accesses a lightweight object or a corresponding similar heavyweight object.
In some embodiments, a lightweight composite object is materialized to create a new lightweight composite object. For example, a change is requested for data or behavior stored associated with the sharable portion of the composite object. The requested change would potentially impact other lightweight composite objects that share the sharable portion. A copy or clone is made of the sharable portion of the composite object and a new composite object is created from the copy or clone of the sharable portion along with any other appropriate lightweight objects.
In some embodiments, heavyweight instance(s) is/are converted to a lightweight instance(s). A selection of one or more heavyweight instances is received. From the heavyweight instances and associated heavyweight types, sharable parent types and instances are identified and created. From the heavyweight instances and associated heavyweight types, lightweight types and instances are identified and created. For each lightweight type and instance, a sharable type or instance is designated as parent. A switch is made to using the new lightweight instances. The original selected heavyweight instances are preserved in case the lightweight instances do not perform similar to the heavyweight instances. The switch to using the lightweight instances is validated. Validation includes determining whether the lightweight instances perform similarly to the heavyweight instances. If the performance is satisfactory, then the switch is committed. In various embodiments, committing includes deleting the selected heavyweight instances and/or types, archiving the selected heavyweight instances and or types, and any other appropriate action for committing to a switch.
Note that in this specification a type and a class are used interchangeably with regard to objects.
FIG. 1 is a block diagram of a system for lightweight objects. In the example shown, run-time engine 100 processes objects that are class-based hierarchical objects. In some embodiments, run-time engine 100 is a java-based engine that processes objects which may be part of a subclass that inherits attributes and/or behaviors and/or other data from a class. In various embodiments, the inherited data comprise one or more of the following: security data, content data, retention data, policy data, lifecycle data, version data. Run-time engine 100 uses memory 102 to store information during the execution of commands. In some embodiments, memory 102 comprises the processing memory, such as random access memory storing registers or other data, for a processor running run-time engine 100. Run-time engine 100 is able to communicate with content server 104. Content server 104 manages content stored in database storage 106. In some embodiments, database 106 comprises a data repository for content server 104. Management of content by content server 104 includes functionality to search, version, retain, secure, apply policy, process using business processes, or any other appropriate content management functionality.
FIG. 2 is a block diagram illustrating an embodiment of a heavyweight type and heavyweight instance. In some embodiments, heavyweight types and heavyweight instances are processed using a run-time engine such as run-time engine 100 of FIG. 1. In some embodiments, the heavyweight instances, while being processed using the run-time engine, are stored in memory such as memory 102 of FIG. 1. In the example shown, heavyweight type 230 includes base class 200 subclassA 202 and subclassB 204. SubclassB 204 inherits behavior and other data from subclassA 202 and base class 200. Heavyweight instance 220 includes correspondingly instance of base class 210, instance of subclassA 212 (an instance of subclassA 202), and instance of subclassB 214 (an instance of subclassB 204). Instance of subclassB 214 inherits behavior and other data from instance subclassA 212 and instance base class 210.
Note that in the event that there are a plurality of instances of subclassB 214, each have their own copy of subclassA 212 and base class 210. Each of the plurality of instances of subclassB 214 may be different with regard to data associated with each of the instances. However, regardless of whether all copies of subclassA 212 are identical and all copies of base class 210 are identical, each of the plurality of instances of subclassB 214 has a copy of both subclassA 212 and base class 210.
Also, a second heavyweight type that includes base class 200, subclassA 202, and subclassC (not shown in FIG. 2) would similarly have potential redundant storage of base class 200 and subclassA 202 type objects and corresponding instance objects.
FIG. 3 is a block diagram illustrating an embodiment of a heavyweight type and instance stored in a database. In some embodiments, the heavyweight instance stored is a heavyweight instance such as heavyweight instance 220 of FIG. 2; the heavyweight type is a heavyweight type such as heavyweight type 230 of FIG. 2; and the database storing the heavyweight instance and heavyweight type is a database such as database 106 of FIG. 1. In the example shown, database 300 stores heavyweight type 301 and a plurality of heavyweight instances, represented in FIG. 3 as heavyweight instance 302 and heavyweight instance 304.
FIG. 4A is a block diagram illustrating an embodiment of a lightweight type. In some embodiments, lightweight types are stored in a database such as database 106 of FIG. 1. In the example shown, lightweight composite object type 400 includes base class 402 subclassA 404 and subclassB 406. SubclassB 406 inherits behavior and other data from subclassA 404 and base class 402. Base class 402 and subclassA 404 comprise a sharable type. SubclassB comprises a lightweight type.
FIG. 4B is a block diagram illustrating an embodiment of a lightweight instance. In some embodiments, lightweight instances are processed using a run-time engine such as run-time engine 100 of FIG. 1. In some embodiments, lightweight instances, while being processed using the run-time engine, are stored in memory such as memory 102 of FIG. 1. In the example shown, lightweight composite object instance 410 includes instance of base class 412, instance of subclassA 414 (an instance of subclassA 404), and instance of subclassB 416 (an instance of subclassB 406). Lightweight composite object instance 430 includes instance of base class 412, instance of subclassA 414 (an instance of subclassA 404), and instance of subclassB 436 (an instance of subclassB 406). Lightweight composite object instance 420 (not shown in FIG. 4B) includes instance of base class 412, instance of subclassA 414 (an instance of subclassA 404), and instance of subclassB 426 (an instance of subclassB 406). Instance of subclassB 426 inherits behavior and other data from instance subclassA 414 and instance base class 412. Instance of subclassB 436 inherits behavior and other data from instance subclassA 414 and instance base class 412.
A lightweight composite object instance such as lightweight composite object instance 410, lightweight composite object instance 420, and lightweight composite object instance 430 and behave and perform similarly to a heavyweight instance such as heavyweight instance 220 of FIG. 2.
Note there are a plurality of instances of subclassB 406, each share a copy of an instance of subclassA 404 and an instance of base class 402 (e.g., instance of subclassA 414 and instance of base class 412, respectively—a sharable instance). Each of the plurality of instances of subclassB 406 (e.g., instance of subclassB 416, instance of subclassB 426, and instance of subclassB 436) may be different with regard to data associated with each of the instances.
Also, a second lightweight type that includes base class 402, subclassA 404, and subclassC (not shown in FIG. 4) would similarly have the potential for sharing the stored of base class 402 and subclassA 404 type objects (e.g., a sharable type) and corresponding instance objects (e.g., a sharable instance).
FIG. 5 is a block diagram illustrating an embodiment of a lightweight type, a sharable type, and a lightweight instance stored in a database. In some embodiments, the lightweight instance stored is a lightweight instance such as lightweight instance 410 or lightweight instance 430 of FIG. 4B; the lightweight type is a lightweight type such as lightweight type 400 of FIG. 4A; and the database storing the lightweight instance, lightweight type and sharable type is a database such as database 106 of FIG. 1. In the example shown, database 500 stores lightweight type 510, sharable type 501, sharable instance 520, and a plurality of lightweight instances, represented in FIG. 5 as lightweight instances 502 and lightweight instance 504. Note lightweight instances share an instance (i.e., sharable instance 520) of sharable type 501. Sharable instance 520 and lightweight instance 502 comprise lightweight composite object instance 530. Sharable instance 520 and lightweight instance 504 comprise a lightweight composite object instance (not indicated in FIG. 5).
FIG. 6 is a flow diagram illustrating an embodiment of a process for creating a lightweight instance. In some embodiments, the process of FIG. 6 is executed using a run-time engine (e.g., run-time engine 100 of FIG. 1) and/or using processing available with regard to a content server (e.g., content server 104 of FIG. 1). In the example shown, in 600 an indication is received to create a lightweight instance. In 602, a sharable type is declared, if appropriate. In the event that the sharable type exists, the sharable type is not declared. In various embodiments, a new sharable type is created, a previously declared non-sharable type is modified, or any other appropriate manner of declaring a sharable type. In 604, a lightweight type is declared, if appropriate, where the sharable type is designated as a parent of the lightweight type. In the event that the lightweight type exists, the lightweight type is not declared. In various embodiments, a new lightweight type is created, a previously declared heavyweight type is modified, a subtype of another lightweight type is created, or any other appropriate manner of declaring a lightweight type. In 606, an instance of the sharable type is created, if appropriate. In the event that the instance of the sharable type exists, the instance of the sharable type is not declared. In 608, an instance of the lightweight type is created, where the instance of the sharable type is designated as the parent of the instance of the lightweight type.
In some embodiments, changing of attributes, behaviors, and/or other data is avoided for attributes, behaviors, and/or other data associated with the sharable parent of a lightweight composite object; a change in these attributes, behaviors, and/or other data associated with the sharable parent will require the creation of a new instance of the sharable parent type that is designated as the parent for the lightweight type. In some embodiments, the creation of a new instance of the sharable parent type is referred to as materialization. In some embodiments, the system automatically executes a materialization process in the event that an attribute, behavior, and/or other data associated with the sharable parent is/are changed or modified for a given lightweight type. In some embodiments, the automatic execution of the creation of the new sharable parent type and instance is referred to as self-materialization.
FIG. 7A is a flow diagram illustrating an embodiment of a process for accessing a lightweight composite object instance. In some embodiments, the process of FIG. 7A is used to access a lightweight composite object instance such as lightweight composite object instance 410 of FIG. 4B. In the example shown, in 700 a request is received to access a lightweight composite object instance. In 702, the lightweight instance of the lightweight composite object instance is accessed, if appropriate. In 704, the sharable instance of the lightweight composite object instance is accessed, if appropriate. In some embodiments, a data aggregator is accessed that determines whether to access the lightweight instance and/or the sharable instance.
FIG. 7B is a flow diagram illustrating an embodiment of a process for deleting a lightweight composite object instance. In some embodiments, the process of FIG. 7B is used to delete a lightweight composite object instance such as lightweight composite object instance 410 of FIG. 4B. In the example shown, in 710 a request is received to delete a lightweight composite object instance. In 712, the lightweight instance of the lightweight composite object instance is deleted. In 714, the sharable instance of the lightweight composite object instance is deleted, if appropriate. In some embodiments, a sharable instance deleted determines whether to delete the sharable instance (e.g., by determining if the sharable instance is being shared by any other lightweight instance(s)).
FIG. 8 is a flow diagram illustrating an embodiment of a process for materializing a lightweight instance. In the example shown, in 800 an indication is received to materialize a lightweight instance. In 802, an instance of the sharable type is cloned to create a new instance of the sharable type, where the instance of the sharable type was designated as the parent of the lightweight instance. In 804, the instance of the sharable type is removed from being designated as the parent of the lightweight instance. In 806, the new instance of the sharable type is designated as being the parent of the lightweight instance.
In some embodiments, the indication to materialize a lightweight instance is a consequence of receiving an indication to modify an attribute, behavior, or other data associated with a lightweight composite object instance where the attribute, behavior, or other data is associated with the sharable instance of the lightweight composite object instance; the lightweight instance is materialized so that a modification to the attribute, behavior, or other data does not propagate unintentionally to other lightweight composite object instances that share the sharable instance. The modification can then be made to the new sharable instance that is now a part of a new lightweight composite object without the modification impacting other lightweight composite objects.
FIG. 9 is a flow diagram illustrating an embodiment of a process for converting heavyweight instance(s) to lightweight instance(s). In the example shown, in 900 an indication is received to convert heavyweight instance(s) to lightweight instance(s). In 902, a selection is received of heavyweight instance(s). In 904, sharable parent(s) of selected heavyweight instance(s) are identified and altered. For example, a group of heavyweight instances are identified as sharing a common set of higher class types; and the corresponding heavyweight type will be altered to be a sharable parent type that includes the common set of higher class types. In 905, sharable parent instances are created. In 906, lightweight types and instances of lightweight types are identified and altered. For example, for a group of heavyweight instances that have been identified as sharing a common set of higher class types, the lower class types that are not shared for the group are identified as lightweight types; the corresponding heavyweight types will be altered to be the lightweight types that include the lower class types. In 907, lightweight instances of the types are created. In 908, for each lightweight type and instance of the lightweight type, a sharable parent or instance of a sharable parent is designated. In 910, a switch is made to use of the lightweight instances, while preserving the heavyweight instances. In 912, the switch is validated. Validating includes determining if the lightweight instances perform similar to the selected heavyweight types. In 914, the switch is committed. In various embodiments, committing the switch includes deleting the heavyweight instances, deleting the heavyweight types, archiving the heavyweight instances, archiving the heavyweight types, or any other appropriate action for committing a switch.
FIG. 10 is a flow diagram illustrating an embodiment of reparenting and materializing. In some embodiments, reparenting is used instead of materializing, where an existing sharable instance is appropriate and is reused instead of creating a new sharable instance. In the example shown, in 1000 an indication is received to materialize a lightweight instance. In 1002, it is determined whether there is an existing appropriate sharable instance. In the event that there is not an existing appropriate sharable instance, then in 1004, an instance of the sharable type is cloned to create a new instance of the sharable type, where the instance of the sharable type was designated as the parent of the lightweight instance. In 1006, the instance of the sharable type is removed from being designated as the parent of the lightweight instance. In 1008, the new instance of the sharable type is designated as being the parent of the lightweight instance, and the process ends. In the event that there is an existing appropriate sharable instance, then in 1010 the instance of the sharable type is removed for being designated as the parent of the lightweight instance. In 1012, the instance of the existing appropriate sharable type is designated as being the parent of the lightweight instance.
Although the foregoing embodiments have been described in some detail for purposes of clarity of understanding, the invention is not limited to the details provided. There are many alternative ways of implementing the invention. The disclosed embodiments are illustrative and not restrictive.

## Claims

1. A system for storing a lightweight type, comprising:
a hardware processor configured to:
declare a lightweight type, comprising:
identify a previously declared heavyweight type;

determine whether a sharable type associated with a lightweight type is available,

wherein a composite of the lightweight type and the shareable type associated with the lightweight type corresponds to the previously declared heavyweight type;
in an event that the sharable type is not available:
determine whether the previously declared heavyweight type is available;
in an event that the previously declared heavyweight type is available:
modify the previously declared heavyweight type to be a parent of the lightweight type; and

in an event that the previously declared heavyweight type is not available:
create in memory the sharable type, comprising:
 selecting one or more heavyweight type instances sharing a common set of one or more higher class types;
 altering a corresponding heavyweight type to be a sharable parent that includes the common set of one or more higher class types;
 creating one or more sharable parent instances based on the sharable parent;
identify and create in memory the lightweight type based on identifying one or more lower class types that are not shared among the one or more heavyweight type instances, wherein the sharable type is designated as a parent of the lightweight type, and wherein an instance of the sharable type is capable of being shared by one or more instances of the lightweight type;
create the one or more instances of the lightweight type; and
designate the sharable parent or an instance of the sharable parent for at least one of the lightweight type and the one or more instances of the lightweight type.

2. The system as in claim 1, wherein creating the sharable type comprises creating a new sharable type.

3. The system as in claim 1, wherein creating the sharable type comprises modifying a previously declared non-sharable type.

4. The system as in claim 1, wherein the hardware processor is further configured to receive an indication to create an object of the lightweight type.

5. The system as in claim 1, wherein declaring the lightweight type comprises creating a new lightweight type.

6. The system as in claim 1, wherein declaring the lightweight type comprises creating a subtype of another lightweight type.

7. The system as in claim 1, wherein the hardware processor is further configured to store in a database the sharable type.

8. The system as in claim 1, wherein the hardware processor is further configured to create in memory an instance of the sharable type.

9. The system as in claim 8, wherein the instance of the sharable type is stored in a database.

10. The system as in claim 1, wherein the hardware processor is further configured to store in a database an instance of the lightweight type.

11. The system as in claim 10, wherein the instance of the lightweight type is stored in a database.

12. The system as in claim 1, wherein the lightweight type is one of a plurality of lightweight types, wherein each of the plurality of lightweight types have the sharable type designated as a parent.

13. The system as in claim 1, wherein the lightweight type inherits behavior from the sharable type.

14. The system of claim 1, wherein the composite has similar behavior to the previously declared heavyweight type.

15. The system of claim 1, wherein the hardware processor is further configured to validate the lightweight type created in memory, wherein validation of the lightweight type comprises determining whether the one or more instances of the lightweight type perform similarly to an instance of the previously declared heavyweight type.

16. The system of claim 1, wherein an instance of the lightweight type inherits one or more of a behavior or data from the shareable type associated with the lightweight type.

17. A method for storing a lightweight type, comprising:
declaring a lightweight type, comprising:
identifying a previously declared heavyweight type;

determining, using a processor, whether a sharable type associated with a lightweight type is available, wherein a composite of the lightweight type and the shareable type associated with the lightweight type corresponds to the previously declared heavyweight type;
in an event that the sharable type is not available:
determining whether the previously declared heavyweight type is available;
in an event that the previously declared heavyweight type is available:
modifying the previously declared heavyweight type to be the lightweight type; and

in an event that the previously declared heavyweight type is not available:
creating in memory the sharable type, comprising:
selecting one or more heavyweight type instances sharing a common set of one or more higher class types;
altering a corresponding heavyweight type to be a sharable parent that includes the common set of one or more higher class types;
creating one or more sharable parent instances based on the sharable parent;

identifying and creating in memory the lightweight type based on identifying one or more lower class types that are not shared among the one or more heavyweight type instances, wherein the sharable type is designated as a parent of the lightweight type, and wherein an instance of the sharable type is capable of being shared by one or more instances of the lightweight type;
creating the one or more instances of the lightweight type; and
designating the sharable parent or an instance of the sharable parent for at least one of the lightweight type and the one or more instances of the lightweight type.

18. A computer program product for storing a lightweight type, the computer program product being embodied in a non-transitory computer readable medium and comprising computer instructions for:
declaring a lightweight type, comprising:
identifying a previously declared heavyweight type;

determining, using a processor, whether a sharable type associated with a lightweight type is available, wherein a composite of the lightweight type and the shareable type associated with the lightweight type corresponds to the previously declared heavyweight type;
in an event that the sharable type is not available:
determining whether the previously declared heavyweight type is available;
in an event that the previously declared heavyweight type is available:
modifying the previously declared heavyweight type to be the lightweight type; and

in an event that the previously declared heavyweight type is not available:
creating in memory the sharable type, comprising:
selecting one or more heavyweight type instances sharing a common set of one or more higher class types;
altering a corresponding heavyweight type to be a sharable parent that includes the common set of one or more higher class types;
creating one or more sharable parent instances based on the sharable parent;
identifying and creating in memory the lightweight type based on identifying one or more lower class types that are not shared among the one or more heavyweight type instances, wherein the sharable type is designated as a parent of the lightweight type, and wherein an instance of the sharable type is capable of being shared by one or more instances of the lightweight type;
creating the one or more instances of the lightweight type; and
designating the sharable parent or an instance of the sharable parent for at least one of the lightweight type and the one or more instances of the lightweight type.