示例#1
0
void
BucketDistribution::getBucketMigrateCount(uint32_t numColumns, uint32_t numBucketBits, std::vector<uint32_t> &ret)
{
    getBucketCount(numColumns++, numBucketBits, ret);
    uint32_t cnt = getNumBuckets(numBucketBits) / numColumns;
    uint32_t rst = getNumBuckets(numBucketBits) % numColumns;
    for (uint32_t i = 0; i < numColumns - 1; ++i) {
        ret[i] -= cnt + (i < rst ? 1 : 0);
    }
}
示例#2
0
void
BucketDistribution::getBucketCount(uint32_t numColumns, uint32_t numBucketBits, std::vector<uint32_t> &ret)
{
    ret.resize(numColumns);
    uint32_t cnt = getNumBuckets(numBucketBits) / numColumns;
    uint32_t rst = getNumBuckets(numBucketBits) % numColumns;
    for (uint32_t i = 0; i < numColumns; ++i) {
        ret[i] = cnt + (i < rst ? 1 : 0);
    }
}
SchemeBitIndex FDREngineDescription::getSchemeBit(BucketIndex b,
                                                  PositionInBucket p) const {
    assert(p < getBucketWidth(b));
    SchemeBitIndex sbi = p * getNumBuckets() + b;
    assert(sbi < getSchemeWidth());
    return sbi;
}
示例#4
0
BucketDistribution::BucketDistribution(uint32_t numColumns, uint32_t numBucketBits) :
    _numColumns(0),
    _numBucketBits(numBucketBits),
    _bucketToColumn(),
    _lock()
{
    _bucketToColumn.resize(getNumBuckets());
    reset();
    setNumColumns(numColumns);
}
示例#5
0
uint32_t
BucketDistribution::getColumn(const document::BucketId &bucketId) const
{
    uint32_t ret = (uint32_t)(bucketId.getId() & (getNumBuckets(_numBucketBits) - 1));
    if (ret >= _bucketToColumn.size()) {
        LOG(error,
            "The bucket distribution map is not in sync with the number of bucket bits. "
            "This should never happen! Distribution is broken!!");
        return 0;
    }
    return _bucketToColumn[ret];
}
示例#6
0
void nitf::HashTable::foreach(HashIterator& fun, NITF_DATA* userData)
    throw(nitf::NITFException)
{
    int numBuckets = getNumBuckets();
    for (int i = 0; i < numBuckets; i++)
    {
        nitf::List l = getBucket(i);
        for (nitf::ListIterator iter = l.begin();
                iter != l.end(); ++iter)
        {
            nitf::Pair pair = nitf::Pair((nitf_Pair*)(*iter));
            fun(this, pair, userData);
        }
    }
}
示例#7
0
void
BucketDistribution::setNumBucketBits(uint32_t numBucketBits)
{
    uint32_t numColumns;
    {
        vespalib::LockGuard guard(_lock);
        if (numBucketBits == _numBucketBits) {
            return;
        }
        _numBucketBits = numBucketBits;
        _bucketToColumn.resize(getNumBuckets(numBucketBits));
        numColumns = _numColumns;
        reset();
    }
    setNumColumns(numColumns);
}
示例#8
0
void
BucketDistribution::addColumn()
{
    uint32_t newColumns = _numColumns + 1;
    std::vector<uint32_t> migrate;
    getBucketMigrateCount(_numColumns, _numBucketBits, migrate);
    uint32_t numBuckets = getNumBuckets(_numBucketBits);
    for (uint32_t i = 0; i < numBuckets; ++i) {
        uint32_t old = _bucketToColumn[i];
        if (migrate[old] > 0) {
            _bucketToColumn[i] = _numColumns; // move this bucket to the new column
            migrate[old]--;
        }
    }
    _numColumns = newColumns;
}
u32 FDREngineDescription::getDefaultFloodSuffixLength() const {
    // rounding up, so that scheme width 32 and 6 buckets is 6 not 5!
    // the +1 avoids pain due to various reach choices
    return ((getSchemeWidth() + getNumBuckets() - 1) / getNumBuckets()) + 1;
}
u32 FDREngineDescription::getBucketWidth(BucketIndex) const {
    u32 sw = getSchemeWidth();
    u32 nm = getNumBuckets();
    assert(sw % nm == 0);
    return sw/nm;
}