Beispiel #1
0
int ArrayData::compare(const ArrayData *v2, bool strict) const {
  ASSERT(v2);

  int count1 = size();
  int count2 = v2->size();
  if (count1 < count2) return -1;
  if (count1 > count2) return 1;
  if (count1 == 0) return 0;

  if (strict) {
    for (ArrayIter iter1(this), iter2(v2); iter1 && iter2; ++iter1, ++iter2) {
      Variant key1(iter1.first());
      Variant key2(iter2.first());
      if (!key1.same(key2)) return 1; // or -1

      Variant value1(iter1.second());
      Variant value2(iter2.second());
      if (!value1.same(value2)) return 1; // or -1
    }
  } else {
    for (ArrayIter iter(this); iter; ++iter) {
      Variant key(iter.first());
      if (!v2->exists(key)) return 1;

      Variant value1(iter.second());
      Variant value2(v2->get(key));
      if (value1.more(value2)) return 1;
      if (value1.less(value2)) return -1;
    }
  }

  return 0;
}
Beispiel #2
0
bool ArrayData::equal(const ArrayData *v2, bool strict) const {
    ASSERT(v2);

    int count1 = size();
    int count2 = v2->size();
    if (count1 != count2) return false;
    if (count1 == 0) return true;

    // prevent circular referenced objects/arrays or deep ones
    DECLARE_THREAD_INFO;
    RECURSION_INJECTION;

    if (strict) {
        for (ArrayIter iter1(this), iter2(v2); iter1 && iter2; ++iter1, ++iter2) {
            Variant key1(iter1.first());
            Variant key2(iter2.first());
            if (!key1.same(key2)) return false;

            Variant value1(iter1.second());
            Variant value2(iter2.second());
            if (!value1.same(value2)) return false;
        }
    } else {
        for (ArrayIter iter(this); iter; ++iter) {
            Variant key(iter.first());
            if (!v2->exists(key)) return false;

            Variant value1(iter.second());
            Variant value2(v2->get(key));
            if (!value1.equal(value2)) return false;
        }
    }

    return true;
}
	 TEST_F(CTestInterfaceBase, GetTestCase_07_dateNotExpire) {
	 	data_entry key1("04_07_key_01");
        data_entry value1("04_07_data_01");
        
        data_entry key2("04_07_key_02");
        data_entry value2("04_07_data_02");

        data_entry value3("04_07_data_03");

        data_entry* p;
        int ret = 0;
		//data1:area equals,key not equal
		DO_WITH_RETRY(client_handle.put(1, key1, value1, 0, 0), ret, TAIR_RETURN_SUCCESS);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);
		
		//data2:area not equas, key equal
		DO_WITH_RETRY(client_handle.put(2, key2, value2, 0, 0), ret, TAIR_RETURN_SUCCESS);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);

		DO_WITH_RETRY(client_handle.put(1, key2, value3, 3, 0), ret, TAIR_RETURN_SUCCESS);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);

		ret = client_handle.get(1, key2, p);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);
        ASSERT_EQ(true, compareDataValue(value3, *p));
        delete p;
		p = NULL;

		client_handle.remove(1, key1);
		client_handle.remove(2, key2);
		client_handle.remove(1, key2);

     }
