Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
admin:basics:rawdata:implementation:fixed [2011/03/08 21:23]
els
— (current)
Line 1: Line 1:
-~~NOTOC~~ 
  
-{{page>:​top_add&​nofooter&​noeditbtn}} 
- 
-====== Administration:​ Omnidex Fundamentals ====== 
- 
-===== Raw Data Files ===== 
- 
-[[admin:​basics:​rawdata:​home|Overview]] | 
-[[admin:​basics:​rawdata:​types|File Types]] | 
-[[admin:​basics:​rawdata:​environments|Environments]] | 
-[[admin:​basics:​rawdata:​queries|Queries]] | 
-[[admin:​basics:​rawdata:​updates|Updates]] | 
-[[admin:​basics:​rawdata:​creation|Creating Raw Data Files]] | 
-**[[admin:​basics:​rawdata:​implementation|Implementation Details]]** 
- 
- 
----- 
-==== Implementation Details: Fixed-length Data Files ==== 
- 
-**[[admin:​basics:​rawdata:​implementation:​fixed|Fixed-length]]** | [[admin:​basics:​rawdata:​implementation:​delimited|Delimited]] | 
-[[admin:​basics:​rawdata:​implementation:​ost|Omnidex Standalone Tables]] | 
-[[admin:​basics:​rawdata:​implementation:​hdfs|Hadoop Distributed File System]] ​ 
- 
----- 
- 
-=== Environment === 
- 
-The record layout described in the CREATE TABLE statement must exactly match the record layout in the data file, including the order, datatype and length of each columns. ​ If these record layouts do not match, Omnidex will have problems reading the data from the data file.  ​ 
- 
-== Declaring Files == 
- 
-Raw data files are accessed by creating a table definition in Omnidex that points to the data file.  Once this is done, applications can use SQL statements to access the table. ​ Omnidex will process the data in the data file just like it would when accessing a relational table. 
- 
-In the [[dev:​sql:​statements:​create_table:​home|CREATE TABLE]] statement, the PHYSICAL clause is used to point to the physical location of the raw data file.  This PHYSICAL clause can contain a relative path name (relative to the location of the Omnidex Environment File) such as "​dat/​states.dat",​ or an absolute path name such as "​d:/​class/​lab1/​dat/​states.dat"​. ​ This PHYSICAL clause can also contain wildcard as described below, and can also reference [[appendix:​reference:​envvar|environment variables]] using a special syntax. 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​physical ​            "​dat/​states.dat"​ 
- ... 
-</​code>​ 
- 
-== Declaring Filesets == 
- 
-In the example above, a single file was used as the source of data for a table. ​ It is also possible for multiple files to be used as the source of data for a table. ​ As long as the files all share the same record layout, they will all be processed when reading the table. Filesets can be declared as a comma-separated list of files, or they can be declared using wildcards in the filename. ​ In this example, three files are declared individually in the PHYSICAL clause: 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​physical ​            "​c:/​class/​lab1/​dat/​states1.dat, ​ 
-                       ​c:/​class/​lab1/​dat/​states2.dat, ​ 
-                       ​d:/​class/​lab1/​dat/​states3.dat"​ 
- ... 
-</​code>​ 
- 
-In this second example, wildcards are used to declare these files: 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​physical ​            "​c:/​class/​lab1/​dat/​states*.dat, ​ 
-                       ​d:/​class/​lab1/​dat/​states*.dat"​ 
- ... 
-</​code>​ 
- 
-Files can reside in multiple directories and in multiple drives or volumes to allow a table to span multiple storage devices. ​ Files may also reside on a Storage Area Network (SAN); in fact, this is one of the most common implementations of Omnidex. ​ Files may also reside on simple mapped drives; however, users should expect performance degradation to occur in this scenario. ​ 
- 
-Wildcards provide a great flexibility since they allow more data to be added to a table by simply moving another file into place. ​ Care should be taken with this approach, though, since the table must be reindexed as soon as new data is in place. 
- 
-== Record Layouts == 
- 
-In the CREATE TABLE statement, the record layout is specified using the COLUMN clause. ​ The datatypes and lengths for these columns can be nearly any datatype supported by Omnidex. ​ The only exceptions are the VARCHAR and CLOB datatypes, as these require that the underlying data also include stored data lengths. ​ With raw data files, use STRING and CHARACTER datatypes instead. 
- 
-<code sql> 
-create table          "​STATES"​ 
- ​physical ​            "​dat/​states.dat"​ 
- ( 
-  "​STATE" ​            ​CHARACTER(2), ​               ​ 
-  "​DESCRIPTION" ​      ​STRING(31), ​                 
-  "​STATE_CODE" ​       CHARACTER(2), ​               ​ 
-  "​REGION" ​           CHARACTER(2), ​               ​ 
-  "​COUNTRY" ​          ​CHARACTER(2), ​               ​ 
-  "​TAX_RATE" ​         FLOAT                        
- ) 
- ​in ​                  "​simple.xml";​ 
-</​code>​ 
- 
-Most raw data files are accompanied by some kind of record layout that can be used to construct the CREATE TABLE statement. ​ For those that do not, the [[programs:​odxsql:​commands:​dump_file|DUMP FILE]] command in OdxSQL can be helpful. ​ This command will dump the contents of a file in hex and in character form so that the alignment of both character and binary datatypes can be seen. 
- 
-<​code>​ 
-> dump file dat/​states.dat 
- 
-File dump for dat/​states.dat 
- 
-Record length [256]: 44 
- 
-dat/​states.dat is 3.3K and has 76 rows 
- 
-Rec #, Previous, Next, First, Last, or Quit: 
-Filename: dat/​sta.dat ​ Record: 1  Offset: 0 
-00000-00015: ​  ​41414172 6d656420 466f7263 65732041 ​    ​AAArmed Forces A 
-00016-00031: ​  ​6d657269 63617300 00000000 00000000 ​    ​mericas......... 
-00032-00043: ​  ​00002020 41465553 00000000 ​             ..  AFUS.... 
-Rec #, Previous, Next, First, Last, or Quit: 
-Filename: dat/​sta.dat ​ Record: 2  Offset: 44 
-00000-00015: ​  ​41454172 6d656420 466f7263 65732045 ​    ​AEArmed Forces E 
-00016-00031: ​  ​75726f70 652f4166 72696361 00000000 ​    ​urope/​Africa.... 
-00032-00043: ​  ​00002020 41465553 00000000 ​             ..  AFUS.... 
-Rec #, Previous, Next, First, Last, or Quit: 
-Filename: dat/​sta.dat ​ Record: 3  Offset: 88 
-00000-00015: ​  ​41504172 6d656420 466f7263 65732050 ​    ​APArmed Forces P 
-00016-00031: ​  ​61636966 69630000 00000000 00000000 ​    ​acific.......... 
-00032-00043: ​  ​00002020 41465553 00000000 ​             ..  AFUS.... 
-</​code>​ 
- 
-Omnidex cannot verify that the record layouts exactly match, so it is always wise to retrieve a few rows and visually inspect that the column definition and the data file line up properly. 
- 
- 
-=== Creating Fixed-length Data Files === 
- 
-== Omnidex SQL Example 1: Export of a table == 
- 
-This example exports all of the columns and rows from a table. 
- 
-<​code>​ 
-export ​       (select ​       * 
-                 ​from ​       INDIVIDUALS) 
-  to          individuals.dat 
-  with        DELETE; 
-</​code>​ 
- 
-== Omnidex SQL Example 2: Denormalization of two tables == 
- 
-This example joins two tables and exports specific columns, applying criteria to restrict the rows returned. ​ It also uses SQL functions to create new columns. 
- 
-<​code>​ 
-export ​       (select ​       I.NAME, 
-                             ​H.ADDRESS,​ 
-                             ​H.CITY,​ 
-                             ​H.STATE,​ 
-                             ​H.ZIP,​ 
-                             ​I.PHONE,​ 
-                             ​I.EMAIL,​ 
-                             ​$compare_dates(I.BIRTHDAY,​ current_date,​ '​YEARS'​) AGE 
-                 ​from ​       INDIVIDUALS I 
-                 ​join ​       HOUSEHOLDS H on I.HOUSEHOLD = H.HOUSEHOLD 
-                 ​where ​      ​H.STATE = '​CA'​) 
-  to          CA_individuals.dat 
-  with        DELETE; 
-</​code>​ 
- 
-== Omnidex SQL Example 3: Summarization of two tables == 
- 
-This example joins two tables and exports aggregations to form a summary table. 
- 
-<​code>​ 
-export ​       (select ​       H.STATE, 
-                             ​H.ZIP,​ 
-                             ​count(distinct H.HOUSEHOLD),​ 
-                             ​count(*) 
-                 ​from ​       INDIVIDUALS I 
-                 ​join ​       HOUSEHOLDS H on I.HOUSEHOLD = H.HOUSEHOLD 
-                 group by    H.STATE, 
-                             ​H.ZIP) 
-  to          individuals_summary.dat 
-  with        DELETE; 
-</​code>​ 
- 
- 
- 
-=====  ===== 
- 
-**[[admin:​basics:​rawdata:​creation|Prev]]** 
- 
-====== Additional Resources ====== 
- 
-See also:  
- 
-{{page>:​admin:​basics:​see_also&​nofooter&​noeditbtn}} 
- 
-{{page>:​bottom_add&​nofooter&​noeditbtn}} 
 
Back to top
admin/basics/rawdata/implementation/fixed.1299619415.txt.gz ยท Last modified: 2012/10/26 14:57 (external edit)