Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1069638
  • 博文数量: 252
  • 博客积分: 4561
  • 博客等级: 上校
  • 技术积分: 2833
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-15 08:23
文章分类

全部博文(252)

文章存档

2015年(2)

2014年(1)

2013年(1)

2012年(16)

2011年(42)

2010年(67)

2009年(87)

2008年(36)

分类:

2010-04-14 17:29:13

#include <netinet/in.h>
#include <sys/socket.h>
#include <wchar.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include <dirent.h>
#include <assert.h>

#include "CLucene.h"
#include "CLucene/util/Misc.h"
#include "CLucene/util/repl_tchar.h"
#include "CLucene/queryParser/MultiFieldQueryParser.h"
#include "CLucene/store/RAMDirectory.h"

using namespace jstreams;
using namespace lucene::analysis;
using namespace lucene::analysis::standard;
using namespace lucene::store;
using namespace lucene::document;
using namespace lucene::index;
using namespace lucene::search;
using namespace lucene::util;
using namespace lucene::queryParser;

static void * pthread_indexer(void *arg)
{
    StandardAnalyzer an;
    IndexWriter writer("/home/fanyf/work/cppwork/testindex", &an, false);
    writer.optimize();
    writer.close();

    return NULL;
}

static void * pthread_searcher(void *arg)
{
    IndexSearcher searcher("/home/fanyf/work/cppwork/clucene_test/index");
    searcher.close();

    return NULL;
}

int main()
{
    pthread_t id[2];
    int err;

    if ((err = pthread_create(&id[0], NULL, pthread_indexer, NULL)) != 0)
        printf("%s\n", strerror(err));

    if ((err = pthread_create(&id[1], NULL, pthread_searcher, NULL)) != 0)
        printf("%s\n", strerror(err));

    for (int i = 0; i < 2; i++)
        pthread_join(id[i], NULL);

        _lucene_shutdown();

    printf("hello world\n");

    return 0;
}


阅读(758) | 评论(0) | 转发(0) |
0

上一篇:split file

下一篇:mysql c api example

给主人留下些什么吧!~~