-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShardCursor.cpp
More file actions
86 lines (76 loc) · 1.35 KB
/
Copy pathShardCursor.cpp
File metadata and controls
86 lines (76 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "pch.h"
#include "Cursor.h"
#include "ShardCursor.h"
ShardCursor::ShardCursor(History* H, std::shared_ptr<::Cursor> C)
{
Hist = H;
ActiveCursor = C;
EoF = false;
LastTimestamp = 0;
}
ShardCursor::~ShardCursor()
{
}
int ShardCursor::Next()
{
int Ret = ActiveCursor->Next();
if (Ret == CURSOR_END)
{
if (EoF == false)
{
//Check to see if there is anything else in the next shard...
//DStore DS = Hist->GetNextShardWith(LastTimestamp, Series.c_str());
std::shared_ptr<Cursor> Curse = Hist->GetNextShardWith(LastTimestamp, Series.c_str());
if (Curse == NULL)
{
this->EoF = true;
}
else
{
//OK - we have a new shard.
ActiveCursor = Curse;
return ActiveCursor->Next();
}
}
}
else
{
LastTimestamp = Timestamp();
}
return Ret;
}
TIMESTAMP ShardCursor::Timestamp()
{
return *(TIMESTAMP*)ActiveCursor->Key();
}
double ShardCursor::Value()
{
return *(double*)ActiveCursor->Value();
}
void ShardCursor::SetParent(History* H)
{
Hist = H;
}
void ShardCursor::SetSeries(std::string S)
{
Series = S;
}
int ShardCursor::NextStepCost()
{
if (this->EoF == true)
{
return 1;
}
if (ActiveCursor->Index < ActiveCursor->Active->KeyCount() - 1)
{
return 0;
}
else
{
if (ActiveCursor->Active->Next == 0)
{
return 9999999;
}
return (int)(ActiveCursor->Active->Next - ActiveCursor->Offset);
}
}