本文整理汇总了C++中MDArray::createIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ MDArray::createIterator方法的具体用法?C++ MDArray::createIterator怎么用?C++ MDArray::createIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDArray
的用法示例。
在下文中一共展示了MDArray::createIterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sequentialRead
/// sequentially read nxn array in row major order
void sequentialRead()
{
MDArray *array = new MDArray(fileName);
PagedStorageContainer::resetPerfCounts();
gettimeofday(&tim, NULL);
t1 = tim.tv_sec + tim.tv_usec/1000000.0;
MDIterator *it = array->createIterator(Dense, row);
while (it->moveNext())
{
it->get(coord, datum);
}
delete it;
delete array;
gettimeofday(&tim, NULL);
t2 = tim.tv_sec + tim.tv_usec/1000000.0;
readCount += PagedStorageContainer::readCount;
writeCount += PagedStorageContainer::writeCount;
accessTime += PagedStorageContainer::accessTime;
execTime += (t2 - t1);
fprintf(pFile, "%-14s %8i %8i %11.3f %11.3f\n", "seq read", PagedStorageContainer::readCount, PagedStorageContainer::writeCount, PagedStorageContainer::accessTime, t2-t1);
}
示例2: stridedIteratorInsert
/// strided insertion, using the iterator
void stridedIteratorInsert()
{
MDArray *array;
Btree::MSplitter<Datum_t> leafSp;
Btree::MSplitter<PID_t> intSp;
if (type == DMA)
array = new MDArray(dim, type, row, fileName);
else if (type == BTREE)
array = new MDArray(dim, row, &leafSp, &intSp, fileName);
PagedStorageContainer::resetPerfCounts();
gettimeofday(&tim, NULL);
t1 = tim.tv_sec + tim.tv_usec/1000000.0;
MDIterator *it = array->createIterator(Dense, col);
while (it->moveNext())
{
it->put(12345);
}
delete it;
delete array;
gettimeofday(&tim, NULL);
t2 = tim.tv_sec + tim.tv_usec/1000000.0;
readCount += PagedStorageContainer::readCount;
writeCount += PagedStorageContainer::writeCount;
accessTime += PagedStorageContainer::accessTime;
execTime += (t2 - t1);
fprintf(pFile, "%-14s %8i %8i %11.3f %11.3f\n", "batch stride", PagedStorageContainer::readCount, PagedStorageContainer::writeCount, PagedStorageContainer::accessTime, t2-t1);
}
示例3: dim
TEST(MDArray, Read)
{
i64 rows = 20L;
i64 cols = 20L;
MDCoord dim(2, rows, cols);
StorageType type = DMA;
i64 blockDims[] = {10L, 10L};
u8 blockOrders[] = {0, 1};
u8 microOrders[] = {0, 1};
//permute(blockOrders, dim.nDim);
//permute(microOrders, dim.nDim);
Linearization *block = new BlockBased(dim.nDim, dim.coords, blockDims,
blockOrders, microOrders);
const char *fileName = "test1.bin";
MDCoord key;
Datum_t datum = 1.0;
MDArray *array = new MDArray(dim, type, block, fileName);
MDIterator *it = array->createIterator(Dense, block);
srand(time(NULL));
const int num=100;
std::map<int, MDCoord> keys;
std::map<int, Datum_t> data;
int total = rows*cols;
for(int i=0; i<num; i++) {
int k = rand() % total;
if (data.find(k) == data.end()) {
data[k] = rand();
it->setIndexRange(k, k+1);
it->moveNext();
it->put(data[k]);
MDCoord key;
it->get(key, datum);
keys[k] = key;
}
else
i--;
}
delete it;
delete array;
array = new MDArray(fileName);
Datum_t datum1;
for (std::map<int,MDCoord>::iterator s = keys.begin();
s != keys.end();
++s) {
//cout<<"checking "<<s->second.toString()<<endl;
array->get(s->second, datum1);
ASSERT_DOUBLE_EQ(data[s->first], datum1);
}
delete array;
delete block;
}