如果我这样做:
import time
import random
import datetime
class TimeoutException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
def busy_work():
# Pretend to do something useful
time.sleep(random.uniform(0.3, 0.6))
def train_loadbatch_from_lists(batch_size, timeout_sec):
time_start = datetime.datetime.now()
batch_xs = []
batch_ys = []
for i in range(0, batch_size+1):
busy_work()
batch_xs.append(i)
batch_ys.append(i)
time_elapsed = datetime.datetime.now() - time_start
print 'Elapsed:', time_elapsed
if time_elapsed > timeout_sec:
raise TimeoutException()
return batch_xs, batch_ys
def main():
timeout_sec = datetime.timedelta(seconds=5)
batch_size = 10
try:
print 'Processing batch'
batch_xs, batch_ys = train_loadbatch_from_lists(batch_size, timeout_sec)
print 'Completed successfully'
print batch_xs, batch_ys
except TimeoutException, e:
print 'Timeout after processing N records'
if __name__ == '__main__':
main()
然而,如果我们注释掉Event
关键字:
SELECT
NON EMPTY
[Measures].[Internet Sales Amount] ON COLUMNS
,NON EMPTY
{
Hierarchize
( EXISTING
{
[Product].[Product Categories].[Product].&[483]
,[Product].[Product Categories].[Product].&[486]
,[Product].[Product Categories].[Product].&[478]
,[Product].[Product Categories].[Product].&[479]
,[Product].[Product Categories].[Product].&[477]
,[Product].[Product Categories].[Product].&[484]
,[Product].[Product Categories].[Product].&[485]
,[Product].[Product Categories].[Product].&[317]
,[Product].[Product Categories].[Product].&[316]
,[Product].[Product Categories].[Product].&[583]
,[Product].[Product Categories].[Product].&[311]
,[Product].[Product Categories].[Product].&[594]
}
)
} ON ROWS
FROM [Adventure Works]
WHERE
[Product].[Product Model Lines].[Product Line].&[M];
我们得到以下信息:
我们使用Pyramid前端。本来希望那里的人可以在他们的mdx渲染引擎中包含EXISTING
关键字,这样用户就不必担心这个错误了。
这绝对是个错误吗?
包含SELECT
NON EMPTY
[Measures].[Internet Sales Amount] ON COLUMNS
,NON EMPTY
{
Hierarchize
( --EXISTING
{
[Product].[Product Categories].[Product].&[483]
,[Product].[Product Categories].[Product].&[486]
,[Product].[Product Categories].[Product].&[478]
,[Product].[Product Categories].[Product].&[479]
,[Product].[Product Categories].[Product].&[477]
,[Product].[Product Categories].[Product].&[484]
,[Product].[Product Categories].[Product].&[485]
,[Product].[Product Categories].[Product].&[317]
,[Product].[Product Categories].[Product].&[316]
,[Product].[Product Categories].[Product].&[583]
,[Product].[Product Categories].[Product].&[311]
,[Product].[Product Categories].[Product].&[594]
}
)
} ON ROWS
FROM [Adventure Works]
WHERE
[Product].[Product Model Lines].[Product Line].&[M];
是否表示脚本运行速度较慢?