dbTalk Databases Forums  

indexes

comp.databases.pick comp.databases.pick


Discuss indexes in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Scott Ballinger
 
Posts: n/a

Default Re: indexes - 10-10-2005 , 08:00 PM






Brian,

I think you can use D3 indexes for your application, you just have to be
a little careful.

Since the null items are the problem, create an index without any null
items by concatenating the key to the value to create a unique field to
index on (as Ross suggested). In this case, if the field you actually
want to index is <16>, then

1. create a dict item to index on, e.g.

uniq16
1 s
2 16
....
8 a16:"-":0
9 l
10 10

2. build the index

create-index myfile uniq16

3. select from tcl for <16> = "abc"

select myfile with uniq16 eq "abc-]"

4. select from basic (not tested!)

root myfile,'a16:"-":0' to root.myfile else ....
result = ""
thing = "abc-"
search = thing
len = len(thing)
loop
key("x",root.myfile,search,id) then
if search[1,len] ne thing then done = 1
end else
done = 1
end
until done do
result<-1> = id
repeat


Speaking of basic btree selects... here is a generic btree lookup
subroutine that I use (because I can't remember the root and key syntax):

0001 subroutine get.btree(thing,result,filename,fieldname)
0002 * Get result id(s) from the btree index fieldname for filename.
0003 * Result is mv if more than 1 id found for thing.
0004 * If thing ends with ] then return all starting with thing.
0005 * If thing doesn't end with ] then return all exactly matching thing.
0006 * If thing requires an iconv (e.g. a date) then iconv before
passing it.
0007
0008 begin case
0009 case fieldname matches "'a'0n"
0010 ac = fieldname
0011 case fieldname matches "0n"
0012 ac = "a":fieldname
0013 case 1
0014 open "dict",filename to dict.filevar else
0015 sleep 1
0016 open "dict",filename to dict.filevar else
0017 stop 201,"dict ":filename
0018 end
0019 end
0020 read rec from dict.filevar,fieldname then
0021 if rec<8>[1,1] eq "A" then
0022 ac = rec<8>
0023 end else
0024 ac = "A":rec<2>
0025 end
0026 end else
0027 print " error! can't read item ":fieldname:" in dict ":filename
0028 stop
0029 end
0030 end case
0031
0032 root filename,ac to fileroot else
0033 sleep 1 ;* pause & try again for remote files
0034 root filename,ac to fileroot else
0035 print "error! no index defined for ":filename:",":ac:"
(":fieldname:")
0036 stop
0037 end
0038 end
0039
0040 lent = len(thing)
0041 if thing[lent,1] eq "]" then
0042 wildcard = 1
0043 lent -= 1
0044 thing = thing[1,lent]
0045 end else
0046 wildcard = 0
0047 end
0048
0049 search = thing
0050 result = ""
0051 id = ""
0052 done = 0
0053
0054 loop
0055 key("x",fileroot,search,id) then
0056 if wildcard then
0057 if search[1,lent] ne thing then done = 1
0058 end else
0059 if search ne thing then done = 1
0060 end
0061 end else
0062 done = 1
0063 end
0064 until done do
0065 result<-1> = id
0066 repeat
0067
0068 convert @am to @vm in result
0069
0070 return


/Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006


Brian Bond wrote:
Quote:
It just seems really odd that a D3 index cannot actually be used in cases
where an index might come in handy.

'nuff said.



Reply With Quote
  #12  
Old   
Brian Bond
 
Posts: n/a

Default Re: indexes - 10-11-2005 , 12:21 PM






I originally wrote a big, long, brilliant (and boring) disseratation as a
reply, but instead I will just say this: Universe has a NO.NULLS clause, and
it would have solved my problem nicely. D3 doesn't, so now I get to write
some code instead of going out and having a beer.


"Scott Ballinger" <scott (AT) tiredofspampareto (DOT) net> wrote

Quote:
Brian,

I think you can use D3 indexes for your application, you just have to be a
little careful.

Since the null items are the problem, create an index without any null
items by concatenating the key to the value to create a unique field to
index on (as Ross suggested). In this case, if the field you actually want
to index is <16>, then



Reply With Quote
  #13  
Old   
Dale Benedict
 
Posts: n/a

Default Re: indexes - 10-11-2005 , 02:36 PM



Brian...

You might try using a bridge correlative to update a home grown index file.

I haven't played with the bridge correlative for some time, so I'm not sure
if it will work for you. The retrieval of the keys would then be a trivial
matter.

regards,

Dale

"Brian Bond" <brian (AT) XYZXYZXYZXYZbonanzapress (DOT) com> wrote

Quote:
I originally wrote a big, long, brilliant (and boring) disseratation as a
reply, but instead I will just say this: Universe has a NO.NULLS clause,
and
it would have solved my problem nicely. D3 doesn't, so now I get to write
some code instead of going out and having a beer.


"Scott Ballinger" <scott (AT) tiredofspampareto (DOT) net> wrote in message
news:L8E2f.13604$wm3.10063 (AT) trnddc01 (DOT) ..
Brian,

I think you can use D3 indexes for your application, you just have to be
a
little careful.

Since the null items are the problem, create an index without any null
items by concatenating the key to the value to create a unique field to
index on (as Ross suggested). In this case, if the field you actually
want
to index is <16>, then





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.