Operator::GetNextResultT BitEntropyPrinter::getNext(unsigned short threadid) { Page* in; Operator::ResultCode rc; unsigned int tupoffset; Page* out = output[threadid]; out->clear(); // Populate output. // populateOutputPage(out, schema, threadid); // Do first read. // Operator::GetNextResultT result = nextOp->getNext(threadid); rc = result.first; in = result.second; tupoffset = 0; while (rc != Error) { void* tuple; dbgassert(rc != Error); dbgassert(in != NULL); dbgassert(tupoffset >= 0); dbgassert(tupoffset <= (buffsize / nextOp->getOutSchema().getTupleSize()) + 1); while ( (tuple = in->getTupleOffset(tupoffset++)) ) { // Calculate entropy. // CtLong val = *(CtLong*)(nextOp->getOutSchema().calcOffset(tuple, fieldno)); addStatsToPage(out, schema, val); } // If input source depleted, remove state information and return. // if (rc == Finished) { return make_pair(Finished, out); } // Read more input. // Operator::GetNextResultT result = nextOp->getNext(threadid); rc = result.first; in = result.second; tupoffset = 0; } state[threadid] = State(NullPage, Error, 0); return make_pair(Error, NullPage); // Reached on Error }
Operator::GetNextResultT IntGeneratorOp::getNext(unsigned short threadid) { dbgassert(output.at(threadid) != NULL); Page* out = output[threadid]; out->clear(); while (out->canStoreTuple()) { void* tuple = produceOne(threadid); if (tuple == NULL) return make_pair(Finished, out); void* target = out->allocateTuple(); dbgassert(target != NULL); schema.copyTuple(target, tuple); } return make_pair(Ready, out); }