コード例 #1
0
void MockReadonlyStore::load(PathRef fpath) {
	FileStream fp(fpath.string().c_str(), "rb");
	fp.disbuf();
	NativeDataInput<InputBuffer> dio; dio.attach(&fp);
	uint64_t fixlen, rows, strSize;
	dio >> fixlen;
	dio >> rows;
	dio >> strSize;
	m_fixedLen = size_t(fixlen);
	m_rows.strpool.resize_no_init(size_t(strSize));
	if (0 == m_fixedLen) {
		m_rows.offsets.resize_no_init(size_t(rows + 1));
		dio.ensureRead(m_rows.offsets.data(), m_rows.offsets.used_mem_size());
	#if !defined(NDEBUG)
		assert(m_rows.strpool.size() == m_rows.offsets.back());
		for (size_t i = 0; i < rows; ++i) {
			assert(m_rows.offsets[i] < m_rows.offsets[i+1]);
		}
	#endif
	} else {
		assert(m_rows.strpool.size() % m_fixedLen == 0);
		assert(m_rows.strpool.size() / m_fixedLen == rows);
	}
	dio.ensureRead(m_rows.strpool.data(), m_rows.strpool.used_mem_size());
}
コード例 #2
0
ファイル: db_index.cpp プロジェクト: hexiaofeng/terark-db
void EmptyIndexStore::save(PathRef fpath) const {
	std::string strFpath = fpath.string();
	if (!fstring(strFpath).endsWith(".empty")) {
		strFpath += ".empty";
	}
	else {
		strFpath = strFpath;
	}
	FileStream fp(strFpath.c_str(), "wb");
}
コード例 #3
0
void MockReadonlyIndex::save(PathRef fpath) const {
	FileStream fp(fpath.string().c_str(), "wb");
	fp.disbuf();
	NativeDataOutput<OutputBuffer> dio; dio.attach(&fp);
	size_t rows = m_ids.size();
	dio << uint64_t(m_fixedLen);
	dio << uint64_t(rows);
	dio << uint64_t(m_keys.strpool.size());
	dio.ensureWrite(m_ids.data(), m_ids.used_mem_size());
	if (m_fixedLen) {
		assert(m_keys.size() == 0);
		assert(m_keys.strpool.size() == m_fixedLen * rows);
	} else {
		assert(m_keys.size() == rows);
		dio.ensureWrite(m_keys.offsets.data(), m_keys.offsets.used_mem_size());
	}
	dio.ensureWrite(m_keys.strpool.data(), m_keys.strpool.used_mem_size());
}
コード例 #4
0
void MockReadonlyIndex::load(PathRef fpath) {
	FileStream fp(fpath.string().c_str(), "rb");
	fp.disbuf();
	NativeDataInput<InputBuffer> dio; dio.attach(&fp);
	uint64_t fixlen, rows, keylen;
	dio >> fixlen;
	dio >> rows;
	dio >> keylen;
	m_ids.resize_no_init(size_t(rows));
	dio.ensureRead(m_ids.data(), m_ids.used_mem_size());
	if (0 == fixlen) {
		m_keys.offsets.resize_no_init(size_t(rows + 1));
		dio.ensureRead(m_keys.offsets.data(), m_keys.offsets.used_mem_size());
	}
	else {
		assert(fixlen * rows == keylen);
	}
	m_keys.strpool.resize_no_init(size_t(keylen));
	dio.ensureRead(m_keys.strpool.data(), size_t(keylen));
	m_fixedLen = size_t(fixlen);
}
コード例 #5
0
void MockReadonlyStore::save(PathRef path) const {
	std::string fpath = path.string() + ".mock";
	FileStream fp(fpath.c_str(), "wb");
	fp.disbuf();
	NativeDataOutput<OutputBuffer> dio; dio.attach(&fp);
	size_t rows = m_fixedLen ? m_rows.strpool.size() / m_fixedLen : m_rows.size();
	dio << uint64_t(m_fixedLen);
	dio << uint64_t(rows);
	dio << uint64_t(m_rows.strpool.size());
	if (0 == m_fixedLen) {
	#if !defined(NDEBUG)
		assert(m_rows.strpool.size() == m_rows.offsets.back());
		for (size_t i = 0; i < rows; ++i) {
			assert(m_rows.offsets[i] < m_rows.offsets[i+1]);
		}
	#endif
		dio.ensureWrite(m_rows.offsets.data(), m_rows.offsets.used_mem_size());
	} else {
		assert(m_rows.strpool.size() % m_fixedLen == 0);
	}
	dio.ensureWrite(m_rows.strpool.data(), m_rows.strpool.used_mem_size());
}
コード例 #6
0
ファイル: db_index.cpp プロジェクト: hexiaofeng/terark-db
void EmptyIndexStore::load(PathRef fpath) {
	std::string strFpath = fpath.string() + ".empty";
//	FileStream fp(strFpath.c_str(), "wb");
}
コード例 #7
0
void MockWritableIndex<Key>::load(PathRef fpath) {
	FileStream fp(fpath.string().c_str(), "rb");
	fp.disbuf();
	NativeDataInput<InputBuffer> dio; dio.attach(&fp);
	dio >> m_kv;
}
コード例 #8
0
void MockWritableIndex<Key>::save(PathRef fpath) const {
	FileStream fp(fpath.string().c_str(), "wb");
	fp.disbuf();
	NativeDataOutput<OutputBuffer> dio; dio.attach(&fp);
	dio << m_kv;
}