コード例 #1
0
 @Override
 public void clear() throws StorageException {
   final StubIndexImpl stubIndex = StubIndexImpl.getInstanceOrInvalidate();
   final Collection<StubIndexKey> allStubIndexKeys =
       stubIndex != null
           ? stubIndex.getAllStubIndexKeys()
           : Collections.<StubIndexKey>emptyList();
   try {
     for (StubIndexKey key : allStubIndexKeys) {
       //noinspection ConstantConditions
       stubIndex.getWriteLock(key).lock();
     }
     getWriteLock().lock();
     if (stubIndex != null) {
       stubIndex.clearAllIndices();
     }
     super.clear();
   } finally {
     getWriteLock().unlock();
     for (StubIndexKey key : allStubIndexKeys) {
       //noinspection ConstantConditions
       stubIndex.getWriteLock(key).unlock();
     }
   }
 }
コード例 #2
0
ファイル: StringIndex.java プロジェクト: novokrest/JBIDEA
 public StringIndex(
     final IndexStorage<String, String> storage,
     final Factory<PersistentHashMap<Integer, Collection<String>>> factory)
     throws IOException {
   myIndex = new MapReduceIndex<String, String, PathContentPair>(null, new Indexer(), storage);
   myIndex.setInputIdToDataKeysIndex(factory);
 }
コード例 #3
0
 @Override
 public void updateWithMap(
     final int inputId,
     final Map<K, TIntArrayList> newData,
     Callable<Collection<K>> oldKeysGetter)
     throws StorageException {
   super.updateWithMap(inputId, newData, oldKeysGetter);
 }
コード例 #4
0
 @Override
 public void dispose() {
   try {
     super.dispose();
   } finally {
     getStubIndex().dispose();
   }
 }
コード例 #5
0
 @Override
 public void flush() throws StorageException {
   final StubIndexImpl stubIndex = getStubIndex();
   try {
     for (StubIndexKey key : stubIndex.getAllStubIndexKeys()) {
       stubIndex.flush(key);
     }
   } finally {
     super.flush();
   }
 }
コード例 #6
0
    @Override
    protected void updateWithMap(
        final int inputId,
        @NotNull final Map<Integer, SerializedStubTree> newData,
        @NotNull Callable<Collection<Integer>> oldKeysGetter)
        throws StorageException {

      checkNameStorage();
      final Map<StubIndexKey, Map<Object, int[]>> newStubTree = getStubTree(newData);

      final StubIndexImpl stubIndex = getStubIndex();
      final Collection<StubIndexKey> allStubIndices = stubIndex.getAllStubIndexKeys();
      try {
        // first write-lock affected stub indices to avoid deadlocks
        for (StubIndexKey key : allStubIndices) {
          stubIndex.getWriteLock(key).lock();
        }

        try {
          getWriteLock().lock();

          final Map<Integer, SerializedStubTree> oldData = readOldData(inputId);
          final Map<StubIndexKey, Map<Object, int[]>> oldStubTree = getStubTree(oldData);

          super.updateWithMap(inputId, newData, oldKeysGetter);

          updateStubIndices(
              getAffectedIndices(oldStubTree, newStubTree), inputId, oldStubTree, newStubTree);
        } finally {
          getWriteLock().unlock();
        }
      } finally {
        for (StubIndexKey key : allStubIndices) {
          stubIndex.getWriteLock(key).unlock();
        }
      }
    }
コード例 #7
0
ファイル: StringIndex.java プロジェクト: novokrest/JBIDEA
 public void update(final String path, @Nullable String content, @Nullable String oldContent)
     throws StorageException {
   myIndex.update(path.hashCode(), toInput(path, content)).compute();
 }
コード例 #8
0
ファイル: StringIndex.java プロジェクト: novokrest/JBIDEA
 public List<String> getFilesByWord(@NotNull String word) throws StorageException {
   return myIndex.getData(word).toValueList();
 }