Skip to content

Commit 80f1705

Browse files
author
Roman Kisel
committed
read from spaces support
1 parent 36565cf commit 80f1705

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

src/swig/common.i

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ public:
144144
Can potentially reduce max throughput and increase CPU use / network bandwidth usage.");
145145
bool minLatency;
146146

147+
%feature("autodoc", "");
148+
149+
%pythoncode %{
150+
151+
def withSpaces(self, spaces: 'list[str]') -> None:
152+
'''List of spaces to select data from.
153+
154+
If set to None then data from all spaces is loaded.
155+
'''
156+
self.__withSpaces(spaces)
157+
158+
%}
159+
160+
%rename(__withSpaces) withSpaces;
161+
void withSpaces(const std::vector<std::string> *spaces);
162+
147163
};
148164

149165
%feature("autodoc", "Options for loading data into a stream.

tests/TestStream.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,49 @@ def test_Spaces(self):
140140
finally:
141141
self.deleteStream(key)
142142

143+
def test_ReadFromSpaces(self):
144+
key = 'BarsWithSpaces'
145+
try:
146+
stream = self.createStream(key)
147+
self.assertIsNotNone(stream)
148+
149+
count = 1234
150+
testutils.loadBars(stream, count, 0, 1000000000, ['MSFT', 'ORCL'])
151+
testutils.loadBars(stream, count, 0, 1000000000, ['SX'], 'SpaceX')
152+
testutils.loadBars(stream, count, 0, 1000000000, ['SY'], 'SpaceY')
153+
154+
time.sleep(1)
155+
156+
so = tbapi.SelectionOptions()
157+
with stream.trySelect(0, so, None, None) as cursor:
158+
self.checkCursorSymbols(cursor, set(['MSFT', 'ORCL', 'SX', 'SY']))
159+
160+
so = tbapi.SelectionOptions()
161+
so.withSpaces(['SpaceX'])
162+
with stream.trySelect(0, so, None, None) as cursor:
163+
self.checkCursorSymbols(cursor, set(['SX']))
164+
165+
so = tbapi.SelectionOptions()
166+
so.withSpaces(['SpaceY'])
167+
with stream.trySelect(0, so, None, None) as cursor:
168+
self.checkCursorSymbols(cursor, set(['SY']))
169+
170+
so = tbapi.SelectionOptions()
171+
so.withSpaces(['SpaceY', 'SpaceX'])
172+
with stream.trySelect(0, so, None, None) as cursor:
173+
self.checkCursorSymbols(cursor, set(['SY', 'SX']))
174+
175+
so = tbapi.SelectionOptions()
176+
so.withSpaces([''])
177+
with stream.trySelect(0, so, None, None) as cursor:
178+
self.checkCursorSymbols(cursor, set(['MSFT', 'ORCL']))
179+
180+
so = tbapi.SelectionOptions()
181+
so.withSpaces(None)
182+
with stream.trySelect(0, so, None, None) as cursor:
183+
self.checkCursorSymbols(cursor, set(['MSFT', 'ORCL', 'SX', 'SY']))
184+
finally:
185+
self.deleteStream(key)
186+
143187
if __name__ == '__main__':
144188
unittest.main()

0 commit comments

Comments
 (0)