Author:
Mark Ireland

相关博客文章>关于FME|2018年5月15日|马克爱尔兰

FME工作区特性缓存:新模式:身份验证oring

One of the best things about working from home is that my office looks out over the garden, and I can watch squirrels gathering food and caching it away for the winter.

它’s annoying that they raid my bird feeders to do so, but I suppose it’s very important to them.They collect food in the summer months and stash it away for quick access in the winter.

I don’t know if our developers were watching squirrels too, but FME2018 has a very similar device for caching data.I’ve promoted功能缓存in网络研讨会and on the世界巡游, but sometimes I forget not every user watches or attends these events.

Plus, even though this is a big deal for workspace development, it’s not obvious that this functionality even exists.

So this blog post is about Feature Caching in FME 2018.I’ll cover what it is, how it works, what the uses of cached data are, and then provide some tips and tricks for the functionality.

I’m going to try and provide something for everyone, so even if you already know about this functionality, do read on…

What is Feature Caching?How Does it Work?

Just like the squirrel, Feature Caching in FME is simply storing data away in order to have easy access to it when required.

I turn on caching by choosing Run with Feature Caching from the Workbench menubar:

Turning on Feature Caching

There’s also – you might notice – a toggle button on the toolbar.Once activated FME now caches data as it is processed:

Cached Data in Workbench

The green icon represents cached data for that particular step.Above you can see that both Tester Passed and Failed features are stored in a cache, and I can even hover over the cache with my mouse to see the data being stored:

Insoecting cached data in Workbench

So caching data is really easy.Just turn on the functionality and run the workspace.Of course, there is overhead in caching data, and the workspace will be slower, so you might be wondering what the use of it is…

What are the Uses of Caching Data?

If you’ve used FME before you might have noticed that Run with Feature Caching replaces Run with Full Inspection on the menubar.That’s because inspection can use cached data.I can click the green icon to view that particular cache, or select a number of transformers, press Ctrl+I, and inspect all their data:

Inspecting cached data

This is great.它 means I can inspect whatever data I want without having to place Inspector transformers beforehand.If the results of the AreaCalculator (above) were not what I was expecting, I can inspect the data both before and after in order to diagnose the problem.

But as great as this is, the bigger use is in something we call部分运行

Partial Runs

Let’s say, in the above workspace, I make a change to the AreaCalculator transformer.The effect on the workspace is this:

A cache made stale by workspace edits

The cache icons on the AreaCalculator, and any transformers further along in the workspace, have turned yellow.This denotes that their contents no longer match what would be actually be produced by the workspace.I can still inspect the data there, but the yellow icon tells me the cache is “stale”.

But what’s more important is that clicking on the AreaCalculator pops up some new run options:

Partial Run with Caching

从这个运行means that the workspace runs from this point onwards.它 doesn’t need to run anything before that point because the data is already available in the caches!This is where we earn back the time spent caching data.Because the Tester has up-to-date caches, the AreaCalculator can use that data instead of running the first part of the workspace again.

Another way to run the same thing is click on a writer feature type and choose运行为了这:

运行为了这

Notice how the parts FME runs are highlighted in green.That way you can see FME reaches back through the workspace until it finds a valid cache.

So that, in a nutshell, is Feature Caching and Partial Runs.Of course, like any FME functionality, there are various ways in which the tool can be applied to our advantage…

功能缓存 Tips and Tricks

One of the best uses for Feature Caching is for caching the results of web services.Let’s take this workspace that I created to generate a web page showing FME World Tour events:

Caching and Web Services

The part with the InlineQuerier took me a little while to get right, and I had to run the workspace a few times.But look, there are two Geocoder transformers before it!One geocodes the point, the other fetches its timezone (did you know we could do that?) With 70+ records it took several minutes to geocode the data and I didn’t want to have that happen every time I tested the InlineQuerier.

那么,与FME 2018我不需要这样的事情发生。我打开缓存,这样的地理编码器缓存他们的数据。然后我可以有它使用高速缓存运行在第二的InlineQuerier。所以特征缓存是一个巨大的好处使用速度较慢的网络资源,如数据库和Web服务时。

同时奔跑

不过说真的缓存为任何大型数据集有帮助的,尤其是当你开始开发一个新的工作区。比方说,我创建一个工作区,我加入了阅读器来阅读五个百万地址记录的数据库启动:

