コード例 #1
0
ExecStreamResult ExternalSortExecStreamImpl::execute(
    ExecStreamQuantum const &quantum)
{
    for (;;) {
        if (!resultsReady) {
            if (pInAccessor->getState() != EXECBUF_EOS) {
                ExecStreamResult rc = precheckConduitBuffers();
                if (rc == EXECRC_BUF_UNDERFLOW) {
                    rc = handleUnderflow();
                }
                if (rc != EXECRC_YIELD) {
                    return rc;
                }
                if (nParallel > 1) {
                    // FIXME
                    computeFirstResultParallel();
                } else {
                    rc = computeFirstResult();
                    if (rc != EXECRC_YIELD) {
                        return rc;
                    }
                }
            } else {
                ExternalSortRunLoader &runLoader = *(runLoaders[0]);
                if (runLoader.isStarted()) {
                    sortRun(runLoader);
                    if (storedRuns.size() || storeFinalRun) {
                        // store last run
                        storeRun(runLoader);
                    }
                }
            }
            mergeFirstResult();

            // close the producers now that we've read all input
            if (earlyClose) {
                ExecStreamGraphImpl &graphImpl =
                    dynamic_cast<ExecStreamGraphImpl&>(getGraph());
                graphImpl.closeProducers(getStreamId());
            }

            resultsReady = true;
        }

        ExecStreamResult rc2 = pOutputWriter->fetch(*pOutAccessor);
        if (rc2 == EXECRC_EOS) {
            if (sortInfo.partitionKeyCount > 0
                && pInAccessor->getState() != EXECBUF_EOS)
            {
                // results have already been produced. Continue loading rows
                // for the next "partition".
                reallocateResources();
                continue;
            }
            pOutAccessor->markEOS();
        }
        return rc2;
    }
}
コード例 #2
0
void* manageSocketConnection(void* param) {
	Socket* socket = (Socket*) param;
	Boolean connected = TRUE;
	log_info(umclog, "UMC: Gestor de conexiones.");
//while (TRUE) {
	log_info(umclog, "UMC: Esperando el request...");
	SocketBuffer* sb = socketReceive(socket);
	log_info(umclog, "UMC: ...Entro el request.");
	if (sb != NULL) {
		Char id = getStreamId((Stream) sb->data);
		StrKerUmc* sku = NULL;
		StrCpuUmc* scu = NULL;
		StrUmcCpu * suc = NULL;
		StrUmcKer * suk = NULL;
		espacioAsignado aux;
		int thread_socketaux;
		switch (id) {
		case KERNEL_ID:
			//sku = unserializeKerUmc((Stream) sb->data);
			//umcThread();

			pthread_mutex_lock(mutexThreadSockets);
			suk = newStrUmcKer(UMC_ID, HANDSHAKE, "hola", thread_socket, 0, 0);
			newUmcThread();
			//(Char id, Char action, Byte* data, Int32U size, Int32U pid, Int32U cantPage)
			sleep(2);
			pthread_mutex_unlock(mutexThreadSockets);
			sb = serializeUmcKer(suk);
			socketSend(socket, sb);

			break;
		case CPU_ID:
			pthread_mutex_lock(mutexThreadSockets);
			//(Char id, Char action, espacioAsignado pageComienzo, Int32U offset, Int32U dataLen, Byte* data, Int32U pid)
			suc = newStrUmcCpu(UMC_ID, HANDSHAKE, aux, 0, thread_socket, "hola",
					0);
			newUmcThread();
			sleep(2);
			pthread_mutex_unlock(mutexThreadSockets);
			sb = serializeUmcCpu(suc);
			socketSend(socket, sb);

			break;
		default:
			connected = FALSE; //todo loggear algun error.
			break;
		}
	} else {
		log_error(umclog,
				"UMC: Gestor de conexiones: No pudo recibir request, desconectando al cliente.");
		connected = FALSE;
		//	}

	}
	return NULL;
}
コード例 #3
0
ファイル: QtsPesPacket.cpp プロジェクト: qtlmovie/qtlmovie
bool QtsPesPacket::isMpeg2Video() const
{
    // Must have a video stream_id and payload must start with 00 00 01
    if (!qtsIsVideoPesStreamId(getStreamId())) {
        return false;
    }
    else {
        const quint8* pl = payload();
        const int size = payloadSize();
        return size >= 3 && pl[0] == 0x00 && pl[1] == 0x00 && pl[2] == 0x01;
    }
}
コード例 #4
0
ファイル: QtsPesPacket.cpp プロジェクト: qtlmovie/qtlmovie
bool QtsPesPacket::isAvc() const
{
    // Must have a video stream_id and payload must start with 00 00 00 [00...] 01
    if (!qtsIsVideoPesStreamId(getStreamId())) {
        return false;
    }
    else {
        const quint8* pl = payload();
        int size = payloadSize();
        while(size > 0 && *pl == 0x00) {
            ++pl;
            --size;
        }
        return size > 0 && *pl == 0x01 && pl > payload() + 2;
    }
}
コード例 #5
0
OsStatus MpRtpInputConnection::setFlowGraph(MpFlowGraphBase* pFlowGraph)
{
   OsStatus stat = MpResource::setFlowGraph(pFlowGraph);

   // If the parent's call was successful, then call
   // setFlowGraph on any child resources we have.
   if(stat == OS_SUCCESS)
   {
      if (pFlowGraph != NULL)
      {
         mpRtpDispatcher->setNotificationDispatcher(pFlowGraph->getNotificationDispatcher());
         if(mpFromNet)
         {
             mpFromNet->setFlowGraph(pFlowGraph);
         }
#ifdef INCLUDE_RTCP /* [ */
      // Get the RTCP Connection object for this flowgraph connection
         mpiRTCPConnection = pFlowGraph->getRTCPConnectionPtr(getConnectionId(), 'A', getStreamId());
         OsSysLog::add(FAC_MP, PRI_DEBUG, " MpRtpInConn::setFlowGraph(%p) CID=%d, TC=%p", pFlowGraph, getConnectionId(), mpiRTCPConnection);

         // Let's use the Connection interface to acquire the constituent interfaces
         // required for dispatching RTP and RTCP packets received from the network as
         // well as the statistics interface tabulating RTP packets going to the network.
         INetDispatch         *piRTCPDispatch = NULL;
         IRTPDispatch         *piRTPDispatch = NULL;
         ISetSenderStatistics *piRTPAccumulator = NULL;

         if(mpiRTCPConnection)
         {
             mpiRTCPConnection->GetDispatchInterfaces(&piRTCPDispatch, &piRTPDispatch, &piRTPAccumulator);
         }
         // The MprFromNet object needs the RTP and RTCP Dispatch interfaces of the
         // associated RTCP connection so that RTP and RTCP packets may be forwarded
         // to the correct location.
         mpFromNet->setDispatchers(piRTPDispatch, piRTCPDispatch);

#endif /* INCLUDE_RTCP ] */
      }
      else
      {
         mpRtpDispatcher->setNotificationDispatcher(NULL);
      }
   }

   return stat;
}
ExecStreamResult SegBufferWriterExecStream::execute(ExecStreamQuantum const &)
{
    if (nOutputsWritten == outAccessors.size()) {
        for (uint i = 0; i < outAccessors.size(); i++) {
            outAccessors[i]->markEOS();
        }
        return EXECRC_EOS;
    }

    // Buffer the input
    if (firstBufferPageId == NULL_PAGE_ID) {
        if (!pSegBufferWriter) {
            pSegBufferWriter =
                SegBufferWriter::newSegBufferWriter(
                    pInAccessor,
                    bufferSegmentAccessor,
                    true);
        }
        ExecStreamResult rc = pSegBufferWriter->write();
        if (rc != EXECRC_EOS) {
            return rc;
        }
        // Close the upstream producers
        ExecStreamGraphImpl &graphImpl =
            dynamic_cast<ExecStreamGraphImpl&>(getGraph());
        graphImpl.closeProducers(getStreamId());
        firstBufferPageId = pSegBufferWriter->getFirstPageId();
    }

    // Once the input has been buffered, then pass along the first buffer
    // pageId to only those consumers that have explicitly requested data
    bool newOutput = false;
    for (uint i = 0; i < outAccessors.size(); i++) {
        switch (outAccessors[i]->getState()) {
        case EXECBUF_NONEMPTY:
        case EXECBUF_OVERFLOW:
        case EXECBUF_EMPTY:
        case EXECBUF_EOS:
            break;

        case EXECBUF_UNDERFLOW:
            // Underflow means the consumer has explicitly requested data
            {
                assert(!outputWritten[i]);
                TupleAccessor *outputTupleAccessor =
                    &outAccessors[i]->getScratchTupleAccessor();
                outputTupleAccessor->marshal(
                    outputTuple,
                    outputTupleBuffer.get());
                outAccessors[i]->provideBufferForConsumption(
                    outputTupleBuffer.get(),
                    outputTupleBuffer.get() + outputBufSize);
                outputWritten[i] = true;
                nOutputsWritten++;
                newOutput = true;
                break;
            }

        default:
            permAssert(false);
        }
    }

    // Verify that at least one output stream was written
    assert(newOutput);
    return EXECRC_BUF_OVERFLOW;
}