Exemple #1
0
 def LoadDataBlockRepByBlockId(self, block_id):
     block_info = decode_block_id(block_id)
     dbr = self.LoadDataBlockReqByIndex(block_info['partition_id'],
                                        block_info['data_block_index'])
     if dbr:
         assert dbr.block_id == block_id, \
                 "Invalid datablock, expected %s, but got %s), please "\
                 "check datasource!"%(block_id, dbr.block_id)
     return dbr
Exemple #2
0
 def __init__(self,
              data_source_name,
              data_block_fname,
              partition_id,
              dirpath,
              check_existed=True):
     assert data_block_fname.endswith(DataBlockSuffix), \
         "data block fname {} should has suffix {}".format(
             data_block_fname, DataBlockSuffix
         )
     block_id = data_block_fname[:-len(DataBlockSuffix)]
     segmap = decode_block_id(block_id)
     if segmap["data_source_name"] != data_source_name:
         raise ValueError("{} invalid. Data source name mismatch "\
                          "{} != {}".format(data_block_fname,
                              segmap["data_source_name"], data_source_name))
     self._data_source_name = data_source_name
     if segmap["partition_id"] != partition_id:
         raise ValueError("{} invalid. partition mismatch "\
                          "{} != {}".format(data_block_fname,
                              segmap["partition_id"], partition_id))
     self._partition_id = partition_id
     start_time, end_time = \
             segmap["time_frame"][0], segmap["time_frame"][1]
     if start_time > end_time:
         raise ValueError("{} invalid. time frame error start_time {} > "\
                          "end_time {}".format(data_block_fname,
                                               start_time, end_time))
     self._start_time, self._end_time = start_time, end_time
     self._data_block_index = segmap["data_block_index"]
     self._block_id = block_id
     meta_fname = encode_data_block_meta_fname(self._data_source_name,
                                               self._partition_id,
                                               self._data_block_index)
     meta_fpath = os.path.join(dirpath, meta_fname)
     if check_existed and (not gfile.Exists(meta_fpath) or \
                           gfile.IsDirectory(meta_fpath)):
         raise ValueError("{} invalid. the corresponding meta file "\
                          "is not existed".format(data_block_fname))
     self._data_block_meta_fpath = meta_fpath
     self._data_block_meta = None
     self._data_block_fpath = os.path.join(dirpath, data_block_fname)
Exemple #3
0
 def LoadDataBlockRepByBlockId(self, block_id):
     block_info = decode_block_id(block_id)
     return self.LoadDataBlockReqByIndex(block_info['partition_id'],
                                         block_info['data_block_index'])