Beispiel #4
0
// DELETE HELPER FUNCTION
void DeleteTest(index::Index *index, VarlenPool *pool, size_t scale_factor) {
  // Loop based on scale factor
  for (size_t scale_itr = 1; scale_itr <= scale_factor; scale_itr++) {
    // Delete a bunch of keys based on scale itr
    std::unique_ptr<storage::Tuple> key0(new storage::Tuple(key_schema, true));
    std::unique_ptr<storage::Tuple> key1(new storage::Tuple(key_schema, true));
    std::unique_ptr<storage::Tuple> key2(new storage::Tuple(key_schema, true));
    std::unique_ptr<storage::Tuple> key3(new storage::Tuple(key_schema, true));
    std::unique_ptr<storage::Tuple> key4(new storage::Tuple(key_schema, true));

    key0->SetValue(0, ValueFactory::GetIntegerValue(100 * scale_itr), pool);
    key0->SetValue(1, ValueFactory::GetStringValue("a"), pool);
    key1->SetValue(0, ValueFactory::GetIntegerValue(100 * scale_itr), pool);
    key1->SetValue(1, ValueFactory::GetStringValue("b"), pool);
    key2->SetValue(0, ValueFactory::GetIntegerValue(100 * scale_itr), pool);
    key2->SetValue(1, ValueFactory::GetStringValue("c"), pool);
    key3->SetValue(0, ValueFactory::GetIntegerValue(400 * scale_itr), pool);
    key3->SetValue(1, ValueFactory::GetStringValue("d"), pool);
    key4->SetValue(0, ValueFactory::GetIntegerValue(500 * scale_itr), pool);
    key4->SetValue(1, ValueFactory::GetStringValue("e"), pool);

    // DELETE
    index->DeleteEntry(key0.get(), item0);
    index->DeleteEntry(key1.get(), item1);
    //    index->DeleteEntry(key2.get(), item2);
    index->DeleteEntry(key3.get(), item1);
    index->DeleteEntry(key3.get(), item1);
    index->DeleteEntry(key3.get(), item1);
    index->DeleteEntry(key4.get(), item1);
    index->DeleteEntry(key4.get(), item1);
    index->DeleteEntry(key4.get(), item1);
    LOG_INFO("--------------- next round delete ---------------");
  }
}
Beispiel #5
0
int pianWHOA::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: key1(); break;
        case 1: key2(); break;
        case 2: key3(); break;
        case 3: key4(); break;
        case 4: key5(); break;
        case 5: key6(); break;
        case 6: key7(); break;
        case 7: key8(); break;
        case 8: key9(); break;
        case 9: key10(); break;
        case 10: key11(); break;
        case 11: key12(); break;
        case 12: key13(); break;
        case 13: key14(); break;
        case 14: key15(); break;
        case 15: key16(); break;
        case 16: key17(); break;
        case 17: key18(); break;
        case 18: tutor(); break;
        default: ;
        }
        _id -= 19;
    }
    return _id;
}
Beispiel #6
0
 void
 buildHashtable ()
   {
     typedef std::unordered_map<KEY, VAL, HashFunc> Hashtable;
     
     Hashtable tab;
     
     VAL o1;  KEY key1 (o1);
     VAL o2;  KEY key2 (o2);
     VAL o3;  KEY key3 (o3);
     
     tab[key1] = o1;                             // store copy into hashtable
     tab[key2] = o2;
     tab[key3] = o3;
     
     CHECK (!isSameObject (o1, tab[key1]));     // indeed a copy...
     CHECK (!isSameObject (o2, tab[key2]));
     CHECK (!isSameObject (o3, tab[key3]));
     
     CHECK (o1.getID() == tab[key1].getID());   // but "equal" by ID
     CHECK (o2.getID() == tab[key2].getID());
     CHECK (o3.getID() == tab[key3].getID());
     
     CHECK (o1.getID() != tab[key2].getID());
     CHECK (o1.getID() != tab[key3].getID());
     CHECK (o2.getID() != tab[key3].getID());
   }
Beispiel #7
0
    void CrwMap::extract0x080a(const CiffComponent& ciffComponent,
                               const CrwMapInfo* crwMapInfo,
                               Image& image,
                               ByteOrder byteOrder)
    {
        if (ciffComponent.typeId() != asciiString) {
            return extractBasic(ciffComponent, crwMapInfo, image, byteOrder);
        }

        // Make
        ExifKey key1("Exif.Image.Make");
        Value::AutoPtr value1 = Value::create(ciffComponent.typeId());
        uint32_t i = 0;
        for (;    i < ciffComponent.size()
               && ciffComponent.pData()[i] != '\0'; ++i) {
            // empty
        }
        value1->read(ciffComponent.pData(), ++i, byteOrder);
        image.exifData().add(key1, value1.get());

        // Model
        ExifKey key2("Exif.Image.Model");
        Value::AutoPtr value2 = Value::create(ciffComponent.typeId());
        uint32_t j = i;
        for (;    i < ciffComponent.size()
               && ciffComponent.pData()[i] != '\0'; ++i) {
            // empty
        }
        value2->read(ciffComponent.pData() + j, i - j + 1, byteOrder);
        image.exifData().add(key2, value2.get());
    } // CrwMap::extract0x080a
