[Swift-devel] turning off Swift's data caching

Justin M Wozniak wozniak at mcs.anl.gov
Mon Apr 22 13:40:30 CDT 2013


Normally, Swift variables are write-once.  Swift assumes the contents of 
a file are constant and is allowed to cache.

However, you can do this in Swift/T.  Swift/T does not stage files, so 
there is no cache, and there are new constructs for handling external 
data dependencies.

The following script launches compute() every 10 seconds if data.txt has 
changed.  Touch done.txt to exit.

import io;
import files;
import sys;

app compute(file f) {
   "/bin/echo" "compute on:" f;
}

(int o) check_done(int i) {
   i =>
   if (file_exists("done.txt")) { o = 1; }
   else                         { o = 0; }
}

global const int interval = 10;

main {
   int i, done;
   for (i = 0, done = 0; done == 0; i = next_i, done = check_done(i)) {
     int next_i;
     i => {
       if (file_mtime("data.txt") > clock_seconds()-interval) {
         compute(input_file("data.txt"));
       }
       sleep(itof(interval)) => next_i = 1;
     }
   }
}


On 04/21/2013 12:26 AM, Ketan Maheshwari wrote:
> Hi,
>
> I am trying to mimic a scenario where an external process is streaming 
> data into a file which is being captured at same or lesser frequency 
> by updating a file periodically which is then cat'ed by Swift into an 
> output file.

-- 
Justin M Wozniak




More information about the Swift-devel mailing list