本文整理汇总了C++中Ardb::GetL1Cache方法的典型用法代码示例。如果您正苦于以下问题:C++ Ardb::GetL1Cache方法的具体用法?C++ Ardb::GetL1Cache怎么用?C++ Ardb::GetL1Cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ardb
的用法示例。
在下文中一共展示了Ardb::GetL1Cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_geo
void test_geo(Ardb& db)
{
DBID dbid = 0;
db.ZClear(dbid, "mygeo");
double x = 300.3;
double y = 300.3;
double p_x = 1000.0;
double p_y = 1000.0;
double raius = 1000;
GeoPointArray cmp;
for (uint32 i = 0; i < 100000; i++)
{
char name[100];
sprintf(name, "p%u", i);
double xx = x + i * 0.1;
double yy = y + i * 0.1;
if (((xx - p_x) * (xx - p_x) + (yy - p_y) * (yy - p_y)) < raius * raius)
{
GeoPoint p;
p.x = xx;
p.y = yy;
cmp.push_back(p);
}
GeoAddOptions add;
add.coord_type = 2;
add.x = x + i * 0.1;
add.y = y + i * 0.1;
add.value = name;
db.GeoAdd(dbid, "mygeo", add);
}
if(db.GetL1Cache() != NULL)
{
db.GetL1Cache()->SyncLoad(dbid, "mygeo");
}
GeoSearchOptions options;
StringArray args;
std::string err;
string_to_string_array("MERCATOR 1000.0 1000.0 RADIUS 1000 ASC WITHCOORDINATES WITHDISTANCES", args);
options.Parse(args, err);
ValueDataDeque result;
db.GeoSearch(dbid, "mygeo", options, result);
CHECK_FATAL(cmp.size() != result.size() / 4, "Search failed with %u elements while expected %u", result.size() / 4,
cmp.size());
uint64 start = get_current_epoch_millis();
for (uint32 i = 0; i < 10000; i++)
{
result.clear();
options.x = p_x + i * 0.1;
options.y = p_y + i * 0.1;
options.radius = 100;
db.GeoSearch(dbid, "mygeo", options, result);
}
uint64 end = get_current_epoch_millis();
for (uint32 i = 0; i < result.size(); i += 4)
{
INFO_LOG("GeoPoint:%s x:%.2f, y:%.2f, distance:%.2f", result[i].bytes_value.c_str(),
result[i + 1].NumberValue(), result[i + 2].NumberValue(), result[i + 3].NumberValue());
}
INFO_LOG("Found %d points for search while expected %d points", result.size() / 4, cmp.size());
INFO_LOG("Cost %lldms to geo search 100000 zset elements 10000 times", (end - start));
}