Package org.infinispan.lucene

Examples of org.infinispan.lucene.ChunkCacheKey$Externalizer


      AssertJUnit.assertNotNull(fileList);
      int fileListCacheKeyInstances = 0;

      for (Object key : cache.keySet()) {
         if (key instanceof ChunkCacheKey) {
            ChunkCacheKey existingChunkKey = (ChunkCacheKey) key;
            AssertJUnit.assertEquals(existingChunkKey.getIndexName(), INDEX_NAME);
            Object value = cache.get(existingChunkKey);
            AssertJUnit.assertNotNull(value);
            AssertJUnit.assertTrue(value instanceof byte[]);
            byte[] buffer = (byte[]) cache.get(existingChunkKey);
            AssertJUnit.assertTrue(buffer.length != 0);
View Full Code Here


                                                                    CacheLoaderManager.class).getCacheLoader();

      HashSet exclusionSet = new HashSet();
      String[] fileNames = TestHelper.getFileNamesFromDir(rootDir, indexName);
      for(String fileName : fileNames) {
         exclusionSet.add(new ChunkCacheKey(indexName, fileName, 0, 110));
      }

      Set keyList = cacheLoader.loadAllKeys(null);
      checkIfExists(keyList, exclusionSet, true, false);
View Full Code Here

   }

   private void checkIfExists(Set result, Set exclusionSet, boolean shouldExist, boolean allShouldBeChecked) {
      boolean keyExists = false;
      for(Object obj : exclusionSet) {
         ChunkCacheKey key = (ChunkCacheKey) obj;

         boolean exists = false;
         for(Object expectedChunk : result) {
            if(obj.equals(expectedChunk)) {
               exists = true;
View Full Code Here

      AssertJUnit.assertEquals(AUTO_BUFFER, metadata.getBufferSize());
   }

   public void testSmallChunkLoading() throws CacheLoaderException {
      DirectoryLoaderAdaptor adaptor = new DirectoryLoaderAdaptor(new InternalDirectoryContractImpl(), INDEX_NAME, AUTO_BUFFER);
      Object loaded = adaptor.load(new ChunkCacheKey(INDEX_NAME, FILE_NAME, 0, AUTO_BUFFER));
      AssertJUnit.assertTrue(loaded instanceof byte[]);
      AssertJUnit.assertEquals(AUTO_BUFFER, ((byte[])loaded).length);
      loaded = adaptor.load(new ChunkCacheKey(INDEX_NAME, FILE_NAME, 5, AUTO_BUFFER));
      AssertJUnit.assertTrue(loaded instanceof byte[]);
      AssertJUnit.assertEquals(AUTO_BUFFER, ((byte[])loaded).length);
      final int lastChunk = (int)(TEST_SIZE / AUTO_BUFFER);
      final long lastChunkSize = TEST_SIZE % AUTO_BUFFER;
      AssertJUnit.assertEquals(9, lastChunkSize);
      loaded = adaptor.load(new ChunkCacheKey(INDEX_NAME, FILE_NAME, lastChunk, AUTO_BUFFER));
      AssertJUnit.assertTrue(loaded instanceof byte[]);
      AssertJUnit.assertEquals(lastChunkSize, ((byte[])loaded).length);
   }
View Full Code Here

      assert cacheLoader.containsKey(new FileListCacheKey(indexName));

      String[] fileNamesFromIndexDir = TestHelper.getFileNamesFromDir(rootDir, indexName);
      for(String fileName : fileNamesFromIndexDir) {
         assert !cacheLoader.containsKey(new FileReadLockKey(indexName, fileName)) : "Failed for " + fileName;
         assert cacheLoader.containsKey(new ChunkCacheKey(indexName, fileName, 0, 1024)) : "Failed for " + fileName;
      }

      assert !cacheLoader.containsKey(new ChunkCacheKey(indexName, "testFile.txt", 0, 1024));
   }
View Full Code Here

   private byte[] getChunkById(FileCacheKey fileKey, int chunkNumber, int bufferSize) {
      if (file.getNumberOfChunks() <= chunkNumber) {
         return new byte[bufferSize];
      }
      ChunkCacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), chunkNumber, bufferSize);
      byte[] readBuffer = (byte[]) chunksCache.get(key);
      if (readBuffer==null) {
         return new byte[bufferSize];
      }
      else if (readBuffer.length == bufferSize) {
View Full Code Here

   /**
    * @param bufferToFlush
    * @param chunkNumber
    */
   private void storeBufferAsChunk(final byte[] bufferToFlush, final int chunkNumber) {
      ChunkCacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), chunkNumber, bufferSize);
      if (trace) log.tracef("Storing segment chunk: %s", key);
      chunksCacheForStorage.put(key, bufferToFlush);
   }
View Full Code Here

         //Next we load the ChunkCacheKey (keys for file contents)
         for (String fileName : listAll) {
            int numChunksInt = figureChunksNumber(fileName);
            for (int i = 0; i < numChunksInt; i++) {
               //Inner loop: we actually have several Chunks per file name
               ChunkCacheKey key = new ChunkCacheKey(indexName, fileName, i, autoChunkSize);
               if (! keysToExclude.contains(key)) {
                  if (keysCollector.add(key)) {
                     if (++collectedKeys >= maxElements) return;
                  }
               }
View Full Code Here

      if (trace) log.tracef("deleting metadata: %s", key);
      final FileMetadata file = (FileMetadata) metadataCache.remove(key);
      final int bufferSize = file.getBufferSize();
      if (file != null) { //during optimization of index a same file could be deleted twice, so you could see a null here
         for (int i = 0; i < file.getNumberOfChunks(); i++) {
            ChunkCacheKey chunkKey = new ChunkCacheKey(indexName, filename, i, bufferSize);
            if (trace) log.tracef("deleting chunk: %s", chunkKey);
            chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES).removeAsync(chunkKey);
         }
      }
      // last operation, as being set as value==0 it prevents others from using it during the
View Full Code Here

         //Next we load the ChunkCacheKey (keys for file contents)
         for (String fileName : listAll) {
            int numChunksInt = figureChunksNumber(fileName);
            for (int i = 0; i < numChunksInt; i++) {
               //Inner loop: we actually have several Chunks per file name
               ChunkCacheKey key = new ChunkCacheKey(indexName, fileName, i, autoChunkSize);
               if (keysToExclude == null || !keysToExclude.contains(key)) {
                  if (keysCollector.add(key)) {
                     if (++collectedKeys >= maxElements) return;
                  }
               }
View Full Code Here

TOP

Related Classes of org.infinispan.lucene.ChunkCacheKey$Externalizer

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.