Java Code Examples for javax.cache.processor.MutableEntry#remove()

The following examples show how to use javax.cache.processor.MutableEntry#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheContinuousQueryRandomOperationsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> e, Object... args) {
    if (skipModify)
        return null;

    oldVal = e.getValue();

    Object old = retOld ? e.getValue() : null;

    if (val != null)
        e.setValue(val);
    else
        e.remove();

    return old;
}
 
Example 2
Source File: GridAbstractCacheInterceptorRebalanceTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Integer process(
    final MutableEntry<Integer, Integer> entry,
    final Object... arguments
) throws EntryProcessorException {
    entry.remove();

    return null;
}
 
Example 3
Source File: IgniteSqlNotNullConstraintTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Integer, Person> entry,
    Object... objects) throws EntryProcessorException {

    if (value == null)
        entry.remove();
    else
        entry.setValue(value);

    return null;
}
 
Example 4
Source File: MvccRepeatableReadBulkOpsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public R process(MutableEntry<K, V> entry,
    Object... arguments) throws EntryProcessorException {
    entry.remove();

    return null;
}
 
Example 5
Source File: IgniteCacheRandomOperationBenchmark.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> entry, Object... arguments) {
    Object oldVal = entry.getValue();

    entry.remove();

    return oldVal;
}
 
Example 6
Source File: CacheInterceptorPartitionCounterRandomOperationsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> e, Object... args) {
    Object old = retOld ? e.getValue() : null;

    if (val != null)
        e.setValue(val);
    else
        e.remove();

    return old;
}
 
Example 7
Source File: RemoveEntryProcessor.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public T process(MutableEntry<K, V> entry, Object... arguments) {
    T result = null;
    if (assertExists) {
        assertTrue(entry.exists());
        result = (T)entry.getValue();
    }
    entry.remove();
    assertFalse(entry.exists());

    return result;
}
 
Example 8
Source File: TransformingCacheProxy.java    From cache2k with Apache License 2.0 5 votes vote down vote up
private MutableEntry<K, V> wrapMutableEntry(final MutableEntry<K0, V0> entry) {
  return new MutableEntry<K, V>() {
    @Override
    public boolean exists() {
      return entry.exists();
    }

    @Override
    public void remove() {
      entry.remove();
    }

    @Override
    public void setValue(V value) {
      entry.setValue(valueTransformer.compact(value));
    }

    @Override
    public K getKey() {
      return keyTransformer.expand(entry.getKey());
    }

    @Override
    public V getValue() {
      return valueTransformer.expand(entry.getValue());
    }

    @Override
    public <T> T unwrap(Class<T> clazz) {
      return entry.unwrap(clazz);
    }
  };
}
 
Example 9
Source File: HadoopJobTracker.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Void process(MutableEntry<HadoopJobId, HadoopJobMetadata> e, Object... args) {
    HadoopJobMetadata val = apply(e.getValue());

    if (val != null)
        e.setValue(val);
    else
        e.remove();

    return null;
}
 
Example 10
Source File: GridCacheAbstractMetricsSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
@Override public Object process(
        MutableEntry<Integer, Integer> entry,
        Object... arguments
) throws EntryProcessorException {

    entry.remove();

    return null;
}
 
Example 11
Source File: CacheInterceptorPartitionCounterLocalSanityTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> e, Object... args) {
    Object old = retOld ? e.getValue() : null;

    if (val != null)
        e.setValue(val);
    else
        e.remove();

    return old;
}
 
Example 12
Source File: RemoveEntryProcessor.java    From blazingcache with Apache License 2.0 5 votes vote down vote up
@Override
public T process(MutableEntry<K, V> entry, Object... arguments) {
    T result = null;
    if (assertExists) {
        assertTrue(entry.exists());
        result = (T)entry.getValue();
    }
    entry.remove();
    assertFalse(entry.exists());

    return result;
}
 
Example 13
Source File: CacheSerializableTransactionsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments) {
    Integer val = entry.getValue();

    if (newVal == null)
        entry.remove();
    else
        entry.setValue(newVal);

    return val;
}
 
Example 14
Source File: RemoveEntryProcessor.java    From ehcache3 with Apache License 2.0 4 votes vote down vote up
@Override
public Void process(MutableEntry<Integer, String> entry, Object... arguments) {
    entry.remove();
    return null;
}
 
Example 15
Source File: TouchyJCacheAdapter.java    From cache2k with Apache License 2.0 4 votes vote down vote up
private <T> javax.cache.processor.EntryProcessor<K,V,T> wrapEntryProcessor(final javax.cache.processor.EntryProcessor<K,V,T> ep) {
  if (ep == null) {
    throw new NullPointerException("processor is null");
  }
  return new javax.cache.processor.EntryProcessor<K,V, T>() {
    boolean freshOrJustLoaded = false;
    @Override
    public T process(final MutableEntry<K, V> e0, Object... _args) throws EntryProcessorException {
      MutableEntry<K, V> me = new MutableEntry<K, V>() {

        @Override
        public boolean exists() {
          return e0.exists();
        }

        @Override
        public void remove() {
          e0.remove();
        }

        @Override
        public void setValue(V value) {
          checkNullValue(value);
          freshOrJustLoaded = true;
          e0.setValue(value);
        }

        @Override
        public K getKey() {
          return e0.getKey();
        }

        @Override
        public V getValue() {
          boolean _doNotCountCacheAccessIfEntryGetsLoaded = !exists();
          boolean _doNotCountCacheAccessIfEntryIsFresh = freshOrJustLoaded;
          if (_doNotCountCacheAccessIfEntryIsFresh || _doNotCountCacheAccessIfEntryGetsLoaded) {
            if (!cache.readThrough && !exists()) {
              return null;
            }
            freshOrJustLoaded = true;
            return e0.getValue();
          }
          return returnValue(e0.getKey(), e0.getValue());
        }

        @Override
        public <X> X unwrap(Class<X> clazz) {
          return null;
        }
      };
      return ep.process(me, _args);
    }
  };
}
 
Example 16
Source File: GridCacheAbstractTransformWriteThroughSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
@Override public Void process(MutableEntry<String, Integer> e, Object... args) {
    e.remove();

    return null;
}
 
Example 17
Source File: DmlStatementsProcessor.java    From ignite with Apache License 2.0 4 votes vote down vote up
@Override public void apply(MutableEntry<Object, Object> e) {
    e.remove();
}
 
Example 18
Source File: DmlStatementsProcessor.java    From ignite with Apache License 2.0 4 votes vote down vote up
@Override public void apply(MutableEntry<Object, Object> e) {
    e.remove();
}
 
Example 19
Source File: GridCacheAbstractFullApiSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
    assertNotNull(e.getKey());

    Integer old = e.getValue();

    e.remove();

    return String.valueOf(old);
}
 
Example 20
Source File: IgniteCacheConfigVariationsFullApiTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override public Object process(MutableEntry<Object, Object> e, Object... args) {
    assertNotNull(e.getKey());

    Object old = e.getValue();

    e.remove();

    return old;
}