-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switched object code demo to demo task logic
- Loading branch information
Showing
5 changed files
with
70 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
module RemoteExecutable (remoteExecutable) where | ||
|
||
import qualified Data.ByteString.Lazy as BL | ||
import qualified Data.ByteString.Lazy.Char8 as BLC | ||
import Data.List (foldl') | ||
import Data.Maybe | ||
|
||
import Control.Distributed.Task.Types.TaskTypes | ||
|
||
remoteExecutable :: Task | ||
remoteExecutable = map $ flip BLC.append $ BLC.pack " appended" | ||
remoteExecutable = calculateRatio | ||
--remoteExecutable = map $ flip BLC.append $ BLC.pack " appended" | ||
|
||
calculateRatio :: [BL.ByteString] -> [BL.ByteString] | ||
calculateRatio = (:[]) . BLC.pack . show . divideRatio . foldl' (flip countHits) (0, 0) . parseEntries | ||
where | ||
divideRatio :: (Int, Int) -> Double | ||
divideRatio (hits, count) = fromIntegral hits / (fromIntegral count) | ||
countHits :: Entry -> (Int, Int) -> (Int, Int) | ||
-- especially hits are important to evaluate strict here to avoid building up of costly to store thunks, containing entries (count is affected to a lesser degree) | ||
countHits e (!hits, !count) = (hits + if isHit e then 1 else 0, count+1) | ||
|
||
isHit :: Entry -> Bool | ||
isHit (_, _, vs) = maybe False notEmpty $ lookup (BLC.pack "searchCrit") vs | ||
where | ||
notEmpty :: BL.ByteString -> Bool | ||
notEmpty = (>0) . (read :: String -> Int) . BLC.unpack | ||
|
||
parseEntries :: [BL.ByteString] -> [Entry] | ||
parseEntries = catMaybes . map parseEntry | ||
|
||
type Entry = (BL.ByteString, BL.ByteString, [(BL.ByteString, BL.ByteString)]) | ||
|
||
--nlrkwldbji|3101692061|xlerb:uubqpnce|searchCrit:0|longerAttr:nspixnozidyqweu|other:lju|otherRandomNam:tndhdno|otherRandomName2:dgkkj|otherRandomName3:yrdwgww|last:xvofbj | ||
parseEntry :: BL.ByteString -> Maybe Entry | ||
parseEntry str = | ||
let cells = BLC.split '|' str | ||
in if length cells < 2 | ||
then Nothing | ||
else Just (cells !! 0, cells !! 1, catMaybes $ map parseValue $ drop 2 cells) | ||
where | ||
parseValue val = let kv = BLC.split ':' val in if length kv /= 2 then Nothing else Just (kv !! 0, kv !! 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
brute | ||
bacteria | ||
phantom | ||
fork | ||
collection | ||
hoist | ||
closeup | ||
decadence | ||
concrete | ||
horses | ||
xuvjyjsxie|5502706229|xlerb:hcdguqkulk|searchCrit:2|longerAttr:jxsvsinotqgwlmeg|other:ydsfftmn|otherRandomName:nbw|otherRandomName2:jayweohyff|otherRandomName3:orjm|last:tja | ||
ltbxziugjw|5228796119|xlerb:inythxxg|searchCrit:0|longerAttr:bzbghjggwdozajermfj|other:dmae|otherRandomName:xybbhfvsc|otherRandomName2:|otherRandomName3:iqiallzrju|last:acneag | ||
lgtueiqldw|4347259115|xlerb:nreellfe|searchCrit:1|longerAttr:supdkogzezjrpxvuidbo|other:n|otherRandomName:dytyzh|otherRandomName2:wmjpdfd|otherRandomName3:qyb|last:dgvvo | ||
oknypwvkva|5588701416|xlerb:bblecxobk|searchCrit:0|longerAttr:hfoguxhxtcmwrhu|other:pfbzt|otherRandomName:sw|otherRandomName2:|otherRandomName3:|last:zfhxck | ||
fiminvsiqi|2081652142|xlerb:xvmlna|searchCrit:1|longerAttr:uzmwwvfmoiwhstyoxyj|other:bqgni|otherRandomName:pc|otherRandomName2:zzju|otherRandomName3:uyl|last:tpna | ||
pmjndsrqpi|4537645139|xlerb:gvrwjkt|searchCrit:0|longerAttr:sdaknfftahucozxhcf|other:g|otherRandomName:cfki|otherRandomName2:y|otherRandomName3:mxt|last:dyj | ||
yauahqkhts|7627055310|xlerb:nqjafsu|searchCrit:2|longerAttr:wmowebnjwoqwoptd|other:upxyc|otherRandomName:hrrdlxn|otherRandomName2:|otherRandomName3:dyupftgpoe|last:ipfi | ||
cohuvousec|7101741810|xlerb:bagprate|searchCrit:0|longerAttr:ojtuckenyemeithbzzgk|other:gral|otherRandomName:tkrdajqsf|otherRandomName2:rvmvxpckyo|otherRandomName3:q|last:jvdzs | ||
kqonjineta|5342486512|xlerb:zkyeeu|searchCrit:0|longerAttr:kifqtywooewjzlvpqie|other:|otherRandomName:kvpakhyaw|otherRandomName2:davmyyg|otherRandomName3:dmn|last:pwcqg | ||
aqbvdaxwtg|6546664928|xlerb:vjavsfrm|searchCrit:0|longerAttr:ocghnvxqawomrhwzfu|other:ojhvjih|otherRandomName:inzdim|otherRandomName2:llrexq|otherRandomName3:a|last:ipttex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
perfect | ||
carnal | ||
fierce | ||
curiosities | ||
bewitching | ||
fallout | ||
abducted | ||
moonbeam | ||
daughter | ||
amnesia | ||
nshusllhaq|8095075735|xlerb:ukudxlzlvn|searchCrit:2|longerAttr:vsgtsxxgxgqhcoyzon|other:epphr|otherRandomName:jebwau|otherRandomName2:ympvvhuivh|otherRandomName3:xjgvyazc|last:sgy | ||
zrbiyecvef|6816064719|xlerb:drhxpxa|searchCrit:0|longerAttr:ehqphdrwvhipcsa|other:zvrukraqj|otherRandomName:yk|otherRandomName2:mvbpe|otherRandomName3:rdtvtd|last:ywzr | ||
reyypommgw|2142463253|xlerb:rywmemprh|searchCrit:1|longerAttr:vehakwacubytaymeyc|other:oa|otherRandomName:amjdau|otherRandomName2:vxmlzhtuv|otherRandomName3:wnkrmgjfd|last:aucll | ||
arhoxdtjyj|6852181259|xlerb:zlyyutstvn|searchCrit:1|longerAttr:dchwhoioqeiipxtkagwj|other:syvrsedzm|otherRandomName:yuasm|otherRandomName2:eikgwszfk|otherRandomName3:dmxfwm|last:sdivmx | ||
amcyvxxzif|5803235766|xlerb:auhdomir|searchCrit:2|longerAttr:jrpbtaewhvoynezvtm|other:zfljki|otherRandomName:fhteisoqa|otherRandomName2:bac|otherRandomName3:qojeqjfqw|last:gqotj | ||
uzkolggtep|2306490264|xlerb:uxmhirdu|searchCrit:1|longerAttr:yrntriucfwrkaezfjwuz|other:wmygltvjx|otherRandomName:jxedro|otherRandomName2:|otherRandomName3:nonclqn|last:unvavd | ||
riyemvnegw|1827566988|xlerb:rwqyompz|searchCrit:0|longerAttr:barilpcqlhrnvjxb|other:b|otherRandomName:hqjklrxw|otherRandomName2:dysjbffw|otherRandomName3:m|last:llfptj | ||
srddvfcgvc|1091751275|xlerb:eojpgpvw|searchCrit:1|longerAttr:tfqrmczynvdurgubkdl|other:m|otherRandomName:qnyx|otherRandomName2:qaqwh|otherRandomName3:ful|last:wogwoy | ||
gpzntyrecl|3200674820|xlerb:rpbgpqyfj|searchCrit:1|longerAttr:xrstqfzuuvzghfgvd|other:yrpbs|otherRandomName:vmim|otherRandomName2:bukswrhnnt|otherRandomName3:lglf|last:yphm | ||
pgyhalzzas|8221442054|xlerb:iavikxnuny|searchCrit:2|longerAttr:ghyjnvdyvbddqjd|other:tnmhwpwba|otherRandomName:xf|otherRandomName2:o|otherRandomName3:to|last:ienry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
smuggler | ||
fly | ||
morbid | ||
deer | ||
relearn | ||
juvenile | ||
propellant | ||
hoop | ||
popular | ||
ambition | ||
gnzzqdjxkc|8464038088|xlerb:pgxjnc|searchCrit:0|longerAttr:gyyzcgrrohlwkevqelu|other:p|otherRandomName:foipeqp|otherRandomName2:qcmridqq|otherRandomName3:zzm|last:jlze | ||
vfooosnoof|2761622570|xlerb:bdqrva|searchCrit:2|longerAttr:hbdovejdmccmhytns|other:yglyookye|otherRandomName:ybkb|otherRandomName2:q|otherRandomName3:quo|last:jhltkl | ||
vvpwvpkcxr|3518530398|xlerb:hjttjeydfg|searchCrit:1|longerAttr:mumrgqgivuyljexpbax|other:tvvp|otherRandomName:sf|otherRandomName2:hzehvxfush|otherRandomName3:l|last:wdv | ||
ttsswqxdrc|1375474313|xlerb:bapqqd|searchCrit:0|longerAttr:suweuxhkxggrzmbanwa|other:bxedpbaxe|otherRandomName:elhinrr|otherRandomName2:bpndavicyl|otherRandomName3:lanmizwweh|last:orv | ||
gkwbyccgkx|2748894345|xlerb:riwpqmlk|searchCrit:2|longerAttr:lotyqhjakjyjnczpjopn|other:mydvv|otherRandomName:byniglnmh|otherRandomName2:ilhznj|otherRandomName3:dg|last:ulgbsq | ||
douueoqrrq|8868904977|xlerb:ncygmmcaqn|searchCrit:0|longerAttr:qfwsevootwwhporm|other:kk|otherRandomName:zpyzsplpw|otherRandomName2:fokiunyakk|otherRandomName3:vr|last:zlyn | ||
yitlbdyoco|5533117771|xlerb:jzcjqihvx|searchCrit:0|longerAttr:iwmiubggmpbtztkbsys|other:xphotbqz|otherRandomName:zsnvib|otherRandomName2:|otherRandomName3:qhzmddymiv|last:zgk | ||
uiwswpkytj|3699256618|xlerb:bjijjgrcy|searchCrit:0|longerAttr:mzaagwnzuberpfitfs|other:|otherRandomName:fd|otherRandomName2:|otherRandomName3:jvcqkex|last:xduxh | ||
ncnpmsykpb|8135511703|xlerb:jalrdfgal|searchCrit:0|longerAttr:rlmstlgbdeuslwbqj|other:rkctvxqyr|otherRandomName:byrk|otherRandomName2:upssjpbs|otherRandomName3:cm|last:vwidln | ||
pqvpxpbctc|5792918988|xlerb:vwupcwlq|searchCrit:1|longerAttr:kgywmywmcmauauvwsu|other:|otherRandomName:vjpxs|otherRandomName2:wlqbs|otherRandomName3:|last:oqcew |