当前位置: 首页>>代码示例>>C++>>正文


C++ DataArray::size方法代码示例

本文整理汇总了C++中DataArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ DataArray::size方法的具体用法?C++ DataArray::size怎么用?C++ DataArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataArray的用法示例。


在下文中一共展示了DataArray::size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SAdd

    int MMKVImpl::SAdd(DBID db, const Data& key, const DataArray& elements)
    {
        if (m_readonly)
        {
            return ERR_PERMISSION_DENIED;
        }
        int err = 0;

        RWLockGuard<MemorySegmentManager, WRITE_LOCK> keylock_guard(m_segment);
        EnsureWritableValueSpace();
        ObjectAllocator allocator = m_segment.MSpaceAllocator<Object>();
        StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, true, err)(std::less<Object>(), allocator);
        if (0 != err)
        {
            return err;
        }
        int inserted = 0;
        for (size_t i = 0; i < elements.size(); i++)
        {
            std::pair<StringSet::iterator, bool> ret = set->insert(Object(elements[i], true));
            if (ret.second)
            {
                m_segment.AssignObjectValue(*(ret.first), elements[i], true);
                inserted++;
            }
        }
        return inserted;
    }
开发者ID:shitfSign,项目名称:mmkv,代码行数:28,代码来源:t_set.cpp

示例2: Stats

 void PerconaFTEngine::Stats(Context& ctx, std::string& str)
 {
     str.append("perconaft_version:").append(stringfromll(DB_VERSION_MAJOR)).append(".").append(stringfromll(DB_VERSION_MINOR)).append(".").append(
             stringfromll(DB_VERSION_PATCH)).append("\r\n");
     DataArray nss;
     ListNameSpaces(ctx, nss);
     PerconaFTLocalContext& local_ctx = g_local_ctx.GetValue();
     for (size_t i = 0; i < nss.size(); i++)
     {
         DB* db = GetFTDB(ctx, nss[i], false);
         if (NULL == db)
             continue;
         str.append("\r\nDB[").append(nss[i].AsString()).append("] Stats:\r\n");
         DB_BTREE_STAT64 st;
         memset(&st, 0, sizeof(st));
         db->stat64(db, local_ctx.transc.Peek(), &st);
         str.append("bt_nkeys:").append(stringfromll(st.bt_nkeys)).append("\r\n");
         str.append("bt_ndata:").append(stringfromll(st.bt_ndata)).append("\r\n");
         str.append("bt_fsize:").append(stringfromll(st.bt_fsize)).append("\r\n");
         str.append("bt_dsize:").append(stringfromll(st.bt_dsize)).append("\r\n");
         str.append("bt_create_time_sec:").append(stringfromll(st.bt_create_time_sec)).append("\r\n");
         str.append("bt_modify_time_sec:").append(stringfromll(st.bt_modify_time_sec)).append("\r\n");
         str.append("bt_verify_time_sec:").append(stringfromll(st.bt_verify_time_sec)).append("\r\n");
     }
 }
开发者ID:yinqiwen,项目名称:ardb,代码行数:25,代码来源:perconaft_engine.cpp

示例3: getElement

 Data& getElement(uint32_t idx)
 {
     if (elements.size() <= idx)
     {
         elements.resize(idx + 1);
     }
     return elements[idx];
 }
开发者ID:omegablitz,项目名称:ardb,代码行数:8,代码来源:codec.hpp

示例4: SDiff

 int MMKVImpl::SDiff(DBID db, const DataArray& keys, const StringArrayResult& diffs)
 {
     if (keys.size() < 2)
     {
         return ERR_INVALID_TYPE;
     }
     RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment);
     return GenericSInterDiffUnion(db, OP_DIFF, keys, NULL, &diffs);
 }
开发者ID:shitfSign,项目名称:mmkv,代码行数:9,代码来源:t_set.cpp

示例5: f

