当前位置: 首页>>代码示例>>C++>>正文


C++ ExtentMap::getExtentSize方法代码示例

本文整理汇总了C++中ExtentMap::getExtentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ExtentMap::getExtentSize方法的具体用法?C++ ExtentMap::getExtentSize怎么用?C++ ExtentMap::getExtentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExtentMap的用法示例。


在下文中一共展示了ExtentMap::getExtentSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
	int c;
	string pname(argv[0]);

	opterr = 0;

	while ((c = getopt(argc, argv, "vdh")) != EOF)
		switch (c)
		{
		case 'v':
			vflg++;
			break;
		case 'd':
			dflg = true;
			break;
		case 'h':
		case '?':
		default:
			usage(pname);
			return (c == 'h' ? 0 : 1);
			break;
		}

	const Config* cf = Config::makeConfig();
	DBRoot = cf->getConfig("SystemConfig", "DBRoot");
	pattern = DBRoot + "/[0-9][0-9][0-9].dir/[0-9][0-9][0-9].dir/[0-9][0-9][0-9].dir/FILE[0-9][0-9][0-9].cdf";

	if (vflg)
	{
		cout << "Using DBRoot " << DBRoot << endl;
	}

	if (access(DBRoot.c_str(), X_OK) != 0)
	{
		cerr << "Could not scan DBRoot " << DBRoot << '!' << endl;
		return 1;
	}

	ExtentMap em;
	extentSize = em.getExtentSize();

	if (vflg)
	{
		cout << "System extent size is " << extentSize << " blocks" << endl;
	}

	if (nftw(DBRoot.c_str(), walkDB, 64, FTW_PHYS|FTW_ACTIONRETVAL) != 0)
	{
		cerr << "Error processing files in DBRoot " << DBRoot << '!' << endl;
		return 1;
	}

	return 0;
}
开发者ID:hans511002,项目名称:erydb,代码行数:55,代码来源:main.cpp

示例2: extentMap_freelist

    void extentMap_freelist()
    {
        ExtentMap em;
        int i, allocdSize, iterations = 1400;  // (EM_INITIAL_SIZE + 4*EM_INCREMENT)
        vector<LBID_t> lbids;
        const int extentSize = em.getExtentSize();

        for (i = 0; i < iterations; i++)
        {
            em.createExtent(extentSize, i, lbids, allocdSize);
            em.confirmChanges();
            CPPUNIT_ASSERT(lbids.back() == static_cast<LBID_t>(i * extentSize));
        }

        em.checkConsistency();

        //frag the lbid space to blow up the free list
        for (i = 0; i < iterations; i += 2)
        {
            em.deleteOID(i);
            em.confirmChanges();
        }

        em.checkConsistency();

        //fill in the holes
        for (i = 0; i < iterations; i += 2)
        {
            em.createExtent(extentSize, i, lbids, allocdSize);
            em.confirmChanges();
        }

        for (i = 0; i < iterations; i += 2)
        {
            em.deleteOID(i);
            em.confirmChanges();
        }

        for (i = 1; i < iterations; i += 2)
        {
            em.deleteOID(i);
            em.confirmChanges();
        }

        em.checkConsistency();
    }
开发者ID:mariadb-corporation,项目名称:mariadb-columnstore-engine,代码行数:46,代码来源:tdriver-load.cpp

