当前位置: 首页>>代码示例>>C++>>正文


C++ FileUtils::read方法代码示例

本文整理汇总了C++中FileUtils::read方法的典型用法代码示例。如果您正苦于以下问题:C++ FileUtils::read方法的具体用法?C++ FileUtils::read怎么用?C++ FileUtils::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtils的用法示例。


在下文中一共展示了FileUtils::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memcmp

      //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();
      }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:48,代码来源:test_sstable_trailer.cpp

示例2:

      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;
            }
          }
        }
        }
开发者ID:Abioy,项目名称:oceanbase,代码行数:41,代码来源:test_sstable_schema.cpp


注:本文中的FileUtils::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。