[Swift-user] Question - csv_mapper

Michael Wilde wilde at mcs.anl.gov
Wed Apr 25 07:46:41 CDT 2012


Hi Heather,

You didnt give any indication here of what output the script produced.

I ran it and got this:

login1$ swift map.swift 
no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml
Swift trunk swift-r5739 cog-r3368 (cog modified locally)

RunID: 20120425-0637-liq6u4s4
Progress:  time: Wed, 25 Apr 2012 06:38:02 -0600
SwiftScript trace: trans[0].physical:string - Closed
SwiftScript trace: trans[1].physical:string - Closed
SwiftScript trace: trans[1].logical:string - Closed
SwiftScript trace: trans[0].logical:string - Closed
Final status: Wed, 25 Apr 2012 06:38:02 -0600
login1$ 

What's happening here is not what you expect. First, "mapping" in Swift is only applicable to file-valued types. You cant apply a mapper to variables or fields of type "string", as you tried to do in this script.

Second, you tried to trace() the fields logical and physical, but your script never assigned a value to these fields. Even if your mapping had succeeded, it would not 
have set the *value* of any fields, just the *mapping* of those fields. Values are only set by assignment (ie, by "=").

Its only a quirk of the current Swift version you ran that the mapping in this case did indeed mark the state of the fields "closed" - as if they *were* assigned a value. I consider this a bug in the 0.93 version; I think the "right" thing for Swift to do here would be simply to hang, waiting for a value that will never by set, which will cause Swift to time out and report the hung state.

Lets take offline the question of how to proceed (as its a class project issue, not a Swift usage issue).

I should note that what I think you may want here is either to read in a table of values that constitute your logical/physical mapping, using one of the readData() functions, or to use the new Swift associate arrays (which can be indexed by string values, but is still undocumented so far as I know), or most likely, to create an app() interface to your external mapping database.

- Mike

----- Original Message -----
> From: "Heather Stoller" <heather.stoller at gmail.com>
> To: swift-user at ci.uchicago.edu
> Cc: "Michael Wilde" <wilde at mcs.anl.gov>, "Kyle Chard" <kyle at ci.uchicago.edu>
> Sent: Tuesday, April 24, 2012 3:57:40 PM
> Subject: Question - csv_mapper
> Hi Swift Users,
> 
> I'm a student at UChicago working with Mike Wilde and Kyle Chard at
> the Computation Institute to try to create a distributed file
> management system. At present, I have a working script that can take
> two strings (physical file locations), scp the strings to get their
> file contents, and merge their contents together. Next, I'd like my
> script to take two strings (logical file names), transform them to
> physical file locations by looking them up in a map somewhere, and
> then scp the transformed strings to get their file contents etc. So I
> only need to do ONE step at present: look up strings in a map. It's
> been suggested that I use a csv_mapper for this purpose, so I tried.
> Below is my swiftscript and attached is my logfile. Could you suggest
> what might be the matter? There are liable to be very elementary
> mistakes as I am quite a novice swift user. Thank you kindly, and
> please do let me know if anything I've mentioned has been unclear.
> Best regards,
> Heather
> 
> type file;
> 
> type translator {
> string logical;
> string physical;
> }
> 
> app (file f) echoer(translator t) {
> echo "The name is" t.logical "and the location is" t.physical
> stdout=@f;
> }
> 
> file outfile <"translation.txt">;
> 
> translator trans[] <csv_mapper; file="translate.csv">;
> 
> trace(trans[0].logical);
> trace(trans[0].physical);
> trace(trans[1].logical);
> trace(trans[1].physical);
> 
> #####################################
> 
> # translate.csv #
> 
> #####################################
> 
> logical, physical
> file1, hstoller at kedzie.cs.uchicago.edu:~/tmp/m
> file2, hstoller at kedzie.cs.uchicago.edu ~/tmp/n
> 
> 
> --
> Heather Stoller

-- 
Michael Wilde
Computation Institute, University of Chicago
Mathematics and Computer Science Division
Argonne National Laboratory




More information about the Swift-user mailing list