Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
 ISetImpl::ISetImpl(const std::string& instanceName, spi::ClientContext *clientContext)
 : ProxyImpl("hz:impl:setService", instanceName, clientContext) {
     serialization::pimpl::Data keyData = context->getSerializationService().toData<std::string>(&instanceName);
     partitionId = getPartitionId(keyData);
 }
Exemplo n.º 4
0
int createPartitionsByMovingPos(int type, int maxThreshhold) {

    UINT32 i, j, k;
    UINT32 partitionPresent = INT_MAX, partitionLast;
    UINT32 partitionStart, partitionEnd, firstVictimLoc;
    BOOL flag;
    UINT32 presentVictim;
    UINT32 *currPartitionPtr = (UINT32*) MALLOC((numSplits + 1) * sizeof (int));
    ;

    UINT32 partitionId;
    UINT32 * count ;
    if(type == TYPE_SORT){
    count= (UINT32*) MALLOC(numSplits * sizeof (UINT32));
    }
    else{
      count =  partitionBeginnings_sorting;
    }
    memset(count, 0, numSplits * sizeof (int));


    for (i = 0; i < arrayElemCount; i++) {
        partitionId = getPartitionId(type, array + arrayElemSize * i);
        count[partitionId]++;
    }
    
    if (type == TYPE_HASH){
        int currValAtIndex = partitionBeginnings_sorting[0];
        int lastCurrVal;
        partitionBeginnings_sorting[0] = 0;
        for(i=1; i<=numSplits; i++){
            lastCurrVal = currValAtIndex;
            currValAtIndex = partitionBeginnings_sorting[i];
            partitionBeginnings_sorting[i] = partitionBeginnings_sorting[i-1] + lastCurrVal;
        }
        partitionBeginnings_sorting[numSplits] = arrayElemCount;
        
        goto partitioning; //Since we shouldn't go through coalescing stage.
    }
    /*Coalesce empty partitions / partitions less than threshold.
      Each split i corresponds to pivot (i-1) and pivot (i) except. 
     * Example split 2 corresponds to pivot 1 and pivot 2. 
     * Hence, when we coalesce array split i with i+1, pivot i
     * should be removed. Note: We do this run 1 less times than numSplits 
     * as last split's count is immaterial __|__|__|__|__ */
    UINT32 runningCount = 0,
            windowCount;
    UINT32 newNumPivots = 0, newNumSplits = 1;
    partitionBeginnings_sorting[0] = 0;
    for (i = 0; i < numSplits - 1; i++) {
        runningCount += count[i];
        windowCount = count[i];
        while ((i < (numSplits - 1)) && (windowCount < maxThreshhold)) {
            i++;
            runningCount += count[i];
            windowCount += count[i];
        }
        if (i != (numSplits - 1)) {
            memcpy(pivots + (newNumPivots * arrayElemSize),
                    pivots + (arrayElemSize * i),
                    arrayElemSize);
            newNumPivots++;
            partitionBeginnings_sorting[newNumSplits++] = runningCount;

        }


    }
    partitionBeginnings_sorting[newNumSplits] = arrayElemCount;
    numPivots = newNumPivots;
    numSplits = newNumSplits;
    printf("Partition Counting Over [Partitions:%d]\n", numSplits);

#if 0 /*Can be used for debuggin later if required*/
    for (i = 0; i < numPivots; i++) {
        printf("Pivots:%d\n", *(int*) (pivots + (sizeof (int)*i)));
    }
#endif
partitioning:
    maxPartitionSize = 0;
    for (i = 0; i < numSplits; i++) {
        if (partitionBeginnings_sorting[i + 1] - partitionBeginnings_sorting[i] > maxPartitionSize) {
            maxPartitionSize = partitionBeginnings_sorting[i + 1] - partitionBeginnings_sorting[i];
        }
        printf("partitions[%d]:%d\n", i, partitionBeginnings_sorting[i]);
    }
    printf("maxPartitionSize is %d\n", maxPartitionSize);

    partitionBeginnings_sorting[numSplits] = arrayElemCount;
    

    memcpy(currPartitionPtr, partitionBeginnings_sorting, (numSplits + 1) * sizeof (int));

    UINT32 temp;
    for (i = 0; i < numSplits; i++) {
        for (j = currPartitionPtr[i]; j < partitionBeginnings_sorting[i + 1]; j++) {
            partitionPresent = getPartitionId(type, array + arrayElemSize * pos[j]);

            if (j >= partitionBeginnings_sorting[partitionPresent] && partitionPresent < partitionBeginnings_sorting[partitionPresent + 1]) {
                currPartitionPtr[i]++;
                continue;
            }

            firstVictimLoc = j;

            presentVictim = j;
            flag = 1;
            while (flag) {
                partitionStart = currPartitionPtr[partitionPresent];
                partitionEnd = partitionBeginnings_sorting[partitionPresent + 1];
                partitionLast = partitionPresent;
                for (k = partitionStart; k < partitionEnd; k++) {
                    partitionPresent = getPartitionId(type, array + arrayElemSize * pos[k]);
                    if (k >= partitionBeginnings_sorting[partitionPresent] && k < partitionBeginnings_sorting[partitionPresent + 1])
                        continue;
                    if (k == firstVictimLoc) {
                        flag = 0;
                    }
                    //swapTuples(presentVictim, array + (arrayElemSize * k));
                    temp = presentVictim;
                    presentVictim = pos[k];
                    pos[k] = temp;

                    INC_WRITES;
                    currPartitionPtr[partitionLast] = k;
                    break;
                }
            }
        }
    }
    printf("Partitioning Over\n");

    //FREE(presentVictim);
    FREE(currPartitionPtr);
    if(type == TYPE_SORT){
    FREE(count);
    }

    return (EXIT_SUCCESS);
}
Exemplo n.º 5
0
 ISemaphore::ISemaphore(const std::string &name, spi::ClientContext *context)
 : proxy::ProxyImpl("hz:impl:semaphoreService", name, context) {
     serialization::pimpl::Data keyData = context->getSerializationService().toData<std::string>(&name);
     partitionId = getPartitionId(keyData);
 }
Exemplo n.º 6
0
 ITopicImpl::ITopicImpl(const std::string &instanceName, spi::ClientContext *context)
         : proxy::ProxyImpl("hz:impl:topicService", instanceName, context) {
     partitionId = getPartitionId(toData(instanceName));
 }