Package proj.zoie.api

Examples of proj.zoie.api.DefaultZoieVersion


    {
      idxSystem.setBatchSize(10);

      final int count = TestData.testdata.length;
      List<DataEvent<String,DefaultZoieVersion>> list = new ArrayList<DataEvent<String,DefaultZoieVersion>>(count);
      DefaultZoieVersion zvt = null;
      for (int i = 0; i < count; i++)
      {
        zvt = new DefaultZoieVersion();
        zvt.setVersionId(i);
        //list.add(new DataEvent<String,DefaultZoieVersion>(i, TestData.testdata[i]));
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i], zvt));
      }
      memoryProvider.addEvents(list);
      idxSystem.syncWthVersion(100000, zvt);

      for(QueryThread queryThread : queryThreads) queryThread.start();

      for(int n = 1; n <= 3; n++)
      {
        for (int i = 0; i < count; i++)
        {
          zvt = new DefaultZoieVersion();
          long version = n * count + i;
          zvt.setVersionId(version);
          list = new ArrayList<DataEvent<String,DefaultZoieVersion>>(1);
          list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i], zvt));
          memoryProvider.addEvents(list);
          idxSystem.syncWthVersion(100000, zvt);
        }
View Full Code Here


    try
    {
      idxSystem.setBatchSize(10);

      long version = 0;
      DefaultZoieVersion zvt = null;
      final int count = TestData.testdata.length;
      List<DataEvent<String,DefaultZoieVersion>> list = new ArrayList<DataEvent<String,DefaultZoieVersion>>(count);
      for (int i = 0; i < count; i++)
      {
        //version = i;
        zvt = new DefaultZoieVersion();
        zvt.setVersionId(i);
        //list.add(new DataEvent<String>(i, TestData.testdata[i]));
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i],zvt));
      }
      memoryProvider.addEvents(list);
      idxSystem.syncWthVersion(10000, zvt);

    
     
      QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,"contents",idxSystem.getAnalyzer());
      Query q;
      Searcher searcher = null;
      List<ZoieIndexReader<IndexReader>> readers = null;

      TopDocs hits;

      q = parser.parse("zoie");
      readers=idxSystem.getIndexReaders();
     
      for(int i=0; i<readers.size(); i++)
      {
        IndexReader ir = readers.get(i);
        Map<String, String> commitData = IndexReader.getCommitUserData(ir.directory()); // = new HashMap<String,String>();
        System.out.println("i:" + i + "ZoieTest: directory: " + ir.directory());
        System.out.println("i:" + i + "ZoieTest: commitData(ZoieVersion): " + commitData)
      }
     
      if(2>1) return;
     
      MultiReader reader=new MultiReader(readers.toArray(new IndexReader[readers.size()]),false);

      searcher=new IndexSearcher(reader);
      hits = searcher.search(q,10);
      int expected = TestData.testdata.length;
      assertEquals("before update: zoie count mismatch[hit count: " + hits.totalHits +" / expected: "+TestData.testdata.length +"]", count, hits.totalHits);
      q = parser.parse("zoie2");

      searcher.close();
      reader.close();
      idxSystem.returnIndexReaders(readers);

      readers=idxSystem.getIndexReaders();
      reader=new MultiReader(readers.toArray(new IndexReader[readers.size()]),false);

      searcher=new IndexSearcher(reader);
      hits = searcher.search(q,10);
      assertEquals("before update: zoie2 count mismatch[hit count: " + hits.totalHits +" / expected: "+ 0 +"]", 0, hits.totalHits);
      searcher.close();
      reader.close();
      idxSystem.returnIndexReaders(readers);

      list = new ArrayList<DataEvent<String,DefaultZoieVersion>>(TestData.testdata2.length);
      for(int i = 0; i < TestData.testdata2.length; i++)
      {
        version = count + i;
        zvt = new DefaultZoieVersion();
        zvt.setVersionId(version);
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata2[i],zvt));
      }
      memoryProvider.addEvents(list);
      idxSystem.syncWthVersion(10000, zvt);
View Full Code Here

      IndexSignature<DefaultZoieVersion> sig;

      list=new ArrayList<DataEvent<String,DefaultZoieVersion>>(count);
      for (int i=0;i<count/2;++i)
      {
        DefaultZoieVersion zvt = new DefaultZoieVersion();
        zvt.setVersionId(i);
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i], zvt));
      }
      idxSystem.consume(list);
      idxSystem.flushEvents(100000);
      sig = dirMgr.getCurrentIndexSignature();

      DefaultZoieVersion dzv = (DefaultZoieVersion)(sig.getVersion());
      assertEquals("index version mismatch after first flush", (count/2 - 1), dzv.getVersionId());

      list=new ArrayList<DataEvent<String, DefaultZoieVersion>>(count);
      for (int i=count/2; i < count; ++i)
      {
        DefaultZoieVersion zvt = new DefaultZoieVersion();
        zvt.setVersionId(i);
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i],zvt));
      }
      idxSystem.consume(list);
      idxSystem.flushEvents(100000);
      sig = dirMgr.getCurrentIndexSignature();
