Exemplo n.º 1
0
void Coordinates_test::
t_iterator()
{
    Coordinates c;
    QCOMPARE(c.begin(), c.end());
    // begin and end checked elsewhere
    c << 1.0 << 3.0;
    Coordinates::iterator i= c.begin();
    QCOMPARE(*i, 1.0);
    QCOMPARE(i[1], 3.0);
    *i= -1.0;
    QCOMPARE(*i, -1.0);
    i[1]= -3.0;
    QCOMPARE(i[1], -3.0);
    *i= 1.0;
    // operator-> is not applicable to double
    QCOMPARE(*i++, 1.0);
    QCOMPARE(*i, -3.0);
    *i= 3.0;
    QCOMPARE(*i--, 3.0);
    QCOMPARE(*i, 1.0);
    QCOMPARE(*(i+1), 3.0);
    QCOMPARE(*++i, 3.0);
    QCOMPARE(*(i-1), 1.0);
    QCOMPARE(*--i, 1.0);
    QVERIFY(i==c.begin());
    QVERIFY(i==c.constBegin());
    QVERIFY(i!=c.end());
    QVERIFY(i!=c.constEnd());
    QVERIFY(i<c.end());
    QVERIFY(i>=c.begin());
    QVERIFY(i+1<=c.end());
    QVERIFY(i+1>c.begin());
}//t_iterator
Exemplo n.º 2
0
Coordinates Coordinates::
operator+(const Coordinates &other) const
{
    Coordinates result(*this);
    std::copy(other.begin(), other.end(), std::back_inserter(result));
    return result;
}//operator+
Exemplo n.º 3
0
bool AllVersionsChunkIterator::setPosition(Coordinates const& pos)
{
    if (VersionID(pos[0]) != currVersion) {
        return false;
    }
    return inputIterator->setPosition(Coordinates(pos.begin()+1, pos.end()));
}
Exemplo n.º 4
0
 bool
 UnfoldBitmapChunkIter::setPosition(Coordinates const& pos)
 {
   // 'pos' will have N coordinates, according to the ArrayDesc returned
   // from inferSchema.  Set the position along the input chunks
   // according to the first N-1 coordinates.  The last coordinate is
   // the attribute index which must be set independently.
   Coordinates mapped(pos.begin(), pos.end()-1);
   AttributeID visitingAttr = *(pos.end()-1);
   if (visitingAttr < _nAttrs && 
       inputIterator->setPosition(mapped)) {
       _visitingAttribute = visitingAttr;
       return true;
   }
   _visitingAttribute = 0;
   return false;
 }
Exemplo n.º 5
0
  bool
  UnfoldChunkIter::setPosition(Coordinates const& pos)
  {
    // 'pos' will have N coordinates, according to the ArrayDesc returned
    // from inferSchema.  Set the position along the input chunks
    // according to the first N-1 coordinates.  The last coordinate is
    // the attribute index which must be set independently.
    Coordinates mapped(pos.begin(), pos.end()-1);
    bool success = true;
    for (std::vector<boost::shared_ptr<ConstChunkIterator> >::const_iterator citer =
	   _inputChunkIterators.begin();
	 (citer != _inputChunkIterators.end()) && success;
	 ++citer) {
      success = success && (*citer)->setPosition(mapped);
    }

    AttributeID visitingAttr = *(pos.end()-1);
    if (success && visitingAttr < _inputChunkIterators.size()) {
        _visitingAttribute = visitingAttr;
        return true;
    }
    _visitingAttribute = 0;
    return false;
  }
