Searching a 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
als110
Participant
Posts: 43
Joined: Fri Nov 05, 2004 11:21 am
Location: United States

Searching a hash File

Post by als110 »

Does anyone know a way to search for a row in a hash file either with a unix command or in Administrator. Basically I want to grep for a row but im not sure how to do this with a hash file.

Thanks

Aaron
chesterkchu
Participant
Posts: 35
Joined: Mon Nov 15, 2004 9:46 am

Post by chesterkchu »

Hi Aaron,

Try "LIST filename WITH @ID=key".

Thanks,

Chester
als110
Participant
Posts: 43
Joined: Fri Nov 05, 2004 11:21 am
Location: United States

Post by als110 »

This only will search if you know the id of the record. I want to know if there is a way to search for a given part of the actual record.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not 'View Data' and then use the Find option there?
-craig

"You can never have too many knives" -- Logan Nine Fingers
chesterkchu
Participant
Posts: 35
Joined: Mon Nov 15, 2004 9:46 am

Post by chesterkchu »

Hi Aaron,

Try LIST filename WITH columnname = 'value'

:lol:

Thanks,

Chester
als110
Participant
Posts: 43
Joined: Fri Nov 05, 2004 11:21 am
Location: United States

Post by als110 »

chulett wrote:Why not 'View Data' and then use the Find option there?
Craig there are over 102 million rows in my hash file this option is not feasible.

Thanks
als110
Participant
Posts: 43
Joined: Fri Nov 05, 2004 11:21 am
Location: United States

Post by als110 »

chesterkchu wrote:Hi Aaron,

Try LIST filename WITH columnname = 'value'

:lol:

Thanks,

Chester
That works but I'm not sure how well it will work with 102 million rows. I tried is on a smaller has file of 2 million and it take about 5 min to return.

Thanks
jmessiha
Participant
Posts: 21
Joined: Fri Nov 12, 2004 9:48 am

Post by jmessiha »

als110 wrote:
chulett wrote:Why not 'View Data' and then use the Find option there?
Craig there are over 102 million rows in my hash file this option is not feasible.

Thanks
Yes, you'd have to skip every time your search failed, viewing 9999 rows at a time. Sounds like too much fun. If your record was at the very bottom, you wouldn't find it until after you skipped 10202 times.

Joey
chesterkchu
Participant
Posts: 35
Joined: Mon Nov 15, 2004 9:46 am

Post by chesterkchu »

jmessiha wrote:
als110 wrote:
chulett wrote:Why not 'View Data' and then use the Find option there?
Craig there are over 102 million rows in my hash file this option is not feasible.

Thanks
Yes, you'd have to skip every time your search failed, viewing 9999 rows at a time. Sounds like too much fun. If your record was at the very bottom, you wouldn't find it until after you skipped 10202 times.

Joey
Therefore, my solution would be more efficient. You can run it and go eat lunch and come back to your record!

Thanks,

Chester
jmessiha
Participant
Posts: 21
Joined: Fri Nov 12, 2004 9:48 am

Post by jmessiha »

als110 wrote:
chesterkchu wrote:Hi Aaron,

Try LIST filename WITH columnname = 'value'

:lol:

Thanks,

Chester
That works but I'm not sure how well it will work with 102 million rows. I tried is on a smaller has file of 2 million and it take about 5 min to return.

Thanks
Chester's way seems like the only way, and will perform at O(n) worst-case efficiency since you are searching for the primary key and not the natural key. I don't think there is a better way, so you'll have to wait for the search to come back.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I you need to do this search repeatedly, you can do a "CREATE.INDEX {TableName} {ColumnName}" and subsequent commands LIST commands on that column will automatically use the index. The CREATE.INDEX command will take a bit of time to create, though.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you are searching for the primary key, the row will be returned instantly irrespective of its location.
Why?
The key value is processed by a hashing algorithm that returns the address of the page on which the key and its record are stored. One I/O operation is required to retrieve that page.

If you are searching based on any other criterion the hashed file behaves like any other database table (which ultimately is what it is). As Arnd suggested, your search can be speeded if the field(s) required in your search criteria are indexed.

Finally, there is no utility for doing this from the operating system prompt; you must be executing a query in the database environment. Get to this from the operating system prompt using the dssh or uv command. Either can take your query (surrounded by double quotes) as a command line argument.
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