TYPED_TEST(CTestInterfaceItemBase,Item10_x_removeItems_05_dataExist)
{
	data_entry key1("Item10TestCase_05_key_01");
	data_entry key2("Item10TestCase_05_key_02");

	typename TestFixture::List value_1;
	typename TestFixture::List value_2;
	typename TestFixture::List value_3;

	try {
		for(uint32_t i=0;i < this->_data.size();++i){
			value_1.push_back(any_cast<TypeParam> (this->_data[i]));
		}

		for(uint32_t i=0;i < this->_data2.size();++i){
			value_2.push_back(any_cast<TypeParam> (this->_data2[i]));
		}
		for(uint32_t i=0;i < this->_data3.size();++i){
			value_3.push_back(any_cast<TypeParam> (this->_data3[i]));
		}
	}catch(bad_any_cast& e){
		cout << e.what() << endl;
		exit(-1);
	}


	int ret = CTestInterfaceBase::client_handle.add_items(1,key1,value_1,0,0);
	ASSERT_EQ(TAIR_RETURN_SUCCESS,ret);

	ret = CTestInterfaceBase::client_handle.add_items(2,key2,value_2,0,0);
	ASSERT_EQ(TAIR_RETURN_SUCCESS,ret);

	ret = CTestInterfaceBase::client_handle.add_items(1,key2,value_3,0,0);
	ASSERT_EQ(TAIR_RETURN_SUCCESS,ret);

	
	typename TestFixture::List result_1;
	typename TestFixture::List result_2;
	typename TestFixture::List result_3;

	ret = CTestInterfaceBase::client_handle.get_items(1,key1,0,tair_client_api::ALL_ITEMS,result_1);
	ASSERT_TRUE(value_1 == result_1);

	ret = CTestInterfaceBase::client_handle.get_items(2,key2,0,tair_client_api::ALL_ITEMS,result_2);
	ASSERT_TRUE(value_2 == result_2);

	ret = CTestInterfaceBase::client_handle.remove_items(1,key2,value_3.size() + 10,2);
	ASSERT_EQ(TAIR_RETURN_OUT_OF_RANGE, ret);
	
	ret = CTestInterfaceBase::client_handle.get_items(1,key2,0,tair_client_api::ALL_ITEMS,result_3);
	ASSERT_TRUE(result_3 == value_3);

	//clean
	ret = CTestInterfaceBase::client_handle.remove(1,key1);
	ASSERT_EQ(TAIR_RETURN_SUCCESS,ret);
	ret = CTestInterfaceBase::client_handle.remove(2,key2);
	ASSERT_EQ(TAIR_RETURN_SUCCESS,ret);
	ret = CTestInterfaceBase::client_handle.remove(1,key2);
	ASSERT_EQ(TAIR_RETURN_SUCCESS,ret);
}
	 TEST_F(CTestInterfaceBase, GetTestCase_08_dateExpired) {
	 	data_entry key1("04_08_key_01");
        data_entry value1("04_08_data_01");
        
        data_entry key2("04_08_key_02");
        data_entry value2("04_08_data_02");

        data_entry value3("04_08_data_03");

        data_entry* p;
        int ret = 0;
		//data1:area equals,key not equal
		DO_WITH_RETRY(client_handle.put(1, key1, value1, 0, 0), ret, TAIR_RETURN_SUCCESS);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);
		
		//data2:area not equas, key equal
		DO_WITH_RETRY(client_handle.put(2, key2, value2, 0, 0), ret, TAIR_RETURN_SUCCESS);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);

		DO_WITH_RETRY(client_handle.put(1, key2, value3, 1, 0), ret, TAIR_RETURN_SUCCESS);
		ASSERT_EQ(TAIR_RETURN_SUCCESS, ret);

        sleep(2);

		ret = client_handle.get(1, key2, p);
		ASSERT_EQ(TAIR_RETURN_DATA_EXPIRED, ret);

		client_handle.remove(1, key1);
		client_handle.remove(2, key2);
		client_handle.remove(1, key2);

     }
