Table E and FILEORG X'100' files (File architecture): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Holds Large Object Data (BLOBs and CLOBs)  
Holds Large Object Data (BLOBs and CLOBs)  


When FILEORG x'100' is set on a file, large object data storage is enabled by reorganizing or [[CREATE command: File|creating]] a file with [[ESIZE parameter|ESIZE]] greater than 0, and then [[DEFINE FIELD command|defining one or more fields]] with an attribute of [[Field design (File management)#BLOB.2C CLOB and MINLOBE attributes|CLOB or BLOB]]. (The file must have an ESIZE for its fields to be defined as CLOB or BLOB.)  
When FILEORG x'100' is set on a file, large object data storage is enabled by reorganizing or [[CREATE command: File|creating]] a file with [[ESIZE parameter|ESIZE]] greater than 0, and then [[DEFINE FIELD command|defining one or more fields]] with an attribute of [[Field design (File management)#BLOB.2C CLOB and MINLOBE attributes|CLOB or BLOB]]. (The file must have an ESIZE for its fields to be defined as CLOB or BLOB.)  
Line 12: Line 11:
<p>Storing chained LOBs has the following advantages over storing and accessing LOBs in non x'100' files:
<p>Storing chained LOBs has the following advantages over storing and accessing LOBs in non x'100' files:
*Because the LOBs no longer need to be contiguous, space monitoring is simpler and Table E is less likely to fill up.
*Because the LOBs no longer need to be contiguous, space monitoring is simpler and Table E is less likely to fill up.
*You can define fields so that 'small' LOBs can be stored 'locally' in the record (and so do not use an entire page in Table E). See the [[Field Design (File Management)#Using the MINLOBE attribute|MINLOBE attribute]].   
*You can define fields so that 'small' LOBs can be stored 'locally' in the record (and so do not use an entire page in Table E). See the [[Field design (File management)#Using the MINLOBE attribute|MINLOBE attribute]].   
*You no longer need to predict (using the [[Data_Maintenance#ADD_statement|RESERVE clause]]) the size that a LOB field might grow to.</p>
*You no longer need to predict (using the [[Data_Maintenance#ADD_statement|RESERVE clause]]) the size that a LOB field might grow to.</p>


== Storing Large Objects ==
== Storing Large Objects ==


<p>Defining a field as a large object (LOB) using the [[Field Design (File Management)#BLOB attribute|BLOB]] or [[Field Design (File Management) #CLOB attribute|CLOB attribute]] stores a pointer in the record in Table B or Table X. Storage of the LOB value depends on the [[Field Design (File Management)#MINLOBE attribute|MINLOBE attribute]] and length of the value being stored, as described below.</p>
<p>Defining a field as a large object (LOB) using the [[Field design (File management)#BLOB attribute|BLOB]] or [[Field design (File management) #CLOB attribute|CLOB attribute]] stores a pointer in the record in Table B or Table X. Storage of the LOB value depends on the [[Field design (File management)#MINLOBE attribute|MINLOBE attribute]] and length of the value being stored, as described below.</p>


=== Pointer in the record ===
=== Pointer in the record ===
Line 27: Line 26:
=== Storing a Large Object ===
=== Storing a Large Object ===


When the length of the value being stored is 0 (a null string), the action taken depends on the 'repeating' type ([[Field Design (File Management)#AT-MOST-ONE, REPEATABLE and EXACTLY-ONE attributes|AT-MOST-ONE, REPEATABLE and EXACTLY-ONE attributes]]) as discussed in the next section.
When the length of the value being stored is 0 (a null string), the action taken depends on the 'repeating' type ([[Field design (File management)#AT-MOST-ONE, REPEATABLE and EXACTLY-ONE attributes|AT-MOST-ONE, REPEATABLE and EXACTLY-ONE attributes]]) as discussed in the next section.
<p>Other than null strings, if the value being stored is less than or equal to the [[Field Design (File Management)#MINLOBE attribute|MINLOBE attribute]] for the field, then the value is stored directly in the record (Table B or Table X). Note that this value is in addition to the pointer described above.</p>
<p>Other than null strings, if the value being stored is less than or equal to the [[Field design (File management)#MINLOBE attribute|MINLOBE attribute]] for the field, then the value is stored directly in the record (Table B or Table X). Note that this value is in addition to the pointer described above.</p>
<p>If the length of the value being stored is greater than the [[Field Design (File Management)#MINLOBE attribute|MINLOBE attribute]] for the field, the value is stored in a series of pages in Table E with the first (up to) 6140 bytes (4 bytes being reserved for the chain pointer) on the first page, the next (up to) 6140 bytes on the 'next' page, and so on. These pages are not necessarily contiguous. Any pages emptied by LOB deletes are first reused before the pages at [[EHIGHPG parameter|EHIGHPG]] are used. </p>
<p>If the length of the value being stored is greater than the [[Field design (File management)#MINLOBE attribute|MINLOBE attribute]] for the field, the value is stored in a series of pages in Table E with the first (up to) 6140 bytes (4 bytes being reserved for the chain pointer) on the first page, the next (up to) 6140 bytes on the 'next' page, and so on. These pages are not necessarily contiguous. Any pages emptied by LOB deletes are first reused before the pages at [[EHIGHPG parameter|EHIGHPG]] are used. </p>


==== Null Strings and Large Objects ====
==== Null Strings and Large Objects ====


The [[Field Design (File Management)#STORE-DEFAULT (SD) and STORE-NULL (SN) attributes|STORE-DEFAULT (SD) and STORE-NULL (SN) attributes]] cannot be set on LOB fields like they can on other field types. This restriction results in LOB fields having the equivalent of the LITeral option. The following table illustrates the results when null strings are stored in Large Object fields:         
The [[Field design (File management)#STORE-DEFAULT (SD) and STORE-NULL (SN) attributes|STORE-DEFAULT (SD) and STORE-NULL (SN) attributes]] cannot be set on LOB fields like they can on other field types. This restriction results in LOB fields having the equivalent of the LITeral option. The following table illustrates the results when null strings are stored in Large Object fields:         


{| class="wikitable";style="width="90%
{| class="wikitable";style="width="90%

Revision as of 20:31, 16 December 2013

Holds Large Object Data (BLOBs and CLOBs)

When FILEORG x'100' is set on a file, large object data storage is enabled by reorganizing or creating a file with ESIZE greater than 0, and then defining one or more fields with an attribute of CLOB or BLOB. (The file must have an ESIZE for its fields to be defined as CLOB or BLOB.)

Available as of Model 204 V7.5.

Summary

Storage and manipulation of Large Objects (LOBs):

All LOBs in a FILEORG=X’100’ file are chained.

Storing chained LOBs has the following advantages over storing and accessing LOBs in non x'100' files:

  • Because the LOBs no longer need to be contiguous, space monitoring is simpler and Table E is less likely to fill up.
  • You can define fields so that 'small' LOBs can be stored 'locally' in the record (and so do not use an entire page in Table E). See the MINLOBE attribute.
  • You no longer need to predict (using the RESERVE clause) the size that a LOB field might grow to.

Storing Large Objects

Defining a field as a large object (LOB) using the BLOB or CLOB attribute stores a pointer in the record in Table B or Table X. Storage of the LOB value depends on the MINLOBE attribute and length of the value being stored, as described below.

Pointer in the record

When you store a 'not null' Large Object value in Table E, a Large Object descriptor is stored in Table B (or Table X depending on where the field is being ADDed). The descriptor contains the length, and a pointer to the Large Object data in the Table E page, and is 27 bytes long.

This descriptor is the same as in non x'100' files.

Storing a Large Object

When the length of the value being stored is 0 (a null string), the action taken depends on the 'repeating' type (AT-MOST-ONE, REPEATABLE and EXACTLY-ONE attributes) as discussed in the next section.

Other than null strings, if the value being stored is less than or equal to the MINLOBE attribute for the field, then the value is stored directly in the record (Table B or Table X). Note that this value is in addition to the pointer described above.

If the length of the value being stored is greater than the MINLOBE attribute for the field, the value is stored in a series of pages in Table E with the first (up to) 6140 bytes (4 bytes being reserved for the chain pointer) on the first page, the next (up to) 6140 bytes on the 'next' page, and so on. These pages are not necessarily contiguous. Any pages emptied by LOB deletes are first reused before the pages at EHIGHPG are used.

Null Strings and Large Objects

The STORE-DEFAULT (SD) and STORE-NULL (SN) attributes cannot be set on LOB fields like they can on other field types. This restriction results in LOB fields having the equivalent of the LITeral option. The following table illustrates the results when null strings are stored in Large Object fields:

Attribute Explicit Null
fieldname = ' '
Implicit Null
fieldname = %X (where %X is null)
No reference in code
EXACTLY-ONE (Note 1) (Note 1) (Note 1)
AT-MOST-ONE field stored with null value not present not present
REPEATABLE field stored with null value not present not present

Note 1: The field will always act as if it is physically present (and return a null). However, exactly-one fields react a bit differently depending on whether they are inside a field group or not. Inside a field group, all three operations will result in a field being present (as displayed in a PAI). Outside of field groups, (and remembering that only the CHANGE statement can be used on exactly-one fields) only the 'CHANGE fieldname TO %X' syntax will physically create an occurrence on the record.

Parameters and commands relating to the use of Table E

Note: Pages are either used or not in Table E, so there is no formula to determine whether a page is added to the reuse queue (unlike Tables B and X). Because of this, there are no EREUSE, EREUSED, or EQLEN parameters. The size of the reuse queue can always be determined by the difference between EHIGHPG and EPGSUSED.

EHIGHPG parameter The highest active Table E page. (The first page in Table E is page zero.)
EPGSUSED parameter The number of Table E pages currently in use.
ESIZE parameter The number of pages in Table E
FILEORG parameter The file organization