1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Merge orderby-planning with this branch.

FossilOrigin-Name: d9549de31741239ece060e448b592ce8fc5b8042
This commit is contained in:
dan
2014-05-02 18:05:38 +00:00
43 changed files with 2398 additions and 1096 deletions

View File

@@ -83,7 +83,8 @@ static LogEst logEstFromDouble(double x){
LogEst e;
assert( sizeof(x)==8 && sizeof(a)==8 );
if( x<=0.0 ) return -32768;
if( x<1.0 ) return -logEstFromDouble(1/x);
if( x<0.01 ) return -logEstFromDouble(1.0/x);
if( x<1.0 ) return logEstFromDouble(100.0*x) - 66;
if( x<1024.0 ) return logEstFromInteger((sqlite3_uint64)(1024.0*x)) - 100;
if( x<=2000000000.0 ) return logEstFromInteger((sqlite3_uint64)x);
memcpy(&a, &x, 8);
@@ -156,8 +157,10 @@ int main(int argc, char **argv){
}
}
for(i=n-1; i>=0; i--){
if( a[i]<0 ){
if( a[i]<-40 ){
printf("%5d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i]));
}else if( a[i]<10 ){
printf("%5d (%f)\n", a[i], logEstToInt(a[i]+100)/1024.0);
}else{
sqlite3_uint64 x = logEstToInt(a[i]+100)*100/1024;
printf("%5d (%lld.%02lld)\n", a[i], x/100, x%100);