void SortTimeFunction::f() {
  const int n           = m_copy.size();
  const int elementSize = m_copy.getElementSize();
  DataArray data        = m_copy;
  switch(elementSize) {
  case 1 : m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<BYTE>(          m_compareCount)); break;
  case 2 : m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<unsigned short>(m_compareCount)); break;
  default: m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<unsigned int  >(m_compareCount)); break;
  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:10,代码来源:AnalyzeSortMethod.cpp

示例6: FlushAll

 int Engine::FlushAll(Context& ctx)
 {
     DataArray nss;
     ListNameSpaces(ctx, nss);
     for (size_t i = 0; i < nss.size(); i++)
     {
         Flush(ctx, nss[i]);
     }
     return 0;
 }
开发者ID:omegablitz,项目名称:ardb,代码行数:10,代码来源:engine.cpp

示例7: CompactAll

 int Engine::CompactAll(Context& ctx)
 {
     DataArray nss;
     ListNameSpaces(ctx, nss);
     for (size_t i = 0; i < nss.size(); i++)
     {
         KeyObject start, end;
         start.SetNameSpace(nss[i]);
         Compact(ctx, start, end);
     }
     return 0;
 }
开发者ID:omegablitz,项目名称:ardb,代码行数:12,代码来源:engine.cpp

示例8: SRem

 int MMKVImpl::SRem(DBID db, const Data& key, const DataArray& members)
 {
     if (m_readonly)
     {
         return ERR_PERMISSION_DENIED;
     }
     int err = 0;
     RWLockGuard<MemorySegmentManager, WRITE_LOCK> keylock_guard(m_segment);
     EnsureWritableValueSpace();
     StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)();
     if (IS_NOT_EXISTS(err))
     {
         return 0;
     }
     if (NULL == set || 0 != err)
     {
         return err;
     }
     int removed = 0;
     for (size_t i = 0; i < members.size(); i++)
     {
         StringSet::iterator found = set->find(Object(members[i], true));
         if (found != set->end())
         {
             Object cc = *found;
             set->erase(found);
             DestroyObjectContent(cc);
             removed++;
         }
     }
     if (set->empty())
     {
         GenericDel(GetMMKVTable(db, false),db, Object(key, false));
     }
     return removed;
 }
开发者ID:shitfSign,项目名称:mmkv,代码行数:36,代码来源:t_set.cpp

