本文整理汇总了C++中NdbOperation::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbOperation::setValue方法的具体用法?C++ NdbOperation::setValue怎么用?C++ NdbOperation::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbOperation
的用法示例。
在下文中一共展示了NdbOperation::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
start_T1(Ndb * pNDB, ThreadData * td, int async){
DEBUG2("T1(%.*s): - Starting", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number);
NdbConnection * pCON = 0;
while((pCON = startTransaction(pNDB, td)) == 0){
CHECK_ALLOWED_ERROR("T1: startTransaction", td, pNDB->getNdbError());
NdbSleep_MilliSleep(10);
}
NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOp != NULL) {
MyOp->updateTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
if (async == 1) {
pCON->executeAsynchPrepare( Commit , T1_Callback, td);
} else {
int result = pCON->execute(Commit);
T1_Callback(result, pCON, (void*)td);
return;
}//if
} else {
CHECK_NULL(MyOp, "T1: getNdbOperation", td, pCON->getNdbError());
}//if
}
示例2:
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
void
start_T1(Ndb * pNDB, ThreadData * td){
DEBUG2("T1(%.*s): - Starting\n", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number);
int check;
NdbConnection * pCON = pNDB->startTransaction();
if (pCON != NULL) {
NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOp != NULL) {
MyOp->updateTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
pCON->executeAsynchPrepare( Commit , T1_Callback, td);
} else {
CHECK_NULL(MyOp, "T1: getNdbOperation", pCON);
}//if
} else {
error_handler("T1-1: startTranscation",
pNDB->getNdbErrorString(),
pNDB->getNdbError());
}//if
}
示例3:
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
int
T1(void * obj,
const SubscriberNumber number,
const Location new_location,
const ChangedBy changed_by,
const ChangedTime changed_time,
BenchmarkTime * transaction_time){
Ndb * pNDB = (Ndb *) obj;
DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
BenchmarkTime start;
get_time(&start);
int check;
NdbRecAttr * check2;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction);
check = MyOperation->updateTuple();
CHECK_MINUS_ONE(check, "T1: updateTuple",
MyTransaction);
check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
number);
CHECK_MINUS_ONE(check, "T1: equal subscriber",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&new_location);
CHECK_MINUS_ONE(check, "T1: setValue location",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
changed_by);
CHECK_MINUS_ONE(check, "T1: setValue changed_by",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
changed_time);
CHECK_MINUS_ONE(check, "T1: setValue changed_time",
MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "T1: Commit",
MyTransaction);
pNDB->closeTransaction(MyTransaction);
get_time(transaction_time);
time_diff(transaction_time, &start);
return 0;
}
示例4: write_rows
void write_rows (Ndb* pMyNdb) {
/****************************************************************
* Insert rows into SimpleTable
*
***************************************************************/
int check = -1 ;
int loop_count_ops = nRecords ;
NdbOperation *MyOperation = NULL ;
NdbConnection *MyTransaction = NULL ;
ndbout << endl << "Writing records ..." << flush;
for (int count=0 ; count < loop_count_ops ; count++) {
MyTransaction = pMyNdb->startTransaction();
if (!MyTransaction) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if
MyOperation = MyTransaction->getNdbOperation(tableName);
if (!MyOperation) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if
check = MyOperation->writeTuple();
if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
check = MyOperation->equal( attrName[0],(char*)&pkValue[count] );
if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
// Update the columns, index column already ok.
for (int i = 1 ; i < MAXATTR; i++) {
if ((i == 2) && (count > 4)) {
check = MyOperation->setValue(attrName[i], (char*)&attrValue[count + 1]);
} else {
check = MyOperation->setValue(attrName[i], (char*)&attrValue[count]);
}
if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
}
check = MyTransaction->execute( Commit );
if(check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
pMyNdb->closeTransaction(MyTransaction);
}
ndbout <<" \tOK" << endl;
return;
}
示例5: UpdateTransaction
int UpdateTransaction(Ndb* pNdb, long iContextId, NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!pNdbOperation->updateTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId)
&& !pNdbOperation->setValue(c_szContextData, STATUS_DATA, g_nStatusDataSize))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例6: ERR
int
UtilTransactions::addRowToInsert(Ndb* pNdb,
NdbConnection* pInsTrans,
NDBT_ResultRow & row,
const char *insertTabName){
int check;
NdbOperation* pInsOp;
pInsOp = pInsTrans->getNdbOperation(insertTabName);
if (pInsOp == NULL) {
ERR(pInsTrans->getNdbError());
return NDBT_FAILED;
}
check = pInsOp->insertTuple();
if( check == -1 ) {
ERR(pInsTrans->getNdbError());
return NDBT_FAILED;
}
// Set all attributes
for (int a = 0; a < tab.getNoOfColumns(); a++){
NdbRecAttr* r = row.attributeStore(a);
int sz = r->get_size_in_bytes();
if (pInsOp->setValue(tab.getColumn(a)->getName(),
r->aRef(),
sz) != 0) {
ERR(pInsTrans->getNdbError());
return NDBT_FAILED;
}
}
return NDBT_OK;
}
示例7: userDbInsertServer
int userDbInsertServer(UserHandle *uh,
ServerId serverId,
SubscriberSuffix suffix,
ServerName name)
{
int check;
uint32 noOfRead = 0;
uint32 noOfInsert = 0;
uint32 noOfDelete = 0;
NdbConnection * MyTransaction = 0;
if(uh->pCurrTrans != 0){
MyTransaction = uh->pCurrTrans;
} else {
uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
}
if (MyTransaction == NULL)
error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insert tuple", MyTransaction);
check = MyOperation->equal(SERVER_ID, (char*)&serverId);
CHECK_MINUS_ONE(check, "setValue id", MyTransaction);
check = MyOperation->setValue(SERVER_SUBSCRIBER_SUFFIX, suffix);
CHECK_MINUS_ONE(check, "setValue suffix", MyTransaction);
check = MyOperation->setValue(SERVER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SERVER_READS, (char*)&noOfRead);
CHECK_MINUS_ONE(check, "setValue reads", MyTransaction);
check = MyOperation->setValue(SERVER_INSERTS, (char*)&noOfInsert);
CHECK_MINUS_ONE(check, "setValue inserts", MyTransaction);
check = MyOperation->setValue(SERVER_DELETES, (char*)&noOfDelete);
CHECK_MINUS_ONE(check, "setValue deletes", MyTransaction);
return 0;
}
示例8:
int
insert_server(void * obj,
ServerId serverId,
SubscriberSuffix suffix,
ServerName name,
Counter noOfRead,
Counter noOfInsert,
Counter noOfDelete){
Ndb * pNDB = (Ndb *)obj;
int check;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insert tuple", MyTransaction);
check = MyOperation->equal(SERVER_ID, (char*)&serverId);
CHECK_MINUS_ONE(check, "setValue id", MyTransaction);
check = MyOperation->setValue(SERVER_SUBSCRIBER_SUFFIX, suffix);
CHECK_MINUS_ONE(check, "setValue suffix", MyTransaction);
check = MyOperation->setValue(SERVER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SERVER_READS, (char*)&noOfRead);
CHECK_MINUS_ONE(check, "setValue reads", MyTransaction);
check = MyOperation->setValue(SERVER_INSERTS, (char*)&noOfInsert);
CHECK_MINUS_ONE(check, "setValue inserts", MyTransaction);
check = MyOperation->setValue(SERVER_DELETES, (char*)&noOfDelete);
CHECK_MINUS_ONE(check, "setValue deletes", MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "commit", MyTransaction);
pNDB->closeTransaction(MyTransaction);
return 0;
}
示例9: run_master_update
static void run_master_update(struct Xxx &xxx, struct XxxR &xxxr)
{
Ndb *ndb = xxx.ndb;
const NdbDictionary::Table *myTable = xxx.table;
int retry_sleep= 10; /* 10 milliseconds */
int retries= 100;
while (1)
{
Uint32 val;
NdbTransaction *trans = ndb->startTransaction();
if (trans == NULL)
goto err;
{
NdbOperation *op = trans->getNdbOperation(myTable);
if (op == NULL)
APIERROR(trans->getNdbError());
op->readTupleExclusive();
op->equal(xxx.pk_col, xxxr.pk_val);
op->getValue(xxx.col, (char *)&val);
}
if (trans->execute(NdbTransaction::NoCommit))
goto err;
//fprintf(stderr, "read %u\n", val);
xxxr.val = val + 1;
{
NdbOperation *op = trans->getNdbOperation(myTable);
if (op == NULL)
APIERROR(trans->getNdbError());
op->updateTuple();
op->equal(xxx.pk_col, xxxr.pk_val);
op->setValue(xxx.col, xxxr.val);
}
if (trans->execute(NdbTransaction::Commit))
goto err;
ndb->closeTransaction(trans);
//fprintf(stderr, "updated to %u\n", xxxr.val);
break;
err:
const NdbError this_error= trans ?
trans->getNdbError() : ndb->getNdbError();
if (this_error.status == NdbError::TemporaryError)
{
if (retries--)
{
if (trans)
ndb->closeTransaction(trans);
NdbSleep_MilliSleep(retry_sleep);
continue; // retry
}
}
if (trans)
ndb->closeTransaction(trans);
APIERROR(this_error);
}
/* update done start timer */
gettimeofday(&xxxr.start_time, 0);
}
示例10: InsertTransaction
int InsertTransaction(Ndb* pNdb,
long iContextID,
long iVersion,
long iLockFlag,
long iLockTime,
long iLockTimeUSec,
const char* pchContextData,
NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextID, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!(g_bWriteTuple ? pNdbOperation->writeTuple() : pNdbOperation->insertTuple())
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextID)
&& !pNdbOperation->setValue(c_szVersion, (Int32)iVersion)
&& !pNdbOperation->setValue(c_szLockFlag, (Int32)iLockFlag)
&& !pNdbOperation->setValue(c_szLockTime, (Int32)iLockTime)
&& !pNdbOperation->setValue(c_szLockTimeUSec, (Int32)iLockTimeUSec)
&& !pNdbOperation->setValue(c_szContextData, pchContextData, g_nStatusDataSize))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例11: userDbInsertGroup
int userDbInsertGroup(UserHandle *uh,
GroupId groupId,
GroupName name,
Permission allowRead,
Permission allowInsert,
Permission allowDelete)
{
int check;
NdbConnection * MyTransaction = 0;
if(uh->pCurrTrans != 0){
MyTransaction = uh->pCurrTrans;
} else {
uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
}
if (MyTransaction == NULL)
error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
check = MyOperation->equal(GROUP_ID, (char*)&groupId);
CHECK_MINUS_ONE(check, "equal", MyTransaction);
check = MyOperation->setValue(NDB_GROUP_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(GROUP_ALLOW_READ, (char*)&allowRead);
CHECK_MINUS_ONE(check, "setValue allowRead", MyTransaction);
check = MyOperation->setValue(GROUP_ALLOW_INSERT, (char*)&allowInsert);
CHECK_MINUS_ONE(check, "setValue allowInsert", MyTransaction);
check = MyOperation->setValue(GROUP_ALLOW_DELETE, (char*)&allowDelete);
CHECK_MINUS_ONE(check, "setValue allowDelete", MyTransaction);
return 0;
}
示例12:
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
void
userTransaction_T1(UserHandle * uh,
SubscriberNumber number,
Location new_location,
ChangedBy changed_by,
ChangedTime changed_time){
Ndb * pNDB = uh->pNDB;
DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
int check;
NdbRecAttr * check2;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction != NULL) {
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOperation != NULL) {
MyOperation->updateTuple();
MyOperation->equal(IND_SUBSCRIBER_NUMBER,
number);
MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&new_location);
MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
changed_by);
MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
changed_time);
check = MyTransaction->execute( Commit );
if (check != -1) {
pNDB->closeTransaction(MyTransaction);
return;
} else {
CHECK_MINUS_ONE(check, "T1: Commit",
MyTransaction);
}//if
} else {
CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction);
}//if
} else {
error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError());
}//if
}
示例13: insert
//
// Example insert
// @param myNdb Ndb object representing NDB Cluster
// @param myTransaction NdbTransaction used for transaction
// @param myTable Table to insert into
// @param error NdbError object returned in case of errors
// @return -1 in case of failures, 0 otherwise
//
int insert(int transactionId, NdbTransaction* myTransaction,
const NdbDictionary::Table *myTable) {
NdbOperation *myOperation; // For other operations
myOperation = myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) return -1;
if (myOperation->insertTuple() ||
myOperation->equal("ATTR1", transactionId) ||
myOperation->setValue("ATTR2", transactionId)) {
APIERROR(myOperation->getNdbError());
exit(-1);
}
return myTransaction->execute(NdbTransaction::NoCommit);
}
示例14: userDbInsertSubscriber
int userDbInsertSubscriber(UserHandle *uh,
SubscriberNumber number,
uint32 groupId,
SubscriberName name)
{
int check;
uint32 activeSessions = 0;
Location l = 0;
ChangedBy changedBy;
ChangedTime changedTime;
BaseString::snprintf(changedBy, sizeof(changedBy), "ChangedBy");
BaseString::snprintf(changedTime, sizeof(changedTime), "ChangedTime");
NdbConnection * MyTransaction = 0;
if(uh->pCurrTrans != 0){
MyTransaction = uh->pCurrTrans;
} else {
uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
}
if (MyTransaction == NULL)
error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
check = MyOperation->equal(SUBSCRIBER_NUMBER, number);
CHECK_MINUS_ONE(check, "equal", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_GROUP, (char*)&groupId);
CHECK_MINUS_ONE(check, "setValue group", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_LOCATION, (char*)&l);
CHECK_MINUS_ONE(check, "setValue location", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_SESSIONS, (char*)&activeSessions);
CHECK_MINUS_ONE(check, "setValue sessions", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, changedBy);
CHECK_MINUS_ONE(check, "setValue changedBy", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, changedTime);
CHECK_MINUS_ONE(check, "setValue changedTime", MyTransaction);
return 0;
}
示例15: populate
/************************************************************************
* populate()
* 1. Prepare 'parallelism' number of insert transactions.
* 2. Send transactions to NDB and wait for callbacks to execute
*/
int populate(Ndb * myNdb, int data, async_callback_t * cbData)
{
NdbOperation* myNdbOperation; // For operations
const NdbDictionary::Dictionary* myDict= myNdb->getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable("api_async");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
async_callback_t * cb;
int retries = 0;
int current = 0;
for(int i=0; i<1024; i++)
{
if(transaction[i].used == 0)
{
current = i;
if (cbData == 0)
{
/**
* We already have a callback
* This is an absolutely new transaction
*/
cb = new async_callback_t;
cb->retries = 0;
}
else
{
/**
* We already have a callback
*/
cb =cbData;
retries = cbData->retries;
}
/**
* Set data used by the callback
*/
cb->ndb = myNdb; //handle to Ndb object so that we can close transaction
// in the callback (alt. make myNdb global).
cb->data = data; //this is the data we want to insert
cb->transaction = current; //This is the number (id) of this transaction
transaction[current].used = 1 ; //Mark the transaction as used
break;
}
}
if(!current)
return -1;
while(retries < MAX_RETRIES)
{
transaction[current].conn = myNdb->startTransaction();
if (transaction[current].conn == NULL) {
/**
* no transaction to close since conn == null
*/
milliSleep(10);
retries++;
continue;
}
myNdbOperation = transaction[current].conn->getNdbOperation(myTable);
if (myNdbOperation == NULL)
{
if (asynchErrorHandler(transaction[current].conn, myNdb))
{
myNdb->closeTransaction(transaction[current].conn);
transaction[current].conn = 0;
milliSleep(10);
retries++;
continue;
}
asynchExitHandler(myNdb);
} // if
if(myNdbOperation->insertTuple() < 0 ||
myNdbOperation->equal("REG_NO", data) < 0 ||
myNdbOperation->setValue("BRAND", "Mercedes") <0 ||
myNdbOperation->setValue("COLOR", "Blue") < 0)
{
if (asynchErrorHandler(transaction[current].conn, myNdb))
{
myNdb->closeTransaction(transaction[current].conn);
transaction[current].conn = 0;
retries++;
milliSleep(10);
continue;
}
asynchExitHandler(myNdb);
}
/*Prepare transaction (the transaction is NOT yet sent to NDB)*/
transaction[current].conn->executeAsynchPrepare(NdbTransaction::Commit,
&callback,
cb);
/**
* When we have prepared parallelism number of transactions ->
//.........这里部分代码省略.........