Marcus Daniels, swarm-support, August 8, 1999 AL> 3) add the list objects to a Map object so I can access them by a AL> unique key ==> PROBLEM If you want to use integer keys, you need to tell Map that is your intent. The default behavior for Map is to send the -compare: method to each key. But since you can only send messages to objects (not integers), -compare: won't work. [[[Map createBegin: aZone] setCompareFunction: compareUnsignedIntegers] createEnd]; AL> - Is this a good solution anyway? Well, I think it's unfortunate you're having to write I/O code in C. I prefer to use higher-level, interpreted tools to do that kind of work. Supposing you want Maps of ragged-length data in R, i.e. data of this form: mgd@pojoaque[~] $ cat lists.txt 10 20 30 40 50 100 200 300 400 500 1000 2000 3000 4000 5000 6000 You can use a `R' program like this to create a HDF5 file from lists.txt. mgd@pojoaque[~] $ cat loadMap.R wrap <- function (val) { obj <- list(val=val) attr (obj, "type") <- "MyObject" obj } mklist <- function (str) { l <- eval(parse(text=paste("c(", gsub(" ",",",str), ")"))) l <- lapply (l, wrap) attr (l, "type") <- "List" l } loadMap <- function (filename) { l <- scan (filename,sep="\n",what=list("")) map <- lapply (l[[1]], mklist) attr(map,"names") <- lapply(1:length(map),"as.character") attr(map,"type") <- "Map" attr(map,"component-type") <- "List" attr(map,"compare-function") <- "compare-integers" map } saveFor141 <- function (map) { loadMap <- list(default=list(map=map)) hdf5save("map.hdf",loadMap) } saveFor20 <- function (map) { hdf5save("map.hdf", map) } Running it like so: mgd@pojoaque[~] $ /usr/local/bin/R -q > source("loadMap.R") > saveFor141(loadMap("lists.txt")) Read 3 lines NULL > To recover the data from the HDF5, you can use the Swarm Archiver interface... #import // initSwarm #import // Map #import // CreateDrop @interface MyObject: CreateDrop { double val; } - (void)describe: outputCharStream; @end @implementation MyObject - (void)describe: outputCharStream { char buf[30]; sprintf (buf, "val: %f\n", val); [outputCharStream catC: buf]; } @end int main (int argc, const char **argv) { id archiver; id map; initSwarmBatch (argc, argv); archiver = [[[[Archiver createBegin: globalZone] setPath: "map.hdf"] setHDF5Flag: YES] createEnd]; map = [archiver getObject: "map"]; { id index = [map begin: globalZone]; id member; int key; for (member = [index next: (id *) &key]; [index getLoc] == Member; member = [index next: (id *) &key]) { printf ("%d:\n", key); xfprint (member); } [index drop]; } } /* Local Variables: compile-command: "/opt/gnu/bin/gcc -o loadMap -g -Wno-import -L/opt/SUNWtcl/8.0/sun4/lib -R/opt/SUNWtcl/8.0/sun4/lib -L/opt/SDGblt/2.4g/lib -R/opt/SDGblt/2.4g/lib -L/opt/SDGlibffi/1.20/lib -R/opt/SDGlibffi/1.20/lib -L/opt/SDGswarm/1.4.1/lib -L/opt/SDGzlib/1.1.3/lib -L/usr/local/X11/lib -R/usr/local/X11/lib -L/usr/openwin/lib -R/usr/openwin/lib -L/opt/SDGhdf5/1.0.1/lib -I/opt/SDGswarm/1.4.1/include loadMap.m -lanalysis -lsimtools -lsimtoolsgui -lactivity -ltkobjc -lrandom -lobjectbase -ldefobj -lcollections -lmisc -ltclobjc -ltk8.0 -ltcl8.0 -lBLT -lsocket -ldl -lnsl -L/usr/openwin/lib -lhdf5 -lpng -lz -lXpm -lX11 -lffi -lm -lobjc -lpthread -lposix4" End: */