示例#1
0
bool SeriesIndex::init(){


    getIndexName();

    printf("Loading index %lu from %s\n", this->id,filename);

    file=fopen(filename, "rb+");
    if(file != NULL){
        size = fread(&this->header,sizeof(this->header),1,file);

        fseek(file,0,SEEK_END); // Move to the end of file
        this->filePoint = (ftell(file) - sizeof(indexHeader))/this->header.timestampSize;

    } else {
        printf("Series Index: Failed to open file\n");
        return false;
    }

    if(size != 1){
        printf("Series Index: Invalid file, incomplete read\n");
        fclose(file);
        return false;
    }


    if(!checkFile()){
        printf("\tSeries Data: Could not recover invalid file\n");
        fclose(file);
        return false;
    }

    fclose(file);


    printf("Index %lu loaded\n",this->id);
    printf("\tPoints: %lu\n",this->filePoint);
    printf("\tOwner: %lu\n",header.owner_id);
    printf("\tTicksPerSecond: %d\n",header.ticksPerSecond);
    printf("\tTimestamp Size: %d\n",header.timestampSize);
    printf("\tRetention Policy: %d\n",header.retentionPolicy);
    printf("\tRetention Value: %lu\n\n\n",header.retentionValue);


    this->indexPoints = DEFAULT_BUFFER_POINTS;


    return true;
}
const NAString
StmtDDLDropIndex::displayLabel1() const
{
  return NAString("Index name: ") + getIndexName();
}