Beispiel #10
0
int main(int argc, char **argv)
{
  typedef my::MyServiceClient client_type;
  typedef tht::TSocket socket_type;
  typedef tht::TFramedTransport transp_type;
  typedef thp::TBinaryProtocol prot_type;
  typedef boost::shared_ptr<tht::TSocket> socket_ptr_type;
  typedef boost::shared_ptr<tht::TTransport> transp_ptr_type;
  typedef boost::shared_ptr<thp::TProtocol> prot_ptr_type;

  const int port_num = 9999;
  const std::string address("localhost");

  socket_ptr_type socket   (new socket_type(address, port_num));
  transp_ptr_type transport(new transp_type(socket) );
  prot_ptr_type   protocol (new prot_type(transport));

  client_type client(protocol);
  try
  {
    transport->open();

    my::MyValue res;

    std::string key1("key-1");
    std::string val1("value-1");

    client.myPut(res, key1, val1);
    std::cout
      << std::boolalpha
      << "response: "
      << '(' << res.exists << ',' << res.content << ')'
      << std::endl;

    client.myGet(res, key1);
    std::cout
      << std::boolalpha
      << "response: "
      << '(' << res.exists << ',' << res.content << ')'
      << std::endl;

  }
  catch(const thr::TException& e)
  {
    std::cerr << "error: " << e.what() << std::endl;
  }
  catch(const std::exception& e)
  {
    std::cerr << "error: " << e.what() << std::endl;
  }
  catch(...)
  {
    std::cerr << "error: " << "unknown" << std::endl;
  }

  transport->close();

  return 0;
}
Beispiel #11
0
bool yej_bituy (MorphInfoCR x, MorphInfoCR y, MorphInfo& tocaa) {
	Bituy b;  
	if (lexicon_bituyim.contains( key2(x,y).str, b ) ) 
		return b.match(x,y,tocaa);
	else if (lexicon_bituyim.contains( key1(x,y).str, b))  
		return b.match(x,y,tocaa);
	else return false;
}
    std::string Num_to_Words(Int toconvert){
        std::string toreturn(toconvert.sign() == -1 ? "negative " : "");

        toconvert = toconvert.magnitude();
        while(toconvert > 0){
            size_t i( toconvert.count_digits() );
        //key1 accesses words of order 10, like "thousand"
        //key2 accesses the single digits words, like "one"
            Int
                key1(Math::exponentiate(Int(k_ten), Int(i-1))),
                key2(toconvert / key1)
            ;

        switch(i){
            case 1: //One digit
                toreturn += NumberWordBank.at(key2);
                break;
            case 2: //Two digits
                if(toconvert >= 2*k_ten)
                    toreturn
                        += NumberWordBank.at(key2 * k_ten)
                        + (toconvert%k_ten > 0 ? "-" : "")
                    ;
                else if(toconvert >= k_ten){
                    toreturn += NumberWordBank.at(toconvert);
                    return toreturn;
                }
                break;
            case 3: //Three digits
                toreturn += NumberWordBank.at(key2) + ' ';
                toreturn += NumberWordBank.at(key1) + ' ';
                break;
            default:    //Four or more digits
                key2 = toconvert;
                key1 = 1;
                while(key2.count_digits() > 3){
                    key1 *= k_thousand;
                    key2 /= k_thousand;
                }

                toreturn += Num_to_Words(key2) + ' ';
                toreturn += NumberWordBank.at(key1) + ' ';
                break;
        }
        //Stop adding things once toconvert is 0
            if(key1*key2 == toconvert) break;
        //Inserting "and"
            if(
                (i == 3 && toconvert%100 > 0) ||
                (i >= 4 && toconvert%k_thousand < 100)
            ) toreturn += k_and;

            toconvert -= key1*key2;
        }
        while(toreturn.back() == ' ') toreturn.pop_back();

        return toreturn;
    }
Beispiel #13
0
  bool LRSPublicKey::VerifyKey(AsymmetricKey &key) const
  {
    if(key.IsPrivateKey() ^ !IsPrivateKey()) {
      return false;
    }

    QSharedPointer<AsymmetricKey> key0(GetPublicKey());
    QSharedPointer<AsymmetricKey> key1(key.GetPublicKey());
    return key0 == key1;
  }
	 TEST_F(CTestInterfaceBase, GetTestCase_06_emptyKey) {
	 	data_entry key;

        data_entry* p;
        int ret = 0;
		ret = client_handle.get(0, key, p);
		ASSERT_EQ(TAIR_RETURN_ITEMSIZE_ERROR, ret);

		data_entry key1("");
		ret = client_handle.get(0, key1, p);
		ASSERT_EQ(TAIR_RETURN_ITEMSIZE_ERROR, ret);
     }
