Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Apache NiFi template - ExecuteScript (Groovy) Word Count
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><template><description>This template is a self-contained example showing how to use ExecuteScript (with Groovy) to perform a classic &quot;Word Count&quot; of an incoming flow file (namely The Tell-Tale Heart by Edgar Allan Poe). The output file consists of lines, each containing a word in the corpus and its frequency of occurrence.</description><name>TellTaleHeartGroovy</name><snippet><connections><id>de8c38dd-af7b-4c23-8480-4b83a11635c7</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><backPressureDataSizeThreshold>0 MB</backPressureDataSizeThreshold><backPressureObjectThreshold>0</backPressureObjectThreshold><destination><groupId>faeccde3-60c2-47af-86c7-3492795ef534</groupId><id>388f347c-7e84-44ef-aaa3-ef42565a7cc6</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>faeccde3-60c2-47af-86c7-3492795ef534</groupId><id>92dc1311-9355-4789-9cb1-3dcbda8a62f7</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><connections><id>afdaf90f-28e1-48d2-9ccf-975091e56829</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><backPressureDataSizeThreshold>0 MB</backPressureDataSizeThreshold><backPressureObjectThreshold>0</backPressureObjectThreshold><destination><groupId>faeccde3-60c2-47af-86c7-3492795ef534</groupId><id>92dc1311-9355-4789-9cb1-3dcbda8a62f7</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>faeccde3-60c2-47af-86c7-3492795ef534</groupId><id>538c961d-aaaf-4b7b-89ac-79245d21891b</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><connections><id>026209bb-2574-45d3-a5b3-0c68108fa728</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><backPressureDataSizeThreshold>0 MB</backPressureDataSizeThreshold><backPressureObjectThreshold>0</backPressureObjectThreshold><destination><groupId>faeccde3-60c2-47af-86c7-3492795ef534</groupId><id>538c961d-aaaf-4b7b-89ac-79245d21891b</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>faeccde3-60c2-47af-86c7-3492795ef534</groupId><id>97e4e641-9856-4a1d-a7a3-f9739931ef6e</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><processors><id>388f347c-7e84-44ef-aaa3-ef42565a7cc6</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><position><x>815.273193359375</x><y>-191.3762664794922</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><defaultConcurrentTasks><entry><key>TIMER_DRIVEN</key><value>1</value></entry><entry><key>EVENT_DRIVEN</key><value>0</value></entry><entry><key>CRON_DRIVEN</key><value>1</value></entry></defaultConcurrentTasks><defaultSchedulingPeriod><entry><key>TIMER_DRIVEN</key><value>0 sec</value></entry><entry><key>CRON_DRIVEN</key><value>* * * * * ?</value></entry></defaultSchedulingPeriod><descriptors><entry><key>Directory</key><value><description>The directory to which files should be written. You may use expression language such as /aa/bb/${path}</description><displayName>Directory</displayName><dynamic>false</dynamic><name>Directory</name><required>true</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Conflict Resolution Strategy</key><value><allowableValues><displayName>replace</displayName><value>replace</value></allowableValues><allowableValues><displayName>ignore</displayName><value>ignore</value></allowableValues><allowableValues><displayName>fail</displayName><value>fail</value></allowableValues><defaultValue>fail</defaultValue><description>Indicates what should happen when a file with the same name already exists in the output directory</description><displayName>Conflict Resolution Strategy</displayName><dynamic>false</dynamic><name>Conflict Resolution Strategy</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Create Missing Directories</key><value><allowableValues><displayName>true</displayName><value>true</value></allowableValues><allowableValues><displayName>false</displayName><value>false</value></allowableValues><defaultValue>true</defaultValue><description>If true, then missing destination directories will be created. If false, flowfiles are penalized and sent to failure.</description><displayName>Create Missing Directories</displayName><dynamic>false</dynamic><name>Create Missing Directories</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Maximum File Count</key><value><description>Specifies the maximum number of files that can exist in the output directory</description><displayName>Maximum File Count</displayName><dynamic>false</dynamic><name>Maximum File Count</name><required>false</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Last Modified Time</key><value><description>Sets the lastModifiedTime on the output file to the value of this attribute. Format must be yyyy-MM-dd'T'HH:mm:ssZ. You may also use expression language such as ${file.lastModifiedTime}.</description><displayName>Last Modified Time</displayName><dynamic>false</dynamic><name>Last Modified Time</name><required>false</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Permissions</key><value><description>Sets the permissions on the output file to the value of this attribute. Format must be either UNIX rwxrwxrwx with a - in place of denied permissions (e.g. rw-r--r--) or an octal number (e.g. 644). You may also use expression language such as ${file.permissions}.</description><displayName>Permissions</displayName><dynamic>false</dynamic><name>Permissions</name><required>false</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Owner</key><value><description>Sets the owner on the output file to the value of this attribute. You may also use expression language such as ${file.owner}.</description><displayName>Owner</displayName><dynamic>false</dynamic><name>Owner</name><required>false</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Group</key><value><description>Sets the group on the output file to the value of this attribute. You may also use expression language such as ${file.group}.</description><displayName>Group</displayName><dynamic>false</dynamic><name>Group</name><required>false</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry></descriptors><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>Directory</key><value>out/word_count</value></entry><entry><key>Conflict Resolution Strategy</key><value>replace</value></entry><entry><key>Create Missing Directories</key></entry><entry><key>Maximum File Count</key></entry><entry><key>Last Modified Time</key></entry><entry><key>Permissions</key></entry><entry><key>Owner</key></entry><entry><key>Group</key></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>0 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>PutFile</name><relationships><autoTerminate>true</autoTerminate><description>Files that could not be written to the output directory for some reason are transferred to this relationship</description><name>failure</name></relationships><relationships><autoTerminate>true</autoTerminate><description>Files that have been successfully written to the output directory are transferred to this relationship</description><name>success</name></relationships><state>STOPPED</state><style/><supportsEventDriven>false</supportsEventDriven><supportsParallelProcessing>true</supportsParallelProcessing><type>org.apache.nifi.processors.standard.PutFile</type></processors><processors><id>97e4e641-9856-4a1d-a7a3-f9739931ef6e</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><position><x>37.00007629394531</x><y>-382.0</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><defaultConcurrentTasks><entry><key>TIMER_DRIVEN</key><value>1</value></entry><entry><key>EVENT_DRIVEN</key><value>0</value></entry><entry><key>CRON_DRIVEN</key><value>1</value></entry></defaultConcurrentTasks><defaultSchedulingPeriod><entry><key>TIMER_DRIVEN</key><value>0 sec</value></entry><entry><key>CRON_DRIVEN</key><value>* * * * * ?</value></entry></defaultSchedulingPeriod><descriptors><entry><key>File Size</key><value><description>The size of the file that will be used</description><displayName>File Size</displayName><dynamic>false</dynamic><name>File Size</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Batch Size</key><value><defaultValue>1</defaultValue><description>The number of FlowFiles to be transferred in each invocation</description><displayName>Batch Size</displayName><dynamic>false</dynamic><name>Batch Size</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Data Format</key><value><allowableValues><displayName>Binary</displayName><value>Binary</value></allowableValues><allowableValues><displayName>Text</displayName><value>Text</value></allowableValues><defaultValue>Binary</defaultValue><description>Specifies whether the data should be Text or Binary</description><displayName>Data Format</displayName><dynamic>false</dynamic><name>Data Format</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Unique FlowFiles</key><value><allowableValues><displayName>true</displayName><value>true</value></allowableValues><allowableValues><displayName>false</displayName><value>false</value></allowableValues><defaultValue>false</defaultValue><description>If true, each FlowFile that is generated will be unique. If false, a random value will be generated and all FlowFiles will get the same content but this offers much higher throughput</description><displayName>Unique FlowFiles</displayName><dynamic>false</dynamic><name>Unique FlowFiles</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry></descriptors><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>File Size</key><value>0B</value></entry><entry><key>Batch Size</key><value>1</value></entry><entry><key>Data Format</key><value>Text</value></entry><entry><key>Unique FlowFiles</key><value>false</value></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>5 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>Empty FlowFile</name><relationships><autoTerminate>false</autoTerminate><description></description><name>success</name></relationships><state>STOPPED</state><style/><supportsEventDriven>false</supportsEventDriven><supportsParallelProcessing>true</supportsParallelProcessing><type>org.apache.nifi.processors.standard.GenerateFlowFile</type></processors><processors><id>538c961d-aaaf-4b7b-89ac-79245d21891b</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><position><x>392.273193359375</x><y>-501.3762664794922</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><defaultConcurrentTasks><entry><key>TIMER_DRIVEN</key><value>1</value></entry><entry><key>EVENT_DRIVEN</key><value>0</value></entry><entry><key>CRON_DRIVEN</key><value>1</value></entry></defaultConcurrentTasks><defaultSchedulingPeriod><entry><key>TIMER_DRIVEN</key><value>0 sec</value></entry><entry><key>CRON_DRIVEN</key><value>* * * * * ?</value></entry></defaultSchedulingPeriod><descriptors><entry><key>Regular Expression</key><value><defaultValue>(?s:^.*$)</defaultValue><description>The Search Value to search for in the FlowFile content. Only used for 'Literal Replace' and 'Regex Replace' matching strategies</description><displayName>Search Value</displayName><dynamic>false</dynamic><name>Regular Expression</name><required>true</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Replacement Value</key><value><defaultValue>$1</defaultValue><description>The value to insert using the 'Replacement Strategy'. Using &quot;Regex Replace&quot; back-references to Regular Expression capturing groups are supported, but back-references that reference capturing groups that do not exist in the regular expression will be treated as literal value. Back References may also be referenced using the Expression Language, as '$1', '$2', etc. The single-tick marks MUST be included, as these variables are not &quot;Standard&quot; attribute names (attribute names must be quoted unless they contain only numbers, letters, and _).</description><displayName>Replacement Value</displayName><dynamic>false</dynamic><name>Replacement Value</name><required>true</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Character Set</key><value><defaultValue>UTF-8</defaultValue><description>The Character Set in which the file is encoded</description><displayName>Character Set</displayName><dynamic>false</dynamic><name>Character Set</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Maximum Buffer Size</key><value><defaultValue>1 MB</defaultValue><description>Specifies the maximum amount of data to buffer (per file or per line, depending on the Evaluation Mode) in order to apply the replacement. If 'Entire Text' (in Evaluation Mode) is selected and the FlowFile is larger than this value, the FlowFile will be routed to 'failure'. In 'Line-by-Line' Mode, if a single line is larger than this value, the FlowFile will be routed to 'failure'. A default value of 1 MB is provided, primarily for 'Entire Text' mode. In 'Line-by-Line' Mode, a value such as 8 KB or 16 KB is suggested. This value is ignored if the &lt;Replacement Strategy&gt; property is set to one of: Append, Prepend, Always Replace</description><displayName>Maximum Buffer Size</displayName><dynamic>false</dynamic><name>Maximum Buffer Size</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Replacement Strategy</key><value><allowableValues><description>Insert the Replacement Value at the beginning of the FlowFile or the beginning of each line (depending on the Evaluation Mode). For &quot;Line-by-Line&quot; Evaluation Mode, the value will be prepended to each line. For &quot;Entire Text&quot; evaluation mode, the value will be prepended to the entire text.</description><displayName>Prepend</displayName><value>Prepend</value></allowableValues><allowableValues><description>Insert the Replacement Value at the end of the FlowFile or the end of each line (depending on the Evluation Mode). For &quot;Line-by-Line&quot; Evaluation Mode, the value will be appended to each line. For &quot;Entire Text&quot; evaluation mode, the value will be appended to the entire text.</description><displayName>Append</displayName><value>Append</value></allowableValues><allowableValues><description>Interpret the Search Value as a Regular Expression and replace all matches with the Replacement Value. The Replacement Value may reference Capturing Groups used in the Search Value by using a dollar-sign followed by the Capturing Group number, such as $1 or $2. If the Search Value is set to .* then everything is replaced without even evaluating the Regular Expression.</description><displayName>Regex Replace</displayName><value>Regex Replace</value></allowableValues><allowableValues><description>Search for all instances of the Search Value and replace the matches with the Replacement Value.</description><displayName>Literal Replace</displayName><value>Literal Replace</value></allowableValues><allowableValues><description>Always replaces the entire line or the entire contents of the FlowFile (depending on the value of the &lt;Evaluation Mode&gt; property) and does not bother searching for any value. When this strategy is chosen, the &lt;Search Value&gt; property is ignored.</description><displayName>Always Replace</displayName><value>Always Replace</value></allowableValues><defaultValue>Regex Replace</defaultValue><description>The strategy for how and what to replace within the FlowFile's text content.</description><displayName>Replacement Strategy</displayName><dynamic>false</dynamic><name>Replacement Strategy</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Evaluation Mode</key><value><allowableValues><displayName>Line-by-Line</displayName><value>Line-by-Line</value></allowableValues><allowableValues><displayName>Entire text</displayName><value>Entire text</value></allowableValues><defaultValue>Entire text</defaultValue><description>Run the 'Replacement Strategy' against each line separately (Line-by-Line) or buffer the entire file into memory (Entire Text) and run against that.</description><displayName>Evaluation Mode</displayName><dynamic>false</dynamic><name>Evaluation Mode</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry></descriptors><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>Regular Expression</key></entry><entry><key>Replacement Value</key><value> 1843
THE TELL-TALE HEART
by Edgar Allan Poe
TRUE! --nervous --very, very dreadfully nervous I had been and am;
but why will you say that I am mad? The disease had sharpened my
senses --not destroyed --not dulled them. Above all was the sense of
hearing acute. I heard all things in the heaven and in the earth. I
heard many things in hell. How, then, am I mad? Hearken! and observe
how healthily --how calmly I can tell you the whole story.
It is impossible to say how first the idea entered my brain; but
once conceived, it haunted me day and night. Object there was none.
Passion there was none. I loved the old man. He had never wronged
me. He had never given me insult. For his gold I had no desire. I
think it was his eye! yes, it was this! He had the eye of a vulture
--a pale blue eye, with a film over it. Whenever it fell upon me, my
blood ran cold; and so by degrees --very gradually --I made up my mind
to take the life of the old man, and thus rid myself of the eye
forever.
Now this is the point. You fancy me mad. Madmen know nothing.
But you should have seen me. You should have seen how wisely I
proceeded --with what caution --with what foresight --with what
dissimulation I went to work! I was never kinder to the old man than
during the whole week before I killed him. And every night, about
midnight, I turned the latch of his door and opened it --oh so gently!
And then, when I had made an opening sufficient for my head, I put
in a dark lantern, all closed, closed, that no light shone out, and
then I thrust in my head. Oh, you would have laughed to see how
cunningly I thrust it in! I moved it slowly --very, very slowly, so
that I might not disturb the old man's sleep. It took me an hour to
place my whole head within the opening so far that I could see him
as he lay upon his bed. Ha! would a madman have been so wise as
this, And then, when my head was well in the room, I undid the lantern
cautiously-oh, so cautiously --cautiously (for the hinges creaked) --I
undid it just so much that a single thin ray fell upon the vulture
eye. And this I did for seven long nights --every night just at
midnight --but I found the eye always closed; and so it was impossible
to do the work; for it was not the old man who vexed me, but his
Evil Eye. And every morning, when the day broke, I went boldly into
the chamber, and spoke courageously to him, calling him by name in a
hearty tone, and inquiring how he has passed the night. So you see
he would have been a very profound old man, indeed, to suspect that
every night, just at twelve, I looked in upon him while he slept.
Upon the eighth night I was more than usually cautious in
opening the door. A watch's minute hand moves more quickly than did
mine. Never before that night had I felt the extent of my own powers
--of my sagacity. I could scarcely contain my feelings of triumph.
To think that there I was, opening the door, little by little, and
he not even to dream of my secret deeds or thoughts. I fairly chuckled
at the idea; and perhaps he heard me; for he moved on the bed
suddenly, as if startled. Now you may think that I drew back --but no.
His room was as black as pitch with the thick darkness, (for the
shutters were close fastened, through fear of robbers,) and so I
knew that he could not see the opening of the door, and I kept pushing
it on steadily, steadily.
I had my head in, and was about to open the lantern, when my thumb
slipped upon the tin fastening, and the old man sprang up in bed,
crying out --&quot;Who's there?&quot;
I kept quite still and said nothing. For a whole hour I did not
move a muscle, and in the meantime I did not hear him lie down. He was
still sitting up in the bed listening; --just as I have done, night
after night, hearkening to the death watches in the wall.
Presently I heard a slight groan, and I knew it was the groan of
mortal terror. It was not a groan of pain or of grief --oh, no! --it
was the low stifled sound that arises from the bottom of the soul when
overcharged with awe. I knew the sound well. Many a night, just at
midnight, when all the world slept, it has welled up from my own
bosom, deepening, with its dreadful echo, the terrors that
distracted me. I say I knew it well. I knew what the old man felt, and
pitied him, although I chuckled at heart. I knew that he had been
lying awake ever since the first slight noise, when he had turned in
the bed. His fears had been ever since growing upon him. He had been
trying to fancy them causeless, but could not. He had been saying to
himself --&quot;It is nothing but the wind in the chimney --it is only a
mouse crossing the floor,&quot; or &quot;It is merely a cricket which has made a
single chirp.&quot; Yes, he had been trying to comfort himself with these
suppositions: but he had found all in vain. All in vain; because
Death, in approaching him had stalked with his black shadow before
him, and enveloped the victim. And it was the mournful influence of
the unperceived shadow that caused him to feel --although he neither
saw nor heard --to feel the presence of my head within the room.
When I had waited a long time, very patiently, without hearing him
lie down, I resolved to open a little --a very, very little crevice in
the lantern. So I opened it --you cannot imagine how stealthily,
stealthily --until, at length a simple dim ray, like the thread of the
spider, shot from out the crevice and fell full upon the vulture eye.
It was open --wide, wide open --and I grew furious as I gazed upon
it. I saw it with perfect distinctness --all a dull blue, with a
hideous veil over it that chilled the very marrow in my bones; but I
could see nothing else of the old man's face or person: for I had
directed the ray as if by instinct, precisely upon the damned spot.
And have I not told you that what you mistake for madness is but
over-acuteness of the sense? --now, I say, there came to my ears a
low, dull, quick sound, such as a watch makes when enveloped in
cotton. I knew that sound well, too. It was the beating of the old
man's heart. It increased my fury, as the beating of a drum stimulates
the soldier into courage.
But even yet I refrained and kept still. I scarcely breathed. I
held the lantern motionless. I tried how steadily I could maintain the
ray upon the eve. Meantime the hellish tattoo of the heart
increased. It grew quicker and quicker, and louder and louder every
instant. The old man's terror must have been extreme! It grew
louder, I say, louder every moment! --do you mark me well I have
told you that I am nervous: so I am. And now at the dead hour of the
night, amid the dreadful silence of that old house, so strange a noise
as this excited me to uncontrollable terror. Yet, for some minutes
longer I refrained and stood still. But the beating grew louder,
louder! I thought the heart must burst. And now a new anxiety seized
me --the sound would be heard by a neighbour! The old man's hour had
come! With a loud yell, I threw open the lantern and leaped into the
room. He shrieked once --once only. In an instant I dragged him to the
floor, and pulled the heavy bed over him. I then smiled gaily, to find
the deed so far done. But, for many minutes, the heart beat on with
a muffled sound. This, however, did not vex me; it would not be
heard through the wall. At length it ceased. The old man was dead. I
removed the bed and examined the corpse. Yes, he was stone, stone
dead. I placed my hand upon the heart and held it there many
minutes. There was no pulsation. He was stone dead. His eve would
trouble me no more.
If still you think me mad, you will think so no longer when I
describe the wise precautions I took for the concealment of the
body. The night waned, and I worked hastily, but in silence. First
of all I dismembered the corpse. I cut off the head and the arms and
the legs.
I then took up three planks from the flooring of the chamber,
and deposited all between the scantlings. I then replaced the boards
so cleverly, so cunningly, that no human eye --not even his --could
have detected any thing wrong. There was nothing to wash out --no
stain of any kind --no blood-spot whatever. I had been too wary for
that. A tub had caught all --ha! ha!
When I had made an end of these labors, it was four o'clock
--still dark as midnight. As the bell sounded the hour, there came a
knocking at the street door. I went down to open it with a light
heart, --for what had I now to fear? There entered three men, who
introduced themselves, with perfect suavity, as officers of the
police. A shriek had been heard by a neighbour during the night;
suspicion of foul play had been aroused; information had been lodged
at the police office, and they (the officers) had been deputed to
search the premises.
I smiled, --for what had I to fear? I bade the gentlemen
welcome. The shriek, I said, was my own in a dream. The old man, I
mentioned, was absent in the country. I took my visitors all over
the house. I bade them search --search well. I led them, at length, to
his chamber. I showed them his treasures, secure, undisturbed. In
the enthusiasm of my confidence, I brought chairs into the room, and
desired them here to rest from their fatigues, while I myself, in
the wild audacity of my perfect triumph, placed my own seat upon the
very spot beneath which reposed the corpse of the victim.
The officers were satisfied. My manner had convinced them. I was
singularly at ease. They sat, and while I answered cheerily, they
chatted of familiar things. But, ere long, I felt myself getting
pale and wished them gone. My head ached, and I fancied a ringing in
my ears: but still they sat and still chatted. The ringing became more
distinct: --It continued and became more distinct: I talked more
freely to get rid of the feeling: but it continued and gained
definiteness --until, at length, I found that the noise was not within
my ears.
No doubt I now grew very pale; --but I talked more fluently, and
with a heightened voice. Yet the sound increased --and what could I
do? It was a low, dull, quick sound --much such a sound as a watch
makes when enveloped in cotton. I gasped for breath --and yet the
officers heard it not. I talked more quickly --more vehemently; but
the noise steadily increased. I arose and argued about trifles, in a
high key and with violent gesticulations; but the noise steadily
increased. Why would they not be gone? I paced the floor to and fro
with heavy strides, as if excited to fury by the observations of the
men --but the noise steadily increased. Oh God! what could I do? I
foamed --I raved --I swore! I swung the chair upon which I had been
sitting, and grated it upon the boards, but the noise arose over all
and continually increased. It grew louder --louder --louder! And still
the men chatted pleasantly, and smiled. Was it possible they heard
not? Almighty God! --no, no! They heard! --they suspected! --they
knew! --they were making a mockery of my horror!-this I thought, and
this I think. But anything was better than this agony! Anything was
more tolerable than this derision! I could bear those hypocritical
smiles no longer! I felt that I must scream or die! and now --again!
--hark! louder! louder! louder! louder!
&quot;Villains!&quot; I shrieked, &quot;dissemble no more! I admit the deed!
--tear up the planks! here, here! --It is the beating of his hideous
heart!&quot;
THE END</value></entry><entry><key>Character Set</key></entry><entry><key>Maximum Buffer Size</key></entry><entry><key>Replacement Strategy</key></entry><entry><key>Evaluation Mode</key></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>0 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>The Tell-Tale Heart</name><relationships><autoTerminate>true</autoTerminate><description>FlowFiles that could not be updated are routed to this relationship</description><name>failure</name></relationships><relationships><autoTerminate>false</autoTerminate><description>FlowFiles that have been successfully processed are routed to this relationship. This includes both FlowFiles that had text replaced and those that did not.</description><name>success</name></relationships><state>STOPPED</state><style/><supportsEventDriven>true</supportsEventDriven><supportsParallelProcessing>true</supportsParallelProcessing><type>org.apache.nifi.processors.standard.ReplaceText</type></processors><processors><id>92dc1311-9355-4789-9cb1-3dcbda8a62f7</id><parentGroupId>faeccde3-60c2-47af-86c7-3492795ef534</parentGroupId><position><x>812.273193359375</x><y>-375.3762664794922</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><defaultConcurrentTasks><entry><key>TIMER_DRIVEN</key><value>1</value></entry><entry><key>EVENT_DRIVEN</key><value>0</value></entry><entry><key>CRON_DRIVEN</key><value>1</value></entry></defaultConcurrentTasks><defaultSchedulingPeriod><entry><key>TIMER_DRIVEN</key><value>0 sec</value></entry><entry><key>CRON_DRIVEN</key><value>* * * * * ?</value></entry></defaultSchedulingPeriod><descriptors><entry><key>Script Engine</key><value><allowableValues><displayName>ECMAScript</displayName><value>ECMAScript</value></allowableValues><allowableValues><displayName>Groovy</displayName><value>Groovy</value></allowableValues><allowableValues><displayName>lua</displayName><value>lua</value></allowableValues><allowableValues><displayName>python</displayName><value>python</value></allowableValues><allowableValues><displayName>ruby</displayName><value>ruby</value></allowableValues><defaultValue>ECMAScript</defaultValue><description>The engine to execute scripts</description><displayName>Script Engine</displayName><dynamic>false</dynamic><name>Script Engine</name><required>true</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Script File</key><value><description>Path to script file to execute. Only one of Script File or Script Body may be used</description><displayName>Script File</displayName><dynamic>false</dynamic><name>Script File</name><required>false</required><sensitive>false</sensitive><supportsEl>true</supportsEl></value></entry><entry><key>Script Body</key><value><description>Body of script to execute. Only one of Script File or Script Body may be used</description><displayName>Script Body</displayName><dynamic>false</dynamic><name>Script Body</name><required>false</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry><entry><key>Module Directory</key><value><description>Comma-separated list of paths to files and/or directories which contain modules required by the script.</description><displayName>Module Directory</displayName><dynamic>false</dynamic><name>Module Directory</name><required>false</required><sensitive>false</sensitive><supportsEl>false</supportsEl></value></entry></descriptors><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>Script Engine</key><value>Groovy</value></entry><entry><key>Script File</key></entry><entry><key>Script Body</key><value>import org.apache.commons.io.IOUtils
import java.nio.charset.*
def flowFile = session.get()
if(!flowFile) return
flowFile = session.write(flowFile, {inputStream, outputStream -&gt;
def wordCount = [:]
def tellTaleHeart = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
def words = tellTaleHeart.split(/(!|\?|-|\.|\&quot;|:|;|,|\s)+/)*.toLowerCase()
words.each { word -&gt;
def currentWordCount = wordCount.get(word)
if(!currentWordCount) {
wordCount.put(word, 1)
}
else {
wordCount.put(word, currentWordCount + 1)
}
}
def outputMapString = wordCount.inject(&quot;&quot;, {k,v -&gt; k += &quot;${v.key}: ${v.value}\n&quot;})
outputStream.write(outputMapString.getBytes(StandardCharsets.UTF_8))
} as StreamCallback)
flowFile = session.putAttribute(flowFile, 'filename', 'telltale_heart_wordcount')
session.transfer(flowFile, REL_SUCCESS)</value></entry><entry><key>Module Directory</key></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>0 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>ExecuteScript</name><relationships><autoTerminate>true</autoTerminate><description>FlowFiles that failed to be processed</description><name>failure</name></relationships><relationships><autoTerminate>false</autoTerminate><description>FlowFiles that were successfully processed</description><name>success</name></relationships><state>STOPPED</state><style/><supportsEventDriven>false</supportsEventDriven><supportsParallelProcessing>false</supportsParallelProcessing><type>org.apache.nifi.processors.script.ExecuteScript</type></processors></snippet><timestamp>02/10/2016 15:28:30 EST</timestamp></template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment