
io.milvus.orm.iterator.IteratorCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of milvus-sdk-java Show documentation
Show all versions of milvus-sdk-java Show documentation
Java SDK for Milvus, a distributed high-performance vector database.
package io.milvus.orm.iterator;
import io.milvus.response.QueryResultsWrapper;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import static io.milvus.param.Constant.NO_CACHE_ID;
public class IteratorCache {
private final AtomicInteger cacheId = new AtomicInteger(0);
private final Map> cacheMap = new ConcurrentHashMap<>();
public int cache(int cacheId, List result) {
if (cacheId == NO_CACHE_ID) {
cacheId = this.cacheId.incrementAndGet();
}
cacheMap.put(cacheId, result);
return cacheId;
}
public List fetchCache(int cacheId) {
return cacheMap.getOrDefault(cacheId, null);
}
public void releaseCache(int cacheId) {
cacheMap.remove(cacheId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy