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


C++ Index类代码示例

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


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

示例1: __flann_radius_search

int __flann_radius_search(flann_index_t index_ptr,
                          typename Distance::ElementType* query,
                          int* indices,
                          typename Distance::ResultType* dists,
                          int max_nn,
                          float radius,
                          FLANNParameters* flann_params)
{
    typedef typename Distance::ElementType ElementType;
    typedef typename Distance::ResultType DistanceType;

    try {
        init_flann_parameters(flann_params);
        if (index_ptr==NULL) {
            throw FLANNException("Invalid index");
        }
        Index<Distance>* index = (Index<Distance>*)index_ptr;

        Matrix<int> m_indices(indices, 1, max_nn);
        Matrix<DistanceType> m_dists(dists, 1, max_nn);
        SearchParams search_params = create_search_params(flann_params);
        int count = index->radiusSearch(Matrix<ElementType>(query, 1, index->veclen()),
                                        m_indices,
                                        m_dists, radius, search_params );


        return count;
    }
    catch (std::runtime_error& e) {
        Logger::error("Caught exception: %s\n",e.what());
        return -1;
    }
}
开发者ID:Erotemic,项目名称:flann,代码行数:33,代码来源:flann.cpp

示例2: __flann_find_nearest_neighbors_index

int __flann_find_nearest_neighbors_index(flann_index_t index_ptr, typename Distance::ElementType* testset, int tcount,
                                         int* result, typename Distance::ResultType* dists, int nn, FLANNParameters* flann_params)
{
    typedef typename Distance::ElementType ElementType;
    typedef typename Distance::ResultType DistanceType;

    try {
        init_flann_parameters(flann_params);
        if (index_ptr==NULL) {
            throw FLANNException("Invalid index");
        }
        Index<Distance>* index = (Index<Distance>*)index_ptr;

        Matrix<int> m_indices(result,tcount, nn);
        Matrix<DistanceType> m_dists(dists, tcount, nn);

        SearchParams search_params = create_search_params(flann_params);
        index->knnSearch(Matrix<ElementType>(testset, tcount, index->veclen()),
                         m_indices,
                         m_dists, nn, search_params );

        return 0;
    }
    catch (std::runtime_error& e) {
        Logger::error("Caught exception: %s\n",e.what());
        return -1;
    }

    return -1;
}
开发者ID:Erotemic,项目名称:flann,代码行数:30,代码来源:flann.cpp

示例3: AddIndex

