drop table Orders, Salesmen, T456a;
|
此行导致从内存中删除三个表。 |
Tab1:
Load * Inline [
Customer, Items, UnitPrice
Bob, 5, 1.50
];
Tab2:
LOAD Customer, Sum( Items * UnitPrice ) as Sales
resident Tab1
group by Customer;
drop table Tab1;
|
创建表 Tab2 后,将删除表 Tab1。
|
// Load mapping table of country codes:
map1:
mapping LOAD *
Inline [
CCode, Country
Sw, Sweden
Dk, Denmark
No, Norway
] ;
// Load list of salesmen, mapping country code to country
// If the country code is not in the mapping table, put Rest of the world
Salespersons:
LOAD *,
ApplyMap('map1', CCode,'Rest of the world') As Country
Inline [
CCode, Salesperson
Sw, John
Sw, Mary
Sw, Per
Dk, Preben
Dk, Olle
No, Ole
Sf, Risttu] ;
// We don't need the CCode anymore
Drop Field 'CCode';
Drop Mapping Table map1;
Metrics:
Load * Inline [
Transaction ID, Sales Amount, Sales Cost, City, Customer ID
1000012, 4509.33, 1234.22, Oslo, 250v9849
1000013, 1043.21, 180.23, Gothenburg, 195d5930
1000014, 6038.35, 1400.10, Copenhagen, 195d5930
];
|
此示例显示了如何使用 Drop mapping table 变体。创建映射表 map1,然后在随后的 LOAD 语句中与 ApplyMap 函数一起使用。使用映射表后,将其从内存中删除,从而优化脚本执行的后续表中要加载的数据的 RAM 使用率。
在这种情况下,由于映射表中只有几行,因此 RAM 优化将是最小的。但是,对于大型映射表或在循环内创建映射表时,性能可以得到显著提高。
|