Skip to content

Commit

Permalink
Merge "Merge branch 'branch_2.0.0'"
Browse files Browse the repository at this point in the history
  • Loading branch information
bcui6611 authored and Gerrit Code Review committed Jan 19, 2013
2 parents c2905f7 + f2d6863 commit 753d51d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
10 changes: 7 additions & 3 deletions pump_mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,14 @@ def cmd_request(self, cmd, vbucket_id, key, val, flg, exp, cas, meta, opaque):
if len(seq_no) < 8:
# The seq_no might be 32-bits from 2.0DP4, so pad with 0x00's.
seq_no = ('\x00\x00\x00\x00\x00\x00\x00\x00' + seq_no)[-8:]
ext = (struct.pack(">II", flg, exp) + seq_no +
struct.pack(">Q", cas))
check_seqno, = struct.unpack(">Q", seq_no)
if check_seqno:
ext = (struct.pack(">II", flg, exp) + seq_no +
struct.pack(">Q", cas))
else:
ext = struct.pack(">IIQQ", flg, exp, 1, cas)
else:
ext = struct.pack(">IIQQ", flg, exp, 0, cas)
ext = struct.pack(">IIQQ", flg, exp, 1, cas)
elif (cmd == memcacheConstants.CMD_SET or
cmd == memcacheConstants.CMD_ADD):
ext = struct.pack(memcacheConstants.SET_PKT_FMT, flg, exp)
Expand Down
31 changes: 19 additions & 12 deletions pump_sfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@ def run(self):
d = couchstore.DocumentInfo(str(key))
d.revMeta = str(struct.pack(SFD_REV_META, cas, exp, flg))
if meta:
d.revSequence = struct.unpack(SFD_REV_SEQ, meta)
if len(meta) > 8:
meta = meta[0:8]
if len(meta) < 8:
meta = ('\x00\x00\x00\x00\x00\x00\x00\x00' + meta)[-8:]
d.revSequence, = struct.unpack(SFD_REV_SEQ, meta)
else:
d.revSequence = 1

if cmd == memcacheConstants.CMD_TAP_MUTATION:
v = str(val)
Expand Down Expand Up @@ -404,20 +410,21 @@ def consume_design(opts, sink_spec, sink_map,
bulk_keys = []
bulk_vals = []

for row in sd['rows']:
logging.debug("design_doc row: " + str(row))
if sd:
for row in sd['rows']:
logging.debug("design_doc row: " + str(row))

d = couchstore.DocumentInfo(str(row['id']))
if '_rev' in row['doc']:
d.revMeta = str(row['doc']['_rev'])
del row['doc']['_rev']
d.contentType = couchstore.DocumentInfo.IS_JSON
d = couchstore.DocumentInfo(str(row['id']))
if '_rev' in row['doc']:
d.revMeta = str(row['doc']['_rev'])
del row['doc']['_rev']
d.contentType = couchstore.DocumentInfo.IS_JSON

bulk_keys.append(d)
bulk_vals.append(json.dumps(row['doc']))
bulk_keys.append(d)
bulk_vals.append(json.dumps(row['doc']))

if bulk_keys and bulk_vals:
store.saveMultiple(bulk_keys, bulk_vals) # TODO: Compress ddocs?
if bulk_keys and bulk_vals:
store.saveMultiple(bulk_keys, bulk_vals) # TODO: Compress ddocs?

store.commit()
store.close()
Expand Down

0 comments on commit 753d51d

Please sign in to comment.