Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: DB_file and DB_HASH

by crazyinsomniac (Prior)
on Jun 05, 2002 at 00:08 UTC ( [id://171680]=note: print w/replies, xml ) Need Help??


in reply to DB_file and DB_HASH

visit the DB_File documentation, and then use a BTREE to store your data. A hash is not sorted. A balanced tree is.

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Replies are listed 'Best First'.
Re: Re: DB_file and DB_HASH
by perrin (Chancellor) on Jun 05, 2002 at 00:14 UTC
    BTREE is faster too, according to a benchmark posted here a while back.
      Thanks but my question is not to get the data in the sorted order but the order in which the data was inserted.For exam if I did 323|Val and 121|Val, I would like to get 323 first.Sorry if I confused.Is there any way to achieve this using BTREE,please advise
        It sounds more like you're using it as an array then. Maybe you should use the Queue instead.

        If you need both insertion order access and random access by key you will have to store a separate array that keeps track of the order that keys were inserted.

        Something like Storable or Freeze/Thaw might do what you want. Check the perldoc

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://171680]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-19 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found