Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Bidirectional lookup algorithm? (Updated: further info.)

by sundialsvc4 (Abbot)
on Jan 06, 2015 at 18:51 UTC ( #1112382=note: print w/replies, xml ) Need Help??

in reply to Bidirectional lookup algorithm? (Updated: further info.)

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re: Bidirectional lookup algorithm? (Updated: further info.)

Replies are listed 'Best First'.
Re^2: Bidirectional lookup algorithm? (sundialsvc4 spam)
by Anonymous Monk on Jan 06, 2015 at 20:06 UTC
    mike robertson it isn't reasonable or polite to keep spamming BrowserUk like this, why is sundialsvc4 such a constant spammer? Its unprofessional to be a spammer mike robertson.

      Yes, that is my name.   But, pardon me, you don’t seem to be using yours.   Wonder why.   Nevertheless, all of this is entirely off-topic.   I believe that someone asked a question about bidirectional lookup algorithms, yes?

      Returning to the topic, then, if you really want to attempt to use a single indexing scheme to locate two keys, the only way that I know of to do this is to generate a synthetic key, within the same domain of values, for each key that you wish to store.   You then employ a hashref keyed by this synthetic-key.   Each bucket in this hashref points to an arrayref of references.   You insert a reference to the (single ...) record into this hashref/arrayref structure multiple times, one for each synthetic key.   Searching now involves retrieving the arrayref for either key, and iterating through it to find the actual record(s) that you want.   The synthetic-key and constrained domain for that key is merely intended to reduce the size of the hashref:   you will still have a lot of accompanying data-structures ... probably more-or-less equivalent to having two separate hashrefs.

      = = = = =

      But the over-arching problem remains the same:   memory must be presumed to be unlimited and resident.   Either you have that or you don’t.   This strategy continues to be “random.”   It does not exhibit “locality of reference.”   It will produce a very high working-set size that, under production load conditions (really, any sort of virtual-memory stress at all ...) will perform prohibitively poorly, even though it may have seemed incredibly-clever on the developer’s machine, which was never actually “paging.”

      (I like to give developers machines that are memory-tight.   It forces them to write better code, because now they feel it, too.)

      I confess to a little bit of déjà vu here, because I once was called-upon to undo a similar program.   Oh, the thing was a gloriously clever mess.   There was “cleverness” running all through it, and memory-wise it was a big, fat pig.   Pretty much had to re-write the whole thing.   It just couldn’t run.   It acted, as I’ve said, “punch-drunk” when page-faults started hitting it, and of course, page-fault behavior affects everything on the machine.   (Other things, too ... “oh no, don’t call a subroutine!   Subroutines are ‘inefficient!’   It’s ‘faster’ to repeat yourself in-line!”)   A big fat pig mess.   But it sure did look clever to the developer, who by then had conveniently slipped out the door.   Code needs to be fast enough, under production conditions, and it must be maintainable.   That’s all.   Don’t be “too clever by half.”   Please.   Pretty please.

        "Yes, that is my name. But, pardon me, you donít seem to be using yours. Wonder why."

        It has finally happened, you don't even know your own name any more! This explains the quality of your posts. You don't even read what people post, then reply anyway.

        Update: I do not for one moment believe that you have actually forgotten your own name. A more constructive way to have approached this would have been to point out brown M&M story. In the past I've engaged you on responding to things people didn't say, and in some cases quoting things that nobody has said, to no avail.

        generate a synthetic key, within the same domain of values, for each key that you wish to store.

        Care to elaborate?

        Perhaps you can post an example of how to generate a synthetic key for pairs selected from the domains: 'aaaaaaaa' .. 'zzzzzzzz'; and 0 .. 2^64-1?

        Each bucket in this hashref points to an arrayref of references.

        If the keys are synthesized, why do the values need to be arrays? And why "arrays of references"?

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        Yes, that is my name
        Is it? Robin and Robert are distinct names, aren't they?
        لսႽÜ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2021-05-07 11:26 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (91 votes). Check out past polls.