当前位置: 首页>>代码示例>>Java>>正文


Java Cache.Entry方法代码示例

本文整理汇总了Java中javax.cache.Cache.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.Entry方法的具体用法?Java Cache.Entry怎么用?Java Cache.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.cache.Cache的用法示例。


在下文中一共展示了Cache.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CacheColumnDecisionTreeTrainerInput

import javax.cache.Cache; //导入方法依赖的package包/类
/**
 * Constructs input for {@link ColumnDecisionTreeTrainer}.
 *
 * @param c Cache.
 * @param valuesMapper Function for mapping cache entry to stream used by {@link ColumnDecisionTreeTrainer}.
 * @param labelsMapper Function used for mapping cache value to labels array.
 * @param keyMapper Function used for mapping feature index to the cache key.
 * @param catFeaturesInfo Information about which features are categorical in form of feature index -> number of
 * categories.
 * @param featuresCnt Count of features.
 * @param samplesCnt Count of samples.
 */
// TODO: IGNITE-5724 think about boxing/unboxing
public CacheColumnDecisionTreeTrainerInput(IgniteCache<K, V> c,
    IgniteSupplier<Stream<K>> labelsKeys,
    IgniteFunction<Cache.Entry<K, V>, Stream<IgniteBiTuple<Integer, Double>>> valuesMapper,
    IgniteFunction<V, DoubleStream> labelsMapper,
    IgniteFunction<Integer, Stream<K>> keyMapper,
    Map<Integer, Integer> catFeaturesInfo,
    int featuresCnt, int samplesCnt) {

    cacheName = c.getName();
    this.labelsKeys = labelsKeys;
    this.valuesMapper = valuesMapper;
    this.labelsMapper = labelsMapper;
    this.keyMapper = keyMapper;
    this.catFeaturesInfo = catFeaturesInfo;
    this.samplesCnt = samplesCnt;
    this.featuresCnt = featuresCnt;
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:31,代码来源:CacheColumnDecisionTreeTrainerInput.java

示例2: getBuffer

import javax.cache.Cache; //导入方法依赖的package包/类
/**
 * Gets buffer which holds changes for specific cache made during transaction.
 *
 * @return buffer.
 */
private Collection<Cache.Entry<?, ?>> getBuffer() {
    Map<Object, Object> properties = session.properties();
    Set<String> caches = (Set<String>) properties.get(CACHES_PROPERTY_NAME);
    if (caches == null) {
        properties.put(CACHES_PROPERTY_NAME, caches = new HashSet<>());
        properties.put(BUFFER_PROPERTY_NAME, new HashMap<String, Map>());
    }
    Map<String, Collection<Cache.Entry<?, ?>>> buffer = (Map<String, Collection<Cache.Entry<?, ?>>>) properties.get(BUFFER_PROPERTY_NAME);
    if (caches.add(cacheName)) {
        Collection<Cache.Entry<?, ?>> cacheBuffer = new ArrayList<>();
        buffer.put(cacheName, cacheBuffer);
        return cacheBuffer;
    } else {
        return buffer.get(cacheName);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:22,代码来源:DataCapturerBus.java

示例3: execute

import javax.cache.Cache; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Object execute() throws IgniteException {
    Injection.inject(this, ignite);
    final Map<Object, Cache.Entry<?, ?>> mergedData = new HashMap<>();
    for (Metadata metadata : metadatas) {
        keyValueProvider.fetchAllKeyValues(cacheName, metadata, new IgniteInClosure<Cache.Entry<Object, Object>>() {
            @Override public void apply(Cache.Entry<Object, Object> entry) {
                Object key = entry.getKey();
                if (!mergedData.containsKey(key)) {
                    mergedData.put(key, new CacheEntryImpl<>(key, entry.getValue()));
                }
            }
        });
    }
    keyValueProvider.write(idSequencer.getNextId(), Collections.singletonMap(cacheName, mergedData.values()), destination);
    return null;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:18,代码来源:MergeTablesJob.java

示例4: process

import javax.cache.Cache; //导入方法依赖的package包/类
@Override public void process(Map<?, ?> entries) {
    if (!running) {
        return;
    }
    long txId = idSequencer.getNextId();
    Collection<Cache.Entry<?, ?>> updates = txDataToCacheUpdates(entries);

    producer.writeTransaction(txId, Collections.singletonMap(config.getCacheName(), updates));
    stats.recordOperationStartTime(txId, System.currentTimeMillis());
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:11,代码来源:KafkaWritingEntryProcessor.java

示例5: apply

import javax.cache.Cache; //导入方法依赖的package包/类
@Override
public TransactionScope apply(Long transactionId, Map<String, Collection<Cache.Entry<?, ?>>> updates) {
    List<Map.Entry<String, List>> scope = new ArrayList<>(updates.size());

    for (Map.Entry<String, Collection<Cache.Entry<?, ?>>> cacheUpdate : updates.entrySet()) {
        List keys = cacheUpdate
            .getValue()
            .stream()
            .map(Cache.Entry::getKey)
            .collect(Collectors.toList());
        scope.add(new AbstractMap.SimpleImmutableEntry<String, List>(cacheUpdate.getKey(), keys));
    }
    return new TransactionScope(transactionId, scope);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:15,代码来源:DefaultKeyTransformer.java

示例6: txDataToCacheUpdates

import javax.cache.Cache; //导入方法依赖的package包/类
private static Collection<Cache.Entry<?, ?>> txDataToCacheUpdates(Map<?, ?> txDataEntries) {
    Collection<Cache.Entry<?, ?>> updates = new ArrayList<>();

    for (Object value : txDataEntries.values()) {
        TransactionData txData = (TransactionData)value;
        AccountTransactionKey txKey = new AccountTransactionKey(txData.getTransactionId(),
            txData.getPartition());
        AccountTransaction accountTx = new AccountTransaction(
            txKey,
            txData.getFromAccountId(),
            txData.getToAccountId(),
            txData.getMoneyAmount()
        );
        AccountKey toAccountKey = new AccountKey(txData.getToAccountId(), txData.getPartition());
        AccountKey fromAccountKey = new AccountKey(txData.getFromAccountId(), txData.getPartition());
        Account toAccount = new Account(toAccountKey);
        Account fromAccount = new Account(fromAccountKey);
        long timestamp = System.currentTimeMillis();

        fromAccount.addTransaction(timestamp, txKey);
        toAccount.addTransaction(timestamp, txKey);

        updates.add(new CacheEntryImpl<>(txKey, accountTx));
        updates.add(new CacheEntryImpl<>(toAccountKey, toAccount));
        updates.add(new CacheEntryImpl<>(fromAccountKey, fromAccount));
    }
    return updates;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:29,代码来源:KafkaWritingEntryProcessor.java

示例7: writeTransaction

import javax.cache.Cache; //导入方法依赖的package包/类
public Future<RecordMetadata> writeTransaction(long transactionId, Map<String,
        Collection<Cache.Entry<?, ?>>> updates) throws CacheWriterException {
    try {
        return send(localTopic, partitions, transactionId, updates);
    }
    catch (Exception e) {
        throw new CacheWriterException(e);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:10,代码来源:LocalKafkaProducer.java

示例8: convertToMessage

import javax.cache.Cache; //导入方法依赖的package包/类
private Message convertToMessage(long transactionId, Map<String, Collection<Cache.Entry<?, ?>>> updates) {
    Message result = new Message(transactionId);
    for (Map.Entry<String, Collection<Cache.Entry<?, ?>>> cacheToUpdates : updates.entrySet()) {
        String cacheName = cacheToUpdates.getKey();
        for (Cache.Entry<?, ?> cacheUpdates : cacheToUpdates.getValue()) {
            result.metadata.addRow(cacheName, cacheUpdates.getKey());
            result.values.add(cacheUpdates.getValue());
        }
    }
    return result;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:12,代码来源:TransactionalKafkaProducer.java

示例9: writeAll

import javax.cache.Cache; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeAll(
    Collection<Cache.Entry<? extends K, ? extends V>> entries) throws CacheWriterException {
    putAll((Collection)entries);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:6,代码来源:ActiveCacheStore.java

示例10: getEntriesIterator

import javax.cache.Cache; //导入方法依赖的package包/类
public Iterator<Cache.Entry<Integer,SpatialPartition>>
        getEntriesIterator() {
    return spatialPartitionsData.iterator();
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:5,代码来源:MemorySpatialIndexSegment.java

示例11: writeKV

import javax.cache.Cache; //导入方法依赖的package包/类
/**
 * Writes key-value to persistent store.
 */
protected void writeKV(Object key, Object value, String cacheName, Metadata metadata) {
    Collection<Cache.Entry<?, ?>> entries = Collections.<Cache.Entry<?, ?>>singletonList(new CacheEntryImpl<>(key, value));
    resource.getKVProvider().write(resource.nextTransactionId(), Collections.singletonMap(cacheName, entries), metadata);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:8,代码来源:BaseCacheStoreTest.java

示例12: notifyListeners

import javax.cache.Cache; //导入方法依赖的package包/类
private void notifyListeners(long transactionId, Map<String, Collection<Cache.Entry<?, ?>>> updates) {
    for (ModificationListener listener : allListeners) {
        listener.handle(transactionId, updates);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:6,代码来源:DataCapturerBus.java

示例13: write

import javax.cache.Cache; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void write(Cache.Entry<? extends K, ? extends V> entry) throws CacheWriterException {
    put(entry.getKey(), entry.getValue());
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:5,代码来源:ActiveCacheStore.java

示例14: fetchAllKeyValues

import javax.cache.Cache; //导入方法依赖的package包/类
@Override
public void fetchAllKeyValues(String cacheName, Metadata metadata, IgniteInClosure<Cache.Entry<Object, Object>> action) {
    //do nothing;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:5,代码来源:QuasiKafkaKeyValueProvider.java

示例15: writeTransaction

import javax.cache.Cache; //导入方法依赖的package包/类
@Override public void writeTransaction(long transactionId,
    Map<String, Collection<Cache.Entry<?, ?>>> updates) throws CacheWriterException {
    producer.writeTransaction(transactionId, updates);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:5,代码来源:LocalKafkaKVListener.java


注:本文中的javax.cache.Cache.Entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。