blob: f39e48bb3811817c4d3a5526ba927f604c166566 [file] [log] [blame]
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title> </title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/favicon.ico">
<meta name="description" content=" ">
<meta name="Description" content="Apache IoTDB: Time Series Database for IoT">
<meta name="Keywords" content="TSDB, time series, time series database, IoTDB, IoT database, IoT data management,时序数据库, 时间序列管理, IoTDB, 物联网数据库, 实时数据库, 物联网数据管理, 物联网数据">
<meta name="baidu-site-verification" content="wfKETzB3OT">
<meta name="google-site-verification" content="mZWAoRY0yj_HAr-s47zHCGHzx5Ju-RVm5wDbPnwQYFo">
<link rel="preload" href="/assets/css/0.styles.ccadf850.css" as="style"><link rel="preload" href="/assets/js/app.9c03bb74.js" as="script"><link rel="preload" href="/assets/js/3.e95317f3.js" as="script"><link rel="preload" href="/assets/js/350.1066134b.js" as="script"><link rel="prefetch" href="/assets/js/10.77e7d27b.js"><link rel="prefetch" href="/assets/js/100.ce37c53f.js"><link rel="prefetch" href="/assets/js/101.ab370749.js"><link rel="prefetch" href="/assets/js/102.4db55384.js"><link rel="prefetch" href="/assets/js/103.28a00d56.js"><link rel="prefetch" href="/assets/js/104.aaf85214.js"><link rel="prefetch" href="/assets/js/105.eb973f15.js"><link rel="prefetch" href="/assets/js/106.007d9ae6.js"><link rel="prefetch" href="/assets/js/107.35199171.js"><link rel="prefetch" href="/assets/js/108.2f080778.js"><link rel="prefetch" href="/assets/js/109.4a3db7c3.js"><link rel="prefetch" href="/assets/js/11.242ea813.js"><link rel="prefetch" href="/assets/js/110.121c12b0.js"><link rel="prefetch" href="/assets/js/111.2d907f27.js"><link rel="prefetch" href="/assets/js/112.cd3fc3c6.js"><link rel="prefetch" href="/assets/js/113.60360e14.js"><link rel="prefetch" href="/assets/js/114.b1977cbf.js"><link rel="prefetch" href="/assets/js/115.71389e78.js"><link rel="prefetch" href="/assets/js/116.c495c800.js"><link rel="prefetch" href="/assets/js/117.f6a4a5d4.js"><link rel="prefetch" href="/assets/js/118.986551b6.js"><link rel="prefetch" href="/assets/js/119.ccf52dd9.js"><link rel="prefetch" href="/assets/js/12.643b0fb0.js"><link rel="prefetch" href="/assets/js/120.c21aafd0.js"><link rel="prefetch" href="/assets/js/121.448ace52.js"><link rel="prefetch" href="/assets/js/122.37b6650b.js"><link rel="prefetch" href="/assets/js/123.096531cd.js"><link rel="prefetch" href="/assets/js/124.6d8ba356.js"><link rel="prefetch" href="/assets/js/125.b053a479.js"><link rel="prefetch" href="/assets/js/126.32856698.js"><link rel="prefetch" href="/assets/js/127.211c2b9f.js"><link rel="prefetch" href="/assets/js/128.f7cd241a.js"><link rel="prefetch" href="/assets/js/129.8983f959.js"><link rel="prefetch" href="/assets/js/13.c58bffc8.js"><link rel="prefetch" href="/assets/js/130.27448489.js"><link rel="prefetch" href="/assets/js/131.f74784eb.js"><link rel="prefetch" href="/assets/js/132.9553fdd5.js"><link rel="prefetch" href="/assets/js/133.128c722a.js"><link rel="prefetch" href="/assets/js/134.3e480989.js"><link rel="prefetch" href="/assets/js/135.06b43884.js"><link rel="prefetch" href="/assets/js/136.6a6503c4.js"><link rel="prefetch" href="/assets/js/137.f79fb732.js"><link rel="prefetch" href="/assets/js/138.c519ee60.js"><link rel="prefetch" href="/assets/js/139.269b4122.js"><link rel="prefetch" href="/assets/js/14.939be0f9.js"><link rel="prefetch" href="/assets/js/140.8acac491.js"><link rel="prefetch" href="/assets/js/141.5739ba5c.js"><link rel="prefetch" href="/assets/js/142.0a0bb60d.js"><link rel="prefetch" href="/assets/js/143.2849d1b8.js"><link rel="prefetch" href="/assets/js/144.40806d0f.js"><link rel="prefetch" href="/assets/js/145.f396d071.js"><link rel="prefetch" href="/assets/js/146.3f935af5.js"><link rel="prefetch" href="/assets/js/147.6ab3b033.js"><link rel="prefetch" href="/assets/js/148.1e9ba5bb.js"><link rel="prefetch" href="/assets/js/149.be7d35fd.js"><link rel="prefetch" href="/assets/js/15.843fe861.js"><link rel="prefetch" href="/assets/js/150.4553bfe1.js"><link rel="prefetch" href="/assets/js/151.4df7c29e.js"><link rel="prefetch" href="/assets/js/152.7fbfa55b.js"><link rel="prefetch" href="/assets/js/153.b307a91f.js"><link rel="prefetch" href="/assets/js/154.61a099b6.js"><link rel="prefetch" href="/assets/js/155.42bd11f4.js"><link rel="prefetch" href="/assets/js/156.5e14d94b.js"><link rel="prefetch" href="/assets/js/157.a82e8d14.js"><link rel="prefetch" href="/assets/js/158.4ca4cf76.js"><link rel="prefetch" href="/assets/js/159.96ad00f0.js"><link rel="prefetch" href="/assets/js/16.17c1f643.js"><link rel="prefetch" href="/assets/js/160.d27a9f8e.js"><link rel="prefetch" href="/assets/js/161.f69489a3.js"><link rel="prefetch" href="/assets/js/162.d6297e81.js"><link rel="prefetch" href="/assets/js/163.8c7d6f48.js"><link rel="prefetch" href="/assets/js/164.844ec167.js"><link rel="prefetch" href="/assets/js/165.e4109536.js"><link rel="prefetch" href="/assets/js/166.6f922175.js"><link rel="prefetch" href="/assets/js/167.27cb7956.js"><link rel="prefetch" href="/assets/js/168.66d50e2f.js"><link rel="prefetch" href="/assets/js/169.db6a9c1e.js"><link rel="prefetch" href="/assets/js/17.a4028525.js"><link rel="prefetch" href="/assets/js/170.f09f4ab5.js"><link rel="prefetch" href="/assets/js/171.03b885f5.js"><link rel="prefetch" href="/assets/js/172.712c6bac.js"><link rel="prefetch" href="/assets/js/173.72a81752.js"><link rel="prefetch" href="/assets/js/174.80e57cad.js"><link rel="prefetch" href="/assets/js/175.96ef1cbc.js"><link rel="prefetch" href="/assets/js/176.975567d0.js"><link rel="prefetch" href="/assets/js/177.e46b5dad.js"><link rel="prefetch" href="/assets/js/178.277a4463.js"><link rel="prefetch" href="/assets/js/179.a8370836.js"><link rel="prefetch" href="/assets/js/18.122d5826.js"><link rel="prefetch" href="/assets/js/180.66ebf02a.js"><link rel="prefetch" href="/assets/js/181.b5488f9b.js"><link rel="prefetch" href="/assets/js/182.d354a8c6.js"><link rel="prefetch" href="/assets/js/183.87f069d1.js"><link rel="prefetch" href="/assets/js/184.47c2f6fb.js"><link rel="prefetch" href="/assets/js/185.b6a632b5.js"><link rel="prefetch" href="/assets/js/186.9f9a7452.js"><link rel="prefetch" href="/assets/js/187.aadc1931.js"><link rel="prefetch" href="/assets/js/188.90cc251e.js"><link rel="prefetch" href="/assets/js/189.01c9ecc3.js"><link rel="prefetch" href="/assets/js/19.9187dec1.js"><link rel="prefetch" href="/assets/js/190.ff15e49f.js"><link rel="prefetch" href="/assets/js/191.a47f90cd.js"><link rel="prefetch" href="/assets/js/192.1d1eb36e.js"><link rel="prefetch" href="/assets/js/193.39fab29d.js"><link rel="prefetch" href="/assets/js/194.f1cbfa0a.js"><link rel="prefetch" href="/assets/js/195.c40239c9.js"><link rel="prefetch" href="/assets/js/196.0388c356.js"><link rel="prefetch" href="/assets/js/197.55863e11.js"><link rel="prefetch" href="/assets/js/198.a48cc095.js"><link rel="prefetch" href="/assets/js/199.dae24824.js"><link rel="prefetch" href="/assets/js/20.c8df4732.js"><link rel="prefetch" href="/assets/js/200.5b971052.js"><link rel="prefetch" href="/assets/js/201.c6d6883b.js"><link rel="prefetch" href="/assets/js/202.56b1c573.js"><link rel="prefetch" href="/assets/js/203.cacf8999.js"><link rel="prefetch" href="/assets/js/204.899538ec.js"><link rel="prefetch" href="/assets/js/205.fd2fe361.js"><link rel="prefetch" href="/assets/js/206.ea246089.js"><link rel="prefetch" href="/assets/js/207.4dd0bdf9.js"><link rel="prefetch" href="/assets/js/208.30c94a7c.js"><link rel="prefetch" href="/assets/js/209.8d20aa77.js"><link rel="prefetch" href="/assets/js/21.acbfa763.js"><link rel="prefetch" href="/assets/js/210.ad8beb10.js"><link rel="prefetch" href="/assets/js/211.87928df0.js"><link rel="prefetch" href="/assets/js/212.552b3f7c.js"><link rel="prefetch" href="/assets/js/213.2b0a5283.js"><link rel="prefetch" href="/assets/js/214.8cf08cfc.js"><link rel="prefetch" href="/assets/js/215.d3564dd7.js"><link rel="prefetch" href="/assets/js/216.736e26f0.js"><link rel="prefetch" href="/assets/js/217.f9370757.js"><link rel="prefetch" href="/assets/js/218.3205fb4a.js"><link rel="prefetch" href="/assets/js/219.fd6ed6fa.js"><link rel="prefetch" href="/assets/js/22.1e7200c8.js"><link rel="prefetch" href="/assets/js/220.d72b3bb1.js"><link rel="prefetch" href="/assets/js/221.7e1fb00c.js"><link rel="prefetch" href="/assets/js/222.f520de95.js"><link rel="prefetch" href="/assets/js/223.494442ca.js"><link rel="prefetch" href="/assets/js/224.642062b0.js"><link rel="prefetch" href="/assets/js/225.9b6f0752.js"><link rel="prefetch" href="/assets/js/226.4868d0a5.js"><link rel="prefetch" href="/assets/js/227.6ba50795.js"><link rel="prefetch" href="/assets/js/228.96c32a84.js"><link rel="prefetch" href="/assets/js/229.79ec0103.js"><link rel="prefetch" href="/assets/js/23.91ba0b88.js"><link rel="prefetch" href="/assets/js/230.eb3c9a16.js"><link rel="prefetch" href="/assets/js/231.dc2fe2df.js"><link rel="prefetch" href="/assets/js/232.5a6632a5.js"><link rel="prefetch" href="/assets/js/233.f79fadcf.js"><link rel="prefetch" href="/assets/js/234.bd229dea.js"><link rel="prefetch" href="/assets/js/235.b9343eea.js"><link rel="prefetch" href="/assets/js/236.39a58653.js"><link rel="prefetch" href="/assets/js/237.d795e1ce.js"><link rel="prefetch" href="/assets/js/238.0357593a.js"><link rel="prefetch" href="/assets/js/239.a96f58b0.js"><link rel="prefetch" href="/assets/js/24.de37758e.js"><link rel="prefetch" href="/assets/js/240.5023ae7f.js"><link rel="prefetch" href="/assets/js/241.b8bfff76.js"><link rel="prefetch" href="/assets/js/242.1006f57d.js"><link rel="prefetch" href="/assets/js/243.177605aa.js"><link rel="prefetch" href="/assets/js/244.49b5cc23.js"><link rel="prefetch" href="/assets/js/245.26270fbd.js"><link rel="prefetch" href="/assets/js/246.5ddc708b.js"><link rel="prefetch" href="/assets/js/247.adc9b00e.js"><link rel="prefetch" href="/assets/js/248.0dddc45e.js"><link rel="prefetch" href="/assets/js/249.86245d4b.js"><link rel="prefetch" href="/assets/js/25.77e4633a.js"><link rel="prefetch" href="/assets/js/250.ca664993.js"><link rel="prefetch" href="/assets/js/251.4110130e.js"><link rel="prefetch" href="/assets/js/252.69e52586.js"><link rel="prefetch" href="/assets/js/253.6a0b34fb.js"><link rel="prefetch" href="/assets/js/254.6d43bbe7.js"><link rel="prefetch" href="/assets/js/255.ef51c14f.js"><link rel="prefetch" href="/assets/js/256.e30632ae.js"><link rel="prefetch" href="/assets/js/257.8474f813.js"><link rel="prefetch" href="/assets/js/258.f4b72fd8.js"><link rel="prefetch" href="/assets/js/259.f9b80571.js"><link rel="prefetch" href="/assets/js/26.bc913725.js"><link rel="prefetch" href="/assets/js/260.890c3824.js"><link rel="prefetch" href="/assets/js/261.7a0e64a4.js"><link rel="prefetch" href="/assets/js/262.f1795204.js"><link rel="prefetch" href="/assets/js/263.4645793a.js"><link rel="prefetch" href="/assets/js/264.cedced53.js"><link rel="prefetch" href="/assets/js/265.f5999224.js"><link rel="prefetch" href="/assets/js/266.796b7845.js"><link rel="prefetch" href="/assets/js/267.6a6e0b45.js"><link rel="prefetch" href="/assets/js/268.e31ccc5d.js"><link rel="prefetch" href="/assets/js/269.87ec3c50.js"><link rel="prefetch" href="/assets/js/27.353617df.js"><link rel="prefetch" href="/assets/js/270.10c1f626.js"><link rel="prefetch" href="/assets/js/271.951311af.js"><link rel="prefetch" href="/assets/js/272.b88b9e6e.js"><link rel="prefetch" href="/assets/js/273.60491e24.js"><link rel="prefetch" href="/assets/js/274.256ac066.js"><link rel="prefetch" href="/assets/js/275.bc626957.js"><link rel="prefetch" href="/assets/js/276.bf42d85f.js"><link rel="prefetch" href="/assets/js/277.195beb55.js"><link rel="prefetch" href="/assets/js/278.f7da5f89.js"><link rel="prefetch" href="/assets/js/279.6238db1e.js"><link rel="prefetch" href="/assets/js/28.0a801078.js"><link rel="prefetch" href="/assets/js/280.4a586292.js"><link rel="prefetch" href="/assets/js/281.2b5d75c2.js"><link rel="prefetch" href="/assets/js/282.d71dd9d3.js"><link rel="prefetch" href="/assets/js/283.39b9ec0e.js"><link rel="prefetch" href="/assets/js/284.306b0a13.js"><link rel="prefetch" href="/assets/js/285.8e9ec7da.js"><link rel="prefetch" href="/assets/js/286.4c15caa2.js"><link rel="prefetch" href="/assets/js/287.4b071b23.js"><link rel="prefetch" href="/assets/js/288.8b780706.js"><link rel="prefetch" href="/assets/js/289.789f44e7.js"><link rel="prefetch" href="/assets/js/29.015a0cef.js"><link rel="prefetch" href="/assets/js/290.faf33e36.js"><link rel="prefetch" href="/assets/js/291.7fe43457.js"><link rel="prefetch" href="/assets/js/292.e00b421d.js"><link rel="prefetch" href="/assets/js/293.010cbc8b.js"><link rel="prefetch" href="/assets/js/294.dbc158e3.js"><link rel="prefetch" href="/assets/js/295.1e94dacc.js"><link rel="prefetch" href="/assets/js/296.77ae03d2.js"><link rel="prefetch" href="/assets/js/297.e548ba7e.js"><link rel="prefetch" href="/assets/js/298.9e64d086.js"><link rel="prefetch" href="/assets/js/299.a9495179.js"><link rel="prefetch" href="/assets/js/30.03cf4852.js"><link rel="prefetch" href="/assets/js/300.4a34e85e.js"><link rel="prefetch" href="/assets/js/301.646c292f.js"><link rel="prefetch" href="/assets/js/302.992ba1a4.js"><link rel="prefetch" href="/assets/js/303.2fa1659c.js"><link rel="prefetch" href="/assets/js/304.45ec5f49.js"><link rel="prefetch" href="/assets/js/305.c920feb8.js"><link rel="prefetch" href="/assets/js/306.9adbbd88.js"><link rel="prefetch" href="/assets/js/307.9236e6dd.js"><link rel="prefetch" href="/assets/js/308.f1153048.js"><link rel="prefetch" href="/assets/js/309.160e8998.js"><link rel="prefetch" href="/assets/js/31.9af92350.js"><link rel="prefetch" href="/assets/js/310.264c84d3.js"><link rel="prefetch" href="/assets/js/311.b0722a23.js"><link rel="prefetch" href="/assets/js/312.d6db71aa.js"><link rel="prefetch" href="/assets/js/313.56c40b4a.js"><link rel="prefetch" href="/assets/js/314.4430b382.js"><link rel="prefetch" href="/assets/js/315.c70120b9.js"><link rel="prefetch" href="/assets/js/316.f8399289.js"><link rel="prefetch" href="/assets/js/317.1de6d257.js"><link rel="prefetch" href="/assets/js/318.91c96271.js"><link rel="prefetch" href="/assets/js/319.eb7b75c1.js"><link rel="prefetch" href="/assets/js/32.e5e702b0.js"><link rel="prefetch" href="/assets/js/320.cc4206e7.js"><link rel="prefetch" href="/assets/js/321.a4b9d736.js"><link rel="prefetch" href="/assets/js/322.5aae6989.js"><link rel="prefetch" href="/assets/js/323.e4fd51b3.js"><link rel="prefetch" href="/assets/js/324.1ba3ee32.js"><link rel="prefetch" href="/assets/js/325.d92a5a32.js"><link rel="prefetch" href="/assets/js/326.176dd708.js"><link rel="prefetch" href="/assets/js/327.974ddc21.js"><link rel="prefetch" href="/assets/js/328.7be0fd73.js"><link rel="prefetch" href="/assets/js/329.c7ddf3b9.js"><link rel="prefetch" href="/assets/js/33.d0eafbb9.js"><link rel="prefetch" href="/assets/js/330.bd9e4aaa.js"><link rel="prefetch" href="/assets/js/331.0930a354.js"><link rel="prefetch" href="/assets/js/332.fb2e17c5.js"><link rel="prefetch" href="/assets/js/333.6a30384d.js"><link rel="prefetch" href="/assets/js/334.c3a65c90.js"><link rel="prefetch" href="/assets/js/335.925d4e40.js"><link rel="prefetch" href="/assets/js/336.d57e25c2.js"><link rel="prefetch" href="/assets/js/337.0231a5b2.js"><link rel="prefetch" href="/assets/js/338.6cda9f6a.js"><link rel="prefetch" href="/assets/js/339.bbf73c4f.js"><link rel="prefetch" href="/assets/js/34.85849ed4.js"><link rel="prefetch" href="/assets/js/340.f50cc5bc.js"><link rel="prefetch" href="/assets/js/341.bb11443e.js"><link rel="prefetch" href="/assets/js/342.0657d637.js"><link rel="prefetch" href="/assets/js/343.6757b598.js"><link rel="prefetch" href="/assets/js/344.eb356eae.js"><link rel="prefetch" href="/assets/js/345.e61fd7a0.js"><link rel="prefetch" href="/assets/js/346.cbfb04f4.js"><link rel="prefetch" href="/assets/js/347.38bbefab.js"><link rel="prefetch" href="/assets/js/348.53daceee.js"><link rel="prefetch" href="/assets/js/349.cf4bf014.js"><link rel="prefetch" href="/assets/js/35.5612ab6a.js"><link rel="prefetch" href="/assets/js/351.70c60d7d.js"><link rel="prefetch" href="/assets/js/352.38c78131.js"><link rel="prefetch" href="/assets/js/353.8c271a83.js"><link rel="prefetch" href="/assets/js/354.f07fe232.js"><link rel="prefetch" href="/assets/js/355.75b97cf0.js"><link rel="prefetch" href="/assets/js/356.7e54a7f7.js"><link rel="prefetch" href="/assets/js/357.186ba021.js"><link rel="prefetch" href="/assets/js/358.239bc6cd.js"><link rel="prefetch" href="/assets/js/359.5b5efbc0.js"><link rel="prefetch" href="/assets/js/36.5a401e9f.js"><link rel="prefetch" href="/assets/js/360.dc8c37e4.js"><link rel="prefetch" href="/assets/js/361.0ffc00b2.js"><link rel="prefetch" href="/assets/js/362.0b44b216.js"><link rel="prefetch" href="/assets/js/363.957ae19e.js"><link rel="prefetch" href="/assets/js/364.f744f1cf.js"><link rel="prefetch" href="/assets/js/365.228a2005.js"><link rel="prefetch" href="/assets/js/366.6dc37394.js"><link rel="prefetch" href="/assets/js/367.56ff065b.js"><link rel="prefetch" href="/assets/js/368.9689ca0c.js"><link rel="prefetch" href="/assets/js/369.ed6d9c14.js"><link rel="prefetch" href="/assets/js/37.692720e1.js"><link rel="prefetch" href="/assets/js/370.584442b6.js"><link rel="prefetch" href="/assets/js/371.770d40de.js"><link rel="prefetch" href="/assets/js/372.6b44d26d.js"><link rel="prefetch" href="/assets/js/373.4548d4c0.js"><link rel="prefetch" href="/assets/js/374.e347ead4.js"><link rel="prefetch" href="/assets/js/375.774420c2.js"><link rel="prefetch" href="/assets/js/376.4b504e94.js"><link rel="prefetch" href="/assets/js/377.e3d4af2c.js"><link rel="prefetch" href="/assets/js/378.8265e3af.js"><link rel="prefetch" href="/assets/js/379.06514b26.js"><link rel="prefetch" href="/assets/js/38.eebc30e0.js"><link rel="prefetch" href="/assets/js/380.413183d4.js"><link rel="prefetch" href="/assets/js/381.570e7c14.js"><link rel="prefetch" href="/assets/js/382.6e94a17d.js"><link rel="prefetch" href="/assets/js/383.ab06426d.js"><link rel="prefetch" href="/assets/js/384.8cde732c.js"><link rel="prefetch" href="/assets/js/385.edbe545d.js"><link rel="prefetch" href="/assets/js/386.5edbd64b.js"><link rel="prefetch" href="/assets/js/387.d08b9da1.js"><link rel="prefetch" href="/assets/js/388.3cafa76f.js"><link rel="prefetch" href="/assets/js/389.ac1c71b5.js"><link rel="prefetch" href="/assets/js/39.9ccd0236.js"><link rel="prefetch" href="/assets/js/390.e3c6dc5b.js"><link rel="prefetch" href="/assets/js/391.097ce5d5.js"><link rel="prefetch" href="/assets/js/392.6c36a3c8.js"><link rel="prefetch" href="/assets/js/393.cc10c814.js"><link rel="prefetch" href="/assets/js/394.0f496e89.js"><link rel="prefetch" href="/assets/js/395.829eba9f.js"><link rel="prefetch" href="/assets/js/396.3ff26d83.js"><link rel="prefetch" href="/assets/js/397.bee7fd8b.js"><link rel="prefetch" href="/assets/js/398.812712cf.js"><link rel="prefetch" href="/assets/js/399.359fa7fe.js"><link rel="prefetch" href="/assets/js/4.9c4b1c6d.js"><link rel="prefetch" href="/assets/js/40.78497aeb.js"><link rel="prefetch" href="/assets/js/400.39779156.js"><link rel="prefetch" href="/assets/js/401.df776005.js"><link rel="prefetch" href="/assets/js/402.be1f5783.js"><link rel="prefetch" href="/assets/js/403.8856d7b1.js"><link rel="prefetch" href="/assets/js/404.562089b0.js"><link rel="prefetch" href="/assets/js/405.93f42baf.js"><link rel="prefetch" href="/assets/js/406.8dbc7179.js"><link rel="prefetch" href="/assets/js/407.ab430854.js"><link rel="prefetch" href="/assets/js/408.78190c9f.js"><link rel="prefetch" href="/assets/js/409.5885c231.js"><link rel="prefetch" href="/assets/js/41.f483212d.js"><link rel="prefetch" href="/assets/js/410.b081220a.js"><link rel="prefetch" href="/assets/js/411.a36444c4.js"><link rel="prefetch" href="/assets/js/412.ceb1c2f9.js"><link rel="prefetch" href="/assets/js/413.9a587755.js"><link rel="prefetch" href="/assets/js/414.76fbf607.js"><link rel="prefetch" href="/assets/js/415.4dcc07c7.js"><link rel="prefetch" href="/assets/js/416.67a151b4.js"><link rel="prefetch" href="/assets/js/417.8f1f6147.js"><link rel="prefetch" href="/assets/js/418.d5fc9d05.js"><link rel="prefetch" href="/assets/js/419.540dcd2a.js"><link rel="prefetch" href="/assets/js/42.ffb032af.js"><link rel="prefetch" href="/assets/js/420.6e0a10f2.js"><link rel="prefetch" href="/assets/js/421.a6c3c8af.js"><link rel="prefetch" href="/assets/js/422.47653244.js"><link rel="prefetch" href="/assets/js/423.cb7eba6d.js"><link rel="prefetch" href="/assets/js/424.9d5aa304.js"><link rel="prefetch" href="/assets/js/425.d2f6e40e.js"><link rel="prefetch" href="/assets/js/426.d6deb76a.js"><link rel="prefetch" href="/assets/js/427.d39d619c.js"><link rel="prefetch" href="/assets/js/428.6e4e5abb.js"><link rel="prefetch" href="/assets/js/429.0f2edacf.js"><link rel="prefetch" href="/assets/js/43.7406f914.js"><link rel="prefetch" href="/assets/js/430.ddcfba32.js"><link rel="prefetch" href="/assets/js/431.5ecf6e5d.js"><link rel="prefetch" href="/assets/js/432.b578015e.js"><link rel="prefetch" href="/assets/js/433.90540732.js"><link rel="prefetch" href="/assets/js/434.04a8d2c6.js"><link rel="prefetch" href="/assets/js/435.959e7362.js"><link rel="prefetch" href="/assets/js/436.891b6ce7.js"><link rel="prefetch" href="/assets/js/437.7c983dad.js"><link rel="prefetch" href="/assets/js/438.f7e133f1.js"><link rel="prefetch" href="/assets/js/439.692da598.js"><link rel="prefetch" href="/assets/js/44.3bea749e.js"><link rel="prefetch" href="/assets/js/440.2971f4ef.js"><link rel="prefetch" href="/assets/js/441.e12292fb.js"><link rel="prefetch" href="/assets/js/442.08f60114.js"><link rel="prefetch" href="/assets/js/443.9f684f2a.js"><link rel="prefetch" href="/assets/js/444.d100eb74.js"><link rel="prefetch" href="/assets/js/445.733e07b3.js"><link rel="prefetch" href="/assets/js/446.b1a5daaf.js"><link rel="prefetch" href="/assets/js/447.b565b8e7.js"><link rel="prefetch" href="/assets/js/448.c4d1c15e.js"><link rel="prefetch" href="/assets/js/449.f9f855be.js"><link rel="prefetch" href="/assets/js/45.4f6dc502.js"><link rel="prefetch" href="/assets/js/450.3ff3ce7b.js"><link rel="prefetch" href="/assets/js/451.f43857ff.js"><link rel="prefetch" href="/assets/js/452.3a8bb15a.js"><link rel="prefetch" href="/assets/js/453.4d5d4319.js"><link rel="prefetch" href="/assets/js/454.e0838804.js"><link rel="prefetch" href="/assets/js/455.86256c6f.js"><link rel="prefetch" href="/assets/js/456.98d95ce5.js"><link rel="prefetch" href="/assets/js/457.27f821d2.js"><link rel="prefetch" href="/assets/js/458.0e11d249.js"><link rel="prefetch" href="/assets/js/459.6b8af96a.js"><link rel="prefetch" href="/assets/js/46.e460983d.js"><link rel="prefetch" href="/assets/js/460.5294a47f.js"><link rel="prefetch" href="/assets/js/461.5cb7cfb1.js"><link rel="prefetch" href="/assets/js/462.214e91ce.js"><link rel="prefetch" href="/assets/js/463.54494074.js"><link rel="prefetch" href="/assets/js/464.0e1615f7.js"><link rel="prefetch" href="/assets/js/465.c61d57fa.js"><link rel="prefetch" href="/assets/js/466.88c375a9.js"><link rel="prefetch" href="/assets/js/467.b3f00de3.js"><link rel="prefetch" href="/assets/js/468.8f2561ff.js"><link rel="prefetch" href="/assets/js/469.741b348f.js"><link rel="prefetch" href="/assets/js/47.e56ee397.js"><link rel="prefetch" href="/assets/js/470.ba1d5a08.js"><link rel="prefetch" href="/assets/js/471.9842c3d9.js"><link rel="prefetch" href="/assets/js/472.887667b1.js"><link rel="prefetch" href="/assets/js/473.ac9f4dc8.js"><link rel="prefetch" href="/assets/js/474.7ab2ad2f.js"><link rel="prefetch" href="/assets/js/475.04c8df23.js"><link rel="prefetch" href="/assets/js/476.369e6ad4.js"><link rel="prefetch" href="/assets/js/477.cd44b6c4.js"><link rel="prefetch" href="/assets/js/478.1c4e292d.js"><link rel="prefetch" href="/assets/js/479.18311c46.js"><link rel="prefetch" href="/assets/js/48.bec9faeb.js"><link rel="prefetch" href="/assets/js/480.6a119ed5.js"><link rel="prefetch" href="/assets/js/481.6504abc3.js"><link rel="prefetch" href="/assets/js/482.a0850ad4.js"><link rel="prefetch" href="/assets/js/483.11c430e0.js"><link rel="prefetch" href="/assets/js/484.cb6bc4a3.js"><link rel="prefetch" href="/assets/js/485.fef6bd3e.js"><link rel="prefetch" href="/assets/js/486.9cbb009e.js"><link rel="prefetch" href="/assets/js/487.bf3ac79b.js"><link rel="prefetch" href="/assets/js/488.cdeb35a5.js"><link rel="prefetch" href="/assets/js/489.dad79eab.js"><link rel="prefetch" href="/assets/js/49.f271ac34.js"><link rel="prefetch" href="/assets/js/490.61225193.js"><link rel="prefetch" href="/assets/js/491.862665a1.js"><link rel="prefetch" href="/assets/js/492.e16d11e1.js"><link rel="prefetch" href="/assets/js/493.83997cf9.js"><link rel="prefetch" href="/assets/js/494.607eaccf.js"><link rel="prefetch" href="/assets/js/495.47d53a9a.js"><link rel="prefetch" href="/assets/js/496.166c88c4.js"><link rel="prefetch" href="/assets/js/497.3b9635e2.js"><link rel="prefetch" href="/assets/js/498.8e8025ec.js"><link rel="prefetch" href="/assets/js/499.22f6be18.js"><link rel="prefetch" href="/assets/js/5.2a4451ec.js"><link rel="prefetch" href="/assets/js/50.e60dabfc.js"><link rel="prefetch" href="/assets/js/500.517d8628.js"><link rel="prefetch" href="/assets/js/501.c5ae8bda.js"><link rel="prefetch" href="/assets/js/502.3dc27869.js"><link rel="prefetch" href="/assets/js/503.d6cc184c.js"><link rel="prefetch" href="/assets/js/504.203d7395.js"><link rel="prefetch" href="/assets/js/505.6cf56773.js"><link rel="prefetch" href="/assets/js/506.ccaa022c.js"><link rel="prefetch" href="/assets/js/507.1fc56592.js"><link rel="prefetch" href="/assets/js/508.1250eed8.js"><link rel="prefetch" href="/assets/js/509.a1a7285a.js"><link rel="prefetch" href="/assets/js/51.fd01b1a1.js"><link rel="prefetch" href="/assets/js/510.de535a70.js"><link rel="prefetch" href="/assets/js/511.c6a7f5d8.js"><link rel="prefetch" href="/assets/js/512.dca82ab9.js"><link rel="prefetch" href="/assets/js/513.8d501ad4.js"><link rel="prefetch" href="/assets/js/514.b07be8d6.js"><link rel="prefetch" href="/assets/js/515.9ea728dd.js"><link rel="prefetch" href="/assets/js/516.3cccca96.js"><link rel="prefetch" href="/assets/js/517.1d7ee046.js"><link rel="prefetch" href="/assets/js/518.05cb30e8.js"><link rel="prefetch" href="/assets/js/519.f838c1ca.js"><link rel="prefetch" href="/assets/js/52.c17bb00d.js"><link rel="prefetch" href="/assets/js/520.e41e66ce.js"><link rel="prefetch" href="/assets/js/521.4726d233.js"><link rel="prefetch" href="/assets/js/522.045aff30.js"><link rel="prefetch" href="/assets/js/523.9d9b45b5.js"><link rel="prefetch" href="/assets/js/524.9ff01ede.js"><link rel="prefetch" href="/assets/js/525.ba766db5.js"><link rel="prefetch" href="/assets/js/526.9f70e3c0.js"><link rel="prefetch" href="/assets/js/527.1af75ed9.js"><link rel="prefetch" href="/assets/js/528.85194f33.js"><link rel="prefetch" href="/assets/js/529.7f05b847.js"><link rel="prefetch" href="/assets/js/53.f69e6824.js"><link rel="prefetch" href="/assets/js/530.4f9b779c.js"><link rel="prefetch" href="/assets/js/531.54b0ee66.js"><link rel="prefetch" href="/assets/js/532.7107ab4b.js"><link rel="prefetch" href="/assets/js/54.29e4a381.js"><link rel="prefetch" href="/assets/js/55.9d4b8667.js"><link rel="prefetch" href="/assets/js/56.00691552.js"><link rel="prefetch" href="/assets/js/57.c942381a.js"><link rel="prefetch" href="/assets/js/58.89130d49.js"><link rel="prefetch" href="/assets/js/59.f0da0bf3.js"><link rel="prefetch" href="/assets/js/6.3450075a.js"><link rel="prefetch" href="/assets/js/60.53b7d88b.js"><link rel="prefetch" href="/assets/js/61.b70ccd57.js"><link rel="prefetch" href="/assets/js/62.ca60798b.js"><link rel="prefetch" href="/assets/js/63.ba337fc9.js"><link rel="prefetch" href="/assets/js/64.ed6b77b6.js"><link rel="prefetch" href="/assets/js/65.1dbdb0ee.js"><link rel="prefetch" href="/assets/js/66.aa4ead2c.js"><link rel="prefetch" href="/assets/js/67.29edf638.js"><link rel="prefetch" href="/assets/js/68.b614ca3d.js"><link rel="prefetch" href="/assets/js/69.8f65fe0a.js"><link rel="prefetch" href="/assets/js/7.c5c54fb4.js"><link rel="prefetch" href="/assets/js/70.dade9939.js"><link rel="prefetch" href="/assets/js/71.dbdc4216.js"><link rel="prefetch" href="/assets/js/72.37c2db55.js"><link rel="prefetch" href="/assets/js/73.40fb8290.js"><link rel="prefetch" href="/assets/js/74.6fb3093b.js"><link rel="prefetch" href="/assets/js/75.d96505fe.js"><link rel="prefetch" href="/assets/js/76.9c4f055c.js"><link rel="prefetch" href="/assets/js/77.3c1e294c.js"><link rel="prefetch" href="/assets/js/78.202bcf6c.js"><link rel="prefetch" href="/assets/js/79.4e6d41b0.js"><link rel="prefetch" href="/assets/js/8.68d2fe5c.js"><link rel="prefetch" href="/assets/js/80.8358bd99.js"><link rel="prefetch" href="/assets/js/81.b603dd42.js"><link rel="prefetch" href="/assets/js/82.bebbea34.js"><link rel="prefetch" href="/assets/js/83.764d566c.js"><link rel="prefetch" href="/assets/js/84.4867883c.js"><link rel="prefetch" href="/assets/js/85.bfe2dffd.js"><link rel="prefetch" href="/assets/js/86.0d9031f6.js"><link rel="prefetch" href="/assets/js/87.88112820.js"><link rel="prefetch" href="/assets/js/88.208d123f.js"><link rel="prefetch" href="/assets/js/89.75ed1194.js"><link rel="prefetch" href="/assets/js/9.e94d434b.js"><link rel="prefetch" href="/assets/js/90.7f184d9a.js"><link rel="prefetch" href="/assets/js/91.6595997c.js"><link rel="prefetch" href="/assets/js/92.791938c3.js"><link rel="prefetch" href="/assets/js/93.8bd8d987.js"><link rel="prefetch" href="/assets/js/94.0e7734d3.js"><link rel="prefetch" href="/assets/js/95.45187f8f.js"><link rel="prefetch" href="/assets/js/96.6b29372c.js"><link rel="prefetch" href="/assets/js/97.7eaeb339.js"><link rel="prefetch" href="/assets/js/98.391d8ef3.js"><link rel="prefetch" href="/assets/js/99.8e370fea.js"><link rel="prefetch" href="/assets/js/vendors~docsearch.eff714eb.js">
<link rel="stylesheet" href="/assets/css/0.styles.ccadf850.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/zh/" class="home-link router-link-active"><img src="/img/logo.png" alt=" " class="logo"></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">文档</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/zh/UserGuide/Master/Get Started/QuickStart.html" class="nav-link">In progress</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.11.x/Get Started/QuickStart.html" class="nav-link">V0.11.x</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.10.x/Get Started/QuickStart.html" class="nav-link">V0.10.x</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.9.x/0-Get Started/1-QuickStart.html" class="nav-link">V0.9.x</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.8.x/0-Get Started/1-QuickStart.html" class="nav-link">V0.8.x</a></li></ul></div></div><div class="nav-item"><a href="/zh/SystemDesign/Architecture/Architecture.html" class="nav-link">系统设计</a></div><div class="nav-item"><a href="/zh/Download/" class="nav-link">下载</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">社区</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://cwiki.apache.org/confluence/display/iotdb" class="nav-link external">
Wiki
<!----></a></li><li class="dropdown-item"><!----> <a href="/zh/Community/Community-Project Committers.html" class="nav-link">开发人员</a></li><li class="dropdown-item"><!----> <a href="/zh/Community/Community-Powered By.html" class="nav-link">技术支持</a></li><li class="dropdown-item"><!----> <a href="/Community/Materials.html" class="nav-link">活动与报告</a></li><li class="dropdown-item"><!----> <a href="/zh/Community/Feedback.html" class="nav-link">交流与反馈</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">开发</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/zh/Development/VoteRelease.html" class="nav-link">如何投票</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/HowToCommit.html" class="nav-link">如何提交代码</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/Committer.html" class="nav-link">成为Committer</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/ContributeGuide.html" class="nav-link">项目开发指南</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/format-changelist.html" class="nav-link">TsFile的更改列表</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/rpc-changelist.html" class="nav-link">RPC变更清单</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">ASF</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="http://www.apache.org/" class="nav-link external">
基金会
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/licenses/" class="nav-link external">
许可证
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/security/" class="nav-link external">
安全
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/foundation/sponsorship.html" class="nav-link external">
赞助
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/foundation/thanks.html" class="nav-link external">
致谢
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/events/current-event" class="nav-link external">
活动
<!----></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">语言</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/UserGuide/Master/Operation Manual/UDF User Defined Function.html" class="nav-link">English</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/Master/Operation Manual/UDF User Defined Function.html" class="nav-link">简体中文</a></li></ul></div></div> <a href="https://github.com/apache/iotdb.git" target="_blank" rel="noopener noreferrer" class="repo-link">
gitHub
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">文档</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/zh/UserGuide/Master/Get Started/QuickStart.html" class="nav-link">In progress</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.11.x/Get Started/QuickStart.html" class="nav-link">V0.11.x</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.10.x/Get Started/QuickStart.html" class="nav-link">V0.10.x</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.9.x/0-Get Started/1-QuickStart.html" class="nav-link">V0.9.x</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/V0.8.x/0-Get Started/1-QuickStart.html" class="nav-link">V0.8.x</a></li></ul></div></div><div class="nav-item"><a href="/zh/SystemDesign/Architecture/Architecture.html" class="nav-link">系统设计</a></div><div class="nav-item"><a href="/zh/Download/" class="nav-link">下载</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">社区</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://cwiki.apache.org/confluence/display/iotdb" class="nav-link external">
Wiki
<!----></a></li><li class="dropdown-item"><!----> <a href="/zh/Community/Community-Project Committers.html" class="nav-link">开发人员</a></li><li class="dropdown-item"><!----> <a href="/zh/Community/Community-Powered By.html" class="nav-link">技术支持</a></li><li class="dropdown-item"><!----> <a href="/Community/Materials.html" class="nav-link">活动与报告</a></li><li class="dropdown-item"><!----> <a href="/zh/Community/Feedback.html" class="nav-link">交流与反馈</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">开发</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/zh/Development/VoteRelease.html" class="nav-link">如何投票</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/HowToCommit.html" class="nav-link">如何提交代码</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/Committer.html" class="nav-link">成为Committer</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/ContributeGuide.html" class="nav-link">项目开发指南</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/format-changelist.html" class="nav-link">TsFile的更改列表</a></li><li class="dropdown-item"><!----> <a href="/zh/Development/rpc-changelist.html" class="nav-link">RPC变更清单</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">ASF</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="http://www.apache.org/" class="nav-link external">
基金会
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/licenses/" class="nav-link external">
许可证
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/security/" class="nav-link external">
安全
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/foundation/sponsorship.html" class="nav-link external">
赞助
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/foundation/thanks.html" class="nav-link external">
致谢
<!----></a></li><li class="dropdown-item"><!----> <a href="http://www.apache.org/events/current-event" class="nav-link external">
活动
<!----></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">语言</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/UserGuide/Master/Operation Manual/UDF User Defined Function.html" class="nav-link">English</a></li><li class="dropdown-item"><!----> <a href="/zh/UserGuide/Master/Operation Manual/UDF User Defined Function.html" class="nav-link">简体中文</a></li></ul></div></div> <a href="https://github.com/apache/iotdb.git" target="_blank" rel="noopener noreferrer" class="repo-link">
gitHub
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>IoTDB用户手册 (In progress)</span> <!----></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>概述</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>概念</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>服务器端</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>客户端</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>操作指南</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/zh/UserGuide/Master/Operation Manual/DDL Data Definition Language.html" class="sidebar-link">DDL (数据定义语言)</a></li><li><a href="/zh/UserGuide/Master/Operation Manual/DML Data Manipulation Language.html" class="sidebar-link">DML (数据操作语言)</a></li><li><a href="/zh/UserGuide/Master/Operation Manual/UDF User Defined Function.html" class="active sidebar-link">UDF(用户自定义函数)</a></li><li><a href="/zh/UserGuide/Master/Operation Manual/Kill Query.html" class="sidebar-link">中止查询</a></li><li><a href="/zh/UserGuide/Master/Operation Manual/Administration.html" class="sidebar-link">权限管理语句</a></li><li><a href="/zh/UserGuide/Master/Operation Manual/SQL Reference.html" class="sidebar-link">SQL 参考文档</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>系统工具</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>生态集成</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>系统设计</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="content content__default"><h1 id="udf-用户定义函数"><a href="#udf-用户定义函数" class="header-anchor">#</a> UDF (用户定义函数)</h1> <p>UDF(User Defined Function)即用户自定义函数。IoTDB提供多种内建函数来满足您的计算需求,同时您还可以通过创建自定义函数来满足更多的计算需求。</p> <p>根据此文档,您将会很快学会UDF的编写、注册、使用等操作。</p> <h2 id="udf分类"><a href="#udf分类" class="header-anchor">#</a> UDF分类</h2> <p>IoTDB 支持两种类型的 UDF 函数,如下表所示。</p> <table><thead><tr><th>UDF 分类</th> <th>描述</th></tr></thead> <tbody><tr><td>UDTF(User Defined Timeseries Generating Function)</td> <td>自定义时间序列生成函数。该类函数允许接收多条时间序列,最终会输出一条时间序列,生成的时间序列可以有任意多数量的数据点。</td></tr> <tr><td>UDAF(User Defined Aggregation Function)</td> <td>正在开发,敬请期待。</td></tr></tbody></table> <h2 id="udf依赖"><a href="#udf依赖" class="header-anchor">#</a> UDF依赖</h2> <p>如果您使用<a href="http://search.maven.org/" target="_blank" rel="noopener noreferrer">Maven<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>,可以从<a href="http://search.maven.org/" target="_blank" rel="noopener noreferrer">Maven库<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>中搜索下面示例中的依赖。请注意选择和目标IoTDB服务器版本相同的依赖版本。</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.iotdb<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>iotdb-server<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.12.0-SNAPSHOT<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>scope</span><span class="token punctuation">&gt;</span></span>provided<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>scope</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="udtf-user-defined-timeseries-generating-function"><a href="#udtf-user-defined-timeseries-generating-function" class="header-anchor">#</a> UDTF(User Defined Timeseries Generating Function)</h2> <p>编写一个UDTF需要继承<code>org.apache.iotdb.db.query.udf.api.UDTF</code>类,并至少实现<code>beforeStart</code>方法和一种<code>transform</code>方法。</p> <p>下表是所有可供用户实现的接口说明。</p> <table><thead><tr><th style="text-align:left;">接口定义</th> <th style="text-align:left;">描述</th> <th>是否必须</th></tr></thead> <tbody><tr><td style="text-align:left;"><code>void validate(UDFParameterValidator validator) throws Exception</code></td> <td style="text-align:left;">在初始化方法<code>beforeStart</code>调用前执行,用于检测<code>UDFParameters</code>中用户输入的参数是否合法。</td> <td></td></tr> <tr><td style="text-align:left;"><code>void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) throws Exception</code></td> <td style="text-align:left;">初始化方法,在UDTF处理输入数据前,调用用户自定义的初始化行为。用户每执行一次UDTF查询,框架就会构造一个新的UDF类实例,该方法在每个UDF类实例被初始化时调用一次。在每一个UDF类实例的生命周期内,该方法只会被调用一次。</td> <td></td></tr> <tr><td style="text-align:left;"><code>void transform(Row row, PointCollector collector) throws Exception</code></td> <td style="text-align:left;">这个方法由框架调用。当您在<code>beforeStart</code>中选择以<code>RowByRowAccessStrategy</code>的策略消费原始数据时,这个数据处理方法就会被调用。输入参数以<code>Row</code>的形式传入,输出结果通过<code>PointCollector</code>输出。您需要在该方法内自行调用<code>collector</code>提供的数据收集方法,以决定最终的输出数据。</td> <td>与下面的方法二选一</td></tr> <tr><td style="text-align:left;"><code>void transform(RowWindow rowWindow, PointCollector collector) throws Exception</code></td> <td style="text-align:left;">这个方法由框架调用。当您在<code>beforeStart</code>中选择以<code>SlidingSizeWindowAccessStrategy</code>或者<code>SlidingTimeWindowAccessStrategy</code>的策略消费原始数据时,这个数据处理方法就会被调用。输入参数以<code>RowWindow</code>的形式传入,输出结果通过<code>PointCollector</code>输出。您需要在该方法内自行调用<code>collector</code>提供的数据收集方法,以决定最终的输出数据。</td> <td>与上面的方法二选一</td></tr> <tr><td style="text-align:left;"><code>void terminate(PointCollector collector) throws Exception</code></td> <td style="text-align:left;">这个方法由框架调用。该方法会在所有的<code>transform</code>调用执行完成后,在<code>beforeDestory</code>方法执行前被调用。在一个UDF查询过程中,该方法会且只会调用一次。您需要在该方法内自行调用<code>collector</code>提供的数据收集方法,以决定最终的输出数据。</td> <td></td></tr> <tr><td style="text-align:left;"><code>void beforeDestroy()</code></td> <td style="text-align:left;">UDTF的结束方法。此方法由框架调用,并且只会被调用一次,即在处理完最后一条记录之后被调用。</td> <td></td></tr></tbody></table> <p>在一个完整的UDTF实例生命周期中,各个方法的调用顺序如下:</p> <ol><li><code>void validate(UDFParameterValidator validator) throws Exception</code></li> <li><code>void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) throws Exception</code></li> <li><code>void transform(Row row, PointCollector collector) throws Exception</code>或者<code>void transform(RowWindow rowWindow, PointCollector collector) throws Exception</code></li> <li><code>void terminate(PointCollector collector) throws Exception</code></li> <li><code>void beforeDestroy()</code></li></ol> <p>注意,框架每执行一次UDTF查询,都会构造一个全新的UDF类实例,查询结束时,对应的UDF类实例即被销毁,因此不同UDTF查询(即使是在同一个SQL语句中)UDF类实例内部的数据都是隔离的。您可以放心地在UDTF中维护一些状态数据,无需考虑并发对UDF类实例内部状态数据的影响。</p> <p>下面将详细介绍各个接口的使用方法。</p> <h3 id="void-validate-udfparametervalidator-validator-throws-exception"><a href="#void-validate-udfparametervalidator-validator-throws-exception" class="header-anchor">#</a> void validate(UDFParameterValidator validator) throws Exception</h3> <p><code>validate</code>方法能够对用户输入的参数进行验证。</p> <p>您可以在该方法中限制输入序列的数量和类型,检查用户输入的属性或者进行自定义逻辑的验证。</p> <p><code>UDFParameterValidator</code>的使用方法请见Javadoc。</p> <h3 id="void-beforestart-udfparameters-parameters-udtfconfigurations-configurations-throws-exception"><a href="#void-beforestart-udfparameters-parameters-udtfconfigurations-configurations-throws-exception" class="header-anchor">#</a> void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) throws Exception</h3> <p><code>beforeStart</code>方法有两个作用:</p> <ol><li>帮助用户解析SQL语句中的UDF参数</li> <li>配置UDF运行时必要的信息,即指定UDF访问原始数据时采取的策略和输出结果序列的类型</li> <li>创建资源,比如建立外部链接,打开文件等。</li></ol> <h4 id="udfparameters"><a href="#udfparameters" class="header-anchor">#</a> UDFParameters</h4> <p><code>UDFParameters</code>的作用是解析SQL语句中的UDF参数(SQL中UDF函数名称后括号中的部分)。参数包括路径(及其序列类型)参数和字符串key-value对形式输入的属性参数。</p> <p>例子:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">SELECT</span> UDF<span class="token punctuation">(</span>s1<span class="token punctuation">,</span> s2<span class="token punctuation">,</span> <span class="token string">'key1'</span><span class="token operator">=</span><span class="token string">'iotdb'</span><span class="token punctuation">,</span> <span class="token string">'key2'</span><span class="token operator">=</span><span class="token string">'123.45'</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> root<span class="token punctuation">.</span>sg<span class="token punctuation">.</span>d<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>用法:</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">void</span> <span class="token function">beforeStart</span><span class="token punctuation">(</span><span class="token class-name">UDFParameters</span> parameters<span class="token punctuation">,</span> <span class="token class-name">UDTFConfigurations</span> configurations<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
<span class="token comment">// parameters</span>
<span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">PartialPath</span> path <span class="token operator">:</span> parameters<span class="token punctuation">.</span><span class="token function">getPaths</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token class-name">TSDataType</span> dataType <span class="token operator">=</span> parameters<span class="token punctuation">.</span><span class="token function">getDataType</span><span class="token punctuation">(</span>path<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// do something</span>
<span class="token punctuation">}</span>
<span class="token class-name">String</span> stringValue <span class="token operator">=</span> parameters<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;key1&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// iotdb</span>
<span class="token class-name">Float</span> floatValue <span class="token operator">=</span> parameters<span class="token punctuation">.</span><span class="token function">getFloat</span><span class="token punctuation">(</span><span class="token string">&quot;key2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 123.45</span>
<span class="token class-name">Double</span> doubleValue <span class="token operator">=</span> parameters<span class="token punctuation">.</span><span class="token function">getDouble</span><span class="token punctuation">(</span><span class="token string">&quot;key3&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// null</span>
<span class="token keyword">int</span> intValue <span class="token operator">=</span> parameters<span class="token punctuation">.</span><span class="token function">getIntOrDefault</span><span class="token punctuation">(</span><span class="token string">&quot;key4&quot;</span><span class="token punctuation">,</span> <span class="token number">678</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 678</span>
<span class="token comment">// do something</span>
<span class="token comment">// configurations</span>
<span class="token comment">// ...</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h4 id="udtfconfigurations"><a href="#udtfconfigurations" class="header-anchor">#</a> UDTFConfigurations</h4> <p>您必须使用 <code>UDTFConfigurations</code> 指定UDF访问原始数据时采取的策略和输出结果序列的类型。</p> <p>用法:</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">void</span> <span class="token function">beforeStart</span><span class="token punctuation">(</span><span class="token class-name">UDFParameters</span> parameters<span class="token punctuation">,</span> <span class="token class-name">UDTFConfigurations</span> configurations<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
<span class="token comment">// parameters</span>
<span class="token comment">// ...</span>
<span class="token comment">// configurations</span>
configurations
<span class="token punctuation">.</span><span class="token function">setAccessStrategy</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">RowByRowAccessStrategy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">setOutputDataType</span><span class="token punctuation">(</span><span class="token class-name">TSDataType</span><span class="token punctuation">.</span>INT32<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>其中<code>setAccessStrategy</code>方法用于设定UDF访问原始数据时采取的策略,<code>setOutputDataType</code>用于设定输出结果序列的类型。</p> <h5 id="setaccessstrategy"><a href="#setaccessstrategy" class="header-anchor">#</a> setAccessStrategy</h5> <p>注意,您在此处设定的原始数据访问策略决定了框架会调用哪一种<code>transform</code>方法 ,请实现与原始数据访问策略对应的<code>transform</code>方法。当然,您也可以根据<code>UDFParameters</code>解析出来的属性参数,动态决定设定哪一种策略,因此,实现两种<code>transform</code>方法也是被允许的。</p> <p>下面是您可以设定的访问原始数据的策略:</p> <table><thead><tr><th style="text-align:left;">接口定义</th> <th style="text-align:left;">描述</th> <th>调用的<code>transform</code>方法</th></tr></thead> <tbody><tr><td style="text-align:left;"><code>RowByRowAccessStrategy</code></td> <td style="text-align:left;">逐行地处理原始数据。框架会为每一行原始数据输入调用一次<code>transform</code>方法。当UDF只有一个输入序列时,一行输入就是该输入序列中的一个数据点。当UDF有多个输入序列时,一行输入序列对应的是这些输入序列按时间对齐后的结果(一行数据中,可能存在某一列为<code>null</code>值,但不会全部都是<code>null</code>)。</td> <td><code>void transform(Row row, PointCollector collector) throws Exception</code></td></tr> <tr><td style="text-align:left;"><code>SlidingTimeWindowAccessStrategy</code></td> <td style="text-align:left;">以滑动时间窗口的方式处理原始数据。框架会为每一个原始数据输入窗口调用一次<code>transform</code>方法。一个窗口可能存在多行数据,每一行数据对应的是输入序列按时间对齐后的结果(一行数据中,可能存在某一列为<code>null</code>值,但不会全部都是<code>null</code>)。</td> <td><code>void transform(RowWindow rowWindow, PointCollector collector) throws Exception</code></td></tr> <tr><td style="text-align:left;"><code>SlidingSizeWindowAccessStrategy</code></td> <td style="text-align:left;">以固定行数的方式处理原始数据,即每个数据处理窗口都会包含固定行数的数据(最后一个窗口除外)。框架会为每一个原始数据输入窗口调用一次<code>transform</code>方法。一个窗口可能存在多行数据,每一行数据对应的是输入序列按时间对齐后的结果(一行数据中,可能存在某一列为<code>null</code>值,但不会全部都是<code>null</code>)。</td> <td><code>void transform(RowWindow rowWindow, PointCollector collector) throws Exception</code></td></tr></tbody></table> <p><code>RowByRowAccessStrategy</code>的构造不需要任何参数。</p> <p><code>SlidingTimeWindowAccessStrategy</code>有多种构造方法,您可以向构造方法提供3类参数:</p> <ol><li>时间轴显示时间窗开始和结束时间</li> <li>划分时间轴的时间间隔参数(必须为正数)</li> <li>滑动步长(不要求大于等于时间间隔,但是必须为正数)</li></ol> <p>时间轴显示时间窗开始和结束时间不是必须要提供的。当您不提供这类参数时,时间轴显示时间窗开始时间会被定义为整个查询结果集中最小的时间戳,时间轴显示时间窗结束时间会被定义为整个查询结果集中最大的时间戳。</p> <p>滑动步长参数也不是必须的。当您不提供滑动步长参数时,滑动步长会被设定为划分时间轴的时间间隔。</p> <p>3类参数的关系可见下图。策略的构造方法详见Javadoc。</p> <div style="text-align:center;"><img src="https://user-images.githubusercontent.com/30497621/99787878-47b51480-2b5b-11eb-8ed3-84088c5c30f7.png" style="width:100%;max-width:800px;max-height:600px;margin-left:auto;margin-right:auto;display:block;"></div> <p>注意,最后的一些时间窗口的实际时间间隔可能小于规定的时间间隔参数。另外,可能存在某些时间窗口内数据行数量为0的情况,这种情况框架也会为该窗口调用一次<code>transform</code>方法。</p> <p><code>SlidingSizeWindowAccessStrategy</code>有多种构造方法,您可以向构造方法提供2个参数:</p> <ol><li>窗口大小,即一个数据处理窗口包含的数据行数。注意,最后一些窗口的数据行数可能少于规定的数据行数。</li> <li>滑动步长,即下一窗口第一个数据行与当前窗口第一个数据行间的数据行数(不要求大于等于窗口大小,但是必须为正数)</li></ol> <p>滑动步长参数不是必须的。当您不提供滑动步长参数时,滑动步长会被设定为窗口大小。</p> <p>策略的构造方法详见Javadoc。</p> <h5 id="setoutputdatatype"><a href="#setoutputdatatype" class="header-anchor">#</a> setOutputDataType</h5> <p>注意,您在此处设定的输出结果序列的类型,决定了<code>transform</code>方法中<code>PointCollector</code>实际能够接收的数据类型。<code>setOutputDataType</code>中设定的输出类型和<code>PointCollector</code>实际能够接收的数据输出类型关系如下:</p> <table><thead><tr><th style="text-align:left;"><code>setOutputDataType</code>中设定的输出类型</th> <th style="text-align:left;"><code>PointCollector</code>实际能够接收的输出类型</th></tr></thead> <tbody><tr><td style="text-align:left;"><code>INT32</code></td> <td style="text-align:left;"><code>int</code></td></tr> <tr><td style="text-align:left;"><code>INT64</code></td> <td style="text-align:left;"><code>long</code></td></tr> <tr><td style="text-align:left;"><code>FLOAT</code></td> <td style="text-align:left;"><code>float</code></td></tr> <tr><td style="text-align:left;"><code>DOUBLE</code></td> <td style="text-align:left;"><code>double</code></td></tr> <tr><td style="text-align:left;"><code>BOOLEAN</code></td> <td style="text-align:left;"><code>boolean</code></td></tr> <tr><td style="text-align:left;"><code>TEXT</code></td> <td style="text-align:left;"><code>java.lang.String</code><code>org.apache.iotdb.tsfile.utils.Binary</code></td></tr></tbody></table> <p>UDTF输出序列的类型是运行时决定的。您可以根据输入序列类型动态决定输出序列类型。</p> <p>下面是一个简单的例子:</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">void</span> <span class="token function">beforeStart</span><span class="token punctuation">(</span><span class="token class-name">UDFParameters</span> parameters<span class="token punctuation">,</span> <span class="token class-name">UDTFConfigurations</span> configurations<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
<span class="token comment">// do something</span>
<span class="token comment">// ...</span>
configurations
<span class="token punctuation">.</span><span class="token function">setAccessStrategy</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">RowByRowAccessStrategy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">setOutputDataType</span><span class="token punctuation">(</span>parameters<span class="token punctuation">.</span><span class="token function">getDataType</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h3 id="void-transform-row-row-pointcollector-collector-throws-exception"><a href="#void-transform-row-row-pointcollector-collector-throws-exception" class="header-anchor">#</a> void transform(Row row, PointCollector collector) throws Exception</h3> <p>当您在<code>beforeStart</code>方法中指定UDF读取原始数据的策略为 <code>RowByRowAccessStrategy</code>,您就需要实现该方法,在该方法中增加对原始数据处理的逻辑。</p> <p>该方法每次处理原始数据的一行。原始数据由<code>Row</code>读入,由<code>PointCollector</code>输出。您可以选择在一次<code>transform</code>方法调用中输出任意数量的数据点。需要注意的是,输出数据点的类型必须与您在<code>beforeStart</code>方法中设置的一致,而输出数据点的时间戳必须是严格单调递增的。</p> <p>下面是一个实现了<code>void transform(Row row, PointCollector collector) throws Exception</code>方法的完整UDF示例。它是一个加法器,接收两列时间序列输入,当这两个数据点都不为<code>null</code>时,输出这两个数据点的代数和。</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span>UDTF<span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>access<span class="token punctuation">.</span></span><span class="token class-name">Row</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>collector<span class="token punctuation">.</span></span><span class="token class-name">PointCollector</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>config<span class="token punctuation">.</span></span><span class="token class-name">UDTFConfigurations</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>parameter<span class="token punctuation">.</span></span><span class="token class-name">UDFParameters</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>strategy<span class="token punctuation">.</span></span><span class="token class-name">RowByRowAccessStrategy</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>tsfile<span class="token punctuation">.</span>file<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">TSDataType</span><span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">Adder</span> <span class="token keyword">implements</span> UDTF <span class="token punctuation">{</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">beforeStart</span><span class="token punctuation">(</span><span class="token class-name">UDFParameters</span> parameters<span class="token punctuation">,</span> <span class="token class-name">UDTFConfigurations</span> configurations<span class="token punctuation">)</span> <span class="token punctuation">{</span>
configurations
<span class="token punctuation">.</span><span class="token function">setOutputDataType</span><span class="token punctuation">(</span><span class="token class-name">TSDataType</span><span class="token punctuation">.</span>INT64<span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">setAccessStrategy</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">RowByRowAccessStrategy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">transform</span><span class="token punctuation">(</span><span class="token class-name">Row</span> row<span class="token punctuation">,</span> <span class="token class-name">PointCollector</span> collector<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>row<span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">||</span> row<span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
collector<span class="token punctuation">.</span><span class="token function">putLong</span><span class="token punctuation">(</span>row<span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> row<span class="token punctuation">.</span><span class="token function">getLong</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">+</span> row<span class="token punctuation">.</span><span class="token function">getLong</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><h3 id="void-transform-rowwindow-rowwindow-pointcollector-collector-throws-exception"><a href="#void-transform-rowwindow-rowwindow-pointcollector-collector-throws-exception" class="header-anchor">#</a> void transform(RowWindow rowWindow, PointCollector collector) throws Exception</h3> <p>当您在<code>beforeStart</code>方法中指定UDF读取原始数据的策略为 <code>SlidingTimeWindowAccessStrategy</code>或者<code>SlidingSizeWindowAccessStrategy</code>时,您就需要实现该方法,在该方法中增加对原始数据处理的逻辑。</p> <p>该方法每次处理固定行数或者固定时间间隔内的一批数据,我们称包含这一批数据的容器为窗口。原始数据由<code>RowWindow</code>读入,由<code>PointCollector</code>输出。<code>RowWindow</code>能够帮助您访问某一批次的<code>Row</code>,它提供了对这一批次的<code>Row</code>进行随机访问和迭代访问的接口。您可以选择在一次<code>transform</code>方法调用中输出任意数量的数据点,需要注意的是,输出数据点的类型必须与您在<code>beforeStart</code>方法中设置的一致,而输出数据点的时间戳必须是严格单调递增的。</p> <p>下面是一个实现了<code>void transform(RowWindow rowWindow, PointCollector collector) throws Exception</code>方法的完整UDF示例。它是一个计数器,接收任意列数的时间序列输入,作用是统计并输出指定时间范围内每一个时间窗口中的数据行数。</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">IOException</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span>UDTF<span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>access<span class="token punctuation">.</span></span><span class="token class-name">RowWindow</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>collector<span class="token punctuation">.</span></span><span class="token class-name">PointCollector</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>config<span class="token punctuation">.</span></span><span class="token class-name">UDTFConfigurations</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>parameter<span class="token punctuation">.</span></span><span class="token class-name">UDFParameters</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>strategy<span class="token punctuation">.</span></span><span class="token class-name">SlidingTimeWindowAccessStrategy</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>tsfile<span class="token punctuation">.</span>file<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">TSDataType</span><span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">Counter</span> <span class="token keyword">implements</span> UDTF <span class="token punctuation">{</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">beforeStart</span><span class="token punctuation">(</span><span class="token class-name">UDFParameters</span> parameters<span class="token punctuation">,</span> <span class="token class-name">UDTFConfigurations</span> configurations<span class="token punctuation">)</span> <span class="token punctuation">{</span>
configurations
<span class="token punctuation">.</span><span class="token function">setOutputDataType</span><span class="token punctuation">(</span><span class="token class-name">TSDataType</span><span class="token punctuation">.</span>INT32<span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">setAccessStrategy</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">SlidingTimeWindowAccessStrategy</span><span class="token punctuation">(</span>
parameters<span class="token punctuation">.</span><span class="token function">getLong</span><span class="token punctuation">(</span><span class="token string">&quot;time_interval&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
parameters<span class="token punctuation">.</span><span class="token function">getLong</span><span class="token punctuation">(</span><span class="token string">&quot;sliding_step&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
parameters<span class="token punctuation">.</span><span class="token function">getLong</span><span class="token punctuation">(</span><span class="token string">&quot;display_window_begin&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
parameters<span class="token punctuation">.</span><span class="token function">getLong</span><span class="token punctuation">(</span><span class="token string">&quot;display_window_end&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">transform</span><span class="token punctuation">(</span><span class="token class-name">RowWindow</span> rowWindow<span class="token punctuation">,</span> <span class="token class-name">PointCollector</span> collector<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>rowWindow<span class="token punctuation">.</span><span class="token function">windowSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
collector<span class="token punctuation">.</span><span class="token function">putInt</span><span class="token punctuation">(</span>rowWindow<span class="token punctuation">.</span><span class="token function">getRow</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> rowWindow<span class="token punctuation">.</span><span class="token function">windowSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><h3 id="void-terminate-pointcollector-collector-throws-exception"><a href="#void-terminate-pointcollector-collector-throws-exception" class="header-anchor">#</a> void terminate(PointCollector collector) throws Exception</h3> <p>在一些场景下,UDF需要遍历完所有的原始数据后才能得到最后的输出结果。<code>terminate</code>接口为这类UDF提供了支持。</p> <p>该方法会在所有的<code>transform</code>调用执行完成后,在<code>beforeDestory</code>方法执行前被调用。您可以选择使用<code>transform</code>方法进行单纯的数据处理,最后使用<code>terminate</code>将处理结果输出。</p> <p>结果需要由<code>PointCollector</code>输出。您可以选择在一次<code>terminate</code>方法调用中输出任意数量的数据点。需要注意的是,输出数据点的类型必须与您在<code>beforeStart</code>方法中设置的一致,而输出数据点的时间戳必须是严格单调递增的。</p> <p>下面是一个实现了<code>void terminate(PointCollector collector) throws Exception</code>方法的完整UDF示例。它接收一个<code>INT32</code>类型的时间序列输入,作用是输出该序列的最大值点。</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">IOException</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span>UDTF<span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>access<span class="token punctuation">.</span></span><span class="token class-name">Row</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>collector<span class="token punctuation">.</span></span><span class="token class-name">PointCollector</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>config<span class="token punctuation">.</span></span><span class="token class-name">UDTFConfigurations</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>parameter<span class="token punctuation">.</span></span><span class="token class-name">UDFParameters</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>db<span class="token punctuation">.</span>query<span class="token punctuation">.</span>udf<span class="token punctuation">.</span>api<span class="token punctuation">.</span>customizer<span class="token punctuation">.</span>strategy<span class="token punctuation">.</span></span><span class="token class-name">RowByRowAccessStrategy</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>iotdb<span class="token punctuation">.</span>tsfile<span class="token punctuation">.</span>file<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">TSDataType</span><span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">Max</span> <span class="token keyword">implements</span> UDTF <span class="token punctuation">{</span>
<span class="token keyword">private</span> <span class="token class-name">Long</span> time<span class="token punctuation">;</span>
<span class="token keyword">private</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">beforeStart</span><span class="token punctuation">(</span><span class="token class-name">UDFParameters</span> parameters<span class="token punctuation">,</span> <span class="token class-name">UDTFConfigurations</span> configurations<span class="token punctuation">)</span> <span class="token punctuation">{</span>
configurations
<span class="token punctuation">.</span><span class="token function">setOutputDataType</span><span class="token punctuation">(</span><span class="token class-name">TSDataType</span><span class="token punctuation">.</span>INT32<span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">setAccessStrategy</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">RowByRowAccessStrategy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">transform</span><span class="token punctuation">(</span><span class="token class-name">Row</span> row<span class="token punctuation">,</span> <span class="token class-name">PointCollector</span> collector<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">int</span> candidateValue <span class="token operator">=</span> row<span class="token punctuation">.</span><span class="token function">getInt</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>time <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token operator">||</span> value <span class="token operator">&lt;</span> candidateValue<span class="token punctuation">)</span> <span class="token punctuation">{</span>
time <span class="token operator">=</span> row<span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
value <span class="token operator">=</span> candidateValue<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">terminate</span><span class="token punctuation">(</span><span class="token class-name">PointCollector</span> collector<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>time <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
collector<span class="token punctuation">.</span><span class="token function">putInt</span><span class="token punctuation">(</span>time<span class="token punctuation">,</span> value<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br></div></div><h3 id="void-beforedestroy"><a href="#void-beforedestroy" class="header-anchor">#</a> void beforeDestroy()</h3> <p>UDTF的结束方法,您可以在此方法中进行一些资源释放等的操作。</p> <p>此方法由框架调用。对于一个UDF类实例而言,生命周期中会且只会被调用一次,即在处理完最后一条记录之后被调用。</p> <h2 id="完整maven项目示例"><a href="#完整maven项目示例" class="header-anchor">#</a> 完整Maven项目示例</h2> <p>如果您使用<a href="http://search.maven.org/" target="_blank" rel="noopener noreferrer">Maven<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>,可以参考我们编写的示例项目<strong>udf-example</strong>。您可以在<a href="https://github.com/apache/iotdb/tree/master/example/udf" target="_blank" rel="noopener noreferrer">这里<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>找到它。</p> <h2 id="udf注册"><a href="#udf注册" class="header-anchor">#</a> UDF注册</h2> <p>注册一个UDF可以按如下流程进行:</p> <ol><li><p>实现一个完整的UDF类,假定这个类的全类名为<code>org.apache.iotdb.udf.ExampleUDTF</code></p></li> <li><p>将项目打成JAR包,如果您使用Maven管理项目,可以参考上述Maven项目示例的写法</p></li> <li><p>将JAR包放置到目录 <code>iotdb-server-0.12.0-SNAPSHOT/ext/udf</code> (也可以是<code>iotdb-server-0.12.0-SNAPSHOT/ext/udf</code>的子目录)下。</p> <blockquote><p>您可以通过修改配置文件中的<code>udf_root_dir</code>来指定UDF加载Jar的根路径。</p></blockquote></li> <li><p>使用SQL语句注册该UDF,假定赋予该UDF的名字为<code>example</code></p></li></ol> <p>注册UDF的SQL语法如下:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> <span class="token operator">&lt;</span>UDF<span class="token operator">-</span>NAME<span class="token operator">&gt;</span> <span class="token keyword">AS</span> <span class="token operator">&lt;</span>UDF<span class="token operator">-</span>CLASS<span class="token operator">-</span><span class="token keyword">FULL</span><span class="token operator">-</span>PATHNAME<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>例子中注册UDF的SQL语句如下:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> example <span class="token keyword">AS</span> <span class="token string">&quot;org.apache.iotdb.udf.ExampleUDTF&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>由于IoTDB的UDF是通过反射技术动态装载的,因此您在装载过程中无需启停服务器。</p> <p>注意:UDF函数名称是大小写不敏感的。</p> <p>注意:请不要给UDF函数注册一个内置函数的名字。使用内置函数的名字给UDF注册会失败。</p> <p>注意:不同的JAR包中最好不要有全类名相同但实现功能逻辑不一样的类。例如 UDF(UDAF/UDTF):<code>udf1</code><code>udf2</code>分别对应资源<code>udf1.jar</code><code>udf2.jar</code>。如果两个JAR包里都包含一个<code>org.apache.iotdb.udf.ExampleUDTF</code>类,当同一个SQL中同时使用到这两个UDF时,系统会随机加载其中一个类,导致UDF执行行为不一致。</p> <h2 id="udf卸载"><a href="#udf卸载" class="header-anchor">#</a> UDF卸载</h2> <p>卸载UDF的SQL语法如下:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> <span class="token operator">&lt;</span>UDF<span class="token operator">-</span>NAME<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>可以通过如下SQL语句卸载上面例子中的UDF:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> example
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="udf查询"><a href="#udf查询" class="header-anchor">#</a> UDF查询</h2> <p>UDF的使用方法与普通内建函数的类似。</p> <h3 id="支持的基础sql语法"><a href="#支持的基础sql语法" class="header-anchor">#</a> 支持的基础SQL语法</h3> <ul><li><code>SLIMIT</code> / <code>SOFFSET</code></li> <li><code>LIMIT</code> / <code>OFFSET</code></li> <li><code>NON ALIGN</code></li> <li>支持值过滤</li> <li>支持时间过滤</li></ul> <h3 id="带-查询"><a href="#带-查询" class="header-anchor">#</a> 带 * 查询</h3> <p>假定现在有时间序列 <code>root.sg.d1.s1</code><code>root.sg.d1.s2</code></p> <ul><li><strong>执行<code>SELECT example(*) from root.sg.d1</code></strong></li></ul> <p>那么结果集中将包括<code>example(root.sg.d1.s1)</code><code>example(root.sg.d1.s2)</code>的结果。</p> <ul><li><strong>执行<code>SELECT example(s1, *) from root.sg.d1</code></strong></li></ul> <p>那么结果集中将包括<code>example(root.sg.d1.s1, root.sg.d1.s1)</code><code>example(root.sg.d1.s1, root.sg.d1.s2)</code>的结果。</p> <ul><li><strong>执行<code>SELECT example(*, *) from root.sg.d1</code></strong></li></ul> <p>那么结果集中将包括<code>example(root.sg.d1.s1, root.sg.d1.s1)</code><code>example(root.sg.d1.s2, root.sg.d1.s1)</code><code>example(root.sg.d1.s1, root.sg.d1.s2)</code><code>example(root.sg.d1.s2, root.sg.d1.s2)</code>的结果。</p> <h3 id="带自定义输入参数的查询"><a href="#带自定义输入参数的查询" class="header-anchor">#</a> 带自定义输入参数的查询</h3> <p>您可以在进行UDF查询的时候,向UDF传入任意数量的键值对参数。键值对中的键和值都需要被单引号或者双引号引起来。注意,键值对参数只能在所有时间序列后传入。下面是一组例子:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">SELECT</span> example<span class="token punctuation">(</span>s1<span class="token punctuation">,</span> <span class="token string">&quot;key1&quot;</span><span class="token operator">=</span><span class="token string">&quot;value1&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;key2&quot;</span><span class="token operator">=</span><span class="token string">&quot;value2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> example<span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">,</span> <span class="token string">&quot;key3&quot;</span><span class="token operator">=</span><span class="token string">&quot;value3&quot;</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> root<span class="token punctuation">.</span>sg<span class="token punctuation">.</span>d1<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> example<span class="token punctuation">(</span>s1<span class="token punctuation">,</span> s2<span class="token punctuation">,</span> <span class="token string">&quot;key1&quot;</span><span class="token operator">=</span><span class="token string">&quot;value1&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;key2&quot;</span><span class="token operator">=</span><span class="token string">&quot;value2&quot;</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> root<span class="token punctuation">.</span>sg<span class="token punctuation">.</span>d1<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="与其他查询的混合查询"><a href="#与其他查询的混合查询" class="header-anchor">#</a> 与其他查询的混合查询</h3> <p>目前IoTDB支持UDF查询与原始查询的混合查询,例如:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">SELECT</span> s1<span class="token punctuation">,</span> s2<span class="token punctuation">,</span> example<span class="token punctuation">(</span>s1<span class="token punctuation">,</span> s2<span class="token punctuation">)</span> <span class="token keyword">FROM</span> root<span class="token punctuation">.</span>sg<span class="token punctuation">.</span>d1<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span><span class="token punctuation">,</span> example<span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> root<span class="token punctuation">.</span>sg<span class="token punctuation">.</span>d1 NON ALIGN<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>暂不支持UDF查询与其他查询混合使用。</p> <h2 id="查看所有注册的udf"><a href="#查看所有注册的udf" class="header-anchor">#</a> 查看所有注册的UDF</h2> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">SHOW</span> FUNCTIONS
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="用户权限管理"><a href="#用户权限管理" class="header-anchor">#</a> 用户权限管理</h2> <p>用户在使用UDF时会涉及到3种权限:</p> <ul><li><code>CREATE_FUNCTION</code>:具备该权限的用户才被允许执行UDF注册操作</li> <li><code>DROP_FUNCTION</code>:具备该权限的用户才被允许执行UDF卸载操作</li> <li><code>READ_TIMESERIES</code>:具备该权限的用户才被允许使用UDF进行查询</li></ul> <p>更多用户权限相关的内容,请参考<a href="/zh/UserGuide/Master/Operation Manual/Administration.html">权限管理语句</a></p> <h2 id="配置项"><a href="#配置项" class="header-anchor">#</a> 配置项</h2> <p>在SQL语句中使用自定义函数时,可能提示内存不足。这种情况下,您可以通过更改配置文件<code>iotdb-engine.properties</code>中的<code>udf_initial_byte_array_length_for_memory_control</code><code>udf_memory_budget_in_mb</code><code>udf_reader_transformer_collector_memory_proportion</code>并重启服务来解决此问题。</p> <h2 id="贡献udf"><a href="#贡献udf" class="header-anchor">#</a> 贡献UDF</h2> <p>该部分主要讲述了外部用户如何将自己编写的 UDF 贡献给 IoTDB 社区。</p> <h3 id="前提条件"><a href="#前提条件" class="header-anchor">#</a> 前提条件</h3> <ol><li><p>UDF 具有通用性。</p> <p>通用性主要指的是:UDF 在某些业务场景下,可以被广泛使用。换言之,就是 UDF 具有复用价值,可被社区内其他用户直接使用。</p> <p>如果您不确定自己写的 UDF 是否具有通用性,可以发邮件到 <code>dev@iotdb.apache.org</code> 或直接创建 ISSUE 发起讨论。</p></li> <li><p>UDF 已经完成测试,且能够正常运行在用户的生产环境中。</p></li></ol> <h3 id="贡献清单"><a href="#贡献清单" class="header-anchor">#</a> 贡献清单</h3> <ol><li>UDF 的源代码</li> <li>UDF 的测试用例</li> <li>UDF 的使用说明</li></ol> <h4 id="源代码"><a href="#源代码" class="header-anchor">#</a> 源代码</h4> <ol><li><code>src/main/java/org/apache/iotdb/db/query/udf/builtin</code>或者它的子文件夹中创建 UDF 主类和相关的辅助类。</li> <li><code>src/main/java/org/apache/iotdb/db/query/udf/builtin/BuiltinFunction.java</code>中注册您编写的 UDF。</li></ol> <h4 id="测试用例"><a href="#测试用例" class="header-anchor">#</a> 测试用例</h4> <p>您至少需要为您贡献的 UDF 编写集成测试。</p> <p>您可以在<code>server/src/test/java/org/apache/iotdb/db/integration</code>中为您贡献的 UDF 新增一个测试类进行测试。</p> <h4 id="使用说明"><a href="#使用说明" class="header-anchor">#</a> 使用说明</h4> <p>使用说明需要包含:UDF 的名称、UDF的作用、执行函数必须的属性参数、函数的适用的场景以及使用示例等。</p> <p>使用说明需包含中英文两个版本。应分别在 <code>docs/zh/UserGuide/Operation Manual/DML Data Manipulation Language.md</code><code>docs/UserGuide/Operation Manual/DML Data Manipulation Language.md</code> 中新增使用说明。</p> <h3 id="提交pr"><a href="#提交pr" class="header-anchor">#</a> 提交PR</h3> <p>当您准备好源代码、测试用例和使用说明后,就可以将 UDF 贡献到 IoTDB 社区了。在 <a href="https://github.com/apache/iotdb" target="_blank" rel="noopener noreferrer">Github<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 上面提交 Pull Request (PR) 即可。具体提交方式见:<a href="https://iotdb.apache.org/Development/HowToCommit.html" target="_blank" rel="noopener noreferrer">Pull Request Guide<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>当 PR 评审通过并被合并后,您的 UDF 就已经贡献给 IoTDB 社区了!</p> <h2 id="已知的udf库实现"><a href="#已知的udf库实现" class="header-anchor">#</a> 已知的UDF库实现</h2> <ul><li><a href="https://thulab.github.io/iotdb-quality" target="_blank" rel="noopener noreferrer">IoTDB-Quality<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>,一个关于数据质量的UDF库实现,包括数据画像、数据质量评估与修复等一系列函数。</li></ul> <h2 id="q-a"><a href="#q-a" class="header-anchor">#</a> Q&amp;A</h2> <p><strong>Q1: 如何修改已经注册的UDF?</strong></p> <p>A1: 假设UDF的名称为<code>example</code>,全类名为<code>org.apache.iotdb.udf.ExampleUDTF</code>,由<code>example.jar</code>引入</p> <ol><li>首先卸载已经注册的<code>example</code>函数,执行<code>DROP FUNCTION example</code></li> <li>删除 <code>iotdb-server-0.12.0-SNAPSHOT/ext/udf</code> 目录下的<code>example.jar</code></li> <li>修改<code>org.apache.iotdb.udf.ExampleUDTF</code>中的逻辑,重新打包,JAR包的名字可以仍然为<code>example.jar</code></li> <li>将新的JAR包上传至 <code>iotdb-server-0.12.0-SNAPSHOT/ext/udf</code> 目录下</li> <li>装载新的UDF,执行<code>CREATE FUNCTION example AS &quot;org.apache.iotdb.udf.ExampleUDTF&quot;</code></li></ol></div> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/zh/UserGuide/Master/Operation Manual/DML Data Manipulation Language.html" class="prev">
DML (数据操作语言)
</a></span> <span class="next"><a href="/zh/UserGuide/Master/Operation Manual/Kill Query.html">
中止查询
</a>
</span></p></div> <p style="text-align: center;">Copyright © 2021 The Apache Software Foundation.<br>
Apache and the Apache feather logo are trademarks of The Apache Software Foundation</p> <p style="text-align: center; margin-top: 10px; color: #444">
Contact us: Join QQ Group 659990460 | Add friend <i>tietouqiao</i> and be invited to Wechat Group<br>
see <a href="https://github.com/apache/iotdb/issues/1995">Join the community</a> for more</p></main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.9c03bb74.js" defer></script><script src="/assets/js/3.e95317f3.js" defer></script><script src="/assets/js/350.1066134b.js" defer></script>
</body>
</html>