View Full Code Here

    idxSystem.setBatchSize(10);

    //long version = 0;
    final int count = TestData.testdata.length;
    List<DataEvent<String, DefaultZoieVersion>> list = new ArrayList<DataEvent<String,DefaultZoieVersion>>(count);
    DefaultZoieVersion zvt = null;
    for (int i = 0; i < count; i++){
      zvt = new DefaultZoieVersion();
      zvt.setVersionId(i);
      //version = i;
      list.add(new DataEvent<String, DefaultZoieVersion>(TestData.testdata[i], zvt));
    }
    memoryProvider.addEvents(list);
    idxSystem.syncWthVersion(10000, zvt);
View Full Code Here

    memoryProvider.setDataConsumer(idxSystem);
    memoryProvider.start();
    idxSystem.setBatchSize(5);

    long version = 0;
    DefaultZoieVersion zvt = null;
    for(int rep = 0 ; rep<5; rep++)
    {
      final int count = TestData.testdata.length;
      List<DataEvent<String,DefaultZoieVersion>> list = new ArrayList<DataEvent<String,DefaultZoieVersion>>(count);
      for (int i = 0; i < count; i++)
      {
        version = i + rep*count;
        zvt = new DefaultZoieVersion();
        zvt.setVersionId(version);
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i],zvt));
      }
      memoryProvider.addEvents(list);
      idxSystem.flushEvents(10000);
      idxSystem.syncWthVersion(10000, zvt);
View Full Code Here

   
    try
    {
      List<DataEvent<String,DefaultZoieVersion>> list;
      DefaultZoieVersion zvt = null;

      list=new ArrayList<DataEvent<String,DefaultZoieVersion>>(TestData.testdata.length);
      for (int i=0;i<TestData.testdata.length;++i)
      {
        zvt = new DefaultZoieVersion();       
        zvt.setVersionId(i);
        list.add(new DataEvent<String,DefaultZoieVersion>(TestData.testdata[i],zvt));
      }
      idxSystem.consume(list);
      idxSystem.flushEvents(100000);
     
      DefaultZoieVersion versionExported = new DefaultZoieVersion();
      versionExported.setVersionId(zvt.getVersionId());
         
      assertEquals("index version mismatch after first flush", TestData.testdata.length - 1, zvt.getVersionId());
     
     
      int hits = countHits(idxSystem, q);

      RandomAccessFile exportFile;
      FileChannel channel;

      exportFile = new RandomAccessFile(new File(getTmpDir(), "zoie_export.dat"), "rw");
      channel = exportFile.getChannel();
      idxSystem.exportSnapshot(channel);
      channel.close();
      exportFile.close();
      exportFile = null;
      channel = null;
    
      list=new ArrayList<DataEvent<String,DefaultZoieVersion>>(TestData.testdata2.length);
      for (int i=0; i < TestData.testdata2.length; ++i)
      {
        zvt = new DefaultZoieVersion();
        zvt.setVersionId(TestData.testdata.length+i);
       
        list.add(new DataEvent<String, DefaultZoieVersion>(TestData.testdata.length + TestData.testdata2[i],zvt));
      }
      idxSystem.consume(list);
      idxSystem.flushEvents(100000);
      zvt = (DefaultZoieVersion)dirMgr.getVersion();
      assertEquals("index version mismatch after second flush", TestData.testdata.length + TestData.testdata2.length - 1, zvt.getVersionId());
      assertEquals("should have no hits", 0, countHits(idxSystem, q));
     
      exportFile = new RandomAccessFile(new File(getTmpDir(), "zoie_export.dat"), "r");
      channel = exportFile.getChannel();
      idxSystem.importSnapshot(channel);
      idxSystem.flushEvents(10000);
      channel.close();
      exportFile.close();

      assertEquals("count is wrong", hits, countHits(idxSystem, q));

     
      zvt = (DefaultZoieVersion)dirMgr.getVersion();     
      assertEquals("imported version is wrong", versionExported.getVersionId(), zvt.getVersionId());    }
    
    catch(ZoieException e)
    {
      throw e;
    }
View Full Code Here

  }
 
  public DefaultZoieVersion nextZoieVersion()
  {
    String desp = _currentVersion.encodeToString();
    DefaultZoieVersion dzv = getZoieVersion(_currentVersion.encodeToString());
    dzv.setVersionId(dzv.getVersionId()+1)
   
    return dzv; 
  }
View Full Code Here

    catch(EOFException eof){
      return null;
    } catch (IOException e) {
      log.error(e.getMessage(),e);
    }
    DefaultZoieVersion v = new DefaultZoieVersion();
    v.setVersionId(_version.getVersionId()+1);
    DataEvent<ContentDoc,DefaultZoieVersion> event = new DataEvent<ContentDoc,DefaultZoieVersion>(dataNode, v);
    return event;
  }
View Full Code Here

TOP

Related Classes of proj.zoie.api.DefaultZoieVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.