[Swift-devel] Coding a server in Swift
Ben Clifford
benc at hawaga.org.uk
Mon May 9 11:51:40 CDT 2011
That's a fairly crazy thing to do, I think. Here is a digression which may
or may not be relevant at the end.
In the past I thought a bit about handling "ever growing" data sets (for
example, a new dated file of sensor readings is placed in an input
directory every hour or day or week), with Swift causing some processing
to happen on each of those files as they appear.
In the case of a fixed-size dataset, that's fairly straightforward: map
all the files in a directory into an array, and then use foreach to run
something on all of those files, generating corresponding output files.
At the high level, Swift shouldn't have a problem with a directory that
grows: you map a directory that is still growing, and you run a foreach
over it.
Most of swift can handle an array that is not yet complete - thats core to
the parallel behaviour.
However the present mapping infrastructure can't deal with that (was my
opinion at the time). It might be possible to implement a Java-land
function that instead creates the appropriate array object over time
rather than through mapping with a mapper. I'm not sure. Then, call that
"polldir" and you could saysomething like:
a = polldir("/path/to/dir")
foreach e in a {
...
}
I think the behaviour you desire is then fairly straightforwardly
expressed.
It might be interesting for someone to have a deeper investigation into
whether something like polldir could be easily implemented (although in
the future, mappers would be the right place, I think)
--
http://www.hawaga.org.uk/ben/
More information about the Swift-devel
mailing list