正常的程序是开始添加变压器到工作区,然后通过运行工作区进行测试。但是......与FME 2018我打开特征缓存并立即运行工作区。为什么?因为虽然FME读取和缓存中的数据,我可以继续开发工作区,在同一时间!

然后,由时间我有我的第一个变压器就位和安装,FME会读取数据并缓存它,准备直接在变压器上使用。

总之,我既可以运行,同步发展的工作空间!花费的时间等待读取或数据可以更有效地使用变换。

模板和缓存

模板已经存在了一段时间,是在一个单一的文件一起保存工作区及其数据的好方法。而在FME2018数据的定义扩展到现有要素缓存:

所以,现在你可以节省您的工作空间与它的高速缓存,后来又重新打开它与高速缓存可以使用。你可能永远不会有以后再运行完整的工作空间!

折叠书签和缓存

正如我所提到的,高速缓存功能的一个缺点是一个性能损失创建初始高速缓存,如明显使用的时间和系统资源。另外,您还缓存整个工作区,不只是你有兴趣,对部分?所以,如果我运行这个工作空间,变压器的都得到缓存:

缓存和书签

对?哦,不。它可能在一个工作区的部分“关闭”缓存。你这样做,通过简单折叠周围的书签(另一个新功能2018年):

缓存和折叠书签

现在我运行该工作区和FME缓存只有最后,连接输出端口。在这种情况下,StatisticsCalculator:完整的输出端口缓存,但没有别的。通过减少缓存量加速了处理。

总之,如果你是不是在工作区的一个组成部分,它藏在一个倒塌的书签有意加快缓存过程。

比方说,我有工作区的该位,并且要运行两个分支即退出Geocoder_2:

我可以运行一个或其他(使用从这个运行在书签本身),但同时运行我必须选择Geocoder_2和选择从这个运行。当然,这意味着地理编码器本身运行,这我并不真正需要的。因此,在这种情况下,我只需要添加一个结变压器:

现在我可以在结此运行,而不必重新运行Geocoder_2。

顺便提一句,即将到来的FME2018.1被更新,以防止结变压器进行其他变压器缓存陈旧。由于变压器什么也不做结,也不会在所有反正影响的数据。

为什么不服务器?

这里有一个问题,我一直在问,我的同事仁一直问,我们的联合创始人戴尔一直问:如何缓存功能与FME Server集成?

简短的答案是,它没有,那我们不就任何整合计划。

但是,如果你问这样的时候,必须有一些混乱。让我尝试澄清:觉得这个功能作为一个工作区“创作模式”或“设计模式”。它的意图是让你使用缓存构建一个工作区,因为这是当部分的运行是有益的。每次添加一个新的变压器则只需运行变压器,而不是整个工作空间测试其运行状况。

但在生产 - 尤其是在服务器 - 你关闭缓存,因为你不是在编辑工作区,因为终端用户不会想要做的部分运行。唯一的一次,一个缓存服务器上有用的阅读数据集和打击网络服务,并且已经有上FeatureReader变压器,一个缓存选项:

在这里我从PostGIS的数据库中读取,但我还缓存数据,为期24小时。所以,如果我发布工作区服务器我不担心在桌面和上传他们创建缓存。使用此选项的服务器引擎自动创建缓存,并自动刷新它。

如果有在桌面缓存的任何其他数据要到服务器上重用(例如缓存的地理编码数据),然后保存了作家的地理编码数据,从工作区中删除了地理编码,并放在一个阅读器读取保存的数据。然后你读服务器,而不是Web服务上的数据。

换句话说,服务器是使用更永久的数据;数据集,而不是缓存。

空间记忆和缓存

我读了 - 就像FME - 松鼠,有一个真正强大的空间记忆。这是他们如何管理自己的检索缓存的食物。我还发现,树松鼠不冬眠和如此不断活跃的一组松鼠被称为乱窜!这太听起来很像FME。我讨厌建议,但也许我们应该有一个FME松鼠吉祥物,而不是FME蜥蜴

无论如何,如果你想了解更多关于高速缓存 - 数据,而不是坚果和浆果 - 不要忘记我们在6月27日至FME桌面2018正在发生的培训课程叫升级。它是免费的,所以如果你打算升级到2018年,或最近所做的那样,为什么不注册?您将了解一些其他的新功能,现在可以从我们的顶级FME专家之一。