def validate_row(app_id, row, zookeeper, db_access):
 row_key = row.keys()[0]
 entity = row.values()[0]
 if (APP_ENTITY_SCHEMA[1] not in entity):
  return row
 row_txn = long(entity[APP_ENTITY_SCHEMA[1]])
 valid_txn = zookeeper.get_valid_transaction_id(app_id, row_txn, row_key)
 if (row_txn == valid_txn):
  return row
 if (valid_txn == 0):
  return None
 padded_version = str(valid_txn).zfill(ID_KEY_LENGTH)
 journal_key = dbconstants.KEY_DELIMITER.join([row_key, padded_version])
 journal_results = db_access.batch_get_entity(dbconstants.JOURNAL_TABLE, [journal_key], dbconstants.JOURNAL_SCHEMA)
 journal_row = journal_results[journal_key]
 if (dbconstants.JOURNAL_SCHEMA[0] not in journal_row):
  return None
 valid_entity = journal_row[dbconstants.JOURNAL_SCHEMA[0]]
 return {row_key: {APP_ENTITY_SCHEMA[0]: valid_entity, APP_ENTITY_SCHEMA[1]: str(valid_txn)}}

def validate_row ( app_id , row , zookeeper , db_access ) : row_key = row . keys ( ) [ 0 ] entity = row . values ( ) [ 0 ] if ( APP_ENTITY_SCHEMA [ 1 ] not in entity ) : return row row_txn = long ( entity [ APP_ENTITY_SCHEMA [ 1 ] ] ) valid_txn = zookeeper . get_valid_transaction_id ( app_id , row_txn , row_key ) if ( row_txn == valid_txn ) : return row if ( valid_txn == 0 ) : return None padded_version = str ( valid_txn ) . zfill ( ID_KEY_LENGTH ) journal_key = dbconstants . KEY_DELIMITER . join ( [ row_key , padded_version ] ) journal_results = db_access . batch_get_entity ( dbconstants . JOURNAL_TABLE , [ journal_key ] , dbconstants . JOURNAL_SCHEMA ) journal_row = journal_results [ journal_key ] if ( dbconstants . JOURNAL_SCHEMA [ 0 ] not in journal_row ) : return None valid_entity = journal_row [ dbconstants . JOURNAL_SCHEMA [ 0 ] ] return { row_key : { APP_ENTITY_SCHEMA [ 0 ] : valid_entity , APP_ENTITY_SCHEMA [ 1 ] : str ( valid_txn ) } }
fetch the valid version of a given entity .