示例9: GenericSInterDiffUnion

    int MMKVImpl::GenericSInterDiffUnion(DBID db, int op, const DataArray& keys, const Data* dest,
            const StringArrayResult* res)
    {
        StdObjectSet results[2];
        int result_index = 0;
        StringSetArray sets;
        sets.resize(keys.size());
        int err = 0;
        size_t start_index = 0;
        StringSet* destset = NULL;
        StdObjectSet* result = NULL;
        StdObjectSet* cmp = NULL;
        int current_result_index = 0;
        ObjectAllocator allocator = m_segment.MSpaceAllocator<Object>();
        StringSet empty_set(std::less<Object>(), allocator);

        for (size_t i = 0; i < keys.size(); i++)
        {
            StringSet* set = GetObject<StringSet>(db, keys[i], V_TYPE_SET, false, err)();
            if (IS_NOT_EXISTS(err))
            {
                sets[i] = &empty_set;
                continue;
            }
            if (0 != err)
            {
                return err;
            }
            sets[i] = set;
        }

        if (NULL != dest)
        {
            ObjectAllocator allocator = m_segment.MSpaceAllocator<Object>();
            destset = GetObject<StringSet>(db, *dest, V_TYPE_SET, true, err)(std::less<Object>(), allocator);
            if (0 != err)
            {
                return err;
            }
        }

        if (NULL == sets[0])
        {
            if (op == OP_DIFF || op == OP_INTER)
            {
                result_index = 0;
                goto _end;
            }
        }

        for (size_t i = 0; i < keys.size(); i++)
        {
            if (sets[i] != NULL)
            {
                start_index = i;
                break;
            }
        }

        for (size_t i = start_index + 1; i < keys.size(); i++)
        {
            result = results + current_result_index;
            if (sets[i]->empty())
            {
                if (op == OP_INTER)
                {
                    results->clear();
                    result_index = 0;
                    goto _end;
                }
            }
            result->clear();
            switch (op)
            {
                case OP_DIFF:
                {
                    if (cmp == NULL)
                    {
                        std::set_difference(sets[start_index]->begin(), sets[start_index]->end(), sets[i]->begin(),
                                sets[i]->end(), std::inserter(*result, result->end()), std::less<Object>());
                    }
                    else
                    {
                        std::set_difference(cmp->begin(), cmp->end(), sets[i]->begin(), sets[i]->end(),
                                std::inserter(*result, result->end()), std::less<Object>());
                    }
                    if (result->empty())
                    {
                        result_index = current_result_index;
                        goto _end;
                    }
                    break;
                }
                case OP_INTER:
                {
                    if (cmp == NULL)
                    {
                        std::set_intersection(sets[start_index]->begin(), sets[start_index]->end(), sets[i]->begin(),
                                sets[i]->end(), std::inserter(*result, result->end()), std::less<Object>());
                    }
//.........这里部分代码省略.........
开发者ID:shitfSign,项目名称:mmkv,代码行数:101,代码来源:t_set.cpp

示例10: Init

    int PerconaFTEngine::Init(const std::string& dir, const std::string& options)
    {
        Properties props;
        parse_conf_content(options, props);
        //parse config
        conf_get_int64(props, "cache_size", g_perconaft_config.cache_size);
        conf_get_uint32(props, "checkpoint_pool_threads", g_perconaft_config.checkpoint_pool_threads);
        conf_get_uint32(props, "checkpoint_period", g_perconaft_config.checkpoint_period);
        conf_get_uint32(props, "cleaner_period", g_perconaft_config.cleaner_period);
        conf_get_uint32(props, "cleaner_iterations", g_perconaft_config.cleaner_iterations);
        conf_get_bool(props, "evictor_enable_partial_eviction", g_perconaft_config.evictor_enable_partial_eviction);
        std::string compression;
        conf_get_string(props, "compression", compression);
        if (compression == "none")
        {
            g_perconaft_config.compression = TOKU_NO_COMPRESSION;
        }
        else if (compression == "snappy" || compression.empty())
        {
            g_perconaft_config.compression = TOKU_SNAPPY_METHOD;
        }
        else if (compression == "zlib")
        {
            g_perconaft_config.compression = TOKU_ZLIB_METHOD;
        }
        else
        {
            ERROR_LOG("Invalid compression config:%s for PercanoFT.", compression.c_str());
            return -1;
        }

        uint32 env_open_flags = DB_CREATE | DB_PRIVATE | DB_THREAD | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_RECOVER;
        int env_open_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
        db_env_create(&m_env, 0);
        m_env->set_default_bt_compare(m_env, ardb_perconaft_compare);
        m_env->set_errcall(m_env, _err_callback);

        /*
         * set env config
         */
        uint32 cache_gsize = g_perconaft_config.cache_size >> 30;
        uint32 cache_bytes = g_perconaft_config.cache_size % (1024 * 1024 * 1024);
        m_env->set_cachesize(m_env, cache_gsize, cache_bytes, 1);
        m_env->set_cachetable_pool_threads(m_env, g_perconaft_config.checkpoint_pool_threads);
        m_env->checkpointing_set_period(m_env, g_perconaft_config.checkpoint_period);
        m_env->cleaner_set_period(m_env, g_perconaft_config.cleaner_period);
        m_env->cleaner_set_iterations(m_env, g_perconaft_config.cleaner_iterations);

        m_env->evictor_set_enable_partial_eviction(m_env, g_perconaft_config.evictor_enable_partial_eviction);

        int r = m_env->open(m_env, dir.c_str(), env_open_flags, env_open_mode);
        CHECK_EXPR(r);
        DataArray nss;
        if (0 == r)
        {
            g_toku_env = m_env;
            DB* db = m_env->get_db_for_directory(m_env);
            if (NULL != db)
            {
                PerconaFTLocalContext& local_ctx = g_local_ctx.GetValue();
                DB_TXN* txn = local_ctx.transc.Get();
                DBC *c = NULL;
                CHECK_EXPR(r = db->cursor(db, txn, &c, 0));
                if (0 == r)
                {
                    r = c->c_getf_first(c, 0, nil_callback, NULL);
                }
                while (0 == r)
                {
                    DBT raw_key;
                    DBT raw_val;
                    memset(&raw_key, 0, sizeof(raw_key));
                    memset(&raw_val, 0, sizeof(raw_key));
                    if (0 == c->c_get(c, &raw_key, &raw_val, DB_CURRENT))
                    {
                        //std::string ns_str
                        Data ns;
                        ns.SetString((const char*) raw_key.data, false);
                        INFO_LOG("TokuFT directory db %s:%s", (const char* ) raw_key.data, (const char* ) raw_val.data);
                        nss.push_back(ns);
                    }
                    r = c->c_getf_next(c, 0, nil_callback, NULL);
                }
                if (NULL != c)
                {
                    c->c_close(c);
                }
                local_ctx.transc.Release(true);
                r = 0;
            }
        }
        for (size_t i = 0; i < nss.size(); i++)
        {
            Context tmp;
            GetFTDB(tmp, nss[i], true);
        }
        return ENGINE_ERR(r);
    }
开发者ID:yinqiwen,项目名称:ardb,代码行数:98,代码来源:perconaft_engine.cpp

示例11: SortCommand

    int Ardb::SortCommand(Context& ctx, const Slice& key, SortOptions& options, DataArray& values)
    {
        values.clear();

        KeyType keytype = KEY_END;
        GetType(ctx, key, keytype);

        switch (keytype)
        {
            case LIST_META:
            {
                ListRange(ctx, key, 0, -1);
                break;
            }
            case SET_META:
            {
                SetMembers(ctx, key);
                break;
            }
            case ZSET_META:
            {
                ZSetRange(ctx, key, 0, -1, false, false, OP_GET);
                if (NULL == options.by)
                {
                    options.nosort = true;
                }
                break;
            }
            default:
            {
                return ERR_INVALID_TYPE;
            }
        }
        DataArray sortvals;
        if (ctx.reply.MemberSize() > 0)
        {
            for (uint32 i = 0; i < ctx.reply.MemberSize(); i++)
            {
                Data v;
                v.SetString(ctx.reply.MemberAt(i).str, true);
                sortvals.push_back(v);
            }
        }
        if (sortvals.empty())
        {
            return 0;
        }
        if (options.with_limit)
        {
            if (options.limit_offset < 0)
            {
                options.limit_offset = 0;
            }
            if ((uint32) options.limit_offset > sortvals.size())
            {
                values.clear();
                return 0;
            }
            if (options.limit_count < 0)
            {
                options.limit_count = sortvals.size();
            }
        }

        std::vector<SortValue> sortvec;
        if (!options.nosort)
        {
            if (NULL != options.by)
            {
                sortvec.reserve(sortvals.size());
            }
            for (uint32 i = 0; i < sortvals.size(); i++)
            {
                if (NULL != options.by)
                {
                    sortvec.push_back(SortValue(&sortvals[i]));
                    if (GetValueByPattern(ctx, options.by, sortvals[i], sortvec[i].cmp) < 0)
                    {
                        DEBUG_LOG("Failed to get value by pattern:%s", options.by);
                        sortvec[i].cmp.Clear();
                        continue;
                    }
                }
                if (options.with_alpha)
                {
                    if (NULL != options.by)
                    {
                        sortvec[i].cmp.ToString();
                    }
                    else
                    {
                        sortvals[i].ToString();
                    }
                }
            }
            if (NULL != options.by)
            {
                if (!options.is_desc)
                {
                    std::sort(sortvec.begin(), sortvec.end(), less_value<SortValue>);
//.........这里部分代码省略.........
开发者ID:mastergyp,项目名称:ardb,代码行数:101,代码来源:sort.cpp

示例12: ClientHandshake

		// Helper Funcitons
		void Socket::ClientHandshake() {
			std::cout << "Client Handshake" << std::endl;
			unsigned char previous = 0;
			bool bEncrypted = false;
			
			std::vector<unsigned char> handshakeData;
			
			bool bDone = false;
			while( !bDone ) {
				Record *record;
				if( !bEncrypted ) {
					record = new Record();
				}else{
					record = new Record( mClient );
				}
				
				record->Read( *mSocket );
				
				// Alert
				if( record->GetType() == Record::Alert ){
					std::vector<unsigned char> data = record->GetData();
					
					std::cerr << "Alert: " << std::hex << std::setw( 2 ) << std::setfill('0') << (int)data[0] 
						<< ", " << std::hex << std::setw( 2 ) << std::setfill('0') << (int)data[1] << std::endl;
					exit( EXIT_FAILURE );
				}
				
				// Cipher
				if( record->GetType() == Record::Cipher ){
					if( previous == Handshake::Type::ClientKey ){
						bEncrypted = true;
					}
					
					previous = Record::Cipher;
				}
				
				// Handshake
				if( record->GetType() == Record::Handshake ){
					std::vector<unsigned char> data = record->GetData();
					
					if( previous == 0 ){
						if( data[0] == Handshake::Type::ClientHello ){
							Handshake::ClientHello hClientHello;
							hClientHello.Deserialize( std::vector<unsigned char>( data.begin() + 4, data.end() ) );
							
							ClientRandom = hClientHello.Random();
							
							handshakeData.insert( handshakeData.end(), data.begin(), data.end() );
							
							Handshake::ServerHello hServerHello( 0x00, 0x35, 0x00 );
							Record rServerHello( Record::Handshake, hServerHello.Serialize() );
							rServerHello.Write( *mSocket );
							
							ServerRandom = hServerHello.Random();
							
							std::vector<unsigned char> dServerHello = hServerHello.Serialize();
							handshakeData.insert( handshakeData.end(), dServerHello.begin(), dServerHello.end() );
							
							Handshake::Certificate hCertificate( mCertificatePath );
							Record rCertificate( Record::Handshake, hCertificate.Serialize() );
							rCertificate.Write( *mSocket );
							
							std::vector<unsigned char> dCertificate = hCertificate.Serialize();
							handshakeData.insert( handshakeData.end(), dCertificate.begin(), dCertificate.end() );
							
							std::vector<unsigned char> dServerDone;
							
							// Insert Size
							unsigned int size = htonl( dServerDone.size() );
							unsigned char* cSize = (unsigned char*)&size;
							
							dServerDone.insert( dServerDone.begin(), cSize[3] );
							dServerDone.insert( dServerDone.begin(), cSize[2] );
							dServerDone.insert( dServerDone.begin(), cSize[1] );
							
							// Insert Type
							dServerDone.insert( dServerDone.begin(), Handshake::Type::ServerDone );
							
							Record rServerDone( Record::Handshake, dServerDone );
							rServerDone.Write( *mSocket );
							
							handshakeData.insert( handshakeData.end(), dServerDone.begin(), dServerDone.end() );
						}
						
						previous = data[0];
					}
					
					if( previous == Handshake::Type::ClientHello ){
						if( data[0] == Handshake::Type::ClientKey ){
							Handshake::ClientKeyExchange hClientKeyExchange( mKeyPath );
							hClientKeyExchange.Deserialize( std::vector<unsigned char>( data.begin() + 4, data.end() ) );

							handshakeData.insert( handshakeData.end(), data.begin(), data.end() );
							
							DataArray secret = hClientKeyExchange.Secret();
				
							MasterKey = PRF( 48, secret, "master secret", Concatonate( ClientRandom, ServerRandom ) );
							KeyBlock = PRF( 136, MasterKey, "key expansion", Concatonate( ServerRandom, ClientRandom ) );
							
//.........这里部分代码省略.........
开发者ID:Omegaice,项目名称:CPP-SSL,代码行数:101,代码来源:Socket.cpp


注:本文中的DataArray::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。