Skip to content

Commit 7dc9881

Browse files
committed
Abstract date specific chunk operation to the date_chunker
1 parent c201388 commit 7dc9881

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

arctic/chunkstore/_chunker.py

+10
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ def filter(self, data, range_obj):
6161
data, filtered by range_obj
6262
"""
6363
raise NotImplementedError
64+
65+
def exclude(self, data, range_obj):
66+
"""
67+
Removes data within the bounds of the range object (inclusive)
68+
69+
returns
70+
-------
71+
data, filtered by range_obj
72+
"""
73+
raise NotImplementedError

arctic/chunkstore/chunkstore.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def delete(self, symbol, chunk_range=None):
8686
# read out chunks that fall within the range and filter out
8787
# data within the range
8888
df = self.read(symbol, chunk_range=chunk_range, no_filter=True)
89-
df = df[(df.index.get_level_values('date') < chunk_range[0]) | (df.index.get_level_values('date') > chunk_range[1])]
90-
89+
df = self.chunker.exclude(df, chunk_range)
9190

9291
# remove chunks, and update any remaining data
9392
query = {'symbol': symbol}

arctic/chunkstore/date_chunker.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def to_mongo(self, range_obj):
8383
else:
8484
return {}
8585

86-
8786
def filter(self, data, range_obj):
8887
return data.ix[range_obj[0]:range_obj[1]]
88+
89+
def exclude(self, data, range_obj):
90+
return data[(data.index.get_level_values('date') < range_obj[0]) | (data.index.get_level_values('date') > range_obj[1])]

0 commit comments

Comments
 (0)