Exemplo n.º 6
0
bool AllVersionsArrayIterator::setPosition(Coordinates const& pos)
{
    boost::shared_ptr<Query> query(getQuery());
    currVersion = pos[0];
    chunkInitialized = false;
    if (currVersion < 1 || currVersion > array.versions.size()) {
        return hasCurrent = false;
    }
    if (!inputIterators[currVersion] )
    {
        shared_ptr<Array> inputVersion(DBArray::newDBArray(array.getVersionName(currVersion), query));
        inputIterators[currVersion]=inputVersion->getConstIterator(attr);
    }
    inputIterator = inputIterators[currVersion];
    return hasCurrent = inputIterator->setPosition(Coordinates(pos.begin()+1, pos.end()));

}
Exemplo n.º 7
0
  bool
  UnfoldArrayIter::setPosition(Coordinates const& pos)
  {
    // Set the position on all of the input iterators at once.
    // Slice-off the last value of the coordinates vector because
    // that is not a valid coordinate for the input chunks.
    Coordinates mapped(pos.begin(), pos.end()-1);
    bool success = true;
  
    for (std::vector<boost::shared_ptr<ConstArrayIterator> >::const_iterator citer =
	   _inputArrayIterators.begin();
	 (citer != _inputArrayIterators.end()) && success;
	 ++citer) {
      success = success && (*citer)->setPosition(mapped);
    }
    return success;
  }
    void CrossJoinArray::decomposeOutCoordinates(Coordinates const& out, Coordinates& left, Coordinates& hashKey, Coordinates& rightLeftover) const
    {
        assert(out.size() == desc.getDimensions().size());
        assert(left.size() == nLeftDims);
        assert(rightLeftover.size() == nRightDims-nJoinDims);
        assert(hashKey.size() == nJoinDims);

        left.assign(out.begin(), out.begin()+nLeftDims);
        rightLeftover.assign(out.begin()+nLeftDims, out.end());

        for (size_t i =0; i<nLeftDims; i++)
        {
            if(leftJoinDims[i]!=-1)
            {
                hashKey[leftJoinDims[i]] = out[i];
            }
        }
    }
Exemplo n.º 9
0
void Coordinates_test::
t_readwrite()
{
    Coordinates c;
    c.clear();
    QCOMPARE(c.count(), 0);
    c << 1.0 << 3.0;
    c.clear();
    QCOMPARE(c.count(), 0);
    c << 1.0 << 3.0;
    c.erase(c.begin(), c.end());
    QCOMPARE(c.count(), 0);
    c << 1.0 << 0.0;
    Coordinates::iterator i= c.erase(c.begin());
    QCOMPARE(*i, 0.0);
    i= c.insert(c.end(), 1.0);
    QCOMPARE(*i, 1.0);
    QCOMPARE(c.count(), 2);
    c.pop_back();
    QCOMPARE(c.count(), 1);   // 0
    QCOMPARE(c[0], 0.0);
    c.push_back(2.0);
    QCOMPARE(c.count(), 2);
    c.append(3.0);
    QCOMPARE(c.count(), 3);   // 0, 2, 3
    QCOMPARE(c[2], 3.0);
    c.insert(0, 4.0);
    QCOMPARE(c[0], 4.0);
    QCOMPARE(c[3], 3.0);
    c.insert(c.count(), 5.0);
    QCOMPARE(c.count(), 5);   // 4, 0, 2, 3, 5
    QCOMPARE(c[4], 5.0);
    c.move(4, 0);
    QCOMPARE(c.count(), 5);   // 5, 4, 0, 2, 3
    QCOMPARE(c[0], 5.0);
    c.pop_front();
    QCOMPARE(c.count(), 4);
    QCOMPARE(c[0], 4.0);
    c.prepend(6.0);
    QCOMPARE(c.count(), 5);   // 6, 4, 0, 2, 3
    QCOMPARE(c[0], 6.0);
    c.push_front(7.0);
    QCOMPARE(c.count(), 6);
    QCOMPARE(c[0], 7.0);
    c.removeAt(1);
    QCOMPARE(c.count(), 5);   // 7, 4, 0, 2, 3
    QCOMPARE(c[1], 4.0);
    c.removeFirst();
    QCOMPARE(c.count(), 4);   // 4, 0, 2, 3
    QCOMPARE(c[0], 4.0);
    c.removeLast();
    QCOMPARE(c.count(), 3);
    QCOMPARE(c.last(), 2.0);
    c.replace(2, 8.0);
    QCOMPARE(c.count(), 3);   // 4, 0, 8
    QCOMPARE(c[2], 8.0);
    c.swap(0, 2);
    QCOMPARE(c[2], 4.0);
    double d= c.takeAt(2);
    QCOMPARE(c.count(), 2);   // 8, 0
    QCOMPARE(d, 4.0);
    double d2= c.takeFirst();
    QCOMPARE(c.count(), 1);   // 0
    QCOMPARE(d2, 8.0);
    double d3= c.takeLast();
    QVERIFY(c.isEmpty()); \
    QCOMPARE(d3, 0.0);
}//t_readwrite
Exemplo n.º 10
0
 void addCoordinate(const Coordinates& coords){
     _coords.insert(_coords.end(), coords.begin(), coords.end());
 }
Exemplo n.º 11
0
 CoordinateSequence(std::uint64_t id, const Coordinates &coordinates) :
     id(id), coordinates(coordinates.begin(), coordinates.end()) {
 }