TableStreamerContext* ElasticContext::cloneForTruncatedTable(PersistentTableSurgeon &surgeon) { if ( ! m_indexActive) { return NULL; } ElasticContext *cloned = new ElasticContext(surgeon.getTable(), surgeon, getPartitionId(), getSerializer(), m_predicateStrings, m_nTuplesPerCall); cloned->handleActivation(TABLE_STREAM_ELASTIC_INDEX); TupleOutputStreamProcessor dummyProcessor; std::vector<int> dummyPosition; while (true) { int64_t retCode = cloned->handleStreamMore(dummyProcessor, dummyPosition); if (retCode == 0) { break; } else if (retCode == TABLE_STREAM_SERIALIZATION_ERROR) { break; } else if (retCode == 1) { continue; } else { char errMsg[1024]; snprintf(errMsg, 1024, "Received an unrecognized return value %jd from handleStreamMore()", (intmax_t)retCode); LogManager::getThreadLogger(LOGGERID_HOST)->log(LOGLEVEL_ERROR, errMsg); break; } } return cloned; }
TableStreamerContext* ElasticContext::cloneForTruncatedTable(PersistentTableSurgeon &surgeon) { if ( ! m_indexActive) { return NULL; } ElasticContext *cloned = new ElasticContext(surgeon.getTable(), surgeon, getPartitionId(), getSerializer(), m_predicateStrings, m_nTuplesPerCall); cloned->handleActivation(TABLE_STREAM_ELASTIC_INDEX); return cloned; }
/* * Generate the next recovery message. Eventually returns a message containing the message type * RECOVERY_MSG_TYPE_COMPLETE indicating that all tuple data and updates to shipped data * have been sent. */ bool RecoveryContext::nextMessage(ReferenceSerializeOutput *out) { if (m_recoveryPhase == RECOVERY_MSG_TYPE_COMPLETE) { return false; } // We need to initialize the iterator over the table the first // time we call here. The implementation in Java guarantees that // once we start generating these recovery messages that no // additional transactions will change the table state (and leave // us with an inconsistent iterator). if (m_firstMessage) { m_iterator = getTable().iterator(); m_firstMessage = false; } if (!m_iterator.hasNext()) { m_recoveryPhase = RECOVERY_MSG_TYPE_COMPLETE; out->writeByte(static_cast<int8_t>(RECOVERY_MSG_TYPE_COMPLETE)); out->writeInt(m_tableId); // out->writeTextString(m_table->m_Tuple); // last message gets the export stream counter // long seqNo = 0; size_t offset = 0; // m_table->getExportStreamSequenceNo(seqNo, offset); // out->writeLong(seqNo); // out->writeLong((long) offset); //No tuple count added to message because completion message is only used in Java return false; } //Use allocated tuple count to size stuff at the other end uint32_t allocatedTupleCount = static_cast<uint32_t>(getTable().allocatedTupleCount()); RecoveryProtoMsgBuilder message( m_recoveryPhase, m_tableId, allocatedTupleCount, out, &getSerializer(), getTable().schema()); TableTuple tuple(getTable().schema()); while (message.canAddMoreTuples() && m_iterator.next(tuple)) { message.addTuple(tuple); } message.finalize(); return true; }