今天我偶然发现了(对我而言)奇怪的事情,即当我运行此代码时
asset_idx01
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n asset_idx01 -z spotlight-prod-cluster01 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster01:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c asset_indexconfig.xml -cp lily.zk=spotlight-prod-cluster01
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n asset_idx01 --batch BUILD_REQUESTED
asset_idx02
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n asset_idx02 -z spotlight-prod-cluster02 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster02:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c asset_indexconfig.xml -cp lily.zk=spotlight-prod-cluster02
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n asset_idx02 --batch BUILD_REQUESTED
brightcove_idx01
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n brightcove_idx01 -z spotlight-prod-cluster01 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster01:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c brightcove_indexconfig.xml -cp lily.zk=spotlight-prod-cluster01
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n brightcove_idx01 --batch BUILD_REQUESTED
brightcove_idx02
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n brightcove_idx02 -z spotlight-prod-cluster02 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster02:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c brightcove_indexconfig.xml -cp lily.zk=spotlight-prod-cluster02
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n brightcove_idx02 --batch BUILD_REQUESTED
fortune_idx01
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n fortune_idx01 -z spotlight-prod-cluster01 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster01:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c fortune_indexconfig.xml -cp lily.zk=spotlight-prod-cluster01
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n fortune_idx01 --batch BUILD_REQUESTED
fortune_idx02
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n fortune_idx01 -z spotlight-prod-cluster02 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster02:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c fortune_indexconfig.xml -cp lily.zk=spotlight-prod-cluster02
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n fortune_idx02 --batch BUILD_REQUESTED
populist_idx01
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n populist_idx01 -z spotlight-prod-cluster01 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster01:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c indexconfig.xml -cp lily.zk=spotlight-prod-cluster01
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n populist_idx01 --batch BUILD_REQUESTED
populist_idx02
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n populist_idx02 -z spotlight-prod-cluster02 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster01:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c indexconfig.xml -cp lily.zk=spotlight-prod-cluster02
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n populist_idx02 --batch BUILD_REQUESTED
twitter_stat_idx01
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n twitter_stats_idx01 -z spotlight-prod-cluster01 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster01:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c twitter_stats_indexconfig.xml -cp lily.zk=spotlight-prod-cluster01
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n twitter_stats_idx01 --batch BUILD_REQUESTED
twitter_stat_idx02
/usr/lib/hbase-indexer/bin/hbase-indexer add-indexer -n twitter_stats_idx02 -z spotlight-prod-cluster02 -cp solr.mode=classic -cp solr.shard.1=http://spotlight-prod-cluster02:7575/solr -r org.lilyproject.indexer.hbase.mapper.LilyIndexerComponentFactory -cp solr.sharder=org.lilyproject.indexer.hbase.mapper.LilySharder -c twitter_stats_indexconfig.xml -cp lily.zk=spotlight-prod-cluster02
/usr/lib/hbase-indexer/bin/hbase-indexer update-indexer -n twitter_stats_idx02 --batch BUILD_REQUESTED
我得到的输出看起来像这样:
int i,j;
uint8_t* p = y.data;
for( i = 0; i < y.rows; ++i)
{
for ( j = 0; j < y.cols; ++j)
{
std::cout << y.at<double>(i,j) << std::endl;
std::cout << saturate_cast<double>(p[i*y.cols + j]) << std::endl;
}
}
有人可以向我解释为什么会这样吗?
不应该一样吗?
答案 0 :(得分:2)
p
指向的内存是:
// |251 |123 |63 |254 |... uint8_t
// +----+----+----+----+----+
// | FB | 7B | 3F | FE |... | hex
// +----+----+----+----+----+
// |0.00683212 ... double
当你执行y.at<double>(i,j)
时,基本上是:
p[i*y.cols + j]
您正在以uint8_t
的形式访问数组,因此转换为uint8_t
的{{1}}保持相同的值。当您通过double
访问它时,它会将其作为.at<double>()