Beispiel #15
0
void find_test() {
    {
        Type a(chr1);
        Type key1("TCGCGCCTGTCATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACGAGGTCAGGAGA");
        //std::cout << key1 << "\n";
        BOOST_CHECK( a.compare(60, key1.size(), key1) == 0);
    }
    {
        Type a(chr1);
        Type key1("T");
        BOOST_CHECK( a.compare(60, key1.size(), key1) == 0);
    }
    {
        Type a(chr1);
        Type key1("TCGCGCCTGTCATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACGAGGTCAGGAGA");
        BOOST_CHECK( a.find(key1, 0) == (size_t)60);
    }
    {
        Type a("ACGTACGTACGTACGTACGTACGTACGTACGC" "ATGTACGTACGTACGTACGTACGTACGTACGT");
        Type key1("CA");
        BOOST_CHECK( a.find(key1, 0) == (size_t)31);
    }
    {
        Type a("ACGTACGTACGTACGTACGTACGTACGTACGC" "ATGTACGTACGTACGTACGTACGTACGTACGT");
        Type key1("CAT");
        BOOST_CHECK( a.find(key1, 0) == (size_t)31);
    }
    {
        Type a("ACGTACGTACGTACGTACGTACGTACGTACCA" "TTGTACGTACGTACGTACGTACGTACGTACGT");
        Type key1("CAT");
        BOOST_CHECK( a.find(key1, 0) == (size_t)30);
    }
}
// Exercise the purgeByKeys and purge methods
static void test_explicit_purging(skiatest::Reporter* reporter,
                                  const sk_sp<SkSpecialImage>& image,
                                  const sk_sp<SkSpecialImage>& subset) {
    static const size_t kCacheSize = 1000000;
    SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize));

    SkIRect clip = SkIRect::MakeWH(100, 100);
    SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
    SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, subset->uniqueID(), image->subset());

    SkIPoint offset = SkIPoint::Make(3, 4);
    cache->set(key1, image.get(), offset);
    cache->set(key2, image.get(), offset);
    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->count());)
Beispiel #17
0
void rowTutor::playTutorSong(QList <char> song){
    if (arrayCount<song.size())
    {
        playNoteGUI(song[arrayCount]);
        arrayCount++;
        }
    else
    {
         QTimer::singleShot(1000, this, SLOT(key1()));
         QTimer::singleShot(1100, this, SLOT(key5()));
         QTimer::singleShot(1200, this, SLOT(key8()));
         QTimer::singleShot(1300, this, SLOT(key13()));

     }
}
Beispiel #18
0
TEST(ImageKeyTest, Difference) {
    srand(2000);
    // coverity[dont_call]
    int randomHashKey1 = rand() % 100;
    ImageCacheKey key1(randomHashKey1, 0, RenderScale(1.), std::string());
    U64 keyHash1 = key1.getHash();


    ///make a second ImageKey different to the first
    // coverity[dont_call]
    int randomHashKey2 = rand() % 1000  + 150;
    ImageCacheKey key2(randomHashKey2, 0, RenderScale(1.), std::string());
    U64 keyHash2 = key2.getHash();

    ASSERT_TRUE(keyHash1 != keyHash2);
}
Beispiel #19
0
int main(int argc,char** argv)
{
	GLDebugDrawer	gDebugDrawer;

	///testing the btHashMap	
	btHashMap<btHashKey<OurValue>,OurValue> map;
	
	OurValue value1(btVector3(2,3,4));
	btHashKey<OurValue> key1(value1.getUid());
	map.insert(key1,value1);


	OurValue value2(btVector3(5,6,7));
	btHashKey<OurValue> key2(value2.getUid());
	map.insert(key2,value2);
	

	{
		OurValue value3(btVector3(7,8,9));
		btHashKey<OurValue> key3(value3.getUid());
		map.insert(key3,value3);
	}


	map.remove(key2);

	const OurValue* ourPtr = map.find(key1);
	for (int i=0;i<map.size();i++)
	{
		OurValue* tmp = map.getAtIndex(i);
		//printf("tmp value=%f,%f,%f\n",tmp->m_position.getX(),tmp->m_position.getY(),tmp->m_position.getZ());
	}
	
	BasicDemo ccdDemo;
	ccdDemo.initPhysics();
	ccdDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);


