Cory,

        Thanks, I'll give it a try. Speed if of the utmost for me here,
because I am building an array of ID's in memory that satisfy a certain
condition and then using that array of ID's back into the database to add to
the array using the keys in the array as the condition for the next select.
I keep iterating like this until there are no more ID's to add to the list.
The array can get to be over 10,000 rows at up to 30 levels. I also track
the levels at which the ID was entered into the table. Obviously I eliminate
the ID's past each level that are already in the array. I currently am doing
this in MSSQL 2K and the CircleOfFriends Database alone (without the profile
data) is over 9GB and has over 94 million rows. It's not distributable in
this format, so I am using sqlite to ship the 289,000+ profiles and building
the lists on the fly in a web application. We ship a new profile every
single day to our clients and the circle of friends list needs to be rebuilt
every time they get a new list.

        Basically what it is, is a database of bad guys and companies from
various world wide lists that each have a unique ID assigned to them. Part
of the database is a table of links to other bad guys that are in the list.
I am using this method to build a 'Circle Of Friends' of the bad guys. We
then rank each member of the Circle according to how many other bad guys
he/she is linked to and assign a severity based on the list or list that
they are on. The list currently contains about 289,000+ profiles of the
worlds top bad guys. By the way - Usama Bin Laden is in a circle that
contains about 9,000+ other bad guys/companies. There's a former Nigeria
dictator Charles Taylor that is even worse.

Mike



> -----Original Message-----
> From: Cory Nelson [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, May 15, 2005 1:36 PM
> To: sqlite-users@sqlite.org
> Cc: [EMAIL PROTECTED]
> Subject: Re: [sqlite] Convert and isnumeric function
> 
> for a nice speed increase (no strlen and only one pointer 
> dereference) try changing
> 
> for (i = 0; i < strlen (z); i++) {
> 
> to
> 
> const char *iter;
> char ch;
> for(iter=z; (ch=*iter); ++iter) {
> 
> and
> 
> if (i == 0) {
> 
> to
> 
> if(iter==z) {
> 
> and all the z[i] to ch.
> 
> On 5/15/05, Michael Evenson <[EMAIL PROTECTED]> wrote:
> > This fixes the problem of negative numeric values. It does 
> not however 
> > handle locale specific numbers (like using , as decimal 
> separator) or 
> > for that matter, commas in the numbers. As I understand it, sqlite 
> > does not handle locale specific numbers in general.
> > 
> > Mike
> > 
> > 
> > /*
> > ** Implementation of the isnumeric() function */ static void 
> > isnumericFunc(sqlite3_context *context, int argc, sqlite3_value
> > **argv)
> > {
> >   int i;
> >   int nResult = 1;
> > 
> >   assert( argc==1 );
> >   switch( sqlite3_value_type(argv[0]) ){
> >     case SQLITE_INTEGER: {
> >       sqlite3_result_int(context, 1);
> >       break;
> >     }
> >     case SQLITE_FLOAT: {
> >       sqlite3_result_int(context, 1);
> >       break;
> >     }
> >     case SQLITE_NULL: {
> >       sqlite3_result_int(context, 0);
> >       break;
> >     }
> >     case SQLITE_TEXT: {
> >       int d = 0;
> >       const char *z = sqlite3_value_text(argv[0]);
> >       for (i = 0; i < strlen (z); i++) {
> >         if (!isdigit (z[i])) {
> >           /* the character is not a digit */
> >           if (i == 0) {
> >             /* allow - or + as the first character */
> >             if ((z[i] != '-') && (z[i] != '+') && (z[i] != '.')) {
> >               /* only +, - and . allowed as first non digit 
> character */
> >               nResult = 0;
> >               if (z[i] == '.')
> >                 d++;
> >               break;
> >             }
> >           }
> >           else {
> >             if ((d > 0) && (z[i] == '.')) {
> >               /* only . allowed as non digit character here */
> >               /* and only one of them in the string */
> >               nResult = 0;
> >               break;
> >             }
> >             else if (z[i] == '.')
> >               d++;
> >           }
> >         }
> >       }
> >       sqlite3_result_int(context, nResult);
> >       break;
> >     }
> >     default: {
> >       sqlite3_result_int(context, 0);
> >       break;
> >     }
> >   }
> > }
> > 
> > > -----Original Message-----
> > > From: Wolfgang Rohdewald [mailto:[EMAIL PROTECTED]
> > > Sent: Saturday, May 14, 2005 8:39 AM
> > > To: sqlite-users@sqlite.org
> > > Subject: Re: [sqlite] Convert and isnumeric function
> > >
> > > On Samstag 14 Mai 2005 00:31, Michael Evenson wrote:
> > > >     case SQLITE_TEXT: {
> > > >       const char *z = sqlite3_value_text(argv[0]);
> > > >       for (i = 0; i < strlen (z); i++) {
> > > >         if (!isdigit (z[i])) {
> > > >           nResult = 0;
> > > >           break;
> > > >         }
> > >
> > > this should return FALSE for -5, 1123.456.
> > > In some locales, that might be written as 1'123,456 or
> > > 1,123.456 or whatever.
> > >
> > > strtol()
> > >
> > > seems to  what you need, see man strol()
> > >
> > > --
> > > Wolfgang
> > >
> > 
> > 
> 
> 
> --
> Cory Nelson
> http://www.int64.org
> 


Reply via email to