def testEncodeDictOfLists_Join_Empty(self): test_dict1 = {} test_dict2 = {} expected = {} encoded1 = parallel.EncodeDictOfLists(test_dict1) encoded2 = parallel.EncodeDictOfLists(test_dict2) encoded = parallel.JoinEncodedDictOfLists([encoded1, encoded2]) decoded = parallel.DecodeDictOfLists(encoded) self.assertEqual(expected, decoded)
def testEncodeDictOfLists_JoinMultiple(self): test_dict1 = {'key1': ['a']} test_dict2 = {'key2': ['b']} expected = {'key1': ['a'], 'key2': ['b']} encoded1 = parallel.EncodeDictOfLists(test_dict1) encoded2 = parallel.EncodeDictOfLists({}) encoded3 = parallel.EncodeDictOfLists(test_dict2) encoded = parallel.JoinEncodedDictOfLists([encoded1, encoded2, encoded3]) decoded = parallel.DecodeDictOfLists(encoded) self.assertEquals(expected, decoded)
def AnalyzeStringLiterals(self, elf_path, elf_string_ranges): logging.debug('worker: AnalyzeStringLiterals() started.') string_data = self._ReadElfStringData(elf_path, elf_string_ranges) # [source_idx][batch_idx][section_idx] -> Encoded {path: [string_ranges]}. encoded_ranges_sources = [ self._GetEncodedRangesFromStringAddresses(string_data), self._GetEncodedRangesFromStrings(string_data), ] # [section_idx] -> {path: [string_ranges]}. self._list_of_encoded_elf_string_ranges_by_path = [] # Contract [source_idx] and [batch_idx], then decode and join. for section_idx in xrange(len(elf_string_ranges)): # Fetch result. t = [] for encoded_ranges in encoded_ranges_sources: # [source_idx]. t.extend([b[section_idx] for b in encoded_ranges]) # [batch_idx]. self._list_of_encoded_elf_string_ranges_by_path.append( parallel.JoinEncodedDictOfLists(t)) logging.debug('worker: AnalyzeStringLiterals() completed.')
def testEncodeDictOfLists_Join_Singl(self): test_dict1 = {'key1': ['a']} encoded1 = parallel.EncodeDictOfLists(test_dict1) encoded = parallel.JoinEncodedDictOfLists([encoded1]) decoded = parallel.DecodeDictOfLists(encoded) self.assertEqual(test_dict1, decoded)