#ifdef CHECK_MEMORY_LEAKS
	ccdDemo.exitPhysics();
#else
	return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&ccdDemo);
#endif
	
	//default glut doesn't return from mainloop
	return 0;
}
Beispiel #20
0
NATRON_NAMESPACE_USING


TEST(ImageKeyTest, Equality) {
    srand(2000);
    // coverity[dont_call]
    int randomHashKey1 = rand();
    ImageCacheKey key1(randomHashKey1, 0, RenderScale(1.), std::string());
    U64 keyHash1 = key1.getHash();


    ///make a second ImageKey equal to the first
    int randomHashKey2 = randomHashKey1;
    ImageCacheKey key2(randomHashKey2, 0, RenderScale(1.), std::string());
    U64 keyHash2 = key2.getHash();
    ASSERT_TRUE(keyHash1 == keyHash2);
}
Beispiel #21
0
TEST(IndexTests, DeleteTest) {
  auto pool = TestingHarness::GetInstance().GetTestingPool();
  std::vector<ItemPointer> locations;

  // INDEX
  std::unique_ptr<index::Index> index(BuildIndex());

  // Single threaded test
  size_t scale_factor = 1000;
  LaunchParallelTest(1, InsertTest, index.get(), pool, scale_factor);
  LaunchParallelTest(1, DeleteTest, index.get(), pool, scale_factor);

  // Checks
  std::unique_ptr<storage::Tuple> key0(new storage::Tuple(key_schema, true));
  std::unique_ptr<storage::Tuple> key1(new storage::Tuple(key_schema, true));
  std::unique_ptr<storage::Tuple> key2(new storage::Tuple(key_schema, true));

  key0->SetValue(0, ValueFactory::GetIntegerValue(100), pool);
  key0->SetValue(1, ValueFactory::GetStringValue("a"), pool);
  key1->SetValue(0, ValueFactory::GetIntegerValue(100), pool);
  key1->SetValue(1, ValueFactory::GetStringValue("b"), pool);
  key2->SetValue(0, ValueFactory::GetIntegerValue(100), pool);
  key2->SetValue(1, ValueFactory::GetStringValue("c"), pool);

  locations = index->ScanKey(key0.get());
  EXPECT_EQ(locations.size(), 0);

  locations = index->ScanKey(key1.get());
  if (index->HasUniqueKeys())
    EXPECT_EQ(locations.size(), 0);
  else
    EXPECT_EQ(locations.size(), 2);

  locations = index->ScanKey(key2.get());
  EXPECT_EQ(locations.size(), 1);
  EXPECT_EQ(locations[0].block, item1.block);

  locations = index->ScanAllKeys();
  if (index->HasUniqueKeys())
    EXPECT_EQ(locations.size(), scale_factor);
  else
    EXPECT_EQ(locations.size(), 3 * scale_factor);

  delete tuple_schema;
}
Beispiel #22
0
bool GrPath::isEqualTo(const SkPath& path, const GrStyle& style) const {
    // Since this is only called in debug we don't care about performance.
    int cnt0 = GrStyle::KeySize(fStyle, GrStyle::Apply::kPathEffectAndStrokeRec);
    int cnt1 = GrStyle::KeySize(style, GrStyle::Apply::kPathEffectAndStrokeRec);
    if (cnt0 < 0 || cnt1 < 0 || cnt0 != cnt1) {
        return false;
    }
    if (cnt0) {
        SkAutoTArray<uint32_t> key0(cnt0);
        SkAutoTArray<uint32_t> key1(cnt0);
        write_style_key(key0.get(), fStyle);
        write_style_key(key1.get(), style);
        if (0 != memcmp(key0.get(), key1.get(), cnt0)) {
            return false;
        }
    }
    return fSkPath == path;
}
Beispiel #23
0
void
MockReadonlyIndex::getValueAppend(llong id, valvec<byte>* key, DbContext*)
const {
	assert(id < (llong)m_ids.size());
	assert(id >= 0);
	if (m_fixedLen) {
		assert(m_keys.size() == 0);
		assert(0 == llong(m_keys.strpool.size() % m_fixedLen));
		assert(m_keys.strpool.size() == m_ids.size() * m_fixedLen);
		fstring key1(m_keys.strpool.data() + m_fixedLen * id, m_fixedLen);
		key->append(key1.udata(), key1.size());
	}
	else {
		assert(m_ids.size() == m_keys.size());
		fstring key1 = m_keys[id];
		key->append(key1.udata(), key1.size());
	}
}
Beispiel #24
0
TEST(ImageKeyTest, Equality) {
    srand(2000);
    // coverity[dont_call]
    int randomHashKey1 = rand();
    SequenceTime time1 = 0;
    ViewIdx view1(0);
    ImageKey key1(std::string(), randomHashKey1, time1, view1, false);
    U64 keyHash1 = key1.getHash();


    ///make a second ImageKey equal to the first
    int randomHashKey2 = randomHashKey1;
    SequenceTime time2 = time1;
    ViewIdx view2(view1);
    ImageKey key2(std::string(), randomHashKey2, time2, view2, false);
    U64 keyHash2 = key2.getHash();
    ASSERT_TRUE(keyHash1 == keyHash2);
}
Beispiel #25
0
TEST(IndexTests, MyMultiThreadedTest) {
  auto pool = TestingHarness::GetInstance().GetTestingPool();
  std::vector<ItemPointer> locations;

  // INDEX
  std::unique_ptr<index::Index> index(BuildIndex());

  // Parallel Test
  size_t num_threads = 15;
  size_t scale_factor = 30;
  LaunchParallelTest(num_threads, InsertTest, index.get(), pool, scale_factor);
  LaunchParallelTest(num_threads, DeleteTest, index.get(), pool, scale_factor);

  locations = index->ScanAllKeys();
  if (index->HasUniqueKeys())
    EXPECT_EQ(locations.size(), scale_factor);
  else
    EXPECT_EQ(locations.size(), 3 * num_threads * scale_factor);

  std::unique_ptr<storage::Tuple> key1(new storage::Tuple(key_schema, true));
  std::unique_ptr<storage::Tuple> key2(new storage::Tuple(key_schema, true));

  key1->SetValue(0, ValueFactory::GetIntegerValue(100), pool);
  key1->SetValue(1, ValueFactory::GetStringValue("b"), pool);
  key2->SetValue(0, ValueFactory::GetIntegerValue(100), pool);
  key2->SetValue(1, ValueFactory::GetStringValue("c"), pool);

  locations = index->ScanKey(key1.get());
  if (index->HasUniqueKeys()) {
    EXPECT_EQ(locations.size(), 0);
  } else {
    EXPECT_EQ(locations.size(), 2 * num_threads);
  }

  locations = index->ScanKey(key2.get());
  if (index->HasUniqueKeys()) {
    EXPECT_EQ(locations.size(), num_threads);
  } else {
    EXPECT_EQ(locations.size(), num_threads);
  }

  delete tuple_schema;
}
Beispiel #26
0
    void CrwMap::extract0x1810(const CiffComponent& ciffComponent,
                               const CrwMapInfo* crwMapInfo,
                               Image& image,
                               ByteOrder byteOrder)
    {
        if (ciffComponent.typeId() != unsignedLong || ciffComponent.size() < 28) {
            return extractBasic(ciffComponent, crwMapInfo, image, byteOrder);
        }

        ExifKey key1("Exif.Photo.PixelXDimension");
        ULongValue value1;
        value1.read(ciffComponent.pData(), 4, byteOrder);
        image.exifData().add(key1, &value1);

        ExifKey key2("Exif.Photo.PixelYDimension");
        ULongValue value2;
        value2.read(ciffComponent.pData() + 4, 4, byteOrder);
        image.exifData().add(key2, &value2);

    } // CrwMap::extract0x1810
