In kvtest.c, use stat() instead of fseek()/ftell() to determine the size of
a BLOB to be read directly from disk. This makes the pile-of-files database more competative against SQLite. FossilOrigin-Name: a7dca29f03e037fe71cc600db97f8058e3bd28a4
This commit is contained in:
parent
03d0c20bbd
commit
cae20d5cf1
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\skvtest.c\stest\sprogram\sused\sto\sshow\sthat\sit\sis\smany\stimes\sfaster\sto\nread\sthumbnail\sand\ssimilar\sBLOBs\sout\sof\san\sSQLite\sdatabase\sthan\sit\sis\sto\sread\nthem\sas\sseparate\sfiles\sfrom\sthe\sfilesystem.
|
||||
D 2016-12-29T16:58:01.454
|
||||
C In\skvtest.c,\suse\sstat()\sinstead\sof\sfseek()/ftell()\sto\sdetermine\sthe\ssize\sof\na\sBLOB\sto\sbe\sread\sdirectly\sfrom\sdisk.\s\sThis\smakes\sthe\spile-of-files\sdatabase\nmore\scompetative\sagainst\sSQLite.
|
||||
D 2016-12-29T17:25:06.872
|
||||
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
|
||||
@ -894,7 +894,7 @@ F test/json101.test c0897616f32d95431f37fd291cb78742181980ac
|
||||
F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a
|
||||
F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0
|
||||
F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
|
||||
F test/kvtest.c 05685d636f6c2985cfe00f88ba95e5c19cbd22bc
|
||||
F test/kvtest.c 2c66ddefcd03c2caa337f6dd79e6c82368af83df
|
||||
F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
|
||||
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
|
||||
F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302
|
||||
@ -1540,8 +1540,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P a6af06f164b1f65779e2171ec4946119c66f9be8 55d29839c9fafe9e6a694f5790151d1f22396b01
|
||||
R 7016508fdc58bb08d2b99836c37fbfc4
|
||||
T +closed 55d29839c9fafe9e6a694f5790151d1f22396b01
|
||||
P 8074d59cf177cb91ee371e2660f2c59ce540b7e2
|
||||
R 753a90b01c338f55ad8c1b7fed642932
|
||||
U drh
|
||||
Z 23505d55f5d4f936007bea728155ea61
|
||||
Z 3b88de21d40c4e92a72ebab5ce816139
|
||||
|
@ -1 +1 @@
|
||||
8074d59cf177cb91ee371e2660f2c59ce540b7e2
|
||||
a7dca29f03e037fe71cc600db97f8058e3bd28a4
|
@ -104,6 +104,7 @@ static const char zHelp[] =
|
||||
/* Provide Windows equivalent for the needed parts of unistd.h */
|
||||
# include <io.h>
|
||||
# define R_OK 2
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# define access _access
|
||||
#endif
|
||||
@ -154,6 +155,20 @@ static int pathType(const char *zPath){
|
||||
return PATH_OTHER;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the size of a file in bytes. Or return -1 if the
|
||||
** named object is not a regular file or does not exist.
|
||||
*/
|
||||
static sqlite3_int64 fileSize(const char *zPath){
|
||||
struct stat x;
|
||||
int rc;
|
||||
memset(&x, 0, sizeof(x));
|
||||
rc = stat(zPath, &x);
|
||||
if( rc<0 ) return -1;
|
||||
if( !S_ISREG(x.st_mode) ) return -1;
|
||||
return x.st_size;
|
||||
}
|
||||
|
||||
/*
|
||||
** A Pseudo-random number generator with a fixed seed. Use this so
|
||||
** that the same sequence of "random" numbers are generated on each
|
||||
@ -315,15 +330,16 @@ static int exportMain(int argc, char **argv){
|
||||
** is undefined in this case.
|
||||
*/
|
||||
static unsigned char *readFile(const char *zName, int *pnByte){
|
||||
FILE *in = fopen(zName, "rb");
|
||||
long nIn;
|
||||
size_t nRead;
|
||||
unsigned char *pBuf;
|
||||
FILE *in; /* FILE from which to read content of zName */
|
||||
sqlite3_int64 nIn; /* Size of zName in bytes */
|
||||
size_t nRead; /* Number of bytes actually read */
|
||||
unsigned char *pBuf; /* Content read from disk */
|
||||
|
||||
nIn = fileSize(zName);
|
||||
if( nIn<0 ) return 0;
|
||||
in = fopen(zName, "rb");
|
||||
if( in==0 ) return 0;
|
||||
fseek(in, 0, SEEK_END);
|
||||
nIn = ftell(in);
|
||||
rewind(in);
|
||||
pBuf = sqlite3_malloc64( nIn+1 );
|
||||
pBuf = sqlite3_malloc64( nIn );
|
||||
if( pBuf==0 ) return 0;
|
||||
nRead = fread(pBuf, nIn, 1, in);
|
||||
fclose(in);
|
||||
@ -331,7 +347,6 @@ static unsigned char *readFile(const char *zName, int *pnByte){
|
||||
sqlite3_free(pBuf);
|
||||
return 0;
|
||||
}
|
||||
pBuf[nIn] = 0;
|
||||
if( pnByte ) *pnByte = nIn;
|
||||
return pBuf;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user