diff --git a/pom.xml b/pom.xml index d393b98fd5b..8bf3160209f 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,8 @@ UTF-8 1.8 2.6.0 + 2.14.1 + 10.12.1.1 @@ -37,6 +39,19 @@ ${hadoop.version} + + jline + jline + ${jline.version} + + + + org.apache.derby + derby + ${derby.version} + + + diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/TestAu.java b/src/main/java/cn/edu/thu/tsfiledb/auth/TestAu.java new file mode 100644 index 00000000000..4991cf8cf3a --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/TestAu.java @@ -0,0 +1,31 @@ +package cn.edu.thu.tsfiledb.auth; + +import cn.edu.thu.tsfiledb.auth.dao.Authorizer; +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.model.User; + +public class TestAu { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + // 启动server的时候需要open db + DBdao dBdao = new DBdao(); + dBdao.open(); + System.out.println("start server....."); + // 操作数据库信息 + User user = new User("test", "test"); + + try { + Authorizer.createUser(user.getUserName(), user.getPassWord()); + Authorizer.deleteUser(user.getUserName()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // 关闭server的时候需要 close db + System.out.println("close the server..."); + dBdao.close(); + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/AuthDao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/AuthDao.java new file mode 100644 index 00000000000..0485e0076a7 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/AuthDao.java @@ -0,0 +1,285 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import cn.edu.thu.tsfiledb.auth.model.Role; +import cn.edu.thu.tsfiledb.auth.model.RolePermission; +import cn.edu.thu.tsfiledb.auth.model.User; +import cn.edu.thu.tsfiledb.auth.model.UserPermission; +import cn.edu.thu.tsfiledb.auth.model.UserRoleRel; + + +/** + * @author liukun + * + */ +public class AuthDao { + + /** + * if the user don't exist in the db, return true else return false + * + * @param statement + * @param user + * @return + */ + public boolean addUser(Statement statement, User user) { + UserDao dao = new UserDao(); + boolean state = false; + // Check the user exist or not + if (dao.getUser(statement, user.getUserName()) == null) { + dao.createUser(statement, user); + state = true; + } + return state; + } + + /** + * if the role isn't exist in the db, will return true else return false + * + * @param statement + * @param role + * @return + */ + public boolean addRole(Statement statement, Role role) { + RoleDao dao = new RoleDao(); + boolean state = false; + // check the user exist or not + if (dao.getRole(statement, role.getRoleName()) == null) { + dao.createRole(statement, role); + state = true; + } + return state; + } + + /** + * the user and role is exist, the relation is not exist, will return true + * else return false + * + * @param statement + * @param userName + * @param roleName + * @return + */ + public boolean addUserRoleRel(Statement statement, String userName, String roleName) { + UserDao userDao = new UserDao(); + RoleDao roleDao = new RoleDao(); + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + int userId; + int roleId; + User user = null; + Role role = null; + boolean state = false; + if ((user = userDao.getUser(statement, userName)) != null) { + if ((role = roleDao.getRole(statement, roleName)) != null) { + userId = user.getId(); + roleId = role.getId(); + UserRoleRel userRoleRel = new UserRoleRel(userId, roleId); + + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel) == null) { + state = true; + userRoleRelDao.createUserRoleRel(statement, userRoleRel); + } + } + } + return state; + } + + public boolean addUserPermission(Statement statement, String userName, String nodeName, int permissionId) { + UserDao userDao = new UserDao(); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + boolean state = false; + User user = null; + if ((user = userDao.getUser(statement, userName)) != null) { + int userId = user.getId(); + UserPermission userPermission = new UserPermission(userId, nodeName, permissionId); + if (userPermissionDao.getUserPermission(statement, userPermission) == null) { + state = true; + userPermissionDao.createUserPermission(statement, userPermission); + } + } + return state; + } + + public boolean addRolePermission(Statement statement, String roleName, String nodeName, int permissionId) { + RoleDao roleDao = new RoleDao(); + RolePermissionDao rolePermissionDao = new RolePermissionDao(); + boolean state = false; + Role role = null; + if ((role = roleDao.getRole(statement, roleName)) != null) { + int roleId = role.getId(); + RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId); + if (rolePermissionDao.getRolePermission(statement, rolePermission) == null) { + state = true; + rolePermissionDao.createRolePermission(statement, rolePermission); + } + } + return state; + } + + public boolean deleteUser(Statement statement, String userName) { + UserDao userDao = new UserDao(); + boolean state = false; + if (userDao.deleteUser(statement, userName) > 0) { + state = true; + } + return state; + } + + public boolean deleteRole(Statement statement, String roleName) { + RoleDao roleDao = new RoleDao(); + boolean state = false; + if (roleDao.deleteRole(statement, roleName) > 0) { + state = true; + } + return state; + } + + public boolean deleteUserRoleRel(Statement statement, String userName, String roleName) { + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + UserDao userDao = new UserDao(); + RoleDao roleDao = new RoleDao(); + int userId; + int roleId; + User user = null; + Role role = null; + boolean state = false; + + if ((user = userDao.getUser(statement, userName)) != null + && (role = roleDao.getRole(statement, roleName)) != null) { + userId = user.getId(); + roleId = role.getId(); + UserRoleRel userRoleRel = new UserRoleRel(userId, roleId); + if (userRoleRelDao.deleteUserRoleRel(statement, userRoleRel) > 0) { + state = true; + } + } + return state; + } + + public boolean deleteUserPermission(Statement statement, String userName, String nodeName, int permissionId) { + UserDao userDao = new UserDao(); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + int userId; + User user = null; + boolean state = false; + if ((user = userDao.getUser(statement, userName)) != null) { + userId = user.getId(); + UserPermission userPermission = new UserPermission(userId, nodeName, permissionId); + if (userPermissionDao.deleteUserPermission(statement, userPermission) > 0) { + state = true; + } + } + return state; + } + + public boolean deleteRolePermission(Statement statement, String roleName, String nodeName, int permissionId) { + RoleDao roleDao = new RoleDao(); + RolePermissionDao rolePermissionDao = new RolePermissionDao(); + Role role = null; + int roleId; + boolean state = false; + if ((role = roleDao.getRole(statement, roleName)) != null) { + roleId = role.getId(); + RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId); + if (rolePermissionDao.deleteRolePermission(statement, rolePermission) > 0) { + state = true; + } + } + return state; + } + + // 如果username或者nodename不存在怎么办? + public List getUsers(Statement statement) { + UserDao userDao = new UserDao(); + List users = userDao.getUsers(statement); + return users; + } + + public List getRoles(Statement statement) { + RoleDao roleDao = new RoleDao(); + List roles = roleDao.getRoles(statement); + return roles; + } + + public List getAllUserRoleRel(Statement statement) { + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + List userRoleRels = userRoleRelDao.getUserRoleRels(statement); + return userRoleRels; + } + + /* + * 返回值的问题 + */ + public List getRolesByUser(Statement statement, String userName) { + UserDao userDao = new UserDao(); + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + RoleDao roleDao = new RoleDao(); + // 当 user不存在的情况下是返回 size = 0,还是 null + ArrayList roles = new ArrayList<>(); + User user = userDao.getUser(statement, userName); + if (user != null) { + int userId = user.getId(); + List userRoleRels = userRoleRelDao.getUserRoleRelByUser(statement, userId); + for (UserRoleRel userRoleRel : userRoleRels) { + int roleId = userRoleRel.getRoleId(); + Role role = roleDao.getRole(statement, roleId); + roles.add(role); + } + } + return roles; + } + + /* + * 返回值的问题 + */ + public List getUserPermission(Statement statement, String userName, String nodeName) { + UserDao userDao = new UserDao(); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + List userPermissions = new ArrayList<>(); + // 当user 不存在的时候 是返回size = 0,还是null + User user = userDao.getUser(statement, userName); + if (user != null) { + userPermissions = userPermissionDao.getUserPermissionByUserAndNodeName(statement, user.getId(), nodeName); + } + // 返回值可能是null还是 没有结果 size = 0; + return userPermissions; + } + + public List getRolePermission(Statement statement, String roleName, String nodeName) { + RoleDao roleDao = new RoleDao(); + RolePermissionDao rolePermissionDao = new RolePermissionDao(); + List rolePermissions = new ArrayList<>(); + Role role = roleDao.getRole(statement, roleName); + if (role != null) { + rolePermissions = rolePermissionDao.getRolePermissionByRoleAndNodeName(statement, role.getId(), nodeName); + } + return rolePermissions; + } + + /* + * All user's permission: userPermission and rolePermission + */ + public Set getAllUserPermission(Statement statement, String userName, String nodeName) { + // permission set + Set permissionSet = new HashSet<>(); + // userpermission + List userPermissions = getUserPermission(statement, userName, nodeName); + for (UserPermission userPermission : userPermissions) { + permissionSet.add(userPermission.getPermissionId()); + } + // rolepermission + List roles = getRolesByUser(statement, userName); + for (Role role : roles) { + List rolePermissions = getRolePermission(statement, role.getRoleName(), nodeName); + // operation add the permission into the set + for (RolePermission rolePermission : rolePermissions) { + permissionSet.add(rolePermission.getPermissionId()); + } + } + return permissionSet; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/AuthDaoWrap.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/AuthDaoWrap.java new file mode 100644 index 00000000000..269db10d890 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/AuthDaoWrap.java @@ -0,0 +1,355 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import cn.edu.thu.tsfiledb.auth.model.AuthException; +import cn.edu.thu.tsfiledb.auth.model.Role; +import cn.edu.thu.tsfiledb.auth.model.RolePermission; +import cn.edu.thu.tsfiledb.auth.model.User; +import cn.edu.thu.tsfiledb.auth.model.UserPermission; +import cn.edu.thu.tsfiledb.auth.model.UserRoleRel; + +/** + * @author liukun + */ +public class AuthDaoWrap { + + // Must init the DBdao before use this class + private Statement statement = DBdao.getStatement(); + + + public boolean addUser(User user) { + UserDao dao = new UserDao(); + boolean state = false; + // Check the user exist or not + if (dao.getUser(statement, user.getUserName()) == null) { + dao.createUser(statement, user); + state = true; + } + return state; + } + + + public boolean addRole(Role role) { + RoleDao dao = new RoleDao(); + boolean state = false; + // check the user exist or not + if (dao.getRole(statement, role.getRoleName()) == null) { + dao.createRole(statement, role); + state = true; + } + return state; + } + + + public boolean addUserRoleRel(String userName, String roleName) throws AuthException { + UserDao userDao = new UserDao(); + RoleDao roleDao = new RoleDao(); + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + int userId; + int roleId; + User user = null; + Role role = null; + boolean state = false; + if ((user = userDao.getUser(statement, userName)) != null) { + if ((role = roleDao.getRole(statement, roleName)) != null) { + userId = user.getId(); + roleId = role.getId(); + UserRoleRel userRoleRel = new UserRoleRel(userId, roleId); + + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel) == null) { + state = true; + userRoleRelDao.createUserRoleRel(statement, userRoleRel); + } else { + throw new AuthException(String.format("The user of %s already has the role of %s", userName, role.getRoleName())); + } + } else { + throw new AuthException("The role is not exist"); + } + } else { + throw new AuthException("The user is not exist"); + } + return state; + } + + public boolean addUserPermission(String userName, String nodeName, int permissionId) throws AuthException { + UserDao userDao = new UserDao(); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + boolean state = false; + User user = null; + if ((user = userDao.getUser(statement, userName)) != null) { + int userId = user.getId(); + UserPermission userPermission = new UserPermission(userId, nodeName, permissionId); + if (userPermissionDao.getUserPermission(statement, userPermission) == null) { + state = true; + userPermissionDao.createUserPermission(statement, userPermission); + } else { + throw new AuthException("The permission is exist"); + } + } else { + throw new AuthException("The user is not exist"); + } + return state; + } + + public boolean addRolePermission(String roleName, String nodeName, int permissionId) throws AuthException { + RoleDao roleDao = new RoleDao(); + RolePermissionDao rolePermissionDao = new RolePermissionDao(); + boolean state = false; + Role role = null; + if ((role = roleDao.getRole(statement, roleName)) != null) { + int roleId = role.getId(); + RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId); + if (rolePermissionDao.getRolePermission(statement, rolePermission) == null) { + state = true; + rolePermissionDao.createRolePermission(statement, rolePermission); + } else { + throw new AuthException("The permission is exist"); + } + } else { + throw new AuthException("The role is not exist"); + } + return state; + } + + public boolean deleteUser(String userName) { + UserDao userDao = new UserDao(); + boolean state = false; + if (userDao.deleteUser(statement, userName) > 0) { + state = true; + } + return state; + } + + public boolean deleteRole(String roleName) { + RoleDao roleDao = new RoleDao(); + boolean state = false; + if (roleDao.deleteRole(statement, roleName) > 0) { + state = true; + } + return state; + } + + public boolean deleteUserRoleRel(String userName, String roleName) throws AuthException { + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + UserDao userDao = new UserDao(); + RoleDao roleDao = new RoleDao(); + int userId; + int roleId; + User user = null; + Role role = null; + boolean state = false; + + if ((user = userDao.getUser(statement, userName)) != null) { + if ((role = roleDao.getRole(statement, roleName)) != null) { + userId = user.getId(); + roleId = role.getId(); + UserRoleRel userRoleRel = new UserRoleRel(userId, roleId); + if (userRoleRelDao.deleteUserRoleRel(statement, userRoleRel) > 0) { + state = true; + } else { + throw new AuthException(String.format("The user of %s does not have the role of %s"), userName, role.getRoleName()); + } + } else { + throw new AuthException("The role is not exist"); + } + } else { + throw new AuthException("The user is not exist"); + } + return state; + } + + public boolean deleteUserPermission(String userName, String nodeName, int permissionId) throws AuthException { + UserDao userDao = new UserDao(); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + int userId; + User user = null; + boolean state = false; + if ((user = userDao.getUser(statement, userName)) != null) { + userId = user.getId(); + UserPermission userPermission = new UserPermission(userId, nodeName, permissionId); + if (userPermissionDao.deleteUserPermission(statement, userPermission) > 0) { + state = true; + } else { + throw new AuthException("The permission is not exist"); + } + } else { + throw new AuthException("The user is not exist"); + } + return state; + } + + public boolean deleteRolePermission(String roleName, String nodeName, int permissionId) throws AuthException { + RoleDao roleDao = new RoleDao(); + RolePermissionDao rolePermissionDao = new RolePermissionDao(); + Role role = null; + int roleId; + boolean state = false; + if ((role = roleDao.getRole(statement, roleName)) != null) { + roleId = role.getId(); + RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId); + if (rolePermissionDao.deleteRolePermission(statement, rolePermission) > 0) { + state = true; + } else { + throw new AuthException("The permission is not exist"); + } + } else { + throw new AuthException("The role is not exist"); + } + return state; + } + + public User getUser(String userName, String password) { + UserDao userDao = new UserDao(); + User user = null; + user = userDao.getUser(statement, userName, password); + return user; + } + + public User getUser(String userName) { + UserDao userDao = new UserDao(); + User user = null; + user = userDao.getUser(statement, userName); + return user; + } + + // 如果username或者nodename不存在怎么办? + public List getUsers() { + UserDao userDao = new UserDao(); + List users = userDao.getUsers(statement); + return users; + } + + public List getRoles() { + RoleDao roleDao = new RoleDao(); + List roles = roleDao.getRoles(statement); + return roles; + } + + public List getAllUserRoleRel() { + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + List userRoleRels = userRoleRelDao.getUserRoleRels(statement); + return userRoleRels; + } + + /* + * 返回值的问题 + */ + public List getRolesByUser(String userName) { + UserDao userDao = new UserDao(); + UserRoleRelDao userRoleRelDao = new UserRoleRelDao(); + RoleDao roleDao = new RoleDao(); + // 当 user不存在的情况下是返回 size = 0,还是 null + ArrayList roles = new ArrayList<>(); + User user = userDao.getUser(statement, userName); + if (user != null) { + int userId = user.getId(); + List userRoleRels = userRoleRelDao.getUserRoleRelByUser(statement, userId); + for (UserRoleRel userRoleRel : userRoleRels) { + int roleId = userRoleRel.getRoleId(); + Role role = roleDao.getRole(statement, roleId); + roles.add(role); + } + } + return roles; + } + + public UserPermission getUserPermission(String userName, String nodeName, int permissionId) { + UserPermission userPermission = null; + UserDao userDao = new UserDao(); + User user = userDao.getUser(statement, userName); + if (user != null) { + int userId = user.getId(); + userPermission = new UserPermission(userId, nodeName, permissionId); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + // userPermission will be null + userPermission = userPermissionDao.getUserPermission(statement, userPermission); + } + return userPermission; + } + + /* + * 返回值的问题 + */ + public List getUserPermissions(String userName, String nodeName) throws AuthException { + UserDao userDao = new UserDao(); + UserPermissionDao userPermissionDao = new UserPermissionDao(); + List userPermissions = new ArrayList<>(); + // 当user 不存在的时候 是返回size = 0,还是null + User user = userDao.getUser(statement, userName); + if (user != null) { + userPermissions = userPermissionDao.getUserPermissionByUserAndNodeName(statement, user.getId(), nodeName); + } else { + throw new AuthException("The user is not exist"); + } + // 返回值可能是null还是 没有结果 size = 0; + return userPermissions; + } + + public List getRolePermissions(String roleName, String nodeName) { + RoleDao roleDao = new RoleDao(); + RolePermissionDao rolePermissionDao = new RolePermissionDao(); + List rolePermissions = new ArrayList<>(); + Role role = roleDao.getRole(statement, roleName); + if (role != null) { + rolePermissions = rolePermissionDao.getRolePermissionByRoleAndNodeName(statement, role.getId(), nodeName); + } + return rolePermissions; + } + + /* + * All user's permission: userPermission and rolePermission + */ + public Set getAllUserPermissions(String userName, String nodeName) throws AuthException { + // permission set + Set permissionSet = new HashSet<>(); + // userpermission + List userPermissions = getUserPermissions(userName, nodeName); + for (UserPermission userPermission : userPermissions) { + permissionSet.add(userPermission.getPermissionId()); + } + // rolepermission + List roles = getRolesByUser(userName); + for (Role role : roles) { + List rolePermissions = getRolePermissions(role.getRoleName(), nodeName); + // operation add the permission into the set + for (RolePermission rolePermission : rolePermissions) { + permissionSet.add(rolePermission.getPermissionId()); + } + } + return permissionSet; + } + + public boolean updateUserPassword(String userName, String newPassword) { + boolean state = false; + UserDao userDao = new UserDao(); + int change = userDao.updateUserPassword(statement, userName, newPassword); + if (change > 0) { + state = true; + } + return state; + } + + public boolean checkUserPermission(String userName, String nodeName, int permissionId) { + boolean state = false; + UserPermission userPermission = this.getUserPermission(userName, nodeName, permissionId); + if (userPermission != null) { + state = true; + } + return state; + } + + // add the method without the authdao + public boolean checkUser(String userName, String password) { + boolean state = false; + User user = this.getUser(userName, password); + if (user != null) { + state = true; + } + return state; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/Authorizer.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/Authorizer.java new file mode 100644 index 00000000000..65bdcc9fa13 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/Authorizer.java @@ -0,0 +1,238 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.util.Set; + +import cn.edu.thu.tsfiledb.auth.model.AuthException; +import cn.edu.thu.tsfiledb.auth.model.Role; +import cn.edu.thu.tsfiledb.auth.model.User; + +/** + * @author liukun + */ +public class Authorizer { + + private static AuthDaoWrap authDaoWrap = new AuthDaoWrap(); + + /** + * Check the information for login + * + * @param username + * @param password + * @return + * @throws AuthException + */ + public static synchronized boolean login(String username, String password) throws AuthException { + + boolean state = false; + state = authDaoWrap.checkUser(username, password); + if (state == false) { + throw new AuthException("The username or the password is not correct"); + } + return state; + } + + /** + * Add user + * + * @param username is not null or empty + * @param password is not null or empty + * @return true: add user successfully, false: add user unsuccessfully + * @throws AuthException + */ + public static boolean createUser(String username, String password) throws AuthException { + boolean state = false; + User user = new User(username, password); + if (username == null || password == null || "".equals(username) || "".equals(password)) { + throw new AuthException("Username or password can't be empty"); + } + state = authDaoWrap.addUser(user); + if (state == false) { + throw new AuthException("The user is exist"); + } + return state; + } + + /** + * Delete user + * + * @param username + * @return true: delete user successfully, false: delete user unsuccessfully + * @throws AuthException + */ + public static boolean deleteUser(String username) throws AuthException { + boolean state = false; + state = authDaoWrap.deleteUser(username); + if (state == false) { + throw new AuthException("The user is not exist"); + } + return state; + } + + /** + * Add permission to user + * + * @param username + * @param nodeName + * @param permissionId + * @return true: add permission successfully, false: add permission unsuccessfully + * @throws AuthException + */ + public static boolean addPmsToUser(String username, String nodeName, int permissionId) throws AuthException { + boolean state = false; + state = authDaoWrap.addUserPermission(username, nodeName, permissionId); + return state; + } + + /** + * Delete permission from user + * + * @param userName + * @param nodeName + * @param permissionId + * @return true: delete permission from user successfully, false: delete permission from user unsuccessfully + * @throws AuthException + */ + public static boolean removePmsFromUser(String userName, String nodeName, int permissionId) throws AuthException { + boolean state = false; + state = authDaoWrap.deleteUserPermission(userName, nodeName, permissionId); + return state; + } + + /** + * Add role + * + * @param roleName + * @return true: add role successfully, false: add role unsuccessfully + * @throws Exception + */ + public static boolean createRole(String roleName) throws AuthException { + boolean state = false; + Role role = new Role(roleName); + state = authDaoWrap.addRole(role); + if (state == false) { + throw new AuthException("The role is exist"); + } + return state; + } + + /** + * Delete role + * + * @param roleName + * @return true: delete role successfully, false: delete role unsuccessfully + * @throws Exception + */ + public static boolean deleteRole(String roleName) throws AuthException { + boolean state = false; + state = authDaoWrap.deleteRole(roleName); + if (state == false) { + throw new AuthException("The role is not exist"); + } + return state; + } + + /** + * Add permission to role + * + * @param roleName + * @param nodeName + * @param permissionId + * @return true: add permission to role successfully, false: add permission to role unsuccessfully + * @throws AuthException + */ + public static boolean addPmsToRole(String roleName, String nodeName, int permissionId) throws AuthException { + boolean state = false; + state = authDaoWrap.addRolePermission(roleName, nodeName, permissionId); + return state; + } + + /** + * Delete permission from role + * + * @param roleName + * @param nodeName + * @param permissionId + * @return true: delete permission from role successfully, false: delete permission from role unsuccessfully + * @throws AuthException + */ + public static boolean removePmsFromRole(String roleName, String nodeName, int permissionId) throws AuthException { + boolean state = false; + state = authDaoWrap.deleteRolePermission(roleName, nodeName, permissionId); + return state; + } + + /** + * Add role to user + * + * @param roleName + * @param username + * @return true: add role to user successfully, false: add role to user unsuccessfully + * @throws AuthException + */ + public static boolean grantRoleToUser(String roleName, String username) throws AuthException { + boolean state = false; + state = authDaoWrap.addUserRoleRel(username, roleName); + return state; + } + + /** + * Delete role from user + * + * @param roleName + * @param username + * @return true: delete role from user successfully, false: delete role from user unsuccessfully + * @throws AuthException + */ + public static boolean revokeRoleFromUser(String roleName, String username) throws AuthException { + boolean state = false; + state = authDaoWrap.deleteUserRoleRel(username, roleName); + return state; + } + + /** + * Get the all permission of the user + * + * @param username + * @param nodeName + * @return + * @throws AuthException + */ + public static Set getPermission(String username, String nodeName) throws AuthException { + Set permissionSets = null; + permissionSets = authDaoWrap.getAllUserPermissions(username, nodeName); + return permissionSets; + } + + /** + * Modify the password + * + * @param username + * @param oldPassword + * @param newPassword + * @return true: update the password successfully, false: update the password unsuccessfully + * @throws AuthException + */ + public static boolean updateUserPassword(String username, String newPassword) throws AuthException { + boolean state = false; + state = authDaoWrap.updateUserPassword(username, newPassword); + if (state == false) { + throw new AuthException("The username or the password is not correct"); + } + return state; + } + + /** + * Check the permission belong to the user + * + * @param username + * @param nodeName + * @param permissionId + * @return true: the user has this permission, false: the user does not have the permission + */ + public static boolean checkUserPermission(String username, String nodeName, int permissionId) { + boolean state = false; + state = authDaoWrap.checkUserPermission(username, nodeName, permissionId); + return state; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/DBdao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/DBdao.java new file mode 100644 index 00000000000..e2425ae7662 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/DBdao.java @@ -0,0 +1,178 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.io.File; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import cn.edu.thu.tsfile.common.conf.TSFileDescriptor; + + +/** + * @author liukun + * + */ +public class DBdao { + + private String derbyEmbeddedDriver = "org.apache.derby.jdbc.EmbeddedDriver"; + private String protocal = "jdbc:derby:"; + private String DBName; + private String createOrNot = ";create=true"; + private String shutdown = ";shutdown=True"; + + private static Connection connection = null; + private static Statement statement = null; + private PreparedStatement preparedStatement = null; + + /** + * @param dBName + */ + public DBdao(String dBName) { + String path = TSFileDescriptor.getInstance().getConfig().derbyHome + File.separator + dBName; + DBName = path; + } + + public DBdao() { + this("derby-tsfile-db"); + } + + private void initDriver() { + try { + Class.forName(derbyEmbeddedDriver).newInstance(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + private void connection() { + String url = protocal + DBName + createOrNot; + try { + connection = DriverManager.getConnection(url); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private void closeConnection() { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } else { + try { + throw new Exception("The connection is null"); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private void statement() { + try { + statement = connection.createStatement(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private void closeStatement() { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } else { + try { + throw new Exception("The statement is null"); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private boolean checkTableExist() { + boolean state = false; + + try { + DatabaseMetaData metaData = connection.getMetaData(); + ResultSet resultSet; + resultSet = metaData.getTables(null, "APP", "USERTABLE", null); + if (resultSet.next()) { + state = true; + } + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + // create table; + public boolean createOriTable() { + boolean state = false; + try { + statement.executeUpdate(InitTable.createTableSql); + statement.executeUpdate(InitTable.createRoleTableSql); + statement.executeUpdate(InitTable.createUserRoleRelTableSql); + statement.executeUpdate(InitTable.creteUserPermissionTableSql); + statement.executeUpdate(InitTable.createRolePermissionTableSql); + statement.executeUpdate(InitTable.insertIntoUserToTableSql); + state = true; + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public void getPreparedStatement() { + try { + preparedStatement = connection.prepareStatement("test"); + + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public void closePreparedStatement() { + + } + + public void open() { + initDriver(); + connection(); + statement(); + if (!checkTableExist()) { + // + createOriTable(); + } + } + + public void close() { + closeStatement(); + closeConnection(); +// try { +// DriverManager.getConnection(protocal + shutdown); +// } catch (SQLException e) { +// e.printStackTrace(); +// } + } + + public static Statement getStatement() { + return statement; + } + + public static Connection getConnection() { + return connection; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/InitTable.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/InitTable.java new file mode 100644 index 00000000000..7fb3cf08b84 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/InitTable.java @@ -0,0 +1,37 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +/** + * @author liukun + * + */ +public class InitTable { + + public static String createTableSql = "create table userTable(" + + "id INT generated always as identity(start with 1,increment by 1) not null primary key," + + "userName VARCHAR(20) not null unique," + "password VARCHAR(20) not null," + + "locked CHAR(1) check (locked='t' or locked='f')," + "validTime VARCHAR(20))"; + + public static String createRoleTableSql = "create table roleTable(" + + "id INT generated always as identity(start with 1, increment by 1) not null primary key," + + "roleName VARCHAR(20) not null unique)"; + + public static String createUserRoleRelTableSql = "create table userRoleRelTable(" + + "id INT generated always as identity(start with 1, increment by 1) ," + "userId INT," + "roleId INT," + + "constraint pk_userrolerel primary key (userId,roleId)," + + "foreign key (userId) references usertable(id) on delete cascade," + + "foreign key (roleId) references roletable(id) on delete cascade)"; + + public static String creteUserPermissionTableSql = "create table userPermissionTable(" + + "id INT generated always as identity(start with 1,increment by 1) ," + "userId INT not null," + + "nodeName VARCHAR(20) not null," + "permissionId INT not null," + + "constraint pk_userpermission primary key (userId,nodeName,permissionId)," + + "foreign key (userId) references usertable(id) on delete cascade)"; + + public static String createRolePermissionTableSql = "create table rolePermissionTable(" + + "id INT generated always as identity(start with 1, increment by 1)," + "roleId INT not null," + + "nodeName VARCHAR(20) not null," + "permissionId INT not null," + + "constraint pk_rolepermission primary key (roleId,nodeName,permissionId)," + + "foreign key (roleId) references roleTable(id) on delete cascade)"; + + public static String insertIntoUserToTableSql = "insert into usertable (username,password) values('root','root')"; +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/RoleDao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/RoleDao.java new file mode 100644 index 00000000000..c689512a613 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/RoleDao.java @@ -0,0 +1,103 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import cn.edu.thu.tsfiledb.auth.model.DBContext; +import cn.edu.thu.tsfiledb.auth.model.Role; + + +/** + * @author liukun + * + */ +public class RoleDao { + + public List getRoles(Statement statement) { + ArrayList arrayList = new ArrayList<>(); + String sql = "select * from " + DBContext.roleTable; + + try { + ResultSet resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + Role role = new Role(); + int id = resultSet.getInt(1); + String roleName = resultSet.getString(2); + role.setId(id); + role.setRoleName(roleName); + arrayList.add(role); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return arrayList; + } + + public Role getRole(Statement statement, String roleName) { + String sql = "select * from " + DBContext.roleTable + " where roleName=" + "'" + roleName + "'"; + Role role = null; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + int id = resultSet.getInt(1); + String name = resultSet.getString(2); + role = new Role(id, name); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + return role; + } + + public Role getRole(Statement statement, int roleId) { + String sql = "select * from " + DBContext.roleTable + " where id=" + roleId; + Role role = null; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + if (resultSet.next()) { + role = new Role(roleId, resultSet.getString(2)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + return role; + } + + public int deleteRole(Statement statement, String roleName) { + String sql = "delete from " + DBContext.roleTable + " where roleName=" + "'" + roleName + "'"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int createRole(Statement statement, Role role) { + String sql = "insert into " + DBContext.roleTable + " (" + "roleName" + ")" + " values('" + role.getRoleName() + + "')"; + + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int updateRole(Statement statement) { + String sql = "update " + DBContext.roleTable + " set "; + int state = 0; + + return state; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/RolePermissionDao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/RolePermissionDao.java new file mode 100644 index 00000000000..83bba202225 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/RolePermissionDao.java @@ -0,0 +1,99 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import cn.edu.thu.tsfiledb.auth.model.DBContext; +import cn.edu.thu.tsfiledb.auth.model.RolePermission; + + +/** + * @author liukun + * + */ +public class RolePermissionDao { + + public int createRolePermission(Statement statement, RolePermission rolePermission) { + String sql = "insert into " + DBContext.rolePermission + " (roleId,nodeName,permissionId) values" + "(" + + rolePermission.getRoleId() + ",'" + rolePermission.getNodeName() + "'," + + rolePermission.getPermissionId() + ")"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int deleteRolePermission(Statement statement, RolePermission rolePermission) { + String sql = "delete from " + DBContext.rolePermission + " where roleId=" + rolePermission.getRoleId() + " and " + + "nodeName=" + "'" + rolePermission.getNodeName() + "'" + " and " + "permissionId=" + + rolePermission.getPermissionId(); + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public RolePermission getRolePermission(Statement statement, RolePermission rolePermission) { + String sql = "select * from " + DBContext.rolePermission + " where roleId=" + rolePermission.getRoleId() + + " and nodeName='" + rolePermission.getNodeName() + "' and permissionId=" + + rolePermission.getPermissionId(); + RolePermission permission = null; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + if (resultSet.next()) { + permission = new RolePermission(resultSet.getInt(1), resultSet.getInt(2), resultSet.getString(3), + resultSet.getInt(4)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + return permission; + } + + public List getRolePermissions(Statement statement) { + String sql = "select * from " + DBContext.rolePermission; + List rolePermissions = new ArrayList<>(); + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + RolePermission rolePermission = new RolePermission(resultSet.getInt(1), resultSet.getInt(2), + resultSet.getString(3), resultSet.getInt(4)); + rolePermissions.add(rolePermission); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return rolePermissions; + } + + public List getRolePermissionByRoleAndNodeName(Statement statement, int roleId, String nodeName) { + String sql = "select * from " + DBContext.rolePermission + " where roleId=" + roleId + " and nodeName='" + + nodeName + "'"; + List rolePermissions = new ArrayList<>(); + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + RolePermission rolePermission = new RolePermission(resultSet.getInt(1), resultSet.getInt(2), + resultSet.getString(3), resultSet.getInt(4)); + rolePermissions.add(rolePermission); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return rolePermissions; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserDao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserDao.java new file mode 100644 index 00000000000..8a2011eeeeb --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserDao.java @@ -0,0 +1,116 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import cn.edu.thu.tsfiledb.auth.model.DBContext; +import cn.edu.thu.tsfiledb.auth.model.User; + + +/** + * @author liukun + * + */ +public class UserDao { + + public int createUser(Statement statement, User user) { + + String sql = "insert into " + DBContext.userTable + " (userName,passWord) " + " values ('" + user.getUserName() + + "','" + user.getPassWord() + "')"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int deleteUser(Statement statement, String userName) { + String sql = "delete from " + DBContext.userTable + " where userName=" + "'" + userName + "'"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int updateUserPassword(Statement statement, String userName, String newPassword) { + String sql = "update " + DBContext.userTable + " set password='" + newPassword + "'" + " where username='" + + userName + "'"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public List getUsers(Statement statement) { + String sql = "select * from " + DBContext.userTable; + ArrayList arrayList = new ArrayList<>(); + + try { + ResultSet resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + int id = resultSet.getInt(1); + String userName = resultSet.getString(2); + String passWord = resultSet.getString(3); + boolean isLock = resultSet.getBoolean(4); + String validTime = resultSet.getString(5); + User user = new User(id, userName, passWord, isLock, validTime); + arrayList.add(user); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return arrayList; + } + + public User getUser(Statement statement, String userName) { + String sql = "select * from " + DBContext.userTable + " where userName=" + "'" + userName + "'"; + User user = null; + + try { + ResultSet resultSet = statement.executeQuery(sql); + if (resultSet.next()) { + int id = resultSet.getInt(1); + String name = userName; + String passWord = resultSet.getString(3); + boolean isLock = resultSet.getBoolean(4); + String validTime = resultSet.getString(5); + user = new User(id, name, passWord, isLock, validTime); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return user; + + } + + public User getUser(Statement statement, String userName, String password) { + User user = null; + String sql = "select * from " + DBContext.userTable + " where username='" + userName + "'" + " and password='" + + password + "'"; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + if (resultSet.next()) { + user = new User(); + user.setId(resultSet.getInt(1)); + user.setUserName(resultSet.getString(2)); + user.setPassWord(resultSet.getString(3)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return user; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserPermissionDao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserPermissionDao.java new file mode 100644 index 00000000000..21b35bb9fef --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserPermissionDao.java @@ -0,0 +1,99 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import cn.edu.thu.tsfiledb.auth.model.DBContext; +import cn.edu.thu.tsfiledb.auth.model.UserPermission; + + +/** + * @author liukun + * + */ +public class UserPermissionDao { + + public int createUserPermission(Statement statement, UserPermission userPermission) { + String sql = "insert into " + DBContext.userPermission + " (userId,nodeName,permissionId)" + " values(" + + userPermission.getUserId() + ",'" + userPermission.getNodeName() + "'," + + userPermission.getPermissionId() + ")"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int deleteUserPermission(Statement statement, UserPermission userPermission) { + String sql = "delete from " + DBContext.userPermission + " where userId=" + userPermission.getUserId() + " and " + + "nodeName=" + "'" + userPermission.getNodeName() + "'" + " and " + "permissionId=" + + userPermission.getPermissionId(); + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public UserPermission getUserPermission(Statement statement, UserPermission userPermission) { + String sql = "select * from " + DBContext.userPermission + " where userId=" + userPermission.getUserId() + + " and " + "nodeName=" + "'" + userPermission.getNodeName() + "'" + " and " + "permissionId=" + + userPermission.getPermissionId(); + UserPermission permission = null; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + if (resultSet.next()) { + permission = new UserPermission(resultSet.getInt(1), resultSet.getInt(2), resultSet.getString(3), + resultSet.getInt(4)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return permission; + } + + // + public ArrayList getUserPermissionByUserAndNodeName(Statement statement, int userId, + String nodeName) { + ArrayList userPermissions = new ArrayList<>(); + String sql = "select * from " + DBContext.userPermission + " where userId=" + userId + " and " + "nodeName=" + + "'" + nodeName + "'"; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + UserPermission userPermission = new UserPermission(resultSet.getInt(1), resultSet.getInt(2), + resultSet.getString(3), resultSet.getInt(4)); + userPermissions.add(userPermission); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return userPermissions; + } + + public List getUserPermissions(Statement statement) { + ArrayList userPermissions = new ArrayList<>(); + String sql = "select * from " + DBContext.userPermission; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + UserPermission userPermission = new UserPermission(resultSet.getInt(1), resultSet.getInt(2), + resultSet.getString(3), resultSet.getInt(4)); + userPermissions.add(userPermission); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return userPermissions; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserRoleRelDao.java b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserRoleRelDao.java new file mode 100644 index 00000000000..69fc1f04992 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/dao/UserRoleRelDao.java @@ -0,0 +1,117 @@ +package cn.edu.thu.tsfiledb.auth.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import cn.edu.thu.tsfiledb.auth.model.DBContext; +import cn.edu.thu.tsfiledb.auth.model.UserRoleRel; + + +/** + * @author liukun + * + */ +public class UserRoleRelDao { + + public List getUserRoleRels(Statement statement) { + String sql = "select * from " + DBContext.userRoleRel; + ArrayList arrayList = new ArrayList<>(); + + try { + ResultSet resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + + int id = resultSet.getInt(1); + int userId = resultSet.getInt(2); + int roleId = resultSet.getInt(3); + UserRoleRel rel = new UserRoleRel(id, userId, roleId); + arrayList.add(rel); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + return arrayList; + } + + public UserRoleRel getUserRoleRel(Statement statement, UserRoleRel rel) { + String sql = "select * from " + DBContext.userRoleRel + " where userId=" + rel.getUserId() + " and roleId=" + + rel.getRoleId(); + UserRoleRel userRoleRel = null; + ResultSet resultSet; + try { + resultSet = statement.executeQuery(sql); + if (resultSet.next()) { + userRoleRel = new UserRoleRel(resultSet.getInt(1), resultSet.getInt(2), resultSet.getInt(3)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return userRoleRel; + + } + + public List getUserRoleRelByUser(Statement statement, int userId) { + String sql = "select * from " + DBContext.userRoleRel + " where userId = " + userId; + ArrayList arrayList = new ArrayList<>(); + try { + ResultSet resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + int id = resultSet.getInt(1); + int roleId = resultSet.getInt(3); + UserRoleRel rel = new UserRoleRel(id, userId, roleId); + arrayList.add(rel); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return arrayList; + } + + public List getUserRoleRelByRole(Statement statement, int roleId) { + String sql = "select * from " + DBContext.userRoleRel + " where roleId=" + roleId; + ArrayList arrayList = new ArrayList<>(); + try { + ResultSet resultSet = statement.executeQuery(sql); + while (resultSet.next()) { + int id = resultSet.getInt(1); + int userId = resultSet.getInt(2); + UserRoleRel rel = new UserRoleRel(id, userId, roleId); + arrayList.add(rel); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return arrayList; + } + + public int createUserRoleRel(Statement statement, UserRoleRel rel) { + String sql = "insert into " + DBContext.userRoleRel + " (userId,roleId) values" + "(" + rel.getUserId() + "," + + rel.getRoleId() + ")"; + int state = 0; + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + return state; + } + + public int deleteUserRoleRel(Statement statement, UserRoleRel rel) { + String sql = "delete from " + DBContext.userRoleRel + " where userId=" + rel.getUserId() + " and roleId=" + + rel.getRoleId(); + int state = 0; + + try { + state = statement.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + + return state; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/AuthException.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/AuthException.java new file mode 100644 index 00000000000..ba2493b4c18 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/AuthException.java @@ -0,0 +1,28 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * The exception for authority model + * Created by liukun on 17/1/4. + */ +public class AuthException extends Exception { + public AuthException(String format, String userName, String roleName) { + super(); + } + + public AuthException(String message) { + super(message); + } + + public AuthException(String message, Throwable cause) { + super(message, cause); + } + + public AuthException(Throwable cause) { + super(cause); + } + + protected AuthException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/DBContext.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/DBContext.java new file mode 100644 index 00000000000..fda7be9ec0f --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/DBContext.java @@ -0,0 +1,16 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * The + * @author liukun + * + */ +public class DBContext { + + public static final String userTable = "userTable"; + public static final String roleTable = "roleTable"; + public static final String userRoleRel = "userRoleRelTable"; + public static final String userPermission = "userPermissionTable"; + public static final String rolePermission = "rolePermissionTable"; + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/Permission.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/Permission.java new file mode 100644 index 00000000000..8b10d83faaf --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/Permission.java @@ -0,0 +1,15 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * @author liukun + * + */ +public class Permission { + + public static final int CREATE = 0; + public static final int INSERT = 1; + public static final int MODIFY = 2; + public static final int READ = 3; + public static final int DELETE = 4; + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/Role.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/Role.java new file mode 100644 index 00000000000..ca94c37edc8 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/Role.java @@ -0,0 +1,57 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * @author liukun + * + */ +public class Role { + + private int id; + private String roleName; + /** + * @param id + * @param roleName + */ + public Role(int id, String roleName) { + this.id = id; + this.roleName = roleName; + } + + public Role(String roleName) { + this.roleName = roleName; + } + + public Role(){ + + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the roleName + */ + public String getRoleName() { + return roleName; + } + + /** + * @param roleName the roleName to set + */ + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/RolePermission.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/RolePermission.java new file mode 100644 index 00000000000..216b943d314 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/RolePermission.java @@ -0,0 +1,96 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * @author liukun + * + */ +public class RolePermission { + + private int id; + private int roleId; + private String nodeName; + private int permissionId; + + /** + * @param id + * @param roleId + * @param permissionId + */ + public RolePermission(int id, int roleId, String nodeName, int permissionId) { + this.id = id; + this.roleId = roleId; + this.nodeName = nodeName; + this.permissionId = permissionId; + } + + public RolePermission(int roleId, String nodeName, int permissionId) { + this.roleId = roleId; + this.nodeName = nodeName; + this.permissionId = permissionId; + } + + public RolePermission() { + + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the nodeName + */ + public String getNodeName() { + return nodeName; + } + + /** + * @param nodeName + * the nodeName to set + */ + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + /** + * @return the roleId + */ + public int getRoleId() { + return roleId; + } + + /** + * @param roleId + * the roleId to set + */ + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + /** + * @return the permissionId + */ + public int getPermissionId() { + return permissionId; + } + + /** + * @param permissionId + * the permissionId to set + */ + public void setPermissionId(int permissionId) { + this.permissionId = permissionId; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/User.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/User.java new file mode 100644 index 00000000000..2e5c98863c3 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/User.java @@ -0,0 +1,109 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * @author liukun + * + */ +public class User { + + private int id; + private String userName; + private String passWord; + private boolean locked;//true - t false - f + private String validTime; + /** + * @param id + * @param userName + * @param passWord + * @param isLock + * @param validTime + */ + public User(int id, String userName, String passWord, boolean isLock, String validTime) { + this.id = id; + this.userName = userName; + this.passWord = passWord; + this.locked = isLock; + this.validTime = validTime; + } + + public User(){ + + } + + public User(String userName, String passWord) { + this.userName = userName; + this.passWord = passWord; + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + + /** + * @param userName the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * @return the passWord + */ + public String getPassWord() { + return passWord; + } + + /** + * @param passWord the passWord to set + */ + public void setPassWord(String passWord) { + this.passWord = passWord; + } + + /** + * @return the isLock + */ + public boolean isLock() { + return locked; + } + + /** + * @param isLock the isLock to set + */ + public void setLock(boolean isLock) { + this.locked = isLock; + } + + /** + * @return the validTime + */ + public String getValidTime() { + return validTime; + } + + /** + * @param validTime the validTime to set + */ + public void setValidTime(String validTime) { + this.validTime = validTime; + } + + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/UserPermission.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/UserPermission.java new file mode 100644 index 00000000000..29f9c6d3e4e --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/UserPermission.java @@ -0,0 +1,98 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * @author liukun + * + */ +public class UserPermission { + + private int id; + private int userId; + private String nodeName; + private int permissionId;// 权限的值必须是permission中的,在数据库中使用check方法来指定 + + /** + * @param id + * @param userId + * @param nodeName + * @param permissionId + */ + public UserPermission(int id, int userId, String nodeName, int permissionId) { + this.id = id; + this.userId = userId; + this.nodeName = nodeName; + this.permissionId = permissionId; + } + + public UserPermission() { + + } + + public UserPermission(int userId, String nodeName, int permissionId) { + this.userId = userId; + this.nodeName = nodeName; + this.permissionId = permissionId; + } + + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the userId + */ + public int getUserId() { + return userId; + } + + /** + * @param userId + * the userId to set + */ + public void setUserId(int userId) { + this.userId = userId; + } + + /** + * @return the nodeName + */ + public String getNodeName() { + return nodeName; + } + + /** + * @param nodeName + * the nodeName to set + */ + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + /** + * @return the permissionId + */ + public int getPermissionId() { + return permissionId; + } + + /** + * @param permissionId + * the permissionId to set + */ + public void setPermissionId(int permissionId) { + this.permissionId = permissionId; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/auth/model/UserRoleRel.java b/src/main/java/cn/edu/thu/tsfiledb/auth/model/UserRoleRel.java new file mode 100644 index 00000000000..952ecccc7a2 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/auth/model/UserRoleRel.java @@ -0,0 +1,65 @@ +package cn.edu.thu.tsfiledb.auth.model; + +/** + * @author liukun + * + */ +public class UserRoleRel { + private int id; + private int userId; + private int roleId; + /** + * @param id + * @param userId + * @param roleId + */ + public UserRoleRel(int id, int userId, int roleId) { + this.id = id; + this.userId = userId; + this.roleId = roleId; + } + public UserRoleRel(int userId,int roleId){ + this.userId = userId; + this.roleId = roleId; + } + public UserRoleRel() { + + } + /** + * @return the id + */ + public int getId() { + return id; + } + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + /** + * @return the userId + */ + public int getUserId() { + return userId; + } + /** + * @param userId the userId to set + */ + public void setUserId(int userId) { + this.userId = userId; + } + /** + * @return the roleId + */ + public int getRoleId() { + return roleId; + } + /** + * @param roleId the roleId to set + */ + public void setRoleId(int roleId) { + this.roleId = roleId; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/Client.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Client.java new file mode 100644 index 00000000000..b0eba015ebe --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Client.java @@ -0,0 +1,229 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLTimeoutException; +import java.sql.Statement; + +import jline.console.ConsoleReader; + +public class Client { + + private static final int MAX_PRINT_ROW_COUNT = 1000; + + public static void main(String[] args) throws ClassNotFoundException, SQLException { + // TODO Auto-generated method stub + Class.forName("com.corp.tsfile.jdbc.TsfileDriver"); + Connection connection = null; + ConsoleReader reader = null; + String s; + boolean printToConsole = true; + + try { + reader = new ConsoleReader(); + String[] argsName = new String[] { "-host", "-port", "-u", "-print" }; + String[] argv = new String[argsName.length]; + + if (args.length < 3) { + System.out.println("Useage : login -host -port -u"); + System.out.println("e.g. : login -host127.0.0.1 -port6667 -u"); + return; + } + + for (int i = 0; i < args.length; i++) { + String v = args[i].trim(); + for (int j = 0; j < argsName.length; j++) { + if (v.startsWith(argsName[j])) { + argv[j] = v.substring(argsName[j].length()).trim(); + } + } + } + + if (argv[3] != null && !argv[3].equals("")) { + if (argv[3].toLowerCase().equals("true") || argv[3].toLowerCase().equals("false")) { + printToConsole = Boolean.valueOf(argv[3]); + } else { + System.out.println("-print args error."); + return; + } + } + String password = reader.readLine("Password: ", ' '); + try { + connection = DriverManager.getConnection("jdbc:tsfile://" + argv[0] + ":" + argv[1] + "/x", argv[2], + password); + } catch (SQLTimeoutException e){ + System.out.println("Connect Timeout: " + e.getMessage()); + return; + } catch (SQLException e) { + System.out.println(e.getMessage()); + return; + } + + } catch (IOException e) { + System.out.println("Console Input Error:" + e.getMessage()); + } catch (Exception e){ + System.out.println("Unknown Error: " + e.getMessage()); + } + + System.out.println(" _______________________________.___.__ \n" + + " \\__ ___/ _____/\\_ _____/| | | ____ \n" + + " | | \\_____ \\ | __) | | | _/ __ \\ \n" + + " | | / \\ | \\ | | |_\\ ___/ \n" + + " |____| /_______ / \\___ / |___|____/\\___ > version 0.0.1\n" + + " \\/ \\/ \\/ \n"); + // Login in and create connection first + + System.out.println("login successfully"); + // connection = + // DriverManager.getConnection("jdbc:tsfile://127.0.0.1:6667/x", + // "User", "HAHAH"); + + try { + while (true) { + s = reader.readLine("[TSFile: ] > "); + if (s.toLowerCase().trim().equals("quit")) { + System.out.println(">> TSFile Quit"); + break; + } + if (s.toLowerCase().trim().equals("show metadata")){ + System.out.println(connection.getMetaData()); + continue; + } + String[] cmds = s.split(";"); + for (int i = 0; i < cmds.length; i++) { + String cmd = cmds[i]; + if (cmd != null && !cmd.trim().equals("")) { + Statement statement = connection.createStatement(); + statement.setFetchSize(500000); + try { + boolean hasResultSet = statement.execute(cmd.trim()); + if (hasResultSet) { + ResultSet resultSet = statement.getResultSet(); + output(resultSet, printToConsole); + } + statement.close(); + System.out.println("Execute successfully."); + } catch (TsfileSQLException e) { + System.out.println("statement error: " + e.getMessage()); + } catch (Exception e){ + System.out.println("Connection error. " + e.getMessage()); + } + + } + } + } + connection.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + + public static void output(ResultSet res, boolean printToConsole) { + try { + File file = new File("src/main/resources/output/queryRes.csv"); + if (!file.exists()) { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + file.createNewFile(); + } + FileWriter fw = new FileWriter(file); +// BufferedWriter bw = new BufferedWriter(fw); + int cnt = 0; + int colCount = res.getMetaData().getColumnCount(); + // //Output Labels + String format = "|%15s|"; + String blockLine = ""; + if (printToConsole) { + // System.out.printf("+---------------+"); + // for(int i = 0 ; i < res.mapRet.keySet().size(); i++){ + // System.out.printf("---------------+"); + // } + // System.out.printf("\n"); + // + // System.out.printf("|%15s|","Timestamp"); + // for(String name : res.mapRet.keySet()){ + // System.out.printf("%15s|", name.split(",")[1]); + // } + // System.out.printf("\n"); + // + + int maxv = 15; + for (int i = 0; i < colCount; i++) { + int len = res.getMetaData().getColumnLabel(i).length(); + maxv = maxv < len ? len : maxv; + } + + for (int i = 0; i < maxv; i++) { + blockLine += "-"; + } + System.out.printf("+" + blockLine + "+"); + for (int i = 0; i < colCount - 1; i++) { + System.out.printf(blockLine + "+"); + } + System.out.printf("\n"); + + format = "%" + maxv + "s|"; + System.out.printf("|" + format, "Timestamp"); + for (int i = 0; i < colCount - 1; i++) { + System.out.printf(format, res.getMetaData().getColumnLabel(i + 1)); + } + System.out.printf("\n"); + + System.out.printf("+" + blockLine + "+"); + for (int i = 0; i < colCount - 1; i++) { + System.out.printf(blockLine + "+"); + } + System.out.printf("\n"); + } + + // Output values + while (res.next()) { + StringBuilder line = new StringBuilder(); + line.append(String.valueOf(res.getString(0))); + + if (printToConsole && cnt < MAX_PRINT_ROW_COUNT) { + System.out.printf("|" + format, String.valueOf(res.getString(0))); + } + + for (int i = 1; i < colCount; i++) { + line.append(","); + line.append(res.getString(i)); + if (printToConsole && cnt < MAX_PRINT_ROW_COUNT) { + System.out.printf(format, String.valueOf(res.getString(i))); + } + } + + if (printToConsole && cnt < MAX_PRINT_ROW_COUNT) { + System.out.printf("\n"); + } + +// bw.write(line.toString()); +// bw.newLine(); + cnt++; + + if (!printToConsole && cnt % 10000 == 0) { + System.out.println(cnt); + } + } + + if (printToConsole) { + System.out.printf("+" + blockLine + "+"); + for (int i = 0; i < colCount - 1; i++) { + System.out.printf(blockLine + "+"); + } + System.out.printf("\n"); + } + +// bw.close(); + System.out.println("Result size : " + cnt); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/Demo.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Demo.java new file mode 100644 index 00000000000..df99b5f63eb --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Demo.java @@ -0,0 +1,41 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class Demo { + + public static void main(String[] args) throws SQLException, ClassNotFoundException { + Class.forName("com.corp.tsfile.jdbc.TsfileDriver"); + Connection connection = DriverManager.getConnection("jdbc:tsfile://127.0.0.1:6667/", "root", "root"); +// Statement statement = connection.createStatement(); +// statement.addBatch("123"); +// statement.addBatch("321"); +// int[] resultSet = statement.executeBatch(); +// System.out.println(resultSet.length); +// statement.clearBatch(); +// connection.close(); +// +// Connection connection = DriverManager.getConnection("jdbc:tsfile://192.168.130.15:6667/","root","root"); + DatabaseMetaData databaseMetaData = connection.getMetaData(); + System.out.println("show metadata"); + System.out.println(databaseMetaData); + // get all columns + ResultSet resultSet = databaseMetaData.getColumns(null, null, "car", null); + while(resultSet.next()){ + System.out.println(String.format("column %s, type %s", resultSet.getString("COLUMN_NAME"), resultSet.getString("COLUMN_TYPE"))); + } + // get all delta object + resultSet = databaseMetaData.getColumns(null, null, null, "car"); + while(resultSet.next()){ + System.out.println(String.format("delta object %s", resultSet.getString("DELTA_OBJECT"))); + } + connection.close(); + + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/Generator.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Generator.java new file mode 100644 index 00000000000..9db6346512c --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Generator.java @@ -0,0 +1,137 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.lang.management.ManagementFactory; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import com.sun.management.OperatingSystemMXBean; + +import cn.edu.thu.tsfile.file.metadata.enums.TSDataType; +import cn.edu.thu.tsfile.file.metadata.enums.TSEncoding; + +@SuppressWarnings("restriction") +public class Generator { + private static final Logger LOGGER = LoggerFactory.getLogger(Generator.class); + + private String deviceName; + private OperatingSystemMXBean osmb; + + private final String createTimeSeriesTemplate = "create timeseries root.%s.laptop.%s with datatype=%s,encoding=%s"; + private final String insertDataTemplate = "insert into root.%s.laptop.%s values(%s,%s)"; + private final String queryDataTemplate = "select laptop.* from root.%s where time < %s"; + private final String setFileLevelTemplate = "set storage group to root.%s.laptop"; + + private final long SLEEP_INTERVAL = 5000; + +// private final String JDBC_SERVER_URL = "jdbc:tsfile://127.0.0.1:6667/x"; + private final String JDBC_SERVER_URL = "jdbc:tsfile://192.168.130.15:6667/x"; + + + public Generator(String deviceName) { + this.deviceName = deviceName; + this.osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + + } + + public void start() throws ClassNotFoundException, SQLException { + Class.forName("com.corp.tsfile.jdbc.TsfileDriver"); + createTimeSeriesMetadata(); + while (true) { + try { + insertData(); + Thread.sleep(SLEEP_INTERVAL); + } catch (SQLException e) { + LOGGER.error("tsfile-jdbc Generator: insertData failed because ", e); + } catch (InterruptedException e) { + LOGGER.error("tsfile-jdbc Generator: thread sleep failed because ", e); + } + } + } + + public void test() throws SQLException, ClassNotFoundException { + Class.forName("com.corp.tsfile.jdbc.TsfileDriver"); + Connection connection = DriverManager.getConnection(JDBC_SERVER_URL, "root", "root"); + Statement statement = connection.createStatement(); + ResultSet res = statement.executeQuery(String.format(queryDataTemplate, deviceName, getCurretnTimestamp())); + Client.output(res, true); + connection.close(); + } + + private void createTimeSeriesMetadata() throws SQLException { + List sqls = new ArrayList<>(); + sqls.add(String.format(createTimeSeriesTemplate, deviceName, "cpu", TSDataType.FLOAT.toString(), + TSEncoding.RLE.toString())); + sqls.add(String.format(createTimeSeriesTemplate, deviceName, "memory", TSDataType.INT64.toString(), + TSEncoding.RLE.toString())); + sqls.add(String.format(setFileLevelTemplate, deviceName)); + executeSQL(sqls); + } + + private void insertData() throws SQLException { + List sqls = new ArrayList<>(); + String timestamp = String.valueOf(getCurretnTimestamp()); + sqls.add(String.format(insertDataTemplate, deviceName, "cpu", timestamp, getCpuRatio())); + sqls.add(String.format(insertDataTemplate, deviceName, "memory", timestamp, getFreePhysicalMemorySize())); + executeSQL(sqls); + } + + private void executeSQL(List sqls) throws SQLException { + Connection connection = null; + try { + connection = DriverManager.getConnection(JDBC_SERVER_URL, "root", "root"); + Statement statement = connection.createStatement(); + for (String sql : sqls) { + try { + statement.execute(sql); + } catch (Exception e) { + LOGGER.error("tsfile-jdbc Generator: execute {} failed!", sql, e); + continue; + } + LOGGER.info("tsfile-jdbc Generator: execute {} successfully!", sql); + } + } catch (SQLException e) { + LOGGER.error("tsfile-jdbc Generator: fail to execute {} because ", sqls, e); + } finally { + if (connection != null) { + connection.close(); + connection = null; + } + } + } + + public String getCpuRatio() { + double cpuRatio = osmb.getSystemCpuLoad() * 100; + if (cpuRatio < 0 || cpuRatio > 100) { + return "0"; + } + return String.format("%.2f", cpuRatio); + } + + private String getFreePhysicalMemorySize() { + long sizeFree = osmb.getFreePhysicalMemorySize(); + return sizeFree > 0 ? String.valueOf(sizeFree) : "0"; + } + + private String getCurretnTimestamp() { + return String.valueOf(System.currentTimeMillis()); + } + + public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException { + Generator demo = new Generator("caogaofei_pc"); + // insert data + demo.start(); + + // query data +// demo.test(); + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConfig.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConfig.java new file mode 100644 index 00000000000..6e05fc4cd83 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConfig.java @@ -0,0 +1,31 @@ +package cn.edu.thu.tsfiledb.jdbc; + +public class TsfileConfig { + /** + * The required prefix for the connection URL. + */ + public static final String TSFILE_URL_PREFIX = "jdbc:tsfile://"; + + public static final String TSFILE_DEFAULT_HOST = "localhost"; + /** + * If host is provided, without a port. + */ + public static final int TSFILE_DEFAULT_PORT = 8888; + + /** + * tsfile's default series name + */ + public static final String DEFAULT_SERIES_NAME = "default"; + + public static final String URI_JDBC_PREFIX = "jdbc:"; + + public static final String URI_TSFILE_PREFIX = "tsfile:"; + + public static final int DEFAULT_FETCH_SIZE = 1000; + + public static final String AUTH_USER = "user"; + public static final String DEFAULT_USER = "user"; + + public static final String AUTH_PASSWORD = "password"; + public static final String DEFALUT_PASSWORD = "password"; +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConnection.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConnection.java new file mode 100644 index 00000000000..98bf78d325c --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConnection.java @@ -0,0 +1,454 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.NClob; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLClientInfoException; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Struct; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +import org.apache.thrift.TException; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.transport.TSocket; +import org.apache.thrift.transport.TTransport; +import org.apache.thrift.transport.TTransportException; + +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService; +import cn.edu.thu.tsfiledb.metadata.ColumnSchema; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class TsfileConnection implements Connection { + private static final Logger LOGGER = LoggerFactory.getLogger(TsfileConnection.class); + private TsfileConnectionParams params; + private boolean isClosed = true; + private SQLWarning warningChain = null; + private TTransport transport; + private TSIService.Iface client = null; + private TS_SessionHandle sessionHandle = null; + private final List supportedProtocols = new LinkedList(); + // private int loginTimeout = 0; + private TSProtocolVersion protocol; + + public TsfileConnection(String url, Properties info) throws SQLException, TTransportException { + if (url == null) { + throw new TsfileURLException("Input url cannot be null"); + } + params = Utils.parseURL(url, info); + + supportedProtocols.add(TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1); + + openTransport(); + + client = new TSIService.Client(new TBinaryProtocol(transport)); + // open client session + openSession(); + + // Wrap the client with a thread-safe proxy to serialize the RPC calls + client = newSynchronizedClient(client); + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public T unwrap(Class arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void abort(Executor arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void clearWarnings() throws SQLException { + warningChain = null; + } + + @Override + public void close() throws SQLException { + if (isClosed) + return; + TSCloseSessionReq req = new TSCloseSessionReq(sessionHandle); + try { + client.CloseSession(req); + } catch (TException e) { + throw new SQLException("Error occurs when closing session at server", e); + } finally { + isClosed = true; + if (transport != null) + transport.close(); + } + } + + @Override + public void commit() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Array createArrayOf(String arg0, Object[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Blob createBlob() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Clob createClob() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public NClob createNClob() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public SQLXML createSQLXML() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Statement createStatement() throws SQLException { + if (isClosed) { + throw new SQLException("Cannot create statement because connection is closed"); + } + return new TsfileStatement(this, client, sessionHandle); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) { + throw new SQLException(String.format("Statement with resultset concurrency %d is not supported", resultSetConcurrency)); + } + if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) { + throw new SQLException(String.format("Statement with resultset type %d is not supported", resultSetType)); + } + return new TsfileStatement(this, client, sessionHandle); + } + + @Override + public Statement createStatement(int arg0, int arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Struct createStruct(String arg0, Object[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean getAutoCommit() throws SQLException { + return false; + } + + @Override + public String getCatalog() throws SQLException { + return "no cata log"; + } + + @Override + public Properties getClientInfo() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String getClientInfo(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getHoldability() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + if (isClosed) { + throw new SQLException("Cannot create statement because connection is closed"); + } + try { + TSFetchMetadataResp resp = client.FetchMetadata(new TSFetchMetadataReq()); + Utils.verifySuccess(resp.getStatus()); + Map> seriesMap = Utils.convertAllSchema(resp.getSeriesMap()); + Map> deltaObjectMap = resp.getDeltaObjectMap(); + String metadataInJson = resp.getMetadataInJson(); + return new TsfileDatabaseMetadata(this, seriesMap, deltaObjectMap, metadataInJson); + } catch (TException e) { + throw new SQLException("Fail to connect to server when fetching metadata because "+e.getMessage()); + } catch (Exception e){ + throw new SQLException("Error occurs when fetching metaData because " + e.getMessage()); + } + } + + @Override + public int getNetworkTimeout() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String getSchema() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getTransactionIsolation() throws SQLException { + return Connection.TRANSACTION_NONE; + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return warningChain; + } + + @Override + public boolean isClosed() throws SQLException { + return isClosed; + } + + @Override + public boolean isReadOnly() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean isValid(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String nativeSQL(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public CallableStatement prepareCall(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public CallableStatement prepareCall(String arg0, int arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public CallableStatement prepareCall(String arg0, int arg1, int arg2, int arg3) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void releaseSavepoint(Savepoint arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void rollback() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void rollback(Savepoint arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setAutoCommit(boolean arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setCatalog(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setClientInfo(Properties arg0) throws SQLClientInfoException { + throw new SQLClientInfoException("Method not supported", null); + } + + @Override + public void setClientInfo(String arg0, String arg1) throws SQLClientInfoException { + throw new SQLClientInfoException("Method not supported", null); + } + + @Override + public void setHoldability(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setNetworkTimeout(Executor arg0, int arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setReadOnly(boolean arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Savepoint setSavepoint() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Savepoint setSavepoint(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setSchema(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setTransactionIsolation(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setTypeMap(Map> arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + private void openTransport() throws TTransportException { + transport = new TSocket(params.getHost(), params.getPort()); + if (!transport.isOpen()) { + transport.open(); + LOGGER.debug("Connect to host {} port {}",params.getHost(),params.getPort()); + } + } + + private void openSession() throws SQLException { + TSOpenSessionReq openReq = new TSOpenSessionReq(TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1); + + openReq.setUsername(params.getUsername()); + openReq.setPassword(params.getPassword()); + + try { + TSOpenSessionResp openResp = client.OpenSession(openReq); + + // validate connection + Utils.verifySuccess(openResp.getStatus()); + if (!supportedProtocols.contains(openResp.getServerProtocolVersion())) { + throw new TException("Unsupported tsfile protocol"); + } + setProtocol(openResp.getServerProtocolVersion()); + sessionHandle = openResp.getSessionHandle(); + } catch (TException e) { + throw new SQLException(String.format("Can not establish connection with %s. because %s", + params.getJdbcUriString()), e.getMessage()); + } + isClosed = false; + } + + public static TSIService.Iface newSynchronizedClient(TSIService.Iface client) { + return (TSIService.Iface) Proxy.newProxyInstance(TsfileConnection.class.getClassLoader(), + new Class[] { TSIService.Iface.class }, new SynchronizedHandler(client)); + } + + public TSProtocolVersion getProtocol() { + return protocol; + } + + public void setProtocol(TSProtocolVersion protocol) { + this.protocol = protocol; + } + + private static class SynchronizedHandler implements InvocationHandler { + private final TSIService.Iface client; + + SynchronizedHandler(TSIService.Iface client) { + this.client = client; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + try { + synchronized (client) { + return method.invoke(client, args); + } + } catch (InvocationTargetException e) { + // all IFace APIs throw TException + if (e.getTargetException() instanceof TException) { + throw (TException) e.getTargetException(); + } else { + // should not happen + throw new TException("Error in calling method " + method.getName(), e.getTargetException()); + } + } catch (Exception e) { + throw new TException("Error in calling method " + method.getName(), e); + } + } + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConnectionParams.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConnectionParams.java new file mode 100644 index 00000000000..dd1e8f6453a --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileConnectionParams.java @@ -0,0 +1,59 @@ +package cn.edu.thu.tsfiledb.jdbc; + +public class TsfileConnectionParams { + private String host = TsfileConfig.TSFILE_DEFAULT_HOST; + private int port = TsfileConfig.TSFILE_DEFAULT_PORT; + private String jdbcUriString; + private String seriesName = TsfileConfig.DEFAULT_SERIES_NAME; + private String username = TsfileConfig.DEFAULT_USER; + private String password = TsfileConfig.DEFALUT_PASSWORD; + private String dbName; + + public TsfileConnectionParams(String url){ + this.jdbcUriString = url; + } + + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + public String getJdbcUriString() { + return jdbcUriString; + } + public void setJdbcUriString(String jdbcUriString) { + this.jdbcUriString = jdbcUriString; + } + public String getSeriesName() { + return seriesName; + } + public void setSeriesName(String seriesName) { + this.seriesName = seriesName; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public String getDbName() { + return dbName; + } + public void setDbName(String dbName) { + this.dbName = dbName; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileDatabaseMetadata.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileDatabaseMetadata.java new file mode 100644 index 00000000000..544620c2cf7 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileDatabaseMetadata.java @@ -0,0 +1,1117 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.RowIdLifetime; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; + +import cn.edu.thu.tsfiledb.metadata.ColumnSchema; + + +public class TsfileDatabaseMetadata implements DatabaseMetaData { + + private TsfileConnection connection; + private Map> seriesMap; + private Map> deltaObjectMap; + private String metadataInJson; + + public TsfileDatabaseMetadata(TsfileConnection connection, Map> seriesMap, Map> deltaObjectMap, String metadataInJson) { + this.connection = connection; + this.seriesMap = seriesMap; + this.deltaObjectMap = deltaObjectMap; + this.metadataInJson = metadataInJson; + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public T unwrap(Class iface) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean allProceduresAreCallable() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean allTablesAreSelectable() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean autoCommitFailureClosesAllResultSets() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean dataDefinitionCausesTransactionCommit() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean dataDefinitionIgnoredInTransactions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean deletesAreDetected(int arg0) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean generatedKeyAlwaysReturned() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getAttributes(String arg0, String arg1, String arg2, String arg3) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getBestRowIdentifier(String arg0, String arg1, String arg2, int arg3, boolean arg4) + throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getCatalogSeparator() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getCatalogTerm() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getCatalogs() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getClientInfoProperties() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getColumnPrivileges(String arg0, String arg1, String arg2, String arg3) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getColumns(String catalog, String schemaPattern, String columnPattern, String deltaObjectPattern) throws SQLException { + if(deltaObjectPattern != null){ + if(deltaObjectMap == null){ + throw new SQLException("No delta object metadata"); + } + List deltaObjectList = deltaObjectMap.get(deltaObjectPattern); + if(deltaObjectList == null){ + throw new SQLException(String.format("Cannot find delta object %s", deltaObjectPattern)); + } + return new TsfileMetadataResultSet(null, deltaObjectList); + } + + if(columnPattern != null){ + if(seriesMap == null){ + throw new SQLException("No schema for TsfileDatabaseMetadata"); + } + List columnSchemas = seriesMap.get(columnPattern); + + if(columnSchemas == null){ + throw new SQLException(String.format("Cannot find table %s",columnPattern)); + } + + return new TsfileMetadataResultSet(columnSchemas, null); + } + + return null; + } + + @Override + public Connection getConnection() throws SQLException { + return connection; + } + + @Override + public ResultSet getCrossReference(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5) + throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public int getDatabaseMajorVersion() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDatabaseMinorVersion() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getDatabaseProductName() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getDatabaseProductVersion() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public int getDefaultTransactionIsolation() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDriverMajorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDriverMinorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getDriverName() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getDriverVersion() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getExportedKeys(String arg0, String arg1, String arg2) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getExtraNameCharacters() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getFunctionColumns(String arg0, String arg1, String arg2, String arg3) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getFunctions(String arg0, String arg1, String arg2) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getIdentifierQuoteString() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getImportedKeys(String arg0, String arg1, String arg2) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getIndexInfo(String arg0, String arg1, String arg2, boolean arg3, boolean arg4) + throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public int getJDBCMajorVersion() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getJDBCMinorVersion() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxBinaryLiteralLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCatalogNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCharLiteralLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInGroupBy() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInIndex() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInOrderBy() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInSelect() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxColumnsInTable() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxConnections() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCursorNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxIndexLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxProcedureNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxRowSize() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxSchemaNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxStatementLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxStatements() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxTableNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxTablesInSelect() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxUserNameLength() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getNumericFunctions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getPrimaryKeys(String arg0, String arg1, String arg2) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getProcedureColumns(String arg0, String arg1, String arg2, String arg3) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getProcedureTerm() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getProcedures(String arg0, String arg1, String arg2) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, + String columnNamePattern) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public int getResultSetHoldability() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public RowIdLifetime getRowIdLifetime() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getSQLKeywords() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public int getSQLStateType() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getSchemaTerm() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getSchemas() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getSearchStringEscape() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getStringFunctions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getSystemFunctions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) + throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getTableTypes() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) + throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getTimeDateFunctions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getTypeInfo() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) + throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getURL() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String getUserName() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean insertsAreDetected(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean isCatalogAtStart() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean isReadOnly() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean locatorsUpdateCopy() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean nullPlusNonNullIsNull() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean nullsAreSortedAtEnd() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean nullsAreSortedAtStart() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean nullsAreSortedHigh() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean nullsAreSortedLow() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean othersDeletesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean othersInsertsAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean othersUpdatesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean ownDeletesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean ownInsertsAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean ownUpdatesAreVisible(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean storesLowerCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean storesMixedCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean storesUpperCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsANSI92EntryLevelSQL() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsANSI92FullSQL() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsANSI92IntermediateSQL() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsAlterTableWithAddColumn() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsAlterTableWithDropColumn() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsBatchUpdates() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCatalogsInDataManipulation() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCatalogsInIndexDefinitions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCatalogsInProcedureCalls() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCatalogsInTableDefinitions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsColumnAliasing() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsConvert() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsConvert(int fromType, int toType) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCoreSQLGrammar() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsCorrelatedSubqueries() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsDataManipulationTransactionsOnly() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsDifferentTableCorrelationNames() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsExpressionsInOrderBy() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsExtendedSQLGrammar() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsFullOuterJoins() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsGetGeneratedKeys() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsGroupBy() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsGroupByBeyondSelect() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsGroupByUnrelated() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsIntegrityEnhancementFacility() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsLikeEscapeClause() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsLimitedOuterJoins() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsMinimumSQLGrammar() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsMixedCaseIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsMultipleOpenResults() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsMultipleResultSets() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsMultipleTransactions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsNamedParameters() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsNonNullableColumns() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsOpenCursorsAcrossCommit() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsOpenCursorsAcrossRollback() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsOpenStatementsAcrossCommit() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsOpenStatementsAcrossRollback() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsOrderByUnrelated() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsOuterJoins() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsPositionedDelete() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsPositionedUpdate() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsResultSetHoldability(int holdability) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsResultSetType(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSavepoints() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSchemasInDataManipulation() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSchemasInIndexDefinitions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSchemasInProcedureCalls() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSchemasInTableDefinitions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSelectForUpdate() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsStatementPooling() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsStoredProcedures() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSubqueriesInComparisons() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSubqueriesInExists() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSubqueriesInIns() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsSubqueriesInQuantifieds() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsTableCorrelationNames() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsTransactionIsolationLevel(int level) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsTransactions() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsUnion() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean supportsUnionAll() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean updatesAreDetected(int type) throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean usesLocalFilePerTable() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public boolean usesLocalFiles() throws SQLException { + // TODO Auto-generated method stub + throw new SQLException("Method not supported"); + } + + @Override + public String toString(){ + return metadataInJson; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileDriver.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileDriver.java new file mode 100644 index 00000000000..4efa6fc81db --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileDriver.java @@ -0,0 +1,77 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.Connection; +import java.sql.Driver; +import java.sql.DriverPropertyInfo; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.Properties; +import java.util.logging.Logger; +import java.util.regex.Pattern; + +import org.apache.thrift.transport.TTransportException; + + +public class TsfileDriver implements Driver { + private static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(TsfileDriver.class); + + static { + try { + java.sql.DriverManager.registerDriver(new TsfileDriver()); + } catch (SQLException e) { + LOGGER.error("Error occurs when resgistering tsfile driver",e); + } + } + + /** + * Is this driver JDBC compliant? + */ + private static final boolean TSFILE_JDBC_COMPLIANT = false; + + public TsfileDriver() { + + } + + @Override + public boolean acceptsURL(String url) throws SQLException { + return Pattern.matches(TsfileConfig.TSFILE_URL_PREFIX+".*", url); + } + + @Override + public Connection connect(String url, Properties info) throws SQLException { + try { + return acceptsURL(url) ? new TsfileConnection(url, info) : null; + } catch (TTransportException e) { + throw new SQLException("Connection Error, Please check whether the network is avalible or the server has started. " + e.getMessage()); + } + } + + @Override + public int getMajorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMinorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new SQLFeatureNotSupportedException("Method not supported"); + } + + @Override + public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean jdbcCompliant() { + return TSFILE_JDBC_COMPLIANT; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileMetadataResultSet.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileMetadataResultSet.java new file mode 100644 index 00000000000..d5ba3b0d681 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileMetadataResultSet.java @@ -0,0 +1,257 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.math.BigDecimal; +import java.sql.Date; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.Statement; +import java.sql.Time; +import java.util.Iterator; +import java.util.List; + +import cn.edu.thu.tsfiledb.metadata.ColumnSchema; + + + +public class TsfileMetadataResultSet extends TsfileQueryResultSet { + + private Iterator columnItr; + private ColumnSchema currentColumn; + private String currentDeltaObject; + private MetadataType type; + + public TsfileMetadataResultSet(List columnSchemas, List deltaObjectList) { + if (columnSchemas != null) { + columnItr = columnSchemas.iterator(); + type = MetadataType.COLUMN; + } else if (deltaObjectList != null) { + columnItr = deltaObjectList.iterator(); + type = MetadataType.DELTA_OBJECT; + } + } + + @Override + public void close() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int findColumn(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public BigDecimal getBigDecimal(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean getBoolean(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public byte getByte(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public byte[] getBytes(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getConcurrency() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Date getDate(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public double getDouble(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public float getFloat(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getInt(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public long getLong(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean next() throws SQLException { + boolean hasNext = columnItr.hasNext(); + switch (type) { + case COLUMN: + if (hasNext) { + currentColumn = (ColumnSchema)columnItr.next(); + } + return hasNext; + case DELTA_OBJECT: + if (hasNext) { + currentDeltaObject = (String)columnItr.next(); + } + return hasNext; + default: + break; + } + return false; + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Object getObject(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public short getShort(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Statement getStatement() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String getString(String columnName) throws SQLException { + switch (columnName) { + case "COLUMN_NAME": + return currentColumn.name; + case "COLUMN_TYPE": + return currentColumn.dataType.toString(); + case "DELTA_OBJECT": + return currentDeltaObject; + default: + break; + } + return null; + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Time getTime(String columnName) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getType() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean isClosed() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean wasNull() throws SQLException { + throw new SQLException("Method not supported"); + } + + private enum MetadataType{ + DELTA_OBJECT, COLUMN; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileQueryResultSet.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileQueryResultSet.java new file mode 100644 index 00000000000..324df33788c --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileQueryResultSet.java @@ -0,0 +1,1119 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.math.MathContext; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.thrift.TException; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet; +import cn.edu.thu.tsfile.timeseries.read.readSupport.RowRecord; + + + +public class TsfileQueryResultSet implements ResultSet { + private static final Logger LOGGER = LoggerFactory.getLogger(TsfileQueryResultSet.class); + + private Statement statement = null; + private String sql; + private SQLWarning warningChain = null; + private boolean wasNull = false; + private boolean isClosed = false; + private TSIService.Iface client = null; +// private TS_SessionHandle sessionHandle = null; + private TSOperationHandle operationHandle = null; + private Map columnInfo; + private RowRecord record; + private Iterator recordItr; + private int rowsFetched = 0; + private int maxRows; + private int fetchSize; + boolean emptyResultSet = false; + + public TsfileQueryResultSet(){ + + } + + public TsfileQueryResultSet(Statement statement,List columnName, + TSIService.Iface client, TS_SessionHandle sessionHandle , + TSOperationHandle operationHandle, String sql) throws SQLException { + this.statement = statement; + this.sql = sql; + this.columnInfo = new HashMap<>(); + this.client = client; + this.operationHandle = operationHandle; +// this.sessionHandle = sessionHandle; + columnInfo.put("Timestamp", 0); + int index = 1; + for(String name : columnName){ + columnInfo.put(name, index++); + } + this.maxRows = statement.getMaxRows(); + this.fetchSize = statement.getFetchSize(); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean absolute(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void afterLast() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void beforeFirst() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void clearWarnings() throws SQLException { + warningChain = null; + } + + @Override + public void close() throws SQLException { + if(isClosed) return; +// if (this.statement != null && (this.statement instanceof TsfileStatement)) { +// TsfileStatement s = (TsfileStatement) this.statement; +// s.closeClientOperation(); +// } else{ + closeOperationHandle(); +// } + client = null; +// sessionHandle = null; + isClosed = true; + } + + private void closeOperationHandle() throws SQLException{ + try { + if (operationHandle != null) { + TSCloseOperationReq closeReq = new TSCloseOperationReq(operationHandle); + TSCloseOperationResp closeResp = client.CloseOperation(closeReq); + Utils.verifySuccess(closeResp.getStatus()); + } + } catch (SQLException e) { + throw new SQLException("Error occurs for close opeation in server side becasuse "+e.getMessage()); + } catch (TException e) { + throw new SQLException("Error occurs when connecting to server for close operation, becasue: "+e.getMessage()); + } + } + + @Override + public void deleteRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int findColumn(String columnName) throws SQLException { + Integer column = columnInfo.get(columnName); + if(column == null){ + throw new SQLException(String.format("Column %s does not exist", columnName)); + } + return column; + } + + @Override + public boolean first() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Array getArray(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Array getArray(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public InputStream getAsciiStream(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public InputStream getAsciiStream(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + return new BigDecimal(getValue(columnIndex)); + } + + @Override + public BigDecimal getBigDecimal(String columnName) throws SQLException { + return getBigDecimal(findColumn(columnName)); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + MathContext mc = new MathContext(scale); + return getBigDecimal(columnIndex).round(mc); + } + + @Override + public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { + return getBigDecimal(findColumn(columnName),scale); + } + + @Override + public InputStream getBinaryStream(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public InputStream getBinaryStream(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Blob getBlob(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Blob getBlob(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + String b = getValue(columnIndex); + if(b.trim().equalsIgnoreCase("0")) return false; + if(b.trim().equalsIgnoreCase("1")) return true; + return Boolean.parseBoolean(getValue(columnIndex)); + } + + @Override + public boolean getBoolean(String columnName) throws SQLException { + return getBoolean(findColumn(columnName)); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public byte getByte(String columnName) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte[] getBytes(String columnName) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getCharacterStream(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Reader getCharacterStream(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Clob getClob(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Clob getClob(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getConcurrency() throws SQLException { + return ResultSet.CONCUR_READ_ONLY; + } + + @Override + public String getCursorName() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + return new Date(getLong(columnIndex)); + } + + @Override + public Date getDate(String columnName) throws SQLException { + return getDate(findColumn(columnName)); + } + + @Override + public Date getDate(int arg0, Calendar arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Date getDate(String arg0, Calendar arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + return Double.parseDouble(getValue(columnIndex)); + } + + @Override + public double getDouble(String columnName) throws SQLException { + return getDouble(findColumn(columnName)); + } + + @Override + public int getFetchDirection() throws SQLException { + return ResultSet.FETCH_FORWARD; + } + + @Override + public int getFetchSize() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + return Float.parseFloat(getValue(columnIndex)); + } + + @Override + public float getFloat(String columnName) throws SQLException { + return getFloat(findColumn(columnName)); + } + + @Override + public int getHoldability() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + return Integer.parseInt(getValue(columnIndex)); + } + + @Override + public int getInt(String columnName) throws SQLException { + return getInt(findColumn(columnName)); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + return Long.parseLong(getValue(columnIndex)); + } + + @Override + public long getLong(String columnName) throws SQLException { + return getLong(findColumn(columnName)); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + return new TsfileResultMetadata(columnInfo); + } + + @Override + public Reader getNCharacterStream(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Reader getNCharacterStream(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public NClob getNClob(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public NClob getNClob(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String getNString(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public String getNString(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + return getValue(columnIndex); + } + + @Override + public Object getObject(String columnName) throws SQLException { + return getObject(findColumn(columnName)); + } + + @Override + public Object getObject(int arg0, Map> arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Object getObject(String arg0, Map> arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public T getObject(int arg0, Class arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public T getObject(String arg0, Class arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Ref getRef(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Ref getRef(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public RowId getRowId(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public RowId getRowId(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public SQLXML getSQLXML(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public SQLXML getSQLXML(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + return Short.parseShort(getValue(columnIndex)); + } + + @Override + public short getShort(String columnName) throws SQLException { + return getShort(findColumn(columnName)); + } + + @Override + public Statement getStatement() throws SQLException { + return this.statement; + } + + @Override + public String getString(int columnIndex) throws SQLException { + return getValue(columnIndex); + } + + @Override + public String getString(String columnName) throws SQLException { + return getString(findColumn(columnName)); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + return new Time(getLong(columnIndex)); + } + + @Override + public Time getTime(String columnName) throws SQLException { + return getTime(findColumn(columnName)); + } + + @Override + public Time getTime(int arg0, Calendar arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Time getTime(String arg0, Calendar arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + return new Timestamp(getLong(columnIndex)); + } + + @Override + public Timestamp getTimestamp(String columnName) throws SQLException { + return getTimestamp(findColumn(columnName)); + } + + @Override + public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public Timestamp getTimestamp(String arg0, Calendar arg1) throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public int getType() throws SQLException { + return ResultSet.TYPE_FORWARD_ONLY; + } + + @Override + public URL getURL(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public URL getURL(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public InputStream getUnicodeStream(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public InputStream getUnicodeStream(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return warningChain; + } + + @Override + public void insertRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public boolean isClosed() throws SQLException { + return isClosed; + } + + @Override + public boolean isFirst() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean isLast() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean last() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean next() throws SQLException { + if(maxRows > 0 && rowsFetched >= maxRows){ + if(LOGGER.isInfoEnabled()) LOGGER.info("tsfile-jdbc TsfileResultSet: reach max rows {}", maxRows); + return false; + } + + if((recordItr == null || !recordItr.hasNext()) && !emptyResultSet){ + TSFetchResultsReq req = new TSFetchResultsReq(sql,fetchSize); + try { + TSFetchResultsResp resp = client.FetchResults(req); + Utils.verifySuccess(resp.status); + if(!resp.hasResultSet){ + emptyResultSet = true; + }else{ + QueryDataSet queryDataSet = Utils.convertQueryDataSet(resp.getQueryDataSet()); + List records = new ArrayList<>(); + while(queryDataSet.hasNextRecord()){ + records.add(queryDataSet.getNextRecord()); + } + + recordItr = records.iterator(); + } + } catch (TException e) { + throw new SQLException("Cannot fetch result from server, because "+e.getMessage()); + } + } + + if(emptyResultSet){ + return false; + } + record = recordItr.next(); + rowsFetched++; + return true; + } + + @Override + public boolean previous() throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public void refreshRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean relative(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public boolean rowInserted() throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public boolean rowUpdated() throws SQLException { + throw new SQLException("Method not supported"); } + + @Override + public void setFetchDirection(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setFetchSize(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateArray(int arg0, Array arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateArray(String arg0, Array arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateAsciiStream(int arg0, InputStream arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateAsciiStream(String arg0, InputStream arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateAsciiStream(int arg0, InputStream arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateAsciiStream(String arg0, InputStream arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateAsciiStream(int arg0, InputStream arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateAsciiStream(String arg0, InputStream arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBigDecimal(int arg0, BigDecimal arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBigDecimal(String arg0, BigDecimal arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBinaryStream(int arg0, InputStream arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBinaryStream(String arg0, InputStream arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBinaryStream(int arg0, InputStream arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBinaryStream(String arg0, InputStream arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBinaryStream(int arg0, InputStream arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBinaryStream(String arg0, InputStream arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBlob(int arg0, Blob arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBlob(String arg0, Blob arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBlob(int arg0, InputStream arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBlob(String arg0, InputStream arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBlob(int arg0, InputStream arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBlob(String arg0, InputStream arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBoolean(int arg0, boolean arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBoolean(String arg0, boolean arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateByte(int arg0, byte arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateByte(String arg0, byte arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBytes(int arg0, byte[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateBytes(String arg0, byte[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateCharacterStream(int arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateCharacterStream(String arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateCharacterStream(int arg0, Reader arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateCharacterStream(String arg0, Reader arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateCharacterStream(int arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateCharacterStream(String arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateClob(int arg0, Clob arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateClob(String arg0, Clob arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateClob(int arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateClob(String arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateClob(int arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + + } + + @Override + public void updateClob(String arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateDate(int arg0, Date arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateDate(String arg0, Date arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateDouble(int arg0, double arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateDouble(String arg0, double arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateFloat(int arg0, float arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateFloat(String arg0, float arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateInt(int arg0, int arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateInt(String arg0, int arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateLong(int arg0, long arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateLong(String arg0, long arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNCharacterStream(int arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNCharacterStream(String arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNCharacterStream(int arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNCharacterStream(String arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNClob(int arg0, NClob arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNClob(String arg0, NClob arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNClob(int arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNClob(String arg0, Reader arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNClob(int arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNClob(String arg0, Reader arg1, long arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNString(int arg0, String arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNString(String arg0, String arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNull(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateNull(String arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateObject(int arg0, Object arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateObject(String arg0, Object arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateObject(int arg0, Object arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateObject(String arg0, Object arg1, int arg2) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateRef(int arg0, Ref arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateRef(String arg0, Ref arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateRow() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateRowId(int arg0, RowId arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateRowId(String arg0, RowId arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateSQLXML(String arg0, SQLXML arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateShort(int arg0, short arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateShort(String arg0, short arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateString(int arg0, String arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateString(String arg0, String arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateTime(int arg0, Time arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateTime(String arg0, Time arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateTimestamp(int arg0, Timestamp arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void updateTimestamp(String arg0, Timestamp arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean wasNull() throws SQLException { + return wasNull; + } + + private void checkRecord() throws SQLException{ + if(record == null){ + throw new SQLException("No record remains"); + } + } + + private String getValue(int columnIndex) throws SQLException{ + checkRecord(); + if(columnIndex == 0){ + return String.valueOf(record.getTime()); + } + int len = record.fields.size(); + if(columnIndex > len || len == 0){ + throw new SQLException(String.format("columnIndex %d out of range %d",columnIndex,len)); + } + return record.fields.get(columnIndex-1).getStringValue(); + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileResultMetadata.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileResultMetadata.java new file mode 100644 index 00000000000..a5e72d15b95 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileResultMetadata.java @@ -0,0 +1,169 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.Map; + +public class TsfileResultMetadata implements ResultSetMetaData { + private Map columnInfo; + + public TsfileResultMetadata(Map columnInfo) { + this.columnInfo = columnInfo; + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getCatalogName(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getColumnClassName(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getColumnCount() throws SQLException { + if (columnInfo == null || columnInfo.keySet() == null || columnInfo.keySet().size() == 0) { + throw new SQLException("No column exists"); + } + return columnInfo.keySet().size(); + } + + @Override + public int getColumnDisplaySize(int arg0) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getColumnLabel(int column) throws SQLException { + if (columnInfo == null || columnInfo.keySet() == null || columnInfo.keySet().size() == 0) { + throw new SQLException("No column exists"); + } + + for (Map.Entry entry : columnInfo.entrySet()) { + if (entry.getValue().equals(column)) { + return String.format(entry.getKey()); + } + } + throw new SQLException(String.format("column %d does not exist", column)); + } + + @Override + public String getColumnName(int column) throws SQLException { + if (columnInfo == null || columnInfo.keySet() == null || columnInfo.keySet().size() == 0) { + throw new SQLException("tNo column exists"); + } + for (Map.Entry entry : columnInfo.entrySet()) { + if (entry.getValue().equals(column)) { + return entry.getKey(); + } + } + throw new SQLException(String.format("column %d does not exist", column)); + } + + @Override + public int getColumnType(int arg0) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getColumnTypeName(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getPrecision(int arg0) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getScale(int arg0) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getSchemaName(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getTableName(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isAutoIncrement(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isCaseSensitive(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isCurrency(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isDefinitelyWritable(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public int isNullable(int arg0) throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean isReadOnly(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isSearchable(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isSigned(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isWritable(int arg0) throws SQLException { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileSQLException.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileSQLException.java new file mode 100644 index 00000000000..394234c409c --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileSQLException.java @@ -0,0 +1,24 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.SQLException; + +public class TsfileSQLException extends SQLException{ + private String errorMessage; + + /** + * + */ + private static final long serialVersionUID = -3306001287342258977L; + + public TsfileSQLException(String reason){ + super(reason); + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileStatement.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileStatement.java new file mode 100644 index 00000000000..99ba7c158ce --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileStatement.java @@ -0,0 +1,411 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLWarning; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import org.apache.thrift.TException; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle; + +public class TsfileStatement implements Statement { + + private ResultSet resultSet = null; + private final TsfileConnection connection; + private int fetchSize = TsfileConfig.DEFAULT_FETCH_SIZE; + private int queryTimeout = 10; + private TSIService.Iface client = null; + private TS_SessionHandle sessionHandle = null; + private TSOperationHandle operationHandle = null; + private List batchSQLList; + + /** + * Keep state so we can fail certain calls made after close(). + */ + private boolean isClosed = false; + + /** + * Keep state so we can fail certain calls made after cancel(). + */ + private boolean isCancelled = false; + + /** + * Sets the limit for the maximum number of rows that any ResultSet object + * produced by this Statement can contain to the given number. If the limit + * is exceeded, the excess rows are silently dropped. The value must be >= + * 0, and 0 means there is not limit. + */ + private int maxRows = 0; + + /** + * Add SQLWarnings to the warningChain if needed. + */ + private SQLWarning warningChain = null; + + public TsfileStatement(TsfileConnection connection, TSIService.Iface client, TS_SessionHandle sessionHandle, + int fetchSize) { + this.connection = connection; + this.client = client; + this.sessionHandle = sessionHandle; + this.fetchSize = fetchSize; + this.batchSQLList = new ArrayList<>(); + } + + public TsfileStatement(TsfileConnection connection, TSIService.Iface client, TS_SessionHandle sessionHandle){ + this(connection, client, sessionHandle, TsfileConfig.DEFAULT_FETCH_SIZE); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new SQLException("Cannot unwrap to " + iface); + } + + @Override + public void addBatch(String sql) throws SQLException { + if(batchSQLList == null){ + batchSQLList = new ArrayList<>(); + } + batchSQLList.add(sql); + } + + @Override + public void cancel() throws SQLException { + checkConnection("cancle"); + if(isCancelled) return; + try { + if (operationHandle != null) { + TSCancelOperationReq closeReq = new TSCancelOperationReq(operationHandle); + TSCancelOperationResp closeResp = client.CancelOperation(closeReq); + Utils.verifySuccess(closeResp.getStatus()); + } + } catch (Exception e) { + throw new SQLException("Error occurs when cancling statement because "+e.getMessage()); + } + isCancelled = true; + } + + @Override + public void clearBatch() throws SQLException { + if(batchSQLList == null){ + batchSQLList = new ArrayList<>(); + } + batchSQLList.clear(); + } + + @Override + public void clearWarnings() throws SQLException { + warningChain = null; + } + + public void closeClientOperation() throws SQLException{ + try { + if (operationHandle != null) { + TSCloseOperationReq closeReq = new TSCloseOperationReq(operationHandle); + TSCloseOperationResp closeResp = client.CloseOperation(closeReq); + Utils.verifySuccess(closeResp.getStatus()); + } + } catch (Exception e) { + throw new SQLException("Error occurs when closing statement because "+e.getMessage()); + } + } + + @Override + public void close() throws SQLException { + if(isClosed) return; + +// if(resultSet != null){ +// resultSet.close(); +// resultSet = null; +// }else{ + closeClientOperation(); +// } + client = null; + isClosed = true; + } + + @Override + public void closeOnCompletion() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean execute(String sql) throws SQLException { + checkConnection("execute"); + try { + isCancelled = false; + TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql); + TSExecuteStatementResp execResp = client.ExecuteStatement(execReq); + operationHandle = execResp.getOperationHandle(); + Utils.verifySuccess(execResp.getStatus()); + if(execResp.getOperationHandle().hasResultSet){ + resultSet = new TsfileQueryResultSet(this, execResp.getColumns(), client, sessionHandle,operationHandle, sql); + return true; + } + return false; + } catch (TException e) { + throw new TsfileSQLException(String.format("Fail to execute %s when connecting to server because %s", sql, e.getMessage())); + } + } + + @Override + public boolean execute(String arg0, int arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean execute(String arg0, int[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public boolean execute(String arg0, String[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int[] executeBatch() throws SQLException { + checkConnection("executeBatch"); + try { + isCancelled = false; + TSExecuteBatchStatementReq execReq = new TSExecuteBatchStatementReq(sessionHandle, batchSQLList); + TSExecuteBatchStatementResp execResp = client.ExecuteBatchStatement(execReq); + Utils.verifySuccess(execResp.getStatus()); + if (execResp.getResult() == null){ + return new int[0]; + } + else{ + List result = execResp.getResult(); + int len = result.size(); + int[] updateArray = new int[len]; + for(int i = 0; i < len; i++){ + updateArray[i] = result.get(i); + } + return updateArray; + } + + } catch (TException e) { + throw new TsfileSQLException(String.format("Fail to execute sqls in batch when connecting to server because %s",e.getMessage())); + } + + } + + @Override + public ResultSet executeQuery(String sql) throws SQLException { + checkConnection("execute"); + try { + isCancelled = false; + TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql); + TSExecuteStatementResp execResp = client.ExecuteQueryStatement(execReq); + operationHandle = execResp.getOperationHandle(); + Utils.verifySuccess(execResp.getStatus()); + resultSet = new TsfileQueryResultSet(this,execResp.getColumns(), client,sessionHandle,operationHandle, sql); + } catch (TException e) { + throw new TsfileSQLException(String.format("Fail to execute query sql %s when connecting to server because %s",sql,e.getMessage())); + } + return resultSet; + } + + @Override + public int executeUpdate(String sql) throws SQLException { + try { + TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql); + TSExecuteStatementResp execResp = client.ExecuteUpdateStatement(execReq); + operationHandle = execResp.getOperationHandle(); + Utils.verifySuccess(execResp.getStatus()); + } catch (TException e) { + throw new TsfileSQLException(String.format("Fail to execute update sql %s when connecting to server because %s",sql,e.getMessage())); + } + return 0; + } + + @Override + public int executeUpdate(String arg0, int arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int executeUpdate(String arg0, int[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int executeUpdate(String arg0, String[] arg1) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public Connection getConnection() throws SQLException { + return connection; + } + + @Override + public int getFetchDirection() throws SQLException { + checkConnection("getFetchDirection"); + return ResultSet.FETCH_FORWARD; + } + + @Override + public int getFetchSize() throws SQLException { + checkConnection("getFetchSize"); + return fetchSize; + } + + @Override + public ResultSet getGeneratedKeys() throws SQLException { + throw new SQLFeatureNotSupportedException("Method not supported"); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getMaxRows() throws SQLException { + checkConnection("getMaxRows"); + return maxRows; + } + + @Override + public boolean getMoreResults() throws SQLException { + return false; + } + + @Override + public boolean getMoreResults(int arg0) throws SQLException { + throw new SQLFeatureNotSupportedException("Method not supported"); + } + + @Override + public int getQueryTimeout() throws SQLException { + return this.queryTimeout; + } + + @Override + public ResultSet getResultSet() throws SQLException { + checkConnection("getResultSet"); + return resultSet; + } + + @Override + public int getResultSetConcurrency() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getResultSetHoldability() throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public int getResultSetType() throws SQLException { + checkConnection("getResultSetType"); + return ResultSet.TYPE_FORWARD_ONLY; + } + + @Override + public int getUpdateCount() throws SQLException { + return 0; + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return warningChain; + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + return false; + } + + @Override + public boolean isClosed() throws SQLException { + return isClosed; + } + + @Override + public boolean isPoolable() throws SQLException { + return false; + } + + @Override + public void setCursorName(String arg0) throws SQLException { + throw new SQLFeatureNotSupportedException("Method not supported"); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new SQLFeatureNotSupportedException("Method not supported"); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + checkConnection("setFetchDirection"); + if (direction != ResultSet.FETCH_FORWARD) { + throw new SQLException(String.format("direction %d is not supported!", direction)); + } + } + + @Override + public void setFetchSize(int fetchSize) throws SQLException { + checkConnection("setFetchSize"); + if (fetchSize < 0) { + throw new SQLException(String.format("fetchSize %d must be >= 0!", fetchSize)); + } + this.fetchSize = fetchSize == 0 ? TsfileConfig.DEFAULT_FETCH_SIZE : fetchSize; + } + + @Override + public void setMaxFieldSize(int arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setMaxRows(int num) throws SQLException { + checkConnection("setMaxRows"); + if (num < 0) { + throw new SQLException(String.format("maxRows %d must be >= 0!", num)); + } + this.maxRows = num; + } + + @Override + public void setPoolable(boolean arg0) throws SQLException { + throw new SQLException("Method not supported"); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + checkConnection("setQueryTimeout"); + if (seconds <= 0) { + throw new SQLException(String.format("queryTimeout %d must be >= 0!", seconds)); + } + this.queryTimeout = seconds; + } + + private void checkConnection(String action) throws SQLException { + if (isClosed) { + throw new SQLException(String.format("Cannot %s after statement has been closed!", action)); + } + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileURLException.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileURLException.java new file mode 100644 index 00000000000..1faa75bc05d --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/TsfileURLException.java @@ -0,0 +1,15 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.sql.SQLException; + +public class TsfileURLException extends SQLException{ + + /** + * + */ + private static final long serialVersionUID = -5071922897222027267L; + + public TsfileURLException(String reason){ + super(reason); + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/jdbc/Utils.java b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Utils.java new file mode 100644 index 00000000000..fcd7a9a56ac --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/jdbc/Utils.java @@ -0,0 +1,162 @@ +package cn.edu.thu.tsfiledb.jdbc; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import cn.edu.thu.tsfile.common.utils.Binary; +import cn.edu.thu.tsfile.file.metadata.enums.TSDataType; +import cn.edu.thu.tsfile.file.metadata.enums.TSEncoding; +import cn.edu.thu.tsfile.timeseries.read.query.DynamicOneColumnData; +import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet; +import cn.edu.thu.tsfiledb.metadata.ColumnSchema; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSColumnSchema; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSDynamicOneColumnData; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_Status; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode; + + + + +public class Utils { + + /** + * Parse JDBC connection URL The only supported format of the URL is: + * jdbc:tsfile://localhost:8888/seriesName + * + * @param url + * @return + * @throws TsfileURLException + */ + public static TsfileConnectionParams parseURL(String url, Properties info) throws TsfileURLException { + TsfileConnectionParams params = new TsfileConnectionParams(url); + if(url.trim().equalsIgnoreCase(TsfileConfig.TSFILE_URL_PREFIX)){ + return params; + } + + Pattern pattern = Pattern.compile("([^;]*):([^;]*)/"); + Matcher matcher = pattern.matcher(url.substring(TsfileConfig.TSFILE_URL_PREFIX.length())); + boolean isUrlLegal = false; + while(matcher.find()){ + params.setHost(matcher.group(1)); + params.setPort(Integer.parseInt((matcher.group(2)))); + isUrlLegal = true; + } + if(!isUrlLegal){ + throw new TsfileURLException("Error url format, url should be jdbc:tsfile://ip:port/"); + } + + if(info.containsKey(TsfileConfig.AUTH_USER)){ + params.setUsername(info.getProperty(TsfileConfig.AUTH_USER)); + } + if(info.containsKey(TsfileConfig.AUTH_PASSWORD)){ + params.setPassword(info.getProperty(TsfileConfig.AUTH_PASSWORD)); + } + + return params; + } + + public static void verifySuccess(TS_Status status) throws TsfileSQLException{ + if(status.getStatusCode() != TS_StatusCode.SUCCESS_STATUS){ + throw new TsfileSQLException(status.errorMessage); + } + } + + public static Map> convertAllSchema(Map> tsAllSchema){ + if(tsAllSchema == null){ + return null; + } + Map> allSchema = new HashMap<>(); + for(Map.Entry> entry : tsAllSchema.entrySet()){ + List columnSchemas = new ArrayList<>(); + for(TSColumnSchema columnSchema : entry.getValue()){ + columnSchemas.add(convertColumnSchema(columnSchema)); + } + allSchema.put(entry.getKey(), columnSchemas); + } + return allSchema; + } + + public static ColumnSchema convertColumnSchema(TSColumnSchema tsSchema){ + if(tsSchema == null){ + return null; + } + TSDataType dataType = tsSchema.dataType == null ? null : TSDataType.valueOf(tsSchema.dataType); + TSEncoding encoding = tsSchema.encoding == null ? null : TSEncoding.valueOf(tsSchema.encoding); + ColumnSchema ColumnSchema = new ColumnSchema(tsSchema.name, dataType, encoding); + ColumnSchema.setArgsMap(tsSchema.getOtherArgs()); + return ColumnSchema; + } + + public static QueryDataSet convertQueryDataSet(TSQueryDataSet tsQueryDataSet){ + QueryDataSet queryDataSet = new QueryDataSet(); + List keys = tsQueryDataSet.getKeys(); + List values = tsQueryDataSet.getValues(); + + LinkedHashMap ret = new LinkedHashMap<>(); + int length = keys.size(); + for(int i = 0; i < length;i++){ + ret.put(keys.get(i), convertDynamicOneColumnData(values.get(i))); + } + queryDataSet.mapRet = ret; + return queryDataSet; + } + + public static DynamicOneColumnData convertDynamicOneColumnData(TSDynamicOneColumnData tsDynamicOneColumnData){ + TSDataType dataType = TSDataType.valueOf(tsDynamicOneColumnData.getDataType()); + DynamicOneColumnData dynamicOneColumnData = new DynamicOneColumnData(dataType,true); + dynamicOneColumnData.setDeltaObjectType(tsDynamicOneColumnData.getDeviceType()); + + for(long time : tsDynamicOneColumnData.getTimeRet()){ + dynamicOneColumnData.putTime(time); + } + + switch (dataType) { + case BOOLEAN: + List booleans = tsDynamicOneColumnData.getBoolList(); + for(Boolean b: booleans){ + dynamicOneColumnData.putBoolean(b); + } + break; + case INT32: + List integers = tsDynamicOneColumnData.getI32List(); + for(Integer i: integers){ + dynamicOneColumnData.putInt(i); + } + break; + case INT64: + List longs = tsDynamicOneColumnData.getI64List(); + for(Long l: longs){ + dynamicOneColumnData.putLong(l); + } + break; + case FLOAT: + List floats = tsDynamicOneColumnData.getFloatList(); + for(double f: floats){ + dynamicOneColumnData.putFloat((float)f); + } + break; + case DOUBLE: + List doubles = tsDynamicOneColumnData.getDoubleList(); + for(double d: doubles){ + dynamicOneColumnData.putDouble(d); + } + break; + case BYTE_ARRAY: + List binaries = tsDynamicOneColumnData.getBinaryList(); + for(Byte b: binaries){ + dynamicOneColumnData.putBinary(new Binary(b.toString())); + } + break; + default: + break; + } + return dynamicOneColumnData; + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/AuthorityChecker.java b/src/main/java/cn/edu/thu/tsfiledb/service/AuthorityChecker.java new file mode 100644 index 00000000000..fc98be7bd8e --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/AuthorityChecker.java @@ -0,0 +1,102 @@ +package cn.edu.thu.tsfiledb.service; + +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cn.edu.thu.tsfile.timeseries.read.qp.Path; +import cn.edu.thu.tsfiledb.auth.dao.Authorizer; +import cn.edu.thu.tsfiledb.auth.model.Permission; + +public class AuthorityChecker { + + public static final String SUPER_USER = "root"; + private static final Logger logger = LoggerFactory.getLogger(AuthorityChecker.class); + + public static boolean check(String username, List paths, OperatorType type){ + if(SUPER_USER.equals(username)){ + return true; + } + int permission = translateToPermissionId(type); + if(permission == -1){ + logger.error("OperateType not found. {}", type); + return false; + } + for(int i = 0 ; i < paths.size() ; i ++){ + if(!checkOnePath(username, paths.get(i), permission)){ + return false; + } + } + return true; + } + + public static List getAllParentPath(Path path){ + List parentPaths = new ArrayList(); + String fullPath = path.getFullPath(); + String[] nodes = fullPath.split("\\."); + + for(int i = 0 ; i < nodes.length ; i++){ + StringBuilder sb = new StringBuilder(); + for(int j = 0 ; j <= i ; j++){ + sb.append(nodes[j]); + if(j < i){ + sb.append("."); + } + } + parentPaths.add(sb.toString()); + } + return parentPaths; + } + + public static boolean checkOnePath(String username, Path path, int permission){ + List parentPaths = getAllParentPath(path); + for(int i = 0 ; i < parentPaths.size(); i ++){ + if(Authorizer.checkUserPermission(username, parentPaths.get(i), permission)){ + return true; + } + } + return false; + } + + public static int translateToPermissionId(OperatorType type){ + switch(type){ + case METADATA: + return Permission.CREATE; + case QUERY: + case SELECT: + case FILTER: + case GROUPBY: + case SEQTABLESCAN: + case TABLESCAN: + return Permission.READ; + case DELETE: + return Permission.DELETE; + case INSERT: + case LOADDATA: + return Permission.INSERT; + case UPDATE: + return Permission.MODIFY; + case AUTHOR: + case BASIC_FUNC: + case FILEREAD: + case FROM: + case FUNC: + case HASHTABLESCAN: + case JOIN: + case LIMIT: + case MERGEJOIN: + case NULL: + case ORDERBY: + case PROPERTY: + case ROOT: + case UNION: + + return -1; + default: + return -1; + } + + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/Daemon.java b/src/main/java/cn/edu/thu/tsfiledb/service/Daemon.java new file mode 100644 index 00000000000..ff011e5e75f --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/Daemon.java @@ -0,0 +1,54 @@ +package cn.edu.thu.tsfiledb.service; + +import java.io.IOException; + +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TBinaryProtocol.Factory; +import org.apache.thrift.server.TServer; +import org.apache.thrift.server.TThreadPoolServer; +import org.apache.thrift.transport.TServerSocket; +import org.apache.thrift.transport.TTransportException; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService.Processor; + + +public class Daemon { + + public static void main(String[] args) { + //init Derby Database + DBdao dBdao = new DBdao(); + dBdao.open(); + + startRPC(); + } + + public static TServer startRPC() { + try { + // 设置服务器端口 + TServerSocket serverTransport = new TServerSocket(JDBCServerConfig.PORT); + // 设置二进制协议工厂 + Factory protocolFactory = new TBinaryProtocol.Factory(); + //处理器关联业务实现 + Processor processor = new TSIService.Processor(new TSServiceImpl()); + // 2. 使用线程池服务模型 + TThreadPoolServer.Args poolArgs = new TThreadPoolServer.Args(serverTransport); + poolArgs.processor(processor); + poolArgs.protocolFactory(protocolFactory); + TServer poolServer = new TThreadPoolServer(poolArgs); + poolServer.serve(); + + } catch (TTransportException e) { + + e.printStackTrace(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServer.java b/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServer.java new file mode 100644 index 00000000000..8be12c24c9a --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServer.java @@ -0,0 +1,155 @@ +package cn.edu.thu.tsfiledb.service; + +import java.io.IOException; + +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TBinaryProtocol.Factory; +import org.apache.thrift.server.TServer; +import org.apache.thrift.server.TThreadPoolServer; +import org.apache.thrift.transport.TServerSocket; +import org.apache.thrift.transport.TTransportException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.engine.exception.FileNodeManagerException; +import cn.edu.thu.tsfiledb.engine.exception.LRUManagerException; +import cn.edu.thu.tsfiledb.engine.filenode.FileNodeManager; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService.Processor; + + + +public class JDBCServer implements JDBCServerMBean { + private static final Logger LOGGER = LoggerFactory.getLogger(JDBCServer.class); + private DBdao dBdao; + private Thread jdbcServerThread; + private boolean isStart; + + private Factory protocolFactory; + private Processor processor; + private TServerSocket serverTransport; + private TThreadPoolServer.Args poolArgs; + private TServer poolServer; + + private boolean isMerging; + + public JDBCServer() throws TTransportException { + isStart = false; + isMerging = false; + } + + @Override + public synchronized void startServer() { + if(isStart){ + LOGGER.info("tsfile-service JDBCServer: jdbc server has been already running now"); + return; + } + LOGGER.info("tsfile-service JDBCServer: starting jdbc server..."); + dBdao = new DBdao(); + dBdao.open(); + + try { + jdbcServerThread = new Thread(new JDBCServerThread()); + } catch (IOException e) { + LOGGER.error("Server start Error. {}", e.getMessage()); + e.printStackTrace(); + return; + } + jdbcServerThread.start(); + + LOGGER.info("tsfile-service JDBCServer: start jdbc server successfully"); + isStart = true; + + } + + @Override + public synchronized void restartServer() { + stopServer(); + startServer(); + } + + @Override + public synchronized void stopServer() { + if(!isStart){ + LOGGER.info("tsfile-service JDBCServer: jdbc server isn't running now"); + return; + } + + LOGGER.info("tsfile-service JDBCServer: closing jdbc server..."); + + if(dBdao != null){ + dBdao.close(); + dBdao = null; + } + + LOGGER.info("tsfile-service JDBCServer: flush data in memory to disk"); + try { + FileNodeManager.getInstance().close(); + } catch (LRUManagerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + close(); + LOGGER.info("tsfile-service JDBCServer: close jdbc server successfully"); + } + + private void close(){ + if(poolServer != null){ + poolServer.stop(); + poolServer = null; + } + + if(serverTransport != null){ + serverTransport.close(); + serverTransport = null; + } + isStart = false; + } + + class JDBCServerThread implements Runnable{ + + public JDBCServerThread() throws IOException{ + protocolFactory = new TBinaryProtocol.Factory(); + processor = new TSIService.Processor(new TSServiceImpl()); + } + + @Override + public void run() { + try { + serverTransport = new TServerSocket(JDBCServerConfig.PORT); + poolArgs = new TThreadPoolServer.Args(serverTransport); + poolArgs.processor(processor); + poolArgs.protocolFactory(protocolFactory); + poolServer = new TThreadPoolServer(poolArgs); + // poolServer.serve(); will block next statement to execute + poolServer.serve(); + } catch (TTransportException e) { + LOGGER.error("tsfile-service JDBCServer: failed to start jdbc server, because ", e); + } catch (Exception e) { + LOGGER.error("tsfile-service JDBCServer: jdbc server exit, because ", e); + } finally { + close(); + LOGGER.info("tsfile-service JDBCServer: close TThreadPoolServer and TServerSocket"); + } + } + } + + public static void main(String[] args) throws TTransportException, InterruptedException{ + JDBCServer server = new JDBCServer(); + server.startServer(); + } + + @Override + public synchronized void mergeAll() { + LOGGER.info("tsfile-service JDBCServer : start merging.."); + try { + FileNodeManager.getInstance().mergeAll(); + } catch (FileNodeManagerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + LOGGER.info("tsfile-service JDBCServer : Done."); + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServerConfig.java b/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServerConfig.java new file mode 100644 index 00000000000..5eb340c982c --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServerConfig.java @@ -0,0 +1,16 @@ +package cn.edu.thu.tsfiledb.service; + +public class JDBCServerConfig { + public static final int PORT = 6667; + +// public static final String TSFILE_DATA_PATH = "writeV2Huge.out"; + + public static final String overflowErrOutput = "overflowErrOutput"; + public static final String overflowOutput = "overflowOutput"; + + public static final String JMX_IP = "0.0.0.0"; + public static final int JMX_PORT = 31999; + public static final String JMX_USER = "saf"; + public static final String JMX_PASS = "pass"; + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServerMBean.java b/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServerMBean.java new file mode 100644 index 00000000000..d5f6447b010 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/JDBCServerMBean.java @@ -0,0 +1,9 @@ +package cn.edu.thu.tsfiledb.service; + + +public interface JDBCServerMBean { + public void startServer(); + public void restartServer(); + public void stopServer(); + public void mergeAll(); +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/JMXManager.java b/src/main/java/cn/edu/thu/tsfiledb/service/JMXManager.java new file mode 100644 index 00000000000..643cb677545 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/JMXManager.java @@ -0,0 +1,115 @@ +package cn.edu.thu.tsfiledb.service; + +import java.io.File; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.rmi.registry.LocateRegistry; +import java.rmi.server.RMISocketFactory; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.management.InstanceAlreadyExistsException; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.NotCompliantMBeanException; +import javax.management.ObjectName; +import javax.management.remote.JMXAuthenticator; +import javax.management.remote.JMXConnectorServer; +import javax.management.remote.JMXConnectorServerFactory; +import javax.management.remote.JMXPrincipal; +import javax.management.remote.JMXServiceURL; +import javax.management.remote.rmi.RMIConnectorServer; +import javax.security.auth.Subject; + +import org.apache.thrift.transport.TTransportException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.core.joran.spi.JoranException; +import cn.edu.thu.tsfile.common.constant.SystemConstant; + +public class JMXManager { + + static{ + try { + String home = System.getProperty(SystemConstant.TSFILE_HOME); + if(home != null && !home.equals("")){ + LogBackConfigLoader.load(home + File.separator + "conf" + File.separator + "logback.xml"); + } + } catch (IOException | JoranException e) { + System.out.println("Load configuration file error"); + e.printStackTrace(); + } + } + + private static final Logger LOGGER = LoggerFactory.getLogger(JMXManager.class); + + private JMXConnectorServer connector; + private Map jmxEnvironment; + + public JMXManager() { + jmxEnvironment = new HashMap(); + } + + public void serice() throws IOException, TTransportException, MalformedObjectNameException, + InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + String addr = String.format("service:jmx:rmi://%s:%d/jndi/rmi://%s:%d/jmxrmi", JDBCServerConfig.JMX_IP, + JDBCServerConfig.JMX_PORT, JDBCServerConfig.JMX_IP, JDBCServerConfig.JMX_PORT); + JMXServiceURL address = new JMXServiceURL(addr); + + RMISocketFactory rmiFactory = RMISocketFactory.getDefaultSocketFactory(); + LocateRegistry.createRegistry(JDBCServerConfig.JMX_PORT, null, rmiFactory); + + jmxEnvironment.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rmiFactory); + + // for auth + JMXAuthenticator auth = createJMXAuthenticator(); + jmxEnvironment.put(JMXConnectorServer.AUTHENTICATOR, auth); + + connector = JMXConnectorServerFactory.newJMXConnectorServer(address, jmxEnvironment, + ManagementFactory.getPlatformMBeanServer()); + JDBCServerMBean mbean = new JDBCServer(); + mbean.startServer(); + ObjectName mBeanName = new ObjectName("JDBCServerDomain", "type", "JDBCServer"); + mbs.registerMBean(mbean, mBeanName); + connector.start(); + LOGGER.info("tsfile-service JMXManager: start JMX manager..."); + } + + public void close() throws IOException { + connector.stop(); + LOGGER.info("tsfile-service JMXManager: close JMX manager..."); + } + + private JMXAuthenticator createJMXAuthenticator() { + return new JMXAuthenticator() { + public Subject authenticate(Object credentials) { + String[] sCredentials = (String[]) credentials; + if (null == sCredentials || sCredentials.length != 2) { + LOGGER.error("tsfile-service JMXManager: auth info in wrong format!"); + throw new SecurityException("Authentication failed!"); + } + String userName = sCredentials[0]; + String pValue = sCredentials[1]; + if (JDBCServerConfig.JMX_USER.equals(userName) && JDBCServerConfig.JMX_PASS.equals(pValue)) { + Set principals = new HashSet(); + principals.add(new JMXPrincipal(userName)); + return new Subject(true, principals, Collections.EMPTY_SET, Collections.EMPTY_SET); + } + LOGGER.error("tsfile-service JMXManager: Authentication failed!"); + throw new SecurityException("Authentication failed!"); + } + }; + } + + public static void main(String[] args) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, TTransportException, IOException { + JMXManager manager = new JMXManager(); + manager.serice(); + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/LogBackConfigLoader.java b/src/main/java/cn/edu/thu/tsfiledb/service/LogBackConfigLoader.java new file mode 100644 index 00000000000..04b089be268 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/LogBackConfigLoader.java @@ -0,0 +1,46 @@ +package cn.edu.thu.tsfiledb.service; + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +import java.io.File; +import java.io.IOException; + +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.util.StatusPrinter; + +/** + * Simple Utility class for loading an external config file for logback + * @author daniel + */ +public class LogBackConfigLoader { + + public static void load (String externalConfigFileLocation) throws IOException, JoranException{ + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + + File externalConfigFile = new File(externalConfigFileLocation); + if(!externalConfigFile.exists()){ + throw new IOException("Logback External Config File Parameter does not reference a file that exists"); + }else{ + if(!externalConfigFile.isFile()){ + throw new IOException("Logback External Config File Parameter exists, but does not reference a file"); + }else{ + if(!externalConfigFile.canRead()){ + throw new IOException("Logback External Config File exists and is a file, but cannot be read."); + }else{ + JoranConfigurator configurator = new JoranConfigurator(); + configurator.setContext(lc); + lc.reset(); + configurator.doConfigure(externalConfigFileLocation); + StatusPrinter.printInCaseOfErrorsOrWarnings(lc); + } + } + } + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/TSServiceImpl.java b/src/main/java/cn/edu/thu/tsfiledb/service/TSServiceImpl.java new file mode 100644 index 00000000000..8b8d1af9754 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/TSServiceImpl.java @@ -0,0 +1,662 @@ +package cn.edu.thu.tsfiledb.service; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cn.edu.thu.tsfile.common.exception.ProcessorException; +import cn.edu.thu.tsfile.file.metadata.enums.TSDataType; +import cn.edu.thu.tsfile.timeseries.read.qp.Path; +import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet; +import cn.edu.thu.tsfiledb.auth.dao.Authorizer; +import cn.edu.thu.tsfiledb.auth.model.AuthException; +import cn.edu.thu.tsfiledb.engine.filenode.FileNodeManager; +import cn.edu.thu.tsfiledb.exception.NotConsistentException; +import cn.edu.thu.tsfiledb.exception.PathErrorException; +import cn.edu.thu.tsfiledb.metadata.ColumnSchema; +import cn.edu.thu.tsfiledb.metadata.MManager; +import cn.edu.thu.tsfiledb.metadata.Metadata; +import cn.edu.thu.tsfiledb.query.aggregation.AggreFuncFactory; +import cn.edu.thu.tsfiledb.query.aggregation.AggregateFunction; +import cn.edu.thu.tsfiledb.query.engine.OverflowQueryEngine; +import cn.edu.thu.tsfiledb.query.management.ReadLockManager; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSColumnSchema; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSHandleIdentifier; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionReq; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionResp; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_Status; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;; + +public class TSServiceImpl implements TSIService.Iface { + + private WriteLogManager writeLogManager; + private OverflowQPExecutor exec = new OverflowQPExecutor(); + // Record the username for every rpc connection. Username.get() is null if + // login is failed. + private ThreadLocal username = new ThreadLocal<>(); + private ThreadLocal> queryStatus = new ThreadLocal<>(); + private ThreadLocal>> queryRet = new ThreadLocal<>(); + + private static final Logger LOGGER = LoggerFactory.getLogger(TSServiceImpl.class); + + public TSServiceImpl() throws IOException { + LOGGER.info("start check write log..."); + writeLogManager = WriteLogManager.getInstance(); + long cnt = 0l; + PhysicalPlan plan; + while ((plan = writeLogManager.getPhysicalPlan()) != null) { + try { + plan.processNonQuery(exec); + cnt++; + } catch (ProcessorException e) { + e.printStackTrace(); + throw new IOException("Error in recovery from write log"); + } + } + LOGGER.info("Done. Recover operation count {}", cnt); + } + + @Override + public TSOpenSessionResp OpenSession(TSOpenSessionReq req) throws TException { + + if (LOGGER.isInfoEnabled()) + LOGGER.info("tsfile-server TSServiceImpl: receive open session from username {}", req.getUsername()); + + boolean status = false; + try { + status = Authorizer.login(req.getUsername(), req.getPassword()); + } catch (AuthException e) { + status = false; + } + // boolean status = true; + TS_Status ts_status; + if (status) { + ts_status = new TS_Status(TS_StatusCode.SUCCESS_STATUS); + ts_status.setErrorMessage("login successfully."); + username.set(req.getUsername()); + initForOneSession(); + } else { + ts_status = new TS_Status(TS_StatusCode.ERROR_STATUS); + ts_status.setErrorMessage("login failed. Username or password is wrong."); + } + TSOpenSessionResp resp = new TSOpenSessionResp(ts_status, TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1); + resp.setSessionHandle(new TS_SessionHandle(new TSHandleIdentifier(ByteBuffer.wrap(req.getUsername().getBytes()), + ByteBuffer.wrap((req.getPassword().getBytes()))))); + if (LOGGER.isInfoEnabled()) + LOGGER.info("tsfile-server TSServiceImpl: Login status: {}. User : {}", ts_status.getErrorMessage(), + req.getUsername()); + + return resp; + } + + private void initForOneSession() { + queryStatus.set(new HashMap()); + queryRet.set(new HashMap>()); + } + + @Override + public TSCloseSessionResp CloseSession(TSCloseSessionReq req) throws TException { + if (LOGGER.isInfoEnabled()) + LOGGER.info("tsfile-server TSServiceImpl: receive close session"); + TS_Status ts_status; + if (username.get() == null) { + ts_status = new TS_Status(TS_StatusCode.ERROR_STATUS); + ts_status.setErrorMessage("Has not logged in"); + } else { + ts_status = new TS_Status(TS_StatusCode.SUCCESS_STATUS); + username.remove(); + } + return new TSCloseSessionResp(ts_status); + } + + @Override + // TODO: 这个方法啥意思? + public TSCancelOperationResp CancelOperation(TSCancelOperationReq req) throws TException { + if (LOGGER.isInfoEnabled()) + LOGGER.info("tsfile-server TSServiceImpl: receive cancle operation"); + return new TSCancelOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS)); + } + + @Override + public TSCloseOperationResp CloseOperation(TSCloseOperationReq req) throws TException { + if (LOGGER.isInfoEnabled()) + LOGGER.info("tsfile-server TSServiceImpl: receive statement close operation"); + try { + ReadLockManager.getInstance().unlockForOneRequest(); + clearAllStatusForCurrentRequest(); + } catch (NotConsistentException e) { + LOGGER.warn("Warning in closeOperation : {}", e.getMessage()); + // e.printStackTrace(); + } catch (ProcessorException e) { + // TODO Auto-generated catch block + LOGGER.error("Error in closeOperation : {}", e.getMessage()); + e.printStackTrace(); + } + return new TSCloseOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS)); + } + + public void clearAllStatusForCurrentRequest() { + this.queryRet.get().clear(); + this.queryStatus.get().clear(); + // Clear all parameters in last request. + exec.clearParamter(); + } + + @Override + public TSFetchMetadataResp FetchMetadata(TSFetchMetadataReq req) throws TException { + LOGGER.info("tsfile-server FetchMetadata: Receive fetch metadata operation"); + TS_Status status; + if (!checkLogin()) { + LOGGER.info("tsfile-server ExecuteStatement: Not login."); + status = new TS_Status(TS_StatusCode.ERROR_STATUS); + status.setErrorMessage("Not login"); + return new TSFetchMetadataResp(status); + } + TSFetchMetadataResp resp = new TSFetchMetadataResp(); + try { + Metadata metadata = MManager.getInstance().getMetadata(); + String metadataInJson = MManager.getInstance().getMetadataInString(); + Map> seriesMap = metadata.getSeriesMap(); + Map> tsSeriesMap = Utils.convertAllSchema(seriesMap); + resp.setSeriesMap(tsSeriesMap); + resp.setDeltaObjectMap(metadata.getDeltaObjectMap()); + resp.setMetadataInJson(metadataInJson); + status = new TS_Status(TS_StatusCode.SUCCESS_STATUS); + resp.setStatus(status); + } catch (PathErrorException e) { + LOGGER.error("tsfile-server FetchMetadata: failed to get all schema", e); + status = new TS_Status(TS_StatusCode.ERROR_STATUS); + status.setErrorMessage(e.getMessage()); + resp.setStatus(status); + resp.setSeriesMap(null); + resp.setDeltaObjectMap(null); + resp.setMetadataInJson(null); + } catch (Exception e) { + LOGGER.error("tsfile-server FetchMetadata: failed to get all schema with unknown reason", e); + status = new TS_Status(TS_StatusCode.ERROR_STATUS); + status.setErrorMessage(e.getMessage()); + resp.setStatus(status); + resp.setSeriesMap(null); + resp.setDeltaObjectMap(null); + resp.setMetadataInJson(null); + } + return resp; + } + + /** + * Judge whether the statement is ADMIN COMMOND and if true, execute it. + * + * @param statement + * @return true if the statement is ADMIN COMMOND + * @throws IOException + */ + public boolean execAdminCommond(String statement) throws IOException { + if (!username.get().equals("root")) { + return false; + } + if (statement == null) { + return false; + } + statement = statement.toLowerCase(); + switch (statement) { + case "close": + FileNodeManager.getInstance().closeAll(); + writeLogManager.overflowFlush(); + writeLogManager.bufferFlush(); + // MManager.getInstance().flushObjectToFile(); + return true; + case "merge": + FileNodeManager.getInstance().mergeAll(); + return true; + } + return false; + } + + /** + * 用来测试的函数,仅供测试,后面要删除 + * + * @param req + * @return + * @throws TException + */ + public TSExecuteStatementResp testExecute(TSExecuteStatementReq req) { + TSExecuteStatementResp resp = getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, ""); + String sql = req.statement; + String[] params = sql.substring(5).split(" "); + List columns = new ArrayList<>(); + columns.add(params[0] + "(" + params[1] + ")"); + TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()), + ByteBuffer.wrap(("PASS".getBytes()))); + TSOperationHandle operationHandle = null; + resp.setColumns(columns); + operationHandle = new TSOperationHandle(operationId, true); + resp.setOperationHandle(operationHandle); + recordANewQuery(sql, null); + return resp; + } + + @Override + public TSExecuteBatchStatementResp ExecuteBatchStatement(TSExecuteBatchStatementReq req) throws TException { + try { + LOGGER.info("tsfile-server ExecuteBatchStatement: Receive execute batch sql operation"); + if (!checkLogin()) { + LOGGER.info("tsfile-server ExecuteBatchStatement: Not login."); + return getTSBathcExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login", null); + } + List statements = req.getStatements(); + List result = new ArrayList<>(); + + TSqlParserV2 parser = new TSqlParserV2(); + ArrayList opList = new ArrayList<>(); + for (String statement : statements) { + RootOperator root = parser.parseSQLToOperator(statement); + if (root.isQuery()) { + return getTSBathcExecuteStatementResp(TS_StatusCode.ERROR_STATUS, + "statement is query :" + statement, result); + } + opList.add(root); + } + for (RootOperator op: opList) { + ExecuteUpdateStatement(op); + } + // TODO Auto-generated method stub + + return getTSBathcExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "Execute statements successfully", + result); + } catch (Exception e) { + LOGGER.error("tsfile-server ExecuteBatchStatement: error occurs when executing statements", e); + return getTSBathcExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage(), null); + } + + } + + @Override + public TSExecuteStatementResp ExecuteStatement(TSExecuteStatementReq req) throws TException { + try { + // 测试代码 + String sql = req.getStatement(); + if (sql != null && sql.startsWith("test:")) { + return testExecute(req); + } + // 测试代码(结束) + + LOGGER.info("tsfile-server ExecuteStatement: Receive execute sql operation,statement {}", req.statement); + if (!checkLogin()) { + LOGGER.info("tsfile-server ExecuteStatement: Not login."); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login"); + } + String statement = req.getStatement(); + + try { + if (execAdminCommond(statement)) { + return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "ADMIN_COMMOND_SUCCESS"); + } + } catch (Exception e) { + e.printStackTrace(); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Server Internal Error"); + } + + TSqlParserV2 parser = new TSqlParserV2(); + RootOperator root; + try { + root = parser.parseSQLToOperator(statement); + } catch (IllegalASTFormatException e) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, + "Statement is not right:" + e.getMessage()); + } catch (NullPointerException e) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement is not allowed"); + } + if (root.isQuery()) { + return ExecuteQueryStatement(req); + } else { + return ExecuteUpdateStatement(root); + } + } catch (Exception e) { + e.printStackTrace(); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + } + + @Override + public TSExecuteStatementResp ExecuteQueryStatement(TSExecuteStatementReq req) throws TException { + + try { + LOGGER.info("tsfile-server ExecuteQueryStatement: receive query sql operation,statement {}", req.statement); + if (!checkLogin()) { + LOGGER.info("tsfile-server ExecuteQueryStatement: Not login."); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login"); + } + + String statement = req.getStatement(); + TSqlParserV2 parser = new TSqlParserV2(); + RootOperator root = parser.parseSQLToOperator(statement); + + List paths = null; + // paths = ((SFWOperator) root).getSelSeriesPaths(exec); + PhysicalPlan plan = parser.parseSQLToPhysicalPlan(statement, exec); + paths = plan.getInvolvedSeriesPaths(); + + // check whether current statement is a query statement + if (!root.isQuery()) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement Error: Not a query statement"); + } + + // check path exists + if (paths.size() == 0) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Selected columns do NOT EXIST."); + } + + // check file level set + try { + MManager.getInstance().checkFileLevel(paths); + } catch (PathErrorException e) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + + // check permissions + if (!checkAuthorization(paths, root.getType())) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "No permissions for this query."); + } + + TSExecuteStatementResp resp = getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, ""); + List columns = new ArrayList<>(); + for (Path p : paths) { + columns.add(p.getFullPath()); + } + TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()), + ByteBuffer.wrap(("PASS".getBytes()))); + TSOperationHandle operationHandle = null; + resp.setColumns(columns); + operationHandle = new TSOperationHandle(operationId, true); + resp.setOperationHandle(operationHandle); + + recordANewQuery(statement, root); + + LOGGER.info("ExecuteQueryStatement: finish query statement {}", statement); + return resp; + } catch (Exception e) { + LOGGER.error("Server internal error: {}", e.getMessage()); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + } + + public TSFetchResultsResp testFetchResults(TSFetchResultsReq req) { + String sql = req.statement; + if (!queryStatus.get().containsKey(sql)) { + TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS, + "FetchResult successfully. Has more result: " + false); + resp.setHasResultSet(false); + return resp; + } + String[] params = sql.substring(5).split(" "); + TSDataType dataType; + try { + dataType = MManager.getInstance().getSeriesType(params[1]); + AggregateFunction aggrFunc = AggreFuncFactory.getAggrFuncByName(params[0], dataType); + Path p = new Path(params[1]); + QueryDataSet queryDataSet = new OverflowQueryEngine().aggregate(p, aggrFunc, null, null, null); + TSQueryDataSet tsQueryDataSet = Utils.convertQueryDataSet(queryDataSet); + + TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS, + "FetchResult successfully. Has more result: " + false); + resp.setHasResultSet(true); + resp.setQueryDataSet(tsQueryDataSet); + queryStatus.get().remove(sql); + return resp; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + + } + + @Override + public TSFetchResultsResp FetchResults(TSFetchResultsReq req) throws TException { + // 测试代码 + if (req.statement.startsWith("test:")) { + return testFetchResults(req); + } + // 测试代码(结束) + try { + if (!checkLogin()) { + return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Not login."); + } + String statement = req.getStatement(); + LOGGER.info("tsfile-server TSServiceImpl: receive fetch result sql operation,statement {}", statement); + + if (!queryStatus.get().containsKey(statement)) { + return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Has not executed statement"); + } + + int fetchSize = req.getFetch_size(); + Iterator queryDataSetIterator; + if (!queryRet.get().containsKey(statement)) { + TSqlParserV2 parser = new TSqlParserV2(); + RootOperator operator = queryStatus.get().get(statement); + exec.setFetchSize(fetchSize); + queryDataSetIterator = parser.query(operator, exec); + queryRet.get().put(statement, queryDataSetIterator); + } else { + queryDataSetIterator = queryRet.get().get(statement); + } + + boolean hasResultSet = false; + // TODO: 需要和徐毅确认res是否可以这么用 + QueryDataSet res = new QueryDataSet(); + if (queryDataSetIterator.hasNext()) { + res = queryDataSetIterator.next(); + hasResultSet = true; + } else { + hasResultSet = false; + queryRet.get().remove(statement); + } + TSQueryDataSet tsQueryDataSet = Utils.convertQueryDataSet(res); + + TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS, + "FetchResult successfully. Has more result: " + hasResultSet); + resp.setHasResultSet(hasResultSet); + resp.setQueryDataSet(tsQueryDataSet); + return resp; + } catch (Exception e) { + LOGGER.error("Server Internal Error: {}", e.getMessage()); + e.printStackTrace(); + return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Server Internal Error"); + } + + } + + @Override + public TSExecuteStatementResp ExecuteUpdateStatement(TSExecuteStatementReq req) throws TException { + try { + if (!checkLogin()) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login"); + } + String statement = req.getStatement(); + return ExecuteUpdateStatement(statement); + } catch (ProcessorException e) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + LOGGER.error(e.getMessage()); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + } + + private TSExecuteStatementResp ExecuteUpdateStatement(RootOperator root) throws TException { + try { + LOGGER.debug("ExecuteUpdateStatement: receive statement {}", root); + PhysicalPlan plan = root.transformToPhysicalPlan(exec); + List paths = plan.getInvolvedSeriesPaths(); + + if (!checkAuthorization(paths, root.getType())) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "No permissions for this operation"); + } + // TODO 是否要添加执行的信息而不是仅仅返回正确或者错误 + boolean execRet; + try { + execRet = plan.processNonQuery(exec); + } catch (ProcessorException e) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + if (execRet && needToBeWritenToLog(plan)) { + writeLogManager.write(plan); + } + TS_StatusCode statusCode = execRet ? TS_StatusCode.SUCCESS_STATUS : TS_StatusCode.ERROR_STATUS; + String msg = execRet ? "Execute successfully" : "Execute statement error."; + TSExecuteStatementResp resp = getTSExecuteStatementResp(statusCode, msg); + TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()), + ByteBuffer.wrap(("PASS".getBytes()))); + TSOperationHandle operationHandle = null; + operationHandle = new TSOperationHandle(operationId, false); + resp.setOperationHandle(operationHandle); + return resp; + } catch (QueryProcessorException e) { + LOGGER.error(e.getMessage()); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } catch (IOException e) { + LOGGER.error("Write preLog error", e); + return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "Write log error"); + } + } + + private TSExecuteStatementResp ExecuteUpdateStatement(String statement) + throws TException, QueryProcessorException, IOException, ProcessorException { + + LOGGER.info("ExecuteUpdateStatement: receive statement {}", statement); + TSqlParserV2 parser = new TSqlParserV2(); + RootOperator root; + + try { + root = parser.parseSQLToOperator(statement); + } catch (QueryProcessorException e) { + e.printStackTrace(); + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + if (root.isQuery()) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement is a query statement."); + } + + // 如果操作是增删改 + PhysicalPlan plan = parser.parseSQLToPhysicalPlan(statement, exec); + List paths = plan.getInvolvedSeriesPaths(); + + if (!checkAuthorization(paths, root.getType())) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "No permissions for this operation"); + } + + // TODO 是否要添加执行的信息而不是仅仅返回正确或者错误 + boolean execRet; + try { + execRet = parser.nonQuery(root, exec); + } catch (ProcessorException e) { + return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage()); + } + if (execRet && needToBeWritenToLog(plan)) { + writeLogManager.write(plan); + } + TS_StatusCode statusCode = execRet ? TS_StatusCode.SUCCESS_STATUS : TS_StatusCode.ERROR_STATUS; + String msg = execRet ? "Execute successfully" : "Execute statement error."; + TSExecuteStatementResp resp = getTSExecuteStatementResp(statusCode, msg); + TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()), + ByteBuffer.wrap(("PASS".getBytes()))); + TSOperationHandle operationHandle = null; + operationHandle = new TSOperationHandle(operationId, false); + resp.setOperationHandle(operationHandle); + return resp; + } + + private boolean needToBeWritenToLog(PhysicalPlan plan) { + if (plan.getOperatorType() == OperatorType.INSERT) { + return true; + } + if (plan.getOperatorType() == OperatorType.UPDATE) { + return true; + } + if (plan.getOperatorType() == OperatorType.DELETE) { + return true; + } + return false; + } + + private void recordANewQuery(String statement, RootOperator op) { + queryStatus.get().put(statement, op); + // refresh current queryRet for statement + if (queryRet.get().containsKey(statement)) { + queryRet.get().remove(statement); + } + } + + /** + * Check whether current user has logined. + * + * @return true: If logined; false: If not logined + */ + private boolean checkLogin() { + if (username.get() == null) { + return false; + } + return true; + } + + private boolean checkAuthorization(List paths, OperatorType type) { + return AuthorityChecker.check(username.get(), paths, type); + } + + private TSExecuteStatementResp getTSExecuteStatementResp(TS_StatusCode code, String msg) { + TSExecuteStatementResp resp = new TSExecuteStatementResp(); + TS_Status ts_status = new TS_Status(code); + ts_status.setErrorMessage(msg); + resp.setStatus(ts_status); + TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()), + ByteBuffer.wrap(("PASS".getBytes()))); + TSOperationHandle operationHandle = new TSOperationHandle(operationId, false); + resp.setOperationHandle(operationHandle); + return resp; + } + + private TSExecuteBatchStatementResp getTSBathcExecuteStatementResp(TS_StatusCode code, String msg, + List result) { + TSExecuteBatchStatementResp resp = new TSExecuteBatchStatementResp(); + TS_Status ts_status = new TS_Status(code); + ts_status.setErrorMessage(msg); + resp.setStatus(ts_status); + resp.setResult(result); + return resp; + } + + private TSFetchResultsResp getTSFetchResultsResp(TS_StatusCode code, String msg) { + TSFetchResultsResp resp = new TSFetchResultsResp(); + TS_Status ts_status = new TS_Status(code); + ts_status.setErrorMessage(msg); + resp.setStatus(ts_status); + return resp; + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/Utils.java b/src/main/java/cn/edu/thu/tsfiledb/service/Utils.java new file mode 100644 index 00000000000..f7ab5e04f90 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/Utils.java @@ -0,0 +1,129 @@ +package cn.edu.thu.tsfiledb.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.edu.thu.tsfile.timeseries.read.query.DynamicOneColumnData; +import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet; +import cn.edu.thu.tsfiledb.metadata.ColumnSchema; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSColumnSchema; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSDynamicOneColumnData; +import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet; + +public class Utils { + public static Map> convertAllSchema(Map> allSchema){ + if(allSchema == null){ + return null; + } + Map> tsAllSchema = new HashMap<>(); + for(Map.Entry> entry : allSchema.entrySet()){ + List tsColumnSchemas = new ArrayList<>(); + for(ColumnSchema columnSchema : entry.getValue()){ + tsColumnSchemas.add(convertColumnSchema(columnSchema)); + } + tsAllSchema.put(entry.getKey(), tsColumnSchemas); + } + return tsAllSchema; + } + + public static TSColumnSchema convertColumnSchema(ColumnSchema schema){ + if(schema == null){ + return null; + } + TSColumnSchema tsColumnSchema = new TSColumnSchema(); + tsColumnSchema.setName(schema.name); + tsColumnSchema.setDataType(schema.dataType == null ? null : schema.dataType.toString()); + tsColumnSchema.setEncoding(schema.encoding == null ? null : schema.encoding.toString()); + tsColumnSchema.setOtherArgs(schema.getArgsMap() == null ? null : schema.getArgsMap()); + return tsColumnSchema; + } + + + public static TSQueryDataSet convertQueryDataSet(QueryDataSet queryDataSet){ + List keys = new ArrayList<>(); + List values = new ArrayList<>(); + for(Map.Entry entry: queryDataSet.mapRet.entrySet()){ + keys.add(entry.getKey()); + values.add(convertDynamicOneColumnData(entry.getValue())); + } + TSQueryDataSet tsQueryDataSet = new TSQueryDataSet(keys,values); + return tsQueryDataSet; + } + + + public static TSDynamicOneColumnData convertDynamicOneColumnData(DynamicOneColumnData dynamicOneColumnData){ + List timeRetList = new ArrayList(); + for(int i = 0 ; i < dynamicOneColumnData.timeLength; i ++){ + timeRetList.add(dynamicOneColumnData.getTime(i)); + } + TSDynamicOneColumnData tsDynamicOneColumnData = new TSDynamicOneColumnData(dynamicOneColumnData.getDeltaObjectType(), dynamicOneColumnData.dataType.toString(), dynamicOneColumnData.length, timeRetList); + + switch (dynamicOneColumnData.dataType) { + case BOOLEAN: + List boolList = new ArrayList<>(); + for(int i = 0 ; i < dynamicOneColumnData.length; i ++){ + boolList.add(dynamicOneColumnData.getBoolean(i)); + } + tsDynamicOneColumnData.setBoolList(boolList); + break; + case INT32: + List intList = new ArrayList<>(); + for(int i = 0 ; i < dynamicOneColumnData.length; i ++){ + intList.add(dynamicOneColumnData.getInt(i)); + } + tsDynamicOneColumnData.setI32List(intList); + break; + case INT64: + List longList = new ArrayList<>(); + for(int i = 0 ; i < dynamicOneColumnData.length; i ++){ + longList.add(dynamicOneColumnData.getLong(i)); + } + tsDynamicOneColumnData.setI64List(longList); + break; + case FLOAT: + List floatList = new ArrayList<>(); + for(int i = 0 ; i < dynamicOneColumnData.length; i ++){ + floatList.add((double) dynamicOneColumnData.getFloat(i)); + } + tsDynamicOneColumnData.setFloatList(floatList); + break; + case DOUBLE: + List doubleList = new ArrayList<>(); + for(int i = 0 ; i < dynamicOneColumnData.length; i ++){ + doubleList.add(dynamicOneColumnData.getDouble(i)); + } + tsDynamicOneColumnData.setDoubleList(doubleList); + break; + case BYTE_ARRAY: + List byteList = new ArrayList<>(); + for(int i = 0 ; i < dynamicOneColumnData.length; i ++){ + byteList.add(Byte.valueOf(dynamicOneColumnData.getStringValue(i))); + } + tsDynamicOneColumnData.setBinaryList(byteList); + break; + default: + break; + } + + return tsDynamicOneColumnData; + } + +// public static TSJDBCRecord convertRecord(TSRecord record){ +// TSJDBCRecord tsJDBCRecord = new TSJDBCRecord(); +// tsJDBCRecord.setDeviceId(record.getRowKey()); +// tsJDBCRecord.setTimeValue(new TSTimeValue(record.getTime().getTime())); +// tsJDBCRecord.setDeviceType(record.getDeviceType()); +// List dataPoints = new ArrayList<>(); +// for(DataPoint point : record.getTuple()){ +// String valueStr = point.getValue() == null ? "null" : point.getValue(); +// TSDataPoint tsDataPoint = new TSDataPoint(point.getType().toString(),point.getSeriesName(),point.getDeviceId(),valueStr); +// tsDataPoint.setGroupId(point.getGroupId()); +// dataPoints.add(tsDataPoint); +// } +// tsJDBCRecord.setDataList(dataPoints); +// return tsJDBCRecord; +// } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCancelOperationReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCancelOperationReq.java new file mode 100644 index 00000000000..7bfe06b620d --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCancelOperationReq.java @@ -0,0 +1,393 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSCancelOperationReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCancelOperationReq"); + + private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSCancelOperationReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSCancelOperationReqTupleSchemeFactory()); + } + + public TSOperationHandle operationHandle; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + OPERATION_HANDLE((short)1, "operationHandle"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // OPERATION_HANDLE + return OPERATION_HANDLE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOperationHandle"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCancelOperationReq.class, metaDataMap); + } + + public TSCancelOperationReq() { + } + + public TSCancelOperationReq( + TSOperationHandle operationHandle) + { + this(); + this.operationHandle = operationHandle; + } + + /** + * Performs a deep copy on other. + */ + public TSCancelOperationReq(TSCancelOperationReq other) { + if (other.isSetOperationHandle()) { + this.operationHandle = other.operationHandle; + } + } + + public TSCancelOperationReq deepCopy() { + return new TSCancelOperationReq(this); + } + + @Override + public void clear() { + this.operationHandle = null; + } + + public TSOperationHandle getOperationHandle() { + return this.operationHandle; + } + + public TSCancelOperationReq setOperationHandle(TSOperationHandle operationHandle) { + this.operationHandle = operationHandle; + return this; + } + + public void unsetOperationHandle() { + this.operationHandle = null; + } + + /** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetOperationHandle() { + return this.operationHandle != null; + } + + public void setOperationHandleIsSet(boolean value) { + if (!value) { + this.operationHandle = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case OPERATION_HANDLE: + if (value == null) { + unsetOperationHandle(); + } else { + setOperationHandle((TSOperationHandle)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case OPERATION_HANDLE: + return getOperationHandle(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case OPERATION_HANDLE: + return isSetOperationHandle(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSCancelOperationReq) + return this.equals((TSCancelOperationReq)that); + return false; + } + + public boolean equals(TSCancelOperationReq that) { + if (that == null) + return false; + + boolean this_present_operationHandle = true && this.isSetOperationHandle(); + boolean that_present_operationHandle = true && that.isSetOperationHandle(); + if (this_present_operationHandle || that_present_operationHandle) { + if (!(this_present_operationHandle && that_present_operationHandle)) + return false; + if (!this.operationHandle.equals(that.operationHandle)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_operationHandle = true && (isSetOperationHandle()); + list.add(present_operationHandle); + if (present_operationHandle) + list.add(operationHandle); + + return list.hashCode(); + } + + @Override + public int compareTo(TSCancelOperationReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOperationHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSCancelOperationReq("); + boolean first = true; + + sb.append("operationHandle:"); + if (this.operationHandle == null) { + sb.append("null"); + } else { + sb.append(this.operationHandle); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (operationHandle == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationHandle' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSCancelOperationReqStandardSchemeFactory implements SchemeFactory { + public TSCancelOperationReqStandardScheme getScheme() { + return new TSCancelOperationReqStandardScheme(); + } + } + + private static class TSCancelOperationReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSCancelOperationReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // OPERATION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSCancelOperationReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.operationHandle != null) { + oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC); + struct.operationHandle.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSCancelOperationReqTupleSchemeFactory implements SchemeFactory { + public TSCancelOperationReqTupleScheme getScheme() { + return new TSCancelOperationReqTupleScheme(); + } + } + + private static class TSCancelOperationReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.operationHandle.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCancelOperationResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCancelOperationResp.java new file mode 100644 index 00000000000..59b5b421787 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCancelOperationResp.java @@ -0,0 +1,396 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSCancelOperationResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCancelOperationResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSCancelOperationRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSCancelOperationRespTupleSchemeFactory()); + } + + public TS_Status status; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCancelOperationResp.class, metaDataMap); + } + + public TSCancelOperationResp() { + } + + public TSCancelOperationResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSCancelOperationResp(TSCancelOperationResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + } + + public TSCancelOperationResp deepCopy() { + return new TSCancelOperationResp(this); + } + + @Override + public void clear() { + this.status = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSCancelOperationResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSCancelOperationResp) + return this.equals((TSCancelOperationResp)that); + return false; + } + + public boolean equals(TSCancelOperationResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + return list.hashCode(); + } + + @Override + public int compareTo(TSCancelOperationResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSCancelOperationResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSCancelOperationRespStandardSchemeFactory implements SchemeFactory { + public TSCancelOperationRespStandardScheme getScheme() { + return new TSCancelOperationRespStandardScheme(); + } + } + + private static class TSCancelOperationRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSCancelOperationResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSCancelOperationResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSCancelOperationRespTupleSchemeFactory implements SchemeFactory { + public TSCancelOperationRespTupleScheme getScheme() { + return new TSCancelOperationRespTupleScheme(); + } + } + + private static class TSCancelOperationRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseOperationReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseOperationReq.java new file mode 100644 index 00000000000..7a0682c0f2b --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseOperationReq.java @@ -0,0 +1,393 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSCloseOperationReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseOperationReq"); + + private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSCloseOperationReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSCloseOperationReqTupleSchemeFactory()); + } + + public TSOperationHandle operationHandle; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + OPERATION_HANDLE((short)1, "operationHandle"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // OPERATION_HANDLE + return OPERATION_HANDLE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOperationHandle"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseOperationReq.class, metaDataMap); + } + + public TSCloseOperationReq() { + } + + public TSCloseOperationReq( + TSOperationHandle operationHandle) + { + this(); + this.operationHandle = operationHandle; + } + + /** + * Performs a deep copy on other. + */ + public TSCloseOperationReq(TSCloseOperationReq other) { + if (other.isSetOperationHandle()) { + this.operationHandle = other.operationHandle; + } + } + + public TSCloseOperationReq deepCopy() { + return new TSCloseOperationReq(this); + } + + @Override + public void clear() { + this.operationHandle = null; + } + + public TSOperationHandle getOperationHandle() { + return this.operationHandle; + } + + public TSCloseOperationReq setOperationHandle(TSOperationHandle operationHandle) { + this.operationHandle = operationHandle; + return this; + } + + public void unsetOperationHandle() { + this.operationHandle = null; + } + + /** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetOperationHandle() { + return this.operationHandle != null; + } + + public void setOperationHandleIsSet(boolean value) { + if (!value) { + this.operationHandle = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case OPERATION_HANDLE: + if (value == null) { + unsetOperationHandle(); + } else { + setOperationHandle((TSOperationHandle)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case OPERATION_HANDLE: + return getOperationHandle(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case OPERATION_HANDLE: + return isSetOperationHandle(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSCloseOperationReq) + return this.equals((TSCloseOperationReq)that); + return false; + } + + public boolean equals(TSCloseOperationReq that) { + if (that == null) + return false; + + boolean this_present_operationHandle = true && this.isSetOperationHandle(); + boolean that_present_operationHandle = true && that.isSetOperationHandle(); + if (this_present_operationHandle || that_present_operationHandle) { + if (!(this_present_operationHandle && that_present_operationHandle)) + return false; + if (!this.operationHandle.equals(that.operationHandle)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_operationHandle = true && (isSetOperationHandle()); + list.add(present_operationHandle); + if (present_operationHandle) + list.add(operationHandle); + + return list.hashCode(); + } + + @Override + public int compareTo(TSCloseOperationReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOperationHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSCloseOperationReq("); + boolean first = true; + + sb.append("operationHandle:"); + if (this.operationHandle == null) { + sb.append("null"); + } else { + sb.append(this.operationHandle); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (operationHandle == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationHandle' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSCloseOperationReqStandardSchemeFactory implements SchemeFactory { + public TSCloseOperationReqStandardScheme getScheme() { + return new TSCloseOperationReqStandardScheme(); + } + } + + private static class TSCloseOperationReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseOperationReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // OPERATION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseOperationReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.operationHandle != null) { + oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC); + struct.operationHandle.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSCloseOperationReqTupleSchemeFactory implements SchemeFactory { + public TSCloseOperationReqTupleScheme getScheme() { + return new TSCloseOperationReqTupleScheme(); + } + } + + private static class TSCloseOperationReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.operationHandle.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseOperationResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseOperationResp.java new file mode 100644 index 00000000000..cb025b264f8 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseOperationResp.java @@ -0,0 +1,396 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSCloseOperationResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseOperationResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSCloseOperationRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSCloseOperationRespTupleSchemeFactory()); + } + + public TS_Status status; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseOperationResp.class, metaDataMap); + } + + public TSCloseOperationResp() { + } + + public TSCloseOperationResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSCloseOperationResp(TSCloseOperationResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + } + + public TSCloseOperationResp deepCopy() { + return new TSCloseOperationResp(this); + } + + @Override + public void clear() { + this.status = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSCloseOperationResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSCloseOperationResp) + return this.equals((TSCloseOperationResp)that); + return false; + } + + public boolean equals(TSCloseOperationResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + return list.hashCode(); + } + + @Override + public int compareTo(TSCloseOperationResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSCloseOperationResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSCloseOperationRespStandardSchemeFactory implements SchemeFactory { + public TSCloseOperationRespStandardScheme getScheme() { + return new TSCloseOperationRespStandardScheme(); + } + } + + private static class TSCloseOperationRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseOperationResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseOperationResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSCloseOperationRespTupleSchemeFactory implements SchemeFactory { + public TSCloseOperationRespTupleScheme getScheme() { + return new TSCloseOperationRespTupleScheme(); + } + } + + private static class TSCloseOperationRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseSessionReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseSessionReq.java new file mode 100644 index 00000000000..e5d8e5082c1 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseSessionReq.java @@ -0,0 +1,393 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSCloseSessionReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseSessionReq"); + + private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSCloseSessionReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSCloseSessionReqTupleSchemeFactory()); + } + + public TS_SessionHandle sessionHandle; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SESSION_HANDLE((short)1, "sessionHandle"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SESSION_HANDLE + return SESSION_HANDLE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TS_SessionHandle"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseSessionReq.class, metaDataMap); + } + + public TSCloseSessionReq() { + } + + public TSCloseSessionReq( + TS_SessionHandle sessionHandle) + { + this(); + this.sessionHandle = sessionHandle; + } + + /** + * Performs a deep copy on other. + */ + public TSCloseSessionReq(TSCloseSessionReq other) { + if (other.isSetSessionHandle()) { + this.sessionHandle = other.sessionHandle; + } + } + + public TSCloseSessionReq deepCopy() { + return new TSCloseSessionReq(this); + } + + @Override + public void clear() { + this.sessionHandle = null; + } + + public TS_SessionHandle getSessionHandle() { + return this.sessionHandle; + } + + public TSCloseSessionReq setSessionHandle(TS_SessionHandle sessionHandle) { + this.sessionHandle = sessionHandle; + return this; + } + + public void unsetSessionHandle() { + this.sessionHandle = null; + } + + /** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetSessionHandle() { + return this.sessionHandle != null; + } + + public void setSessionHandleIsSet(boolean value) { + if (!value) { + this.sessionHandle = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SESSION_HANDLE: + if (value == null) { + unsetSessionHandle(); + } else { + setSessionHandle((TS_SessionHandle)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SESSION_HANDLE: + return getSessionHandle(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SESSION_HANDLE: + return isSetSessionHandle(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSCloseSessionReq) + return this.equals((TSCloseSessionReq)that); + return false; + } + + public boolean equals(TSCloseSessionReq that) { + if (that == null) + return false; + + boolean this_present_sessionHandle = true && this.isSetSessionHandle(); + boolean that_present_sessionHandle = true && that.isSetSessionHandle(); + if (this_present_sessionHandle || that_present_sessionHandle) { + if (!(this_present_sessionHandle && that_present_sessionHandle)) + return false; + if (!this.sessionHandle.equals(that.sessionHandle)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_sessionHandle = true && (isSetSessionHandle()); + list.add(present_sessionHandle); + if (present_sessionHandle) + list.add(sessionHandle); + + return list.hashCode(); + } + + @Override + public int compareTo(TSCloseSessionReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSessionHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSCloseSessionReq("); + boolean first = true; + + sb.append("sessionHandle:"); + if (this.sessionHandle == null) { + sb.append("null"); + } else { + sb.append(this.sessionHandle); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (sessionHandle == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSCloseSessionReqStandardSchemeFactory implements SchemeFactory { + public TSCloseSessionReqStandardScheme getScheme() { + return new TSCloseSessionReqStandardScheme(); + } + } + + private static class TSCloseSessionReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseSessionReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SESSION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseSessionReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.sessionHandle != null) { + oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC); + struct.sessionHandle.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSCloseSessionReqTupleSchemeFactory implements SchemeFactory { + public TSCloseSessionReqTupleScheme getScheme() { + return new TSCloseSessionReqTupleScheme(); + } + } + + private static class TSCloseSessionReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.sessionHandle.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseSessionResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseSessionResp.java new file mode 100644 index 00000000000..18b0e1bf5ed --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSCloseSessionResp.java @@ -0,0 +1,396 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSCloseSessionResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseSessionResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSCloseSessionRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSCloseSessionRespTupleSchemeFactory()); + } + + public TS_Status status; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseSessionResp.class, metaDataMap); + } + + public TSCloseSessionResp() { + } + + public TSCloseSessionResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSCloseSessionResp(TSCloseSessionResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + } + + public TSCloseSessionResp deepCopy() { + return new TSCloseSessionResp(this); + } + + @Override + public void clear() { + this.status = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSCloseSessionResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSCloseSessionResp) + return this.equals((TSCloseSessionResp)that); + return false; + } + + public boolean equals(TSCloseSessionResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + return list.hashCode(); + } + + @Override + public int compareTo(TSCloseSessionResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSCloseSessionResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSCloseSessionRespStandardSchemeFactory implements SchemeFactory { + public TSCloseSessionRespStandardScheme getScheme() { + return new TSCloseSessionRespStandardScheme(); + } + } + + private static class TSCloseSessionRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseSessionResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseSessionResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSCloseSessionRespTupleSchemeFactory implements SchemeFactory { + public TSCloseSessionRespTupleScheme getScheme() { + return new TSCloseSessionRespTupleScheme(); + } + } + + private static class TSCloseSessionRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSColumnSchema.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSColumnSchema.java new file mode 100644 index 00000000000..6e5b5c0ec60 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSColumnSchema.java @@ -0,0 +1,769 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSColumnSchema implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSColumnSchema"); + + private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField DATA_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("dataType", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField ENCODING_FIELD_DESC = new org.apache.thrift.protocol.TField("encoding", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField OTHER_ARGS_FIELD_DESC = new org.apache.thrift.protocol.TField("otherArgs", org.apache.thrift.protocol.TType.MAP, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSColumnSchemaStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSColumnSchemaTupleSchemeFactory()); + } + + public String name; // optional + public String dataType; // optional + public String encoding; // optional + public Map otherArgs; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + NAME((short)1, "name"), + DATA_TYPE((short)2, "dataType"), + ENCODING((short)3, "encoding"), + OTHER_ARGS((short)4, "otherArgs"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // NAME + return NAME; + case 2: // DATA_TYPE + return DATA_TYPE; + case 3: // ENCODING + return ENCODING; + case 4: // OTHER_ARGS + return OTHER_ARGS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.NAME,_Fields.DATA_TYPE,_Fields.ENCODING,_Fields.OTHER_ARGS}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DATA_TYPE, new org.apache.thrift.meta_data.FieldMetaData("dataType", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.ENCODING, new org.apache.thrift.meta_data.FieldMetaData("encoding", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.OTHER_ARGS, new org.apache.thrift.meta_data.FieldMetaData("otherArgs", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSColumnSchema.class, metaDataMap); + } + + public TSColumnSchema() { + } + + /** + * Performs a deep copy on other. + */ + public TSColumnSchema(TSColumnSchema other) { + if (other.isSetName()) { + this.name = other.name; + } + if (other.isSetDataType()) { + this.dataType = other.dataType; + } + if (other.isSetEncoding()) { + this.encoding = other.encoding; + } + if (other.isSetOtherArgs()) { + Map __this__otherArgs = new HashMap(other.otherArgs); + this.otherArgs = __this__otherArgs; + } + } + + public TSColumnSchema deepCopy() { + return new TSColumnSchema(this); + } + + @Override + public void clear() { + this.name = null; + this.dataType = null; + this.encoding = null; + this.otherArgs = null; + } + + public String getName() { + return this.name; + } + + public TSColumnSchema setName(String name) { + this.name = name; + return this; + } + + public void unsetName() { + this.name = null; + } + + /** Returns true if field name is set (has been assigned a value) and false otherwise */ + public boolean isSetName() { + return this.name != null; + } + + public void setNameIsSet(boolean value) { + if (!value) { + this.name = null; + } + } + + public String getDataType() { + return this.dataType; + } + + public TSColumnSchema setDataType(String dataType) { + this.dataType = dataType; + return this; + } + + public void unsetDataType() { + this.dataType = null; + } + + /** Returns true if field dataType is set (has been assigned a value) and false otherwise */ + public boolean isSetDataType() { + return this.dataType != null; + } + + public void setDataTypeIsSet(boolean value) { + if (!value) { + this.dataType = null; + } + } + + public String getEncoding() { + return this.encoding; + } + + public TSColumnSchema setEncoding(String encoding) { + this.encoding = encoding; + return this; + } + + public void unsetEncoding() { + this.encoding = null; + } + + /** Returns true if field encoding is set (has been assigned a value) and false otherwise */ + public boolean isSetEncoding() { + return this.encoding != null; + } + + public void setEncodingIsSet(boolean value) { + if (!value) { + this.encoding = null; + } + } + + public int getOtherArgsSize() { + return (this.otherArgs == null) ? 0 : this.otherArgs.size(); + } + + public void putToOtherArgs(String key, String val) { + if (this.otherArgs == null) { + this.otherArgs = new HashMap(); + } + this.otherArgs.put(key, val); + } + + public Map getOtherArgs() { + return this.otherArgs; + } + + public TSColumnSchema setOtherArgs(Map otherArgs) { + this.otherArgs = otherArgs; + return this; + } + + public void unsetOtherArgs() { + this.otherArgs = null; + } + + /** Returns true if field otherArgs is set (has been assigned a value) and false otherwise */ + public boolean isSetOtherArgs() { + return this.otherArgs != null; + } + + public void setOtherArgsIsSet(boolean value) { + if (!value) { + this.otherArgs = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case NAME: + if (value == null) { + unsetName(); + } else { + setName((String)value); + } + break; + + case DATA_TYPE: + if (value == null) { + unsetDataType(); + } else { + setDataType((String)value); + } + break; + + case ENCODING: + if (value == null) { + unsetEncoding(); + } else { + setEncoding((String)value); + } + break; + + case OTHER_ARGS: + if (value == null) { + unsetOtherArgs(); + } else { + setOtherArgs((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case NAME: + return getName(); + + case DATA_TYPE: + return getDataType(); + + case ENCODING: + return getEncoding(); + + case OTHER_ARGS: + return getOtherArgs(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case NAME: + return isSetName(); + case DATA_TYPE: + return isSetDataType(); + case ENCODING: + return isSetEncoding(); + case OTHER_ARGS: + return isSetOtherArgs(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSColumnSchema) + return this.equals((TSColumnSchema)that); + return false; + } + + public boolean equals(TSColumnSchema that) { + if (that == null) + return false; + + boolean this_present_name = true && this.isSetName(); + boolean that_present_name = true && that.isSetName(); + if (this_present_name || that_present_name) { + if (!(this_present_name && that_present_name)) + return false; + if (!this.name.equals(that.name)) + return false; + } + + boolean this_present_dataType = true && this.isSetDataType(); + boolean that_present_dataType = true && that.isSetDataType(); + if (this_present_dataType || that_present_dataType) { + if (!(this_present_dataType && that_present_dataType)) + return false; + if (!this.dataType.equals(that.dataType)) + return false; + } + + boolean this_present_encoding = true && this.isSetEncoding(); + boolean that_present_encoding = true && that.isSetEncoding(); + if (this_present_encoding || that_present_encoding) { + if (!(this_present_encoding && that_present_encoding)) + return false; + if (!this.encoding.equals(that.encoding)) + return false; + } + + boolean this_present_otherArgs = true && this.isSetOtherArgs(); + boolean that_present_otherArgs = true && that.isSetOtherArgs(); + if (this_present_otherArgs || that_present_otherArgs) { + if (!(this_present_otherArgs && that_present_otherArgs)) + return false; + if (!this.otherArgs.equals(that.otherArgs)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_name = true && (isSetName()); + list.add(present_name); + if (present_name) + list.add(name); + + boolean present_dataType = true && (isSetDataType()); + list.add(present_dataType); + if (present_dataType) + list.add(dataType); + + boolean present_encoding = true && (isSetEncoding()); + list.add(present_encoding); + if (present_encoding) + list.add(encoding); + + boolean present_otherArgs = true && (isSetOtherArgs()); + list.add(present_otherArgs); + if (present_otherArgs) + list.add(otherArgs); + + return list.hashCode(); + } + + @Override + public int compareTo(TSColumnSchema other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDataType()).compareTo(other.isSetDataType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDataType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataType, other.dataType); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetEncoding()).compareTo(other.isSetEncoding()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetEncoding()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.encoding, other.encoding); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetOtherArgs()).compareTo(other.isSetOtherArgs()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOtherArgs()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.otherArgs, other.otherArgs); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSColumnSchema("); + boolean first = true; + + if (isSetName()) { + sb.append("name:"); + if (this.name == null) { + sb.append("null"); + } else { + sb.append(this.name); + } + first = false; + } + if (isSetDataType()) { + if (!first) sb.append(", "); + sb.append("dataType:"); + if (this.dataType == null) { + sb.append("null"); + } else { + sb.append(this.dataType); + } + first = false; + } + if (isSetEncoding()) { + if (!first) sb.append(", "); + sb.append("encoding:"); + if (this.encoding == null) { + sb.append("null"); + } else { + sb.append(this.encoding); + } + first = false; + } + if (isSetOtherArgs()) { + if (!first) sb.append(", "); + sb.append("otherArgs:"); + if (this.otherArgs == null) { + sb.append("null"); + } else { + sb.append(this.otherArgs); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSColumnSchemaStandardSchemeFactory implements SchemeFactory { + public TSColumnSchemaStandardScheme getScheme() { + return new TSColumnSchemaStandardScheme(); + } + } + + private static class TSColumnSchemaStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSColumnSchema struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.name = iprot.readString(); + struct.setNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // DATA_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.dataType = iprot.readString(); + struct.setDataTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // ENCODING + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.encoding = iprot.readString(); + struct.setEncodingIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // OTHER_ARGS + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map160 = iprot.readMapBegin(); + struct.otherArgs = new HashMap(2*_map160.size); + String _key161; + String _val162; + for (int _i163 = 0; _i163 < _map160.size; ++_i163) + { + _key161 = iprot.readString(); + _val162 = iprot.readString(); + struct.otherArgs.put(_key161, _val162); + } + iprot.readMapEnd(); + } + struct.setOtherArgsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSColumnSchema struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.name != null) { + if (struct.isSetName()) { + oprot.writeFieldBegin(NAME_FIELD_DESC); + oprot.writeString(struct.name); + oprot.writeFieldEnd(); + } + } + if (struct.dataType != null) { + if (struct.isSetDataType()) { + oprot.writeFieldBegin(DATA_TYPE_FIELD_DESC); + oprot.writeString(struct.dataType); + oprot.writeFieldEnd(); + } + } + if (struct.encoding != null) { + if (struct.isSetEncoding()) { + oprot.writeFieldBegin(ENCODING_FIELD_DESC); + oprot.writeString(struct.encoding); + oprot.writeFieldEnd(); + } + } + if (struct.otherArgs != null) { + if (struct.isSetOtherArgs()) { + oprot.writeFieldBegin(OTHER_ARGS_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.otherArgs.size())); + for (Map.Entry _iter164 : struct.otherArgs.entrySet()) + { + oprot.writeString(_iter164.getKey()); + oprot.writeString(_iter164.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSColumnSchemaTupleSchemeFactory implements SchemeFactory { + public TSColumnSchemaTupleScheme getScheme() { + return new TSColumnSchemaTupleScheme(); + } + } + + private static class TSColumnSchemaTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSColumnSchema struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetName()) { + optionals.set(0); + } + if (struct.isSetDataType()) { + optionals.set(1); + } + if (struct.isSetEncoding()) { + optionals.set(2); + } + if (struct.isSetOtherArgs()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); + if (struct.isSetName()) { + oprot.writeString(struct.name); + } + if (struct.isSetDataType()) { + oprot.writeString(struct.dataType); + } + if (struct.isSetEncoding()) { + oprot.writeString(struct.encoding); + } + if (struct.isSetOtherArgs()) { + { + oprot.writeI32(struct.otherArgs.size()); + for (Map.Entry _iter165 : struct.otherArgs.entrySet()) + { + oprot.writeString(_iter165.getKey()); + oprot.writeString(_iter165.getValue()); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSColumnSchema struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(4); + if (incoming.get(0)) { + struct.name = iprot.readString(); + struct.setNameIsSet(true); + } + if (incoming.get(1)) { + struct.dataType = iprot.readString(); + struct.setDataTypeIsSet(true); + } + if (incoming.get(2)) { + struct.encoding = iprot.readString(); + struct.setEncodingIsSet(true); + } + if (incoming.get(3)) { + { + org.apache.thrift.protocol.TMap _map166 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.otherArgs = new HashMap(2*_map166.size); + String _key167; + String _val168; + for (int _i169 = 0; _i169 < _map166.size; ++_i169) + { + _key167 = iprot.readString(); + _val168 = iprot.readString(); + struct.otherArgs.put(_key167, _val168); + } + } + struct.setOtherArgsIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSDynamicOneColumnData.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSDynamicOneColumnData.java new file mode 100644 index 00000000000..cf808dfa200 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSDynamicOneColumnData.java @@ -0,0 +1,1682 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSDynamicOneColumnData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSDynamicOneColumnData"); + + private static final org.apache.thrift.protocol.TField DEVICE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("deviceType", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField DATA_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("dataType", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField LENGTH_FIELD_DESC = new org.apache.thrift.protocol.TField("length", org.apache.thrift.protocol.TType.I32, (short)3); + private static final org.apache.thrift.protocol.TField TIME_RET_FIELD_DESC = new org.apache.thrift.protocol.TField("timeRet", org.apache.thrift.protocol.TType.LIST, (short)4); + private static final org.apache.thrift.protocol.TField BOOL_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("boolList", org.apache.thrift.protocol.TType.LIST, (short)5); + private static final org.apache.thrift.protocol.TField I32_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("i32List", org.apache.thrift.protocol.TType.LIST, (short)6); + private static final org.apache.thrift.protocol.TField I64_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("i64List", org.apache.thrift.protocol.TType.LIST, (short)7); + private static final org.apache.thrift.protocol.TField FLOAT_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("floatList", org.apache.thrift.protocol.TType.LIST, (short)8); + private static final org.apache.thrift.protocol.TField DOUBLE_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("doubleList", org.apache.thrift.protocol.TType.LIST, (short)9); + private static final org.apache.thrift.protocol.TField BINARY_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("binaryList", org.apache.thrift.protocol.TType.LIST, (short)10); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSDynamicOneColumnDataStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSDynamicOneColumnDataTupleSchemeFactory()); + } + + public String deviceType; // required + public String dataType; // required + public int length; // required + public List timeRet; // required + public List boolList; // optional + public List i32List; // optional + public List i64List; // optional + public List floatList; // optional + public List doubleList; // optional + public List binaryList; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + DEVICE_TYPE((short)1, "deviceType"), + DATA_TYPE((short)2, "dataType"), + LENGTH((short)3, "length"), + TIME_RET((short)4, "timeRet"), + BOOL_LIST((short)5, "boolList"), + I32_LIST((short)6, "i32List"), + I64_LIST((short)7, "i64List"), + FLOAT_LIST((short)8, "floatList"), + DOUBLE_LIST((short)9, "doubleList"), + BINARY_LIST((short)10, "binaryList"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // DEVICE_TYPE + return DEVICE_TYPE; + case 2: // DATA_TYPE + return DATA_TYPE; + case 3: // LENGTH + return LENGTH; + case 4: // TIME_RET + return TIME_RET; + case 5: // BOOL_LIST + return BOOL_LIST; + case 6: // I32_LIST + return I32_LIST; + case 7: // I64_LIST + return I64_LIST; + case 8: // FLOAT_LIST + return FLOAT_LIST; + case 9: // DOUBLE_LIST + return DOUBLE_LIST; + case 10: // BINARY_LIST + return BINARY_LIST; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __LENGTH_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.BOOL_LIST,_Fields.I32_LIST,_Fields.I64_LIST,_Fields.FLOAT_LIST,_Fields.DOUBLE_LIST,_Fields.BINARY_LIST}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.DEVICE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("deviceType", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DATA_TYPE, new org.apache.thrift.meta_data.FieldMetaData("dataType", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.LENGTH, new org.apache.thrift.meta_data.FieldMetaData("length", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.TIME_RET, new org.apache.thrift.meta_data.FieldMetaData("timeRet", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)))); + tmpMap.put(_Fields.BOOL_LIST, new org.apache.thrift.meta_data.FieldMetaData("boolList", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)))); + tmpMap.put(_Fields.I32_LIST, new org.apache.thrift.meta_data.FieldMetaData("i32List", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.I64_LIST, new org.apache.thrift.meta_data.FieldMetaData("i64List", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)))); + tmpMap.put(_Fields.FLOAT_LIST, new org.apache.thrift.meta_data.FieldMetaData("floatList", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)))); + tmpMap.put(_Fields.DOUBLE_LIST, new org.apache.thrift.meta_data.FieldMetaData("doubleList", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)))); + tmpMap.put(_Fields.BINARY_LIST, new org.apache.thrift.meta_data.FieldMetaData("binaryList", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BYTE)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSDynamicOneColumnData.class, metaDataMap); + } + + public TSDynamicOneColumnData() { + } + + public TSDynamicOneColumnData( + String deviceType, + String dataType, + int length, + List timeRet) + { + this(); + this.deviceType = deviceType; + this.dataType = dataType; + this.length = length; + setLengthIsSet(true); + this.timeRet = timeRet; + } + + /** + * Performs a deep copy on other. + */ + public TSDynamicOneColumnData(TSDynamicOneColumnData other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetDeviceType()) { + this.deviceType = other.deviceType; + } + if (other.isSetDataType()) { + this.dataType = other.dataType; + } + this.length = other.length; + if (other.isSetTimeRet()) { + List __this__timeRet = new ArrayList(other.timeRet); + this.timeRet = __this__timeRet; + } + if (other.isSetBoolList()) { + List __this__boolList = new ArrayList(other.boolList); + this.boolList = __this__boolList; + } + if (other.isSetI32List()) { + List __this__i32List = new ArrayList(other.i32List); + this.i32List = __this__i32List; + } + if (other.isSetI64List()) { + List __this__i64List = new ArrayList(other.i64List); + this.i64List = __this__i64List; + } + if (other.isSetFloatList()) { + List __this__floatList = new ArrayList(other.floatList); + this.floatList = __this__floatList; + } + if (other.isSetDoubleList()) { + List __this__doubleList = new ArrayList(other.doubleList); + this.doubleList = __this__doubleList; + } + if (other.isSetBinaryList()) { + List __this__binaryList = new ArrayList(other.binaryList); + this.binaryList = __this__binaryList; + } + } + + public TSDynamicOneColumnData deepCopy() { + return new TSDynamicOneColumnData(this); + } + + @Override + public void clear() { + this.deviceType = null; + this.dataType = null; + setLengthIsSet(false); + this.length = 0; + this.timeRet = null; + this.boolList = null; + this.i32List = null; + this.i64List = null; + this.floatList = null; + this.doubleList = null; + this.binaryList = null; + } + + public String getDeviceType() { + return this.deviceType; + } + + public TSDynamicOneColumnData setDeviceType(String deviceType) { + this.deviceType = deviceType; + return this; + } + + public void unsetDeviceType() { + this.deviceType = null; + } + + /** Returns true if field deviceType is set (has been assigned a value) and false otherwise */ + public boolean isSetDeviceType() { + return this.deviceType != null; + } + + public void setDeviceTypeIsSet(boolean value) { + if (!value) { + this.deviceType = null; + } + } + + public String getDataType() { + return this.dataType; + } + + public TSDynamicOneColumnData setDataType(String dataType) { + this.dataType = dataType; + return this; + } + + public void unsetDataType() { + this.dataType = null; + } + + /** Returns true if field dataType is set (has been assigned a value) and false otherwise */ + public boolean isSetDataType() { + return this.dataType != null; + } + + public void setDataTypeIsSet(boolean value) { + if (!value) { + this.dataType = null; + } + } + + public int getLength() { + return this.length; + } + + public TSDynamicOneColumnData setLength(int length) { + this.length = length; + setLengthIsSet(true); + return this; + } + + public void unsetLength() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __LENGTH_ISSET_ID); + } + + /** Returns true if field length is set (has been assigned a value) and false otherwise */ + public boolean isSetLength() { + return EncodingUtils.testBit(__isset_bitfield, __LENGTH_ISSET_ID); + } + + public void setLengthIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LENGTH_ISSET_ID, value); + } + + public int getTimeRetSize() { + return (this.timeRet == null) ? 0 : this.timeRet.size(); + } + + public java.util.Iterator getTimeRetIterator() { + return (this.timeRet == null) ? null : this.timeRet.iterator(); + } + + public void addToTimeRet(long elem) { + if (this.timeRet == null) { + this.timeRet = new ArrayList(); + } + this.timeRet.add(elem); + } + + public List getTimeRet() { + return this.timeRet; + } + + public TSDynamicOneColumnData setTimeRet(List timeRet) { + this.timeRet = timeRet; + return this; + } + + public void unsetTimeRet() { + this.timeRet = null; + } + + /** Returns true if field timeRet is set (has been assigned a value) and false otherwise */ + public boolean isSetTimeRet() { + return this.timeRet != null; + } + + public void setTimeRetIsSet(boolean value) { + if (!value) { + this.timeRet = null; + } + } + + public int getBoolListSize() { + return (this.boolList == null) ? 0 : this.boolList.size(); + } + + public java.util.Iterator getBoolListIterator() { + return (this.boolList == null) ? null : this.boolList.iterator(); + } + + public void addToBoolList(boolean elem) { + if (this.boolList == null) { + this.boolList = new ArrayList(); + } + this.boolList.add(elem); + } + + public List getBoolList() { + return this.boolList; + } + + public TSDynamicOneColumnData setBoolList(List boolList) { + this.boolList = boolList; + return this; + } + + public void unsetBoolList() { + this.boolList = null; + } + + /** Returns true if field boolList is set (has been assigned a value) and false otherwise */ + public boolean isSetBoolList() { + return this.boolList != null; + } + + public void setBoolListIsSet(boolean value) { + if (!value) { + this.boolList = null; + } + } + + public int getI32ListSize() { + return (this.i32List == null) ? 0 : this.i32List.size(); + } + + public java.util.Iterator getI32ListIterator() { + return (this.i32List == null) ? null : this.i32List.iterator(); + } + + public void addToI32List(int elem) { + if (this.i32List == null) { + this.i32List = new ArrayList(); + } + this.i32List.add(elem); + } + + public List getI32List() { + return this.i32List; + } + + public TSDynamicOneColumnData setI32List(List i32List) { + this.i32List = i32List; + return this; + } + + public void unsetI32List() { + this.i32List = null; + } + + /** Returns true if field i32List is set (has been assigned a value) and false otherwise */ + public boolean isSetI32List() { + return this.i32List != null; + } + + public void setI32ListIsSet(boolean value) { + if (!value) { + this.i32List = null; + } + } + + public int getI64ListSize() { + return (this.i64List == null) ? 0 : this.i64List.size(); + } + + public java.util.Iterator getI64ListIterator() { + return (this.i64List == null) ? null : this.i64List.iterator(); + } + + public void addToI64List(long elem) { + if (this.i64List == null) { + this.i64List = new ArrayList(); + } + this.i64List.add(elem); + } + + public List getI64List() { + return this.i64List; + } + + public TSDynamicOneColumnData setI64List(List i64List) { + this.i64List = i64List; + return this; + } + + public void unsetI64List() { + this.i64List = null; + } + + /** Returns true if field i64List is set (has been assigned a value) and false otherwise */ + public boolean isSetI64List() { + return this.i64List != null; + } + + public void setI64ListIsSet(boolean value) { + if (!value) { + this.i64List = null; + } + } + + public int getFloatListSize() { + return (this.floatList == null) ? 0 : this.floatList.size(); + } + + public java.util.Iterator getFloatListIterator() { + return (this.floatList == null) ? null : this.floatList.iterator(); + } + + public void addToFloatList(double elem) { + if (this.floatList == null) { + this.floatList = new ArrayList(); + } + this.floatList.add(elem); + } + + public List getFloatList() { + return this.floatList; + } + + public TSDynamicOneColumnData setFloatList(List floatList) { + this.floatList = floatList; + return this; + } + + public void unsetFloatList() { + this.floatList = null; + } + + /** Returns true if field floatList is set (has been assigned a value) and false otherwise */ + public boolean isSetFloatList() { + return this.floatList != null; + } + + public void setFloatListIsSet(boolean value) { + if (!value) { + this.floatList = null; + } + } + + public int getDoubleListSize() { + return (this.doubleList == null) ? 0 : this.doubleList.size(); + } + + public java.util.Iterator getDoubleListIterator() { + return (this.doubleList == null) ? null : this.doubleList.iterator(); + } + + public void addToDoubleList(double elem) { + if (this.doubleList == null) { + this.doubleList = new ArrayList(); + } + this.doubleList.add(elem); + } + + public List getDoubleList() { + return this.doubleList; + } + + public TSDynamicOneColumnData setDoubleList(List doubleList) { + this.doubleList = doubleList; + return this; + } + + public void unsetDoubleList() { + this.doubleList = null; + } + + /** Returns true if field doubleList is set (has been assigned a value) and false otherwise */ + public boolean isSetDoubleList() { + return this.doubleList != null; + } + + public void setDoubleListIsSet(boolean value) { + if (!value) { + this.doubleList = null; + } + } + + public int getBinaryListSize() { + return (this.binaryList == null) ? 0 : this.binaryList.size(); + } + + public java.util.Iterator getBinaryListIterator() { + return (this.binaryList == null) ? null : this.binaryList.iterator(); + } + + public void addToBinaryList(byte elem) { + if (this.binaryList == null) { + this.binaryList = new ArrayList(); + } + this.binaryList.add(elem); + } + + public List getBinaryList() { + return this.binaryList; + } + + public TSDynamicOneColumnData setBinaryList(List binaryList) { + this.binaryList = binaryList; + return this; + } + + public void unsetBinaryList() { + this.binaryList = null; + } + + /** Returns true if field binaryList is set (has been assigned a value) and false otherwise */ + public boolean isSetBinaryList() { + return this.binaryList != null; + } + + public void setBinaryListIsSet(boolean value) { + if (!value) { + this.binaryList = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case DEVICE_TYPE: + if (value == null) { + unsetDeviceType(); + } else { + setDeviceType((String)value); + } + break; + + case DATA_TYPE: + if (value == null) { + unsetDataType(); + } else { + setDataType((String)value); + } + break; + + case LENGTH: + if (value == null) { + unsetLength(); + } else { + setLength((Integer)value); + } + break; + + case TIME_RET: + if (value == null) { + unsetTimeRet(); + } else { + setTimeRet((List)value); + } + break; + + case BOOL_LIST: + if (value == null) { + unsetBoolList(); + } else { + setBoolList((List)value); + } + break; + + case I32_LIST: + if (value == null) { + unsetI32List(); + } else { + setI32List((List)value); + } + break; + + case I64_LIST: + if (value == null) { + unsetI64List(); + } else { + setI64List((List)value); + } + break; + + case FLOAT_LIST: + if (value == null) { + unsetFloatList(); + } else { + setFloatList((List)value); + } + break; + + case DOUBLE_LIST: + if (value == null) { + unsetDoubleList(); + } else { + setDoubleList((List)value); + } + break; + + case BINARY_LIST: + if (value == null) { + unsetBinaryList(); + } else { + setBinaryList((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case DEVICE_TYPE: + return getDeviceType(); + + case DATA_TYPE: + return getDataType(); + + case LENGTH: + return Integer.valueOf(getLength()); + + case TIME_RET: + return getTimeRet(); + + case BOOL_LIST: + return getBoolList(); + + case I32_LIST: + return getI32List(); + + case I64_LIST: + return getI64List(); + + case FLOAT_LIST: + return getFloatList(); + + case DOUBLE_LIST: + return getDoubleList(); + + case BINARY_LIST: + return getBinaryList(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case DEVICE_TYPE: + return isSetDeviceType(); + case DATA_TYPE: + return isSetDataType(); + case LENGTH: + return isSetLength(); + case TIME_RET: + return isSetTimeRet(); + case BOOL_LIST: + return isSetBoolList(); + case I32_LIST: + return isSetI32List(); + case I64_LIST: + return isSetI64List(); + case FLOAT_LIST: + return isSetFloatList(); + case DOUBLE_LIST: + return isSetDoubleList(); + case BINARY_LIST: + return isSetBinaryList(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSDynamicOneColumnData) + return this.equals((TSDynamicOneColumnData)that); + return false; + } + + public boolean equals(TSDynamicOneColumnData that) { + if (that == null) + return false; + + boolean this_present_deviceType = true && this.isSetDeviceType(); + boolean that_present_deviceType = true && that.isSetDeviceType(); + if (this_present_deviceType || that_present_deviceType) { + if (!(this_present_deviceType && that_present_deviceType)) + return false; + if (!this.deviceType.equals(that.deviceType)) + return false; + } + + boolean this_present_dataType = true && this.isSetDataType(); + boolean that_present_dataType = true && that.isSetDataType(); + if (this_present_dataType || that_present_dataType) { + if (!(this_present_dataType && that_present_dataType)) + return false; + if (!this.dataType.equals(that.dataType)) + return false; + } + + boolean this_present_length = true; + boolean that_present_length = true; + if (this_present_length || that_present_length) { + if (!(this_present_length && that_present_length)) + return false; + if (this.length != that.length) + return false; + } + + boolean this_present_timeRet = true && this.isSetTimeRet(); + boolean that_present_timeRet = true && that.isSetTimeRet(); + if (this_present_timeRet || that_present_timeRet) { + if (!(this_present_timeRet && that_present_timeRet)) + return false; + if (!this.timeRet.equals(that.timeRet)) + return false; + } + + boolean this_present_boolList = true && this.isSetBoolList(); + boolean that_present_boolList = true && that.isSetBoolList(); + if (this_present_boolList || that_present_boolList) { + if (!(this_present_boolList && that_present_boolList)) + return false; + if (!this.boolList.equals(that.boolList)) + return false; + } + + boolean this_present_i32List = true && this.isSetI32List(); + boolean that_present_i32List = true && that.isSetI32List(); + if (this_present_i32List || that_present_i32List) { + if (!(this_present_i32List && that_present_i32List)) + return false; + if (!this.i32List.equals(that.i32List)) + return false; + } + + boolean this_present_i64List = true && this.isSetI64List(); + boolean that_present_i64List = true && that.isSetI64List(); + if (this_present_i64List || that_present_i64List) { + if (!(this_present_i64List && that_present_i64List)) + return false; + if (!this.i64List.equals(that.i64List)) + return false; + } + + boolean this_present_floatList = true && this.isSetFloatList(); + boolean that_present_floatList = true && that.isSetFloatList(); + if (this_present_floatList || that_present_floatList) { + if (!(this_present_floatList && that_present_floatList)) + return false; + if (!this.floatList.equals(that.floatList)) + return false; + } + + boolean this_present_doubleList = true && this.isSetDoubleList(); + boolean that_present_doubleList = true && that.isSetDoubleList(); + if (this_present_doubleList || that_present_doubleList) { + if (!(this_present_doubleList && that_present_doubleList)) + return false; + if (!this.doubleList.equals(that.doubleList)) + return false; + } + + boolean this_present_binaryList = true && this.isSetBinaryList(); + boolean that_present_binaryList = true && that.isSetBinaryList(); + if (this_present_binaryList || that_present_binaryList) { + if (!(this_present_binaryList && that_present_binaryList)) + return false; + if (!this.binaryList.equals(that.binaryList)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_deviceType = true && (isSetDeviceType()); + list.add(present_deviceType); + if (present_deviceType) + list.add(deviceType); + + boolean present_dataType = true && (isSetDataType()); + list.add(present_dataType); + if (present_dataType) + list.add(dataType); + + boolean present_length = true; + list.add(present_length); + if (present_length) + list.add(length); + + boolean present_timeRet = true && (isSetTimeRet()); + list.add(present_timeRet); + if (present_timeRet) + list.add(timeRet); + + boolean present_boolList = true && (isSetBoolList()); + list.add(present_boolList); + if (present_boolList) + list.add(boolList); + + boolean present_i32List = true && (isSetI32List()); + list.add(present_i32List); + if (present_i32List) + list.add(i32List); + + boolean present_i64List = true && (isSetI64List()); + list.add(present_i64List); + if (present_i64List) + list.add(i64List); + + boolean present_floatList = true && (isSetFloatList()); + list.add(present_floatList); + if (present_floatList) + list.add(floatList); + + boolean present_doubleList = true && (isSetDoubleList()); + list.add(present_doubleList); + if (present_doubleList) + list.add(doubleList); + + boolean present_binaryList = true && (isSetBinaryList()); + list.add(present_binaryList); + if (present_binaryList) + list.add(binaryList); + + return list.hashCode(); + } + + @Override + public int compareTo(TSDynamicOneColumnData other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetDeviceType()).compareTo(other.isSetDeviceType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDeviceType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.deviceType, other.deviceType); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDataType()).compareTo(other.isSetDataType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDataType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataType, other.dataType); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetLength()).compareTo(other.isSetLength()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetLength()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.length, other.length); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTimeRet()).compareTo(other.isSetTimeRet()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTimeRet()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timeRet, other.timeRet); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetBoolList()).compareTo(other.isSetBoolList()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBoolList()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.boolList, other.boolList); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetI32List()).compareTo(other.isSetI32List()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetI32List()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.i32List, other.i32List); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetI64List()).compareTo(other.isSetI64List()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetI64List()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.i64List, other.i64List); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetFloatList()).compareTo(other.isSetFloatList()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetFloatList()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.floatList, other.floatList); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDoubleList()).compareTo(other.isSetDoubleList()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDoubleList()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.doubleList, other.doubleList); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetBinaryList()).compareTo(other.isSetBinaryList()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBinaryList()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.binaryList, other.binaryList); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSDynamicOneColumnData("); + boolean first = true; + + sb.append("deviceType:"); + if (this.deviceType == null) { + sb.append("null"); + } else { + sb.append(this.deviceType); + } + first = false; + if (!first) sb.append(", "); + sb.append("dataType:"); + if (this.dataType == null) { + sb.append("null"); + } else { + sb.append(this.dataType); + } + first = false; + if (!first) sb.append(", "); + sb.append("length:"); + sb.append(this.length); + first = false; + if (!first) sb.append(", "); + sb.append("timeRet:"); + if (this.timeRet == null) { + sb.append("null"); + } else { + sb.append(this.timeRet); + } + first = false; + if (isSetBoolList()) { + if (!first) sb.append(", "); + sb.append("boolList:"); + if (this.boolList == null) { + sb.append("null"); + } else { + sb.append(this.boolList); + } + first = false; + } + if (isSetI32List()) { + if (!first) sb.append(", "); + sb.append("i32List:"); + if (this.i32List == null) { + sb.append("null"); + } else { + sb.append(this.i32List); + } + first = false; + } + if (isSetI64List()) { + if (!first) sb.append(", "); + sb.append("i64List:"); + if (this.i64List == null) { + sb.append("null"); + } else { + sb.append(this.i64List); + } + first = false; + } + if (isSetFloatList()) { + if (!first) sb.append(", "); + sb.append("floatList:"); + if (this.floatList == null) { + sb.append("null"); + } else { + sb.append(this.floatList); + } + first = false; + } + if (isSetDoubleList()) { + if (!first) sb.append(", "); + sb.append("doubleList:"); + if (this.doubleList == null) { + sb.append("null"); + } else { + sb.append(this.doubleList); + } + first = false; + } + if (isSetBinaryList()) { + if (!first) sb.append(", "); + sb.append("binaryList:"); + if (this.binaryList == null) { + sb.append("null"); + } else { + sb.append(this.binaryList); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (deviceType == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'deviceType' was not present! Struct: " + toString()); + } + if (dataType == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'dataType' was not present! Struct: " + toString()); + } + // alas, we cannot check 'length' because it's a primitive and you chose the non-beans generator. + if (timeRet == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'timeRet' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSDynamicOneColumnDataStandardSchemeFactory implements SchemeFactory { + public TSDynamicOneColumnDataStandardScheme getScheme() { + return new TSDynamicOneColumnDataStandardScheme(); + } + } + + private static class TSDynamicOneColumnDataStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSDynamicOneColumnData struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // DEVICE_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.deviceType = iprot.readString(); + struct.setDeviceTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // DATA_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.dataType = iprot.readString(); + struct.setDataTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // LENGTH + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.length = iprot.readI32(); + struct.setLengthIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // TIME_RET + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list68 = iprot.readListBegin(); + struct.timeRet = new ArrayList(_list68.size); + long _elem69; + for (int _i70 = 0; _i70 < _list68.size; ++_i70) + { + _elem69 = iprot.readI64(); + struct.timeRet.add(_elem69); + } + iprot.readListEnd(); + } + struct.setTimeRetIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // BOOL_LIST + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list71 = iprot.readListBegin(); + struct.boolList = new ArrayList(_list71.size); + boolean _elem72; + for (int _i73 = 0; _i73 < _list71.size; ++_i73) + { + _elem72 = iprot.readBool(); + struct.boolList.add(_elem72); + } + iprot.readListEnd(); + } + struct.setBoolListIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // I32_LIST + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list74 = iprot.readListBegin(); + struct.i32List = new ArrayList(_list74.size); + int _elem75; + for (int _i76 = 0; _i76 < _list74.size; ++_i76) + { + _elem75 = iprot.readI32(); + struct.i32List.add(_elem75); + } + iprot.readListEnd(); + } + struct.setI32ListIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // I64_LIST + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list77 = iprot.readListBegin(); + struct.i64List = new ArrayList(_list77.size); + long _elem78; + for (int _i79 = 0; _i79 < _list77.size; ++_i79) + { + _elem78 = iprot.readI64(); + struct.i64List.add(_elem78); + } + iprot.readListEnd(); + } + struct.setI64ListIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 8: // FLOAT_LIST + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list80 = iprot.readListBegin(); + struct.floatList = new ArrayList(_list80.size); + double _elem81; + for (int _i82 = 0; _i82 < _list80.size; ++_i82) + { + _elem81 = iprot.readDouble(); + struct.floatList.add(_elem81); + } + iprot.readListEnd(); + } + struct.setFloatListIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 9: // DOUBLE_LIST + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list83 = iprot.readListBegin(); + struct.doubleList = new ArrayList(_list83.size); + double _elem84; + for (int _i85 = 0; _i85 < _list83.size; ++_i85) + { + _elem84 = iprot.readDouble(); + struct.doubleList.add(_elem84); + } + iprot.readListEnd(); + } + struct.setDoubleListIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 10: // BINARY_LIST + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list86 = iprot.readListBegin(); + struct.binaryList = new ArrayList(_list86.size); + byte _elem87; + for (int _i88 = 0; _i88 < _list86.size; ++_i88) + { + _elem87 = iprot.readByte(); + struct.binaryList.add(_elem87); + } + iprot.readListEnd(); + } + struct.setBinaryListIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetLength()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'length' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSDynamicOneColumnData struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.deviceType != null) { + oprot.writeFieldBegin(DEVICE_TYPE_FIELD_DESC); + oprot.writeString(struct.deviceType); + oprot.writeFieldEnd(); + } + if (struct.dataType != null) { + oprot.writeFieldBegin(DATA_TYPE_FIELD_DESC); + oprot.writeString(struct.dataType); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(LENGTH_FIELD_DESC); + oprot.writeI32(struct.length); + oprot.writeFieldEnd(); + if (struct.timeRet != null) { + oprot.writeFieldBegin(TIME_RET_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I64, struct.timeRet.size())); + for (long _iter89 : struct.timeRet) + { + oprot.writeI64(_iter89); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.boolList != null) { + if (struct.isSetBoolList()) { + oprot.writeFieldBegin(BOOL_LIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.BOOL, struct.boolList.size())); + for (boolean _iter90 : struct.boolList) + { + oprot.writeBool(_iter90); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.i32List != null) { + if (struct.isSetI32List()) { + oprot.writeFieldBegin(I32_LIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.i32List.size())); + for (int _iter91 : struct.i32List) + { + oprot.writeI32(_iter91); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.i64List != null) { + if (struct.isSetI64List()) { + oprot.writeFieldBegin(I64_LIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I64, struct.i64List.size())); + for (long _iter92 : struct.i64List) + { + oprot.writeI64(_iter92); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.floatList != null) { + if (struct.isSetFloatList()) { + oprot.writeFieldBegin(FLOAT_LIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.DOUBLE, struct.floatList.size())); + for (double _iter93 : struct.floatList) + { + oprot.writeDouble(_iter93); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.doubleList != null) { + if (struct.isSetDoubleList()) { + oprot.writeFieldBegin(DOUBLE_LIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.DOUBLE, struct.doubleList.size())); + for (double _iter94 : struct.doubleList) + { + oprot.writeDouble(_iter94); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.binaryList != null) { + if (struct.isSetBinaryList()) { + oprot.writeFieldBegin(BINARY_LIST_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.BYTE, struct.binaryList.size())); + for (byte _iter95 : struct.binaryList) + { + oprot.writeByte(_iter95); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSDynamicOneColumnDataTupleSchemeFactory implements SchemeFactory { + public TSDynamicOneColumnDataTupleScheme getScheme() { + return new TSDynamicOneColumnDataTupleScheme(); + } + } + + private static class TSDynamicOneColumnDataTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSDynamicOneColumnData struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.deviceType); + oprot.writeString(struct.dataType); + oprot.writeI32(struct.length); + { + oprot.writeI32(struct.timeRet.size()); + for (long _iter96 : struct.timeRet) + { + oprot.writeI64(_iter96); + } + } + BitSet optionals = new BitSet(); + if (struct.isSetBoolList()) { + optionals.set(0); + } + if (struct.isSetI32List()) { + optionals.set(1); + } + if (struct.isSetI64List()) { + optionals.set(2); + } + if (struct.isSetFloatList()) { + optionals.set(3); + } + if (struct.isSetDoubleList()) { + optionals.set(4); + } + if (struct.isSetBinaryList()) { + optionals.set(5); + } + oprot.writeBitSet(optionals, 6); + if (struct.isSetBoolList()) { + { + oprot.writeI32(struct.boolList.size()); + for (boolean _iter97 : struct.boolList) + { + oprot.writeBool(_iter97); + } + } + } + if (struct.isSetI32List()) { + { + oprot.writeI32(struct.i32List.size()); + for (int _iter98 : struct.i32List) + { + oprot.writeI32(_iter98); + } + } + } + if (struct.isSetI64List()) { + { + oprot.writeI32(struct.i64List.size()); + for (long _iter99 : struct.i64List) + { + oprot.writeI64(_iter99); + } + } + } + if (struct.isSetFloatList()) { + { + oprot.writeI32(struct.floatList.size()); + for (double _iter100 : struct.floatList) + { + oprot.writeDouble(_iter100); + } + } + } + if (struct.isSetDoubleList()) { + { + oprot.writeI32(struct.doubleList.size()); + for (double _iter101 : struct.doubleList) + { + oprot.writeDouble(_iter101); + } + } + } + if (struct.isSetBinaryList()) { + { + oprot.writeI32(struct.binaryList.size()); + for (byte _iter102 : struct.binaryList) + { + oprot.writeByte(_iter102); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSDynamicOneColumnData struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.deviceType = iprot.readString(); + struct.setDeviceTypeIsSet(true); + struct.dataType = iprot.readString(); + struct.setDataTypeIsSet(true); + struct.length = iprot.readI32(); + struct.setLengthIsSet(true); + { + org.apache.thrift.protocol.TList _list103 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I64, iprot.readI32()); + struct.timeRet = new ArrayList(_list103.size); + long _elem104; + for (int _i105 = 0; _i105 < _list103.size; ++_i105) + { + _elem104 = iprot.readI64(); + struct.timeRet.add(_elem104); + } + } + struct.setTimeRetIsSet(true); + BitSet incoming = iprot.readBitSet(6); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list106 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); + struct.boolList = new ArrayList(_list106.size); + boolean _elem107; + for (int _i108 = 0; _i108 < _list106.size; ++_i108) + { + _elem107 = iprot.readBool(); + struct.boolList.add(_elem107); + } + } + struct.setBoolListIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TList _list109 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.i32List = new ArrayList(_list109.size); + int _elem110; + for (int _i111 = 0; _i111 < _list109.size; ++_i111) + { + _elem110 = iprot.readI32(); + struct.i32List.add(_elem110); + } + } + struct.setI32ListIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list112 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I64, iprot.readI32()); + struct.i64List = new ArrayList(_list112.size); + long _elem113; + for (int _i114 = 0; _i114 < _list112.size; ++_i114) + { + _elem113 = iprot.readI64(); + struct.i64List.add(_elem113); + } + } + struct.setI64ListIsSet(true); + } + if (incoming.get(3)) { + { + org.apache.thrift.protocol.TList _list115 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.DOUBLE, iprot.readI32()); + struct.floatList = new ArrayList(_list115.size); + double _elem116; + for (int _i117 = 0; _i117 < _list115.size; ++_i117) + { + _elem116 = iprot.readDouble(); + struct.floatList.add(_elem116); + } + } + struct.setFloatListIsSet(true); + } + if (incoming.get(4)) { + { + org.apache.thrift.protocol.TList _list118 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.DOUBLE, iprot.readI32()); + struct.doubleList = new ArrayList(_list118.size); + double _elem119; + for (int _i120 = 0; _i120 < _list118.size; ++_i120) + { + _elem119 = iprot.readDouble(); + struct.doubleList.add(_elem119); + } + } + struct.setDoubleListIsSet(true); + } + if (incoming.get(5)) { + { + org.apache.thrift.protocol.TList _list121 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.BYTE, iprot.readI32()); + struct.binaryList = new ArrayList(_list121.size); + byte _elem122; + for (int _i123 = 0; _i123 < _list121.size; ++_i123) + { + _elem122 = iprot.readByte(); + struct.binaryList.add(_elem122); + } + } + struct.setBinaryListIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteBatchStatementReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteBatchStatementReq.java new file mode 100644 index 00000000000..1d8db99c9ec --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteBatchStatementReq.java @@ -0,0 +1,546 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSExecuteBatchStatementReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteBatchStatementReq"); + + private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField STATEMENTS_FIELD_DESC = new org.apache.thrift.protocol.TField("statements", org.apache.thrift.protocol.TType.LIST, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSExecuteBatchStatementReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSExecuteBatchStatementReqTupleSchemeFactory()); + } + + public TS_SessionHandle sessionHandle; // required + public List statements; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SESSION_HANDLE((short)1, "sessionHandle"), + STATEMENTS((short)2, "statements"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SESSION_HANDLE + return SESSION_HANDLE; + case 2: // STATEMENTS + return STATEMENTS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_SessionHandle.class))); + tmpMap.put(_Fields.STATEMENTS, new org.apache.thrift.meta_data.FieldMetaData("statements", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteBatchStatementReq.class, metaDataMap); + } + + public TSExecuteBatchStatementReq() { + } + + public TSExecuteBatchStatementReq( + TS_SessionHandle sessionHandle, + List statements) + { + this(); + this.sessionHandle = sessionHandle; + this.statements = statements; + } + + /** + * Performs a deep copy on other. + */ + public TSExecuteBatchStatementReq(TSExecuteBatchStatementReq other) { + if (other.isSetSessionHandle()) { + this.sessionHandle = new TS_SessionHandle(other.sessionHandle); + } + if (other.isSetStatements()) { + List __this__statements = new ArrayList(other.statements); + this.statements = __this__statements; + } + } + + public TSExecuteBatchStatementReq deepCopy() { + return new TSExecuteBatchStatementReq(this); + } + + @Override + public void clear() { + this.sessionHandle = null; + this.statements = null; + } + + public TS_SessionHandle getSessionHandle() { + return this.sessionHandle; + } + + public TSExecuteBatchStatementReq setSessionHandle(TS_SessionHandle sessionHandle) { + this.sessionHandle = sessionHandle; + return this; + } + + public void unsetSessionHandle() { + this.sessionHandle = null; + } + + /** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetSessionHandle() { + return this.sessionHandle != null; + } + + public void setSessionHandleIsSet(boolean value) { + if (!value) { + this.sessionHandle = null; + } + } + + public int getStatementsSize() { + return (this.statements == null) ? 0 : this.statements.size(); + } + + public java.util.Iterator getStatementsIterator() { + return (this.statements == null) ? null : this.statements.iterator(); + } + + public void addToStatements(String elem) { + if (this.statements == null) { + this.statements = new ArrayList(); + } + this.statements.add(elem); + } + + public List getStatements() { + return this.statements; + } + + public TSExecuteBatchStatementReq setStatements(List statements) { + this.statements = statements; + return this; + } + + public void unsetStatements() { + this.statements = null; + } + + /** Returns true if field statements is set (has been assigned a value) and false otherwise */ + public boolean isSetStatements() { + return this.statements != null; + } + + public void setStatementsIsSet(boolean value) { + if (!value) { + this.statements = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SESSION_HANDLE: + if (value == null) { + unsetSessionHandle(); + } else { + setSessionHandle((TS_SessionHandle)value); + } + break; + + case STATEMENTS: + if (value == null) { + unsetStatements(); + } else { + setStatements((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SESSION_HANDLE: + return getSessionHandle(); + + case STATEMENTS: + return getStatements(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SESSION_HANDLE: + return isSetSessionHandle(); + case STATEMENTS: + return isSetStatements(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSExecuteBatchStatementReq) + return this.equals((TSExecuteBatchStatementReq)that); + return false; + } + + public boolean equals(TSExecuteBatchStatementReq that) { + if (that == null) + return false; + + boolean this_present_sessionHandle = true && this.isSetSessionHandle(); + boolean that_present_sessionHandle = true && that.isSetSessionHandle(); + if (this_present_sessionHandle || that_present_sessionHandle) { + if (!(this_present_sessionHandle && that_present_sessionHandle)) + return false; + if (!this.sessionHandle.equals(that.sessionHandle)) + return false; + } + + boolean this_present_statements = true && this.isSetStatements(); + boolean that_present_statements = true && that.isSetStatements(); + if (this_present_statements || that_present_statements) { + if (!(this_present_statements && that_present_statements)) + return false; + if (!this.statements.equals(that.statements)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_sessionHandle = true && (isSetSessionHandle()); + list.add(present_sessionHandle); + if (present_sessionHandle) + list.add(sessionHandle); + + boolean present_statements = true && (isSetStatements()); + list.add(present_statements); + if (present_statements) + list.add(statements); + + return list.hashCode(); + } + + @Override + public int compareTo(TSExecuteBatchStatementReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSessionHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStatements()).compareTo(other.isSetStatements()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatements()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statements, other.statements); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSExecuteBatchStatementReq("); + boolean first = true; + + sb.append("sessionHandle:"); + if (this.sessionHandle == null) { + sb.append("null"); + } else { + sb.append(this.sessionHandle); + } + first = false; + if (!first) sb.append(", "); + sb.append("statements:"); + if (this.statements == null) { + sb.append("null"); + } else { + sb.append(this.statements); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (sessionHandle == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' was not present! Struct: " + toString()); + } + if (statements == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'statements' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (sessionHandle != null) { + sessionHandle.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSExecuteBatchStatementReqStandardSchemeFactory implements SchemeFactory { + public TSExecuteBatchStatementReqStandardScheme getScheme() { + return new TSExecuteBatchStatementReqStandardScheme(); + } + } + + private static class TSExecuteBatchStatementReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SESSION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // STATEMENTS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list44 = iprot.readListBegin(); + struct.statements = new ArrayList(_list44.size); + String _elem45; + for (int _i46 = 0; _i46 < _list44.size; ++_i46) + { + _elem45 = iprot.readString(); + struct.statements.add(_elem45); + } + iprot.readListEnd(); + } + struct.setStatementsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.sessionHandle != null) { + oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC); + struct.sessionHandle.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.statements != null) { + oprot.writeFieldBegin(STATEMENTS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.statements.size())); + for (String _iter47 : struct.statements) + { + oprot.writeString(_iter47); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSExecuteBatchStatementReqTupleSchemeFactory implements SchemeFactory { + public TSExecuteBatchStatementReqTupleScheme getScheme() { + return new TSExecuteBatchStatementReqTupleScheme(); + } + } + + private static class TSExecuteBatchStatementReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.sessionHandle.write(oprot); + { + oprot.writeI32(struct.statements.size()); + for (String _iter48 : struct.statements) + { + oprot.writeString(_iter48); + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + { + org.apache.thrift.protocol.TList _list49 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.statements = new ArrayList(_list49.size); + String _elem50; + for (int _i51 = 0; _i51 < _list49.size; ++_i51) + { + _elem50 = iprot.readString(); + struct.statements.add(_elem50); + } + } + struct.setStatementsIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteBatchStatementResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteBatchStatementResp.java new file mode 100644 index 00000000000..e26b57a8eb8 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteBatchStatementResp.java @@ -0,0 +1,556 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSExecuteBatchStatementResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteBatchStatementResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField("result", org.apache.thrift.protocol.TType.LIST, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSExecuteBatchStatementRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSExecuteBatchStatementRespTupleSchemeFactory()); + } + + public TS_Status status; // required + public List result; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + RESULT((short)2, "result"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // RESULT + return RESULT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.RESULT}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteBatchStatementResp.class, metaDataMap); + } + + public TSExecuteBatchStatementResp() { + } + + public TSExecuteBatchStatementResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSExecuteBatchStatementResp(TSExecuteBatchStatementResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + if (other.isSetResult()) { + List __this__result = new ArrayList(other.result); + this.result = __this__result; + } + } + + public TSExecuteBatchStatementResp deepCopy() { + return new TSExecuteBatchStatementResp(this); + } + + @Override + public void clear() { + this.status = null; + this.result = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSExecuteBatchStatementResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public int getResultSize() { + return (this.result == null) ? 0 : this.result.size(); + } + + public java.util.Iterator getResultIterator() { + return (this.result == null) ? null : this.result.iterator(); + } + + public void addToResult(int elem) { + if (this.result == null) { + this.result = new ArrayList(); + } + this.result.add(elem); + } + + public List getResult() { + return this.result; + } + + public TSExecuteBatchStatementResp setResult(List result) { + this.result = result; + return this; + } + + public void unsetResult() { + this.result = null; + } + + /** Returns true if field result is set (has been assigned a value) and false otherwise */ + public boolean isSetResult() { + return this.result != null; + } + + public void setResultIsSet(boolean value) { + if (!value) { + this.result = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + case RESULT: + if (value == null) { + unsetResult(); + } else { + setResult((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case RESULT: + return getResult(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case RESULT: + return isSetResult(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSExecuteBatchStatementResp) + return this.equals((TSExecuteBatchStatementResp)that); + return false; + } + + public boolean equals(TSExecuteBatchStatementResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_result = true && this.isSetResult(); + boolean that_present_result = true && that.isSetResult(); + if (this_present_result || that_present_result) { + if (!(this_present_result && that_present_result)) + return false; + if (!this.result.equals(that.result)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + boolean present_result = true && (isSetResult()); + list.add(present_result); + if (present_result) + list.add(result); + + return list.hashCode(); + } + + @Override + public int compareTo(TSExecuteBatchStatementResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetResult()).compareTo(other.isSetResult()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetResult()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, other.result); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSExecuteBatchStatementResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (isSetResult()) { + if (!first) sb.append(", "); + sb.append("result:"); + if (this.result == null) { + sb.append("null"); + } else { + sb.append(this.result); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSExecuteBatchStatementRespStandardSchemeFactory implements SchemeFactory { + public TSExecuteBatchStatementRespStandardScheme getScheme() { + return new TSExecuteBatchStatementRespStandardScheme(); + } + } + + private static class TSExecuteBatchStatementRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // RESULT + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list36 = iprot.readListBegin(); + struct.result = new ArrayList(_list36.size); + int _elem37; + for (int _i38 = 0; _i38 < _list36.size; ++_i38) + { + _elem37 = iprot.readI32(); + struct.result.add(_elem37); + } + iprot.readListEnd(); + } + struct.setResultIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.result != null) { + if (struct.isSetResult()) { + oprot.writeFieldBegin(RESULT_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.result.size())); + for (int _iter39 : struct.result) + { + oprot.writeI32(_iter39); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSExecuteBatchStatementRespTupleSchemeFactory implements SchemeFactory { + public TSExecuteBatchStatementRespTupleScheme getScheme() { + return new TSExecuteBatchStatementRespTupleScheme(); + } + } + + private static class TSExecuteBatchStatementRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + BitSet optionals = new BitSet(); + if (struct.isSetResult()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetResult()) { + { + oprot.writeI32(struct.result.size()); + for (int _iter40 : struct.result) + { + oprot.writeI32(_iter40); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list41 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.result = new ArrayList(_list41.size); + int _elem42; + for (int _i43 = 0; _i43 < _list41.size; ++_i43) + { + _elem42 = iprot.readI32(); + struct.result.add(_elem42); + } + } + struct.setResultIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteStatementReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteStatementReq.java new file mode 100644 index 00000000000..99901c558e5 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteStatementReq.java @@ -0,0 +1,497 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSExecuteStatementReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteStatementReq"); + + private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField STATEMENT_FIELD_DESC = new org.apache.thrift.protocol.TField("statement", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSExecuteStatementReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSExecuteStatementReqTupleSchemeFactory()); + } + + public TS_SessionHandle sessionHandle; // required + public String statement; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SESSION_HANDLE((short)1, "sessionHandle"), + STATEMENT((short)2, "statement"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SESSION_HANDLE + return SESSION_HANDLE; + case 2: // STATEMENT + return STATEMENT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_SessionHandle.class))); + tmpMap.put(_Fields.STATEMENT, new org.apache.thrift.meta_data.FieldMetaData("statement", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteStatementReq.class, metaDataMap); + } + + public TSExecuteStatementReq() { + } + + public TSExecuteStatementReq( + TS_SessionHandle sessionHandle, + String statement) + { + this(); + this.sessionHandle = sessionHandle; + this.statement = statement; + } + + /** + * Performs a deep copy on other. + */ + public TSExecuteStatementReq(TSExecuteStatementReq other) { + if (other.isSetSessionHandle()) { + this.sessionHandle = new TS_SessionHandle(other.sessionHandle); + } + if (other.isSetStatement()) { + this.statement = other.statement; + } + } + + public TSExecuteStatementReq deepCopy() { + return new TSExecuteStatementReq(this); + } + + @Override + public void clear() { + this.sessionHandle = null; + this.statement = null; + } + + public TS_SessionHandle getSessionHandle() { + return this.sessionHandle; + } + + public TSExecuteStatementReq setSessionHandle(TS_SessionHandle sessionHandle) { + this.sessionHandle = sessionHandle; + return this; + } + + public void unsetSessionHandle() { + this.sessionHandle = null; + } + + /** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetSessionHandle() { + return this.sessionHandle != null; + } + + public void setSessionHandleIsSet(boolean value) { + if (!value) { + this.sessionHandle = null; + } + } + + public String getStatement() { + return this.statement; + } + + public TSExecuteStatementReq setStatement(String statement) { + this.statement = statement; + return this; + } + + public void unsetStatement() { + this.statement = null; + } + + /** Returns true if field statement is set (has been assigned a value) and false otherwise */ + public boolean isSetStatement() { + return this.statement != null; + } + + public void setStatementIsSet(boolean value) { + if (!value) { + this.statement = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SESSION_HANDLE: + if (value == null) { + unsetSessionHandle(); + } else { + setSessionHandle((TS_SessionHandle)value); + } + break; + + case STATEMENT: + if (value == null) { + unsetStatement(); + } else { + setStatement((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SESSION_HANDLE: + return getSessionHandle(); + + case STATEMENT: + return getStatement(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SESSION_HANDLE: + return isSetSessionHandle(); + case STATEMENT: + return isSetStatement(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSExecuteStatementReq) + return this.equals((TSExecuteStatementReq)that); + return false; + } + + public boolean equals(TSExecuteStatementReq that) { + if (that == null) + return false; + + boolean this_present_sessionHandle = true && this.isSetSessionHandle(); + boolean that_present_sessionHandle = true && that.isSetSessionHandle(); + if (this_present_sessionHandle || that_present_sessionHandle) { + if (!(this_present_sessionHandle && that_present_sessionHandle)) + return false; + if (!this.sessionHandle.equals(that.sessionHandle)) + return false; + } + + boolean this_present_statement = true && this.isSetStatement(); + boolean that_present_statement = true && that.isSetStatement(); + if (this_present_statement || that_present_statement) { + if (!(this_present_statement && that_present_statement)) + return false; + if (!this.statement.equals(that.statement)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_sessionHandle = true && (isSetSessionHandle()); + list.add(present_sessionHandle); + if (present_sessionHandle) + list.add(sessionHandle); + + boolean present_statement = true && (isSetStatement()); + list.add(present_statement); + if (present_statement) + list.add(statement); + + return list.hashCode(); + } + + @Override + public int compareTo(TSExecuteStatementReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSessionHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStatement()).compareTo(other.isSetStatement()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatement()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statement, other.statement); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSExecuteStatementReq("); + boolean first = true; + + sb.append("sessionHandle:"); + if (this.sessionHandle == null) { + sb.append("null"); + } else { + sb.append(this.sessionHandle); + } + first = false; + if (!first) sb.append(", "); + sb.append("statement:"); + if (this.statement == null) { + sb.append("null"); + } else { + sb.append(this.statement); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (sessionHandle == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' was not present! Struct: " + toString()); + } + if (statement == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'statement' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (sessionHandle != null) { + sessionHandle.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSExecuteStatementReqStandardSchemeFactory implements SchemeFactory { + public TSExecuteStatementReqStandardScheme getScheme() { + return new TSExecuteStatementReqStandardScheme(); + } + } + + private static class TSExecuteStatementReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteStatementReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SESSION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // STATEMENT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.statement = iprot.readString(); + struct.setStatementIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteStatementReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.sessionHandle != null) { + oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC); + struct.sessionHandle.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.statement != null) { + oprot.writeFieldBegin(STATEMENT_FIELD_DESC); + oprot.writeString(struct.statement); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSExecuteStatementReqTupleSchemeFactory implements SchemeFactory { + public TSExecuteStatementReqTupleScheme getScheme() { + return new TSExecuteStatementReqTupleScheme(); + } + } + + private static class TSExecuteStatementReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.sessionHandle.write(oprot); + oprot.writeString(struct.statement); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + struct.statement = iprot.readString(); + struct.setStatementIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteStatementResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteStatementResp.java new file mode 100644 index 00000000000..9a44cae41ba --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSExecuteStatementResp.java @@ -0,0 +1,668 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSExecuteStatementResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteStatementResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSExecuteStatementRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSExecuteStatementRespTupleSchemeFactory()); + } + + public TS_Status status; // required + public TSOperationHandle operationHandle; // optional + public List columns; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + OPERATION_HANDLE((short)2, "operationHandle"), + COLUMNS((short)3, "columns"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // OPERATION_HANDLE + return OPERATION_HANDLE; + case 3: // COLUMNS + return COLUMNS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.OPERATION_HANDLE,_Fields.COLUMNS}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSOperationHandle.class))); + tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteStatementResp.class, metaDataMap); + } + + public TSExecuteStatementResp() { + } + + public TSExecuteStatementResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSExecuteStatementResp(TSExecuteStatementResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + if (other.isSetOperationHandle()) { + this.operationHandle = new TSOperationHandle(other.operationHandle); + } + if (other.isSetColumns()) { + List __this__columns = new ArrayList(other.columns); + this.columns = __this__columns; + } + } + + public TSExecuteStatementResp deepCopy() { + return new TSExecuteStatementResp(this); + } + + @Override + public void clear() { + this.status = null; + this.operationHandle = null; + this.columns = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSExecuteStatementResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public TSOperationHandle getOperationHandle() { + return this.operationHandle; + } + + public TSExecuteStatementResp setOperationHandle(TSOperationHandle operationHandle) { + this.operationHandle = operationHandle; + return this; + } + + public void unsetOperationHandle() { + this.operationHandle = null; + } + + /** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetOperationHandle() { + return this.operationHandle != null; + } + + public void setOperationHandleIsSet(boolean value) { + if (!value) { + this.operationHandle = null; + } + } + + public int getColumnsSize() { + return (this.columns == null) ? 0 : this.columns.size(); + } + + public java.util.Iterator getColumnsIterator() { + return (this.columns == null) ? null : this.columns.iterator(); + } + + public void addToColumns(String elem) { + if (this.columns == null) { + this.columns = new ArrayList(); + } + this.columns.add(elem); + } + + public List getColumns() { + return this.columns; + } + + public TSExecuteStatementResp setColumns(List columns) { + this.columns = columns; + return this; + } + + public void unsetColumns() { + this.columns = null; + } + + /** Returns true if field columns is set (has been assigned a value) and false otherwise */ + public boolean isSetColumns() { + return this.columns != null; + } + + public void setColumnsIsSet(boolean value) { + if (!value) { + this.columns = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + case OPERATION_HANDLE: + if (value == null) { + unsetOperationHandle(); + } else { + setOperationHandle((TSOperationHandle)value); + } + break; + + case COLUMNS: + if (value == null) { + unsetColumns(); + } else { + setColumns((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case OPERATION_HANDLE: + return getOperationHandle(); + + case COLUMNS: + return getColumns(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case OPERATION_HANDLE: + return isSetOperationHandle(); + case COLUMNS: + return isSetColumns(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSExecuteStatementResp) + return this.equals((TSExecuteStatementResp)that); + return false; + } + + public boolean equals(TSExecuteStatementResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_operationHandle = true && this.isSetOperationHandle(); + boolean that_present_operationHandle = true && that.isSetOperationHandle(); + if (this_present_operationHandle || that_present_operationHandle) { + if (!(this_present_operationHandle && that_present_operationHandle)) + return false; + if (!this.operationHandle.equals(that.operationHandle)) + return false; + } + + boolean this_present_columns = true && this.isSetColumns(); + boolean that_present_columns = true && that.isSetColumns(); + if (this_present_columns || that_present_columns) { + if (!(this_present_columns && that_present_columns)) + return false; + if (!this.columns.equals(that.columns)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + boolean present_operationHandle = true && (isSetOperationHandle()); + list.add(present_operationHandle); + if (present_operationHandle) + list.add(operationHandle); + + boolean present_columns = true && (isSetColumns()); + list.add(present_columns); + if (present_columns) + list.add(columns); + + return list.hashCode(); + } + + @Override + public int compareTo(TSExecuteStatementResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOperationHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetColumns()).compareTo(other.isSetColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, other.columns); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSExecuteStatementResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (isSetOperationHandle()) { + if (!first) sb.append(", "); + sb.append("operationHandle:"); + if (this.operationHandle == null) { + sb.append("null"); + } else { + sb.append(this.operationHandle); + } + first = false; + } + if (isSetColumns()) { + if (!first) sb.append(", "); + sb.append("columns:"); + if (this.columns == null) { + sb.append("null"); + } else { + sb.append(this.columns); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + if (operationHandle != null) { + operationHandle.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSExecuteStatementRespStandardSchemeFactory implements SchemeFactory { + public TSExecuteStatementRespStandardScheme getScheme() { + return new TSExecuteStatementRespStandardScheme(); + } + } + + private static class TSExecuteStatementRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteStatementResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // OPERATION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list28 = iprot.readListBegin(); + struct.columns = new ArrayList(_list28.size); + String _elem29; + for (int _i30 = 0; _i30 < _list28.size; ++_i30) + { + _elem29 = iprot.readString(); + struct.columns.add(_elem29); + } + iprot.readListEnd(); + } + struct.setColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteStatementResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.operationHandle != null) { + if (struct.isSetOperationHandle()) { + oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC); + struct.operationHandle.write(oprot); + oprot.writeFieldEnd(); + } + } + if (struct.columns != null) { + if (struct.isSetColumns()) { + oprot.writeFieldBegin(COLUMNS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.columns.size())); + for (String _iter31 : struct.columns) + { + oprot.writeString(_iter31); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSExecuteStatementRespTupleSchemeFactory implements SchemeFactory { + public TSExecuteStatementRespTupleScheme getScheme() { + return new TSExecuteStatementRespTupleScheme(); + } + } + + private static class TSExecuteStatementRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + BitSet optionals = new BitSet(); + if (struct.isSetOperationHandle()) { + optionals.set(0); + } + if (struct.isSetColumns()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetOperationHandle()) { + struct.operationHandle.write(oprot); + } + if (struct.isSetColumns()) { + { + oprot.writeI32(struct.columns.size()); + for (String _iter32 : struct.columns) + { + oprot.writeString(_iter32); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TList _list33 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.columns = new ArrayList(_list33.size); + String _elem34; + for (int _i35 = 0; _i35 < _list33.size; ++_i35) + { + _elem34 = iprot.readString(); + struct.columns.add(_elem34); + } + } + struct.setColumnsIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchMetadataReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchMetadataReq.java new file mode 100644 index 00000000000..e4fbe81dcd5 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchMetadataReq.java @@ -0,0 +1,285 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSFetchMetadataReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchMetadataReq"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSFetchMetadataReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSFetchMetadataReqTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchMetadataReq.class, metaDataMap); + } + + public TSFetchMetadataReq() { + } + + /** + * Performs a deep copy on other. + */ + public TSFetchMetadataReq(TSFetchMetadataReq other) { + } + + public TSFetchMetadataReq deepCopy() { + return new TSFetchMetadataReq(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSFetchMetadataReq) + return this.equals((TSFetchMetadataReq)that); + return false; + } + + public boolean equals(TSFetchMetadataReq that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + return list.hashCode(); + } + + @Override + public int compareTo(TSFetchMetadataReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSFetchMetadataReq("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSFetchMetadataReqStandardSchemeFactory implements SchemeFactory { + public TSFetchMetadataReqStandardScheme getScheme() { + return new TSFetchMetadataReqStandardScheme(); + } + } + + private static class TSFetchMetadataReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchMetadataReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchMetadataReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSFetchMetadataReqTupleSchemeFactory implements SchemeFactory { + public TSFetchMetadataReqTupleScheme getScheme() { + return new TSFetchMetadataReqTupleScheme(); + } + } + + private static class TSFetchMetadataReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchMetadataResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchMetadataResp.java new file mode 100644 index 00000000000..3356b68ab78 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchMetadataResp.java @@ -0,0 +1,918 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSFetchMetadataResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchMetadataResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField SERIES_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("seriesMap", org.apache.thrift.protocol.TType.MAP, (short)2); + private static final org.apache.thrift.protocol.TField DELTA_OBJECT_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("deltaObjectMap", org.apache.thrift.protocol.TType.MAP, (short)3); + private static final org.apache.thrift.protocol.TField METADATA_IN_JSON_FIELD_DESC = new org.apache.thrift.protocol.TField("metadataInJson", org.apache.thrift.protocol.TType.STRING, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSFetchMetadataRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSFetchMetadataRespTupleSchemeFactory()); + } + + public TS_Status status; // required + public Map> seriesMap; // optional + public Map> deltaObjectMap; // optional + public String metadataInJson; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + SERIES_MAP((short)2, "seriesMap"), + DELTA_OBJECT_MAP((short)3, "deltaObjectMap"), + METADATA_IN_JSON((short)4, "metadataInJson"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // SERIES_MAP + return SERIES_MAP; + case 3: // DELTA_OBJECT_MAP + return DELTA_OBJECT_MAP; + case 4: // METADATA_IN_JSON + return METADATA_IN_JSON; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.SERIES_MAP,_Fields.DELTA_OBJECT_MAP,_Fields.METADATA_IN_JSON}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + tmpMap.put(_Fields.SERIES_MAP, new org.apache.thrift.meta_data.FieldMetaData("seriesMap", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSColumnSchema"))))); + tmpMap.put(_Fields.DELTA_OBJECT_MAP, new org.apache.thrift.meta_data.FieldMetaData("deltaObjectMap", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))))); + tmpMap.put(_Fields.METADATA_IN_JSON, new org.apache.thrift.meta_data.FieldMetaData("metadataInJson", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchMetadataResp.class, metaDataMap); + } + + public TSFetchMetadataResp() { + } + + public TSFetchMetadataResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSFetchMetadataResp(TSFetchMetadataResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + if (other.isSetSeriesMap()) { + Map> __this__seriesMap = new HashMap>(other.seriesMap.size()); + for (Map.Entry> other_element : other.seriesMap.entrySet()) { + + String other_element_key = other_element.getKey(); + List other_element_value = other_element.getValue(); + + String __this__seriesMap_copy_key = other_element_key; + + List __this__seriesMap_copy_value = new ArrayList(other_element_value.size()); + for (TSColumnSchema other_element_value_element : other_element_value) { + __this__seriesMap_copy_value.add(other_element_value_element); + } + + __this__seriesMap.put(__this__seriesMap_copy_key, __this__seriesMap_copy_value); + } + this.seriesMap = __this__seriesMap; + } + if (other.isSetDeltaObjectMap()) { + Map> __this__deltaObjectMap = new HashMap>(other.deltaObjectMap.size()); + for (Map.Entry> other_element : other.deltaObjectMap.entrySet()) { + + String other_element_key = other_element.getKey(); + List other_element_value = other_element.getValue(); + + String __this__deltaObjectMap_copy_key = other_element_key; + + List __this__deltaObjectMap_copy_value = new ArrayList(other_element_value); + + __this__deltaObjectMap.put(__this__deltaObjectMap_copy_key, __this__deltaObjectMap_copy_value); + } + this.deltaObjectMap = __this__deltaObjectMap; + } + if (other.isSetMetadataInJson()) { + this.metadataInJson = other.metadataInJson; + } + } + + public TSFetchMetadataResp deepCopy() { + return new TSFetchMetadataResp(this); + } + + @Override + public void clear() { + this.status = null; + this.seriesMap = null; + this.deltaObjectMap = null; + this.metadataInJson = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSFetchMetadataResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public int getSeriesMapSize() { + return (this.seriesMap == null) ? 0 : this.seriesMap.size(); + } + + public void putToSeriesMap(String key, List val) { + if (this.seriesMap == null) { + this.seriesMap = new HashMap>(); + } + this.seriesMap.put(key, val); + } + + public Map> getSeriesMap() { + return this.seriesMap; + } + + public TSFetchMetadataResp setSeriesMap(Map> seriesMap) { + this.seriesMap = seriesMap; + return this; + } + + public void unsetSeriesMap() { + this.seriesMap = null; + } + + /** Returns true if field seriesMap is set (has been assigned a value) and false otherwise */ + public boolean isSetSeriesMap() { + return this.seriesMap != null; + } + + public void setSeriesMapIsSet(boolean value) { + if (!value) { + this.seriesMap = null; + } + } + + public int getDeltaObjectMapSize() { + return (this.deltaObjectMap == null) ? 0 : this.deltaObjectMap.size(); + } + + public void putToDeltaObjectMap(String key, List val) { + if (this.deltaObjectMap == null) { + this.deltaObjectMap = new HashMap>(); + } + this.deltaObjectMap.put(key, val); + } + + public Map> getDeltaObjectMap() { + return this.deltaObjectMap; + } + + public TSFetchMetadataResp setDeltaObjectMap(Map> deltaObjectMap) { + this.deltaObjectMap = deltaObjectMap; + return this; + } + + public void unsetDeltaObjectMap() { + this.deltaObjectMap = null; + } + + /** Returns true if field deltaObjectMap is set (has been assigned a value) and false otherwise */ + public boolean isSetDeltaObjectMap() { + return this.deltaObjectMap != null; + } + + public void setDeltaObjectMapIsSet(boolean value) { + if (!value) { + this.deltaObjectMap = null; + } + } + + public String getMetadataInJson() { + return this.metadataInJson; + } + + public TSFetchMetadataResp setMetadataInJson(String metadataInJson) { + this.metadataInJson = metadataInJson; + return this; + } + + public void unsetMetadataInJson() { + this.metadataInJson = null; + } + + /** Returns true if field metadataInJson is set (has been assigned a value) and false otherwise */ + public boolean isSetMetadataInJson() { + return this.metadataInJson != null; + } + + public void setMetadataInJsonIsSet(boolean value) { + if (!value) { + this.metadataInJson = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + case SERIES_MAP: + if (value == null) { + unsetSeriesMap(); + } else { + setSeriesMap((Map>)value); + } + break; + + case DELTA_OBJECT_MAP: + if (value == null) { + unsetDeltaObjectMap(); + } else { + setDeltaObjectMap((Map>)value); + } + break; + + case METADATA_IN_JSON: + if (value == null) { + unsetMetadataInJson(); + } else { + setMetadataInJson((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case SERIES_MAP: + return getSeriesMap(); + + case DELTA_OBJECT_MAP: + return getDeltaObjectMap(); + + case METADATA_IN_JSON: + return getMetadataInJson(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case SERIES_MAP: + return isSetSeriesMap(); + case DELTA_OBJECT_MAP: + return isSetDeltaObjectMap(); + case METADATA_IN_JSON: + return isSetMetadataInJson(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSFetchMetadataResp) + return this.equals((TSFetchMetadataResp)that); + return false; + } + + public boolean equals(TSFetchMetadataResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_seriesMap = true && this.isSetSeriesMap(); + boolean that_present_seriesMap = true && that.isSetSeriesMap(); + if (this_present_seriesMap || that_present_seriesMap) { + if (!(this_present_seriesMap && that_present_seriesMap)) + return false; + if (!this.seriesMap.equals(that.seriesMap)) + return false; + } + + boolean this_present_deltaObjectMap = true && this.isSetDeltaObjectMap(); + boolean that_present_deltaObjectMap = true && that.isSetDeltaObjectMap(); + if (this_present_deltaObjectMap || that_present_deltaObjectMap) { + if (!(this_present_deltaObjectMap && that_present_deltaObjectMap)) + return false; + if (!this.deltaObjectMap.equals(that.deltaObjectMap)) + return false; + } + + boolean this_present_metadataInJson = true && this.isSetMetadataInJson(); + boolean that_present_metadataInJson = true && that.isSetMetadataInJson(); + if (this_present_metadataInJson || that_present_metadataInJson) { + if (!(this_present_metadataInJson && that_present_metadataInJson)) + return false; + if (!this.metadataInJson.equals(that.metadataInJson)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + boolean present_seriesMap = true && (isSetSeriesMap()); + list.add(present_seriesMap); + if (present_seriesMap) + list.add(seriesMap); + + boolean present_deltaObjectMap = true && (isSetDeltaObjectMap()); + list.add(present_deltaObjectMap); + if (present_deltaObjectMap) + list.add(deltaObjectMap); + + boolean present_metadataInJson = true && (isSetMetadataInJson()); + list.add(present_metadataInJson); + if (present_metadataInJson) + list.add(metadataInJson); + + return list.hashCode(); + } + + @Override + public int compareTo(TSFetchMetadataResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSeriesMap()).compareTo(other.isSetSeriesMap()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSeriesMap()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.seriesMap, other.seriesMap); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDeltaObjectMap()).compareTo(other.isSetDeltaObjectMap()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDeltaObjectMap()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.deltaObjectMap, other.deltaObjectMap); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMetadataInJson()).compareTo(other.isSetMetadataInJson()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMetadataInJson()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.metadataInJson, other.metadataInJson); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSFetchMetadataResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (isSetSeriesMap()) { + if (!first) sb.append(", "); + sb.append("seriesMap:"); + if (this.seriesMap == null) { + sb.append("null"); + } else { + sb.append(this.seriesMap); + } + first = false; + } + if (isSetDeltaObjectMap()) { + if (!first) sb.append(", "); + sb.append("deltaObjectMap:"); + if (this.deltaObjectMap == null) { + sb.append("null"); + } else { + sb.append(this.deltaObjectMap); + } + first = false; + } + if (isSetMetadataInJson()) { + if (!first) sb.append(", "); + sb.append("metadataInJson:"); + if (this.metadataInJson == null) { + sb.append("null"); + } else { + sb.append(this.metadataInJson); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSFetchMetadataRespStandardSchemeFactory implements SchemeFactory { + public TSFetchMetadataRespStandardScheme getScheme() { + return new TSFetchMetadataRespStandardScheme(); + } + } + + private static class TSFetchMetadataRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchMetadataResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SERIES_MAP + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map124 = iprot.readMapBegin(); + struct.seriesMap = new HashMap>(2*_map124.size); + String _key125; + List _val126; + for (int _i127 = 0; _i127 < _map124.size; ++_i127) + { + _key125 = iprot.readString(); + { + org.apache.thrift.protocol.TList _list128 = iprot.readListBegin(); + _val126 = new ArrayList(_list128.size); + TSColumnSchema _elem129; + for (int _i130 = 0; _i130 < _list128.size; ++_i130) + { + _elem129 = new TSColumnSchema(); + _elem129.read(iprot); + _val126.add(_elem129); + } + iprot.readListEnd(); + } + struct.seriesMap.put(_key125, _val126); + } + iprot.readMapEnd(); + } + struct.setSeriesMapIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // DELTA_OBJECT_MAP + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map131 = iprot.readMapBegin(); + struct.deltaObjectMap = new HashMap>(2*_map131.size); + String _key132; + List _val133; + for (int _i134 = 0; _i134 < _map131.size; ++_i134) + { + _key132 = iprot.readString(); + { + org.apache.thrift.protocol.TList _list135 = iprot.readListBegin(); + _val133 = new ArrayList(_list135.size); + String _elem136; + for (int _i137 = 0; _i137 < _list135.size; ++_i137) + { + _elem136 = iprot.readString(); + _val133.add(_elem136); + } + iprot.readListEnd(); + } + struct.deltaObjectMap.put(_key132, _val133); + } + iprot.readMapEnd(); + } + struct.setDeltaObjectMapIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // METADATA_IN_JSON + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.metadataInJson = iprot.readString(); + struct.setMetadataInJsonIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchMetadataResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.seriesMap != null) { + if (struct.isSetSeriesMap()) { + oprot.writeFieldBegin(SERIES_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, struct.seriesMap.size())); + for (Map.Entry> _iter138 : struct.seriesMap.entrySet()) + { + oprot.writeString(_iter138.getKey()); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter138.getValue().size())); + for (TSColumnSchema _iter139 : _iter138.getValue()) + { + _iter139.write(oprot); + } + oprot.writeListEnd(); + } + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.deltaObjectMap != null) { + if (struct.isSetDeltaObjectMap()) { + oprot.writeFieldBegin(DELTA_OBJECT_MAP_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, struct.deltaObjectMap.size())); + for (Map.Entry> _iter140 : struct.deltaObjectMap.entrySet()) + { + oprot.writeString(_iter140.getKey()); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, _iter140.getValue().size())); + for (String _iter141 : _iter140.getValue()) + { + oprot.writeString(_iter141); + } + oprot.writeListEnd(); + } + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.metadataInJson != null) { + if (struct.isSetMetadataInJson()) { + oprot.writeFieldBegin(METADATA_IN_JSON_FIELD_DESC); + oprot.writeString(struct.metadataInJson); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSFetchMetadataRespTupleSchemeFactory implements SchemeFactory { + public TSFetchMetadataRespTupleScheme getScheme() { + return new TSFetchMetadataRespTupleScheme(); + } + } + + private static class TSFetchMetadataRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + BitSet optionals = new BitSet(); + if (struct.isSetSeriesMap()) { + optionals.set(0); + } + if (struct.isSetDeltaObjectMap()) { + optionals.set(1); + } + if (struct.isSetMetadataInJson()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetSeriesMap()) { + { + oprot.writeI32(struct.seriesMap.size()); + for (Map.Entry> _iter142 : struct.seriesMap.entrySet()) + { + oprot.writeString(_iter142.getKey()); + { + oprot.writeI32(_iter142.getValue().size()); + for (TSColumnSchema _iter143 : _iter142.getValue()) + { + _iter143.write(oprot); + } + } + } + } + } + if (struct.isSetDeltaObjectMap()) { + { + oprot.writeI32(struct.deltaObjectMap.size()); + for (Map.Entry> _iter144 : struct.deltaObjectMap.entrySet()) + { + oprot.writeString(_iter144.getKey()); + { + oprot.writeI32(_iter144.getValue().size()); + for (String _iter145 : _iter144.getValue()) + { + oprot.writeString(_iter145); + } + } + } + } + } + if (struct.isSetMetadataInJson()) { + oprot.writeString(struct.metadataInJson); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TMap _map146 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, iprot.readI32()); + struct.seriesMap = new HashMap>(2*_map146.size); + String _key147; + List _val148; + for (int _i149 = 0; _i149 < _map146.size; ++_i149) + { + _key147 = iprot.readString(); + { + org.apache.thrift.protocol.TList _list150 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + _val148 = new ArrayList(_list150.size); + TSColumnSchema _elem151; + for (int _i152 = 0; _i152 < _list150.size; ++_i152) + { + _elem151 = new TSColumnSchema(); + _elem151.read(iprot); + _val148.add(_elem151); + } + } + struct.seriesMap.put(_key147, _val148); + } + } + struct.setSeriesMapIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TMap _map153 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, iprot.readI32()); + struct.deltaObjectMap = new HashMap>(2*_map153.size); + String _key154; + List _val155; + for (int _i156 = 0; _i156 < _map153.size; ++_i156) + { + _key154 = iprot.readString(); + { + org.apache.thrift.protocol.TList _list157 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + _val155 = new ArrayList(_list157.size); + String _elem158; + for (int _i159 = 0; _i159 < _list157.size; ++_i159) + { + _elem158 = iprot.readString(); + _val155.add(_elem158); + } + } + struct.deltaObjectMap.put(_key154, _val155); + } + } + struct.setDeltaObjectMapIsSet(true); + } + if (incoming.get(2)) { + struct.metadataInJson = iprot.readString(); + struct.setMetadataInJsonIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchResultsReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchResultsReq.java new file mode 100644 index 00000000000..abe461ef8ce --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchResultsReq.java @@ -0,0 +1,491 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSFetchResultsReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchResultsReq"); + + private static final org.apache.thrift.protocol.TField STATEMENT_FIELD_DESC = new org.apache.thrift.protocol.TField("statement", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField FETCH_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("fetch_size", org.apache.thrift.protocol.TType.I32, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSFetchResultsReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSFetchResultsReqTupleSchemeFactory()); + } + + public String statement; // required + public int fetch_size; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATEMENT((short)1, "statement"), + FETCH_SIZE((short)2, "fetch_size"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATEMENT + return STATEMENT; + case 2: // FETCH_SIZE + return FETCH_SIZE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __FETCH_SIZE_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATEMENT, new org.apache.thrift.meta_data.FieldMetaData("statement", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.FETCH_SIZE, new org.apache.thrift.meta_data.FieldMetaData("fetch_size", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchResultsReq.class, metaDataMap); + } + + public TSFetchResultsReq() { + } + + public TSFetchResultsReq( + String statement, + int fetch_size) + { + this(); + this.statement = statement; + this.fetch_size = fetch_size; + setFetch_sizeIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public TSFetchResultsReq(TSFetchResultsReq other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetStatement()) { + this.statement = other.statement; + } + this.fetch_size = other.fetch_size; + } + + public TSFetchResultsReq deepCopy() { + return new TSFetchResultsReq(this); + } + + @Override + public void clear() { + this.statement = null; + setFetch_sizeIsSet(false); + this.fetch_size = 0; + } + + public String getStatement() { + return this.statement; + } + + public TSFetchResultsReq setStatement(String statement) { + this.statement = statement; + return this; + } + + public void unsetStatement() { + this.statement = null; + } + + /** Returns true if field statement is set (has been assigned a value) and false otherwise */ + public boolean isSetStatement() { + return this.statement != null; + } + + public void setStatementIsSet(boolean value) { + if (!value) { + this.statement = null; + } + } + + public int getFetch_size() { + return this.fetch_size; + } + + public TSFetchResultsReq setFetch_size(int fetch_size) { + this.fetch_size = fetch_size; + setFetch_sizeIsSet(true); + return this; + } + + public void unsetFetch_size() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __FETCH_SIZE_ISSET_ID); + } + + /** Returns true if field fetch_size is set (has been assigned a value) and false otherwise */ + public boolean isSetFetch_size() { + return EncodingUtils.testBit(__isset_bitfield, __FETCH_SIZE_ISSET_ID); + } + + public void setFetch_sizeIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __FETCH_SIZE_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATEMENT: + if (value == null) { + unsetStatement(); + } else { + setStatement((String)value); + } + break; + + case FETCH_SIZE: + if (value == null) { + unsetFetch_size(); + } else { + setFetch_size((Integer)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATEMENT: + return getStatement(); + + case FETCH_SIZE: + return Integer.valueOf(getFetch_size()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATEMENT: + return isSetStatement(); + case FETCH_SIZE: + return isSetFetch_size(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSFetchResultsReq) + return this.equals((TSFetchResultsReq)that); + return false; + } + + public boolean equals(TSFetchResultsReq that) { + if (that == null) + return false; + + boolean this_present_statement = true && this.isSetStatement(); + boolean that_present_statement = true && that.isSetStatement(); + if (this_present_statement || that_present_statement) { + if (!(this_present_statement && that_present_statement)) + return false; + if (!this.statement.equals(that.statement)) + return false; + } + + boolean this_present_fetch_size = true; + boolean that_present_fetch_size = true; + if (this_present_fetch_size || that_present_fetch_size) { + if (!(this_present_fetch_size && that_present_fetch_size)) + return false; + if (this.fetch_size != that.fetch_size) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_statement = true && (isSetStatement()); + list.add(present_statement); + if (present_statement) + list.add(statement); + + boolean present_fetch_size = true; + list.add(present_fetch_size); + if (present_fetch_size) + list.add(fetch_size); + + return list.hashCode(); + } + + @Override + public int compareTo(TSFetchResultsReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatement()).compareTo(other.isSetStatement()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatement()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statement, other.statement); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetFetch_size()).compareTo(other.isSetFetch_size()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetFetch_size()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fetch_size, other.fetch_size); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSFetchResultsReq("); + boolean first = true; + + sb.append("statement:"); + if (this.statement == null) { + sb.append("null"); + } else { + sb.append(this.statement); + } + first = false; + if (!first) sb.append(", "); + sb.append("fetch_size:"); + sb.append(this.fetch_size); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (statement == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'statement' was not present! Struct: " + toString()); + } + // alas, we cannot check 'fetch_size' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSFetchResultsReqStandardSchemeFactory implements SchemeFactory { + public TSFetchResultsReqStandardScheme getScheme() { + return new TSFetchResultsReqStandardScheme(); + } + } + + private static class TSFetchResultsReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchResultsReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATEMENT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.statement = iprot.readString(); + struct.setStatementIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // FETCH_SIZE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.fetch_size = iprot.readI32(); + struct.setFetch_sizeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetFetch_size()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'fetch_size' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchResultsReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.statement != null) { + oprot.writeFieldBegin(STATEMENT_FIELD_DESC); + oprot.writeString(struct.statement); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(FETCH_SIZE_FIELD_DESC); + oprot.writeI32(struct.fetch_size); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSFetchResultsReqTupleSchemeFactory implements SchemeFactory { + public TSFetchResultsReqTupleScheme getScheme() { + return new TSFetchResultsReqTupleScheme(); + } + } + + private static class TSFetchResultsReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.statement); + oprot.writeI32(struct.fetch_size); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.statement = iprot.readString(); + struct.setStatementIsSet(true); + struct.fetch_size = iprot.readI32(); + struct.setFetch_sizeIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchResultsResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchResultsResp.java new file mode 100644 index 00000000000..5ad7202ef96 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSFetchResultsResp.java @@ -0,0 +1,612 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSFetchResultsResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchResultsResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField HAS_RESULT_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("hasResultSet", org.apache.thrift.protocol.TType.BOOL, (short)2); + private static final org.apache.thrift.protocol.TField QUERY_DATA_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("queryDataSet", org.apache.thrift.protocol.TType.STRUCT, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSFetchResultsRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSFetchResultsRespTupleSchemeFactory()); + } + + public TS_Status status; // required + public boolean hasResultSet; // required + public TSQueryDataSet queryDataSet; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + HAS_RESULT_SET((short)2, "hasResultSet"), + QUERY_DATA_SET((short)3, "queryDataSet"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // HAS_RESULT_SET + return HAS_RESULT_SET; + case 3: // QUERY_DATA_SET + return QUERY_DATA_SET; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __HASRESULTSET_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.QUERY_DATA_SET}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + tmpMap.put(_Fields.HAS_RESULT_SET, new org.apache.thrift.meta_data.FieldMetaData("hasResultSet", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.QUERY_DATA_SET, new org.apache.thrift.meta_data.FieldMetaData("queryDataSet", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSQueryDataSet.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchResultsResp.class, metaDataMap); + } + + public TSFetchResultsResp() { + } + + public TSFetchResultsResp( + TS_Status status, + boolean hasResultSet) + { + this(); + this.status = status; + this.hasResultSet = hasResultSet; + setHasResultSetIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public TSFetchResultsResp(TSFetchResultsResp other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + this.hasResultSet = other.hasResultSet; + if (other.isSetQueryDataSet()) { + this.queryDataSet = new TSQueryDataSet(other.queryDataSet); + } + } + + public TSFetchResultsResp deepCopy() { + return new TSFetchResultsResp(this); + } + + @Override + public void clear() { + this.status = null; + setHasResultSetIsSet(false); + this.hasResultSet = false; + this.queryDataSet = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSFetchResultsResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public boolean isHasResultSet() { + return this.hasResultSet; + } + + public TSFetchResultsResp setHasResultSet(boolean hasResultSet) { + this.hasResultSet = hasResultSet; + setHasResultSetIsSet(true); + return this; + } + + public void unsetHasResultSet() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __HASRESULTSET_ISSET_ID); + } + + /** Returns true if field hasResultSet is set (has been assigned a value) and false otherwise */ + public boolean isSetHasResultSet() { + return EncodingUtils.testBit(__isset_bitfield, __HASRESULTSET_ISSET_ID); + } + + public void setHasResultSetIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __HASRESULTSET_ISSET_ID, value); + } + + public TSQueryDataSet getQueryDataSet() { + return this.queryDataSet; + } + + public TSFetchResultsResp setQueryDataSet(TSQueryDataSet queryDataSet) { + this.queryDataSet = queryDataSet; + return this; + } + + public void unsetQueryDataSet() { + this.queryDataSet = null; + } + + /** Returns true if field queryDataSet is set (has been assigned a value) and false otherwise */ + public boolean isSetQueryDataSet() { + return this.queryDataSet != null; + } + + public void setQueryDataSetIsSet(boolean value) { + if (!value) { + this.queryDataSet = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + case HAS_RESULT_SET: + if (value == null) { + unsetHasResultSet(); + } else { + setHasResultSet((Boolean)value); + } + break; + + case QUERY_DATA_SET: + if (value == null) { + unsetQueryDataSet(); + } else { + setQueryDataSet((TSQueryDataSet)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case HAS_RESULT_SET: + return Boolean.valueOf(isHasResultSet()); + + case QUERY_DATA_SET: + return getQueryDataSet(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case HAS_RESULT_SET: + return isSetHasResultSet(); + case QUERY_DATA_SET: + return isSetQueryDataSet(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSFetchResultsResp) + return this.equals((TSFetchResultsResp)that); + return false; + } + + public boolean equals(TSFetchResultsResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_hasResultSet = true; + boolean that_present_hasResultSet = true; + if (this_present_hasResultSet || that_present_hasResultSet) { + if (!(this_present_hasResultSet && that_present_hasResultSet)) + return false; + if (this.hasResultSet != that.hasResultSet) + return false; + } + + boolean this_present_queryDataSet = true && this.isSetQueryDataSet(); + boolean that_present_queryDataSet = true && that.isSetQueryDataSet(); + if (this_present_queryDataSet || that_present_queryDataSet) { + if (!(this_present_queryDataSet && that_present_queryDataSet)) + return false; + if (!this.queryDataSet.equals(that.queryDataSet)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + boolean present_hasResultSet = true; + list.add(present_hasResultSet); + if (present_hasResultSet) + list.add(hasResultSet); + + boolean present_queryDataSet = true && (isSetQueryDataSet()); + list.add(present_queryDataSet); + if (present_queryDataSet) + list.add(queryDataSet); + + return list.hashCode(); + } + + @Override + public int compareTo(TSFetchResultsResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetHasResultSet()).compareTo(other.isSetHasResultSet()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetHasResultSet()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hasResultSet, other.hasResultSet); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetQueryDataSet()).compareTo(other.isSetQueryDataSet()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetQueryDataSet()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryDataSet, other.queryDataSet); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSFetchResultsResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (!first) sb.append(", "); + sb.append("hasResultSet:"); + sb.append(this.hasResultSet); + first = false; + if (isSetQueryDataSet()) { + if (!first) sb.append(", "); + sb.append("queryDataSet:"); + if (this.queryDataSet == null) { + sb.append("null"); + } else { + sb.append(this.queryDataSet); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // alas, we cannot check 'hasResultSet' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + if (status != null) { + status.validate(); + } + if (queryDataSet != null) { + queryDataSet.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSFetchResultsRespStandardSchemeFactory implements SchemeFactory { + public TSFetchResultsRespStandardScheme getScheme() { + return new TSFetchResultsRespStandardScheme(); + } + } + + private static class TSFetchResultsRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchResultsResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // HAS_RESULT_SET + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.hasResultSet = iprot.readBool(); + struct.setHasResultSetIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // QUERY_DATA_SET + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.queryDataSet = new TSQueryDataSet(); + struct.queryDataSet.read(iprot); + struct.setQueryDataSetIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetHasResultSet()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'hasResultSet' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchResultsResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(HAS_RESULT_SET_FIELD_DESC); + oprot.writeBool(struct.hasResultSet); + oprot.writeFieldEnd(); + if (struct.queryDataSet != null) { + if (struct.isSetQueryDataSet()) { + oprot.writeFieldBegin(QUERY_DATA_SET_FIELD_DESC); + struct.queryDataSet.write(oprot); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSFetchResultsRespTupleSchemeFactory implements SchemeFactory { + public TSFetchResultsRespTupleScheme getScheme() { + return new TSFetchResultsRespTupleScheme(); + } + } + + private static class TSFetchResultsRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + oprot.writeBool(struct.hasResultSet); + BitSet optionals = new BitSet(); + if (struct.isSetQueryDataSet()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetQueryDataSet()) { + struct.queryDataSet.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + struct.hasResultSet = iprot.readBool(); + struct.setHasResultSetIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.queryDataSet = new TSQueryDataSet(); + struct.queryDataSet.read(iprot); + struct.setQueryDataSetIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSGetOperationStatusReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSGetOperationStatusReq.java new file mode 100644 index 00000000000..1ab598c7b6e --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSGetOperationStatusReq.java @@ -0,0 +1,393 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSGetOperationStatusReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSGetOperationStatusReq"); + + private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSGetOperationStatusReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSGetOperationStatusReqTupleSchemeFactory()); + } + + public TSOperationHandle operationHandle; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + OPERATION_HANDLE((short)1, "operationHandle"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // OPERATION_HANDLE + return OPERATION_HANDLE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOperationHandle"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSGetOperationStatusReq.class, metaDataMap); + } + + public TSGetOperationStatusReq() { + } + + public TSGetOperationStatusReq( + TSOperationHandle operationHandle) + { + this(); + this.operationHandle = operationHandle; + } + + /** + * Performs a deep copy on other. + */ + public TSGetOperationStatusReq(TSGetOperationStatusReq other) { + if (other.isSetOperationHandle()) { + this.operationHandle = other.operationHandle; + } + } + + public TSGetOperationStatusReq deepCopy() { + return new TSGetOperationStatusReq(this); + } + + @Override + public void clear() { + this.operationHandle = null; + } + + public TSOperationHandle getOperationHandle() { + return this.operationHandle; + } + + public TSGetOperationStatusReq setOperationHandle(TSOperationHandle operationHandle) { + this.operationHandle = operationHandle; + return this; + } + + public void unsetOperationHandle() { + this.operationHandle = null; + } + + /** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetOperationHandle() { + return this.operationHandle != null; + } + + public void setOperationHandleIsSet(boolean value) { + if (!value) { + this.operationHandle = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case OPERATION_HANDLE: + if (value == null) { + unsetOperationHandle(); + } else { + setOperationHandle((TSOperationHandle)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case OPERATION_HANDLE: + return getOperationHandle(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case OPERATION_HANDLE: + return isSetOperationHandle(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSGetOperationStatusReq) + return this.equals((TSGetOperationStatusReq)that); + return false; + } + + public boolean equals(TSGetOperationStatusReq that) { + if (that == null) + return false; + + boolean this_present_operationHandle = true && this.isSetOperationHandle(); + boolean that_present_operationHandle = true && that.isSetOperationHandle(); + if (this_present_operationHandle || that_present_operationHandle) { + if (!(this_present_operationHandle && that_present_operationHandle)) + return false; + if (!this.operationHandle.equals(that.operationHandle)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_operationHandle = true && (isSetOperationHandle()); + list.add(present_operationHandle); + if (present_operationHandle) + list.add(operationHandle); + + return list.hashCode(); + } + + @Override + public int compareTo(TSGetOperationStatusReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOperationHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSGetOperationStatusReq("); + boolean first = true; + + sb.append("operationHandle:"); + if (this.operationHandle == null) { + sb.append("null"); + } else { + sb.append(this.operationHandle); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (operationHandle == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationHandle' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSGetOperationStatusReqStandardSchemeFactory implements SchemeFactory { + public TSGetOperationStatusReqStandardScheme getScheme() { + return new TSGetOperationStatusReqStandardScheme(); + } + } + + private static class TSGetOperationStatusReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // OPERATION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.operationHandle != null) { + oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC); + struct.operationHandle.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSGetOperationStatusReqTupleSchemeFactory implements SchemeFactory { + public TSGetOperationStatusReqTupleScheme getScheme() { + return new TSGetOperationStatusReqTupleScheme(); + } + } + + private static class TSGetOperationStatusReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.operationHandle.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.operationHandle = new TSOperationHandle(); + struct.operationHandle.read(iprot); + struct.setOperationHandleIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSGetOperationStatusResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSGetOperationStatusResp.java new file mode 100644 index 00000000000..d2d58c70775 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSGetOperationStatusResp.java @@ -0,0 +1,396 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSGetOperationStatusResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSGetOperationStatusResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSGetOperationStatusRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSGetOperationStatusRespTupleSchemeFactory()); + } + + public TS_Status status; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSGetOperationStatusResp.class, metaDataMap); + } + + public TSGetOperationStatusResp() { + } + + public TSGetOperationStatusResp( + TS_Status status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on other. + */ + public TSGetOperationStatusResp(TSGetOperationStatusResp other) { + if (other.isSetStatus()) { + this.status = new TS_Status(other.status); + } + } + + public TSGetOperationStatusResp deepCopy() { + return new TSGetOperationStatusResp(this); + } + + @Override + public void clear() { + this.status = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSGetOperationStatusResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSGetOperationStatusResp) + return this.equals((TSGetOperationStatusResp)that); + return false; + } + + public boolean equals(TSGetOperationStatusResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + return list.hashCode(); + } + + @Override + public int compareTo(TSGetOperationStatusResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSGetOperationStatusResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (status != null) { + status.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSGetOperationStatusRespStandardSchemeFactory implements SchemeFactory { + public TSGetOperationStatusRespStandardScheme getScheme() { + return new TSGetOperationStatusRespStandardScheme(); + } + } + + private static class TSGetOperationStatusRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSGetOperationStatusRespTupleSchemeFactory implements SchemeFactory { + public TSGetOperationStatusRespTupleScheme getScheme() { + return new TSGetOperationStatusRespTupleScheme(); + } + } + + private static class TSGetOperationStatusRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSHandleIdentifier.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSHandleIdentifier.java new file mode 100644 index 00000000000..e867505daa0 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSHandleIdentifier.java @@ -0,0 +1,512 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSHandleIdentifier implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSHandleIdentifier"); + + private static final org.apache.thrift.protocol.TField GUID_FIELD_DESC = new org.apache.thrift.protocol.TField("guid", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("secret", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSHandleIdentifierStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSHandleIdentifierTupleSchemeFactory()); + } + + public ByteBuffer guid; // required + public ByteBuffer secret; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + GUID((short)1, "guid"), + SECRET((short)2, "secret"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // GUID + return GUID; + case 2: // SECRET + return SECRET; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.GUID, new org.apache.thrift.meta_data.FieldMetaData("guid", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.SECRET, new org.apache.thrift.meta_data.FieldMetaData("secret", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSHandleIdentifier.class, metaDataMap); + } + + public TSHandleIdentifier() { + } + + public TSHandleIdentifier( + ByteBuffer guid, + ByteBuffer secret) + { + this(); + this.guid = org.apache.thrift.TBaseHelper.copyBinary(guid); + this.secret = org.apache.thrift.TBaseHelper.copyBinary(secret); + } + + /** + * Performs a deep copy on other. + */ + public TSHandleIdentifier(TSHandleIdentifier other) { + if (other.isSetGuid()) { + this.guid = org.apache.thrift.TBaseHelper.copyBinary(other.guid); + } + if (other.isSetSecret()) { + this.secret = org.apache.thrift.TBaseHelper.copyBinary(other.secret); + } + } + + public TSHandleIdentifier deepCopy() { + return new TSHandleIdentifier(this); + } + + @Override + public void clear() { + this.guid = null; + this.secret = null; + } + + public byte[] getGuid() { + setGuid(org.apache.thrift.TBaseHelper.rightSize(guid)); + return guid == null ? null : guid.array(); + } + + public ByteBuffer bufferForGuid() { + return org.apache.thrift.TBaseHelper.copyBinary(guid); + } + + public TSHandleIdentifier setGuid(byte[] guid) { + this.guid = guid == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(guid, guid.length)); + return this; + } + + public TSHandleIdentifier setGuid(ByteBuffer guid) { + this.guid = org.apache.thrift.TBaseHelper.copyBinary(guid); + return this; + } + + public void unsetGuid() { + this.guid = null; + } + + /** Returns true if field guid is set (has been assigned a value) and false otherwise */ + public boolean isSetGuid() { + return this.guid != null; + } + + public void setGuidIsSet(boolean value) { + if (!value) { + this.guid = null; + } + } + + public byte[] getSecret() { + setSecret(org.apache.thrift.TBaseHelper.rightSize(secret)); + return secret == null ? null : secret.array(); + } + + public ByteBuffer bufferForSecret() { + return org.apache.thrift.TBaseHelper.copyBinary(secret); + } + + public TSHandleIdentifier setSecret(byte[] secret) { + this.secret = secret == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(secret, secret.length)); + return this; + } + + public TSHandleIdentifier setSecret(ByteBuffer secret) { + this.secret = org.apache.thrift.TBaseHelper.copyBinary(secret); + return this; + } + + public void unsetSecret() { + this.secret = null; + } + + /** Returns true if field secret is set (has been assigned a value) and false otherwise */ + public boolean isSetSecret() { + return this.secret != null; + } + + public void setSecretIsSet(boolean value) { + if (!value) { + this.secret = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case GUID: + if (value == null) { + unsetGuid(); + } else { + setGuid((ByteBuffer)value); + } + break; + + case SECRET: + if (value == null) { + unsetSecret(); + } else { + setSecret((ByteBuffer)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case GUID: + return getGuid(); + + case SECRET: + return getSecret(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case GUID: + return isSetGuid(); + case SECRET: + return isSetSecret(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSHandleIdentifier) + return this.equals((TSHandleIdentifier)that); + return false; + } + + public boolean equals(TSHandleIdentifier that) { + if (that == null) + return false; + + boolean this_present_guid = true && this.isSetGuid(); + boolean that_present_guid = true && that.isSetGuid(); + if (this_present_guid || that_present_guid) { + if (!(this_present_guid && that_present_guid)) + return false; + if (!this.guid.equals(that.guid)) + return false; + } + + boolean this_present_secret = true && this.isSetSecret(); + boolean that_present_secret = true && that.isSetSecret(); + if (this_present_secret || that_present_secret) { + if (!(this_present_secret && that_present_secret)) + return false; + if (!this.secret.equals(that.secret)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_guid = true && (isSetGuid()); + list.add(present_guid); + if (present_guid) + list.add(guid); + + boolean present_secret = true && (isSetSecret()); + list.add(present_secret); + if (present_secret) + list.add(secret); + + return list.hashCode(); + } + + @Override + public int compareTo(TSHandleIdentifier other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetGuid()).compareTo(other.isSetGuid()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetGuid()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.guid, other.guid); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSecret()).compareTo(other.isSetSecret()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSecret()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.secret, other.secret); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSHandleIdentifier("); + boolean first = true; + + sb.append("guid:"); + if (this.guid == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.guid, sb); + } + first = false; + if (!first) sb.append(", "); + sb.append("secret:"); + if (this.secret == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.secret, sb); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (guid == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'guid' was not present! Struct: " + toString()); + } + if (secret == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'secret' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSHandleIdentifierStandardSchemeFactory implements SchemeFactory { + public TSHandleIdentifierStandardScheme getScheme() { + return new TSHandleIdentifierStandardScheme(); + } + } + + private static class TSHandleIdentifierStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSHandleIdentifier struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // GUID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.guid = iprot.readBinary(); + struct.setGuidIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SECRET + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.secret = iprot.readBinary(); + struct.setSecretIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSHandleIdentifier struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.guid != null) { + oprot.writeFieldBegin(GUID_FIELD_DESC); + oprot.writeBinary(struct.guid); + oprot.writeFieldEnd(); + } + if (struct.secret != null) { + oprot.writeFieldBegin(SECRET_FIELD_DESC); + oprot.writeBinary(struct.secret); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSHandleIdentifierTupleSchemeFactory implements SchemeFactory { + public TSHandleIdentifierTupleScheme getScheme() { + return new TSHandleIdentifierTupleScheme(); + } + } + + private static class TSHandleIdentifierTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSHandleIdentifier struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeBinary(struct.guid); + oprot.writeBinary(struct.secret); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSHandleIdentifier struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.guid = iprot.readBinary(); + struct.setGuidIsSet(true); + struct.secret = iprot.readBinary(); + struct.setSecretIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSIService.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSIService.java new file mode 100644 index 00000000000..c566579d6d1 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSIService.java @@ -0,0 +1,8700 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSIService { + + public interface Iface { + + public TSOpenSessionResp OpenSession(TSOpenSessionReq req) throws org.apache.thrift.TException; + + public TSCloseSessionResp CloseSession(TSCloseSessionReq req) throws org.apache.thrift.TException; + + public TSExecuteStatementResp ExecuteStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException; + + public TSExecuteBatchStatementResp ExecuteBatchStatement(TSExecuteBatchStatementReq req) throws org.apache.thrift.TException; + + public TSExecuteStatementResp ExecuteQueryStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException; + + public TSExecuteStatementResp ExecuteUpdateStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException; + + public TSFetchResultsResp FetchResults(TSFetchResultsReq req) throws org.apache.thrift.TException; + + public TSFetchMetadataResp FetchMetadata(TSFetchMetadataReq req) throws org.apache.thrift.TException; + + public TSCancelOperationResp CancelOperation(TSCancelOperationReq req) throws org.apache.thrift.TException; + + public TSCloseOperationResp CloseOperation(TSCloseOperationReq req) throws org.apache.thrift.TException; + + } + + public interface AsyncIface { + + public void OpenSession(TSOpenSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void CloseSession(TSCloseSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void ExecuteStatement(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void ExecuteBatchStatement(TSExecuteBatchStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void ExecuteQueryStatement(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void ExecuteUpdateStatement(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void FetchResults(TSFetchResultsReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void FetchMetadata(TSFetchMetadataReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void CancelOperation(TSCancelOperationReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void CloseOperation(TSCloseOperationReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + } + + public static class Client extends org.apache.thrift.TServiceClient implements Iface { + public static class Factory implements org.apache.thrift.TServiceClientFactory { + public Factory() {} + public Client getClient(org.apache.thrift.protocol.TProtocol prot) { + return new Client(prot); + } + public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + return new Client(iprot, oprot); + } + } + + public Client(org.apache.thrift.protocol.TProtocol prot) + { + super(prot, prot); + } + + public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + super(iprot, oprot); + } + + public TSOpenSessionResp OpenSession(TSOpenSessionReq req) throws org.apache.thrift.TException + { + send_OpenSession(req); + return recv_OpenSession(); + } + + public void send_OpenSession(TSOpenSessionReq req) throws org.apache.thrift.TException + { + OpenSession_args args = new OpenSession_args(); + args.setReq(req); + sendBase("OpenSession", args); + } + + public TSOpenSessionResp recv_OpenSession() throws org.apache.thrift.TException + { + OpenSession_result result = new OpenSession_result(); + receiveBase(result, "OpenSession"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "OpenSession failed: unknown result"); + } + + public TSCloseSessionResp CloseSession(TSCloseSessionReq req) throws org.apache.thrift.TException + { + send_CloseSession(req); + return recv_CloseSession(); + } + + public void send_CloseSession(TSCloseSessionReq req) throws org.apache.thrift.TException + { + CloseSession_args args = new CloseSession_args(); + args.setReq(req); + sendBase("CloseSession", args); + } + + public TSCloseSessionResp recv_CloseSession() throws org.apache.thrift.TException + { + CloseSession_result result = new CloseSession_result(); + receiveBase(result, "CloseSession"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "CloseSession failed: unknown result"); + } + + public TSExecuteStatementResp ExecuteStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException + { + send_ExecuteStatement(req); + return recv_ExecuteStatement(); + } + + public void send_ExecuteStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException + { + ExecuteStatement_args args = new ExecuteStatement_args(); + args.setReq(req); + sendBase("ExecuteStatement", args); + } + + public TSExecuteStatementResp recv_ExecuteStatement() throws org.apache.thrift.TException + { + ExecuteStatement_result result = new ExecuteStatement_result(); + receiveBase(result, "ExecuteStatement"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "ExecuteStatement failed: unknown result"); + } + + public TSExecuteBatchStatementResp ExecuteBatchStatement(TSExecuteBatchStatementReq req) throws org.apache.thrift.TException + { + send_ExecuteBatchStatement(req); + return recv_ExecuteBatchStatement(); + } + + public void send_ExecuteBatchStatement(TSExecuteBatchStatementReq req) throws org.apache.thrift.TException + { + ExecuteBatchStatement_args args = new ExecuteBatchStatement_args(); + args.setReq(req); + sendBase("ExecuteBatchStatement", args); + } + + public TSExecuteBatchStatementResp recv_ExecuteBatchStatement() throws org.apache.thrift.TException + { + ExecuteBatchStatement_result result = new ExecuteBatchStatement_result(); + receiveBase(result, "ExecuteBatchStatement"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "ExecuteBatchStatement failed: unknown result"); + } + + public TSExecuteStatementResp ExecuteQueryStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException + { + send_ExecuteQueryStatement(req); + return recv_ExecuteQueryStatement(); + } + + public void send_ExecuteQueryStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException + { + ExecuteQueryStatement_args args = new ExecuteQueryStatement_args(); + args.setReq(req); + sendBase("ExecuteQueryStatement", args); + } + + public TSExecuteStatementResp recv_ExecuteQueryStatement() throws org.apache.thrift.TException + { + ExecuteQueryStatement_result result = new ExecuteQueryStatement_result(); + receiveBase(result, "ExecuteQueryStatement"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "ExecuteQueryStatement failed: unknown result"); + } + + public TSExecuteStatementResp ExecuteUpdateStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException + { + send_ExecuteUpdateStatement(req); + return recv_ExecuteUpdateStatement(); + } + + public void send_ExecuteUpdateStatement(TSExecuteStatementReq req) throws org.apache.thrift.TException + { + ExecuteUpdateStatement_args args = new ExecuteUpdateStatement_args(); + args.setReq(req); + sendBase("ExecuteUpdateStatement", args); + } + + public TSExecuteStatementResp recv_ExecuteUpdateStatement() throws org.apache.thrift.TException + { + ExecuteUpdateStatement_result result = new ExecuteUpdateStatement_result(); + receiveBase(result, "ExecuteUpdateStatement"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "ExecuteUpdateStatement failed: unknown result"); + } + + public TSFetchResultsResp FetchResults(TSFetchResultsReq req) throws org.apache.thrift.TException + { + send_FetchResults(req); + return recv_FetchResults(); + } + + public void send_FetchResults(TSFetchResultsReq req) throws org.apache.thrift.TException + { + FetchResults_args args = new FetchResults_args(); + args.setReq(req); + sendBase("FetchResults", args); + } + + public TSFetchResultsResp recv_FetchResults() throws org.apache.thrift.TException + { + FetchResults_result result = new FetchResults_result(); + receiveBase(result, "FetchResults"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "FetchResults failed: unknown result"); + } + + public TSFetchMetadataResp FetchMetadata(TSFetchMetadataReq req) throws org.apache.thrift.TException + { + send_FetchMetadata(req); + return recv_FetchMetadata(); + } + + public void send_FetchMetadata(TSFetchMetadataReq req) throws org.apache.thrift.TException + { + FetchMetadata_args args = new FetchMetadata_args(); + args.setReq(req); + sendBase("FetchMetadata", args); + } + + public TSFetchMetadataResp recv_FetchMetadata() throws org.apache.thrift.TException + { + FetchMetadata_result result = new FetchMetadata_result(); + receiveBase(result, "FetchMetadata"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "FetchMetadata failed: unknown result"); + } + + public TSCancelOperationResp CancelOperation(TSCancelOperationReq req) throws org.apache.thrift.TException + { + send_CancelOperation(req); + return recv_CancelOperation(); + } + + public void send_CancelOperation(TSCancelOperationReq req) throws org.apache.thrift.TException + { + CancelOperation_args args = new CancelOperation_args(); + args.setReq(req); + sendBase("CancelOperation", args); + } + + public TSCancelOperationResp recv_CancelOperation() throws org.apache.thrift.TException + { + CancelOperation_result result = new CancelOperation_result(); + receiveBase(result, "CancelOperation"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "CancelOperation failed: unknown result"); + } + + public TSCloseOperationResp CloseOperation(TSCloseOperationReq req) throws org.apache.thrift.TException + { + send_CloseOperation(req); + return recv_CloseOperation(); + } + + public void send_CloseOperation(TSCloseOperationReq req) throws org.apache.thrift.TException + { + CloseOperation_args args = new CloseOperation_args(); + args.setReq(req); + sendBase("CloseOperation", args); + } + + public TSCloseOperationResp recv_CloseOperation() throws org.apache.thrift.TException + { + CloseOperation_result result = new CloseOperation_result(); + receiveBase(result, "CloseOperation"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "CloseOperation failed: unknown result"); + } + + } + public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { + public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { + private org.apache.thrift.async.TAsyncClientManager clientManager; + private org.apache.thrift.protocol.TProtocolFactory protocolFactory; + public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { + this.clientManager = clientManager; + this.protocolFactory = protocolFactory; + } + public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { + return new AsyncClient(protocolFactory, clientManager, transport); + } + } + + public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { + super(protocolFactory, clientManager, transport); + } + + public void OpenSession(TSOpenSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + OpenSession_call method_call = new OpenSession_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class OpenSession_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSOpenSessionReq req; + public OpenSession_call(TSOpenSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("OpenSession", org.apache.thrift.protocol.TMessageType.CALL, 0)); + OpenSession_args args = new OpenSession_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSOpenSessionResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_OpenSession(); + } + } + + public void CloseSession(TSCloseSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + CloseSession_call method_call = new CloseSession_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class CloseSession_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSCloseSessionReq req; + public CloseSession_call(TSCloseSessionReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("CloseSession", org.apache.thrift.protocol.TMessageType.CALL, 0)); + CloseSession_args args = new CloseSession_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSCloseSessionResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_CloseSession(); + } + } + + public void ExecuteStatement(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + ExecuteStatement_call method_call = new ExecuteStatement_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class ExecuteStatement_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSExecuteStatementReq req; + public ExecuteStatement_call(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("ExecuteStatement", org.apache.thrift.protocol.TMessageType.CALL, 0)); + ExecuteStatement_args args = new ExecuteStatement_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSExecuteStatementResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_ExecuteStatement(); + } + } + + public void ExecuteBatchStatement(TSExecuteBatchStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + ExecuteBatchStatement_call method_call = new ExecuteBatchStatement_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class ExecuteBatchStatement_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSExecuteBatchStatementReq req; + public ExecuteBatchStatement_call(TSExecuteBatchStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("ExecuteBatchStatement", org.apache.thrift.protocol.TMessageType.CALL, 0)); + ExecuteBatchStatement_args args = new ExecuteBatchStatement_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSExecuteBatchStatementResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_ExecuteBatchStatement(); + } + } + + public void ExecuteQueryStatement(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + ExecuteQueryStatement_call method_call = new ExecuteQueryStatement_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class ExecuteQueryStatement_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSExecuteStatementReq req; + public ExecuteQueryStatement_call(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("ExecuteQueryStatement", org.apache.thrift.protocol.TMessageType.CALL, 0)); + ExecuteQueryStatement_args args = new ExecuteQueryStatement_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSExecuteStatementResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_ExecuteQueryStatement(); + } + } + + public void ExecuteUpdateStatement(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + ExecuteUpdateStatement_call method_call = new ExecuteUpdateStatement_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class ExecuteUpdateStatement_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSExecuteStatementReq req; + public ExecuteUpdateStatement_call(TSExecuteStatementReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("ExecuteUpdateStatement", org.apache.thrift.protocol.TMessageType.CALL, 0)); + ExecuteUpdateStatement_args args = new ExecuteUpdateStatement_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSExecuteStatementResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_ExecuteUpdateStatement(); + } + } + + public void FetchResults(TSFetchResultsReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + FetchResults_call method_call = new FetchResults_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class FetchResults_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSFetchResultsReq req; + public FetchResults_call(TSFetchResultsReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("FetchResults", org.apache.thrift.protocol.TMessageType.CALL, 0)); + FetchResults_args args = new FetchResults_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSFetchResultsResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_FetchResults(); + } + } + + public void FetchMetadata(TSFetchMetadataReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + FetchMetadata_call method_call = new FetchMetadata_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class FetchMetadata_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSFetchMetadataReq req; + public FetchMetadata_call(TSFetchMetadataReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("FetchMetadata", org.apache.thrift.protocol.TMessageType.CALL, 0)); + FetchMetadata_args args = new FetchMetadata_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSFetchMetadataResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_FetchMetadata(); + } + } + + public void CancelOperation(TSCancelOperationReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + CancelOperation_call method_call = new CancelOperation_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class CancelOperation_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSCancelOperationReq req; + public CancelOperation_call(TSCancelOperationReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("CancelOperation", org.apache.thrift.protocol.TMessageType.CALL, 0)); + CancelOperation_args args = new CancelOperation_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSCancelOperationResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_CancelOperation(); + } + } + + public void CloseOperation(TSCloseOperationReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + CloseOperation_call method_call = new CloseOperation_call(req, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class CloseOperation_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSCloseOperationReq req; + public CloseOperation_call(TSCloseOperationReq req, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.req = req; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("CloseOperation", org.apache.thrift.protocol.TMessageType.CALL, 0)); + CloseOperation_args args = new CloseOperation_args(); + args.setReq(req); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSCloseOperationResp getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_CloseOperation(); + } + } + + } + + public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName()); + public Processor(I iface) { + super(iface, getProcessMap(new HashMap>())); + } + + protected Processor(I iface, Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static Map> getProcessMap(Map> processMap) { + processMap.put("OpenSession", new OpenSession()); + processMap.put("CloseSession", new CloseSession()); + processMap.put("ExecuteStatement", new ExecuteStatement()); + processMap.put("ExecuteBatchStatement", new ExecuteBatchStatement()); + processMap.put("ExecuteQueryStatement", new ExecuteQueryStatement()); + processMap.put("ExecuteUpdateStatement", new ExecuteUpdateStatement()); + processMap.put("FetchResults", new FetchResults()); + processMap.put("FetchMetadata", new FetchMetadata()); + processMap.put("CancelOperation", new CancelOperation()); + processMap.put("CloseOperation", new CloseOperation()); + return processMap; + } + + public static class OpenSession extends org.apache.thrift.ProcessFunction { + public OpenSession() { + super("OpenSession"); + } + + public OpenSession_args getEmptyArgsInstance() { + return new OpenSession_args(); + } + + protected boolean isOneway() { + return false; + } + + public OpenSession_result getResult(I iface, OpenSession_args args) throws org.apache.thrift.TException { + OpenSession_result result = new OpenSession_result(); + result.success = iface.OpenSession(args.req); + return result; + } + } + + public static class CloseSession extends org.apache.thrift.ProcessFunction { + public CloseSession() { + super("CloseSession"); + } + + public CloseSession_args getEmptyArgsInstance() { + return new CloseSession_args(); + } + + protected boolean isOneway() { + return false; + } + + public CloseSession_result getResult(I iface, CloseSession_args args) throws org.apache.thrift.TException { + CloseSession_result result = new CloseSession_result(); + result.success = iface.CloseSession(args.req); + return result; + } + } + + public static class ExecuteStatement extends org.apache.thrift.ProcessFunction { + public ExecuteStatement() { + super("ExecuteStatement"); + } + + public ExecuteStatement_args getEmptyArgsInstance() { + return new ExecuteStatement_args(); + } + + protected boolean isOneway() { + return false; + } + + public ExecuteStatement_result getResult(I iface, ExecuteStatement_args args) throws org.apache.thrift.TException { + ExecuteStatement_result result = new ExecuteStatement_result(); + result.success = iface.ExecuteStatement(args.req); + return result; + } + } + + public static class ExecuteBatchStatement extends org.apache.thrift.ProcessFunction { + public ExecuteBatchStatement() { + super("ExecuteBatchStatement"); + } + + public ExecuteBatchStatement_args getEmptyArgsInstance() { + return new ExecuteBatchStatement_args(); + } + + protected boolean isOneway() { + return false; + } + + public ExecuteBatchStatement_result getResult(I iface, ExecuteBatchStatement_args args) throws org.apache.thrift.TException { + ExecuteBatchStatement_result result = new ExecuteBatchStatement_result(); + result.success = iface.ExecuteBatchStatement(args.req); + return result; + } + } + + public static class ExecuteQueryStatement extends org.apache.thrift.ProcessFunction { + public ExecuteQueryStatement() { + super("ExecuteQueryStatement"); + } + + public ExecuteQueryStatement_args getEmptyArgsInstance() { + return new ExecuteQueryStatement_args(); + } + + protected boolean isOneway() { + return false; + } + + public ExecuteQueryStatement_result getResult(I iface, ExecuteQueryStatement_args args) throws org.apache.thrift.TException { + ExecuteQueryStatement_result result = new ExecuteQueryStatement_result(); + result.success = iface.ExecuteQueryStatement(args.req); + return result; + } + } + + public static class ExecuteUpdateStatement extends org.apache.thrift.ProcessFunction { + public ExecuteUpdateStatement() { + super("ExecuteUpdateStatement"); + } + + public ExecuteUpdateStatement_args getEmptyArgsInstance() { + return new ExecuteUpdateStatement_args(); + } + + protected boolean isOneway() { + return false; + } + + public ExecuteUpdateStatement_result getResult(I iface, ExecuteUpdateStatement_args args) throws org.apache.thrift.TException { + ExecuteUpdateStatement_result result = new ExecuteUpdateStatement_result(); + result.success = iface.ExecuteUpdateStatement(args.req); + return result; + } + } + + public static class FetchResults extends org.apache.thrift.ProcessFunction { + public FetchResults() { + super("FetchResults"); + } + + public FetchResults_args getEmptyArgsInstance() { + return new FetchResults_args(); + } + + protected boolean isOneway() { + return false; + } + + public FetchResults_result getResult(I iface, FetchResults_args args) throws org.apache.thrift.TException { + FetchResults_result result = new FetchResults_result(); + result.success = iface.FetchResults(args.req); + return result; + } + } + + public static class FetchMetadata extends org.apache.thrift.ProcessFunction { + public FetchMetadata() { + super("FetchMetadata"); + } + + public FetchMetadata_args getEmptyArgsInstance() { + return new FetchMetadata_args(); + } + + protected boolean isOneway() { + return false; + } + + public FetchMetadata_result getResult(I iface, FetchMetadata_args args) throws org.apache.thrift.TException { + FetchMetadata_result result = new FetchMetadata_result(); + result.success = iface.FetchMetadata(args.req); + return result; + } + } + + public static class CancelOperation extends org.apache.thrift.ProcessFunction { + public CancelOperation() { + super("CancelOperation"); + } + + public CancelOperation_args getEmptyArgsInstance() { + return new CancelOperation_args(); + } + + protected boolean isOneway() { + return false; + } + + public CancelOperation_result getResult(I iface, CancelOperation_args args) throws org.apache.thrift.TException { + CancelOperation_result result = new CancelOperation_result(); + result.success = iface.CancelOperation(args.req); + return result; + } + } + + public static class CloseOperation extends org.apache.thrift.ProcessFunction { + public CloseOperation() { + super("CloseOperation"); + } + + public CloseOperation_args getEmptyArgsInstance() { + return new CloseOperation_args(); + } + + protected boolean isOneway() { + return false; + } + + public CloseOperation_result getResult(I iface, CloseOperation_args args) throws org.apache.thrift.TException { + CloseOperation_result result = new CloseOperation_result(); + result.success = iface.CloseOperation(args.req); + return result; + } + } + + } + + public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncProcessor.class.getName()); + public AsyncProcessor(I iface) { + super(iface, getProcessMap(new HashMap>())); + } + + protected AsyncProcessor(I iface, Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static Map> getProcessMap(Map> processMap) { + processMap.put("OpenSession", new OpenSession()); + processMap.put("CloseSession", new CloseSession()); + processMap.put("ExecuteStatement", new ExecuteStatement()); + processMap.put("ExecuteBatchStatement", new ExecuteBatchStatement()); + processMap.put("ExecuteQueryStatement", new ExecuteQueryStatement()); + processMap.put("ExecuteUpdateStatement", new ExecuteUpdateStatement()); + processMap.put("FetchResults", new FetchResults()); + processMap.put("FetchMetadata", new FetchMetadata()); + processMap.put("CancelOperation", new CancelOperation()); + processMap.put("CloseOperation", new CloseOperation()); + return processMap; + } + + public static class OpenSession extends org.apache.thrift.AsyncProcessFunction { + public OpenSession() { + super("OpenSession"); + } + + public OpenSession_args getEmptyArgsInstance() { + return new OpenSession_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSOpenSessionResp o) { + OpenSession_result result = new OpenSession_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + OpenSession_result result = new OpenSession_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, OpenSession_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.OpenSession(args.req,resultHandler); + } + } + + public static class CloseSession extends org.apache.thrift.AsyncProcessFunction { + public CloseSession() { + super("CloseSession"); + } + + public CloseSession_args getEmptyArgsInstance() { + return new CloseSession_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSCloseSessionResp o) { + CloseSession_result result = new CloseSession_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + CloseSession_result result = new CloseSession_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, CloseSession_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.CloseSession(args.req,resultHandler); + } + } + + public static class ExecuteStatement extends org.apache.thrift.AsyncProcessFunction { + public ExecuteStatement() { + super("ExecuteStatement"); + } + + public ExecuteStatement_args getEmptyArgsInstance() { + return new ExecuteStatement_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSExecuteStatementResp o) { + ExecuteStatement_result result = new ExecuteStatement_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + ExecuteStatement_result result = new ExecuteStatement_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, ExecuteStatement_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.ExecuteStatement(args.req,resultHandler); + } + } + + public static class ExecuteBatchStatement extends org.apache.thrift.AsyncProcessFunction { + public ExecuteBatchStatement() { + super("ExecuteBatchStatement"); + } + + public ExecuteBatchStatement_args getEmptyArgsInstance() { + return new ExecuteBatchStatement_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSExecuteBatchStatementResp o) { + ExecuteBatchStatement_result result = new ExecuteBatchStatement_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + ExecuteBatchStatement_result result = new ExecuteBatchStatement_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, ExecuteBatchStatement_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.ExecuteBatchStatement(args.req,resultHandler); + } + } + + public static class ExecuteQueryStatement extends org.apache.thrift.AsyncProcessFunction { + public ExecuteQueryStatement() { + super("ExecuteQueryStatement"); + } + + public ExecuteQueryStatement_args getEmptyArgsInstance() { + return new ExecuteQueryStatement_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSExecuteStatementResp o) { + ExecuteQueryStatement_result result = new ExecuteQueryStatement_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + ExecuteQueryStatement_result result = new ExecuteQueryStatement_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, ExecuteQueryStatement_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.ExecuteQueryStatement(args.req,resultHandler); + } + } + + public static class ExecuteUpdateStatement extends org.apache.thrift.AsyncProcessFunction { + public ExecuteUpdateStatement() { + super("ExecuteUpdateStatement"); + } + + public ExecuteUpdateStatement_args getEmptyArgsInstance() { + return new ExecuteUpdateStatement_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSExecuteStatementResp o) { + ExecuteUpdateStatement_result result = new ExecuteUpdateStatement_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + ExecuteUpdateStatement_result result = new ExecuteUpdateStatement_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, ExecuteUpdateStatement_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.ExecuteUpdateStatement(args.req,resultHandler); + } + } + + public static class FetchResults extends org.apache.thrift.AsyncProcessFunction { + public FetchResults() { + super("FetchResults"); + } + + public FetchResults_args getEmptyArgsInstance() { + return new FetchResults_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSFetchResultsResp o) { + FetchResults_result result = new FetchResults_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + FetchResults_result result = new FetchResults_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, FetchResults_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.FetchResults(args.req,resultHandler); + } + } + + public static class FetchMetadata extends org.apache.thrift.AsyncProcessFunction { + public FetchMetadata() { + super("FetchMetadata"); + } + + public FetchMetadata_args getEmptyArgsInstance() { + return new FetchMetadata_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSFetchMetadataResp o) { + FetchMetadata_result result = new FetchMetadata_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + FetchMetadata_result result = new FetchMetadata_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, FetchMetadata_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.FetchMetadata(args.req,resultHandler); + } + } + + public static class CancelOperation extends org.apache.thrift.AsyncProcessFunction { + public CancelOperation() { + super("CancelOperation"); + } + + public CancelOperation_args getEmptyArgsInstance() { + return new CancelOperation_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSCancelOperationResp o) { + CancelOperation_result result = new CancelOperation_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + CancelOperation_result result = new CancelOperation_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, CancelOperation_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.CancelOperation(args.req,resultHandler); + } + } + + public static class CloseOperation extends org.apache.thrift.AsyncProcessFunction { + public CloseOperation() { + super("CloseOperation"); + } + + public CloseOperation_args getEmptyArgsInstance() { + return new CloseOperation_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(TSCloseOperationResp o) { + CloseOperation_result result = new CloseOperation_result(); + result.success = o; + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + CloseOperation_result result = new CloseOperation_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, CloseOperation_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.CloseOperation(args.req,resultHandler); + } + } + + } + + public static class OpenSession_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("OpenSession_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new OpenSession_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new OpenSession_argsTupleSchemeFactory()); + } + + public TSOpenSessionReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOpenSessionReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(OpenSession_args.class, metaDataMap); + } + + public OpenSession_args() { + } + + public OpenSession_args( + TSOpenSessionReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public OpenSession_args(OpenSession_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public OpenSession_args deepCopy() { + return new OpenSession_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSOpenSessionReq getReq() { + return this.req; + } + + public OpenSession_args setReq(TSOpenSessionReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSOpenSessionReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof OpenSession_args) + return this.equals((OpenSession_args)that); + return false; + } + + public boolean equals(OpenSession_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(OpenSession_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("OpenSession_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class OpenSession_argsStandardSchemeFactory implements SchemeFactory { + public OpenSession_argsStandardScheme getScheme() { + return new OpenSession_argsStandardScheme(); + } + } + + private static class OpenSession_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, OpenSession_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSOpenSessionReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, OpenSession_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class OpenSession_argsTupleSchemeFactory implements SchemeFactory { + public OpenSession_argsTupleScheme getScheme() { + return new OpenSession_argsTupleScheme(); + } + } + + private static class OpenSession_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, OpenSession_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, OpenSession_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSOpenSessionReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class OpenSession_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("OpenSession_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new OpenSession_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new OpenSession_resultTupleSchemeFactory()); + } + + public TSOpenSessionResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOpenSessionResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(OpenSession_result.class, metaDataMap); + } + + public OpenSession_result() { + } + + public OpenSession_result( + TSOpenSessionResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public OpenSession_result(OpenSession_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public OpenSession_result deepCopy() { + return new OpenSession_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSOpenSessionResp getSuccess() { + return this.success; + } + + public OpenSession_result setSuccess(TSOpenSessionResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSOpenSessionResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof OpenSession_result) + return this.equals((OpenSession_result)that); + return false; + } + + public boolean equals(OpenSession_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(OpenSession_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("OpenSession_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class OpenSession_resultStandardSchemeFactory implements SchemeFactory { + public OpenSession_resultStandardScheme getScheme() { + return new OpenSession_resultStandardScheme(); + } + } + + private static class OpenSession_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, OpenSession_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSOpenSessionResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, OpenSession_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class OpenSession_resultTupleSchemeFactory implements SchemeFactory { + public OpenSession_resultTupleScheme getScheme() { + return new OpenSession_resultTupleScheme(); + } + } + + private static class OpenSession_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, OpenSession_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, OpenSession_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSOpenSessionResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class CloseSession_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CloseSession_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CloseSession_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CloseSession_argsTupleSchemeFactory()); + } + + public TSCloseSessionReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSCloseSessionReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CloseSession_args.class, metaDataMap); + } + + public CloseSession_args() { + } + + public CloseSession_args( + TSCloseSessionReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public CloseSession_args(CloseSession_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public CloseSession_args deepCopy() { + return new CloseSession_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSCloseSessionReq getReq() { + return this.req; + } + + public CloseSession_args setReq(TSCloseSessionReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSCloseSessionReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CloseSession_args) + return this.equals((CloseSession_args)that); + return false; + } + + public boolean equals(CloseSession_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(CloseSession_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CloseSession_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CloseSession_argsStandardSchemeFactory implements SchemeFactory { + public CloseSession_argsStandardScheme getScheme() { + return new CloseSession_argsStandardScheme(); + } + } + + private static class CloseSession_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CloseSession_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSCloseSessionReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CloseSession_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CloseSession_argsTupleSchemeFactory implements SchemeFactory { + public CloseSession_argsTupleScheme getScheme() { + return new CloseSession_argsTupleScheme(); + } + } + + private static class CloseSession_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CloseSession_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CloseSession_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSCloseSessionReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class CloseSession_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CloseSession_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CloseSession_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CloseSession_resultTupleSchemeFactory()); + } + + public TSCloseSessionResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSCloseSessionResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CloseSession_result.class, metaDataMap); + } + + public CloseSession_result() { + } + + public CloseSession_result( + TSCloseSessionResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public CloseSession_result(CloseSession_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public CloseSession_result deepCopy() { + return new CloseSession_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSCloseSessionResp getSuccess() { + return this.success; + } + + public CloseSession_result setSuccess(TSCloseSessionResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSCloseSessionResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CloseSession_result) + return this.equals((CloseSession_result)that); + return false; + } + + public boolean equals(CloseSession_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(CloseSession_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CloseSession_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CloseSession_resultStandardSchemeFactory implements SchemeFactory { + public CloseSession_resultStandardScheme getScheme() { + return new CloseSession_resultStandardScheme(); + } + } + + private static class CloseSession_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CloseSession_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSCloseSessionResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CloseSession_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CloseSession_resultTupleSchemeFactory implements SchemeFactory { + public CloseSession_resultTupleScheme getScheme() { + return new CloseSession_resultTupleScheme(); + } + } + + private static class CloseSession_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CloseSession_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CloseSession_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSCloseSessionResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class ExecuteStatement_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteStatement_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteStatement_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteStatement_argsTupleSchemeFactory()); + } + + public TSExecuteStatementReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteStatementReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteStatement_args.class, metaDataMap); + } + + public ExecuteStatement_args() { + } + + public ExecuteStatement_args( + TSExecuteStatementReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteStatement_args(ExecuteStatement_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public ExecuteStatement_args deepCopy() { + return new ExecuteStatement_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSExecuteStatementReq getReq() { + return this.req; + } + + public ExecuteStatement_args setReq(TSExecuteStatementReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSExecuteStatementReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteStatement_args) + return this.equals((ExecuteStatement_args)that); + return false; + } + + public boolean equals(ExecuteStatement_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteStatement_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteStatement_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteStatement_argsStandardSchemeFactory implements SchemeFactory { + public ExecuteStatement_argsStandardScheme getScheme() { + return new ExecuteStatement_argsStandardScheme(); + } + } + + private static class ExecuteStatement_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteStatement_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteStatement_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteStatement_argsTupleSchemeFactory implements SchemeFactory { + public ExecuteStatement_argsTupleScheme getScheme() { + return new ExecuteStatement_argsTupleScheme(); + } + } + + private static class ExecuteStatement_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class ExecuteStatement_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteStatement_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteStatement_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteStatement_resultTupleSchemeFactory()); + } + + public TSExecuteStatementResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteStatementResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteStatement_result.class, metaDataMap); + } + + public ExecuteStatement_result() { + } + + public ExecuteStatement_result( + TSExecuteStatementResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteStatement_result(ExecuteStatement_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public ExecuteStatement_result deepCopy() { + return new ExecuteStatement_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSExecuteStatementResp getSuccess() { + return this.success; + } + + public ExecuteStatement_result setSuccess(TSExecuteStatementResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSExecuteStatementResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteStatement_result) + return this.equals((ExecuteStatement_result)that); + return false; + } + + public boolean equals(ExecuteStatement_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteStatement_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteStatement_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteStatement_resultStandardSchemeFactory implements SchemeFactory { + public ExecuteStatement_resultStandardScheme getScheme() { + return new ExecuteStatement_resultStandardScheme(); + } + } + + private static class ExecuteStatement_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteStatement_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSExecuteStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteStatement_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteStatement_resultTupleSchemeFactory implements SchemeFactory { + public ExecuteStatement_resultTupleScheme getScheme() { + return new ExecuteStatement_resultTupleScheme(); + } + } + + private static class ExecuteStatement_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSExecuteStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class ExecuteBatchStatement_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteBatchStatement_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteBatchStatement_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteBatchStatement_argsTupleSchemeFactory()); + } + + public TSExecuteBatchStatementReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteBatchStatementReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteBatchStatement_args.class, metaDataMap); + } + + public ExecuteBatchStatement_args() { + } + + public ExecuteBatchStatement_args( + TSExecuteBatchStatementReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteBatchStatement_args(ExecuteBatchStatement_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public ExecuteBatchStatement_args deepCopy() { + return new ExecuteBatchStatement_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSExecuteBatchStatementReq getReq() { + return this.req; + } + + public ExecuteBatchStatement_args setReq(TSExecuteBatchStatementReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSExecuteBatchStatementReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteBatchStatement_args) + return this.equals((ExecuteBatchStatement_args)that); + return false; + } + + public boolean equals(ExecuteBatchStatement_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteBatchStatement_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteBatchStatement_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteBatchStatement_argsStandardSchemeFactory implements SchemeFactory { + public ExecuteBatchStatement_argsStandardScheme getScheme() { + return new ExecuteBatchStatement_argsStandardScheme(); + } + } + + private static class ExecuteBatchStatement_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteBatchStatement_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSExecuteBatchStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteBatchStatement_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteBatchStatement_argsTupleSchemeFactory implements SchemeFactory { + public ExecuteBatchStatement_argsTupleScheme getScheme() { + return new ExecuteBatchStatement_argsTupleScheme(); + } + } + + private static class ExecuteBatchStatement_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteBatchStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteBatchStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSExecuteBatchStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class ExecuteBatchStatement_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteBatchStatement_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteBatchStatement_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteBatchStatement_resultTupleSchemeFactory()); + } + + public TSExecuteBatchStatementResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteBatchStatementResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteBatchStatement_result.class, metaDataMap); + } + + public ExecuteBatchStatement_result() { + } + + public ExecuteBatchStatement_result( + TSExecuteBatchStatementResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteBatchStatement_result(ExecuteBatchStatement_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public ExecuteBatchStatement_result deepCopy() { + return new ExecuteBatchStatement_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSExecuteBatchStatementResp getSuccess() { + return this.success; + } + + public ExecuteBatchStatement_result setSuccess(TSExecuteBatchStatementResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSExecuteBatchStatementResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteBatchStatement_result) + return this.equals((ExecuteBatchStatement_result)that); + return false; + } + + public boolean equals(ExecuteBatchStatement_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteBatchStatement_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteBatchStatement_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteBatchStatement_resultStandardSchemeFactory implements SchemeFactory { + public ExecuteBatchStatement_resultStandardScheme getScheme() { + return new ExecuteBatchStatement_resultStandardScheme(); + } + } + + private static class ExecuteBatchStatement_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteBatchStatement_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSExecuteBatchStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteBatchStatement_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteBatchStatement_resultTupleSchemeFactory implements SchemeFactory { + public ExecuteBatchStatement_resultTupleScheme getScheme() { + return new ExecuteBatchStatement_resultTupleScheme(); + } + } + + private static class ExecuteBatchStatement_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteBatchStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteBatchStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSExecuteBatchStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class ExecuteQueryStatement_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteQueryStatement_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteQueryStatement_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteQueryStatement_argsTupleSchemeFactory()); + } + + public TSExecuteStatementReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteStatementReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteQueryStatement_args.class, metaDataMap); + } + + public ExecuteQueryStatement_args() { + } + + public ExecuteQueryStatement_args( + TSExecuteStatementReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteQueryStatement_args(ExecuteQueryStatement_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public ExecuteQueryStatement_args deepCopy() { + return new ExecuteQueryStatement_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSExecuteStatementReq getReq() { + return this.req; + } + + public ExecuteQueryStatement_args setReq(TSExecuteStatementReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSExecuteStatementReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteQueryStatement_args) + return this.equals((ExecuteQueryStatement_args)that); + return false; + } + + public boolean equals(ExecuteQueryStatement_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteQueryStatement_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteQueryStatement_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteQueryStatement_argsStandardSchemeFactory implements SchemeFactory { + public ExecuteQueryStatement_argsStandardScheme getScheme() { + return new ExecuteQueryStatement_argsStandardScheme(); + } + } + + private static class ExecuteQueryStatement_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteQueryStatement_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteQueryStatement_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteQueryStatement_argsTupleSchemeFactory implements SchemeFactory { + public ExecuteQueryStatement_argsTupleScheme getScheme() { + return new ExecuteQueryStatement_argsTupleScheme(); + } + } + + private static class ExecuteQueryStatement_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteQueryStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteQueryStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class ExecuteQueryStatement_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteQueryStatement_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteQueryStatement_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteQueryStatement_resultTupleSchemeFactory()); + } + + public TSExecuteStatementResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteStatementResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteQueryStatement_result.class, metaDataMap); + } + + public ExecuteQueryStatement_result() { + } + + public ExecuteQueryStatement_result( + TSExecuteStatementResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteQueryStatement_result(ExecuteQueryStatement_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public ExecuteQueryStatement_result deepCopy() { + return new ExecuteQueryStatement_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSExecuteStatementResp getSuccess() { + return this.success; + } + + public ExecuteQueryStatement_result setSuccess(TSExecuteStatementResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSExecuteStatementResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteQueryStatement_result) + return this.equals((ExecuteQueryStatement_result)that); + return false; + } + + public boolean equals(ExecuteQueryStatement_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteQueryStatement_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteQueryStatement_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteQueryStatement_resultStandardSchemeFactory implements SchemeFactory { + public ExecuteQueryStatement_resultStandardScheme getScheme() { + return new ExecuteQueryStatement_resultStandardScheme(); + } + } + + private static class ExecuteQueryStatement_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteQueryStatement_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSExecuteStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteQueryStatement_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteQueryStatement_resultTupleSchemeFactory implements SchemeFactory { + public ExecuteQueryStatement_resultTupleScheme getScheme() { + return new ExecuteQueryStatement_resultTupleScheme(); + } + } + + private static class ExecuteQueryStatement_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteQueryStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteQueryStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSExecuteStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class ExecuteUpdateStatement_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteUpdateStatement_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteUpdateStatement_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteUpdateStatement_argsTupleSchemeFactory()); + } + + public TSExecuteStatementReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteStatementReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteUpdateStatement_args.class, metaDataMap); + } + + public ExecuteUpdateStatement_args() { + } + + public ExecuteUpdateStatement_args( + TSExecuteStatementReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteUpdateStatement_args(ExecuteUpdateStatement_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public ExecuteUpdateStatement_args deepCopy() { + return new ExecuteUpdateStatement_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSExecuteStatementReq getReq() { + return this.req; + } + + public ExecuteUpdateStatement_args setReq(TSExecuteStatementReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSExecuteStatementReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteUpdateStatement_args) + return this.equals((ExecuteUpdateStatement_args)that); + return false; + } + + public boolean equals(ExecuteUpdateStatement_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteUpdateStatement_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteUpdateStatement_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteUpdateStatement_argsStandardSchemeFactory implements SchemeFactory { + public ExecuteUpdateStatement_argsStandardScheme getScheme() { + return new ExecuteUpdateStatement_argsStandardScheme(); + } + } + + private static class ExecuteUpdateStatement_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteUpdateStatement_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteUpdateStatement_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteUpdateStatement_argsTupleSchemeFactory implements SchemeFactory { + public ExecuteUpdateStatement_argsTupleScheme getScheme() { + return new ExecuteUpdateStatement_argsTupleScheme(); + } + } + + private static class ExecuteUpdateStatement_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteUpdateStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteUpdateStatement_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSExecuteStatementReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class ExecuteUpdateStatement_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteUpdateStatement_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ExecuteUpdateStatement_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ExecuteUpdateStatement_resultTupleSchemeFactory()); + } + + public TSExecuteStatementResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSExecuteStatementResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteUpdateStatement_result.class, metaDataMap); + } + + public ExecuteUpdateStatement_result() { + } + + public ExecuteUpdateStatement_result( + TSExecuteStatementResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public ExecuteUpdateStatement_result(ExecuteUpdateStatement_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public ExecuteUpdateStatement_result deepCopy() { + return new ExecuteUpdateStatement_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSExecuteStatementResp getSuccess() { + return this.success; + } + + public ExecuteUpdateStatement_result setSuccess(TSExecuteStatementResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSExecuteStatementResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ExecuteUpdateStatement_result) + return this.equals((ExecuteUpdateStatement_result)that); + return false; + } + + public boolean equals(ExecuteUpdateStatement_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(ExecuteUpdateStatement_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ExecuteUpdateStatement_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ExecuteUpdateStatement_resultStandardSchemeFactory implements SchemeFactory { + public ExecuteUpdateStatement_resultStandardScheme getScheme() { + return new ExecuteUpdateStatement_resultStandardScheme(); + } + } + + private static class ExecuteUpdateStatement_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteUpdateStatement_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSExecuteStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ExecuteUpdateStatement_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ExecuteUpdateStatement_resultTupleSchemeFactory implements SchemeFactory { + public ExecuteUpdateStatement_resultTupleScheme getScheme() { + return new ExecuteUpdateStatement_resultTupleScheme(); + } + } + + private static class ExecuteUpdateStatement_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteUpdateStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteUpdateStatement_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSExecuteStatementResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class FetchResults_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("FetchResults_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new FetchResults_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new FetchResults_argsTupleSchemeFactory()); + } + + public TSFetchResultsReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSFetchResultsReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(FetchResults_args.class, metaDataMap); + } + + public FetchResults_args() { + } + + public FetchResults_args( + TSFetchResultsReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public FetchResults_args(FetchResults_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public FetchResults_args deepCopy() { + return new FetchResults_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSFetchResultsReq getReq() { + return this.req; + } + + public FetchResults_args setReq(TSFetchResultsReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSFetchResultsReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof FetchResults_args) + return this.equals((FetchResults_args)that); + return false; + } + + public boolean equals(FetchResults_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(FetchResults_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("FetchResults_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class FetchResults_argsStandardSchemeFactory implements SchemeFactory { + public FetchResults_argsStandardScheme getScheme() { + return new FetchResults_argsStandardScheme(); + } + } + + private static class FetchResults_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, FetchResults_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSFetchResultsReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, FetchResults_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class FetchResults_argsTupleSchemeFactory implements SchemeFactory { + public FetchResults_argsTupleScheme getScheme() { + return new FetchResults_argsTupleScheme(); + } + } + + private static class FetchResults_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, FetchResults_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, FetchResults_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSFetchResultsReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class FetchResults_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("FetchResults_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new FetchResults_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new FetchResults_resultTupleSchemeFactory()); + } + + public TSFetchResultsResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSFetchResultsResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(FetchResults_result.class, metaDataMap); + } + + public FetchResults_result() { + } + + public FetchResults_result( + TSFetchResultsResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public FetchResults_result(FetchResults_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public FetchResults_result deepCopy() { + return new FetchResults_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSFetchResultsResp getSuccess() { + return this.success; + } + + public FetchResults_result setSuccess(TSFetchResultsResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSFetchResultsResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof FetchResults_result) + return this.equals((FetchResults_result)that); + return false; + } + + public boolean equals(FetchResults_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(FetchResults_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("FetchResults_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class FetchResults_resultStandardSchemeFactory implements SchemeFactory { + public FetchResults_resultStandardScheme getScheme() { + return new FetchResults_resultStandardScheme(); + } + } + + private static class FetchResults_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, FetchResults_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSFetchResultsResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, FetchResults_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class FetchResults_resultTupleSchemeFactory implements SchemeFactory { + public FetchResults_resultTupleScheme getScheme() { + return new FetchResults_resultTupleScheme(); + } + } + + private static class FetchResults_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, FetchResults_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, FetchResults_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSFetchResultsResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class FetchMetadata_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("FetchMetadata_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new FetchMetadata_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new FetchMetadata_argsTupleSchemeFactory()); + } + + public TSFetchMetadataReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSFetchMetadataReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(FetchMetadata_args.class, metaDataMap); + } + + public FetchMetadata_args() { + } + + public FetchMetadata_args( + TSFetchMetadataReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public FetchMetadata_args(FetchMetadata_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public FetchMetadata_args deepCopy() { + return new FetchMetadata_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSFetchMetadataReq getReq() { + return this.req; + } + + public FetchMetadata_args setReq(TSFetchMetadataReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSFetchMetadataReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof FetchMetadata_args) + return this.equals((FetchMetadata_args)that); + return false; + } + + public boolean equals(FetchMetadata_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(FetchMetadata_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("FetchMetadata_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class FetchMetadata_argsStandardSchemeFactory implements SchemeFactory { + public FetchMetadata_argsStandardScheme getScheme() { + return new FetchMetadata_argsStandardScheme(); + } + } + + private static class FetchMetadata_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, FetchMetadata_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSFetchMetadataReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, FetchMetadata_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class FetchMetadata_argsTupleSchemeFactory implements SchemeFactory { + public FetchMetadata_argsTupleScheme getScheme() { + return new FetchMetadata_argsTupleScheme(); + } + } + + private static class FetchMetadata_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, FetchMetadata_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, FetchMetadata_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSFetchMetadataReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class FetchMetadata_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("FetchMetadata_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new FetchMetadata_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new FetchMetadata_resultTupleSchemeFactory()); + } + + public TSFetchMetadataResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSFetchMetadataResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(FetchMetadata_result.class, metaDataMap); + } + + public FetchMetadata_result() { + } + + public FetchMetadata_result( + TSFetchMetadataResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public FetchMetadata_result(FetchMetadata_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public FetchMetadata_result deepCopy() { + return new FetchMetadata_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSFetchMetadataResp getSuccess() { + return this.success; + } + + public FetchMetadata_result setSuccess(TSFetchMetadataResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSFetchMetadataResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof FetchMetadata_result) + return this.equals((FetchMetadata_result)that); + return false; + } + + public boolean equals(FetchMetadata_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(FetchMetadata_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("FetchMetadata_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class FetchMetadata_resultStandardSchemeFactory implements SchemeFactory { + public FetchMetadata_resultStandardScheme getScheme() { + return new FetchMetadata_resultStandardScheme(); + } + } + + private static class FetchMetadata_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, FetchMetadata_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSFetchMetadataResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, FetchMetadata_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class FetchMetadata_resultTupleSchemeFactory implements SchemeFactory { + public FetchMetadata_resultTupleScheme getScheme() { + return new FetchMetadata_resultTupleScheme(); + } + } + + private static class FetchMetadata_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, FetchMetadata_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, FetchMetadata_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSFetchMetadataResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class CancelOperation_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CancelOperation_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CancelOperation_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CancelOperation_argsTupleSchemeFactory()); + } + + public TSCancelOperationReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSCancelOperationReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CancelOperation_args.class, metaDataMap); + } + + public CancelOperation_args() { + } + + public CancelOperation_args( + TSCancelOperationReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public CancelOperation_args(CancelOperation_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public CancelOperation_args deepCopy() { + return new CancelOperation_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSCancelOperationReq getReq() { + return this.req; + } + + public CancelOperation_args setReq(TSCancelOperationReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSCancelOperationReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CancelOperation_args) + return this.equals((CancelOperation_args)that); + return false; + } + + public boolean equals(CancelOperation_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(CancelOperation_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CancelOperation_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CancelOperation_argsStandardSchemeFactory implements SchemeFactory { + public CancelOperation_argsStandardScheme getScheme() { + return new CancelOperation_argsStandardScheme(); + } + } + + private static class CancelOperation_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CancelOperation_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSCancelOperationReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CancelOperation_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CancelOperation_argsTupleSchemeFactory implements SchemeFactory { + public CancelOperation_argsTupleScheme getScheme() { + return new CancelOperation_argsTupleScheme(); + } + } + + private static class CancelOperation_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CancelOperation_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CancelOperation_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSCancelOperationReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class CancelOperation_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CancelOperation_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CancelOperation_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CancelOperation_resultTupleSchemeFactory()); + } + + public TSCancelOperationResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSCancelOperationResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CancelOperation_result.class, metaDataMap); + } + + public CancelOperation_result() { + } + + public CancelOperation_result( + TSCancelOperationResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public CancelOperation_result(CancelOperation_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public CancelOperation_result deepCopy() { + return new CancelOperation_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSCancelOperationResp getSuccess() { + return this.success; + } + + public CancelOperation_result setSuccess(TSCancelOperationResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSCancelOperationResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CancelOperation_result) + return this.equals((CancelOperation_result)that); + return false; + } + + public boolean equals(CancelOperation_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(CancelOperation_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CancelOperation_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CancelOperation_resultStandardSchemeFactory implements SchemeFactory { + public CancelOperation_resultStandardScheme getScheme() { + return new CancelOperation_resultStandardScheme(); + } + } + + private static class CancelOperation_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CancelOperation_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSCancelOperationResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CancelOperation_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CancelOperation_resultTupleSchemeFactory implements SchemeFactory { + public CancelOperation_resultTupleScheme getScheme() { + return new CancelOperation_resultTupleScheme(); + } + } + + private static class CancelOperation_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CancelOperation_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CancelOperation_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSCancelOperationResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class CloseOperation_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CloseOperation_args"); + + private static final org.apache.thrift.protocol.TField REQ_FIELD_DESC = new org.apache.thrift.protocol.TField("req", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CloseOperation_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CloseOperation_argsTupleSchemeFactory()); + } + + public TSCloseOperationReq req; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + REQ((short)1, "req"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // REQ + return REQ; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.REQ, new org.apache.thrift.meta_data.FieldMetaData("req", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSCloseOperationReq"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CloseOperation_args.class, metaDataMap); + } + + public CloseOperation_args() { + } + + public CloseOperation_args( + TSCloseOperationReq req) + { + this(); + this.req = req; + } + + /** + * Performs a deep copy on other. + */ + public CloseOperation_args(CloseOperation_args other) { + if (other.isSetReq()) { + this.req = other.req; + } + } + + public CloseOperation_args deepCopy() { + return new CloseOperation_args(this); + } + + @Override + public void clear() { + this.req = null; + } + + public TSCloseOperationReq getReq() { + return this.req; + } + + public CloseOperation_args setReq(TSCloseOperationReq req) { + this.req = req; + return this; + } + + public void unsetReq() { + this.req = null; + } + + /** Returns true if field req is set (has been assigned a value) and false otherwise */ + public boolean isSetReq() { + return this.req != null; + } + + public void setReqIsSet(boolean value) { + if (!value) { + this.req = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQ: + if (value == null) { + unsetReq(); + } else { + setReq((TSCloseOperationReq)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQ: + return getReq(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case REQ: + return isSetReq(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CloseOperation_args) + return this.equals((CloseOperation_args)that); + return false; + } + + public boolean equals(CloseOperation_args that) { + if (that == null) + return false; + + boolean this_present_req = true && this.isSetReq(); + boolean that_present_req = true && that.isSetReq(); + if (this_present_req || that_present_req) { + if (!(this_present_req && that_present_req)) + return false; + if (!this.req.equals(that.req)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_req = true && (isSetReq()); + list.add(present_req); + if (present_req) + list.add(req); + + return list.hashCode(); + } + + @Override + public int compareTo(CloseOperation_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetReq()).compareTo(other.isSetReq()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReq()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.req, other.req); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CloseOperation_args("); + boolean first = true; + + sb.append("req:"); + if (this.req == null) { + sb.append("null"); + } else { + sb.append(this.req); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CloseOperation_argsStandardSchemeFactory implements SchemeFactory { + public CloseOperation_argsStandardScheme getScheme() { + return new CloseOperation_argsStandardScheme(); + } + } + + private static class CloseOperation_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CloseOperation_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // REQ + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.req = new TSCloseOperationReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CloseOperation_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.req != null) { + oprot.writeFieldBegin(REQ_FIELD_DESC); + struct.req.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CloseOperation_argsTupleSchemeFactory implements SchemeFactory { + public CloseOperation_argsTupleScheme getScheme() { + return new CloseOperation_argsTupleScheme(); + } + } + + private static class CloseOperation_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CloseOperation_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetReq()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetReq()) { + struct.req.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CloseOperation_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.req = new TSCloseOperationReq(); + struct.req.read(iprot); + struct.setReqIsSet(true); + } + } + } + + } + + public static class CloseOperation_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CloseOperation_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CloseOperation_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CloseOperation_resultTupleSchemeFactory()); + } + + public TSCloseOperationResp success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSCloseOperationResp"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CloseOperation_result.class, metaDataMap); + } + + public CloseOperation_result() { + } + + public CloseOperation_result( + TSCloseOperationResp success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public CloseOperation_result(CloseOperation_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public CloseOperation_result deepCopy() { + return new CloseOperation_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSCloseOperationResp getSuccess() { + return this.success; + } + + public CloseOperation_result setSuccess(TSCloseOperationResp success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSCloseOperationResp)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CloseOperation_result) + return this.equals((CloseOperation_result)that); + return false; + } + + public boolean equals(CloseOperation_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_success = true && (isSetSuccess()); + list.add(present_success); + if (present_success) + list.add(success); + + return list.hashCode(); + } + + @Override + public int compareTo(CloseOperation_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CloseOperation_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CloseOperation_resultStandardSchemeFactory implements SchemeFactory { + public CloseOperation_resultStandardScheme getScheme() { + return new CloseOperation_resultStandardScheme(); + } + } + + private static class CloseOperation_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CloseOperation_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TSCloseOperationResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CloseOperation_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CloseOperation_resultTupleSchemeFactory implements SchemeFactory { + public CloseOperation_resultTupleScheme getScheme() { + return new CloseOperation_resultTupleScheme(); + } + } + + private static class CloseOperation_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CloseOperation_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CloseOperation_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSCloseOperationResp(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOpenSessionReq.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOpenSessionReq.java new file mode 100644 index 00000000000..8361f6f99a3 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOpenSessionReq.java @@ -0,0 +1,787 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSOpenSessionReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSOpenSessionReq"); + + private static final org.apache.thrift.protocol.TField CLIENT_PROTOCOL_FIELD_DESC = new org.apache.thrift.protocol.TField("client_protocol", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField PASSWORD_FIELD_DESC = new org.apache.thrift.protocol.TField("password", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField CONFIGURATION_FIELD_DESC = new org.apache.thrift.protocol.TField("configuration", org.apache.thrift.protocol.TType.MAP, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSOpenSessionReqStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSOpenSessionReqTupleSchemeFactory()); + } + + /** + * + * @see TSProtocolVersion + */ + public TSProtocolVersion client_protocol; // required + public String username; // optional + public String password; // optional + public Map configuration; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + /** + * + * @see TSProtocolVersion + */ + CLIENT_PROTOCOL((short)1, "client_protocol"), + USERNAME((short)2, "username"), + PASSWORD((short)3, "password"), + CONFIGURATION((short)4, "configuration"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLIENT_PROTOCOL + return CLIENT_PROTOCOL; + case 2: // USERNAME + return USERNAME; + case 3: // PASSWORD + return PASSWORD; + case 4: // CONFIGURATION + return CONFIGURATION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.USERNAME,_Fields.PASSWORD,_Fields.CONFIGURATION}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLIENT_PROTOCOL, new org.apache.thrift.meta_data.FieldMetaData("client_protocol", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TSProtocolVersion.class))); + tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PASSWORD, new org.apache.thrift.meta_data.FieldMetaData("password", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CONFIGURATION, new org.apache.thrift.meta_data.FieldMetaData("configuration", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSOpenSessionReq.class, metaDataMap); + } + + public TSOpenSessionReq() { + this.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1; + + } + + public TSOpenSessionReq( + TSProtocolVersion client_protocol) + { + this(); + this.client_protocol = client_protocol; + } + + /** + * Performs a deep copy on other. + */ + public TSOpenSessionReq(TSOpenSessionReq other) { + if (other.isSetClient_protocol()) { + this.client_protocol = other.client_protocol; + } + if (other.isSetUsername()) { + this.username = other.username; + } + if (other.isSetPassword()) { + this.password = other.password; + } + if (other.isSetConfiguration()) { + Map __this__configuration = new HashMap(other.configuration); + this.configuration = __this__configuration; + } + } + + public TSOpenSessionReq deepCopy() { + return new TSOpenSessionReq(this); + } + + @Override + public void clear() { + this.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1; + + this.username = null; + this.password = null; + this.configuration = null; + } + + /** + * + * @see TSProtocolVersion + */ + public TSProtocolVersion getClient_protocol() { + return this.client_protocol; + } + + /** + * + * @see TSProtocolVersion + */ + public TSOpenSessionReq setClient_protocol(TSProtocolVersion client_protocol) { + this.client_protocol = client_protocol; + return this; + } + + public void unsetClient_protocol() { + this.client_protocol = null; + } + + /** Returns true if field client_protocol is set (has been assigned a value) and false otherwise */ + public boolean isSetClient_protocol() { + return this.client_protocol != null; + } + + public void setClient_protocolIsSet(boolean value) { + if (!value) { + this.client_protocol = null; + } + } + + public String getUsername() { + return this.username; + } + + public TSOpenSessionReq setUsername(String username) { + this.username = username; + return this; + } + + public void unsetUsername() { + this.username = null; + } + + /** Returns true if field username is set (has been assigned a value) and false otherwise */ + public boolean isSetUsername() { + return this.username != null; + } + + public void setUsernameIsSet(boolean value) { + if (!value) { + this.username = null; + } + } + + public String getPassword() { + return this.password; + } + + public TSOpenSessionReq setPassword(String password) { + this.password = password; + return this; + } + + public void unsetPassword() { + this.password = null; + } + + /** Returns true if field password is set (has been assigned a value) and false otherwise */ + public boolean isSetPassword() { + return this.password != null; + } + + public void setPasswordIsSet(boolean value) { + if (!value) { + this.password = null; + } + } + + public int getConfigurationSize() { + return (this.configuration == null) ? 0 : this.configuration.size(); + } + + public void putToConfiguration(String key, String val) { + if (this.configuration == null) { + this.configuration = new HashMap(); + } + this.configuration.put(key, val); + } + + public Map getConfiguration() { + return this.configuration; + } + + public TSOpenSessionReq setConfiguration(Map configuration) { + this.configuration = configuration; + return this; + } + + public void unsetConfiguration() { + this.configuration = null; + } + + /** Returns true if field configuration is set (has been assigned a value) and false otherwise */ + public boolean isSetConfiguration() { + return this.configuration != null; + } + + public void setConfigurationIsSet(boolean value) { + if (!value) { + this.configuration = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLIENT_PROTOCOL: + if (value == null) { + unsetClient_protocol(); + } else { + setClient_protocol((TSProtocolVersion)value); + } + break; + + case USERNAME: + if (value == null) { + unsetUsername(); + } else { + setUsername((String)value); + } + break; + + case PASSWORD: + if (value == null) { + unsetPassword(); + } else { + setPassword((String)value); + } + break; + + case CONFIGURATION: + if (value == null) { + unsetConfiguration(); + } else { + setConfiguration((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLIENT_PROTOCOL: + return getClient_protocol(); + + case USERNAME: + return getUsername(); + + case PASSWORD: + return getPassword(); + + case CONFIGURATION: + return getConfiguration(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLIENT_PROTOCOL: + return isSetClient_protocol(); + case USERNAME: + return isSetUsername(); + case PASSWORD: + return isSetPassword(); + case CONFIGURATION: + return isSetConfiguration(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSOpenSessionReq) + return this.equals((TSOpenSessionReq)that); + return false; + } + + public boolean equals(TSOpenSessionReq that) { + if (that == null) + return false; + + boolean this_present_client_protocol = true && this.isSetClient_protocol(); + boolean that_present_client_protocol = true && that.isSetClient_protocol(); + if (this_present_client_protocol || that_present_client_protocol) { + if (!(this_present_client_protocol && that_present_client_protocol)) + return false; + if (!this.client_protocol.equals(that.client_protocol)) + return false; + } + + boolean this_present_username = true && this.isSetUsername(); + boolean that_present_username = true && that.isSetUsername(); + if (this_present_username || that_present_username) { + if (!(this_present_username && that_present_username)) + return false; + if (!this.username.equals(that.username)) + return false; + } + + boolean this_present_password = true && this.isSetPassword(); + boolean that_present_password = true && that.isSetPassword(); + if (this_present_password || that_present_password) { + if (!(this_present_password && that_present_password)) + return false; + if (!this.password.equals(that.password)) + return false; + } + + boolean this_present_configuration = true && this.isSetConfiguration(); + boolean that_present_configuration = true && that.isSetConfiguration(); + if (this_present_configuration || that_present_configuration) { + if (!(this_present_configuration && that_present_configuration)) + return false; + if (!this.configuration.equals(that.configuration)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_client_protocol = true && (isSetClient_protocol()); + list.add(present_client_protocol); + if (present_client_protocol) + list.add(client_protocol.getValue()); + + boolean present_username = true && (isSetUsername()); + list.add(present_username); + if (present_username) + list.add(username); + + boolean present_password = true && (isSetPassword()); + list.add(present_password); + if (present_password) + list.add(password); + + boolean present_configuration = true && (isSetConfiguration()); + list.add(present_configuration); + if (present_configuration) + list.add(configuration); + + return list.hashCode(); + } + + @Override + public int compareTo(TSOpenSessionReq other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetClient_protocol()).compareTo(other.isSetClient_protocol()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClient_protocol()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.client_protocol, other.client_protocol); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUsername()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPassword()).compareTo(other.isSetPassword()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPassword()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.password, other.password); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConfiguration()).compareTo(other.isSetConfiguration()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConfiguration()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.configuration, other.configuration); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSOpenSessionReq("); + boolean first = true; + + sb.append("client_protocol:"); + if (this.client_protocol == null) { + sb.append("null"); + } else { + sb.append(this.client_protocol); + } + first = false; + if (isSetUsername()) { + if (!first) sb.append(", "); + sb.append("username:"); + if (this.username == null) { + sb.append("null"); + } else { + sb.append(this.username); + } + first = false; + } + if (isSetPassword()) { + if (!first) sb.append(", "); + sb.append("password:"); + if (this.password == null) { + sb.append("null"); + } else { + sb.append(this.password); + } + first = false; + } + if (isSetConfiguration()) { + if (!first) sb.append(", "); + sb.append("configuration:"); + if (this.configuration == null) { + sb.append("null"); + } else { + sb.append(this.configuration); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (client_protocol == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'client_protocol' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSOpenSessionReqStandardSchemeFactory implements SchemeFactory { + public TSOpenSessionReqStandardScheme getScheme() { + return new TSOpenSessionReqStandardScheme(); + } + } + + private static class TSOpenSessionReqStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSOpenSessionReq struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLIENT_PROTOCOL + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32()); + struct.setClient_protocolIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // USERNAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.username = iprot.readString(); + struct.setUsernameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // PASSWORD + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.password = iprot.readString(); + struct.setPasswordIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // CONFIGURATION + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin(); + struct.configuration = new HashMap(2*_map0.size); + String _key1; + String _val2; + for (int _i3 = 0; _i3 < _map0.size; ++_i3) + { + _key1 = iprot.readString(); + _val2 = iprot.readString(); + struct.configuration.put(_key1, _val2); + } + iprot.readMapEnd(); + } + struct.setConfigurationIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSOpenSessionReq struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.client_protocol != null) { + oprot.writeFieldBegin(CLIENT_PROTOCOL_FIELD_DESC); + oprot.writeI32(struct.client_protocol.getValue()); + oprot.writeFieldEnd(); + } + if (struct.username != null) { + if (struct.isSetUsername()) { + oprot.writeFieldBegin(USERNAME_FIELD_DESC); + oprot.writeString(struct.username); + oprot.writeFieldEnd(); + } + } + if (struct.password != null) { + if (struct.isSetPassword()) { + oprot.writeFieldBegin(PASSWORD_FIELD_DESC); + oprot.writeString(struct.password); + oprot.writeFieldEnd(); + } + } + if (struct.configuration != null) { + if (struct.isSetConfiguration()) { + oprot.writeFieldBegin(CONFIGURATION_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.configuration.size())); + for (Map.Entry _iter4 : struct.configuration.entrySet()) + { + oprot.writeString(_iter4.getKey()); + oprot.writeString(_iter4.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSOpenSessionReqTupleSchemeFactory implements SchemeFactory { + public TSOpenSessionReqTupleScheme getScheme() { + return new TSOpenSessionReqTupleScheme(); + } + } + + private static class TSOpenSessionReqTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionReq struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeI32(struct.client_protocol.getValue()); + BitSet optionals = new BitSet(); + if (struct.isSetUsername()) { + optionals.set(0); + } + if (struct.isSetPassword()) { + optionals.set(1); + } + if (struct.isSetConfiguration()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetUsername()) { + oprot.writeString(struct.username); + } + if (struct.isSetPassword()) { + oprot.writeString(struct.password); + } + if (struct.isSetConfiguration()) { + { + oprot.writeI32(struct.configuration.size()); + for (Map.Entry _iter5 : struct.configuration.entrySet()) + { + oprot.writeString(_iter5.getKey()); + oprot.writeString(_iter5.getValue()); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionReq struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32()); + struct.setClient_protocolIsSet(true); + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.username = iprot.readString(); + struct.setUsernameIsSet(true); + } + if (incoming.get(1)) { + struct.password = iprot.readString(); + struct.setPasswordIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TMap _map6 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.configuration = new HashMap(2*_map6.size); + String _key7; + String _val8; + for (int _i9 = 0; _i9 < _map6.size; ++_i9) + { + _key7 = iprot.readString(); + _val8 = iprot.readString(); + struct.configuration.put(_key7, _val8); + } + } + struct.setConfigurationIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOpenSessionResp.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOpenSessionResp.java new file mode 100644 index 00000000000..7461b29f38f --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOpenSessionResp.java @@ -0,0 +1,785 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSOpenSessionResp implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSOpenSessionResp"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField SERVER_PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("serverProtocolVersion", org.apache.thrift.protocol.TType.I32, (short)2); + private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)3); + private static final org.apache.thrift.protocol.TField CONFIGURATION_FIELD_DESC = new org.apache.thrift.protocol.TField("configuration", org.apache.thrift.protocol.TType.MAP, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSOpenSessionRespStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSOpenSessionRespTupleSchemeFactory()); + } + + public TS_Status status; // required + /** + * + * @see TSProtocolVersion + */ + public TSProtocolVersion serverProtocolVersion; // required + public TS_SessionHandle sessionHandle; // optional + public Map configuration; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + /** + * + * @see TSProtocolVersion + */ + SERVER_PROTOCOL_VERSION((short)2, "serverProtocolVersion"), + SESSION_HANDLE((short)3, "sessionHandle"), + CONFIGURATION((short)4, "configuration"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // SERVER_PROTOCOL_VERSION + return SERVER_PROTOCOL_VERSION; + case 3: // SESSION_HANDLE + return SESSION_HANDLE; + case 4: // CONFIGURATION + return CONFIGURATION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.SESSION_HANDLE,_Fields.CONFIGURATION}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TS_Status"))); + tmpMap.put(_Fields.SERVER_PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("serverProtocolVersion", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TSProtocolVersion.class))); + tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TS_SessionHandle"))); + tmpMap.put(_Fields.CONFIGURATION, new org.apache.thrift.meta_data.FieldMetaData("configuration", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSOpenSessionResp.class, metaDataMap); + } + + public TSOpenSessionResp() { + this.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1; + + } + + public TSOpenSessionResp( + TS_Status status, + TSProtocolVersion serverProtocolVersion) + { + this(); + this.status = status; + this.serverProtocolVersion = serverProtocolVersion; + } + + /** + * Performs a deep copy on other. + */ + public TSOpenSessionResp(TSOpenSessionResp other) { + if (other.isSetStatus()) { + this.status = other.status; + } + if (other.isSetServerProtocolVersion()) { + this.serverProtocolVersion = other.serverProtocolVersion; + } + if (other.isSetSessionHandle()) { + this.sessionHandle = other.sessionHandle; + } + if (other.isSetConfiguration()) { + Map __this__configuration = new HashMap(other.configuration); + this.configuration = __this__configuration; + } + } + + public TSOpenSessionResp deepCopy() { + return new TSOpenSessionResp(this); + } + + @Override + public void clear() { + this.status = null; + this.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1; + + this.sessionHandle = null; + this.configuration = null; + } + + public TS_Status getStatus() { + return this.status; + } + + public TSOpenSessionResp setStatus(TS_Status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + /** + * + * @see TSProtocolVersion + */ + public TSProtocolVersion getServerProtocolVersion() { + return this.serverProtocolVersion; + } + + /** + * + * @see TSProtocolVersion + */ + public TSOpenSessionResp setServerProtocolVersion(TSProtocolVersion serverProtocolVersion) { + this.serverProtocolVersion = serverProtocolVersion; + return this; + } + + public void unsetServerProtocolVersion() { + this.serverProtocolVersion = null; + } + + /** Returns true if field serverProtocolVersion is set (has been assigned a value) and false otherwise */ + public boolean isSetServerProtocolVersion() { + return this.serverProtocolVersion != null; + } + + public void setServerProtocolVersionIsSet(boolean value) { + if (!value) { + this.serverProtocolVersion = null; + } + } + + public TS_SessionHandle getSessionHandle() { + return this.sessionHandle; + } + + public TSOpenSessionResp setSessionHandle(TS_SessionHandle sessionHandle) { + this.sessionHandle = sessionHandle; + return this; + } + + public void unsetSessionHandle() { + this.sessionHandle = null; + } + + /** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */ + public boolean isSetSessionHandle() { + return this.sessionHandle != null; + } + + public void setSessionHandleIsSet(boolean value) { + if (!value) { + this.sessionHandle = null; + } + } + + public int getConfigurationSize() { + return (this.configuration == null) ? 0 : this.configuration.size(); + } + + public void putToConfiguration(String key, String val) { + if (this.configuration == null) { + this.configuration = new HashMap(); + } + this.configuration.put(key, val); + } + + public Map getConfiguration() { + return this.configuration; + } + + public TSOpenSessionResp setConfiguration(Map configuration) { + this.configuration = configuration; + return this; + } + + public void unsetConfiguration() { + this.configuration = null; + } + + /** Returns true if field configuration is set (has been assigned a value) and false otherwise */ + public boolean isSetConfiguration() { + return this.configuration != null; + } + + public void setConfigurationIsSet(boolean value) { + if (!value) { + this.configuration = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((TS_Status)value); + } + break; + + case SERVER_PROTOCOL_VERSION: + if (value == null) { + unsetServerProtocolVersion(); + } else { + setServerProtocolVersion((TSProtocolVersion)value); + } + break; + + case SESSION_HANDLE: + if (value == null) { + unsetSessionHandle(); + } else { + setSessionHandle((TS_SessionHandle)value); + } + break; + + case CONFIGURATION: + if (value == null) { + unsetConfiguration(); + } else { + setConfiguration((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case SERVER_PROTOCOL_VERSION: + return getServerProtocolVersion(); + + case SESSION_HANDLE: + return getSessionHandle(); + + case CONFIGURATION: + return getConfiguration(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case SERVER_PROTOCOL_VERSION: + return isSetServerProtocolVersion(); + case SESSION_HANDLE: + return isSetSessionHandle(); + case CONFIGURATION: + return isSetConfiguration(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSOpenSessionResp) + return this.equals((TSOpenSessionResp)that); + return false; + } + + public boolean equals(TSOpenSessionResp that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_serverProtocolVersion = true && this.isSetServerProtocolVersion(); + boolean that_present_serverProtocolVersion = true && that.isSetServerProtocolVersion(); + if (this_present_serverProtocolVersion || that_present_serverProtocolVersion) { + if (!(this_present_serverProtocolVersion && that_present_serverProtocolVersion)) + return false; + if (!this.serverProtocolVersion.equals(that.serverProtocolVersion)) + return false; + } + + boolean this_present_sessionHandle = true && this.isSetSessionHandle(); + boolean that_present_sessionHandle = true && that.isSetSessionHandle(); + if (this_present_sessionHandle || that_present_sessionHandle) { + if (!(this_present_sessionHandle && that_present_sessionHandle)) + return false; + if (!this.sessionHandle.equals(that.sessionHandle)) + return false; + } + + boolean this_present_configuration = true && this.isSetConfiguration(); + boolean that_present_configuration = true && that.isSetConfiguration(); + if (this_present_configuration || that_present_configuration) { + if (!(this_present_configuration && that_present_configuration)) + return false; + if (!this.configuration.equals(that.configuration)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_status = true && (isSetStatus()); + list.add(present_status); + if (present_status) + list.add(status); + + boolean present_serverProtocolVersion = true && (isSetServerProtocolVersion()); + list.add(present_serverProtocolVersion); + if (present_serverProtocolVersion) + list.add(serverProtocolVersion.getValue()); + + boolean present_sessionHandle = true && (isSetSessionHandle()); + list.add(present_sessionHandle); + if (present_sessionHandle) + list.add(sessionHandle); + + boolean present_configuration = true && (isSetConfiguration()); + list.add(present_configuration); + if (present_configuration) + list.add(configuration); + + return list.hashCode(); + } + + @Override + public int compareTo(TSOpenSessionResp other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetServerProtocolVersion()).compareTo(other.isSetServerProtocolVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServerProtocolVersion()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverProtocolVersion, other.serverProtocolVersion); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSessionHandle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConfiguration()).compareTo(other.isSetConfiguration()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConfiguration()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.configuration, other.configuration); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSOpenSessionResp("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (!first) sb.append(", "); + sb.append("serverProtocolVersion:"); + if (this.serverProtocolVersion == null) { + sb.append("null"); + } else { + sb.append(this.serverProtocolVersion); + } + first = false; + if (isSetSessionHandle()) { + if (!first) sb.append(", "); + sb.append("sessionHandle:"); + if (this.sessionHandle == null) { + sb.append("null"); + } else { + sb.append(this.sessionHandle); + } + first = false; + } + if (isSetConfiguration()) { + if (!first) sb.append(", "); + sb.append("configuration:"); + if (this.configuration == null) { + sb.append("null"); + } else { + sb.append(this.configuration); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (status == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); + } + if (serverProtocolVersion == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'serverProtocolVersion' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSOpenSessionRespStandardSchemeFactory implements SchemeFactory { + public TSOpenSessionRespStandardScheme getScheme() { + return new TSOpenSessionRespStandardScheme(); + } + } + + private static class TSOpenSessionRespStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSOpenSessionResp struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SERVER_PROTOCOL_VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32()); + struct.setServerProtocolVersionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // SESSION_HANDLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // CONFIGURATION + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map10 = iprot.readMapBegin(); + struct.configuration = new HashMap(2*_map10.size); + String _key11; + String _val12; + for (int _i13 = 0; _i13 < _map10.size; ++_i13) + { + _key11 = iprot.readString(); + _val12 = iprot.readString(); + struct.configuration.put(_key11, _val12); + } + iprot.readMapEnd(); + } + struct.setConfigurationIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSOpenSessionResp struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.serverProtocolVersion != null) { + oprot.writeFieldBegin(SERVER_PROTOCOL_VERSION_FIELD_DESC); + oprot.writeI32(struct.serverProtocolVersion.getValue()); + oprot.writeFieldEnd(); + } + if (struct.sessionHandle != null) { + if (struct.isSetSessionHandle()) { + oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC); + struct.sessionHandle.write(oprot); + oprot.writeFieldEnd(); + } + } + if (struct.configuration != null) { + if (struct.isSetConfiguration()) { + oprot.writeFieldBegin(CONFIGURATION_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.configuration.size())); + for (Map.Entry _iter14 : struct.configuration.entrySet()) + { + oprot.writeString(_iter14.getKey()); + oprot.writeString(_iter14.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSOpenSessionRespTupleSchemeFactory implements SchemeFactory { + public TSOpenSessionRespTupleScheme getScheme() { + return new TSOpenSessionRespTupleScheme(); + } + } + + private static class TSOpenSessionRespTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionResp struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + oprot.writeI32(struct.serverProtocolVersion.getValue()); + BitSet optionals = new BitSet(); + if (struct.isSetSessionHandle()) { + optionals.set(0); + } + if (struct.isSetConfiguration()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetSessionHandle()) { + struct.sessionHandle.write(oprot); + } + if (struct.isSetConfiguration()) { + { + oprot.writeI32(struct.configuration.size()); + for (Map.Entry _iter15 : struct.configuration.entrySet()) + { + oprot.writeString(_iter15.getKey()); + oprot.writeString(_iter15.getValue()); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionResp struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new TS_Status(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + struct.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32()); + struct.setServerProtocolVersionIsSet(true); + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.sessionHandle = new TS_SessionHandle(); + struct.sessionHandle.read(iprot); + struct.setSessionHandleIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TMap _map16 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.configuration = new HashMap(2*_map16.size); + String _key17; + String _val18; + for (int _i19 = 0; _i19 < _map16.size; ++_i19) + { + _key17 = iprot.readString(); + _val18 = iprot.readString(); + struct.configuration.put(_key17, _val18); + } + } + struct.setConfigurationIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOperationHandle.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOperationHandle.java new file mode 100644 index 00000000000..1ef69b4b1ac --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSOperationHandle.java @@ -0,0 +1,496 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSOperationHandle implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSOperationHandle"); + + private static final org.apache.thrift.protocol.TField OPERATION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("operationId", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField HAS_RESULT_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("hasResultSet", org.apache.thrift.protocol.TType.BOOL, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSOperationHandleStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSOperationHandleTupleSchemeFactory()); + } + + public TSHandleIdentifier operationId; // required + public boolean hasResultSet; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + OPERATION_ID((short)1, "operationId"), + HAS_RESULT_SET((short)2, "hasResultSet"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // OPERATION_ID + return OPERATION_ID; + case 2: // HAS_RESULT_SET + return HAS_RESULT_SET; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __HASRESULTSET_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.OPERATION_ID, new org.apache.thrift.meta_data.FieldMetaData("operationId", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSHandleIdentifier.class))); + tmpMap.put(_Fields.HAS_RESULT_SET, new org.apache.thrift.meta_data.FieldMetaData("hasResultSet", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSOperationHandle.class, metaDataMap); + } + + public TSOperationHandle() { + } + + public TSOperationHandle( + TSHandleIdentifier operationId, + boolean hasResultSet) + { + this(); + this.operationId = operationId; + this.hasResultSet = hasResultSet; + setHasResultSetIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public TSOperationHandle(TSOperationHandle other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetOperationId()) { + this.operationId = new TSHandleIdentifier(other.operationId); + } + this.hasResultSet = other.hasResultSet; + } + + public TSOperationHandle deepCopy() { + return new TSOperationHandle(this); + } + + @Override + public void clear() { + this.operationId = null; + setHasResultSetIsSet(false); + this.hasResultSet = false; + } + + public TSHandleIdentifier getOperationId() { + return this.operationId; + } + + public TSOperationHandle setOperationId(TSHandleIdentifier operationId) { + this.operationId = operationId; + return this; + } + + public void unsetOperationId() { + this.operationId = null; + } + + /** Returns true if field operationId is set (has been assigned a value) and false otherwise */ + public boolean isSetOperationId() { + return this.operationId != null; + } + + public void setOperationIdIsSet(boolean value) { + if (!value) { + this.operationId = null; + } + } + + public boolean isHasResultSet() { + return this.hasResultSet; + } + + public TSOperationHandle setHasResultSet(boolean hasResultSet) { + this.hasResultSet = hasResultSet; + setHasResultSetIsSet(true); + return this; + } + + public void unsetHasResultSet() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __HASRESULTSET_ISSET_ID); + } + + /** Returns true if field hasResultSet is set (has been assigned a value) and false otherwise */ + public boolean isSetHasResultSet() { + return EncodingUtils.testBit(__isset_bitfield, __HASRESULTSET_ISSET_ID); + } + + public void setHasResultSetIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __HASRESULTSET_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case OPERATION_ID: + if (value == null) { + unsetOperationId(); + } else { + setOperationId((TSHandleIdentifier)value); + } + break; + + case HAS_RESULT_SET: + if (value == null) { + unsetHasResultSet(); + } else { + setHasResultSet((Boolean)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case OPERATION_ID: + return getOperationId(); + + case HAS_RESULT_SET: + return Boolean.valueOf(isHasResultSet()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case OPERATION_ID: + return isSetOperationId(); + case HAS_RESULT_SET: + return isSetHasResultSet(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSOperationHandle) + return this.equals((TSOperationHandle)that); + return false; + } + + public boolean equals(TSOperationHandle that) { + if (that == null) + return false; + + boolean this_present_operationId = true && this.isSetOperationId(); + boolean that_present_operationId = true && that.isSetOperationId(); + if (this_present_operationId || that_present_operationId) { + if (!(this_present_operationId && that_present_operationId)) + return false; + if (!this.operationId.equals(that.operationId)) + return false; + } + + boolean this_present_hasResultSet = true; + boolean that_present_hasResultSet = true; + if (this_present_hasResultSet || that_present_hasResultSet) { + if (!(this_present_hasResultSet && that_present_hasResultSet)) + return false; + if (this.hasResultSet != that.hasResultSet) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_operationId = true && (isSetOperationId()); + list.add(present_operationId); + if (present_operationId) + list.add(operationId); + + boolean present_hasResultSet = true; + list.add(present_hasResultSet); + if (present_hasResultSet) + list.add(hasResultSet); + + return list.hashCode(); + } + + @Override + public int compareTo(TSOperationHandle other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetOperationId()).compareTo(other.isSetOperationId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOperationId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationId, other.operationId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetHasResultSet()).compareTo(other.isSetHasResultSet()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetHasResultSet()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hasResultSet, other.hasResultSet); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSOperationHandle("); + boolean first = true; + + sb.append("operationId:"); + if (this.operationId == null) { + sb.append("null"); + } else { + sb.append(this.operationId); + } + first = false; + if (!first) sb.append(", "); + sb.append("hasResultSet:"); + sb.append(this.hasResultSet); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (operationId == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationId' was not present! Struct: " + toString()); + } + // alas, we cannot check 'hasResultSet' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + if (operationId != null) { + operationId.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSOperationHandleStandardSchemeFactory implements SchemeFactory { + public TSOperationHandleStandardScheme getScheme() { + return new TSOperationHandleStandardScheme(); + } + } + + private static class TSOperationHandleStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSOperationHandle struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // OPERATION_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.operationId = new TSHandleIdentifier(); + struct.operationId.read(iprot); + struct.setOperationIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // HAS_RESULT_SET + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.hasResultSet = iprot.readBool(); + struct.setHasResultSetIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetHasResultSet()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'hasResultSet' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSOperationHandle struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.operationId != null) { + oprot.writeFieldBegin(OPERATION_ID_FIELD_DESC); + struct.operationId.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(HAS_RESULT_SET_FIELD_DESC); + oprot.writeBool(struct.hasResultSet); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSOperationHandleTupleSchemeFactory implements SchemeFactory { + public TSOperationHandleTupleScheme getScheme() { + return new TSOperationHandleTupleScheme(); + } + } + + private static class TSOperationHandleTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSOperationHandle struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.operationId.write(oprot); + oprot.writeBool(struct.hasResultSet); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSOperationHandle struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.operationId = new TSHandleIdentifier(); + struct.operationId.read(iprot); + struct.setOperationIdIsSet(true); + struct.hasResultSet = iprot.readBool(); + struct.setHasResultSetIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSProtocolVersion.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSProtocolVersion.java new file mode 100644 index 00000000000..b61b33cf01c --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSProtocolVersion.java @@ -0,0 +1,42 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum TSProtocolVersion implements org.apache.thrift.TEnum { + TSFILE_SERVICE_PROTOCOL_V1(0); + + private final int value; + + private TSProtocolVersion(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static TSProtocolVersion findByValue(int value) { + switch (value) { + case 0: + return TSFILE_SERVICE_PROTOCOL_V1; + default: + return null; + } + } +} diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSQueryDataSet.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSQueryDataSet.java new file mode 100644 index 00000000000..a83cde2a2b5 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TSQueryDataSet.java @@ -0,0 +1,595 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TSQueryDataSet implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSQueryDataSet"); + + private static final org.apache.thrift.protocol.TField KEYS_FIELD_DESC = new org.apache.thrift.protocol.TField("keys", org.apache.thrift.protocol.TType.LIST, (short)1); + private static final org.apache.thrift.protocol.TField VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("values", org.apache.thrift.protocol.TType.LIST, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSQueryDataSetStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSQueryDataSetTupleSchemeFactory()); + } + + public List keys; // required + public List values; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + KEYS((short)1, "keys"), + VALUES((short)2, "values"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // KEYS + return KEYS; + case 2: // VALUES + return VALUES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.KEYS, new org.apache.thrift.meta_data.FieldMetaData("keys", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.VALUES, new org.apache.thrift.meta_data.FieldMetaData("values", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSDynamicOneColumnData")))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSQueryDataSet.class, metaDataMap); + } + + public TSQueryDataSet() { + } + + public TSQueryDataSet( + List keys, + List values) + { + this(); + this.keys = keys; + this.values = values; + } + + /** + * Performs a deep copy on other. + */ + public TSQueryDataSet(TSQueryDataSet other) { + if (other.isSetKeys()) { + List __this__keys = new ArrayList(other.keys); + this.keys = __this__keys; + } + if (other.isSetValues()) { + List __this__values = new ArrayList(other.values.size()); + for (TSDynamicOneColumnData other_element : other.values) { + __this__values.add(other_element); + } + this.values = __this__values; + } + } + + public TSQueryDataSet deepCopy() { + return new TSQueryDataSet(this); + } + + @Override + public void clear() { + this.keys = null; + this.values = null; + } + + public int getKeysSize() { + return (this.keys == null) ? 0 : this.keys.size(); + } + + public java.util.Iterator getKeysIterator() { + return (this.keys == null) ? null : this.keys.iterator(); + } + + public void addToKeys(String elem) { + if (this.keys == null) { + this.keys = new ArrayList(); + } + this.keys.add(elem); + } + + public List getKeys() { + return this.keys; + } + + public TSQueryDataSet setKeys(List keys) { + this.keys = keys; + return this; + } + + public void unsetKeys() { + this.keys = null; + } + + /** Returns true if field keys is set (has been assigned a value) and false otherwise */ + public boolean isSetKeys() { + return this.keys != null; + } + + public void setKeysIsSet(boolean value) { + if (!value) { + this.keys = null; + } + } + + public int getValuesSize() { + return (this.values == null) ? 0 : this.values.size(); + } + + public java.util.Iterator getValuesIterator() { + return (this.values == null) ? null : this.values.iterator(); + } + + public void addToValues(TSDynamicOneColumnData elem) { + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(elem); + } + + public List getValues() { + return this.values; + } + + public TSQueryDataSet setValues(List values) { + this.values = values; + return this; + } + + public void unsetValues() { + this.values = null; + } + + /** Returns true if field values is set (has been assigned a value) and false otherwise */ + public boolean isSetValues() { + return this.values != null; + } + + public void setValuesIsSet(boolean value) { + if (!value) { + this.values = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case KEYS: + if (value == null) { + unsetKeys(); + } else { + setKeys((List)value); + } + break; + + case VALUES: + if (value == null) { + unsetValues(); + } else { + setValues((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case KEYS: + return getKeys(); + + case VALUES: + return getValues(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case KEYS: + return isSetKeys(); + case VALUES: + return isSetValues(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSQueryDataSet) + return this.equals((TSQueryDataSet)that); + return false; + } + + public boolean equals(TSQueryDataSet that) { + if (that == null) + return false; + + boolean this_present_keys = true && this.isSetKeys(); + boolean that_present_keys = true && that.isSetKeys(); + if (this_present_keys || that_present_keys) { + if (!(this_present_keys && that_present_keys)) + return false; + if (!this.keys.equals(that.keys)) + return false; + } + + boolean this_present_values = true && this.isSetValues(); + boolean that_present_values = true && that.isSetValues(); + if (this_present_values || that_present_values) { + if (!(this_present_values && that_present_values)) + return false; + if (!this.values.equals(that.values)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_keys = true && (isSetKeys()); + list.add(present_keys); + if (present_keys) + list.add(keys); + + boolean present_values = true && (isSetValues()); + list.add(present_values); + if (present_values) + list.add(values); + + return list.hashCode(); + } + + @Override + public int compareTo(TSQueryDataSet other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetKeys()).compareTo(other.isSetKeys()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetKeys()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.keys, other.keys); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetValues()).compareTo(other.isSetValues()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetValues()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.values, other.values); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TSQueryDataSet("); + boolean first = true; + + sb.append("keys:"); + if (this.keys == null) { + sb.append("null"); + } else { + sb.append(this.keys); + } + first = false; + if (!first) sb.append(", "); + sb.append("values:"); + if (this.values == null) { + sb.append("null"); + } else { + sb.append(this.values); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (keys == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'keys' was not present! Struct: " + toString()); + } + if (values == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'values' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TSQueryDataSetStandardSchemeFactory implements SchemeFactory { + public TSQueryDataSetStandardScheme getScheme() { + return new TSQueryDataSetStandardScheme(); + } + } + + private static class TSQueryDataSetStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSQueryDataSet struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // KEYS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list52 = iprot.readListBegin(); + struct.keys = new ArrayList(_list52.size); + String _elem53; + for (int _i54 = 0; _i54 < _list52.size; ++_i54) + { + _elem53 = iprot.readString(); + struct.keys.add(_elem53); + } + iprot.readListEnd(); + } + struct.setKeysIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // VALUES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list55 = iprot.readListBegin(); + struct.values = new ArrayList(_list55.size); + TSDynamicOneColumnData _elem56; + for (int _i57 = 0; _i57 < _list55.size; ++_i57) + { + _elem56 = new TSDynamicOneColumnData(); + _elem56.read(iprot); + struct.values.add(_elem56); + } + iprot.readListEnd(); + } + struct.setValuesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSQueryDataSet struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.keys != null) { + oprot.writeFieldBegin(KEYS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.keys.size())); + for (String _iter58 : struct.keys) + { + oprot.writeString(_iter58); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.values != null) { + oprot.writeFieldBegin(VALUES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.values.size())); + for (TSDynamicOneColumnData _iter59 : struct.values) + { + _iter59.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSQueryDataSetTupleSchemeFactory implements SchemeFactory { + public TSQueryDataSetTupleScheme getScheme() { + return new TSQueryDataSetTupleScheme(); + } + } + + private static class TSQueryDataSetTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSQueryDataSet struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + { + oprot.writeI32(struct.keys.size()); + for (String _iter60 : struct.keys) + { + oprot.writeString(_iter60); + } + } + { + oprot.writeI32(struct.values.size()); + for (TSDynamicOneColumnData _iter61 : struct.values) + { + _iter61.write(oprot); + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSQueryDataSet struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + { + org.apache.thrift.protocol.TList _list62 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.keys = new ArrayList(_list62.size); + String _elem63; + for (int _i64 = 0; _i64 < _list62.size; ++_i64) + { + _elem63 = iprot.readString(); + struct.keys.add(_elem63); + } + } + struct.setKeysIsSet(true); + { + org.apache.thrift.protocol.TList _list65 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.values = new ArrayList(_list65.size); + TSDynamicOneColumnData _elem66; + for (int _i67 = 0; _i67 < _list65.size; ++_i67) + { + _elem66 = new TSDynamicOneColumnData(); + _elem66.read(iprot); + struct.values.add(_elem66); + } + } + struct.setValuesIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_SessionHandle.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_SessionHandle.java new file mode 100644 index 00000000000..c87371f61af --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_SessionHandle.java @@ -0,0 +1,396 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TS_SessionHandle implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TS_SessionHandle"); + + private static final org.apache.thrift.protocol.TField SESSION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionId", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TS_SessionHandleStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TS_SessionHandleTupleSchemeFactory()); + } + + public TSHandleIdentifier sessionId; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SESSION_ID((short)1, "sessionId"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SESSION_ID + return SESSION_ID; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SESSION_ID, new org.apache.thrift.meta_data.FieldMetaData("sessionId", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSHandleIdentifier.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TS_SessionHandle.class, metaDataMap); + } + + public TS_SessionHandle() { + } + + public TS_SessionHandle( + TSHandleIdentifier sessionId) + { + this(); + this.sessionId = sessionId; + } + + /** + * Performs a deep copy on other. + */ + public TS_SessionHandle(TS_SessionHandle other) { + if (other.isSetSessionId()) { + this.sessionId = new TSHandleIdentifier(other.sessionId); + } + } + + public TS_SessionHandle deepCopy() { + return new TS_SessionHandle(this); + } + + @Override + public void clear() { + this.sessionId = null; + } + + public TSHandleIdentifier getSessionId() { + return this.sessionId; + } + + public TS_SessionHandle setSessionId(TSHandleIdentifier sessionId) { + this.sessionId = sessionId; + return this; + } + + public void unsetSessionId() { + this.sessionId = null; + } + + /** Returns true if field sessionId is set (has been assigned a value) and false otherwise */ + public boolean isSetSessionId() { + return this.sessionId != null; + } + + public void setSessionIdIsSet(boolean value) { + if (!value) { + this.sessionId = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SESSION_ID: + if (value == null) { + unsetSessionId(); + } else { + setSessionId((TSHandleIdentifier)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SESSION_ID: + return getSessionId(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SESSION_ID: + return isSetSessionId(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TS_SessionHandle) + return this.equals((TS_SessionHandle)that); + return false; + } + + public boolean equals(TS_SessionHandle that) { + if (that == null) + return false; + + boolean this_present_sessionId = true && this.isSetSessionId(); + boolean that_present_sessionId = true && that.isSetSessionId(); + if (this_present_sessionId || that_present_sessionId) { + if (!(this_present_sessionId && that_present_sessionId)) + return false; + if (!this.sessionId.equals(that.sessionId)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_sessionId = true && (isSetSessionId()); + list.add(present_sessionId); + if (present_sessionId) + list.add(sessionId); + + return list.hashCode(); + } + + @Override + public int compareTo(TS_SessionHandle other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSessionId()).compareTo(other.isSetSessionId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSessionId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionId, other.sessionId); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TS_SessionHandle("); + boolean first = true; + + sb.append("sessionId:"); + if (this.sessionId == null) { + sb.append("null"); + } else { + sb.append(this.sessionId); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (sessionId == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionId' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (sessionId != null) { + sessionId.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TS_SessionHandleStandardSchemeFactory implements SchemeFactory { + public TS_SessionHandleStandardScheme getScheme() { + return new TS_SessionHandleStandardScheme(); + } + } + + private static class TS_SessionHandleStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TS_SessionHandle struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SESSION_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sessionId = new TSHandleIdentifier(); + struct.sessionId.read(iprot); + struct.setSessionIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TS_SessionHandle struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.sessionId != null) { + oprot.writeFieldBegin(SESSION_ID_FIELD_DESC); + struct.sessionId.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TS_SessionHandleTupleSchemeFactory implements SchemeFactory { + public TS_SessionHandleTupleScheme getScheme() { + return new TS_SessionHandleTupleScheme(); + } + } + + private static class TS_SessionHandleTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TS_SessionHandle struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.sessionId.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TS_SessionHandle struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.sessionId = new TSHandleIdentifier(); + struct.sessionId.read(iprot); + struct.setSessionIdIsSet(true); + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_Status.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_Status.java new file mode 100644 index 00000000000..19dab519e04 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_Status.java @@ -0,0 +1,885 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10") +public class TS_Status implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TS_Status"); + + private static final org.apache.thrift.protocol.TField STATUS_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("statusCode", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField INFO_MESSAGES_FIELD_DESC = new org.apache.thrift.protocol.TField("infoMessages", org.apache.thrift.protocol.TType.LIST, (short)2); + private static final org.apache.thrift.protocol.TField SQL_STATE_FIELD_DESC = new org.apache.thrift.protocol.TField("sqlState", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField ERROR_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("errorCode", org.apache.thrift.protocol.TType.I32, (short)4); + private static final org.apache.thrift.protocol.TField ERROR_MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("errorMessage", org.apache.thrift.protocol.TType.STRING, (short)5); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TS_StatusStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TS_StatusTupleSchemeFactory()); + } + + /** + * + * @see TS_StatusCode + */ + public TS_StatusCode statusCode; // required + public List infoMessages; // optional + public String sqlState; // optional + public int errorCode; // optional + public String errorMessage; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + /** + * + * @see TS_StatusCode + */ + STATUS_CODE((short)1, "statusCode"), + INFO_MESSAGES((short)2, "infoMessages"), + SQL_STATE((short)3, "sqlState"), + ERROR_CODE((short)4, "errorCode"), + ERROR_MESSAGE((short)5, "errorMessage"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS_CODE + return STATUS_CODE; + case 2: // INFO_MESSAGES + return INFO_MESSAGES; + case 3: // SQL_STATE + return SQL_STATE; + case 4: // ERROR_CODE + return ERROR_CODE; + case 5: // ERROR_MESSAGE + return ERROR_MESSAGE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __ERRORCODE_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.INFO_MESSAGES,_Fields.SQL_STATE,_Fields.ERROR_CODE,_Fields.ERROR_MESSAGE}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS_CODE, new org.apache.thrift.meta_data.FieldMetaData("statusCode", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TS_StatusCode.class))); + tmpMap.put(_Fields.INFO_MESSAGES, new org.apache.thrift.meta_data.FieldMetaData("infoMessages", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.SQL_STATE, new org.apache.thrift.meta_data.FieldMetaData("sqlState", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.ERROR_CODE, new org.apache.thrift.meta_data.FieldMetaData("errorCode", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.ERROR_MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("errorMessage", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TS_Status.class, metaDataMap); + } + + public TS_Status() { + } + + public TS_Status( + TS_StatusCode statusCode) + { + this(); + this.statusCode = statusCode; + } + + /** + * Performs a deep copy on other. + */ + public TS_Status(TS_Status other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetStatusCode()) { + this.statusCode = other.statusCode; + } + if (other.isSetInfoMessages()) { + List __this__infoMessages = new ArrayList(other.infoMessages); + this.infoMessages = __this__infoMessages; + } + if (other.isSetSqlState()) { + this.sqlState = other.sqlState; + } + this.errorCode = other.errorCode; + if (other.isSetErrorMessage()) { + this.errorMessage = other.errorMessage; + } + } + + public TS_Status deepCopy() { + return new TS_Status(this); + } + + @Override + public void clear() { + this.statusCode = null; + this.infoMessages = null; + this.sqlState = null; + setErrorCodeIsSet(false); + this.errorCode = 0; + this.errorMessage = null; + } + + /** + * + * @see TS_StatusCode + */ + public TS_StatusCode getStatusCode() { + return this.statusCode; + } + + /** + * + * @see TS_StatusCode + */ + public TS_Status setStatusCode(TS_StatusCode statusCode) { + this.statusCode = statusCode; + return this; + } + + public void unsetStatusCode() { + this.statusCode = null; + } + + /** Returns true if field statusCode is set (has been assigned a value) and false otherwise */ + public boolean isSetStatusCode() { + return this.statusCode != null; + } + + public void setStatusCodeIsSet(boolean value) { + if (!value) { + this.statusCode = null; + } + } + + public int getInfoMessagesSize() { + return (this.infoMessages == null) ? 0 : this.infoMessages.size(); + } + + public java.util.Iterator getInfoMessagesIterator() { + return (this.infoMessages == null) ? null : this.infoMessages.iterator(); + } + + public void addToInfoMessages(String elem) { + if (this.infoMessages == null) { + this.infoMessages = new ArrayList(); + } + this.infoMessages.add(elem); + } + + public List getInfoMessages() { + return this.infoMessages; + } + + public TS_Status setInfoMessages(List infoMessages) { + this.infoMessages = infoMessages; + return this; + } + + public void unsetInfoMessages() { + this.infoMessages = null; + } + + /** Returns true if field infoMessages is set (has been assigned a value) and false otherwise */ + public boolean isSetInfoMessages() { + return this.infoMessages != null; + } + + public void setInfoMessagesIsSet(boolean value) { + if (!value) { + this.infoMessages = null; + } + } + + public String getSqlState() { + return this.sqlState; + } + + public TS_Status setSqlState(String sqlState) { + this.sqlState = sqlState; + return this; + } + + public void unsetSqlState() { + this.sqlState = null; + } + + /** Returns true if field sqlState is set (has been assigned a value) and false otherwise */ + public boolean isSetSqlState() { + return this.sqlState != null; + } + + public void setSqlStateIsSet(boolean value) { + if (!value) { + this.sqlState = null; + } + } + + public int getErrorCode() { + return this.errorCode; + } + + public TS_Status setErrorCode(int errorCode) { + this.errorCode = errorCode; + setErrorCodeIsSet(true); + return this; + } + + public void unsetErrorCode() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ERRORCODE_ISSET_ID); + } + + /** Returns true if field errorCode is set (has been assigned a value) and false otherwise */ + public boolean isSetErrorCode() { + return EncodingUtils.testBit(__isset_bitfield, __ERRORCODE_ISSET_ID); + } + + public void setErrorCodeIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ERRORCODE_ISSET_ID, value); + } + + public String getErrorMessage() { + return this.errorMessage; + } + + public TS_Status setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + return this; + } + + public void unsetErrorMessage() { + this.errorMessage = null; + } + + /** Returns true if field errorMessage is set (has been assigned a value) and false otherwise */ + public boolean isSetErrorMessage() { + return this.errorMessage != null; + } + + public void setErrorMessageIsSet(boolean value) { + if (!value) { + this.errorMessage = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS_CODE: + if (value == null) { + unsetStatusCode(); + } else { + setStatusCode((TS_StatusCode)value); + } + break; + + case INFO_MESSAGES: + if (value == null) { + unsetInfoMessages(); + } else { + setInfoMessages((List)value); + } + break; + + case SQL_STATE: + if (value == null) { + unsetSqlState(); + } else { + setSqlState((String)value); + } + break; + + case ERROR_CODE: + if (value == null) { + unsetErrorCode(); + } else { + setErrorCode((Integer)value); + } + break; + + case ERROR_MESSAGE: + if (value == null) { + unsetErrorMessage(); + } else { + setErrorMessage((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS_CODE: + return getStatusCode(); + + case INFO_MESSAGES: + return getInfoMessages(); + + case SQL_STATE: + return getSqlState(); + + case ERROR_CODE: + return Integer.valueOf(getErrorCode()); + + case ERROR_MESSAGE: + return getErrorMessage(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case STATUS_CODE: + return isSetStatusCode(); + case INFO_MESSAGES: + return isSetInfoMessages(); + case SQL_STATE: + return isSetSqlState(); + case ERROR_CODE: + return isSetErrorCode(); + case ERROR_MESSAGE: + return isSetErrorMessage(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TS_Status) + return this.equals((TS_Status)that); + return false; + } + + public boolean equals(TS_Status that) { + if (that == null) + return false; + + boolean this_present_statusCode = true && this.isSetStatusCode(); + boolean that_present_statusCode = true && that.isSetStatusCode(); + if (this_present_statusCode || that_present_statusCode) { + if (!(this_present_statusCode && that_present_statusCode)) + return false; + if (!this.statusCode.equals(that.statusCode)) + return false; + } + + boolean this_present_infoMessages = true && this.isSetInfoMessages(); + boolean that_present_infoMessages = true && that.isSetInfoMessages(); + if (this_present_infoMessages || that_present_infoMessages) { + if (!(this_present_infoMessages && that_present_infoMessages)) + return false; + if (!this.infoMessages.equals(that.infoMessages)) + return false; + } + + boolean this_present_sqlState = true && this.isSetSqlState(); + boolean that_present_sqlState = true && that.isSetSqlState(); + if (this_present_sqlState || that_present_sqlState) { + if (!(this_present_sqlState && that_present_sqlState)) + return false; + if (!this.sqlState.equals(that.sqlState)) + return false; + } + + boolean this_present_errorCode = true && this.isSetErrorCode(); + boolean that_present_errorCode = true && that.isSetErrorCode(); + if (this_present_errorCode || that_present_errorCode) { + if (!(this_present_errorCode && that_present_errorCode)) + return false; + if (this.errorCode != that.errorCode) + return false; + } + + boolean this_present_errorMessage = true && this.isSetErrorMessage(); + boolean that_present_errorMessage = true && that.isSetErrorMessage(); + if (this_present_errorMessage || that_present_errorMessage) { + if (!(this_present_errorMessage && that_present_errorMessage)) + return false; + if (!this.errorMessage.equals(that.errorMessage)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_statusCode = true && (isSetStatusCode()); + list.add(present_statusCode); + if (present_statusCode) + list.add(statusCode.getValue()); + + boolean present_infoMessages = true && (isSetInfoMessages()); + list.add(present_infoMessages); + if (present_infoMessages) + list.add(infoMessages); + + boolean present_sqlState = true && (isSetSqlState()); + list.add(present_sqlState); + if (present_sqlState) + list.add(sqlState); + + boolean present_errorCode = true && (isSetErrorCode()); + list.add(present_errorCode); + if (present_errorCode) + list.add(errorCode); + + boolean present_errorMessage = true && (isSetErrorMessage()); + list.add(present_errorMessage); + if (present_errorMessage) + list.add(errorMessage); + + return list.hashCode(); + } + + @Override + public int compareTo(TS_Status other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetStatusCode()).compareTo(other.isSetStatusCode()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatusCode()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statusCode, other.statusCode); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetInfoMessages()).compareTo(other.isSetInfoMessages()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetInfoMessages()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.infoMessages, other.infoMessages); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSqlState()).compareTo(other.isSetSqlState()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSqlState()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sqlState, other.sqlState); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetErrorCode()).compareTo(other.isSetErrorCode()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetErrorCode()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorCode, other.errorCode); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetErrorMessage()).compareTo(other.isSetErrorMessage()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetErrorMessage()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorMessage, other.errorMessage); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TS_Status("); + boolean first = true; + + sb.append("statusCode:"); + if (this.statusCode == null) { + sb.append("null"); + } else { + sb.append(this.statusCode); + } + first = false; + if (isSetInfoMessages()) { + if (!first) sb.append(", "); + sb.append("infoMessages:"); + if (this.infoMessages == null) { + sb.append("null"); + } else { + sb.append(this.infoMessages); + } + first = false; + } + if (isSetSqlState()) { + if (!first) sb.append(", "); + sb.append("sqlState:"); + if (this.sqlState == null) { + sb.append("null"); + } else { + sb.append(this.sqlState); + } + first = false; + } + if (isSetErrorCode()) { + if (!first) sb.append(", "); + sb.append("errorCode:"); + sb.append(this.errorCode); + first = false; + } + if (isSetErrorMessage()) { + if (!first) sb.append(", "); + sb.append("errorMessage:"); + if (this.errorMessage == null) { + sb.append("null"); + } else { + sb.append(this.errorMessage); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (statusCode == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'statusCode' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TS_StatusStandardSchemeFactory implements SchemeFactory { + public TS_StatusStandardScheme getScheme() { + return new TS_StatusStandardScheme(); + } + } + + private static class TS_StatusStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TS_Status struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS_CODE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.statusCode = cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode.findByValue(iprot.readI32()); + struct.setStatusCodeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // INFO_MESSAGES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list20 = iprot.readListBegin(); + struct.infoMessages = new ArrayList(_list20.size); + String _elem21; + for (int _i22 = 0; _i22 < _list20.size; ++_i22) + { + _elem21 = iprot.readString(); + struct.infoMessages.add(_elem21); + } + iprot.readListEnd(); + } + struct.setInfoMessagesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // SQL_STATE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.sqlState = iprot.readString(); + struct.setSqlStateIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // ERROR_CODE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.errorCode = iprot.readI32(); + struct.setErrorCodeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // ERROR_MESSAGE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.errorMessage = iprot.readString(); + struct.setErrorMessageIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TS_Status struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.statusCode != null) { + oprot.writeFieldBegin(STATUS_CODE_FIELD_DESC); + oprot.writeI32(struct.statusCode.getValue()); + oprot.writeFieldEnd(); + } + if (struct.infoMessages != null) { + if (struct.isSetInfoMessages()) { + oprot.writeFieldBegin(INFO_MESSAGES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.infoMessages.size())); + for (String _iter23 : struct.infoMessages) + { + oprot.writeString(_iter23); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.sqlState != null) { + if (struct.isSetSqlState()) { + oprot.writeFieldBegin(SQL_STATE_FIELD_DESC); + oprot.writeString(struct.sqlState); + oprot.writeFieldEnd(); + } + } + if (struct.isSetErrorCode()) { + oprot.writeFieldBegin(ERROR_CODE_FIELD_DESC); + oprot.writeI32(struct.errorCode); + oprot.writeFieldEnd(); + } + if (struct.errorMessage != null) { + if (struct.isSetErrorMessage()) { + oprot.writeFieldBegin(ERROR_MESSAGE_FIELD_DESC); + oprot.writeString(struct.errorMessage); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TS_StatusTupleSchemeFactory implements SchemeFactory { + public TS_StatusTupleScheme getScheme() { + return new TS_StatusTupleScheme(); + } + } + + private static class TS_StatusTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TS_Status struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeI32(struct.statusCode.getValue()); + BitSet optionals = new BitSet(); + if (struct.isSetInfoMessages()) { + optionals.set(0); + } + if (struct.isSetSqlState()) { + optionals.set(1); + } + if (struct.isSetErrorCode()) { + optionals.set(2); + } + if (struct.isSetErrorMessage()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); + if (struct.isSetInfoMessages()) { + { + oprot.writeI32(struct.infoMessages.size()); + for (String _iter24 : struct.infoMessages) + { + oprot.writeString(_iter24); + } + } + } + if (struct.isSetSqlState()) { + oprot.writeString(struct.sqlState); + } + if (struct.isSetErrorCode()) { + oprot.writeI32(struct.errorCode); + } + if (struct.isSetErrorMessage()) { + oprot.writeString(struct.errorMessage); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TS_Status struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.statusCode = cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode.findByValue(iprot.readI32()); + struct.setStatusCodeIsSet(true); + BitSet incoming = iprot.readBitSet(4); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list25 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.infoMessages = new ArrayList(_list25.size); + String _elem26; + for (int _i27 = 0; _i27 < _list25.size; ++_i27) + { + _elem26 = iprot.readString(); + struct.infoMessages.add(_elem26); + } + } + struct.setInfoMessagesIsSet(true); + } + if (incoming.get(1)) { + struct.sqlState = iprot.readString(); + struct.setSqlStateIsSet(true); + } + if (incoming.get(2)) { + struct.errorCode = iprot.readI32(); + struct.setErrorCodeIsSet(true); + } + if (incoming.get(3)) { + struct.errorMessage = iprot.readString(); + struct.setErrorMessageIsSet(true); + } + } + } + +} + diff --git a/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_StatusCode.java b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_StatusCode.java new file mode 100644 index 00000000000..713335ee602 --- /dev/null +++ b/src/main/java/cn/edu/thu/tsfiledb/service/rpc/thrift/TS_StatusCode.java @@ -0,0 +1,54 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package cn.edu.thu.tsfiledb.service.rpc.thrift; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum TS_StatusCode implements org.apache.thrift.TEnum { + SUCCESS_STATUS(0), + SUCCESS_WITH_INFO_STATUS(1), + STILL_EXECUTING_STATUS(2), + ERROR_STATUS(3), + INVALID_HANDLE_STATUS(4); + + private final int value; + + private TS_StatusCode(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static TS_StatusCode findByValue(int value) { + switch (value) { + case 0: + return SUCCESS_STATUS; + case 1: + return SUCCESS_WITH_INFO_STATUS; + case 2: + return STILL_EXECUTING_STATUS; + case 3: + return ERROR_STATUS; + case 4: + return INVALID_HANDLE_STATUS; + default: + return null; + } + } +} diff --git a/src/main/resources/rpc.thrift b/src/main/resources/rpc.thrift new file mode 100644 index 00000000000..93bf1df2212 --- /dev/null +++ b/src/main/resources/rpc.thrift @@ -0,0 +1,326 @@ +namespace java cn.edu.thu.tsfiledb.service.rpc.thrift + +service TSIService { + TSOpenSessionResp OpenSession(1:TSOpenSessionReq req); + + TSCloseSessionResp CloseSession(1:TSCloseSessionReq req); + + TSExecuteStatementResp ExecuteStatement(1:TSExecuteStatementReq req); + + TSExecuteBatchStatementResp ExecuteBatchStatement(1:TSExecuteBatchStatementReq req); + + TSExecuteStatementResp ExecuteQueryStatement(1:TSExecuteStatementReq req); + + TSExecuteStatementResp ExecuteUpdateStatement(1:TSExecuteStatementReq req); + + TSFetchResultsResp FetchResults(1:TSFetchResultsReq req) + + TSFetchMetadataResp FetchMetadata(1:TSFetchMetadataReq req) + + //TSGetOperationStatusResp GetOperationStatus(1:TSGetOperationStatusReq req); + + TSCancelOperationResp CancelOperation(1:TSCancelOperationReq req); + + TSCloseOperationResp CloseOperation(1:TSCloseOperationReq req); + + + //TSGetResultSetMetadataResp GetResultSetMetadata(1:TSGetResultSetMetadataReq req); + + //TSFetchResultsResp FetchResults(1:TSFetchResultsReq req); +} + +enum TSProtocolVersion { + TSFILE_SERVICE_PROTOCOL_V1, +} + +// OpenSession() +// +// Open a session (connection) on the server against +// which operations may be executed. +struct TSOpenSessionReq { + 1: required TSProtocolVersion client_protocol = TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1 + 2: optional string username + 3: optional string password + 4: optional map configuration +} + +struct TSOpenSessionResp { + 1: required TS_Status status + + // The protocol version that the server is using. + 2: required TSProtocolVersion serverProtocolVersion = TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1 + + // Session Handle + 3: optional TS_SessionHandle sessionHandle + + // The configuration settings for this session. + 4: optional map configuration +} + +// The return status code contained in each response. +enum TS_StatusCode { + SUCCESS_STATUS, + SUCCESS_WITH_INFO_STATUS, + STILL_EXECUTING_STATUS, + ERROR_STATUS, + INVALID_HANDLE_STATUS +} + +// The return status of a remote request +struct TS_Status { + 1: required TS_StatusCode statusCode + + // If status is SUCCESS_WITH_INFO, info_msgs may be populated with + // additional diagnostic information. + 2: optional list infoMessages + + // If status is ERROR, then the following fields may be set + 3: optional string sqlState // as defined in the ISO/IEF CLI specification + 4: optional i32 errorCode // internal error code + 5: optional string errorMessage +} + + +// CloseSession() +// +// Closes the specified session and frees any resources +// currently allocated to that session. Any open +// operations in that session will be canceled. +struct TSCloseSessionReq { + 1: required TS_SessionHandle sessionHandle +} + +struct TSCloseSessionResp { + 1: required TS_Status status +} + +struct TSHandleIdentifier { + // 16 byte globally unique identifier + // This is the public ID of the handle and + // can be used for reporting. + 1: required binary guid, + + // 16 byte secret generated by the server + // and used to verify that the handle is not + // being hijacked by another user. + 2: required binary secret, +} + +// Client-side handle to persistent +// session information on the server-side. +struct TS_SessionHandle { + 1: required TSHandleIdentifier sessionId +} + + +struct TSGetOperationStatusReq { + // Session to run this request against + 1: required TSOperationHandle operationHandle +} + +struct TSGetOperationStatusResp { + 1: required TS_Status status + //2: optional TSOperationState operationState + + // If operationState is ERROR_STATE, then the following fields may be set + // sqlState as defined in the ISO/IEF CLI specification + //3: optional string sqlState + + // Internal error code + //4: optional i32 errorCode + + // Error message + //5: optional string errorMessage + + // List of statuses of sub tasks + //6: optional string taskStatus + + // When was the operation started + //7: optional i64 operationStarted + + // When was the operation completed + //8: optional i64 operationCompleted + + // If the operation has the result + //9: optional bool hasResultSet +} + +// CancelOperation() +// +// Cancels processing on the specified operation handle and +// frees any resources which were allocated. +struct TSCancelOperationReq { + // Operation to cancel + 1: required TSOperationHandle operationHandle +} + +struct TSCancelOperationResp { + 1: required TS_Status status +} + + +// CloseOperation() +// +// Given an operation in the FINISHED, CANCELED, +// or ERROR states, CloseOperation() will free +// all of the resources which were allocated on +// the server to service the operation. +struct TSCloseOperationReq { + 1: required TSOperationHandle operationHandle +} + +struct TSCloseOperationResp { + 1: required TS_Status status +} + +// Client-side reference to a task running +// asynchronously on the server. +struct TSOperationHandle { + 1: required TSHandleIdentifier operationId + + // If hasResultSet = TRUE, then this operation + // generates a result set that can be fetched. + // Note that the result set may be empty. + // + // If hasResultSet = FALSE, then this operation + // does not generate a result set, and calling + // GetResultSetMetadata or FetchResults against + // this OperationHandle will generate an error. + 2: required bool hasResultSet + + //3: required TSOperationType operationType + + // For operations that don't generate result sets, + // modifiedRowCount is either: + // + // 1) The number of rows that were modified by + // the DML operation (e.g. number of rows inserted, + // number of rows deleted, etc). + // + // 2) 0 for operations that don't modify or add rows. + // + // 3) < 0 if the operation is capable of modifiying rows, + // but Hive is unable to determine how many rows were + // modified. For example, Hive's LOAD DATA command + // doesn't generate row count information because + // Hive doesn't inspect the data as it is loaded. + // + // modifiedRowCount is unset if the operation generates + // a result set. + //4: optional double modifiedRowCount +} + +// ExecuteStatement() +// +// Execute a statement. +// The returned OperationHandle can be used to check on the +// status of the statement, and to fetch results once the +// statement has finished executing. +struct TSExecuteStatementReq { + // The session to execute the statement against + 1: required TS_SessionHandle sessionHandle + + // The statement to be executed (DML, DDL, SET, etc) + 2: required string statement + + // Configuration properties that are overlayed on top of the + // the existing session configuration before this statement + // is executed. These properties apply to this statement + // only and will not affect the subsequent state of the Session. + //3: optional map confOverlay + + // Execute asynchronously when runAsync is true + //4: optional bool runAsync = false + + // The number of seconds after which the query will timeout on the server + //5: optional i64 queryTimeout = 0 +} + +struct TSExecuteStatementResp { + 1: required TS_Status status + 2: optional TSOperationHandle operationHandle + 3: optional list columns +} + +struct TSExecuteBatchStatementResp{ + 1: required TS_Status status + + 2: optional list result +} + +struct TSExecuteBatchStatementReq{ + // The session to execute the statement against + 1: required TS_SessionHandle sessionHandle + + // The statements to be executed (DML, DDL, SET, etc) + 2: required list statements +} + +struct TSQueryDataSet{ + 1: required list keys + 2: required list values +} + +struct TSDynamicOneColumnData{ + 1: required string deviceType + 2: required string dataType + 3: required i32 length + + 4: required list timeRet + + 5: optional list boolList + 6: optional list i32List + 7: optional list i64List + 8: optional list floatList + 9: optional list doubleList + 10: optional list binaryList +} + +struct TSFetchResultsReq{ + 1: required string statement + 2: required i32 fetch_size +} + +struct TSFetchResultsResp{ + 1: required TS_Status status + 2: required bool hasResultSet + 3: optional TSQueryDataSet queryDataSet +} +// +// struct TSJDBCRecord { +// 1: required string deviceType +// 2: required string deviceId +// 3: required list dataList +// 4: required TSTimeValue timeValue +// } +// +// struct TSTimeValue { +// 1: required i64 time +// } +// +// struct TSDataPoint{ +// 1: required string type +// 2: required string sensorId +// 3: required string deviceId +// 4: required string valueStr +// 5: optional i32 groupId +// } + +struct TSFetchMetadataResp{ + 1: required TS_Status status + 2: optional map> seriesMap + 3: optional map> deltaObjectMap + 4: optional string metadataInJson +} + +struct TSFetchMetadataReq{ + +} + + +struct TSColumnSchema{ + 1: optional string name; + 2: optional string dataType; + 3: optional string encoding; + 4: optional map otherArgs; +} diff --git a/src/test/java/cn/edu/thu/tsfiledb/auth/AuthTest.java b/src/test/java/cn/edu/thu/tsfiledb/auth/AuthTest.java new file mode 100644 index 00000000000..d53e1cb3a1d --- /dev/null +++ b/src/test/java/cn/edu/thu/tsfiledb/auth/AuthTest.java @@ -0,0 +1,236 @@ +package cn.edu.thu.tsfiledb.auth; + +import static org.junit.Assert.assertEquals; + +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import cn.edu.thu.tsfiledb.auth.dao.AuthDao; +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.dao.RoleDao; +import cn.edu.thu.tsfiledb.auth.dao.UserDao; +import cn.edu.thu.tsfiledb.auth.model.Permission; +import cn.edu.thu.tsfiledb.auth.model.Role; +import cn.edu.thu.tsfiledb.auth.model.RolePermission; +import cn.edu.thu.tsfiledb.auth.model.User; +import cn.edu.thu.tsfiledb.auth.model.UserPermission; + +public class AuthTest { + + private DBdao dbDao = null; + private Statement statement = null; + private AuthDao authDao = null; + // prepare the data + private User user1; + private User user2; + private Role role1; + private Role role2; + + @Before + public void setUp() throws Exception { + + dbDao = new DBdao(); + authDao = new AuthDao(); + dbDao.open(); + statement = dbDao.getStatement(); + + // init data + user1 = new User("user1", "user1"); + user2 = new User("user2", "user2"); + + role1 = new Role("role1"); + role2 = new Role("role2"); + } + + @After + public void tearDown() throws Exception { + dbDao.close(); + } + + @Test + public void testUser() { + authDao.deleteUser(statement, user1.getUserName()); + // add user + assertEquals(true, authDao.addUser(statement, user1)); + // check the user inserted + UserDao userDao = new UserDao(); + User user = userDao.getUser(statement, user1.getUserName()); + assertEquals(user1.getUserName(), user.getUserName()); + assertEquals(user1.getPassWord(), user.getPassWord()); + // delete the user + assertEquals(true, authDao.deleteUser(statement, user1.getUserName())); + assertEquals(null, userDao.getUser(statement, user1.getUserName())); + + authDao.addUser(statement, user1); + authDao.addUser(statement, user2); + // add the root user + assertEquals(3, authDao.getUsers(statement).size()); + authDao.deleteUser(statement, user1.getUserName()); + authDao.deleteUser(statement, user2.getUserName()); + } + + @Test + public void testRole() { + authDao.deleteRole(statement, role1.getRoleName()); + // add role + assertEquals(true, authDao.addRole(statement, role1)); + // check the role inserted + RoleDao roleDao = new RoleDao(); + Role role = roleDao.getRole(statement, role1.getRoleName()); + assertEquals(role1.getRoleName(), role.getRoleName()); + // delete the role + assertEquals(true, authDao.deleteRole(statement, role1.getRoleName())); + assertEquals(null, roleDao.getRole(statement, role1.getRoleName())); + + authDao.addRole(statement, role1); + authDao.addRole(statement, role2); + assertEquals(2, authDao.getRoles(statement).size()); + authDao.deleteRole(statement, role1.getRoleName()); + authDao.deleteRole(statement, role2.getRoleName()); + } + + @Test + public void testUserRoleRel() { + // add user and role + authDao.addUser(statement, user1); + authDao.addUser(statement, user2); + authDao.addRole(statement, role1); + authDao.addRole(statement, role2); + + // add relation + assertEquals(true, authDao.addUserRoleRel(statement, user1.getUserName(), role1.getRoleName())); + assertEquals(1, authDao.getAllUserRoleRel(statement).size()); + assertEquals(true, authDao.addUserRoleRel(statement, user1.getUserName(), role2.getRoleName())); + List roles = authDao.getRolesByUser(statement, user1.getUserName()); + assertEquals(2, roles.size()); + for (Role role : roles) { + assertEquals(true, (role.getRoleName().equals(role1.getRoleName())) + || (role.getRoleName().equals(role2.getRoleName()))); + } + // delete the relation + authDao.deleteUserRoleRel(statement, user1.getUserName(), role1.getRoleName()); + authDao.deleteUserRoleRel(statement, user1.getUserName(), role2.getRoleName()); + assertEquals(0, authDao.getAllUserRoleRel(statement).size()); + // delete user and role + authDao.deleteUser(statement, user1.getUserName()); + authDao.deleteUser(statement, user2.getUserName()); + authDao.deleteRole(statement, role1.getRoleName()); + authDao.deleteRole(statement, role2.getRoleName()); + } + + @Test + public void testUserPermission() { + int permissionId1 = Permission.CREATE; + int permissionId2 = Permission.DELETE; + int permissionId3 = Permission.INSERT; + String nodeName = "nodeName"; + authDao.addUser(statement, user1); + + // add permission + authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId1); + authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId2); + authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId3); + assertEquals(false, authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId1)); + List userPermissions = authDao.getUserPermission(statement, user1.getUserName(), nodeName); + assertEquals(3, userPermissions.size()); + List list = new ArrayList<>(); + for (UserPermission userPermission : userPermissions) { + list.add(userPermission.getPermissionId()); + } + List checkList = new ArrayList<>(); + checkList.add(permissionId1); + checkList.add(permissionId2); + checkList.add(permissionId3); + checkList.removeAll(list); + assertEquals(0, checkList.size()); + // delete permission + authDao.deleteUserPermission(statement, user1.getUserName(), nodeName, permissionId1); + assertEquals(2, authDao.getUserPermission(statement, user1.getUserName(), nodeName).size()); + authDao.deleteUserPermission(statement, user1.getUserName(), nodeName, permissionId2); + assertEquals(1, authDao.getUserPermission(statement, user1.getUserName(), nodeName).size()); + authDao.deleteUserPermission(statement, user1.getUserName(), nodeName, permissionId3); + assertEquals(0, authDao.getUserPermission(statement, user1.getUserName(), nodeName).size()); + // delete user + authDao.deleteUser(statement, user1.getUserName()); + } + + @Test + public void testRolePermission() { + int permissionId1 = Permission.CREATE; + int permissionId2 = Permission.DELETE; + int permissionId3 = Permission.INSERT; + String nodeName = "nodeName"; + authDao.addRole(statement, role1); + // add permission + authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId1); + authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId2); + authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId3); + assertEquals(false, authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId1)); + + List rolePermissions = authDao.getRolePermission(statement, role1.getRoleName(), nodeName); + assertEquals(3, rolePermissions.size()); + List list = new ArrayList<>(); + for (RolePermission rolePermission : rolePermissions) { + list.add(rolePermission.getPermissionId()); + } + List checkList = new ArrayList<>(); + checkList.add(permissionId1); + checkList.add(permissionId2); + checkList.add(permissionId3); + checkList.removeAll(list); + assertEquals(0, checkList.size()); + // delete permission + authDao.deleteRolePermission(statement, role1.getRoleName(), nodeName, permissionId1); + assertEquals(2, authDao.getRolePermission(statement, role1.getRoleName(), nodeName).size()); + authDao.deleteRolePermission(statement, role1.getRoleName(), nodeName, permissionId2); + assertEquals(1, authDao.getRolePermission(statement, role1.getRoleName(), nodeName).size()); + authDao.deleteRolePermission(statement, role1.getRoleName(), nodeName, permissionId3); + assertEquals(0, authDao.getRolePermission(statement, role1.getRoleName(), nodeName).size()); + // delete user + authDao.deleteRole(statement, role1.getRoleName()); + } + + @Test + public void testUserAllPermission() { + String nodeName = "nodeName"; + String newNodeName = "newNodeName"; + int permissionId1 = Permission.CREATE; + int permissionId2 = Permission.DELETE; + int permissionId3 = Permission.INSERT; + + // add user + authDao.addUser(statement, user1); + // add role + authDao.addRole(statement, role1); + authDao.addRole(statement, role2); + + // only add permission to user + authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId1); + assertEquals(1, authDao.getAllUserPermission(statement, user1.getUserName(), nodeName).size()); + // add role1 permission + authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId1); + authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId3); + // add permission to different node + authDao.addRolePermission(statement, role1.getRoleName(), newNodeName, permissionId2); + // add role2 permission + authDao.addRolePermission(statement, role2.getRoleName(), nodeName, permissionId1); + // add roles(role1,role2) to user + authDao.addUserRoleRel(statement, user1.getUserName(), role1.getRoleName()); + authDao.addUserRoleRel(statement, user1.getUserName(), role2.getRoleName()); + + // check the all user's permission + assertEquals(2, authDao.getAllUserPermission(statement, user1.getUserName(), nodeName).size()); + + assertEquals(1, authDao.getAllUserPermission(statement, user1.getUserName(), newNodeName).size()); + + // delete the user and role + authDao.deleteUser(statement, user1.getUserName()); + authDao.deleteRole(statement, role1.getRoleName()); + authDao.deleteRole(statement, role2.getRoleName()); + } +} diff --git a/src/test/java/cn/edu/thu/tsfiledb/auth/RolePermissionTest.java b/src/test/java/cn/edu/thu/tsfiledb/auth/RolePermissionTest.java new file mode 100644 index 00000000000..bfe583aa8a9 --- /dev/null +++ b/src/test/java/cn/edu/thu/tsfiledb/auth/RolePermissionTest.java @@ -0,0 +1,95 @@ +package cn.edu.thu.tsfiledb.auth; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.sql.Statement; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.dao.RoleDao; +import cn.edu.thu.tsfiledb.auth.dao.RolePermissionDao; +import cn.edu.thu.tsfiledb.auth.model.Permission; +import cn.edu.thu.tsfiledb.auth.model.Role; +import cn.edu.thu.tsfiledb.auth.model.RolePermission; + +public class RolePermissionTest { + + private DBdao dbDao = null; + private RoleDao roleDao = null; + private RolePermissionDao rolePermissionDao = null; + private Statement statement; + + private Role role = new Role("role"); + private String nodeName = "nodeName"; + private String newNodeName = "newNodeName"; + private int permissionId; + private RolePermission rolePermission = null; + + @Before + public void setUp() throws Exception { + dbDao = new DBdao(); + roleDao = new RoleDao(); + rolePermissionDao = new RolePermissionDao(); + permissionId = Permission.CREATE; + + dbDao.open(); + statement = dbDao.getStatement(); + + // if role not exist, create role + if (roleDao.getRole(statement, role.getRoleName()) == null) { + roleDao.createRole(statement, role); + } + rolePermission = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(), nodeName, + permissionId); + } + + @After + public void tearDown() throws Exception { + roleDao.deleteRole(statement, role.getRoleName()); + dbDao.close(); + } + + @Test + public void test() { + + // create the role permission + int state = 0; + state = rolePermissionDao.deleteRolePermission(statement, rolePermission); + state = rolePermissionDao.createRolePermission(statement, rolePermission); + RolePermission permission = rolePermissionDao.getRolePermission(statement, rolePermission); + assertEquals(1, state); + assertNotNull(permission); + assertEquals(rolePermission.getRoleId(), permission.getRoleId()); + assertEquals(rolePermission.getNodeName(), permission.getNodeName()); + assertEquals(rolePermission.getPermissionId(), permission.getPermissionId()); + // delete the role permission + state = rolePermissionDao.deleteRolePermission(statement, rolePermission); + assertEquals(1, state); + permission = rolePermissionDao.getRolePermission(statement, rolePermission); + assertNull(permission); + + } + + @Test + public void testGetRoles() { + RolePermission rolePermission1 = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(), + nodeName, Permission.CREATE); + RolePermission rolePermission2 = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(), + nodeName, Permission.DELETE); + rolePermissionDao.createRolePermission(statement, rolePermission1); + rolePermissionDao.createRolePermission(statement, rolePermission2); + RolePermission rolePermission3 = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(), + newNodeName, Permission.CREATE); + rolePermissionDao.createRolePermission(statement, rolePermission3); + assertEquals(3, rolePermissionDao.getRolePermissions(statement).size()); + assertEquals(1, rolePermissionDao.getRolePermissionByRoleAndNodeName(statement, + roleDao.getRole(statement, role.getRoleName()).getId(), newNodeName).size()); + + } + +} diff --git a/src/test/java/cn/edu/thu/tsfiledb/auth/RoleTest.java b/src/test/java/cn/edu/thu/tsfiledb/auth/RoleTest.java new file mode 100644 index 00000000000..93f4acd340d --- /dev/null +++ b/src/test/java/cn/edu/thu/tsfiledb/auth/RoleTest.java @@ -0,0 +1,84 @@ +package cn.edu.thu.tsfiledb.auth; + +import static org.junit.Assert.*; + +import java.sql.Statement; +import java.util.ArrayList; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.dao.RoleDao; +import cn.edu.thu.tsfiledb.auth.model.Role; + +public class RoleTest { + + private Statement statement = null; + private DBdao dbdao = null; + private RoleDao roleDao = null; + private Role role = null; + + private String roleName = "role"; + + @Before + public void setUp() throws Exception { + dbdao = new DBdao(); + dbdao.open(); + statement = dbdao.getStatement(); + roleDao = new RoleDao(); + } + + @After + public void tearDown() throws Exception { + dbdao.close(); + } + + @Test + public void test() { + role = roleDao.getRole(statement, roleName); + if (role != null) { + System.out.println("Delete the original role"); + roleDao.deleteRole(statement, roleName); + } + // create role + role = new Role(roleName); + roleDao.createRole(statement, role); + Role getRole = roleDao.getRole(statement, roleName); + assertEquals(roleName, getRole.getRoleName()); + // delete role + roleDao.deleteRole(statement, roleName); + role = roleDao.getRole(statement, roleName); + assertEquals(null, role); + } + + @Test + public void getRolesTest() { + Role role1 = new Role("role1"); + Role role2 = new Role("role2"); + ArrayList arrayList = new ArrayList<>(); + arrayList.add(role1); + arrayList.add(role2); + if (roleDao.getRole(statement, role1.getRoleName()) == null) { + roleDao.createRole(statement, role1); + } + if (roleDao.getRole(statement, role2.getRoleName()) == null) { + roleDao.createRole(statement, role2); + } + ArrayList list = (ArrayList) roleDao.getRoles(statement); + ArrayList getRoleNames = new ArrayList<>(); + for (Role role : list) { + getRoleNames.add(role.getRoleName()); + } + ArrayList remove = new ArrayList<>(); + remove.add(role1.getRoleName()); + remove.add(role2.getRoleName()); + getRoleNames.removeAll(remove); + assertEquals(0, getRoleNames.size()); + roleDao.deleteRole(statement, role1.getRoleName()); + roleDao.deleteRole(statement, role2.getRoleName()); + + } + +} diff --git a/src/test/java/cn/edu/thu/tsfiledb/auth/UserPemissionTest.java b/src/test/java/cn/edu/thu/tsfiledb/auth/UserPemissionTest.java new file mode 100644 index 00000000000..7a3d0a0c2ae --- /dev/null +++ b/src/test/java/cn/edu/thu/tsfiledb/auth/UserPemissionTest.java @@ -0,0 +1,90 @@ +package cn.edu.thu.tsfiledb.auth; + +import static org.junit.Assert.*; + +import java.sql.Statement; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.dao.UserDao; +import cn.edu.thu.tsfiledb.auth.dao.UserPermissionDao; +import cn.edu.thu.tsfiledb.auth.model.Permission; +import cn.edu.thu.tsfiledb.auth.model.User; +import cn.edu.thu.tsfiledb.auth.model.UserPermission; + +public class UserPemissionTest { + + private DBdao DBdao = null; + private UserDao userDao = null; + private UserPermissionDao UserPermissionDao = null; + private Statement statement = null; + + private String nodeName = "nodeName"; + private String newNodeName = "newNodeName"; + private int permission; + + private User user = new User("user1", "user1"); + + @Before + public void setUp() throws Exception { + permission = Permission.CREATE; + DBdao = new DBdao(); + DBdao.open(); + statement = DBdao.getStatement(); + userDao = new UserDao(); + UserPermissionDao = new UserPermissionDao(); + + // if not exitst, create the user + if (userDao.getUser(statement, user.getUserName()) == null) { + userDao.createUser(statement, user); + } + } + + @After + public void tearDown() throws Exception { + userDao.deleteUser(statement, user.getUserName()); + DBdao.close(); + } + + @Test + public void test() { + UserPermission userPermission = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(), + nodeName, permission); + // if userpermission exist in the table ,and delete it + UserPermissionDao.deleteUserPermission(statement, userPermission); + // create permission + UserPermissionDao.createUserPermission(statement, userPermission); + UserPermission permission = UserPermissionDao.getUserPermission(statement, userPermission); + assertEquals(userPermission.getUserId(), permission.getUserId()); + assertEquals(userPermission.getNodeName(), permission.getNodeName()); + assertEquals(userPermission.getPermissionId(), permission.getPermissionId()); + // delete permission + int state = 0; + state = UserPermissionDao.deleteUserPermission(statement, userPermission); + assertEquals(1, state); + permission = UserPermissionDao.getUserPermission(statement, userPermission); + assertEquals(null, permission); + } + + @Test + public void testGetUserPermissions() { + UserPermission userPermission1 = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(), + nodeName, Permission.CREATE); + UserPermission userPermission2 = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(), + nodeName, Permission.DELETE); + UserPermissionDao.createUserPermission(statement, userPermission1); + UserPermissionDao.createUserPermission(statement, userPermission2); + assertEquals(2, UserPermissionDao.getUserPermissions(statement).size()); + UserPermission userPermission3 = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(), + newNodeName, Permission.CREATE); + UserPermissionDao.createUserPermission(statement, userPermission3); + assertEquals(2, UserPermissionDao.getUserPermissionByUserAndNodeName(statement, + userDao.getUser(statement, user.getUserName()).getId(), nodeName).size()); + assertEquals(1, UserPermissionDao.getUserPermissionByUserAndNodeName(statement, + userDao.getUser(statement, user.getUserName()).getId(), newNodeName).size()); + } + +} diff --git a/src/test/java/cn/edu/thu/tsfiledb/auth/UserRoleRelTest.java b/src/test/java/cn/edu/thu/tsfiledb/auth/UserRoleRelTest.java new file mode 100644 index 00000000000..ae45cfababc --- /dev/null +++ b/src/test/java/cn/edu/thu/tsfiledb/auth/UserRoleRelTest.java @@ -0,0 +1,167 @@ +package cn.edu.thu.tsfiledb.auth; + +import static org.junit.Assert.*; + +import java.sql.Statement; +import java.util.ArrayList; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.dao.RoleDao; +import cn.edu.thu.tsfiledb.auth.dao.UserDao; +import cn.edu.thu.tsfiledb.auth.dao.UserRoleRelDao; +import cn.edu.thu.tsfiledb.auth.model.Role; +import cn.edu.thu.tsfiledb.auth.model.User; +import cn.edu.thu.tsfiledb.auth.model.UserRoleRel; + +public class UserRoleRelTest { + + private DBdao dbdao = null; + private UserRoleRelDao userRoleRelDao = null; + private UserDao userDao = null; + private RoleDao roleDao = null; + private Statement statement = null; + User user1 = new User("user1", "user2"); + User user2 = new User("user2", "user2"); + Role role1 = new Role("role1"); + Role role2 = new Role("role2"); + + @Before + public void setUp() throws Exception { + dbdao = new DBdao(); + dbdao.open(); + statement = dbdao.getStatement(); + userDao = new UserDao(); + roleDao = new RoleDao(); + userRoleRelDao = new UserRoleRelDao(); + + // create user and role + + if (userDao.getUser(statement, user1.getUserName()) == null) { + userDao.createUser(statement, user1); + } + if (userDao.getUser(statement, user2.getUserName()) == null) { + userDao.createUser(statement, user2); + } + + if (roleDao.getRole(statement, role1.getRoleName()) == null) { + roleDao.createRole(statement, role1); + } + if (roleDao.getRole(statement, role2.getRoleName()) == null) { + roleDao.createRole(statement, role2); + } + } + + @After + public void tearDown() throws Exception { + + userDao.deleteUser(statement, user1.getUserName()); + userDao.deleteUser(statement, user2.getUserName()); + roleDao.deleteRole(statement, role1.getRoleName()); + roleDao.deleteRole(statement, role2.getRoleName()); + dbdao.close(); + + } + + @Test + public void test() { + // create relation between user and role + String userName = "user1"; + String roleName = "role1"; + int userId = userDao.getUser(statement, userName).getId(); + int roleId = roleDao.getRole(statement, roleName).getId(); + UserRoleRel userRoleRel = new UserRoleRel(userId, roleId); + // if not exist, create the relation + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel) == null) { + userRoleRelDao.createUserRoleRel(statement, userRoleRel); + } else { + userRoleRelDao.deleteUserRoleRel(statement, userRoleRel); + userRoleRelDao.createUserRoleRel(statement, userRoleRel); + } + // get the relation + userRoleRel = userRoleRelDao.getUserRoleRel(statement, userRoleRel); + assertEquals(userId, userRoleRel.getUserId()); + assertEquals(roleId, userRoleRel.getRoleId()); + // delete the relation ana assert + userRoleRelDao.deleteUserRoleRel(statement, userRoleRel); + assertEquals(null, userRoleRelDao.getUserRoleRel(statement, userRoleRel)); + } + + @Test + public void getRolesByUserTest() { + String user1name = user1.getUserName(); + String role1name = role1.getRoleName(); + String role2name = role2.getRoleName(); + int user1Id = userDao.getUser(statement, user1name).getId(); + int role1Id = roleDao.getRole(statement, role1name).getId(); + int role2Id = roleDao.getRole(statement, role2name).getId(); + + UserRoleRel userRoleRel1 = new UserRoleRel(user1Id, role1Id); + UserRoleRel userRoleRel2 = new UserRoleRel(user1Id, role2Id); + + // if not exist, create the relations + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel1) == null) { + userRoleRelDao.createUserRoleRel(statement, userRoleRel1); + } + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel2) == null) { + userRoleRelDao.createUserRoleRel(statement, userRoleRel2); + } + // get the relation and assert them + ArrayList arrayList = (ArrayList) userRoleRelDao.getUserRoleRelByUser(statement, + user1Id); + ArrayList roleIds = new ArrayList<>(); + for (UserRoleRel userRoleRel : arrayList) { + roleIds.add(userRoleRel.getRoleId()); + } + ArrayList list = new ArrayList<>(); + list.add(role1Id); + list.add(role2Id); + + roleIds.removeAll(list); + assertEquals(0, roleIds.size()); + // delete the relations + userRoleRelDao.deleteUserRoleRel(statement, userRoleRel1); + userRoleRelDao.deleteUserRoleRel(statement, userRoleRel2); + + } + + @Test + public void getUserByRoleTest() { + String role1name = role1.getRoleName(); + String user1name = user1.getUserName(); + String user2name = user2.getUserName(); + int role1Id = roleDao.getRole(statement, role1name).getId(); + int user1Id = userDao.getUser(statement, user1name).getId(); + int user2Id = userDao.getUser(statement, user2name).getId(); + + UserRoleRel userRoleRel1 = new UserRoleRel(user1Id, role1Id); + UserRoleRel userRoleRel2 = new UserRoleRel(user2Id, role1Id); + + //if not exist, create the relations + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel1)==null) { + userRoleRelDao.createUserRoleRel(statement, userRoleRel1); + } + if (userRoleRelDao.getUserRoleRel(statement, userRoleRel2)==null) { + userRoleRelDao.createUserRoleRel(statement, userRoleRel2); + } + //get the relation and assert them + ArrayList arrayList = (ArrayList)userRoleRelDao.getUserRoleRelByRole(statement, role1Id); + ArrayList userIds = new ArrayList<>(); + for (UserRoleRel userRoleRel : arrayList) { + userIds.add(userRoleRel.getUserId()); + } + ArrayList list = new ArrayList<>(); + list.add(user1Id); + list.add(user2Id); + + userIds.removeAll(list); + assertEquals(0, userIds.size()); + //delete the relations + userRoleRelDao.deleteUserRoleRel(statement, userRoleRel1); + userRoleRelDao.deleteUserRoleRel(statement, userRoleRel2); + } + +} diff --git a/src/test/java/cn/edu/thu/tsfiledb/auth/UserTest.java b/src/test/java/cn/edu/thu/tsfiledb/auth/UserTest.java new file mode 100644 index 00000000000..4ad70c586cf --- /dev/null +++ b/src/test/java/cn/edu/thu/tsfiledb/auth/UserTest.java @@ -0,0 +1,116 @@ +package cn.edu.thu.tsfiledb.auth; + +import static org.junit.Assert.*; + +import java.sql.Statement; +import java.util.ArrayList; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import cn.edu.thu.tsfiledb.auth.dao.DBdao; +import cn.edu.thu.tsfiledb.auth.dao.UserDao; +import cn.edu.thu.tsfiledb.auth.model.User; + +public class UserTest { + + private Statement statement = null; + private UserDao userDao = null; + private DBdao dBdao = null; + + private String userName = "testuser"; + private String passWord = "password"; + private User user = new User(userName, passWord); + + /** + * @throws Exception + * prepare to connect the derby DB + */ + @Before + public void setUp() throws Exception { + dBdao = new DBdao(); + dBdao.open(); + statement = dBdao.getStatement(); + userDao = new UserDao(); + + } + + @After + public void tearDown() throws Exception { + dBdao.close(); + } + + /** + * Create user first and delete the user + */ + @Test + public void test() { + User getUser = userDao.getUser(statement, userName); + if (getUser != null) { + int deleteCount = userDao.deleteUser(statement, userName); + if (deleteCount > 0) { + System.out.println("Delete the original record"); + } + } + // create user + userDao.createUser(statement, user); + getUser = userDao.getUser(statement, userName); + assertEquals(userName, getUser.getUserName()); + assertEquals(passWord, getUser.getPassWord()); + // delete user + userDao.deleteUser(statement, userName); + getUser = userDao.getUser(statement, userName); + assertEquals(getUser, null); + } + + @Test + public void getUsersTest() { + User user1 = new User("user1", "user1"); + User user2 = new User("user2", "user2"); + ArrayList arrayList = new ArrayList<>(); + arrayList.add(user1); + arrayList.add(user2); + if (userDao.getUser(statement, user1.getUserName()) == null) { + userDao.createUser(statement, user1); + } + if (userDao.getUser(statement, user2.getUserName()) == null) { + userDao.createUser(statement, user2); + } + ArrayList list = (ArrayList) userDao.getUsers(statement); + // add the root user + assertEquals(3, list.size()); + // int count = 0; + // // Some problems + // for (User user : list) { + // User testUser = arrayList.get(count); + // count++; + // if (user.getUserName().equals("root")) { + // continue; + // } + // assertEquals(testUser.getUserName(), user.getUserName()); + // assertEquals(testUser.getPassWord(), user.getPassWord()); + // } + userDao.deleteUser(statement, user1.getUserName()); + userDao.deleteUser(statement, user2.getUserName()); + } + + @Test + public void updateUserTest(){ + User user = new User("user", "user"); + if ((userDao.getUser(statement, user.getUserName()))==null) { + userDao.createUser(statement, user); + } + user = userDao.getUser(statement, user.getUserName()); + assertEquals("user", user.getUserName()); + assertEquals("user", user.getPassWord()); + // update password + String updatePassword = "password"; + userDao.updateUserPassword(statement, + user.getUserName(), updatePassword); + user = userDao.getUser(statement, user.getUserName()); + assertEquals("user", user.getUserName()); + assertEquals(updatePassword, user.getPassWord()); + userDao.deleteUser(statement, user.getUserName()); + } + +}