void IdbOrderBy::initialize(const RowGroup& rg) { // initialize rows IdbCompare::initialize(rg); uint64_t newSize = fRowsPerRG * rg.getRowSize(); if (!fRm->getMemory(newSize)) { cerr << IDBErrorInfo::instance()->errorMsg(fErrorCode) << " @" << __FILE__ << ":" << __LINE__; throw IDBExcept(fErrorCode); } fMemSize += newSize; fData.reinit(fRowGroup, fRowsPerRG); fRowGroup.setData(&fData); fRowGroup.resetRowGroup(0); fRowGroup.initRow(&fRow0); fRowGroup.getRow(0, &fRow0); // set compare functors fRule.compileRules(fOrderByCond, fRowGroup); fRowGroup.initRow(&row1); fRowGroup.initRow(&row2); if (fDistinct) { fDistinctMap.reset(new DistinctMap_t(10, Hasher(this, getKeyLength()), Eq(this, getKeyLength()))); } }
skey_t CTimeSetMember::get_key() const { skey_t skey = 0; if(getKeyLength() == 4) { #ifdef PGSQL_ORM unpack4((char*)&skey, (char*)key); #else DWORD t; memcpy(&t, key, sizeof(DWORD)); skey = (skey_t)t; #endif } else { #ifdef PGSQL_ORM unpack8((char*)&skey, (char*)key); #else time_t t; memcpy(&t, key, sizeof(time_t)); skey = t; #endif } return skey; }
void CTimeSetMember::UpdateKeyVal(time_t new_key) { if(getKeyLength() == 4) { #ifdef PGSQL_ORM pack4((char*)key, (char*)&new_key); #else DWORD t = (DWORD)new_key; memcpy(key, &t, sizeof(DWORD)); #endif } else { #ifdef PGSQL_ORM pack8((char*)key, (char*)&new_key); #else memcpy(key, &new_key, sizeof(time_t)); #endif } }
void * getValAddr(Message * m) { return ((char*)getKeyAddr(m)) + getKeyLength(m); /* key address + key length. */ }
/** The client side function that 'does everything' @param request_type The type of request to be run. @param response_type The expected response type. Returns 1 if this remote state is returned, 0 otherwise. (TODO: Double check this documentation.) @param xid The (stateMachine) transaction id. Set to a random number when calling BEGIN. To prevent deadlock, it's best to choose a number unlikely to correspond to an active transaction. (A random number within 2^32 of the highest 64-bit integer will work.) @param reply_type When should the local call return? The choices are AWAIT_ARRIVAL, which returns after hearing back from the coordinator, AWAIT_COMMIT_POINT to wait until after the transaction commits/aborts, AWAIT_RESULT, which waits for the actual result from one of the replicas. @param key, key_size, value, value_size depend on the value of request_type. @return 1 on success, 0 on failure. */ static int _chtEval(DfaSet * dfaSet, unsigned char request_type, unsigned char response_type, state_machine_id * xid, clusterHashTable_t * ht, void * key, size_t * key_size, void * value, size_t * value_size) { /* Fill out a message payload. */ Message m; if(ht != NULL) { DEBUG("_chtEval(request=%d, response=%d, xid=%ld, ht=%d ", request_type, response_type, *xid, ht->id); } else { DEBUG("_chtEval(request=%d, response=%d, xid=%ld, ht=NULL ", request_type, response_type, *xid); } if(key == NULL) { DEBUG(")\n"); } else { DEBUG("key=%d)\n", *(int*)key); } * requestType(&m) = request_type; m.response_type = response_type; setKeyLength(&m, *key_size); setValLength(&m, *value_size); assert(checkPayload(&m)); if(key_size != 0) { memcpy(getKeyAddr(&m), key, *key_size); } if(value_size != 0) { memcpy(getValAddr(&m), value, *value_size); } if(ht != NULL) { memcpy(&(__header_ptr(&m)->hashTable), ht, sizeof(clusterHashTable_t)); } else { //memset(&(__header_ptr(&m)->hashTable), 0, sizeof(clusterHashTable_t)); } /* printf("%s <- %s\n", __header_ptr(&m)->initiator, dfaSet->networkSetup.localhost); */ /* Synchronously run the request */ request(dfaSet, response_type, "bc:0", *xid, &m); if(!checkPayload(&m)) { printf("_chtEval failed: Invalid response.\n"); assert(0); } /* Copy message contents back into caller's buffers, even if the request failed. (There may be app-specific information in the response...) */ if(ht != NULL) { memcpy(ht, &(__header_ptr(&m)->hashTable), sizeof(clusterHashTable_t)); } if (*key_size != 0) { /* printf("\n+%x<-%x+, length %d value=%s and %s\n", (unsigned int) value, (unsigned int)getValAddr(&m), getValLength(&m), value, getValAddr(&m)); */ memcpy(value, getValAddr(&m), getValLength(&m)); } if (*value_size != 0) { memcpy(key, getKeyAddr(&m), getKeyLength(&m)); } *value_size = getValLength(&m); *key_size = getKeyLength(&m); *xid = m.to_machine_id; DEBUG("+chtEval returning %d\n", m.type); // return m.type; return 1; }