Storage and Streams

Structured Storage

How Structured Storage Increases Performance

Structured storage provides a simple way to store objects and compound files. Its purpose is to reduce the performance penalties and overhead associated with storing separate objects in a flat file. Instead, COM stores the separate objects in a single, structured file consisting of two main elements: storage objects and stream objects. Together they function like a file system within a file. Like a file, a stream contains data stored as a consecutive sequence of bytes.

Nested Objects

A COM compound file consists of a root storage object containing at least one stream object representing its native data along with one or more storage objects corresponding to its linked and embedded objects. The root storage object maps to a file name in whatever file system it happens to reside in. A storage object containing one or more stream objects, and perhaps also containing one or more substorage objects, also represents each of the objects inside the document. In this way, a document can consist of an unlimited number of nested objects.

For example, if a Word document contained an Excel chart, the root object would be the storage object of the Word document. This would contain the native data and OLE data for the Word object. In addition, it would contain the storage object for the Excel chart. The Excel chart storage object would contain the native data and OLE data for the Excel object.

click to view at full size.

Figure 5.11 Nested Objects

Modifying or Adding New Objects

The file does not have to be rewritten to storage when a new object is added to a compound file; it also does not have to be rewritten if an existing object increases in size . Instead, the new data is written to the next available location in permanent storage, and the storage object updates the table of pointers it maintains to track the locations of its storage objects and stream objects. This increases overall performance. At the same time, structured storage enables end users to interact and manage a compound file as if it were a single file rather than a nested hierarchy of separate objects.

Additional Benefits

Structured storage provides additional benefits:

  • Incremental Access

    If a user needs access to an object within a compound file, the user can load and save that object alone, rather than the entire file.

  • Multiple use

    More than one end user or application can read and write information in the same compound file at one time.

  • Transaction processing

    Users can read or write to COM compound files in transacted mode, where changes made to the file are buffered and can subsequently be committed to the file or reversed .

  • Low memory saves

    Structured storage allows files to be saved in low memory situations.



Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net