in reply to (podmaster) Re: In order traversal of BTREE keys where not all keys have duplicate values (using DB_File)
in thread In order traversal of BTREE keys where not all keys have duplicate values (using DB_File)

Oops missing the compare function.
 sub _compare { $_[0] <=> $_[1] }

Keys are numeric bins of the form 10000.000178 - this adapted from a mysql strategy where we are testing for bins within the boundaries but I am interested in an in-memory adaptation.

I want to iterate through a subset of the keys that are bounded by some values $begin, $end not the whole set of keys as is demonstrated in all the examples. I was using get_dup to initialize the cursor and then iterate through all the available keys, however the cursor will only point to keys which have >1 value.
===
Ahem. I was making it harder than it should be.

$bhandle->seq($start,$v,R_CURSOR); while( $bhandle->seq($k,$v,R_NEXT) == 0 ) { last if( $k> $end); ... }
Gets me what I want. Calling get_dup to initialize the cursor was not a smart idea and was the root of the problem.
  • Comment on Re: (podmaster) Re: In order traversal of BTREE keys where not all keys have duplicate values (using DB_File)
  • Select or Download Code