如何在给出之前获得N条记录?
我有以下表结构:
Id, Message
1, John Doe
2, Jane Smith
3, Error
4, Jane Smith
5, Michael Pirs
7, Gabriel Angelos
8, Error
Run Code Online (Sandbox Code Playgroud)
有没有办法在每个错误之前获取N条记录并加入所有这些记录?因此,N = 2的预期结果将是
1, John Doe
2, Jane Smith
5, Michael Pirs
7, Gabriel Angelos
Run Code Online (Sandbox Code Playgroud)
多年来我一直没有使用C++,现在我用test编写了c ++项目.
当我开始调试时,我发现奇怪的是,默认情况下变量没有初始化为零.例如,当我看到我的类未初始化的变量(unsigned int)时,我看到它的值3452816845被预期的zeo ...这会导致单元测试中的错误.我使用这样的初始化:
TEST_METHOD(TestPlus)
{
Entity* entity = new Entity();
entity->mCreateOperator(entity->Plus);
entity->SetContactValue(1);
entity->SetContactValue(2);
entity->mProcessLast();
Assert::IsTrue(entity->GetContactValue((1+2));
}
Run Code Online (Sandbox Code Playgroud)
我有Entity类的默认构造函数:
Entity::Entity(void) {/*some internal array initialization*/}
Run Code Online (Sandbox Code Playgroud)
我认为当我使用new关键字时,所有类变量都将由C++运行时初始化为0.
我错过了什么吗?
例如,看起来我不能将此相似性度量用于sklearnKDTree,但我需要,因为我正在使用测量词向量相似性。对于这种情况,什么是快速稳健的定制算法?我知道Local Sensitivity Hashing,但它应该调整和测试很多才能找到参数。
我有下一个类,并希望用0初始化_operators数组:
//Entity.h
class Entity
{
static const unsigned short operatorTypeColumn = 1;
static const unsigned short outputValueColumn = 4;
private:
mainDataType _operators[operatorsMaxCount][operatorsTableWidth];
}
//Entity.cpp. I thought this should work in C++ v11
Entity::Entity(void) : _operators[operatorsMaxCount][operatorsTableWidth]
{
}
Run Code Online (Sandbox Code Playgroud)
我以为这是在C++ v11中出售的工作,但是我得到了错误...我怎么能用0来初始化数组..丑陋的?我不想让它静止