示例3: catch

    void extentMap_good_1()
    {
        ExtentMap em;
        int i, err, oid, iterations = 1300;  // (EM_INITIAL_SIZE + 3*EM_INCREMENT)
        int caughtException = 0, allocdSize;
        uint32_t fbo, hwm;
        BRM::HWM_t hwm2;
        BRM::VER_t txnID;
        vector<LBID_t> lbids;
        const uint32_t extentSize = em.getExtentSize();

        em.load(string("EMImage"));
        em.checkConsistency();

        for (i = 0; i < iterations; i++)
        {
            err = em.lookup(static_cast<LBID_t>(i * extentSize), oid, fbo);
            CPPUNIT_ASSERT(err == 0);
            CPPUNIT_ASSERT(oid == i);
            CPPUNIT_ASSERT(fbo == 0);

            if (i != 0)
            {
                err = em.lookup(static_cast<LBID_t>(i * extentSize - 1), oid, fbo);
                CPPUNIT_ASSERT(err == 0);
                CPPUNIT_ASSERT(oid == i - 1);
                CPPUNIT_ASSERT(fbo == extentSize - 1);
            }

            if (i != iterations - 1)
            {
                err = em.lookup(static_cast<LBID_t>(i * extentSize + 1), oid, fbo);
                CPPUNIT_ASSERT(err == 0);
                CPPUNIT_ASSERT(oid == i);
                CPPUNIT_ASSERT(fbo == 1);
            }
        }

        em.checkConsistency();

        err = em.lookup(static_cast<LBID_t>(i * extentSize), oid, fbo);
        CPPUNIT_ASSERT(err == -1);

        for (i = 0; i < iterations; i++)
        {
            err = em.getBulkInsertVars(static_cast<LBID_t>(i * extentSize),
                                       hwm2, txnID);
            CPPUNIT_ASSERT(err == 0);
            CPPUNIT_ASSERT(hwm2 == 0);
            CPPUNIT_ASSERT(txnID == 0);
            err = em.setBulkInsertVars(static_cast<LBID_t>(i * extentSize),
                                       i, i + 1);
            em.confirmChanges();
            CPPUNIT_ASSERT(err == 0);
            err = em.getBulkInsertVars(static_cast<LBID_t>(i * extentSize),
                                       hwm2, txnID);
            CPPUNIT_ASSERT(err == 0);
            CPPUNIT_ASSERT(hwm2 == static_cast<LBID_t>(i));
            CPPUNIT_ASSERT(txnID == static_cast<VER_t>(i + 1));

            hwm = em.getHWM(i);
            CPPUNIT_ASSERT(hwm == 0);
            em.setHWM(i, (i > (extentSize - 1) ? extentSize - 1 : i));
            em.confirmChanges();
            hwm = em.getHWM(i);
            CPPUNIT_ASSERT(hwm == static_cast<uint32_t>(i > extentSize - 1 ? extentSize - 1 : i));
        }

        em.checkConsistency();

#ifdef BRM_DEBUG
        caughtException = 0;

        try
        {
            em.setHWM(i, hwm);
        }
        catch (std::invalid_argument e)
        {
            caughtException = 1;
        }

        em.undoChanges();
        CPPUNIT_ASSERT(caughtException == 1);
#endif

        for (i = 0; i < iterations; i++)
        {
            em.deleteOID(i);
            em.confirmChanges();
        }

#ifdef BRM_DEBUG
        caughtException = 0;

        try
        {
            em.deleteOID(i);
        }
        catch (std::invalid_argument& e)
//.........这里部分代码省略.........
开发者ID:mariadb-corporation,项目名称:mariadb-columnstore-engine,代码行数:101,代码来源:tdriver-load.cpp

示例4: EMRunner

static void* EMRunner(void *arg)
{
	
	// keep track of LBID ranges allocated here and
	// randomly allocate, lookup, delete, get/set HWM, and
	// destroy the EM object.
	
	struct EMEntries {
		u_int64_t LBIDstart;
		u_int32_t size;
		int OID;
		u_int32_t FBO;
		u_int32_t HWM;
		u_int32_t secondHWM;
		u_int32_t txnID;
		struct EMEntries *next;
		EMEntries() { next = NULL; HWM = 0; secondHWM = 0; txnID = 0; }
	};
	
#ifdef BRM_VERBOSE
	int threadNum = reinterpret_cast<int>(arg);
#endif
	int op, listSize = 0, i;
	uint randstate;
	struct EMEntries *head = NULL, *tmp;
	struct timeval tv;
	ExtentMap *em;
	vector<LBID_t> lbids;

#ifdef BRM_VERBOSE
	cerr << "thread number " << threadNum << " started." << endl;
#endif
	
	gettimeofday(&tv, NULL);
	randstate = static_cast<uint>(tv.tv_usec);
	em = new ExtentMap();
	
	while (!threadStop) {
		op = rand_r(&randstate) % 10;
#ifdef BRM_VERBOSE
		cerr << "next op is " << op << endl;
#endif
		switch (op) {
			case 0:   //allocate space for a new file
			{
				struct EMEntries *newEm;
				int size = rand_r(&randstate) % 102399 + 1;
				int entries, OID, allocdSize;
				
				pthread_mutex_lock(&mutex);
				OID = oid++;
				pthread_mutex_unlock(&mutex);
				
				em->createExtent(size, OID, lbids, allocdSize);
				em->confirmChanges();
				
				entries = size/em->getExtentSize();
				if ((size % em->getExtentSize()) != 0)
					entries++;
				
				CPPUNIT_ASSERT((uint)entries == lbids.size());
				
				for (i = 0 ; i < entries; i++) {
				
					newEm = new EMEntries();
					newEm->size = em->getExtentSize();
					newEm->OID = OID;
					newEm->FBO = i * em->getExtentSize();
					newEm->LBIDstart = lbids[i];
				
					newEm->next = head;
					head = newEm;
					listSize++;
				}
#ifdef BRM_VERBOSE
				cerr << "created new space for OID " << newEm->OID << endl;
#endif
				em->checkConsistency();
				break;
			}
			case 1:		//allocate space for an existing file
			{
				if (listSize == 0)
					break;
				
				struct EMEntries *newEm, *tmp;
				int size = rand_r(&randstate) % 102399 + 1;
				int fileRand = rand_r(&randstate) % listSize;
				int i, lastExtent, blockEnd, oid;
				int tmpHWM, entries, allocdSize;
				vector<LBID_t> lbids;

				for (i = 0, tmp = head; i < fileRand; i++)
					tmp = tmp->next;
				
				oid = tmp->OID;
				
				for (lastExtent = 0, tmp = head; tmp != NULL; tmp = tmp->next) {
					if (tmp->OID != oid) 
						continue;
//.........这里部分代码省略.........
开发者ID:demonlife,项目名称:infinidb,代码行数:101,代码来源:tdriver-dbrm2.cpp


注:本文中的ExtentMap::getExtentSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。