Beispiel #27
0
// DELETE HELPER FUNCTION
void DeleteTest2(index::Index *index, VarlenPool *pool, size_t scale_factor) {
  // Loop based on scale factor
  for (size_t scale_itr = 1; scale_itr <= scale_factor; scale_itr++) {
    // Delete a bunch of keys based on scale itr
    std::unique_ptr<storage::Tuple> key0(new storage::Tuple(key_schema, true));
    std::unique_ptr<storage::Tuple> key1(new storage::Tuple(key_schema, true));

    key0->SetValue(0, ValueFactory::GetIntegerValue(100 * scale_itr), pool);
    key0->SetValue(1, ValueFactory::GetStringValue("a"), pool);
    key1->SetValue(0, ValueFactory::GetIntegerValue(100 * scale_itr), pool);
    key1->SetValue(1, ValueFactory::GetStringValue("b"), pool);

    // DELETE
    index->InsertEntry(key1.get(), item0);
    index->InsertEntry(key1.get(), item1);
    index->DeleteEntry(key1.get(), item0);
    index->DeleteEntry(key1.get(), item1);
    index->DeleteEntry(key1.get(), item1);
  }
}
Beispiel #28
0
int rowTutor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: playSong(); break;
        case 1: stopSong(); break;
        case 2: playTutorSong((*reinterpret_cast< QList<char>(*)>(_a[1]))); break;
        case 3: playNoteGUI((*reinterpret_cast< char(*)>(_a[1]))); break;
        case 4: noteCDown(); break;
        case 5: noteDDown(); break;
        case 6: noteEDown(); break;
        case 7: noteFDown(); break;
        case 8: noteGDown(); break;
        case 9: noteHiCDown(); break;
        case 10: key1(); break;
        case 11: key2(); break;
        case 12: key3(); break;
        case 13: key4(); break;
        case 14: key5(); break;
        case 15: key6(); break;
        case 16: key7(); break;
        case 17: key8(); break;
        case 18: key9(); break;
        case 19: key10(); break;
        case 20: key11(); break;
        case 21: key12(); break;
        case 22: key13(); break;
        case 23: key14(); break;
        case 24: key15(); break;
        case 25: key16(); break;
        case 26: key17(); break;
        case 27: key18(); break;
        default: ;
        }
        _id -= 28;
    }
    return _id;
}
// Ensure the cache can return a cached image
static void test_find_existing(skiatest::Reporter* reporter,
                               const sk_sp<SkSpecialImage>& image,
                               const sk_sp<SkSpecialImage>& subset) {
    static const size_t kCacheSize = 1000000;
    SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize));

    SkIRect clip = SkIRect::MakeWH(100, 100);
    SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset());
    SkImageFilter::Cache::Key key2(0, SkMatrix::I(), clip, subset->uniqueID(), subset->subset());

    SkIPoint offset = SkIPoint::Make(3, 4);
    cache->set(key1, image.get(), offset);

    SkIPoint foundOffset;

    SkSpecialImage* foundImage = cache->get(key1, &foundOffset);
    REPORTER_ASSERT(reporter, foundImage);
    REPORTER_ASSERT(reporter, offset == foundOffset);

    REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
}
Beispiel #30
0
wxString wxJoystick::GetProductName() const
{
    wxString str;
#ifndef __WINE__
    JOYCAPS joyCaps;
    if (joyGetDevCaps(m_joystick, &joyCaps, sizeof(joyCaps)) != JOYERR_NOERROR)
        return wxEmptyString;

    wxRegKey key1(wxString::Format(wxT("HKEY_LOCAL_MACHINE\\%s\\%s\\%s"),
                   REGSTR_PATH_JOYCONFIG, joyCaps.szRegKey, REGSTR_KEY_JOYCURR));

    key1.QueryValue(wxString::Format(wxT("Joystick%d%s"),
                                     m_joystick + 1, REGSTR_VAL_JOYOEMNAME),
                    str);

    wxRegKey key2(wxString::Format(wxT("HKEY_LOCAL_MACHINE\\%s\\%s"),
                                        REGSTR_PATH_JOYOEM, str.c_str()));
    key2.QueryValue(REGSTR_VAL_JOYOEMNAME, str);
#endif
    return str;
}