コード例 #1
0
ファイル: iskive.cpp プロジェクト: agonen/fastbit
/// Reconstruct an index from a piece of consecutive memory.  Unlike the
/// implementations for other type indices, this function always reads all
/// bit vectors.
int ibis::skive::read(ibis::fileManager::storage* st) {
    if (st == 0) return -1;
    if (st->begin()[5] != ibis::index::SKIVE &&
	st->begin()[5] != ibis::index::SLICE) return -3;
    clear(); // clear the current conent

    nrows = *(reinterpret_cast<uint32_t*>(st->begin()+8));
    uint32_t pos = 8+sizeof(uint32_t);
    const uint32_t nobs = *(reinterpret_cast<uint32_t*>(st->begin()+pos));
    pos += sizeof(uint32_t);
    const uint32_t card = *(reinterpret_cast<uint32_t*>(st->begin()+pos));
    pos += sizeof(uint32_t) + 7;
    pos = 8 * (pos / 8);
    int ierr = initOffsets(st, pos + sizeof(double)*card, nobs);
    if (ierr < 0)
	return ierr;

    { // limit the scope of dbl
	array_t<double> dbl(st, pos, card);
	vals.swap(dbl);
    }
    {
	pos += sizeof(double)*card + sizeof(int32_t)*(nobs+1);
	array_t<uint32_t> szt(st, pos, card);
	cnts.swap(szt);
    }

    initBitmaps(st);
    activate();
    return 0;
} // ibis::skive::read
コード例 #2
0
ファイル: maindialog.cpp プロジェクト: dsimba/lmaxconnective
void MainDialog::setupTable()
{
    tableview_.reset(new QuotesTableView(this));

    QSize szt( width() - 20, height() - startButton_->height() - 30);

    netman_->model()->resetView(tableview_.data());

    tableview_->setFixedSize(szt);
    tableview_->setFont(*Global::compact);
    tableview_->move(10, startButton_->height() + 20);
    tableview_->show();
    tableview_->updateStyles();

    tableview_->setModel(netman_->model());
}
コード例 #3
0
ファイル: iskive.cpp プロジェクト: agonen/fastbit
/// Read the index contained in the file f.  This function always reads all
/// bitvectors.
int ibis::skive::read(const char* f) {
    std::string fnm;
    indexFileName(fnm, f);

    int fdes = UnixOpen(fnm.c_str(), OPEN_READONLY);
    if (fdes < 0) {
	LOGGER(ibis::gVerbose > 0)
	    << "Warning -- skive[" << col->partition()->name() << '.'
	    << col->name() << "]::read failed to open " << fnm;
	return -1; // can not do anything else
    }

    char header[8];
    IBIS_BLOCK_GUARD(UnixClose, fdes);
#if defined(_WIN32) && defined(_MSC_VER)
    (void)_setmode(fdes, _O_BINARY);
#endif
    int ierr = UnixRead(fdes, static_cast<void*>(header), 8);
    if (ierr != 8) {
	LOGGER(ibis::gVerbose > 0)
	    << "Warning -- skive[" << col->partition()->name() << '.'
	    << col->name() << "]::read failed to read 8 bytes from "
	    << fnm;
	return -2;
    }
    if (!(header[0] == '#' && header[1] == 'I' &&
	  header[2] == 'B' && header[3] == 'I' &&
	  header[4] == 'S' &&
	  (header[5] == static_cast<char>(ibis::index::SKIVE) ||
	   header[5] == static_cast<char>(ibis::index::SLICE)) &&
	  (header[6] == 8 || header[6] == 4) &&
	  header[7] == static_cast<char>(0))) {
	if (ibis::gVerbose > 0) {
	    ibis::util::logger lg;
	    lg() << "Warning -- skive[" << col->partition()->name() << '.'
		 << col->name() << "]::read the header from " << fnm << " (";
	    printHeader(lg(), header);
	    lg() << ") does not contain the expected values";
	}
	return -3;
    }

    uint32_t dim[3]; // nrows, nobs, card
    size_t begin, end;
    clear(); // clear the current content

    ierr = UnixRead(fdes, static_cast<void*>(dim), 3*sizeof(uint32_t));
    nrows = dim[0];
    // read vals
    begin = 8*((3*sizeof(uint32_t) + 15) / 8);
    end = begin + dim[2] * sizeof(double);
    {
	array_t<double> dbl(fnm.c_str(), fdes, begin, end);
	vals.swap(dbl);
    }
    // read the offsets
    begin = end;
    end += header[6] * (dim[1] + 1);
    ierr = initOffsets(fdes, header[6], begin, dim[1]);
    if (ierr < 0)
	return ierr;

    // cnts
    begin = end;
    end += sizeof(uint32_t) * dim[2];
    {
	array_t<uint32_t> szt(fnm.c_str(), fdes, begin, end);
	cnts.swap(szt);
    }
    ibis::fileManager::instance().recordPages(0, end);

    initBitmaps(fdes);
    activate();
    return 0;
} // ibis::skive::read