diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java index 21f09ae..50ff9f9 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java @@ -1282,6 +1282,124 @@ public void testInsertToMultiKeyPartition() throws IOException { } @Test + public void testInsertOverwriteOnUnpartitionedTableWithCM() throws IOException { + String testName = "insertOverwriteOnUnpartitionedTableWithCM"; + LOG.info("Testing " + testName); + String dbName = testName + "_" + tid; + + run("CREATE DATABASE " + dbName); + run("CREATE TABLE " + dbName + ".unptned(a string) STORED AS TEXTFILE"); + + advanceDumpDir(); + run("REPL DUMP " + dbName); + String replDumpLocn = getResult(0, 0); + String replDumpId = getResult(0, 1, true); + LOG.info("Bootstrap-Dump: Dumped to {} with id {}", replDumpLocn, replDumpId); + run("REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'"); + + String[] unptn_data = new String[] { "thirteen" }; + + // 3 events to insert, last repl ID: replDumpId+3 + run("INSERT INTO TABLE " + dbName + ".unptned values('" + unptn_data[0] + "')"); + verifySetup("SELECT a from " + dbName + ".unptned ORDER BY a", unptn_data); + + String[] data_after_ovwrite = new String[] { "hundred" }; + + // Insert overwrite on unpartitioned table + // 3 events to insert, last repl ID: replDumpId+6 + run("INSERT OVERWRITE TABLE " + dbName + ".unptned values('" + data_after_ovwrite[0] + "')"); + verifySetup("SELECT a from " + dbName + ".unptned", data_after_ovwrite); + + advanceDumpDir(); + // Dump only one INSERT INTO operation on the tables (3 events). + run("REPL DUMP " + dbName + " FROM " + replDumpId + " LIMIT 3"); + String incrementalDumpLocn = getResult(0, 0); + String incrementalDumpId = getResult(0, 1, true); + LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", incrementalDumpLocn, incrementalDumpId, replDumpId); + replDumpId = incrementalDumpId; + + // After Load from this dump, all target tables/partitions will have initial set of data but source will have latest data. + run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'"); + verifyRun("SELECT a from " + dbName + ".unptned ORDER BY a", data_after_ovwrite); + verifyRun("SELECT a from " + dbName + "_dupe.unptned ORDER BY a", unptn_data); + + advanceDumpDir(); + // Dump the remaining INSERT OVERWRITE operations on the table. + run("REPL DUMP " + dbName + " FROM " + replDumpId); + incrementalDumpLocn = getResult(0, 0); + incrementalDumpId = getResult(0, 1, true); + LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", incrementalDumpLocn, incrementalDumpId, replDumpId); + replDumpId = incrementalDumpId; + + // After load, shall see the overwritten data. + run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'"); + verifyRun("SELECT a from " + dbName + "_dupe.unptned ORDER BY a", data_after_ovwrite); + } + + @Test + public void testInsertOverwriteOnPartitionedTableWithCM() throws IOException { + String testName = "insertOverwriteOnPartitionedTableWithCM"; + LOG.info("Testing " + testName); + String dbName = testName + "_" + tid; + + run("CREATE DATABASE " + dbName); + run("CREATE TABLE " + dbName + ".ptned(a string) partitioned by (b int) STORED AS TEXTFILE"); + + advanceDumpDir(); + run("REPL DUMP " + dbName); + String replDumpLocn = getResult(0, 0); + String replDumpId = getResult(0, 1, true); + LOG.info("Bootstrap-Dump: Dumped to {} with id {}", replDumpLocn, replDumpId); + run("REPL LOAD " + dbName + "_dupe FROM '" + replDumpLocn + "'"); + + String[] unptn_data = new String[] { "thirteen" }; + String[] ptn_data_1 = new String[] { "fourteen" }; + String[] ptn_data_2 = new String[] { "fifteen" }; + + // 2 events to insert, last repl ID: replDumpId+2 + run("INSERT INTO TABLE " + dbName + ".ptned partition(b=1) values('" + ptn_data_1[0] + "')"); + // 2 events to insert, last repl ID: replDumpId+4 + run("INSERT INTO TABLE " + dbName + ".ptned partition(b=2) values('" + ptn_data_2[0] + "')"); + verifySetup("SELECT a from " + dbName + ".ptned where (b=1) ORDER BY a", ptn_data_1); + verifySetup("SELECT a from " + dbName + ".ptned where (b=2) ORDER BY a", ptn_data_2); + + String[] data_after_ovwrite = new String[] { "hundred" }; + + // Insert overwrite on one partition + // 3 events to insert, last repl ID: replDumpId+7 + run("INSERT OVERWRITE TABLE " + dbName + ".ptned partition(b=2) values('" + data_after_ovwrite[0] + "')"); + verifySetup("SELECT a from " + dbName + ".ptned where (b=2)", data_after_ovwrite); + + advanceDumpDir(); + // Dump only 2 INSERT INTO operations on the table (4 events). + run("REPL DUMP " + dbName + " FROM " + replDumpId + " LIMIT 4"); + String incrementalDumpLocn = getResult(0, 0); + String incrementalDumpId = getResult(0, 1, true); + LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", incrementalDumpLocn, incrementalDumpId, replDumpId); + replDumpId = incrementalDumpId; + + // After Load from this dump, all target tables/partitions will have initial set of data but source will have latest data. + run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'"); + verifyRun("SELECT a from " + dbName + ".ptned where (b=1) ORDER BY a", ptn_data_1); + verifyRun("SELECT a from " + dbName + ".ptned where (b=2) ORDER BY a", data_after_ovwrite); + verifyRun("SELECT a from " + dbName + "_dupe.ptned where (b=1) ORDER BY a", ptn_data_1); + verifyRun("SELECT a from " + dbName + "_dupe.ptned where (b=2) ORDER BY a", ptn_data_2); + + advanceDumpDir(); + // Dump the remaining INSERT OVERWRITE operation on the table. + run("REPL DUMP " + dbName + " FROM " + replDumpId); + incrementalDumpLocn = getResult(0, 0); + incrementalDumpId = getResult(0, 1, true); + LOG.info("Incremental-Dump: Dumped to {} with id {} from {}", incrementalDumpLocn, incrementalDumpId, replDumpId); + replDumpId = incrementalDumpId; + + // After load, shall see the overwritten data. + run("REPL LOAD " + dbName + "_dupe FROM '" + incrementalDumpLocn + "'"); + verifyRun("SELECT a from " + dbName + "_dupe.ptned where (b=1) ORDER BY a", ptn_data_1); + verifyRun("SELECT a from " + dbName + "_dupe.ptned where (b=2) ORDER BY a", data_after_ovwrite); + } + + @Test public void testViewsReplication() throws IOException { String testName = "viewsReplication"; String dbName = createDB(testName); diff --git a/metastore/if/hive_metastore.thrift b/metastore/if/hive_metastore.thrift index 0573f0c..63960e1 100755 --- a/metastore/if/hive_metastore.thrift +++ b/metastore/if/hive_metastore.thrift @@ -1127,6 +1127,7 @@ service ThriftHiveMetastore extends fb303.FacebookService throws(1:NoSuchObjectException o1, 2:MetaException o3) void truncate_table(1:string dbName, 2:string tableName, 3:list partNames) throws(1:MetaException o1) + void cm_recycle(1:string dataPath, 2:bool isCopy, 3:bool isPurge) throws(1:MetaException o1) list get_tables(1: string db_name, 2: string pattern) throws (1: MetaException o1) list get_tables_by_type(1: string db_name, 2: string pattern, 3: string tableType) throws (1: MetaException o1) list get_table_meta(1: string db_patterns, 2: string tbl_patterns, 3: list tbl_types) @@ -1136,11 +1137,8 @@ service ThriftHiveMetastore extends fb303.FacebookService Table get_table(1:string dbname, 2:string tbl_name) throws (1:MetaException o1, 2:NoSuchObjectException o2) list get_table_objects_by_name(1:string dbname, 2:list tbl_names) - GetTableResult get_table_req(1:GetTableRequest req) - throws (1:MetaException o1, 2:NoSuchObjectException o2) + GetTableResult get_table_req(1:GetTableRequest req) throws (1:MetaException o1, 2:NoSuchObjectException o2) GetTablesResult get_table_objects_by_name_req(1:GetTablesRequest req) - - throws (1:MetaException o1, 2:InvalidOperationException o2, 3:UnknownDBException o3) // Get a list of table names that match a filter. diff --git a/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp b/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp index 0d4fe5a..84c8746 100644 --- a/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp +++ b/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp @@ -6680,6 +6680,225 @@ uint32_t ThriftHiveMetastore_truncate_table_presult::read(::apache::thrift::prot } +ThriftHiveMetastore_cm_recycle_args::~ThriftHiveMetastore_cm_recycle_args() throw() { +} + + +uint32_t ThriftHiveMetastore_cm_recycle_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->dataPath); + this->__isset.dataPath = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->isCopy); + this->__isset.isCopy = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->isPurge); + this->__isset.isPurge = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_cm_recycle_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("ThriftHiveMetastore_cm_recycle_args"); + + xfer += oprot->writeFieldBegin("dataPath", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->dataPath); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("isCopy", ::apache::thrift::protocol::T_BOOL, 2); + xfer += oprot->writeBool(this->isCopy); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("isPurge", ::apache::thrift::protocol::T_BOOL, 3); + xfer += oprot->writeBool(this->isPurge); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +ThriftHiveMetastore_cm_recycle_pargs::~ThriftHiveMetastore_cm_recycle_pargs() throw() { +} + + +uint32_t ThriftHiveMetastore_cm_recycle_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("ThriftHiveMetastore_cm_recycle_pargs"); + + xfer += oprot->writeFieldBegin("dataPath", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString((*(this->dataPath))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("isCopy", ::apache::thrift::protocol::T_BOOL, 2); + xfer += oprot->writeBool((*(this->isCopy))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("isPurge", ::apache::thrift::protocol::T_BOOL, 3); + xfer += oprot->writeBool((*(this->isPurge))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +ThriftHiveMetastore_cm_recycle_result::~ThriftHiveMetastore_cm_recycle_result() throw() { +} + + +uint32_t ThriftHiveMetastore_cm_recycle_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_cm_recycle_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("ThriftHiveMetastore_cm_recycle_result"); + + if (this->__isset.o1) { + xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->o1.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +ThriftHiveMetastore_cm_recycle_presult::~ThriftHiveMetastore_cm_recycle_presult() throw() { +} + + +uint32_t ThriftHiveMetastore_cm_recycle_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + ThriftHiveMetastore_get_tables_args::~ThriftHiveMetastore_get_tables_args() throw() { } @@ -41024,6 +41243,64 @@ void ThriftHiveMetastoreClient::recv_truncate_table() return; } +void ThriftHiveMetastoreClient::cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) +{ + send_cm_recycle(dataPath, isCopy, isPurge); + recv_cm_recycle(); +} + +void ThriftHiveMetastoreClient::send_cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("cm_recycle", ::apache::thrift::protocol::T_CALL, cseqid); + + ThriftHiveMetastore_cm_recycle_pargs args; + args.dataPath = &dataPath; + args.isCopy = &isCopy; + args.isPurge = &isPurge; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void ThriftHiveMetastoreClient::recv_cm_recycle() +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("cm_recycle") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + ThriftHiveMetastore_cm_recycle_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.o1) { + throw result.o1; + } + return; +} + void ThriftHiveMetastoreClient::get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern) { send_get_tables(db_name, pattern); @@ -51018,6 +51295,62 @@ void ThriftHiveMetastoreProcessor::process_truncate_table(int32_t seqid, ::apach } } +void ThriftHiveMetastoreProcessor::process_cm_recycle(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("ThriftHiveMetastore.cm_recycle", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.cm_recycle"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.cm_recycle"); + } + + ThriftHiveMetastore_cm_recycle_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.cm_recycle", bytes); + } + + ThriftHiveMetastore_cm_recycle_result result; + try { + iface_->cm_recycle(args.dataPath, args.isCopy, args.isPurge); + } catch (MetaException &o1) { + result.o1 = o1; + result.__isset.o1 = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.cm_recycle"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("cm_recycle", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.cm_recycle"); + } + + oprot->writeMessageBegin("cm_recycle", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.cm_recycle", bytes); + } +} + void ThriftHiveMetastoreProcessor::process_get_tables(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) { void* ctx = NULL; @@ -61245,6 +61578,90 @@ void ThriftHiveMetastoreConcurrentClient::recv_truncate_table(const int32_t seqi } // end while(true) } +void ThriftHiveMetastoreConcurrentClient::cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) +{ + int32_t seqid = send_cm_recycle(dataPath, isCopy, isPurge); + recv_cm_recycle(seqid); +} + +int32_t ThriftHiveMetastoreConcurrentClient::send_cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("cm_recycle", ::apache::thrift::protocol::T_CALL, cseqid); + + ThriftHiveMetastore_cm_recycle_pargs args; + args.dataPath = &dataPath; + args.isCopy = &isCopy; + args.isPurge = &isPurge; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void ThriftHiveMetastoreConcurrentClient::recv_cm_recycle(const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("cm_recycle") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + ThriftHiveMetastore_cm_recycle_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.o1) { + sentry.commit(); + throw result.o1; + } + sentry.commit(); + return; + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + void ThriftHiveMetastoreConcurrentClient::get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern) { int32_t seqid = send_get_tables(db_name, pattern); diff --git a/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h b/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h index 47d9f1d..6f3eb9b 100644 --- a/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h +++ b/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h @@ -49,6 +49,7 @@ class ThriftHiveMetastoreIf : virtual public ::facebook::fb303::FacebookService virtual void drop_table(const std::string& dbname, const std::string& name, const bool deleteData) = 0; virtual void drop_table_with_environment_context(const std::string& dbname, const std::string& name, const bool deleteData, const EnvironmentContext& environment_context) = 0; virtual void truncate_table(const std::string& dbName, const std::string& tableName, const std::vector & partNames) = 0; + virtual void cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) = 0; virtual void get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern) = 0; virtual void get_tables_by_type(std::vector & _return, const std::string& db_name, const std::string& pattern, const std::string& tableType) = 0; virtual void get_table_meta(std::vector & _return, const std::string& db_patterns, const std::string& tbl_patterns, const std::vector & tbl_types) = 0; @@ -293,6 +294,9 @@ class ThriftHiveMetastoreNull : virtual public ThriftHiveMetastoreIf , virtual p void truncate_table(const std::string& /* dbName */, const std::string& /* tableName */, const std::vector & /* partNames */) { return; } + void cm_recycle(const std::string& /* dataPath */, const bool /* isCopy */, const bool /* isPurge */) { + return; + } void get_tables(std::vector & /* _return */, const std::string& /* db_name */, const std::string& /* pattern */) { return; } @@ -4035,6 +4039,124 @@ class ThriftHiveMetastore_truncate_table_presult { }; +typedef struct _ThriftHiveMetastore_cm_recycle_args__isset { + _ThriftHiveMetastore_cm_recycle_args__isset() : dataPath(false), isCopy(false), isPurge(false) {} + bool dataPath :1; + bool isCopy :1; + bool isPurge :1; +} _ThriftHiveMetastore_cm_recycle_args__isset; + +class ThriftHiveMetastore_cm_recycle_args { + public: + + ThriftHiveMetastore_cm_recycle_args(const ThriftHiveMetastore_cm_recycle_args&); + ThriftHiveMetastore_cm_recycle_args& operator=(const ThriftHiveMetastore_cm_recycle_args&); + ThriftHiveMetastore_cm_recycle_args() : dataPath(), isCopy(0), isPurge(0) { + } + + virtual ~ThriftHiveMetastore_cm_recycle_args() throw(); + std::string dataPath; + bool isCopy; + bool isPurge; + + _ThriftHiveMetastore_cm_recycle_args__isset __isset; + + void __set_dataPath(const std::string& val); + + void __set_isCopy(const bool val); + + void __set_isPurge(const bool val); + + bool operator == (const ThriftHiveMetastore_cm_recycle_args & rhs) const + { + if (!(dataPath == rhs.dataPath)) + return false; + if (!(isCopy == rhs.isCopy)) + return false; + if (!(isPurge == rhs.isPurge)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_cm_recycle_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_cm_recycle_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class ThriftHiveMetastore_cm_recycle_pargs { + public: + + + virtual ~ThriftHiveMetastore_cm_recycle_pargs() throw(); + const std::string* dataPath; + const bool* isCopy; + const bool* isPurge; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_cm_recycle_result__isset { + _ThriftHiveMetastore_cm_recycle_result__isset() : o1(false) {} + bool o1 :1; +} _ThriftHiveMetastore_cm_recycle_result__isset; + +class ThriftHiveMetastore_cm_recycle_result { + public: + + ThriftHiveMetastore_cm_recycle_result(const ThriftHiveMetastore_cm_recycle_result&); + ThriftHiveMetastore_cm_recycle_result& operator=(const ThriftHiveMetastore_cm_recycle_result&); + ThriftHiveMetastore_cm_recycle_result() { + } + + virtual ~ThriftHiveMetastore_cm_recycle_result() throw(); + MetaException o1; + + _ThriftHiveMetastore_cm_recycle_result__isset __isset; + + void __set_o1(const MetaException& val); + + bool operator == (const ThriftHiveMetastore_cm_recycle_result & rhs) const + { + if (!(o1 == rhs.o1)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_cm_recycle_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_cm_recycle_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_cm_recycle_presult__isset { + _ThriftHiveMetastore_cm_recycle_presult__isset() : o1(false) {} + bool o1 :1; +} _ThriftHiveMetastore_cm_recycle_presult__isset; + +class ThriftHiveMetastore_cm_recycle_presult { + public: + + + virtual ~ThriftHiveMetastore_cm_recycle_presult() throw(); + MetaException o1; + + _ThriftHiveMetastore_cm_recycle_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + typedef struct _ThriftHiveMetastore_get_tables_args__isset { _ThriftHiveMetastore_get_tables_args__isset() : db_name(false), pattern(false) {} bool db_name :1; @@ -20413,6 +20535,9 @@ class ThriftHiveMetastoreClient : virtual public ThriftHiveMetastoreIf, public void truncate_table(const std::string& dbName, const std::string& tableName, const std::vector & partNames); void send_truncate_table(const std::string& dbName, const std::string& tableName, const std::vector & partNames); void recv_truncate_table(); + void cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge); + void send_cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge); + void recv_cm_recycle(); void get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern); void send_get_tables(const std::string& db_name, const std::string& pattern); void recv_get_tables(std::vector & _return); @@ -20846,6 +20971,7 @@ class ThriftHiveMetastoreProcessor : public ::facebook::fb303::FacebookServiceP void process_drop_table(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_drop_table_with_environment_context(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_truncate_table(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_cm_recycle(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_get_tables(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_get_tables_by_type(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_get_table_meta(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); @@ -21009,6 +21135,7 @@ class ThriftHiveMetastoreProcessor : public ::facebook::fb303::FacebookServiceP processMap_["drop_table"] = &ThriftHiveMetastoreProcessor::process_drop_table; processMap_["drop_table_with_environment_context"] = &ThriftHiveMetastoreProcessor::process_drop_table_with_environment_context; processMap_["truncate_table"] = &ThriftHiveMetastoreProcessor::process_truncate_table; + processMap_["cm_recycle"] = &ThriftHiveMetastoreProcessor::process_cm_recycle; processMap_["get_tables"] = &ThriftHiveMetastoreProcessor::process_get_tables; processMap_["get_tables_by_type"] = &ThriftHiveMetastoreProcessor::process_get_tables_by_type; processMap_["get_table_meta"] = &ThriftHiveMetastoreProcessor::process_get_table_meta; @@ -21427,6 +21554,15 @@ class ThriftHiveMetastoreMultiface : virtual public ThriftHiveMetastoreIf, publi ifaces_[i]->truncate_table(dbName, tableName, partNames); } + void cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->cm_recycle(dataPath, isCopy, isPurge); + } + ifaces_[i]->cm_recycle(dataPath, isCopy, isPurge); + } + void get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern) { size_t sz = ifaces_.size(); size_t i = 0; @@ -22795,6 +22931,9 @@ class ThriftHiveMetastoreConcurrentClient : virtual public ThriftHiveMetastoreIf void truncate_table(const std::string& dbName, const std::string& tableName, const std::vector & partNames); int32_t send_truncate_table(const std::string& dbName, const std::string& tableName, const std::vector & partNames); void recv_truncate_table(const int32_t seqid); + void cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge); + int32_t send_cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge); + void recv_cm_recycle(const int32_t seqid); void get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern); int32_t send_get_tables(const std::string& db_name, const std::string& pattern); void recv_get_tables(std::vector & _return, const int32_t seqid); diff --git a/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp b/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp index 28f9af9..461212e 100644 --- a/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp +++ b/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp @@ -157,6 +157,11 @@ class ThriftHiveMetastoreHandler : virtual public ThriftHiveMetastoreIf { printf("truncate_table\n"); } + void cm_recycle(const std::string& dataPath, const bool isCopy, const bool isPurge) { + // Your implementation goes here + printf("cm_recycle\n"); + } + void get_tables(std::vector & _return, const std::string& db_name, const std::string& pattern) { // Your implementation goes here printf("get_tables\n"); diff --git a/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java b/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java index 89c59e1..7f973d2 100644 --- a/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java +++ b/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java @@ -96,6 +96,8 @@ public void truncate_table(String dbName, String tableName, List partNames) throws MetaException, org.apache.thrift.TException; + public void cm_recycle(String dataPath, boolean isCopy, boolean isPurge) throws MetaException, org.apache.thrift.TException; + public List get_tables(String db_name, String pattern) throws MetaException, org.apache.thrift.TException; public List get_tables_by_type(String db_name, String pattern, String tableType) throws MetaException, org.apache.thrift.TException; @@ -418,6 +420,8 @@ public void truncate_table(String dbName, String tableName, List partNames, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void cm_recycle(String dataPath, boolean isCopy, boolean isPurge, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void get_tables(String db_name, String pattern, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void get_tables_by_type(String db_name, String pattern, String tableType, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -1484,6 +1488,31 @@ public void recv_truncate_table() throws MetaException, org.apache.thrift.TExcep return; } + public void cm_recycle(String dataPath, boolean isCopy, boolean isPurge) throws MetaException, org.apache.thrift.TException + { + send_cm_recycle(dataPath, isCopy, isPurge); + recv_cm_recycle(); + } + + public void send_cm_recycle(String dataPath, boolean isCopy, boolean isPurge) throws org.apache.thrift.TException + { + cm_recycle_args args = new cm_recycle_args(); + args.setDataPath(dataPath); + args.setIsCopy(isCopy); + args.setIsPurge(isPurge); + sendBase("cm_recycle", args); + } + + public void recv_cm_recycle() throws MetaException, org.apache.thrift.TException + { + cm_recycle_result result = new cm_recycle_result(); + receiveBase(result, "cm_recycle"); + if (result.o1 != null) { + throw result.o1; + } + return; + } + public List get_tables(String db_name, String pattern) throws MetaException, org.apache.thrift.TException { send_get_tables(db_name, pattern); @@ -6213,6 +6242,44 @@ public void getResult() throws MetaException, org.apache.thrift.TException { } } + public void cm_recycle(String dataPath, boolean isCopy, boolean isPurge, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + cm_recycle_call method_call = new cm_recycle_call(dataPath, isCopy, isPurge, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class cm_recycle_call extends org.apache.thrift.async.TAsyncMethodCall { + private String dataPath; + private boolean isCopy; + private boolean isPurge; + public cm_recycle_call(String dataPath, boolean isCopy, boolean isPurge, 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.dataPath = dataPath; + this.isCopy = isCopy; + this.isPurge = isPurge; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("cm_recycle", org.apache.thrift.protocol.TMessageType.CALL, 0)); + cm_recycle_args args = new cm_recycle_args(); + args.setDataPath(dataPath); + args.setIsCopy(isCopy); + args.setIsPurge(isPurge); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws MetaException, 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); + (new Client(prot)).recv_cm_recycle(); + } + } + public void get_tables(String db_name, String pattern, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); get_tables_call method_call = new get_tables_call(db_name, pattern, resultHandler, this, ___protocolFactory, ___transport); @@ -10912,6 +10979,7 @@ protected Processor(I iface, Map extends org.apache.thrift.ProcessFunction { + public cm_recycle() { + super("cm_recycle"); + } + + public cm_recycle_args getEmptyArgsInstance() { + return new cm_recycle_args(); + } + + protected boolean isOneway() { + return false; + } + + public cm_recycle_result getResult(I iface, cm_recycle_args args) throws org.apache.thrift.TException { + cm_recycle_result result = new cm_recycle_result(); + try { + iface.cm_recycle(args.dataPath, args.isCopy, args.isPurge); + } catch (MetaException o1) { + result.o1 = o1; + } + return result; + } + } + public static class get_tables extends org.apache.thrift.ProcessFunction { public get_tables() { super("get_tables"); @@ -15135,6 +15227,7 @@ protected AsyncProcessor(I iface, Map extends org.apache.thrift.AsyncProcessFunction { + public cm_recycle() { + super("cm_recycle"); + } + + public cm_recycle_args getEmptyArgsInstance() { + return new cm_recycle_args(); + } + + public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback() { + public void onComplete(Void o) { + cm_recycle_result result = new cm_recycle_result(); + 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; + cm_recycle_result result = new cm_recycle_result(); + if (e instanceof MetaException) { + result.o1 = (MetaException) e; + result.setO1IsSet(true); + msg = result; + } + else + { + 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, cm_recycle_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { + iface.cm_recycle(args.dataPath, args.isCopy, args.isPurge,resultHandler); + } + } + public static class get_tables extends org.apache.thrift.AsyncProcessFunction> { public get_tables() { super("get_tables"); @@ -51172,165 +51321,1125 @@ public String getFieldName() { 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.DB_NAME, new org.apache.thrift.meta_data.FieldMetaData("dbName", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.DB_NAME, new org.apache.thrift.meta_data.FieldMetaData("dbName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PART_NAMES, new org.apache.thrift.meta_data.FieldMetaData("partNames", org.apache.thrift.TFieldRequirementType.DEFAULT, + 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(truncate_table_args.class, metaDataMap); + } + + public truncate_table_args() { + } + + public truncate_table_args( + String dbName, + String tableName, + List partNames) + { + this(); + this.dbName = dbName; + this.tableName = tableName; + this.partNames = partNames; + } + + /** + * Performs a deep copy on other. + */ + public truncate_table_args(truncate_table_args other) { + if (other.isSetDbName()) { + this.dbName = other.dbName; + } + if (other.isSetTableName()) { + this.tableName = other.tableName; + } + if (other.isSetPartNames()) { + List __this__partNames = new ArrayList(other.partNames); + this.partNames = __this__partNames; + } + } + + public truncate_table_args deepCopy() { + return new truncate_table_args(this); + } + + @Override + public void clear() { + this.dbName = null; + this.tableName = null; + this.partNames = null; + } + + public String getDbName() { + return this.dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public void unsetDbName() { + this.dbName = null; + } + + /** Returns true if field dbName is set (has been assigned a value) and false otherwise */ + public boolean isSetDbName() { + return this.dbName != null; + } + + public void setDbNameIsSet(boolean value) { + if (!value) { + this.dbName = null; + } + } + + public String getTableName() { + return this.tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public void unsetTableName() { + this.tableName = null; + } + + /** Returns true if field tableName is set (has been assigned a value) and false otherwise */ + public boolean isSetTableName() { + return this.tableName != null; + } + + public void setTableNameIsSet(boolean value) { + if (!value) { + this.tableName = null; + } + } + + public int getPartNamesSize() { + return (this.partNames == null) ? 0 : this.partNames.size(); + } + + public java.util.Iterator getPartNamesIterator() { + return (this.partNames == null) ? null : this.partNames.iterator(); + } + + public void addToPartNames(String elem) { + if (this.partNames == null) { + this.partNames = new ArrayList(); + } + this.partNames.add(elem); + } + + public List getPartNames() { + return this.partNames; + } + + public void setPartNames(List partNames) { + this.partNames = partNames; + } + + public void unsetPartNames() { + this.partNames = null; + } + + /** Returns true if field partNames is set (has been assigned a value) and false otherwise */ + public boolean isSetPartNames() { + return this.partNames != null; + } + + public void setPartNamesIsSet(boolean value) { + if (!value) { + this.partNames = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case DB_NAME: + if (value == null) { + unsetDbName(); + } else { + setDbName((String)value); + } + break; + + case TABLE_NAME: + if (value == null) { + unsetTableName(); + } else { + setTableName((String)value); + } + break; + + case PART_NAMES: + if (value == null) { + unsetPartNames(); + } else { + setPartNames((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case DB_NAME: + return getDbName(); + + case TABLE_NAME: + return getTableName(); + + case PART_NAMES: + return getPartNames(); + + } + 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 DB_NAME: + return isSetDbName(); + case TABLE_NAME: + return isSetTableName(); + case PART_NAMES: + return isSetPartNames(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof truncate_table_args) + return this.equals((truncate_table_args)that); + return false; + } + + public boolean equals(truncate_table_args that) { + if (that == null) + return false; + + boolean this_present_dbName = true && this.isSetDbName(); + boolean that_present_dbName = true && that.isSetDbName(); + if (this_present_dbName || that_present_dbName) { + if (!(this_present_dbName && that_present_dbName)) + return false; + if (!this.dbName.equals(that.dbName)) + return false; + } + + boolean this_present_tableName = true && this.isSetTableName(); + boolean that_present_tableName = true && that.isSetTableName(); + if (this_present_tableName || that_present_tableName) { + if (!(this_present_tableName && that_present_tableName)) + return false; + if (!this.tableName.equals(that.tableName)) + return false; + } + + boolean this_present_partNames = true && this.isSetPartNames(); + boolean that_present_partNames = true && that.isSetPartNames(); + if (this_present_partNames || that_present_partNames) { + if (!(this_present_partNames && that_present_partNames)) + return false; + if (!this.partNames.equals(that.partNames)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_dbName = true && (isSetDbName()); + list.add(present_dbName); + if (present_dbName) + list.add(dbName); + + boolean present_tableName = true && (isSetTableName()); + list.add(present_tableName); + if (present_tableName) + list.add(tableName); + + boolean present_partNames = true && (isSetPartNames()); + list.add(present_partNames); + if (present_partNames) + list.add(partNames); + + return list.hashCode(); + } + + @Override + public int compareTo(truncate_table_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetDbName()).compareTo(other.isSetDbName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDbName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dbName, other.dbName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTableName()).compareTo(other.isSetTableName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTableName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, other.tableName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPartNames()).compareTo(other.isSetPartNames()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPartNames()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partNames, other.partNames); + 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("truncate_table_args("); + boolean first = true; + + sb.append("dbName:"); + if (this.dbName == null) { + sb.append("null"); + } else { + sb.append(this.dbName); + } + first = false; + if (!first) sb.append(", "); + sb.append("tableName:"); + if (this.tableName == null) { + sb.append("null"); + } else { + sb.append(this.tableName); + } + first = false; + if (!first) sb.append(", "); + sb.append("partNames:"); + if (this.partNames == null) { + sb.append("null"); + } else { + sb.append(this.partNames); + } + 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 truncate_table_argsStandardSchemeFactory implements SchemeFactory { + public truncate_table_argsStandardScheme getScheme() { + return new truncate_table_argsStandardScheme(); + } + } + + private static class truncate_table_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_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: // DB_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.dbName = iprot.readString(); + struct.setDbNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // TABLE_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // PART_NAMES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list796 = iprot.readListBegin(); + struct.partNames = new ArrayList(_list796.size); + String _elem797; + for (int _i798 = 0; _i798 < _list796.size; ++_i798) + { + _elem797 = iprot.readString(); + struct.partNames.add(_elem797); + } + iprot.readListEnd(); + } + struct.setPartNamesIsSet(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(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, truncate_table_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.dbName != null) { + oprot.writeFieldBegin(DB_NAME_FIELD_DESC); + oprot.writeString(struct.dbName); + oprot.writeFieldEnd(); + } + if (struct.tableName != null) { + oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC); + oprot.writeString(struct.tableName); + oprot.writeFieldEnd(); + } + if (struct.partNames != null) { + oprot.writeFieldBegin(PART_NAMES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.partNames.size())); + for (String _iter799 : struct.partNames) + { + oprot.writeString(_iter799); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class truncate_table_argsTupleSchemeFactory implements SchemeFactory { + public truncate_table_argsTupleScheme getScheme() { + return new truncate_table_argsTupleScheme(); + } + } + + private static class truncate_table_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, truncate_table_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetDbName()) { + optionals.set(0); + } + if (struct.isSetTableName()) { + optionals.set(1); + } + if (struct.isSetPartNames()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetDbName()) { + oprot.writeString(struct.dbName); + } + if (struct.isSetTableName()) { + oprot.writeString(struct.tableName); + } + if (struct.isSetPartNames()) { + { + oprot.writeI32(struct.partNames.size()); + for (String _iter800 : struct.partNames) + { + oprot.writeString(_iter800); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, truncate_table_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.dbName = iprot.readString(); + struct.setDbNameIsSet(true); + } + if (incoming.get(1)) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list801 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.partNames = new ArrayList(_list801.size); + String _elem802; + for (int _i803 = 0; _i803 < _list801.size; ++_i803) + { + _elem802 = iprot.readString(); + struct.partNames.add(_elem802); + } + } + struct.setPartNamesIsSet(true); + } + } + } + + } + + public static class truncate_table_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("truncate_table_result"); + + private static final org.apache.thrift.protocol.TField O1_FIELD_DESC = new org.apache.thrift.protocol.TField("o1", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new truncate_table_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new truncate_table_resultTupleSchemeFactory()); + } + + private MetaException o1; // 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 { + O1((short)1, "o1"); + + 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: // O1 + return O1; + 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.O1, new org.apache.thrift.meta_data.FieldMetaData("o1", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(truncate_table_result.class, metaDataMap); + } + + public truncate_table_result() { + } + + public truncate_table_result( + MetaException o1) + { + this(); + this.o1 = o1; + } + + /** + * Performs a deep copy on other. + */ + public truncate_table_result(truncate_table_result other) { + if (other.isSetO1()) { + this.o1 = new MetaException(other.o1); + } + } + + public truncate_table_result deepCopy() { + return new truncate_table_result(this); + } + + @Override + public void clear() { + this.o1 = null; + } + + public MetaException getO1() { + return this.o1; + } + + public void setO1(MetaException o1) { + this.o1 = o1; + } + + public void unsetO1() { + this.o1 = null; + } + + /** Returns true if field o1 is set (has been assigned a value) and false otherwise */ + public boolean isSetO1() { + return this.o1 != null; + } + + public void setO1IsSet(boolean value) { + if (!value) { + this.o1 = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case O1: + if (value == null) { + unsetO1(); + } else { + setO1((MetaException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case O1: + return getO1(); + + } + 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 O1: + return isSetO1(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof truncate_table_result) + return this.equals((truncate_table_result)that); + return false; + } + + public boolean equals(truncate_table_result that) { + if (that == null) + return false; + + boolean this_present_o1 = true && this.isSetO1(); + boolean that_present_o1 = true && that.isSetO1(); + if (this_present_o1 || that_present_o1) { + if (!(this_present_o1 && that_present_o1)) + return false; + if (!this.o1.equals(that.o1)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_o1 = true && (isSetO1()); + list.add(present_o1); + if (present_o1) + list.add(o1); + + return list.hashCode(); + } + + @Override + public int compareTo(truncate_table_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetO1()).compareTo(other.isSetO1()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetO1()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.o1, other.o1); + 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("truncate_table_result("); + boolean first = true; + + sb.append("o1:"); + if (this.o1 == null) { + sb.append("null"); + } else { + sb.append(this.o1); + } + 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 truncate_table_resultStandardSchemeFactory implements SchemeFactory { + public truncate_table_resultStandardScheme getScheme() { + return new truncate_table_resultStandardScheme(); + } + } + + private static class truncate_table_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_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 1: // O1 + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.o1 = new MetaException(); + struct.o1.read(iprot); + struct.setO1IsSet(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(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, truncate_table_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.o1 != null) { + oprot.writeFieldBegin(O1_FIELD_DESC); + struct.o1.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class truncate_table_resultTupleSchemeFactory implements SchemeFactory { + public truncate_table_resultTupleScheme getScheme() { + return new truncate_table_resultTupleScheme(); + } + } + + private static class truncate_table_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, truncate_table_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetO1()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetO1()) { + struct.o1.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, truncate_table_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.o1 = new MetaException(); + struct.o1.read(iprot); + struct.setO1IsSet(true); + } + } + } + + } + + public static class cm_recycle_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("cm_recycle_args"); + + private static final org.apache.thrift.protocol.TField DATA_PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("dataPath", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField IS_COPY_FIELD_DESC = new org.apache.thrift.protocol.TField("isCopy", org.apache.thrift.protocol.TType.BOOL, (short)2); + private static final org.apache.thrift.protocol.TField IS_PURGE_FIELD_DESC = new org.apache.thrift.protocol.TField("isPurge", org.apache.thrift.protocol.TType.BOOL, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new cm_recycle_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new cm_recycle_argsTupleSchemeFactory()); + } + + private String dataPath; // required + private boolean isCopy; // required + private boolean isPurge; // 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 { + DATA_PATH((short)1, "dataPath"), + IS_COPY((short)2, "isCopy"), + IS_PURGE((short)3, "isPurge"); + + 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: // DATA_PATH + return DATA_PATH; + case 2: // IS_COPY + return IS_COPY; + case 3: // IS_PURGE + return IS_PURGE; + 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 __ISCOPY_ISSET_ID = 0; + private static final int __ISPURGE_ISSET_ID = 1; + 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.DATA_PATH, new org.apache.thrift.meta_data.FieldMetaData("dataPath", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.PART_NAMES, new org.apache.thrift.meta_data.FieldMetaData("partNames", org.apache.thrift.TFieldRequirementType.DEFAULT, - 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.IS_COPY, new org.apache.thrift.meta_data.FieldMetaData("isCopy", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.IS_PURGE, new org.apache.thrift.meta_data.FieldMetaData("isPurge", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(truncate_table_args.class, metaDataMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(cm_recycle_args.class, metaDataMap); } - public truncate_table_args() { + public cm_recycle_args() { } - public truncate_table_args( - String dbName, - String tableName, - List partNames) + public cm_recycle_args( + String dataPath, + boolean isCopy, + boolean isPurge) { this(); - this.dbName = dbName; - this.tableName = tableName; - this.partNames = partNames; + this.dataPath = dataPath; + this.isCopy = isCopy; + setIsCopyIsSet(true); + this.isPurge = isPurge; + setIsPurgeIsSet(true); } /** * Performs a deep copy on other. */ - public truncate_table_args(truncate_table_args other) { - if (other.isSetDbName()) { - this.dbName = other.dbName; - } - if (other.isSetTableName()) { - this.tableName = other.tableName; - } - if (other.isSetPartNames()) { - List __this__partNames = new ArrayList(other.partNames); - this.partNames = __this__partNames; + public cm_recycle_args(cm_recycle_args other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetDataPath()) { + this.dataPath = other.dataPath; } + this.isCopy = other.isCopy; + this.isPurge = other.isPurge; } - public truncate_table_args deepCopy() { - return new truncate_table_args(this); + public cm_recycle_args deepCopy() { + return new cm_recycle_args(this); } @Override public void clear() { - this.dbName = null; - this.tableName = null; - this.partNames = null; + this.dataPath = null; + setIsCopyIsSet(false); + this.isCopy = false; + setIsPurgeIsSet(false); + this.isPurge = false; } - public String getDbName() { - return this.dbName; + public String getDataPath() { + return this.dataPath; } - public void setDbName(String dbName) { - this.dbName = dbName; + public void setDataPath(String dataPath) { + this.dataPath = dataPath; } - public void unsetDbName() { - this.dbName = null; + public void unsetDataPath() { + this.dataPath = null; } - /** Returns true if field dbName is set (has been assigned a value) and false otherwise */ - public boolean isSetDbName() { - return this.dbName != null; + /** Returns true if field dataPath is set (has been assigned a value) and false otherwise */ + public boolean isSetDataPath() { + return this.dataPath != null; } - public void setDbNameIsSet(boolean value) { + public void setDataPathIsSet(boolean value) { if (!value) { - this.dbName = null; + this.dataPath = null; } } - public String getTableName() { - return this.tableName; + public boolean isIsCopy() { + return this.isCopy; } - public void setTableName(String tableName) { - this.tableName = tableName; + public void setIsCopy(boolean isCopy) { + this.isCopy = isCopy; + setIsCopyIsSet(true); } - public void unsetTableName() { - this.tableName = null; + public void unsetIsCopy() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISCOPY_ISSET_ID); } - /** Returns true if field tableName is set (has been assigned a value) and false otherwise */ - public boolean isSetTableName() { - return this.tableName != null; + /** Returns true if field isCopy is set (has been assigned a value) and false otherwise */ + public boolean isSetIsCopy() { + return EncodingUtils.testBit(__isset_bitfield, __ISCOPY_ISSET_ID); } - public void setTableNameIsSet(boolean value) { - if (!value) { - this.tableName = null; - } - } - - public int getPartNamesSize() { - return (this.partNames == null) ? 0 : this.partNames.size(); - } - - public java.util.Iterator getPartNamesIterator() { - return (this.partNames == null) ? null : this.partNames.iterator(); - } - - public void addToPartNames(String elem) { - if (this.partNames == null) { - this.partNames = new ArrayList(); - } - this.partNames.add(elem); + public void setIsCopyIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISCOPY_ISSET_ID, value); } - public List getPartNames() { - return this.partNames; + public boolean isIsPurge() { + return this.isPurge; } - public void setPartNames(List partNames) { - this.partNames = partNames; + public void setIsPurge(boolean isPurge) { + this.isPurge = isPurge; + setIsPurgeIsSet(true); } - public void unsetPartNames() { - this.partNames = null; + public void unsetIsPurge() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISPURGE_ISSET_ID); } - /** Returns true if field partNames is set (has been assigned a value) and false otherwise */ - public boolean isSetPartNames() { - return this.partNames != null; + /** Returns true if field isPurge is set (has been assigned a value) and false otherwise */ + public boolean isSetIsPurge() { + return EncodingUtils.testBit(__isset_bitfield, __ISPURGE_ISSET_ID); } - public void setPartNamesIsSet(boolean value) { - if (!value) { - this.partNames = null; - } + public void setIsPurgeIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISPURGE_ISSET_ID, value); } public void setFieldValue(_Fields field, Object value) { switch (field) { - case DB_NAME: + case DATA_PATH: if (value == null) { - unsetDbName(); + unsetDataPath(); } else { - setDbName((String)value); + setDataPath((String)value); } break; - case TABLE_NAME: + case IS_COPY: if (value == null) { - unsetTableName(); + unsetIsCopy(); } else { - setTableName((String)value); + setIsCopy((Boolean)value); } break; - case PART_NAMES: + case IS_PURGE: if (value == null) { - unsetPartNames(); + unsetIsPurge(); } else { - setPartNames((List)value); + setIsPurge((Boolean)value); } break; @@ -51339,14 +52448,14 @@ public void setFieldValue(_Fields field, Object value) { public Object getFieldValue(_Fields field) { switch (field) { - case DB_NAME: - return getDbName(); + case DATA_PATH: + return getDataPath(); - case TABLE_NAME: - return getTableName(); + case IS_COPY: + return isIsCopy(); - case PART_NAMES: - return getPartNames(); + case IS_PURGE: + return isIsPurge(); } throw new IllegalStateException(); @@ -51359,12 +52468,12 @@ public boolean isSet(_Fields field) { } switch (field) { - case DB_NAME: - return isSetDbName(); - case TABLE_NAME: - return isSetTableName(); - case PART_NAMES: - return isSetPartNames(); + case DATA_PATH: + return isSetDataPath(); + case IS_COPY: + return isSetIsCopy(); + case IS_PURGE: + return isSetIsPurge(); } throw new IllegalStateException(); } @@ -51373,39 +52482,39 @@ public boolean isSet(_Fields field) { public boolean equals(Object that) { if (that == null) return false; - if (that instanceof truncate_table_args) - return this.equals((truncate_table_args)that); + if (that instanceof cm_recycle_args) + return this.equals((cm_recycle_args)that); return false; } - public boolean equals(truncate_table_args that) { + public boolean equals(cm_recycle_args that) { if (that == null) return false; - boolean this_present_dbName = true && this.isSetDbName(); - boolean that_present_dbName = true && that.isSetDbName(); - if (this_present_dbName || that_present_dbName) { - if (!(this_present_dbName && that_present_dbName)) + boolean this_present_dataPath = true && this.isSetDataPath(); + boolean that_present_dataPath = true && that.isSetDataPath(); + if (this_present_dataPath || that_present_dataPath) { + if (!(this_present_dataPath && that_present_dataPath)) return false; - if (!this.dbName.equals(that.dbName)) + if (!this.dataPath.equals(that.dataPath)) return false; } - boolean this_present_tableName = true && this.isSetTableName(); - boolean that_present_tableName = true && that.isSetTableName(); - if (this_present_tableName || that_present_tableName) { - if (!(this_present_tableName && that_present_tableName)) + boolean this_present_isCopy = true; + boolean that_present_isCopy = true; + if (this_present_isCopy || that_present_isCopy) { + if (!(this_present_isCopy && that_present_isCopy)) return false; - if (!this.tableName.equals(that.tableName)) + if (this.isCopy != that.isCopy) return false; } - boolean this_present_partNames = true && this.isSetPartNames(); - boolean that_present_partNames = true && that.isSetPartNames(); - if (this_present_partNames || that_present_partNames) { - if (!(this_present_partNames && that_present_partNames)) + boolean this_present_isPurge = true; + boolean that_present_isPurge = true; + if (this_present_isPurge || that_present_isPurge) { + if (!(this_present_isPurge && that_present_isPurge)) return false; - if (!this.partNames.equals(that.partNames)) + if (this.isPurge != that.isPurge) return false; } @@ -51416,58 +52525,58 @@ public boolean equals(truncate_table_args that) { public int hashCode() { List list = new ArrayList(); - boolean present_dbName = true && (isSetDbName()); - list.add(present_dbName); - if (present_dbName) - list.add(dbName); + boolean present_dataPath = true && (isSetDataPath()); + list.add(present_dataPath); + if (present_dataPath) + list.add(dataPath); - boolean present_tableName = true && (isSetTableName()); - list.add(present_tableName); - if (present_tableName) - list.add(tableName); + boolean present_isCopy = true; + list.add(present_isCopy); + if (present_isCopy) + list.add(isCopy); - boolean present_partNames = true && (isSetPartNames()); - list.add(present_partNames); - if (present_partNames) - list.add(partNames); + boolean present_isPurge = true; + list.add(present_isPurge); + if (present_isPurge) + list.add(isPurge); return list.hashCode(); } @Override - public int compareTo(truncate_table_args other) { + public int compareTo(cm_recycle_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; - lastComparison = Boolean.valueOf(isSetDbName()).compareTo(other.isSetDbName()); + lastComparison = Boolean.valueOf(isSetDataPath()).compareTo(other.isSetDataPath()); if (lastComparison != 0) { return lastComparison; } - if (isSetDbName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dbName, other.dbName); + if (isSetDataPath()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataPath, other.dataPath); if (lastComparison != 0) { return lastComparison; } } - lastComparison = Boolean.valueOf(isSetTableName()).compareTo(other.isSetTableName()); + lastComparison = Boolean.valueOf(isSetIsCopy()).compareTo(other.isSetIsCopy()); if (lastComparison != 0) { return lastComparison; } - if (isSetTableName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, other.tableName); + if (isSetIsCopy()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isCopy, other.isCopy); if (lastComparison != 0) { return lastComparison; } } - lastComparison = Boolean.valueOf(isSetPartNames()).compareTo(other.isSetPartNames()); + lastComparison = Boolean.valueOf(isSetIsPurge()).compareTo(other.isSetIsPurge()); if (lastComparison != 0) { return lastComparison; } - if (isSetPartNames()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partNames, other.partNames); + if (isSetIsPurge()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isPurge, other.isPurge); if (lastComparison != 0) { return lastComparison; } @@ -51489,31 +52598,23 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public String toString() { - StringBuilder sb = new StringBuilder("truncate_table_args("); + StringBuilder sb = new StringBuilder("cm_recycle_args("); boolean first = true; - sb.append("dbName:"); - if (this.dbName == null) { + sb.append("dataPath:"); + if (this.dataPath == null) { sb.append("null"); } else { - sb.append(this.dbName); + sb.append(this.dataPath); } first = false; if (!first) sb.append(", "); - sb.append("tableName:"); - if (this.tableName == null) { - sb.append("null"); - } else { - sb.append(this.tableName); - } + sb.append("isCopy:"); + sb.append(this.isCopy); first = false; if (!first) sb.append(", "); - sb.append("partNames:"); - if (this.partNames == null) { - sb.append("null"); - } else { - sb.append(this.partNames); - } + sb.append("isPurge:"); + sb.append(this.isPurge); first = false; sb.append(")"); return sb.toString(); @@ -51534,21 +52635,23 @@ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOExcept 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 truncate_table_argsStandardSchemeFactory implements SchemeFactory { - public truncate_table_argsStandardScheme getScheme() { - return new truncate_table_argsStandardScheme(); + private static class cm_recycle_argsStandardSchemeFactory implements SchemeFactory { + public cm_recycle_argsStandardScheme getScheme() { + return new cm_recycle_argsStandardScheme(); } } - private static class truncate_table_argsStandardScheme extends StandardScheme { + private static class cm_recycle_argsStandardScheme extends StandardScheme { - public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_args struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, cm_recycle_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -51558,36 +52661,26 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_args break; } switch (schemeField.id) { - case 1: // DB_NAME + case 1: // DATA_PATH if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.dbName = iprot.readString(); - struct.setDbNameIsSet(true); + struct.dataPath = iprot.readString(); + struct.setDataPathIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 2: // TABLE_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.tableName = iprot.readString(); - struct.setTableNameIsSet(true); + case 2: // IS_COPY + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.isCopy = iprot.readBool(); + struct.setIsCopyIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 3: // PART_NAMES - if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { - { - org.apache.thrift.protocol.TList _list796 = iprot.readListBegin(); - struct.partNames = new ArrayList(_list796.size); - String _elem797; - for (int _i798 = 0; _i798 < _list796.size; ++_i798) - { - _elem797 = iprot.readString(); - struct.partNames.add(_elem797); - } - iprot.readListEnd(); - } - struct.setPartNamesIsSet(true); + case 3: // IS_PURGE + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.isPurge = iprot.readBool(); + struct.setIsPurgeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -51601,116 +52694,90 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_args struct.validate(); } - public void write(org.apache.thrift.protocol.TProtocol oprot, truncate_table_args struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, cm_recycle_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); - if (struct.dbName != null) { - oprot.writeFieldBegin(DB_NAME_FIELD_DESC); - oprot.writeString(struct.dbName); - oprot.writeFieldEnd(); - } - if (struct.tableName != null) { - oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC); - oprot.writeString(struct.tableName); - oprot.writeFieldEnd(); - } - if (struct.partNames != null) { - oprot.writeFieldBegin(PART_NAMES_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.partNames.size())); - for (String _iter799 : struct.partNames) - { - oprot.writeString(_iter799); - } - oprot.writeListEnd(); - } + if (struct.dataPath != null) { + oprot.writeFieldBegin(DATA_PATH_FIELD_DESC); + oprot.writeString(struct.dataPath); oprot.writeFieldEnd(); } + oprot.writeFieldBegin(IS_COPY_FIELD_DESC); + oprot.writeBool(struct.isCopy); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(IS_PURGE_FIELD_DESC); + oprot.writeBool(struct.isPurge); + oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } - private static class truncate_table_argsTupleSchemeFactory implements SchemeFactory { - public truncate_table_argsTupleScheme getScheme() { - return new truncate_table_argsTupleScheme(); + private static class cm_recycle_argsTupleSchemeFactory implements SchemeFactory { + public cm_recycle_argsTupleScheme getScheme() { + return new cm_recycle_argsTupleScheme(); } } - private static class truncate_table_argsTupleScheme extends TupleScheme { + private static class cm_recycle_argsTupleScheme extends TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, truncate_table_args struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, cm_recycle_args struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); - if (struct.isSetDbName()) { + if (struct.isSetDataPath()) { optionals.set(0); } - if (struct.isSetTableName()) { + if (struct.isSetIsCopy()) { optionals.set(1); } - if (struct.isSetPartNames()) { + if (struct.isSetIsPurge()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); - if (struct.isSetDbName()) { - oprot.writeString(struct.dbName); + if (struct.isSetDataPath()) { + oprot.writeString(struct.dataPath); } - if (struct.isSetTableName()) { - oprot.writeString(struct.tableName); + if (struct.isSetIsCopy()) { + oprot.writeBool(struct.isCopy); } - if (struct.isSetPartNames()) { - { - oprot.writeI32(struct.partNames.size()); - for (String _iter800 : struct.partNames) - { - oprot.writeString(_iter800); - } - } + if (struct.isSetIsPurge()) { + oprot.writeBool(struct.isPurge); } } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, truncate_table_args struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, cm_recycle_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { - struct.dbName = iprot.readString(); - struct.setDbNameIsSet(true); + struct.dataPath = iprot.readString(); + struct.setDataPathIsSet(true); } if (incoming.get(1)) { - struct.tableName = iprot.readString(); - struct.setTableNameIsSet(true); + struct.isCopy = iprot.readBool(); + struct.setIsCopyIsSet(true); } if (incoming.get(2)) { - { - org.apache.thrift.protocol.TList _list801 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.partNames = new ArrayList(_list801.size); - String _elem802; - for (int _i803 = 0; _i803 < _list801.size; ++_i803) - { - _elem802 = iprot.readString(); - struct.partNames.add(_elem802); - } - } - struct.setPartNamesIsSet(true); + struct.isPurge = iprot.readBool(); + struct.setIsPurgeIsSet(true); } } } } - public static class truncate_table_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("truncate_table_result"); + public static class cm_recycle_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("cm_recycle_result"); private static final org.apache.thrift.protocol.TField O1_FIELD_DESC = new org.apache.thrift.protocol.TField("o1", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { - schemes.put(StandardScheme.class, new truncate_table_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new truncate_table_resultTupleSchemeFactory()); + schemes.put(StandardScheme.class, new cm_recycle_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new cm_recycle_resultTupleSchemeFactory()); } private MetaException o1; // required @@ -51780,13 +52847,13 @@ public String getFieldName() { tmpMap.put(_Fields.O1, new org.apache.thrift.meta_data.FieldMetaData("o1", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(truncate_table_result.class, metaDataMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(cm_recycle_result.class, metaDataMap); } - public truncate_table_result() { + public cm_recycle_result() { } - public truncate_table_result( + public cm_recycle_result( MetaException o1) { this(); @@ -51796,14 +52863,14 @@ public truncate_table_result( /** * Performs a deep copy on other. */ - public truncate_table_result(truncate_table_result other) { + public cm_recycle_result(cm_recycle_result other) { if (other.isSetO1()) { this.o1 = new MetaException(other.o1); } } - public truncate_table_result deepCopy() { - return new truncate_table_result(this); + public cm_recycle_result deepCopy() { + return new cm_recycle_result(this); } @Override @@ -51873,12 +52940,12 @@ public boolean isSet(_Fields field) { public boolean equals(Object that) { if (that == null) return false; - if (that instanceof truncate_table_result) - return this.equals((truncate_table_result)that); + if (that instanceof cm_recycle_result) + return this.equals((cm_recycle_result)that); return false; } - public boolean equals(truncate_table_result that) { + public boolean equals(cm_recycle_result that) { if (that == null) return false; @@ -51907,7 +52974,7 @@ public int hashCode() { } @Override - public int compareTo(truncate_table_result other) { + public int compareTo(cm_recycle_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } @@ -51941,7 +53008,7 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public String toString() { - StringBuilder sb = new StringBuilder("truncate_table_result("); + StringBuilder sb = new StringBuilder("cm_recycle_result("); boolean first = true; sb.append("o1:"); @@ -51976,15 +53043,15 @@ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException } } - private static class truncate_table_resultStandardSchemeFactory implements SchemeFactory { - public truncate_table_resultStandardScheme getScheme() { - return new truncate_table_resultStandardScheme(); + private static class cm_recycle_resultStandardSchemeFactory implements SchemeFactory { + public cm_recycle_resultStandardScheme getScheme() { + return new cm_recycle_resultStandardScheme(); } } - private static class truncate_table_resultStandardScheme extends StandardScheme { + private static class cm_recycle_resultStandardScheme extends StandardScheme { - public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, cm_recycle_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -52012,7 +53079,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, truncate_table_resu struct.validate(); } - public void write(org.apache.thrift.protocol.TProtocol oprot, truncate_table_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, cm_recycle_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); @@ -52027,16 +53094,16 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, truncate_table_res } - private static class truncate_table_resultTupleSchemeFactory implements SchemeFactory { - public truncate_table_resultTupleScheme getScheme() { - return new truncate_table_resultTupleScheme(); + private static class cm_recycle_resultTupleSchemeFactory implements SchemeFactory { + public cm_recycle_resultTupleScheme getScheme() { + return new cm_recycle_resultTupleScheme(); } } - private static class truncate_table_resultTupleScheme extends TupleScheme { + private static class cm_recycle_resultTupleScheme extends TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, truncate_table_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, cm_recycle_result struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetO1()) { @@ -52049,7 +53116,7 @@ public void write(org.apache.thrift.protocol.TProtocol prot, truncate_table_resu } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, truncate_table_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, cm_recycle_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { diff --git a/metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php b/metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php index 709eea9..e69466b 100644 --- a/metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php +++ b/metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php @@ -223,6 +223,13 @@ interface ThriftHiveMetastoreIf extends \FacebookServiceIf { */ public function truncate_table($dbName, $tableName, array $partNames); /** + * @param string $dataPath + * @param bool $isCopy + * @param bool $isPurge + * @throws \metastore\MetaException + */ + public function cm_recycle($dataPath, $isCopy, $isPurge); + /** * @param string $db_name * @param string $pattern * @return string[] @@ -2771,6 +2778,59 @@ class ThriftHiveMetastoreClient extends \FacebookServiceClient implements \metas return; } + public function cm_recycle($dataPath, $isCopy, $isPurge) + { + $this->send_cm_recycle($dataPath, $isCopy, $isPurge); + $this->recv_cm_recycle(); + } + + public function send_cm_recycle($dataPath, $isCopy, $isPurge) + { + $args = new \metastore\ThriftHiveMetastore_cm_recycle_args(); + $args->dataPath = $dataPath; + $args->isCopy = $isCopy; + $args->isPurge = $isPurge; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'cm_recycle', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('cm_recycle', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_cm_recycle() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\metastore\ThriftHiveMetastore_cm_recycle_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \metastore\ThriftHiveMetastore_cm_recycle_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->o1 !== null) { + throw $result->o1; + } + return; + } + public function get_tables($db_name, $pattern) { $this->send_get_tables($db_name, $pattern); @@ -16389,6 +16449,204 @@ class ThriftHiveMetastore_truncate_table_result { } +class ThriftHiveMetastore_cm_recycle_args { + static $_TSPEC; + + /** + * @var string + */ + public $dataPath = null; + /** + * @var bool + */ + public $isCopy = null; + /** + * @var bool + */ + public $isPurge = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'dataPath', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'isCopy', + 'type' => TType::BOOL, + ), + 3 => array( + 'var' => 'isPurge', + 'type' => TType::BOOL, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['dataPath'])) { + $this->dataPath = $vals['dataPath']; + } + if (isset($vals['isCopy'])) { + $this->isCopy = $vals['isCopy']; + } + if (isset($vals['isPurge'])) { + $this->isPurge = $vals['isPurge']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_cm_recycle_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->dataPath); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::BOOL) { + $xfer += $input->readBool($this->isCopy); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::BOOL) { + $xfer += $input->readBool($this->isPurge); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ThriftHiveMetastore_cm_recycle_args'); + if ($this->dataPath !== null) { + $xfer += $output->writeFieldBegin('dataPath', TType::STRING, 1); + $xfer += $output->writeString($this->dataPath); + $xfer += $output->writeFieldEnd(); + } + if ($this->isCopy !== null) { + $xfer += $output->writeFieldBegin('isCopy', TType::BOOL, 2); + $xfer += $output->writeBool($this->isCopy); + $xfer += $output->writeFieldEnd(); + } + if ($this->isPurge !== null) { + $xfer += $output->writeFieldBegin('isPurge', TType::BOOL, 3); + $xfer += $output->writeBool($this->isPurge); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ThriftHiveMetastore_cm_recycle_result { + static $_TSPEC; + + /** + * @var \metastore\MetaException + */ + public $o1 = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'o1', + 'type' => TType::STRUCT, + 'class' => '\metastore\MetaException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['o1'])) { + $this->o1 = $vals['o1']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_cm_recycle_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->o1 = new \metastore\MetaException(); + $xfer += $this->o1->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ThriftHiveMetastore_cm_recycle_result'); + if ($this->o1 !== null) { + $xfer += $output->writeFieldBegin('o1', TType::STRUCT, 1); + $xfer += $this->o1->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + class ThriftHiveMetastore_get_tables_args { static $_TSPEC; diff --git a/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote b/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote index 67e9422..f60f165 100755 --- a/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote +++ b/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote @@ -51,6 +51,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print(' void drop_table(string dbname, string name, bool deleteData)') print(' void drop_table_with_environment_context(string dbname, string name, bool deleteData, EnvironmentContext environment_context)') print(' void truncate_table(string dbName, string tableName, partNames)') + print(' void cm_recycle(string dataPath, bool isCopy, bool isPurge)') print(' get_tables(string db_name, string pattern)') print(' get_tables_by_type(string db_name, string pattern, string tableType)') print(' get_table_meta(string db_patterns, string tbl_patterns, tbl_types)') @@ -414,6 +415,12 @@ elif cmd == 'truncate_table': sys.exit(1) pp.pprint(client.truncate_table(args[0],args[1],eval(args[2]),)) +elif cmd == 'cm_recycle': + if len(args) != 3: + print('cm_recycle requires 3 args') + sys.exit(1) + pp.pprint(client.cm_recycle(args[0],eval(args[1]),eval(args[2]),)) + elif cmd == 'get_tables': if len(args) != 2: print('get_tables requires 2 args') diff --git a/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py b/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py index a4937e2..0980525 100644 --- a/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py +++ b/metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py @@ -230,6 +230,15 @@ def truncate_table(self, dbName, tableName, partNames): """ pass + def cm_recycle(self, dataPath, isCopy, isPurge): + """ + Parameters: + - dataPath + - isCopy + - isPurge + """ + pass + def get_tables(self, db_name, pattern): """ Parameters: @@ -2248,6 +2257,41 @@ def recv_truncate_table(self): raise result.o1 return + def cm_recycle(self, dataPath, isCopy, isPurge): + """ + Parameters: + - dataPath + - isCopy + - isPurge + """ + self.send_cm_recycle(dataPath, isCopy, isPurge) + self.recv_cm_recycle() + + def send_cm_recycle(self, dataPath, isCopy, isPurge): + self._oprot.writeMessageBegin('cm_recycle', TMessageType.CALL, self._seqid) + args = cm_recycle_args() + args.dataPath = dataPath + args.isCopy = isCopy + args.isPurge = isPurge + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_cm_recycle(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = cm_recycle_result() + result.read(iprot) + iprot.readMessageEnd() + if result.o1 is not None: + raise result.o1 + return + def get_tables(self, db_name, pattern): """ Parameters: @@ -7036,6 +7080,7 @@ def __init__(self, handler): self._processMap["drop_table"] = Processor.process_drop_table self._processMap["drop_table_with_environment_context"] = Processor.process_drop_table_with_environment_context self._processMap["truncate_table"] = Processor.process_truncate_table + self._processMap["cm_recycle"] = Processor.process_cm_recycle self._processMap["get_tables"] = Processor.process_get_tables self._processMap["get_tables_by_type"] = Processor.process_get_tables_by_type self._processMap["get_table_meta"] = Processor.process_get_table_meta @@ -7880,6 +7925,28 @@ def process_truncate_table(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_cm_recycle(self, seqid, iprot, oprot): + args = cm_recycle_args() + args.read(iprot) + iprot.readMessageEnd() + result = cm_recycle_result() + try: + self._handler.cm_recycle(args.dataPath, args.isCopy, args.isPurge) + msg_type = TMessageType.REPLY + except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): + raise + except MetaException as o1: + msg_type = TMessageType.REPLY + result.o1 = o1 + except Exception as ex: + msg_type = TMessageType.EXCEPTION + logging.exception(ex) + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("cm_recycle", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_get_tables(self, seqid, iprot, oprot): args = get_tables_args() args.read(iprot) @@ -15611,6 +15678,163 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +class cm_recycle_args: + """ + Attributes: + - dataPath + - isCopy + - isPurge + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'dataPath', None, None, ), # 1 + (2, TType.BOOL, 'isCopy', None, None, ), # 2 + (3, TType.BOOL, 'isPurge', None, None, ), # 3 + ) + + def __init__(self, dataPath=None, isCopy=None, isPurge=None,): + self.dataPath = dataPath + self.isCopy = isCopy + self.isPurge = isPurge + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.dataPath = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.isCopy = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.BOOL: + self.isPurge = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('cm_recycle_args') + if self.dataPath is not None: + oprot.writeFieldBegin('dataPath', TType.STRING, 1) + oprot.writeString(self.dataPath) + oprot.writeFieldEnd() + if self.isCopy is not None: + oprot.writeFieldBegin('isCopy', TType.BOOL, 2) + oprot.writeBool(self.isCopy) + oprot.writeFieldEnd() + if self.isPurge is not None: + oprot.writeFieldBegin('isPurge', TType.BOOL, 3) + oprot.writeBool(self.isPurge) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.dataPath) + value = (value * 31) ^ hash(self.isCopy) + value = (value * 31) ^ hash(self.isPurge) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class cm_recycle_result: + """ + Attributes: + - o1 + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'o1', (MetaException, MetaException.thrift_spec), None, ), # 1 + ) + + def __init__(self, o1=None,): + self.o1 = o1 + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.o1 = MetaException() + self.o1.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('cm_recycle_result') + if self.o1 is not None: + oprot.writeFieldBegin('o1', TType.STRUCT, 1) + self.o1.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __hash__(self): + value = 17 + value = (value * 31) ^ hash(self.o1) + return value + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class get_tables_args: """ Attributes: diff --git a/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb b/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb index 2711381..7517faf 100644 --- a/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb +++ b/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb @@ -463,6 +463,21 @@ module ThriftHiveMetastore return end + def cm_recycle(dataPath, isCopy, isPurge) + send_cm_recycle(dataPath, isCopy, isPurge) + recv_cm_recycle() + end + + def send_cm_recycle(dataPath, isCopy, isPurge) + send_message('cm_recycle', Cm_recycle_args, :dataPath => dataPath, :isCopy => isCopy, :isPurge => isPurge) + end + + def recv_cm_recycle() + result = receive_message(Cm_recycle_result) + raise result.o1 unless result.o1.nil? + return + end + def get_tables(db_name, pattern) send_get_tables(db_name, pattern) return recv_get_tables() @@ -3014,6 +3029,17 @@ module ThriftHiveMetastore write_result(result, oprot, 'truncate_table', seqid) end + def process_cm_recycle(seqid, iprot, oprot) + args = read_args(iprot, Cm_recycle_args) + result = Cm_recycle_result.new() + begin + @handler.cm_recycle(args.dataPath, args.isCopy, args.isPurge) + rescue ::MetaException => o1 + result.o1 = o1 + end + write_result(result, oprot, 'cm_recycle', seqid) + end + def process_get_tables(seqid, iprot, oprot) args = read_args(iprot, Get_tables_args) result = Get_tables_result.new() @@ -5605,6 +5631,42 @@ module ThriftHiveMetastore ::Thrift::Struct.generate_accessors self end + class Cm_recycle_args + include ::Thrift::Struct, ::Thrift::Struct_Union + DATAPATH = 1 + ISCOPY = 2 + ISPURGE = 3 + + FIELDS = { + DATAPATH => {:type => ::Thrift::Types::STRING, :name => 'dataPath'}, + ISCOPY => {:type => ::Thrift::Types::BOOL, :name => 'isCopy'}, + ISPURGE => {:type => ::Thrift::Types::BOOL, :name => 'isPurge'} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + + class Cm_recycle_result + include ::Thrift::Struct, ::Thrift::Struct_Union + O1 = 1 + + FIELDS = { + O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => ::MetaException} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + class Get_tables_args include ::Thrift::Struct, ::Thrift::Struct_Union DB_NAME = 1 diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 52bfb26..82e1e93 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -2066,6 +2066,12 @@ private void alterTableStatsForTruncate(final RawStore ms, } @Override + public void cm_recycle(final String dataPath, final boolean isCopy, final boolean isPurge) throws MetaException { + wh.recycleDirToCmPath(new Path(dataPath), isCopy, isPurge); + return; + } + + @Override public void truncate_table(final String dbName, final String tableName, List partNames) throws NoSuchObjectException, MetaException { try { diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 0ff4c11..0173bd6 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -1125,6 +1125,20 @@ public void truncateTable(String dbName, String tableName, List partName } /** + * Recycles the files recursively from the input path to the cmroot directory either by copying or moving it. + * + * @param dataPath Path of the data files to be recycled to cmroot + * @param isCopy + * If this flag is true, then files will be copied recursively to cmroot else will be moved. + * @param isPurge + * When set to true files which needs to be recycled are not moved to Trash + */ + @Override + public void recycleDirToCmPath(String dataPath, boolean isCopy, boolean isPurge) throws MetaException, TException { + client.cm_recycle(dataPath, isCopy, isPurge); + } + + /** * @param type * @return true if the type is dropped * @throws MetaException diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java index 3663305..50a193b 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java @@ -322,6 +322,17 @@ void dropTable(String dbname, String tableName) */ void truncateTable(String dbName, String tableName, List partNames) throws MetaException, TException; + /** + * Recycles the files recursively from the input path to the cmroot directory either by copying or moving it. + * + * @param dataPath Path of the data files to be recycled to cmroot + * @param isCopy + * If this flag is true, then files will be copied recursively to cmroot else will be moved. + * @param isPurge + * When set to true files which needs to be recycled are not moved to Trash + */ + void recycleDirToCmPath(String dataPath, boolean isCopy, boolean isPurge) throws MetaException, TException; + boolean tableExists(String databaseName, String tableName) throws MetaException, TException, UnknownDBException; diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java b/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java index 8134ab2..f2cbd38 100755 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java @@ -216,6 +216,18 @@ public boolean deleteDir(Path f, boolean recursive, boolean ifPurge) throws Meta return fsHandler.deleteDir(fs, f, recursive, ifPurge, conf); } + public void recycleDirToCmPath(Path f, boolean ifCopy, boolean ifPurge) throws MetaException { + // ifCopy input is just a place holder to support copy of data files to cmroot. + // Currently we through exception if it is set to true. + // This flag is useful in case of rename where the data won't be deleted and hence should be copied instead of move. + // Shall remove this exception once it is supported. + if (ifCopy) { + throw new MetaException("CM doesn't support copying of files to cmroot. It only supports move right now."); + } + cm.recycle(f, ifPurge); + return; + } + public boolean isEmpty(Path path) throws IOException, MetaException { ContentSummary contents = getFs(path).getContentSummary(path); if (contents != null && contents.getFileCount() == 0 && contents.getDirectoryCount() == 1) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index 3f032c8..f0276c0 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -3171,6 +3171,23 @@ public static void listNewFilesRecursively(final FileSystem destFs, Path dest, } } + /** + * Recycles the files recursively from the input path to the cmroot directory either by copying or moving it. + * + * @param dataPath Path of the data files to be recycled to cmroot + * @param isCopy + * If this flag is true, then files will be copied recursively to cmroot else will be moved. + * @param isPurge + * When set to true files which needs to be recycled are not moved to Trash + */ + public void recycleDirToCmPath(Path dataPath, boolean isCopy, boolean isPurge) throws HiveException { + try { + getMSC().recycleDirToCmPath(dataPath.toString(), isCopy, isPurge); + } catch (Exception e) { + throw new HiveException(e); + } + } + //it is assumed that parent directory of the destf should already exist when this //method is called. when the replace value is true, this method works a little different //from mv command if the destf is a directory, it replaces the destf instead of moving under @@ -3447,7 +3464,6 @@ private static void moveAcidDeltaFiles(String deltaFileType, PathFilter pathFilt } } - /** * Replaces files in the partition with new data set specified by srcf. Works * by renaming directory of srcf to the destination file. @@ -3496,7 +3512,7 @@ protected void replaceFiles(Path tablePath, Path srcf, Path destf, Path oldPath, FileStatus[] statuses = null; try { FileSystem oldFs = oldPath.getFileSystem(conf); - statuses = oldFs.listStatus(oldPath, FileUtils.HIDDEN_FILES_PATH_FILTER); + // Do not delete oldPath if: // - destf is subdir of oldPath isOldPathUnderDestf = isSubDir(oldPath, destf, oldFs, destFs, false); @@ -3505,6 +3521,10 @@ protected void replaceFiles(Path tablePath, Path srcf, Path destf, Path oldPath, // existing content might result in incorrect (extra) data. // But not sure why we changed not to delete the oldPath in HIVE-8750 if it is // not the destf or its subdir? + if (conf.getBoolVar(HiveConf.ConfVars.REPLCMENABLED)) { + recycleDirToCmPath(oldPath, false, purge); + } + statuses = oldFs.listStatus(oldPath, FileUtils.HIDDEN_FILES_PATH_FILTER); oldPathDeleted = trashFiles(oldFs, statuses, conf, purge); } } catch (IOException e) { @@ -3518,7 +3538,7 @@ protected void replaceFiles(Path tablePath, Path srcf, Path destf, Path oldPath, } } if (statuses != null && statuses.length > 0) { - if (isOldPathUnderDestf && !oldPathDeleted) { + if (!oldPathDeleted) { throw new HiveException("Destination directory " + destf + " has not be cleaned up."); } }