test_class.declarator: dataStorage = new PartitionDataStorage(-1)
test_class.modifier: private
test_class.original_string: private PartitionDataStorage dataStorage = new PartitionDataStorage(-1);
test_class.type: PartitionDataStorage
test_class.var_name: dataStorage
test_class.file: modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/util/PartitionDataStorageTest.java
test_class.identifier: PartitionDataStorageTest
test_case.body: @Test
      public void testComputeDataIfAbsent() {
          AtomicLong cnt = new AtomicLong();
  
          for (int i = 0; i < 10; i++) {
              Integer res = (Integer) dataStorage.computeDataIfAbsent(0, () -> {
                  cnt.incrementAndGet();
  
                  return 42;
              });
  
              assertEquals(42, res.intValue());
          }
  
          assertEquals(1, cnt.intValue());
      }
test_case.class_method_signature: PartitionDataStorageTest.testComputeDataIfAbsent()
test_case.full_signature: @Test public void testComputeDataIfAbsent()
test_case.identifier: testComputeDataIfAbsent
test_case.invocations: computeDataIfAbsent incrementAndGet assertEquals intValue assertEquals intValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testComputeDataIfAbsent()
focal_class.declarator: storage = new ConcurrentHashMap<>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<Integer, ObjectWithUsageStat> storage = new ConcurrentHashMap<>();
focal_class.type: ConcurrentMap<Integer, ObjectWithUsageStat>
focal_class.var_name: storage
focal_class.declarator: locks = new ConcurrentHashMap<>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<Integer, Lock> locks = new ConcurrentHashMap<>();
focal_class.type: ConcurrentMap<Integer, Lock>
focal_class.var_name: locks
focal_class.declarator: executor = new ScheduledThreadPoolExecutor(1)
focal_class.modifier: private final
focal_class.original_string: private final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
focal_class.type: ScheduledThreadPoolExecutor
focal_class.var_name: executor
focal_class.declarator: ttl
focal_class.modifier: private final
focal_class.original_string: private final long ttl;
focal_class.type: long
focal_class.var_name: ttl
focal_class.file: modules/ml/src/main/java/org/apache/ignite/ml/dataset/impl/cache/util/PartitionDataStorage.java
focal_class.identifier: PartitionDataStorage
focal_class.interfaces: implements AutoCloseable
focal_class.class_method_signature: PartitionDataStorage.PartitionDataStorage(long ttl)
focal_class.full_signature: public  PartitionDataStorage(long ttl)
focal_class.identifier: PartitionDataStorage
focal_class.modifiers: public
focal_class.parameters: (long ttl)
focal_class.signature:  PartitionDataStorage(long ttl)
focal_class.class_method_signature: PartitionDataStorage.computeDataIfAbsent(int part, Supplier<D> supplier)
focal_class.full_signature:  D computeDataIfAbsent(int part, Supplier<D> supplier)
focal_class.identifier: computeDataIfAbsent
focal_class.parameters: (int part, Supplier<D> supplier)
focal_class.return: D
focal_class.signature: D computeDataIfAbsent(int part, Supplier<D> supplier)
focal_class.class_method_signature: PartitionDataStorage.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_method.body: <D> D computeDataIfAbsent(int part, Supplier<D> supplier) {
          ObjectWithUsageStat objWithStat = storage.get(part);
  
          if (objWithStat == null) {
              Lock lock = locks.computeIfAbsent(part, p -> new ReentrantLock());
  
              lock.lock();
              try {
                  objWithStat = storage.get(part);
                  if (objWithStat == null) {
                      objWithStat = new ObjectWithUsageStat(supplier.get());
                      storage.put(part, objWithStat);
                      if (ttl > -1)
                          executor.schedule(new Cleaner(part), ttl, TimeUnit.MILLISECONDS);
                  }
              }
              finally {
                  lock.unlock();
              }
          }
  
          objWithStat.updateLastAccessTime();
  
          return (D)objWithStat.data;
      }
focal_method.class_method_signature: PartitionDataStorage.computeDataIfAbsent(int part, Supplier<D> supplier)
focal_method.full_signature:  D computeDataIfAbsent(int part, Supplier<D> supplier)
focal_method.identifier: computeDataIfAbsent
focal_method.invocations: get computeIfAbsent lock get get put schedule unlock updateLastAccessTime
focal_method.parameters: (int part, Supplier<D> supplier)
focal_method.return: D
focal_method.signature: D computeDataIfAbsent(int part, Supplier<D> supplier)