Skip to content

Commit

Permalink
fix issue pandas-dev#135
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoscon committed May 4, 2016
1 parent 7a4c9c5 commit 7065372
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions arctic/chunkstore/chunkstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,17 @@ def read(self, symbol, chunk_range=None):
"""

sym = self._get_symbol_info(symbol)

if not sym:
raise NoDataFoundException('No data found for %s in library %s' % (symbol, self._collection.get_name()))

spec = {'symbol': symbol,
}

if chunk_range is not None:
if chunk_range:
spec['start'] = self.chunker.to_mongo(chunk_range)

segments = []
i = -1
for i, x in enumerate(self._collection.find(spec, sort=[('start', pymongo.ASCENDING)],)):
for _, x in enumerate(self._collection.find(spec, sort=[('start', pymongo.ASCENDING)],)):
segments.append(decompress(x['data']))

data = b''.join(segments)
Expand Down Expand Up @@ -169,10 +167,9 @@ def write(self, symbol, item, chunk_size):

previous_shas = []
if self._get_symbol_info(symbol):
previous_shas = set([x['sha'] for x in self._collection.find({'symbol': symbol},
previous_shas = set([Binary(x['sha']) for x in self._collection.find({'symbol': symbol},
projection={'sha': True, '_id': False},
)])

records = []
ranges = []
dtype = None
Expand Down Expand Up @@ -205,6 +202,7 @@ def write(self, symbol, item, chunk_size):
chunk['end'] = end
chunk['symbol'] = symbol
chunk['sha'] = checksum(symbol, chunk)

if chunk['sha'] not in previous_shas:
op = True
bulk.find({'symbol': symbol, 'sha': chunk['sha']},
Expand Down
2 changes: 1 addition & 1 deletion arctic/store/_ndarray_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def _do_write(self, collection, version, symbol, item, previous_version, segment

previous_shas = []
if previous_version:
previous_shas = set([x['sha'] for x in
previous_shas = set([Binary(x['sha']) for x in
collection.find({'symbol': symbol},
projection={'sha': 1, '_id': 0},
)
Expand Down

0 comments on commit 7065372

Please sign in to comment.