//test compatible between version2 && version2 compiled without -DCOMPATIBLE TEST_F(TestObSSTableTrailer, Compatible) { ObTrailerOffset trailer_offset; ObSSTableTrailer trailer; EXPECT_TRUE(default_range == trailer.get_range()); FileUtils filesys; const char *compressor_name = "lzo1x_1_11_compress"; int64_t file_len = FileDirectoryUtils::get_size(trailer_file_name); char *file_buf = reinterpret_cast<char*>(malloc(file_len)); EXPECT_TRUE(NULL != file_buf); int64_t read_size = 0; filesys.open(trailer_file_name, O_RDONLY); read_size = filesys.read(file_buf, file_len); EXPECT_EQ(read_size, file_len); int64_t pos = 0; pos = trailer.get_serialize_size(); trailer_offset.trailer_record_offset_ = 0; trailer_offset.deserialize(file_buf, file_len, pos); EXPECT_EQ(trailer_offset.trailer_record_offset_, 256 * 1024 - 1023); pos = 0; trailer.deserialize(file_buf, file_len, pos); EXPECT_EQ(0x300, trailer.get_trailer_version()); EXPECT_EQ(1, trailer.get_table_version()); EXPECT_EQ(0, trailer.get_first_block_data_offset()); EXPECT_EQ(1, trailer.get_row_value_store_style()); EXPECT_EQ(1023, trailer.get_block_count()); EXPECT_EQ(2047, trailer.get_block_index_record_offset()); EXPECT_EQ(1024, trailer.get_block_index_record_size()); EXPECT_EQ(8, trailer.get_bloom_filter_hash_count()); EXPECT_EQ(2047 + 1024, trailer.get_bloom_filter_record_offset()); EXPECT_EQ(511, trailer.get_bloom_filter_record_size()); EXPECT_EQ(2047+ 1024 + 511, trailer.get_schema_record_offset()); EXPECT_EQ(1023, trailer.get_schema_record_size()); EXPECT_EQ(64 * 1024, trailer.get_block_size()); EXPECT_EQ(777, trailer.get_row_count()); EXPECT_EQ(123456789, (int64_t)trailer.get_sstable_checksum()); EXPECT_EQ(1001, (int64_t)trailer.get_first_table_id()); EXPECT_EQ(123456789, trailer.get_frozen_time()); int ret = memcmp(compressor_name, trailer.get_compressor_name(), strlen(compressor_name)); EXPECT_EQ(0, ret); EXPECT_TRUE(default_range == trailer.get_range()); free(file_buf); file_buf = NULL; filesys.close(); }
TEST_F(TestObSSTableSchema, test_compatible) { ObSSTableSchema schema; const ObSSTableSchemaColumnDef *column = NULL; int64_t file_len = FileDirectoryUtils::get_size(schema_file_name); char * file_buf = reinterpret_cast<char*>(malloc(file_len)); int64_t pos = 0; FileUtils filesys; filesys.open(schema_file_name, O_RDONLY); int64_t read_size = filesys.read(file_buf, file_len); EXPECT_EQ(read_size, file_len); schema.deserialize(file_buf, file_len, pos); EXPECT_EQ(schema.get_column_count(), 550); int64_t index_find = 0; int64_t index = 0; int64_t table_schema_size = 0; int64_t group_schema_size = 0; for (uint64_t table_id = 1000; table_id < 1010; ++table_id) { schema.get_table_schema(table_id, table_schema_size); EXPECT_EQ(55, table_schema_size); for(uint64_t group_id = 1; group_id < 11; ++group_id) { schema.get_group_schema(table_id, group_id, group_schema_size); EXPECT_EQ(group_schema_size, (int64_t)group_id); for(uint64_t column_id = 0; column_id < group_id; ++column_id) { index_find = schema.find_column_id(table_id, group_id, column_id); column = schema.get_column_def(index_find); EXPECT_EQ(index, index_find); EXPECT_EQ(column_id, column->column_name_id_); EXPECT_EQ(group_id, column->column_group_id_); EXPECT_EQ(table_id, column->table_id_); EXPECT_EQ(ObIntType, column->column_value_type_); ++index; } } } }