Class CacheAdapter<K,V>

java.lang.Object
org.gridgain.ignite.migrationtools.adapter.internal.CacheAdapter<K,V>
Type Parameters:
K - Key type.
V - Value type.

public class CacheAdapter<K,V> extends Object
Provides basic methods to interact with an Ignite 3 table in a similar fashion as an Ignite 2.
  • Constructor Details

    • CacheAdapter

      public CacheAdapter(ClientAdapter clientAdapter, org.apache.ignite3.sql.IgniteSql sql, org.apache.ignite3.internal.client.table.ClientTable clientTable, org.apache.ignite3.table.mapper.Mapper<K> keyMapper, org.apache.ignite3.table.mapper.Mapper<V> valueMapper, Supplier<org.apache.ignite3.tx.Transaction> txSupplier, CacheTableReference cacheRef)
      Constructor.
      Parameters:
      clientAdapter - Client Adapter.
      sql - IgniteSql API.
      clientTable - ClientTable.
      keyMapper - Mapper for the keys.
      valueMapper - Mapper for the values.
      txSupplier - Supplier for the current transaction.
      cacheRef - CacheTableReference.
  • Method Details

    • getClientTable

      public org.apache.ignite3.internal.client.table.ClientTable getClientTable()
      Gets the ClientTable.
      Returns:
      The ClientTable for this adapted cache.
    • getSql

      public org.apache.ignite3.sql.IgniteSql getSql()
      Returns the Ignite Sql API used by this adapted cache.
      Returns:
      IgniteSql API.
    • getKeyMapper

      public org.apache.ignite3.table.mapper.Mapper<K> getKeyMapper()
      Gets the mapper for the keys used by this adapter.
      Returns:
      The Key Mapper.
    • getValueMapper

      public org.apache.ignite3.table.mapper.Mapper<V> getValueMapper()
      Gets the mapper for the values used by this adapter.
      Returns:
      The Value Mapper.
    • isInTransaction

      public boolean isInTransaction()
      Returns:
      Whether or not there's an active transaction.
    • getName

      public String getName()
      Gets the name of this cache.
      Returns:
      Name of this cache.
    • get

      public CompletableFuture<V> get(K key)
      Gets a value associated with a given key. Checkout KeyValueView.get(Transaction, Object).
      Parameters:
      key - Key whose value is to be returned. The key cannot be null.
      Returns:
      Value or null, if it does not exist.
    • getAll

      public CompletableFuture<Map<K,V>> getAll(Set<? extends K> keys) throws org.apache.ignite.transactions.TransactionException
      Get values associated with the given keys. Checkout KeyValueView.getAllAsync(Transaction, Collection).
      Parameters:
      keys - Keys whose values are to be returned. The keys cannot be null.
      Returns:
      Values associated with given keys. If a requested key does not exist, it will have no corresponding entry in the returned map.
      Throws:
      org.apache.ignite.transactions.TransactionException
    • containsKey

      public CompletableFuture<Boolean> containsKey(K key) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • containsKeys

      public CompletableFuture<Boolean> containsKeys(Set<? extends K> keys) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • put

      public CompletableFuture<Void> put(K key, V val) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • getAndPut

      public CompletableFuture<V> getAndPut(K key, V val) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • getAndPutIfAbsent

      public CompletableFuture<V> getAndPutIfAbsent(K key, V val) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • putAll

      public CompletableFuture<Void> putAll(Map<? extends K,? extends V> map) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • putIfAbsent

      public CompletableFuture<Boolean> putIfAbsent(K key, V val)
    • remove

      public CompletableFuture<Boolean> remove(K key) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • remove

      public CompletableFuture<Boolean> remove(K key, V oldVal) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • getAndRemove

      public CompletableFuture<V> getAndRemove(K key) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • replace

      public CompletableFuture<Boolean> replace(K key, V oldVal, V newVal) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • replace

      public CompletableFuture<Boolean> replace(K key, V val) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • getAndReplace

      public CompletableFuture<V> getAndReplace(K key, V val)
    • removeAll

      public CompletableFuture<Void> removeAll()
    • removeAll

      public CompletableFuture<Void> removeAll(Set<? extends K> keys) throws org.apache.ignite.transactions.TransactionException
      Throws:
      org.apache.ignite.transactions.TransactionException
    • clear

      public CompletableFuture<Void> clear()
    • clear

      public CompletableFuture<Void> clear(K key)
    • clearAll

      public CompletableFuture<Void> clearAll(Set<? extends K> keys)
    • destroy

      public CompletableFuture<Void> destroy()
    • size

      public CompletableFuture<Long> size(org.apache.ignite.cache.CachePeekMode... peekModes)
    • query

      public <R> CompletableFuture<org.apache.ignite.cache.query.QueryCursor<R>> query(org.apache.ignite.cache.query.Query<R> qry)
      Provides support for queries.
      Type Parameters:
      R - Query Result type.
      Parameters:
      qry - Query.
      Returns:
      The query result as a future.
    • query

      public org.apache.ignite.cache.query.FieldsQueryCursor<List<?>> query(org.apache.ignite.cache.query.SqlFieldsQuery qry)
    • query

      public CompletableFuture<org.apache.ignite.cache.query.QueryCursor<javax.cache.Cache.Entry<K,V>>> query(org.apache.ignite.cache.query.ScanQuery<K,V> query)
      Provides support for ScanQueries using the SQL API.
      Parameters:
      query - ScanQuery.
      Returns:
      A future holding the query result.