Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • When auto caching is disabled

    Code Block
    languagejava
    titleAuto caching is disabled
    TableEnvironment tEnv = ...
    Table t1 = ...
    Table t2 = t1.cache()
    ...
    tEnv.execute() // t1 is cached.
    Table t3 = t1.select(...) // cache will NOT be used. <----- difference
    Table t4 = t2.select(...) // cache will be used.
    ...
    // The following two lines of code are equivalent
    t1.invalidateCache() // cache will be released
    t2.invalidateCache() // cache will be released
    ...
    // The following two lines of code are equivalent.
    t1.print() // cache will not be recreated <-------- different
    t2.print() // cache will be recreated


...

Code Block
languagejava
titleSemantic API Option 1
// Do not return anything
void cache();
// Alternatively, return the original table for chaining purpose.
Table cache();
 
// Physically uncache the table to release resource
void uncache();
 
// To explicitly ignore cache, not part of this proposal but in the future
Table hint(“ingoreCache”)

...

  • Side effect: a table may be cached / uncached in a method invocation, while the caller does not know about this.

    Code Block
    languagejava
    titleSemantic Side Effect Option 1
    {
      Table t  = …
       // cache the table
       t.cache(); 
       ...
       // The cache may be released in foo()
       foo(t);
       ...
       // cache is no longer available
       t.bar() 
    }
     
     
    void foo(Table t) {
       // cache the table
       t.cache();   
       ….
       // Physically drop the table
       t.uncache(); 
    }


...

Code Block
languagejava
titleSemantic API Option 2
// Return CachedTable
CachedTable cache();
 
public interface CachedTable extends Table {
  // Physically uncache the table to release resource
  void uncache();
}

...

Code Block
languagejava
titleSemantic API Option 3
// Return a CacheHandle
CacheHandle cache();
 
public interface CacheHandle {
  // Physically release cache resource
  void release();
}

...

Code Block
languagejava
titleSemantic Option 23
TableEnvironment tEnv = ...
Table t = …
...
// cache the table
CacheHandle handle1 = t.cache();
CacheHandle handle2 = t.cache;
…
// Assume some execution physically created the cache.
tEnv.execute()
...
// Optimizer decide whether cache will be used.
t.foo();
...
// Release the first handle, cache will not be released because handle 2 has not been released
handle1.release();
// Release the second handle, the cache will be released because all the cache handle have been released.
handle2.release();

...