本文整理汇总了Java中org.apache.ignite.IgniteCache.get方法的典型用法代码示例。如果您正苦于以下问题:Java IgniteCache.get方法的具体用法?Java IgniteCache.get怎么用?Java IgniteCache.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.IgniteCache
的用法示例。
在下文中一共展示了IgniteCache.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReference
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
public static <V> Reference<V> getReference(Ignite ignite, final String name, boolean create) {
final IgniteCache<Object, Object> cache = create ? ignite.getOrCreateCache(NAME) : ignite.cache(NAME);
return new Reference<V>() {
@Override
public V get() {
return cache == null ? null : (V) cache.get(name);
}
@Override
public void set(V value) {
if (value == null) {
cache.remove(name);
} else {
cache.put(name, value);
}
}
};
}
示例2: queryAccountBalance
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/** */
private static double queryAccountBalance(Account account,
IgniteCache<AccountTransactionKey, AccountTransaction> accountTxCache) {
double result = 0;
int accountId = account.getAccountKey().getAccountId();
for (AccountTransactionKey txKey : account.getTransactionKeys().values()) {
AccountTransaction transaction = accountTxCache.get(txKey);
if (accountId == transaction.getFromAccountId()) {
result -= transaction.getMoneyAmount();
}
else {
result += transaction.getMoneyAmount();
}
}
return result;
}
示例3: queryAccountBalance
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
private static double queryAccountBalance(
Account account,
IgniteCache<AccountTransactionKey, AccountTransaction> accountTxCache
) {
double result = 0;
int accountId = account.getAccountKey().getAccountId();
for (AccountTransactionKey txKey : account.getTransactionKeys().values()) {
AccountTransaction transaction = accountTxCache.get(txKey);
if (accountId == transaction.getFromAccountId()) {
result -= transaction.getMoneyAmount();
}
else {
result += transaction.getMoneyAmount();
}
}
return result;
}
示例4: extractEntityTuple
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public Map<String, Object> extractEntityTuple(Session session, EntityKey key) {
SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) session.getSessionFactory();
IgniteCache<Object, BinaryObject> cache = getEntityCache( sessionFactory, key.getMetadata() );
Object cacheKey = getProvider( sessionFactory ).createKeyObject( key );
Map<String, Object> result = new HashMap<>();
BinaryObject po = cache.get( cacheKey );
TupleSnapshot snapshot = new IgniteTupleSnapshot( cacheKey, po, key.getMetadata() );
for ( String fieldName : snapshot.getColumnNames() ) {
result.put( fieldName, snapshot.get( fieldName ) );
}
return result;
}
示例5: loadCache
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void loadCache(IgniteBiInClosure<Integer, SpatialPartition>
igniteBiInClosure, @Nullable Object... objects)
throws CacheLoaderException {
IgniteCache<Integer,SpatialPartition> cache =
(IgniteCache<Integer,SpatialPartition>) objects[0];
Integer key = (Integer) objects[1];
ArrayList<Long> values = (ArrayList<Long>) objects[2];
SpatialPartition curr_value = cache.get(key);
if(curr_value == null)
curr_value = new SpatialPartition(values);
else
curr_value.mergeData(values);
cache.put(key, curr_value);
}
示例6: loadPerson
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test(dataProvider = DataProviders.KV_META_PROVIDER)
public void loadPerson(KeyValueAndMetadata kvMeta, String dbMode) throws SQLException {
JDBCUtil.setDBMode(dataSource, dbMode);
JDBCUtil.insertIntoDB(dataSource, kvMeta);
IgniteCache<Integer, Object> cache = ignite().cache(kvMeta.getCacheName());
Object result = cache.get(kvMeta.getKey());
Object expected = kvMeta.getUnwrappedValue();
assertEquals(result, expected);
}
示例7: testWriteThroughAndReadThrough
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test(dataProvider = PRIMITIVES_CACHE_NAMES_PROVIDER)
public void testWriteThroughAndReadThrough(String cacheName) throws Exception {
PrimitivesHolder expected = DataProviders.PH_1;
IgniteCache<Integer, PrimitivesHolder> cache = ignite().cache(cacheName);
cache.put(1, expected);
awaitTransactions();
cache.withSkipStore().clear(1);
PrimitivesHolder actual = cache.get(1);
Assert.assertEquals(actual, expected);
}
示例8: process
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void process(IgniteCache cache, Map<?, ?> entries) {
for (Map.Entry<?, ?> entry : entries.entrySet()) {
cache.get(entry.getKey());
}
}
示例9: getTuple
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public Tuple getTuple(EntityKey key, OperationContext operationContext) {
IgniteCache<Object, BinaryObject> entityCache = provider.getEntityCache( key.getMetadata() );
if ( entityCache == null ) {
throw log.cacheNotFound( key.getMetadata().getTable() );
}
Object id = provider.createKeyObject( key );
BinaryObject po = entityCache.get( id );
if ( po != null ) {
return new Tuple( new IgniteTupleSnapshot( id, po, key.getMetadata() ), SnapshotType.UPDATE );
}
else {
return null;
}
}
示例10: nextValue
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public Number nextValue(NextValueRequest request) {
Long result = null;
switch ( request.getKey().getMetadata().getType() ) {
case TABLE:
IgniteCache<String, Long> cache = provider.getIdSourceCache( request.getKey().getMetadata() );
String idSourceKey = request.getKey().getColumnValue();
Long previousValue = cache.get( idSourceKey );
if ( previousValue == null ) {
result = (long) request.getInitialValue();
if ( !cache.putIfAbsent( idSourceKey, result ) ) {
previousValue = (long) request.getInitialValue();
}
}
if ( previousValue != null ) {
while ( true ) {
result = previousValue + request.getIncrement();
if ( cache.replace( idSourceKey, previousValue, result ) ) {
break;
}
else {
previousValue = cache.get( idSourceKey );
}
}
}
break;
case SEQUENCE:
IgniteAtomicSequence seq = provider.atomicSequence( request.getKey().getMetadata().getName(), request.getInitialValue(), false );
result = seq.getAndAdd( request.getIncrement() );
break;
}
return result;
}
示例11: find
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
public static <K> Map<K, BinaryObject> find(SessionFactory sessionFactory, Class<?> class1, K... ids) {
OgmEntityPersister entityPersister = (OgmEntityPersister) ( (SessionFactoryImplementor) sessionFactory ).getEntityPersister( Poem.class.getName() );
IgniteCache<K, BinaryObject> entityCache = getEntityCache( sessionFactory, entityPersister.getEntityKeyMetadata() );
Map<K, BinaryObject> missingIds = new HashMap<>();
for ( K id : ids ) {
BinaryObject binaryObject = entityCache.get( id );
if ( binaryObject != null ) {
missingIds.put( id, binaryObject );
}
}
return missingIds;
}
示例12: loadCache
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void loadCache(IgniteBiInClosure<String, ArrayList<Long>>
igniteBiInClosure, @Nullable Object... objects) throws CacheLoaderException {
IgniteCache<String,ArrayList<Long>> cache =
(IgniteCache<String,ArrayList<Long>>) objects[0];
String key = (String) objects[1];
ArrayList<Long> values = (ArrayList<Long>) objects[2];
ArrayList<Long> curr_value = cache.get(key);
if(curr_value == null)
curr_value = new ArrayList<Long>();
curr_value.addAll(values);
cache.put(key, curr_value);
}