1 Star 0 Fork 23

carter.j.cheng/curve

forked from Gitee 极速下载/curve 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
location_operator.h 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
qinyi 提交于 2020-07-01 11:04 +08:00 . add License head for all files
/*
* Copyright (c) 2020 NetEase Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Project: curve
* Created Date: Monday March 25th 2019
* Author: yangyaokai
*/
#ifndef SRC_COMMON_LOCATION_OPERATOR_H_
#define SRC_COMMON_LOCATION_OPERATOR_H_
#include <string>
#include <vector>
namespace curve {
namespace common {
const char CURVE_TYPE[] = "cs";
const char S3_TYPE[] = "s3";
const char kOriginTypeSeprator[] = "@";
const char kOriginPathSeprator[] = ":";
enum class OriginType {
S3Origin = 0,
CurveOrigin = 1,
InvalidOrigin = 2,
};
class LocationOperator {
public:
/**
* 生成s3的location
* location格式:${objectname}@s3
* @param objectName:s3上object的名称
* @return:生成的location
*/
static std::string GenerateS3Location(const std::string& objectName);
/**
* 生成curve的location
* location格式:${filename}:${offset}@cs
*/
static std::string GenerateCurveLocation(const std::string& fileName,
off_t offset);
/**
* 解析数据源的位置信息
* location格式:
* s3示例:${objectname}@s3
* curve示例:${filename}:${offset}@cs
*
* @param location[in]:数据源的位置,其格式为originPath@originType
* @param originPath[out]:表示数据源在源端的路径
* @return:返回OriginType,表示源数据的源端类型是s3还是curve
* 如果路径格式不正确或者originType无法识别,则返回InvalidOrigin
*/
static OriginType ParseLocation(const std::string& location,
std::string* originPath);
/**
* 解析curvefs的originPath
* 格式:${filename}:${offset}
* @param originPath[in]:数据源在curvefs上的路径
* @param fileName[out]:数据源所属文件名
* @param offset[out]:数据源在文件中的偏移
* @return: 解析成功返回true,失败返回false
*/
static bool ParseCurveChunkPath(const std::string& originPath,
std::string* fileName,
off_t* offset);
};
} // namespace common
} // namespace curve
#endif // SRC_COMMON_LOCATION_OPERATOR_H_
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/carters/curve.git
git@gitee.com:carters/curve.git
carters
curve
curve
master

搜索帮助

371d5123 14472233 46e8bd33 14472233