OP_STATUS ComplementIndexGroup::AddIndex(index_gid_t index_id)
{
	if (m_indexes.Contains(index_id))
		return OpStatus::OK;

	Index* index = m_indexer->GetIndexById(index_id);
	if (index)
	{
		RETURN_IF_ERROR(index->PreFetch());
		
		OpINT32Vector all_messages;
		RETURN_IF_ERROR(m_index->GetAllMessages(all_messages));
		for (UINT32 i = 0; i < all_messages.GetCount(); i++)
		{
			if (index->Contains(all_messages.Get(i)))
			{
				RETURN_IF_ERROR(m_index->RemoveMessage(all_messages.Get(i)));
			}
		}
		
		RETURN_IF_ERROR(m_indexes.Insert(index_id));
		index->AddObserver(this);
	}

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:26,代码来源:indexgroup.cpp

示例4: __flann_build_index

flann_index_t __flann_build_index(typename Distance::ElementType* dataset, int rows, int cols, float* speedup,
                                  FLANNParameters* flann_params, Distance d = Distance())
{
    typedef typename Distance::ElementType ElementType;
    try {

        init_flann_parameters(flann_params);
        if (flann_params == NULL) {
            throw FLANNException("The flann_params argument must be non-null");
        }
        IndexParams params = create_parameters(flann_params);
        Index<Distance>* index = new Index<Distance>(Matrix<ElementType>(dataset,rows,cols), params, d);
        index->buildIndex();

        if (flann_params->algorithm==FLANN_INDEX_AUTOTUNED) {
            IndexParams params = index->getParameters();
            update_flann_parameters(params,flann_params);
            SearchParams search_params = get_param<SearchParams>(params,"search_params");
            *speedup = get_param<float>(params,"speedup");
            flann_params->checks = search_params.checks;
            flann_params->eps = search_params.eps;
            flann_params->cb_index = get_param<float>(params,"cb_index",0.0);
        }

        return index;
    }
    catch (std::runtime_error& e) {
        Logger::error("Caught exception: %s\n",e.what());
        return NULL;
    }
}
开发者ID:Erotemic,项目名称:flann,代码行数:31,代码来源:flann.cpp

示例5: __flann_find_nearest_neighbors

int __flann_find_nearest_neighbors(typename Distance::ElementType* dataset,  int rows, int cols, typename Distance::ElementType* testset, int tcount,
                                   int* result, typename Distance::ResultType* dists, int nn, FLANNParameters* flann_params, Distance d = Distance())
{
    typedef typename Distance::ElementType ElementType;
    typedef typename Distance::ResultType DistanceType;
    try {
        init_flann_parameters(flann_params);

        IndexParams params = create_parameters(flann_params);
        Index<Distance>* index = new Index<Distance>(Matrix<ElementType>(dataset,rows,cols), params, d);
        index->buildIndex();
        Matrix<int> m_indices(result,tcount, nn);
        Matrix<DistanceType> m_dists(dists,tcount, nn);
        SearchParams search_params = create_search_params(flann_params);
        index->knnSearch(Matrix<ElementType>(testset, tcount, index->veclen()),
                         m_indices,
                         m_dists, nn, search_params );
        delete index;
        return 0;
    }
    catch (std::runtime_error& e) {
        Logger::error("Caught exception: %s\n",e.what());
        return -1;
    }

    return -1;
}
开发者ID:Erotemic,项目名称:flann,代码行数:27,代码来源:flann.cpp

示例6: sizeof

bool Slice::loadIndex(Index &index, Buffer &buf)
{
	auto leftSize = _indexFd.fileSize();
	_indexFd.seek(sizeof(SliceIndexHeader), SEEK_SET);
	leftSize -= sizeof(SliceIndexHeader);
	while (leftSize > 0) {
		static uint32_t CHUNK_SIZE = sizeof(IndexEntry) * 100000;
		
		ssize_t readSize = CHUNK_SIZE;
		if (readSize > leftSize)
			readSize = leftSize;
		buf.clear();
		if (_indexFd.read(buf.reserveBuffer(readSize), readSize) != readSize) {
			log::Fatal::L("Can't read data index from sliceID %u\n", _sliceID);
			return false;
		}
		leftSize -= readSize;
		while (buf.readPos() < buf.writtenSize()) {
			IndexEntry &ie = *(IndexEntry*)buf.mapBuffer(sizeof(IndexEntry));
			if (ie.header.status & ST_ITEM_DELETED)
				index.remove(ie.header);
			else
				index.addNoLock(ie);
		}
	}
	return true;
}
开发者ID:AntonOrnatskyi,项目名称:metis,代码行数:27,代码来源:slice.cpp

示例7: Index

bool DB::select(Data *property, Data *tables, Data *qulification) {
    
    cout<<"hello"<<endl;

    Index i = Index();
    block_addr addr = i.getBlock(tables);


    const char * tableName = "x";

    preparePathModelAddr(tableName, addr);
    if (!f.prepareFetchTuple()) // data文件为空
        return 0;

    int numOfAttribute = f.getAttributeNumFromModel(model);
    tuple *p = new tuple[numOfAttribute];

    int numOfResult = 0;
    while (f.fetchTuple(p)) {
        numOfResult++;

        tuple x = p[0];
        int xx = this->ChartoInt(x);
//        char *str = p[1];

        cout << numOfResult << ":" << xx << " " << endl;
        deleteNewAttribute(p, numOfAttribute);
    }

    return true;
}
开发者ID:littlechi,项目名称:myDBMS,代码行数:31,代码来源:DB.cpp

示例8: build

Index Index::build(DocumentCollection docs) {
    Index index;
    int count = docs.size();
    double avgLen = 0;
    for (auto& doc : docs) {
        for (auto& field : doc.second) {
            string value = field.value;
            for (unsigned i = 0; i < value.length(); i++)
                if (value[i] == ' ' && i != value.length()-1)
                    avgLen++;
            avgLen++;
        }
    }
    avgLen = avgLen / (double)count;

    for (auto& doc : docs) {
        for (auto& field : doc.second) {
            unique_ptr<TokenStream> stream(ArnetAnalyzer::tokenStream(field.value));
            index.addSingle(doc.second.id, 0, stream.get(), avgLen);
        }
    }

    index.optimize();
    return std::move(index);
}
开发者ID:actnet,项目名称:saedb,代码行数:25,代码来源:indexing.cpp

示例9: GLOBAL_CONF

void IndexTestCase::testInt32ForwardIndex()
{
    DocumentSchema schema;
    schema.addSortableField("Int32Id", FieldType::INT32, false);

    const static size_t NUM_DOCS = 1000;
    stringstream ss;
    for (size_t i = 0; i < NUM_DOCS; ++i)
    {
        ss << i << ";";
    }

    GLOBAL_CONF().Build.buildThreadCount = 1;
    buildIndex(schema, ss.str());

    tstring str = getTestPath();
    Index index;
    index.open(str, Index::READ, NULL);
    IndexReaderPtr pReader = index.acquireReader();
    CPPUNIT_ASSERT(pReader != NULL);
    ForwardIndexIteratorPtr pForIndexIt = pReader->forwardIndexReader("Int32Id");
    CPPUNIT_ASSERT(pForIndexIt != NULL);
    Int32ForwardIndexIteratorPtr pInt32ForIndexIt =
        pForIndexIt.cast<Int32ForwardIndexIterator>();
    CPPUNIT_ASSERT(pInt32ForIndexIt != NULL);
    
    int32_t value = 0;
    docid_t docId = 0;
    for (; docId < (docid_t)NUM_DOCS; ++docId)
    {
        CPPUNIT_ASSERT(pInt32ForIndexIt->seek(docId, value));
        CPPUNIT_ASSERT_EQUAL((int32_t)docId, value);
    }
    CPPUNIT_ASSERT(!pInt32ForIndexIt->seek(docId, value));
}
开发者ID:Web5design,项目名称:firtex2,代码行数:35,代码来源:IndexTestCase.cpp

示例10: buildIndex

void IndexTestCase::testRefreshIndexWithMultiBarrel()
{
    DocumentSchema schema;
    schema.addTextField("BODY");
    
    stringstream ss;
    const size_t NUM_DOCS = 1000;
    for (size_t i = 0; i < NUM_DOCS; ++i)
    {
        ss << "body" << i << " hot;";
    }
    buildIndex(schema, ss.str());
    buildIndex(schema, ss.str(), true);

    tstring str = getTestPath();
    Index index;
    index.open(str, Index::READ, NULL);
    IndexReaderPtr pIndexReader1 = index.acquireReader();
    checkDocFreq(pIndexReader1, "BODY", "hot", 2 * NUM_DOCS);

    buildIndex(schema, ss.str(), true);
    IndexReaderPtr pIndexReader2 = index.acquireReader(true);
    CPPUNIT_ASSERT(pIndexReader1 != pIndexReader2);
    
    checkDocFreq(pIndexReader2, "BODY", "hot", 3 * NUM_DOCS);
}
开发者ID:Web5design,项目名称:firtex2,代码行数:26,代码来源:IndexTestCase.cpp

示例11: main

int main()
{
	Index index;
	index.read_dictionary();
	index.debug();
	return 0;
}
开发者ID:huweiqing915,项目名称:spell_correct,代码行数:7,代码来源:test_index.cpp

示例12: main

int main(void){
	Index idx;
	idx.readFile("dict.dat");
	idx.createIndex("dict.idx");

	return 0;
}
开发者ID:gardness,项目名称:SpC_Framework,代码行数:7,代码来源:create_Index.cpp

示例13: basis0

  void
  TensorProductBasis<BASIS0,BASIS1>::reconstruct_1(const Index& lambda,
						   const int j,
						   InfiniteVector<double, Index>& c) const {
    if (lambda.j() >= j) {
      // then we can just copy \psi_\lambda
      c.add_coefficient(lambda, 1.0);
    } else {
      // reconstruct by recursion
      
      typedef typename BASIS0::Index Index0;
      typedef typename BASIS1::Index Index1;
      InfiniteVector<double,Index0> c1;
      InfiniteVector<double,Index1> c2;
      basis0().reconstruct_1(lambda.index0(), lambda.j()+1, c1);
      basis1().reconstruct_1(lambda.index1(), lambda.j()+1, c2);

      for (typename InfiniteVector<double,Index0>::const_iterator it1(c1.begin()), it1end(c1.end());
	   it1 != it1end; ++it1)
	for (typename InfiniteVector<double,Index1>::const_iterator it2(c2.begin()), it2end(c2.end());
	     it2 != it2end; ++it2) {
	  InfiniteVector<double,Index> d;
	  reconstruct_1(Index(it1.index(), it2.index()), j, d);
	  c.add(*it1 * *it2, d);
	}
    }
  }
开发者ID:kedingagnumerikunimarburg,项目名称:Marburg_Software_Library,代码行数:27,代码来源:tp_basis.cpp

示例14: Index

void IndexContentTestCase::testIndexContent_DL0()
{
    Index* pIndex;
    IndexReaderPtr pReader;

    const Term* pTerm;
    TermIteratorPtr pTermIter;
    int	docCount = 0;
    uint32_t i;
    uint32_t indexTermId;
    string fileName;

    //Check posting list
    Path indexPath = TestHelper::getTestDataPath();
    indexPath.makeDirectory();
    indexPath.pushDirectory(_T("test_dl0index"));    
    pIndex = new Index(indexPath.toString().c_str(), Index::READ, NULL);
    auto_ptr<Index> indexPtr(pIndex);
    pReader = pIndex->acquireReader();
    TermReaderPtr pTermReader = pReader->termReader();

    pTermIter = pTermReader->termIterator("BODY");

    StoredFieldsReaderPtr pDocReader = pReader->createStoredFieldsReader();
    //Iterator all terms
    while(pTermIter->next())
    {
        pTerm = pTermIter->term();

        CPPUNIT_ASSERT(pTermReader->seek(pTerm));
		
        indexTermId = (pTerm->cast<int32_t>())->getValue();
        TermPostingIteratorPtr pTermDocFreqs = pTermReader->termPostings();
        docCount = 0;

        while(pTermDocFreqs->nextDoc())
        {
            DocumentPtr pDoc = pDocReader->document(pTermDocFreqs->doc());
            docCount++;

            // 获取文件路径
            fileName.assign(pDoc->getField("PATH")->getValue().c_str());

            TermList* pTermIdList = m_pDocScanner->getTermListOfFile(fileName);
            CPPUNIT_ASSERT(pTermIdList != NULL);//存在该文件
            for(i = 0; i < pTermIdList->getSize(); i++)
            {
                if(indexTermId == pTermIdList->getValue(i))
                {
                    break;
                }
            }
            CPPUNIT_ASSERT(i < pTermIdList->getSize());//源文档中是否存在该词
        }//end while nextDoc()
        CPPUNIT_ASSERT_EQUAL((df_t)docCount, pTermDocFreqs->getDocFreq());//测DF
    }
    CPPUNIT_ASSERT_EQUAL((int64_t)m_pDocScanner->getTotalTermCount(), 
                         pReader->getNumTerms());//CTF
}
开发者ID:Web5design,项目名称:firtex2,代码行数:59,代码来源:IndexContentTestCase.cpp

示例15: figureKeyToIndex

void FittingLayer::markFigureKeyUnselected(const FigureKey& figureKey)
{
	Index index = figureKeyToIndex(figureKey);
	if (index.isValid()) 
	{
		getChosenSymbol(index)->setVisible(false);	
	}
}
开发者ID:ctomiao2,项目名称:Miss-U-Project,代码行数:8,代码来源:FittingLayer.cpp


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