Tuples Introduction The purpose of a Tuple is to contain data in the form of single or multiple fields. The data in each field has a size and alignment restrictions. Some fields will be fixed size, where the size is known ahead of time. Other fields will be variable length, the size of that data will not be known until runtime. Some of the fields in the tuple may not have a value associated with them; these are known as null values. As such, the tuple will need some indicator to record which fields have valid, though perhaps empty, values, and which fields do not contain a value. The tuple does not care about the type of the data that it holds. Int, float, double, string, bitmap, whatever, it is all just bits to the tuple. Tuples are simple, contigous, in-memory data structures which are self-referential and self-contained. A tuple may be copied to a new address and be used there. A tuple may be copied to disk and brought back into memory. Tuples assume that the memory which they exist in are aligned cor- rectly for their own and their contained fields. A individual tuple knows nothing about it's own struc- ture, except for it's overall size -- which it may not actu- ally know anyway, as whatever uses the tuple will know it's size. Components A tuple is really several things. A tuple is a chunk of memory with a size that is treated opaquely and may be copied around as any other chunk of memory can. A tuple is the actual representation of the tuple which is contained in the chunk of memory. There is some per- tuple meta-information, the null bitmap, which is itself just an ordinary field in the tuple. Typically the null bitmap is followed by the fixed length attributes in the tuple, including the fixed length portions of the variable length attributes. Lastly, there ia a heap of the variable sized data contained in the tuple. -2- A tuple has a list of what offsets data are found at in the tuple, and what the type, fixed or variable, of that data is. A tuple is the class which, given a pointer to a tuple body and a list of tuple offsets, can provide address and size information of data in that tuple to whatever desires to access that data. This class is also the entity which creates new tuples and tells a controlling entity their overall size. A tuple has a layout engine which, given a list of data to be placed in a tuple, determines where in the tuple that data will be positioned and what its actual field number is. Converesely, if field ordering is important or convenient to the agent wanting to use a tuple, it generates a mapping list which converts attribute numbers which the application uses into internal attribute numbers. A reverse list may be needed also. A tuple with all fields of fixed size has its size known a-priori. Tuples with variable fields are of unknown size. When a tuple with variable size fields is created its final size is not known until all variable sized fields have been sized. In this situation the result tuple can not be built in-situ, but may need to be built and expanded until it all data is present. If all the info about the variable sized fields is known in advance, it is possible for the final size of the tuple to be known, and space allocated for it in its final resting place. This is especially important for projection of data from other tuples. Interface A tuple provides storage for fields. It is a mecha- nism, not a policy. It does not copy data into and out of the fields, for that would be a policy. Instead it just provides the address and length of the field and allows the user to decide how it should be accessed.