Page 1 of 1

Data is not in order in Hash file.

Posted: Tue Feb 12, 2008 9:16 am
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

Posted: Tue Feb 12, 2008 9:30 am
by chulett
Simply answer is - don't expect it to be. If the order matters, resort the data after you extract it.

Posted: Tue Feb 12, 2008 9:38 am
by sachin1
A hash file can simply be described as a file that distributes data throughout a pre-sized and space allocated file.

Posted: Tue Feb 12, 2008 10:09 am
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.

Re: Data is not in order in Hash file.

Posted: Tue Feb 12, 2008 10:40 am
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

Posted: Tue Feb 12, 2008 11:30 am
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.

Posted: Tue Feb 12, 2008 3:36 pm
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.

Re: Data is not in order in Hash file.

Posted: Tue Feb 12, 2008 11:54 pm
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

Posted: Wed Feb 13, 2008 12:20 am
by MOHAMMAD.ISSAQ
Thanks for the help

Posted: Wed Feb 13, 2008 1:20 am
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.

Posted: Wed Feb 13, 2008 1:21 am
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.