feat:change fseek and fread to pread in StringIndex
This commit is contained in:
parent
e5fba910aa
commit
0f936c75ea
|
@ -92,8 +92,9 @@ bool StringIndexFile::randomAccess(unsigned id, string *str)
|
|||
|
||||
allocBuffer(length);
|
||||
|
||||
fseek(this->value_file, offset, SEEK_SET);
|
||||
fread(this->buffer, sizeof(char), length, this->value_file);
|
||||
//fseek(this->value_file, offset, SEEK_SET);
|
||||
//fread(this->buffer, sizeof(char), length, this->value_file);
|
||||
pread(fileno(value_file), this->buffer, sizeof(char)*length, offset);
|
||||
this->buffer[length] = '\0';
|
||||
|
||||
*str = string(this->buffer);
|
||||
|
@ -124,6 +125,7 @@ void StringIndexFile::trySequenceAccess()
|
|||
if (this->type == Predicate)
|
||||
cout << "Predicate StringIndex ";
|
||||
|
||||
long current_offset = 0;
|
||||
if ((max_end - min_begin) / 800000L < (long)this->request.size())
|
||||
{
|
||||
cout << "sequence access." << endl;
|
||||
|
@ -134,7 +136,8 @@ void StringIndexFile::trySequenceAccess()
|
|||
char *block = new char[MAX_BLOCK_SIZE];
|
||||
|
||||
long current_block_begin = min_begin;
|
||||
fseek(this->value_file, current_block_begin, SEEK_SET);
|
||||
//fseek(this->value_file, current_block_begin, SEEK_SET);
|
||||
current_offset = current_block_begin;
|
||||
|
||||
while (current_block_begin < max_end)
|
||||
{
|
||||
|
@ -143,11 +146,14 @@ void StringIndexFile::trySequenceAccess()
|
|||
if (current_block_end <= this->request[pos].offset)
|
||||
{
|
||||
current_block_begin = this->request[pos].offset;
|
||||
fseek(this->value_file, current_block_begin, SEEK_SET);
|
||||
//fseek(this->value_file, current_block_begin, SEEK_SET);
|
||||
current_offset = current_block_begin;
|
||||
current_block_end = min(current_block_begin + MAX_BLOCK_SIZE, max_end);
|
||||
}
|
||||
|
||||
fread(block, sizeof(char), current_block_end - current_block_begin, this->value_file);
|
||||
//fread(block, sizeof(char), current_block_end - current_block_begin, this->value_file);
|
||||
pread(fileno(this->value_file), block, sizeof(char)*(current_block_end-current_block_begin), current_offset);
|
||||
current_offset += sizeof(char)*(current_block_end-current_block_begin);
|
||||
|
||||
while (pos < (int)this->request.size())
|
||||
{
|
||||
|
|
|
@ -55,6 +55,7 @@ public class Benchmark
|
|||
spq[4] = "select distinct ?x where { ?x <rdf:type> <ub:UndergraduateStudent>. }";
|
||||
spq[5] = "select ?s ?o where { ?s ?p ?o . }";
|
||||
int tnum = 6;
|
||||
//tnum = 3000;
|
||||
//tnum = 12000;
|
||||
//tnum = 30000;
|
||||
MyThread[] qt = new MyThread[tnum];
|
||||
|
|
Loading…
Reference in New Issue