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


C++ Extent::getRecord方法代码示例

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


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

示例1: getNextRecordData

char* Namespace::getNextRecordData(int &recordSize)
{
	Record *rec;

	if (extentCursor.isNull()) // the first time after connection the extent cursor will be null
	{
		extentCursor = firstExtentLoc; // so, get the first extent of the colection
		if (_DEBUG)
			LOGI("getting first extent");
	}

	if (extentCursor.isNull()) // if first extent is null, then no extents exist
		return NULL;  // no extents

	Extent* extent = db->getExtent(extentCursor);

	if (recordCursor == -1)	// the first time the record cursor will be null as well
	{
		recordCursor = extent->firstRecord;	// get the first record of the extent

		if (recordCursor == -1)	// if first record is null, then no records exist
			return NULL;  // no records

		rec = extent->getRecord(recordCursor);
	}
	else // else, the cursor shows the previous record, should take the next one and return its data
	{
		rec = extent->getRecord(recordCursor);

		if (rec->nextRecLoc == -1) // if its next record is null, then go to next extent
		{
			if (extent->nextExtent.isNull()) // if the next extent is null, then no more extents
			{
				return NULL;  // no more records
			}
			else							// proceed with the next extent
			{
				extentCursor = extent->nextExtent;
				recordCursor = -1;
				return getNextRecordData(recordSize);
			}
		}
		else
		{
			recordCursor = rec->nextRecLoc;	// next record exists, so put the cursor on it
			if (_DEBUG)
				LOGI("getting next record");
			rec = extent->getRecord(recordCursor);
		}
	}

	int bsonSize = 0;
	bson_little_endian32( &bsonSize, rec->data);
	char *val = (char*) malloc((bsonSize + 128) * sizeof(char));
	int cur = 0;
	return bson_to_json(val, rec->data, 0, true, 0, recordSize, cur);
}
开发者ID:vamitrou,项目名称:JSONDroid,代码行数:57,代码来源:Namespace.cpp

示例2: getNextRecord

Record* Namespace::getNextRecord()
{
	Record *rec;
	if (extentCursor.isNull()) // the first time after connection the extent cursor will be null
	{
		extentCursor = firstExtentLoc; // so, get the first extent of the colection
		if (_DEBUG)
			LOGI("getting first extent");
	}

	if (extentCursor.isNull()) // if first extent is null, then no extents exist
		return NULL;  // no extents

	Extent* extent = db->getExtent(extentCursor);

	if (recordCursor == -1)	// the first time the record cursor will be null as well
	{
		recordCursor = extent->firstRecord;	// get the first record of the extent

		if (recordCursor == -1)	// if first record is null, then no records exist
			return NULL;  // no records

		rec = extent->getRecord(recordCursor);
	}
	else // else, the cursor shows the previous record, should take the next one and return its data
	{
		rec = extent->getRecord(recordCursor);

		if (rec->nextRecLoc == -1) // if its next record is null, then go to next extent
		{
			if (extent->nextExtent.isNull()) // if the next extent is null, then no more extents
			{
				return NULL;  // no more records
			}
			else							// proceed with the next extent
			{
				extentCursor = extent->nextExtent;
				recordCursor = -1;
				return getNextRecord();
			}
		}
		else
		{
			recordCursor = rec->nextRecLoc;	// next record exists, so put the cursor on it
			if (_DEBUG)
				LOGI("getting next record");
			rec = extent->getRecord(recordCursor);
		}
	}
	return rec;
}
开发者ID:vamitrou,项目名称:JSONDroid,代码行数:51,代码来源:Namespace.cpp

示例3: getData

string Namespace::getData()
{
	string data = "{\"docs\":[";
	DiskLoc nextExtentLoc = firstExtentLoc;
	while (!nextExtentLoc.isNull())
	{
		Extent* extent = db->getExtent(nextExtentLoc);
		int nextRecordOffset = extent->firstRecord;
		while (nextRecordOffset != -1)
		{
			Record* record = extent->getRecord(nextRecordOffset);
			//LOGI(record->data);
			data.append(record->data);

			nextRecordOffset = record->nextRecLoc;

			if (nextRecordOffset != -1)
				data.append(",");
		}

		nextExtentLoc = extent->nextExtent;
	}
	data.append("]}");
	return data;
}
开发者ID:vamitrou,项目名称:JSONDroid,代码行数:25,代码来源:Namespace.cpp

示例4: getNextBatch

char* Namespace::getNextBatch(int &count)
{
	if (_DEBUG)
		LOGI("get next batch");

	int batchSize = 0;
	int sizes[count];
	int jsonSize = 0;
	char *records[count]; //= (char**)malloc(count*sizeof(char*));

	int lastRetrievedRecord = -1, recordSize, skip = 0;

	int i = 0;
	Extent *extent = getFirstExtent();
	while (extent != NULL)
	{
		lastRetrievedRecord = -1;
		Record *record = extent->getFirstRecord();
		while (record != NULL && i < count)
		{
			recordSize = 0;

			int bsonSize = 0;
			bson_little_endian32( &bsonSize, record->data);
			//FORCE_LOG_INT("bsonSize: ", bsonSize);
			char *val = (char*) malloc((bsonSize + 100) * sizeof(char));
			int cur = 0;
			val = bson_to_json(val, record->data, 0, true, bsonSize, recordSize,
					cur);

			records[i] = val;
			batchSize += recordSize;
			sizes[i] = recordSize;
			jsonSize += recordSize;

			record = extent->getRecord(record->nextRecLoc);

			i++;
		}

		extent = db->getExtent(extent->nextExtent);
	}

	count = i;
	FORCE_LOG_INT("count: ", i);

	return serializeJSON(records, jsonSize, count, sizes);
}
开发者ID:vamitrou,项目名称:JSONDroid,代码行数:48,代码来源:Namespace.cpp

示例5: printData

void Namespace::printData()
{
	DiskLoc nextExtentLoc = firstExtentLoc;
	while (!nextExtentLoc.isNull())
	{
		Extent* extent = db->getExtent(nextExtentLoc);
		int nextRecordOffset = extent->firstRecord;
		while (nextRecordOffset != -1)
		{
			LOG_INT("print record num: ", nextRecordOffset);
			Record* record = extent->getRecord(nextRecordOffset);
			int jsonSize = 0;
//			bson_to_json(((bson*)record->data)->data, 0, true, 0, jsonSize);
			nextRecordOffset = record->nextRecLoc;
		}

		nextExtentLoc = extent->nextExtent;
	}
}
开发者ID:vamitrou,项目名称:JSONDroid,代码行数:19,代码来源:Namespace.cpp


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