Data is not in order in Hash file.

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
MOHAMMAD.ISSAQ
Participant
Posts: 78
Joined: Fri Mar 02, 2007 4:54 am
Location: CHENNAI

Data is not in order in Hash file.

Post by MOHAMMAD.ISSAQ »

I'm extracting data from .csv file and putting it into a hash file.
I'm just doing direct mapping.I've input key column values as 1 to 100.

But in output the value of key column are not in the same order as that of input.

Pls help me out..




Thanks in advance
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Simply answer is - don't expect it to be. If the order matters, resort the data after you extract it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Post by sachin1 »

A hash file can simply be described as a file that distributes data throughout a pre-sized and space allocated file.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... based on a hashing algorithm, hence the name. Now, if you want sorted output you can:

1. Create the hashed file in an account or create a VOC record for it if pathed
2. Create an index over the desired field (may be optional but certainly recommended)
3. Use a UV stage to access the hashed file via SQL and specify an 'ORDER BY' clause.

There's also the SSELECT verb in BASIC but that's for hand coders.
-craig

"You can never have too many knives" -- Logan Nine Fingers
veera24
Premium Member
Premium Member
Posts: 150
Joined: Thu Feb 07, 2008 9:37 pm
Location: NewYork

Re: Data is not in order in Hash file.

Post by veera24 »

Actually it wont give it in sorted order.It ll be workin based on the key n if u particularly wan in sorted order den u shud use sort stage.

Thanks,
veera
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

If you do need to pull out the data in an ORDER'ed manner, you could use the UV/ODBC stage and SQL ordering to pull out the data.

If you're really proficient with Universe, you could use the WITH section to add in Retrieve commands and use inline commands and field definitions to handle ordering. You just dummy the WITH using @ID to get past the hardcoded WITH statement and then add your BY or BY-DSND commands.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What you said about hashed files applies equally to all database tables. Physical storage is irrelevant to the user. This is a fundamental tenet of database design; it permits the engine to use an optimal storage strategy.

Hashed files are used by a number of different database products (such as UniVerse, UniData, D3, jBase and others) to implement their database tables.

In a Hashed File stage you can specify sorting criteria on the Selection tab if the stage is delivering a stream link. Simply put BY @ID as the phrase that governs selection by key.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Re: Data is not in order in Hash file.

Post by baglasumit21 »

MOHAMMAD.ISSAQ wrote:I'm extracting data from .csv file and putting it into a hash file.
I'm just doing direct mapping.I've input key column values as 1 to 100.

But in output the value of key column are not in the same order as that of input.

Pls help me out..




Thanks in advance
The hashed file stores the data based on hashing algorithm based on the key columns of your file. Its a type of indexed file.So when you insert the data it wont be in the same order as you have inserted. It is generally used for look-up so it wont matter what order the data is stored in the file. It wont affect the performance atall even if it is not sorted
SMB
MOHAMMAD.ISSAQ
Participant
Posts: 78
Joined: Fri Mar 02, 2007 4:54 am
Location: CHENNAI

Post by MOHAMMAD.ISSAQ »

Thanks for the help
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

sachin1 wrote:A hash file can simply be described as a file that distributes data throughout a pre-sized and space allocated file.
No, that's a hashed file that you've defined.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

sachin1 wrote:A hash file can simply be described as a file that distributes data throughout a pre-sized and space allocated file.
No, that's a hashed file that you've defined.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply