blob: b53d1c348e897e2038b28958a9a44a45cf4ea422 [file]
<!doctype html>
<html lang="en-US" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="generator" content="VuePress 2.0.0-rc.19" />
<meta name="theme" content="VuePress Theme Hope 2.0.0-rc.71" />
<style>
:root {
--vp-c-bg: #fff;
}
[data-theme="dark"] {
--vp-c-bg: #1b1b1f;
}
html,
body {
background: var(--vp-c-bg);
}
</style>
<script>
const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
const systemDarkMode =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;
if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
document.documentElement.setAttribute("data-theme", "dark");
}
</script>
<link rel="alternate" hreflang="zh-cn" href="https://tsfile.apache.org/zh/stage/QuickStart.html"><meta property="og:url" content="https://tsfile.apache.org/stage/QuickStart.html"><meta property="og:site_name" content="Apache TsFile"><meta property="og:title" content="TsFile API"><meta property="og:description" content="TsFile API TsFile is a file format of Time Series used in IoTDB. This session introduces the usage of this file format. TsFile library Installation There are two ways to use TsF..."><meta property="og:type" content="article"><meta property="og:locale" content="en-US"><meta property="og:locale:alternate" content="zh-CN"><meta property="og:updated_time" content="2025-12-30T03:29:28.000Z"><meta property="article:modified_time" content="2025-12-30T03:29:28.000Z"><script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","headline":"TsFile API","image":[""],"dateModified":"2025-12-30T03:29:28.000Z","author":[]}</script><link rel="icon" href="/favicon.ico"><script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDoNotTrack", true]);
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '53']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script><title>TsFile API | Apache TsFile</title><meta name="description" content="TsFile API TsFile is a file format of Time Series used in IoTDB. This session introduces the usage of this file format. TsFile library Installation There are two ways to use TsF...">
<link rel="preload" href="/assets/style-BW4wF7Wp.css" as="style"><link rel="stylesheet" href="/assets/style-BW4wF7Wp.css">
<link rel="modulepreload" href="/assets/app-jw83bKft.js"><link rel="modulepreload" href="/assets/QuickStart.html-DTONh-Rj.js"><link rel="modulepreload" href="/assets/plugin-vue_export-helper-DlAUqK2U.js">
<link rel="prefetch" href="/assets/index.html-BsXXw7FW.js" as="script"><link rel="prefetch" href="/assets/About.html-BTj5b8KP.js" as="script"><link rel="prefetch" href="/assets/Feedback.html-DDyygGs4.js" as="script"><link rel="prefetch" href="/assets/Community-Project-Committers.html-CMp1oXiz.js" as="script"><link rel="prefetch" href="/assets/Powered-By.html-6ByqQIAS.js" as="script"><link rel="prefetch" href="/assets/index.html-DJYC7CCn.js" as="script"><link rel="prefetch" href="/assets/index.html-vLAary3j.js" as="script"><link rel="prefetch" href="/assets/About.html-DcBbVo7u.js" as="script"><link rel="prefetch" href="/assets/Feedback.html-B6iXebc7.js" as="script"><link rel="prefetch" href="/assets/Community-Project-Committers.html-CdyYrFbB.js" as="script"><link rel="prefetch" href="/assets/Powered-By.html-NFswhMIA.js" as="script"><link rel="prefetch" href="/assets/index.html-DUtgO_cQ.js" as="script"><link rel="prefetch" href="/assets/QuickStart.html-BEfD8y0v.js" as="script"><link rel="prefetch" href="/assets/Flink-TsFile.html-DGttutGB.js" as="script"><link rel="prefetch" href="/assets/Hive-TsFile.html-CjmTi791.js" as="script"><link rel="prefetch" href="/assets/Spark-TsFile.html-CnSk0IRc.js" as="script"><link rel="prefetch" href="/assets/Data-Model.html-Dned9sNR.js" as="script"><link rel="prefetch" href="/assets/Navigating_Time_Series_Data.html-D-MiY5BA.js" as="script"><link rel="prefetch" href="/assets/QuickStart-C.html-BH_cj7M2.js" as="script"><link rel="prefetch" href="/assets/QuickStart-CPP.html-CsbXAKg0.js" as="script"><link rel="prefetch" href="/assets/QuickStart-JAVA.html-BzGDwcjc.js" as="script"><link rel="prefetch" href="/assets/QuickStart-PYTHON.html-7KY8oOfm.js" as="script"><link rel="prefetch" href="/assets/Flink-TsFile.html-BBzlAiTv.js" as="script"><link rel="prefetch" href="/assets/Hive-TsFile.html-iC_fYTzs.js" as="script"><link rel="prefetch" href="/assets/Spark-TsFile.html-C29pZfBf.js" as="script"><link rel="prefetch" href="/assets/Data-Model.html-B4nqaifq.js" as="script"><link rel="prefetch" href="/assets/Navigating_Time_Series_Data.html-BZ9wnmvS.js" as="script"><link rel="prefetch" href="/assets/QuickStart-C.html-BIMKbPzh.js" as="script"><link rel="prefetch" href="/assets/QuickStart-CPP.html-kcyySaaY.js" as="script"><link rel="prefetch" href="/assets/QuickStart-PYTHON.html-bqqWi1S_.js" as="script"><link rel="prefetch" href="/assets/QuickStart.html-DINR-vK_.js" as="script"><link rel="prefetch" href="/assets/Flink-TsFile.html-CGFW4aE0.js" as="script"><link rel="prefetch" href="/assets/Hive-TsFile.html-2NGuGHWr.js" as="script"><link rel="prefetch" href="/assets/Spark-TsFile.html-CvvpsN8A.js" as="script"><link rel="prefetch" href="/assets/Data-Model.html-BHqoCY9x.js" as="script"><link rel="prefetch" href="/assets/Navigating_Time_Series_Data.html-BTF5EZoK.js" as="script"><link rel="prefetch" href="/assets/QuickStart.html-CubzqcZH.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-C.html-JmzdEv9n.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-CPP.html-DZbb8yNK.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Java.html-HUOPFvXj.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Python.html-Danm2pFV.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-C.html-DkKMWxO3.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-CPP.html-HvhXQM23.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Java.html-DflenPYj.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Python.html-CRn1wYKR.js" as="script"><link rel="prefetch" href="/assets/Flink-TsFile.html-PH8P4y4i.js" as="script"><link rel="prefetch" href="/assets/Hive-TsFile.html-vbD1Wb_q.js" as="script"><link rel="prefetch" href="/assets/Spark-TsFile.html-BLMOnlt0.js" as="script"><link rel="prefetch" href="/assets/Data-Model.html-CMRSALOs.js" as="script"><link rel="prefetch" href="/assets/Interface-Definitions.html-BjqTa7h3.js" as="script"><link rel="prefetch" href="/assets/Navigating_Time_Series_Data.html-BTtdjd4G.js" as="script"><link rel="prefetch" href="/assets/QuickStart-C.html-BaEa6vPM.js" as="script"><link rel="prefetch" href="/assets/QuickStart-CPP.html-BAusP9Ps.js" as="script"><link rel="prefetch" href="/assets/QuickStart-JAVA.html-B5yADMUf.js" as="script"><link rel="prefetch" href="/assets/QuickStart-PYTHON.html-BfGXfnSP.js" as="script"><link rel="prefetch" href="/assets/Flink-TsFile.html-DXd0rgrT.js" as="script"><link rel="prefetch" href="/assets/Hive-TsFile.html-D5O1ylNW.js" as="script"><link rel="prefetch" href="/assets/Spark-TsFile.html-D7-FUZNs.js" as="script"><link rel="prefetch" href="/assets/Data-Model.html-0jHwqeJH.js" as="script"><link rel="prefetch" href="/assets/Navigating_Time_Series_Data.html-oaLicXPJ.js" as="script"><link rel="prefetch" href="/assets/QuickStart-C.html-DoyT-xkV.js" as="script"><link rel="prefetch" href="/assets/QuickStart-CPP.html-CHixZdtN.js" as="script"><link rel="prefetch" href="/assets/QuickStart-PYTHON.html-B_kN8fdw.js" as="script"><link rel="prefetch" href="/assets/QuickStart.html-CrMQwEd-.js" as="script"><link rel="prefetch" href="/assets/Flink-TsFile.html-CubbftDu.js" as="script"><link rel="prefetch" href="/assets/Hive-TsFile.html-CXCoXNSi.js" as="script"><link rel="prefetch" href="/assets/Spark-TsFile.html-B7dB2x2X.js" as="script"><link rel="prefetch" href="/assets/Data-Model.html-Bj02-z3F.js" as="script"><link rel="prefetch" href="/assets/Navigating_Time_Series_Data.html-ChKNVjet.js" as="script"><link rel="prefetch" href="/assets/QuickStart.html-LDY9Inhg.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-C.html-BjmR1DLj.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-CPP.html-CNb6mohP.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Java.html-CjVW83vV.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Python.html-B4n5O8S5.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-C.html-DIrouQN9.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-CPP.html-_qC9C3nc.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Java.html-BM2Uah1b.js" as="script"><link rel="prefetch" href="/assets/InterfaceDefinition-Python.html-CLbZmPRE.js" as="script"><link rel="prefetch" href="/assets/404.html-C_TnKfR6.js" as="script"><link rel="prefetch" href="/assets/index.html-B1CUhjiC.js" as="script"><link rel="prefetch" href="/assets/index.html-BgSr-sXS.js" as="script"><link rel="prefetch" href="/assets/index.html-DIs1vZbU.js" as="script"><link rel="prefetch" href="/assets/index.html-CqoWhg9G.js" as="script"><link rel="prefetch" href="/assets/index.html-Bg1Myhou.js" as="script"><link rel="prefetch" href="/assets/index.html-CZrb7xvz.js" as="script"><link rel="prefetch" href="/assets/index.html-CfGsLosC.js" as="script"><link rel="prefetch" href="/assets/index.html-DpR3jM3w.js" as="script"><link rel="prefetch" href="/assets/index.html-CJD6I08i.js" as="script"><link rel="prefetch" href="/assets/index.html-C4A1DrfI.js" as="script"><link rel="prefetch" href="/assets/index.html-BHJnAzob.js" as="script"><link rel="prefetch" href="/assets/index.html-rPco-07h.js" as="script"><link rel="prefetch" href="/assets/index.html-COvRHi8P.js" as="script"><link rel="prefetch" href="/assets/index.html-CBqSiLvS.js" as="script"><link rel="prefetch" href="/assets/index.html-ORoCSBfC.js" as="script"><link rel="prefetch" href="/assets/index.html-BsX39I4V.js" as="script"><link rel="prefetch" href="/assets/index.html-DBXTHItz.js" as="script"><link rel="prefetch" href="/assets/index.html-DIm9qt1m.js" as="script"><link rel="prefetch" href="/assets/index.html-CqsLd3m9.js" as="script"><link rel="prefetch" href="/assets/index.html-md4Cw3Qo.js" as="script"><link rel="prefetch" href="/assets/index.html-BUrGFqMb.js" as="script"><link rel="prefetch" href="/assets/index.html-CHYXOHRx.js" as="script"><link rel="prefetch" href="/assets/index.html-ChCaqRpK.js" as="script"><link rel="prefetch" href="/assets/index.html-DB9Tcu0n.js" as="script"><link rel="prefetch" href="/assets/index.html-C6ZDum6O.js" as="script"><link rel="prefetch" href="/assets/index.html-QzhWqtMK.js" as="script"><link rel="prefetch" href="/assets/index.html-Bsa4TN4C.js" as="script"><link rel="prefetch" href="/assets/index.html-CKXTw0wv.js" as="script"><link rel="prefetch" href="/assets/index.html-B_YNRgWu.js" as="script"><link rel="prefetch" href="/assets/index.html-O1uFjFms.js" as="script"><link rel="prefetch" href="/assets/photoswipe.esm-D2Nf-uDI.js" as="script"><link rel="prefetch" href="/assets/index-B-M8YVCw.js" as="script">
</head>
<body>
<div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content" class="vp-skip-link sr-only">Skip to main content</a><!--]--><!--[--><div class="theme-container no-sidebar external-link-icon has-toc" vp-container><!--[--><header id="navbar" class="vp-navbar" vp-navbar><div class="vp-navbar-start"><button type="button" class="vp-toggle-sidebar-button" title="Toggle Sidebar"><span class="icon"></span></button><!--[--><a class="route-link vp-brand" href="/" aria-label="Take me home"><img class="vp-nav-logo" src="/logo.svg" alt><!----><span class="vp-site-name hide-in-pad">Apache TsFile</span></a><!--]--></div><div class="vp-navbar-center"><!--[--><!--]--></div><div class="vp-navbar-end"><!--[--><!--[--><div id="docsearch-container" style="display:none;"></div><div><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"><svg width="15" height="15" class="DocSearch-Control-Key-Icon"><path d="M4.505 4.496h2M5.505 5.496v5M8.216 4.496l.055 5.993M10 7.5c.333.333.5.667.5 1v2M12.326 4.5v5.996M8.384 4.496c1.674 0 2.116 0 2.116 1.5s-.442 1.5-2.116 1.5M3.205 9.303c-.09.448-.277 1.21-1.241 1.203C1 10.5.5 9.513.5 8V7c0-1.57.5-2.5 1.464-2.494.964.006 1.134.598 1.24 1.342M12.553 10.5h1.953" stroke-width="1.2" stroke="currentColor" fill="none" stroke-linecap="square"></path></svg></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--><nav class="vp-nav-links"><div class="vp-nav-item hide-in-mobile"><div class="vp-dropdown-wrapper"><button type="button" class="vp-dropdown-title" aria-label="Documentation"><!--[--><!---->Documentation<!--]--><span class="arrow"></span><ul class="vp-dropdown"><li class="vp-dropdown-item"><a class="route-link auto-link" href="/zh/UserGuide/latest/QuickStart/QuickStart.html" aria-label="v2.x" iconsizing="both"><!---->v2.x<!----></a></li><li class="vp-dropdown-item"><a class="route-link auto-link" href="/zh/UserGuide/v1.x/QuickStart/QuickStart.html" aria-label="v1.x" iconsizing="both"><!---->v1.x<!----></a></li></ul></button></div></div><div class="vp-nav-item hide-in-mobile"><a class="route-link auto-link" href="/Download/" aria-label="Download" iconsizing="height"><!---->Download<!----></a></div><div class="vp-nav-item hide-in-mobile"><div class="vp-dropdown-wrapper"><button type="button" class="vp-dropdown-title" aria-label="ASF"><!--[--><!---->ASF<!--]--><span class="arrow"></span><ul class="vp-dropdown"><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://www.apache.org/" aria-label="Foundation" target="_self" iconsizing="both"><!---->Foundation<!----></a></li><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://www.apache.org/licenses/" aria-label="License" target="_self" iconsizing="both"><!---->License<!----></a></li><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://www.apache.org/security/" aria-label="Security" rel="noopener noreferrer" target="_blank" iconsizing="both"><!---->Security<!----></a></li><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://www.apache.org/foundation/sponsorship.html" aria-label="Sponsorship" rel="noopener noreferrer" target="_blank" iconsizing="both"><!---->Sponsorship<!----></a></li><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://www.apache.org/foundation/thanks.html" aria-label="Thanks" target="_self" iconsizing="both"><!---->Thanks<!----></a></li><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://www.apache.org/events/current-event" aria-label="Current Events" rel="noopener noreferrer" target="_blank" iconsizing="both"><!---->Current Events<!----></a></li><li class="vp-dropdown-item"><a class="auto-link external-link" href="https://privacy.apache.org/policies/privacy-policy-public.html" aria-label="Privacy" rel="noopener noreferrer" target="_blank" iconsizing="both"><!---->Privacy<!----></a></li></ul></button></div></div></nav><div class="vp-nav-item"><div class="vp-dropdown-wrapper"><button type="button" class="vp-dropdown-title" aria-label="Select language"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon i18n-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="i18n icon" name="i18n" style="width:1rem;height:1rem;vertical-align:middle;"><path d="M379.392 460.8 494.08 575.488l-42.496 102.4L307.2 532.48 138.24 701.44l-71.68-72.704L234.496 460.8l-45.056-45.056c-27.136-27.136-51.2-66.56-66.56-108.544h112.64c7.68 14.336 16.896 27.136 26.112 35.84l45.568 46.08 45.056-45.056C382.976 312.32 409.6 247.808 409.6 204.8H0V102.4h256V0h102.4v102.4h256v102.4H512c0 70.144-37.888 161.28-87.04 210.944L378.88 460.8zM576 870.4 512 1024H409.6l256-614.4H768l256 614.4H921.6l-64-153.6H576zM618.496 768h196.608L716.8 532.48 618.496 768z"></path></svg><!--]--><span class="arrow"></span><ul class="vp-dropdown"><li class="vp-dropdown-item"><a class="route-link route-link-active auto-link" href="/stage/QuickStart.html" aria-label="English" iconsizing="both"><!---->English<!----></a></li><li class="vp-dropdown-item"><a class="route-link auto-link" href="/zh/stage/QuickStart.html" aria-label="简体中文" iconsizing="both"><!---->简体中文<!----></a></li></ul></button></div></div><div class="vp-nav-item hide-in-mobile"><button type="button" class="vp-color-mode-switch" id="color-mode-switch"><svg xmlns="http://www.w3.org/2000/svg" class="icon auto-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="auto icon" name="auto" style="display:none;"><path d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="dark icon" name="dark" style="display:none;"><path d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="light icon" name="light" style="display:block;"><path d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z"></path></svg></button></div><div class="vp-nav-item vp-action"><a class="vp-action-link" href="https://github.com/apache/tsfile" target="_blank" rel="noopener noreferrer" aria-label="GitHub"><svg xmlns="http://www.w3.org/2000/svg" class="icon github-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="github icon" name="github" style="width:1.25rem;height:1.25rem;vertical-align:middle;"><path d="M511.957 21.333C241.024 21.333 21.333 240.981 21.333 512c0 216.832 140.544 400.725 335.574 465.664 24.49 4.395 32.256-10.07 32.256-23.083 0-11.69.256-44.245 0-85.205-136.448 29.61-164.736-64.64-164.736-64.64-22.315-56.704-54.4-71.765-54.4-71.765-44.587-30.464 3.285-29.824 3.285-29.824 49.195 3.413 75.179 50.517 75.179 50.517 43.776 75.008 114.816 53.333 142.762 40.79 4.523-31.66 17.152-53.377 31.19-65.537-108.971-12.458-223.488-54.485-223.488-242.602 0-53.547 19.114-97.323 50.517-131.67-5.035-12.33-21.93-62.293 4.779-129.834 0 0 41.258-13.184 134.912 50.346a469.803 469.803 0 0 1 122.88-16.554c41.642.213 83.626 5.632 122.88 16.554 93.653-63.488 134.784-50.346 134.784-50.346 26.752 67.541 9.898 117.504 4.864 129.834 31.402 34.347 50.474 78.123 50.474 131.67 0 188.586-114.73 230.016-224.042 242.09 17.578 15.232 33.578 44.672 33.578 90.454v135.85c0 13.142 7.936 27.606 32.854 22.87C862.25 912.597 1002.667 728.747 1002.667 512c0-271.019-219.648-490.667-490.71-490.667z"></path></svg></a></div><!--]--><button type="button" class="vp-toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false" aria-controls="nav-screen"><span><span class="vp-top"></span><span class="vp-middle"></span><span class="vp-bottom"></span></span></button></div></header><!----><!--]--><!----><div class="toggle-sidebar-wrapper"><span class="arrow start"></span></div><aside id="sidebar" class="vp-sidebar" vp-sidebar><!----><ul class="vp-sidebar-links"></ul><!----></aside><!--[--><main id="main-content" class="vp-page"><!--[--><!----><!----><nav class="vp-breadcrumb disable"></nav><div class="vp-page-title"><h1><!---->TsFile API</h1><div class="page-info"><!----><!----><span class="page-date-info" aria-label="Writing Date📅" data-balloon-pos="up"><svg xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="calendar icon" name="calendar"><path d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z"></path></svg><span data-allow-mismatch="text">December 30, 2025</span><meta property="datePublished" content="2025-12-30T03:29:28.000Z"></span><!----><span class="page-reading-time-info" aria-label="Reading Time⌛" data-balloon-pos="up"><svg xmlns="http://www.w3.org/2000/svg" class="icon timer-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="timer icon" name="timer"><path d="M799.387 122.15c4.402-2.978 7.38-7.897 7.38-13.463v-1.165c0-8.933-7.38-16.312-16.312-16.312H256.33c-8.933 0-16.311 7.38-16.311 16.312v1.165c0 5.825 2.977 10.874 7.637 13.592 4.143 194.44 97.22 354.963 220.201 392.763-122.204 37.542-214.893 196.511-220.2 389.397-4.661 5.049-7.638 11.651-7.638 19.03v5.825h566.49v-5.825c0-7.379-2.849-13.981-7.509-18.9-5.049-193.016-97.867-351.985-220.2-389.527 123.24-37.67 216.446-198.453 220.588-392.892zM531.16 450.445v352.632c117.674 1.553 211.787 40.778 211.787 88.676H304.097c0-48.286 95.149-87.382 213.728-88.676V450.445c-93.077-3.107-167.901-81.297-167.901-177.093 0-8.803 6.99-15.793 15.793-15.793 8.803 0 15.794 6.99 15.794 15.793 0 80.261 63.69 145.635 142.01 145.635s142.011-65.374 142.011-145.635c0-8.803 6.99-15.793 15.794-15.793s15.793 6.99 15.793 15.793c0 95.019-73.789 172.82-165.96 177.093z"></path></svg><span>About 8 min</span><meta property="timeRequired" content="PT8M"></span><!----><!----></div><hr></div><div class="vp-toc-placeholder"><aside id="toc" vp-toc><!----><!--[--><div class="vp-toc-header">On This Page<button type="button" class="print-button" title="Print"><svg xmlns="http://www.w3.org/2000/svg" class="icon print-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="print icon" name="print"><path d="M819.2 364.8h-44.8V128c0-17.067-14.933-32-32-32H281.6c-17.067 0-32 14.933-32 32v236.8h-44.8C145.067 364.8 96 413.867 96 473.6v192c0 59.733 49.067 108.8 108.8 108.8h44.8V896c0 17.067 14.933 32 32 32h460.8c17.067 0 32-14.933 32-32V774.4h44.8c59.733 0 108.8-49.067 108.8-108.8v-192c0-59.733-49.067-108.8-108.8-108.8zM313.6 160h396.8v204.8H313.6V160zm396.8 704H313.6V620.8h396.8V864zM864 665.6c0 25.6-19.2 44.8-44.8 44.8h-44.8V588.8c0-17.067-14.933-32-32-32H281.6c-17.067 0-32 14.933-32 32v121.6h-44.8c-25.6 0-44.8-19.2-44.8-44.8v-192c0-25.6 19.2-44.8 44.8-44.8h614.4c25.6 0 44.8 19.2 44.8 44.8v192z"></path></svg></button><div class="arrow end"></div></div><div class="vp-toc-wrapper"><ul class="vp-toc-list"><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#tsfile-library-installation">TsFile library Installation</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#tsfile-usage">TsFile Usage</a></li><li><ul class="vp-toc-list"><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level3" href="#write-tsfile">Write TsFile</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level3" href="#example-for-writing-a-tsfile">Example for writing a TsFile</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level3" href="#interface-for-reading-tsfile">Interface for Reading TsFile</a></li><!----><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level3" href="#example-for-reading-an-existing-tsfile">Example for reading an existing TsFile</a></li><!----><!--]--></ul></li><!--]--><!--[--><li class="vp-toc-item"><a class="route-link vp-toc-link level2" href="#change-tsfile-configuration">Change TsFile Configuration</a></li><!----><!--]--></ul><div class="vp-toc-marker" style="top:-1.7rem;"></div></div><!--]--><!----></aside></div><!----><div class="theme-hope-content" vp-content><h1 id="tsfile-api" tabindex="-1"><a class="header-anchor" href="#tsfile-api"><span>TsFile API</span></a></h1><p>TsFile is a file format of Time Series used in IoTDB. This session introduces the usage of this file format.</p><h2 id="tsfile-library-installation" tabindex="-1"><a class="header-anchor" href="#tsfile-library-installation"><span>TsFile library Installation</span></a></h2><p>There are two ways to use TsFile in your own project.</p><ul><li>Use as jars: Compile the source codes and build to jars</li></ul><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" data-title="shell" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#61AFEF;">git</span><span style="color:#98C379;"> clone</span><span style="color:#98C379;"> https://github.com/apache/tsfile.git</span></span>
<span class="line"><span style="color:#61AFEF;">mvn</span><span style="color:#98C379;"> clean</span><span style="color:#98C379;"> package</span><span style="color:#D19A66;"> -Dmaven.test.skip=true</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><p>Then, all the jars are in folder named <code>target/</code>. Import <code>target/tsfile-2.1.0.jar</code> to your project.</p><ul><li><p>Use as a maven dependency:</p><p>Compile source codes and deploy to your local repository in three steps:</p><ul><li><p>Get the source codes</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" data-title="shell" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#61AFEF;">git</span><span style="color:#98C379;"> clone</span><span style="color:#98C379;"> https://github.com/apache/tsfile.git</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div></li><li><p>Compile the source codes and deploy</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" data-title="shell" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#61AFEF;">mvn</span><span style="color:#98C379;"> clean</span><span style="color:#98C379;"> install</span><span style="color:#D19A66;"> -P</span><span style="color:#98C379;"> with-java</span><span style="color:#D19A66;"> -Dmaven.test.skip=true</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div></li><li><p>add dependencies into your project:</p><div class="language-xml line-numbers-mode" data-highlighter="shiki" data-ext="xml" data-title="xml" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">dependency</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">groupId</span><span style="color:#ABB2BF;">&gt;org.apache.tsfile&lt;/</span><span style="color:#E06C75;">groupId</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">artifactId</span><span style="color:#ABB2BF;">&gt;tsfile&lt;/</span><span style="color:#E06C75;">artifactId</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">version</span><span style="color:#ABB2BF;">&gt;2.0.1&lt;/</span><span style="color:#E06C75;">version</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">dependency</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li></ul><p>Or, you can download the dependencies from official Maven repository:</p><ul><li><p>First, find your maven <code>settings.xml</code> on path: <code>${username}\.m2\settings.xml</code><br> , add this <code>&lt;profile&gt;</code> to <code>&lt;profiles&gt;</code>:</p><div class="language-xml line-numbers-mode" data-highlighter="shiki" data-ext="xml" data-title="xml" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">profile</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">id</span><span style="color:#ABB2BF;">&gt;allow-snapshots&lt;/</span><span style="color:#E06C75;">id</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">activation</span><span style="color:#ABB2BF;">&gt;&lt;</span><span style="color:#E06C75;">activeByDefault</span><span style="color:#ABB2BF;">&gt;true&lt;/</span><span style="color:#E06C75;">activeByDefault</span><span style="color:#ABB2BF;">&gt;&lt;/</span><span style="color:#E06C75;">activation</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">repositories</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">repository</span><span style="color:#ABB2BF;">&gt; </span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">id</span><span style="color:#ABB2BF;">&gt;apache.snapshots&lt;/</span><span style="color:#E06C75;">id</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">name</span><span style="color:#ABB2BF;">&gt;Apache Development Snapshot Repository&lt;/</span><span style="color:#E06C75;">name</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">url</span><span style="color:#ABB2BF;">&gt;https://repository.apache.org/content/repositories/snapshots/&lt;/</span><span style="color:#E06C75;">url</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">releases</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">enabled</span><span style="color:#ABB2BF;">&gt;false&lt;/</span><span style="color:#E06C75;">enabled</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">releases</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">snapshots</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">enabled</span><span style="color:#ABB2BF;">&gt;true&lt;/</span><span style="color:#E06C75;">enabled</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">snapshots</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">repository</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">repositories</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">profile</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li><li><p>Then add dependencies into your project:</p><div class="language-xml line-numbers-mode" data-highlighter="shiki" data-ext="xml" data-title="xml" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">dependency</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">groupId</span><span style="color:#ABB2BF;">&gt;org.apache.tsfile&lt;/</span><span style="color:#E06C75;">groupId</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">artifactId</span><span style="color:#ABB2BF;">&gt;tsfile&lt;/</span><span style="color:#E06C75;">artifactId</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;</span><span style="color:#E06C75;">version</span><span style="color:#ABB2BF;">&gt;2.0.1&lt;/</span><span style="color:#E06C75;">version</span><span style="color:#ABB2BF;">&gt;</span></span>
<span class="line"><span style="color:#ABB2BF;"> &lt;/</span><span style="color:#E06C75;">dependency</span><span style="color:#ABB2BF;">&gt;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li></ul></li></ul><h2 id="tsfile-usage" tabindex="-1"><a class="header-anchor" href="#tsfile-usage"><span>TsFile Usage</span></a></h2><p>This section demonstrates the detailed usages of TsFile.</p><p>Time-series Data<br> Time-series data is considered as a sequence of quadruples. A quadruple is defined as (device, measurement, time, value).</p><ul><li><p><strong>measurement</strong>: A physical or formal measurement that a time-series data takes, e.g., the temperature of a city, the<br> sales number of some goods or the speed of a train at different times. As a traditional sensor (like a thermometer) also<br> takes a single measurement and produce a time-series, we will use measurement and sensor interchangeably below.</p></li><li><p><strong>device</strong>: A device refers to an entity that takes several measurements (producing multiple time-series), e.g.,<br> a running train monitors its speed, oil meter, miles it has run, current passengers each is conveyed to a time-series dataset.</p></li></ul><p><strong>One Line of Data</strong>: In many industrial applications, a device normally contains more than one sensor and these sensors<br> may have values at the same timestamp, which is called one line of data.</p><p>Formally, one line of data consists of a <code>device_id</code>, a timestamp which indicates the milliseconds since January 1,<br> 1970, 00:00:00, and several data pairs composed of <code>measurement_id</code> and corresponding <code>value</code>. All data pairs in one<br> line belong to this <code>device_id</code> and have the same timestamp. If one of the <code>measurements</code> does not have a <code>value</code><br> in the <code>timestamp</code>, use a space instead(Actually, TsFile does not store null values). Its format is shown as follow:</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span>device_id, timestamp, &lt;measurement_id, value&gt;...</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>An example is illustrated as follow. In this example, the data type of two measurements are <code>INT32</code>, <code>FLOAT</code> respectively.</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span>device_1, 1490860659000, m1, 10, m2, 12.12</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><h3 id="write-tsfile" tabindex="-1"><a class="header-anchor" href="#write-tsfile"><span>Write TsFile</span></a></h3><p>A TsFile is generated by the following three steps and the complete code is given in the section &quot;Example for writing TsFile&quot;.</p><ol><li><p>construct a <code>TsFileWriter</code> instance.</p><p>Here are the available constructors:</p><ul><li>Without pre-defined schema</li></ul><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> TsFileWriter</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">File</span><span style="color:#E06C75;"> file) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><ul><li>With pre-defined schema</li></ul><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> TsFileWriter</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">File</span><span style="color:#E06C75;"> file</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> Schema</span><span style="color:#E06C75;"> schema) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>This one is for using the HDFS file system. <code>TsFileOutput</code> can be an instance of class <code>HDFSOutput</code>.</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> TsFileWriter</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">TsFileOutput</span><span style="color:#E06C75;"> output</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> Schema</span><span style="color:#E06C75;"> schema) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>If you want to set some TSFile configuration on your own, you could use param <code>config</code>. For example:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">TSFileConfig</span><span style="color:#E06C75;"> conf </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> TSFileConfig</span><span style="color:#E06C75;">()</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#E5C07B;">conf</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">setTSFileStorageFs</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;HDFS&quot;</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#E5C07B;">TsFileWriter</span><span style="color:#E06C75;"> tsFileWriter </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> TsFileWriter</span><span style="color:#E06C75;">(file</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> schema</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> conf)</span><span style="color:#ABB2BF;">;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>In this example, data files will be stored in HDFS, instead of local file system. If you&#39;d like to store data files in local file system, you can use <code>conf.setTSFileStorageFs(&quot;LOCAL&quot;)</code>, which is also the default config.</p><p>You can also config the ip and rpc port of your HDFS by <code>config.setHdfsIp(...)</code> and <code>config.setHdfsPort(...)</code>. The default ip is <code>localhost</code> and default rpc port is <code>9000</code>.</p><p><strong>Parameters:</strong></p><ul><li><p>file : The TsFile to write</p></li><li><p>schema : The file schemas, will be introduced in next part.</p></li><li><p>config : The config of TsFile.</p></li></ul></li><li><p>add measurements</p><p>Or you can make an instance of class <code>Schema</code> first and pass this to the constructor of class <code>TsFileWriter</code></p><p>The class <code>Schema</code> contains a map whose key is the name of one measurement schema, and the value is the schema itself.</p><p>Here are the interfaces:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// Create an empty Schema or from an existing map</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> Schema</span><span style="color:#E06C75;">()</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> Schema</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">Map</span><span style="color:#56B6C2;">&lt;</span><span style="color:#E06C75;">String</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> MeasurementSchema</span><span style="color:#56B6C2;">&gt;</span><span style="color:#E06C75;"> measurements)</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// Use this two interfaces to add measurements</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#C678DD;"> void</span><span style="color:#61AFEF;"> registerMeasurement</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">MeasurementSchema</span><span style="color:#E06C75;"> descriptor)</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#C678DD;"> void</span><span style="color:#61AFEF;"> registerMeasurements</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">Map</span><span style="color:#56B6C2;">&lt;</span><span style="color:#E06C75;">String</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> MeasurementSchema</span><span style="color:#56B6C2;">&gt;</span><span style="color:#E06C75;"> measurements)</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// Some useful getter and checker</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#E5C07B;"> TSDataType</span><span style="color:#61AFEF;"> getMeasurementDataType</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">String</span><span style="color:#E06C75;"> measurementId)</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#E5C07B;"> MeasurementSchema</span><span style="color:#61AFEF;"> getMeasurementSchema</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">String</span><span style="color:#E06C75;"> measurementId)</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#E5C07B;"> Map</span><span style="color:#56B6C2;">&lt;</span><span style="color:#E06C75;">String</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> MeasurementSchema</span><span style="color:#56B6C2;">&gt;</span><span style="color:#61AFEF;"> getAllMeasurementSchema</span><span style="color:#E06C75;">()</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#C678DD;"> boolean</span><span style="color:#61AFEF;"> hasMeasurement</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">String</span><span style="color:#E06C75;"> measurementId)</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>You can always use the following interface in <code>TsFileWriter</code> class to add additional measurements:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#C678DD;"> void</span><span style="color:#61AFEF;"> addMeasurement</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">MeasurementSchema</span><span style="color:#E06C75;"> measurementSchema) throws </span><span style="color:#E5C07B;">WriteProcessException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>The class <code>MeasurementSchema</code> contains the information of one measurement, there are several constructors:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> MeasurementSchema</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">String</span><span style="color:#E06C75;"> measurementId</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSDataType</span><span style="color:#E06C75;"> type</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSEncoding</span><span style="color:#E06C75;"> encoding)</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> MeasurementSchema</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">String</span><span style="color:#E06C75;"> measurementId</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSDataType</span><span style="color:#E06C75;"> type</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSEncoding</span><span style="color:#E06C75;"> encoding</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> CompressionType</span><span style="color:#E06C75;"> compressionType)</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> MeasurementSchema</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">String</span><span style="color:#E06C75;"> measurementId</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSDataType</span><span style="color:#E06C75;"> type</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSEncoding</span><span style="color:#E06C75;"> encoding</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> CompressionType</span><span style="color:#E06C75;"> compressionType</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> </span></span>
<span class="line"><span style="color:#E5C07B;">Map</span><span style="color:#56B6C2;">&lt;</span><span style="color:#E06C75;">String</span><span style="color:#ABB2BF;">,</span><span style="color:#E06C75;"> String</span><span style="color:#56B6C2;">&gt;</span><span style="color:#E06C75;"> props)</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>Parameters:</strong><br> ​</p><ul><li><p>measurementID: The name of this measurement, typically the name of the sensor.</p></li><li><p>type: The data type, now support six types: <code>BOOLEAN</code>, <code>INT32</code>, <code>INT64</code>, <code>FLOAT</code>, <code>DOUBLE</code>, <code>TEXT</code>;</p></li><li><p>encoding: The data encoding.</p></li><li><p>compression: The data compression.</p></li><li><p>props: Properties for special data types.Such as <code>max_point_number</code> for <code>FLOAT</code> and <code>DOUBLE</code>, <code>max_string_length</code> for<br><code>TEXT</code>. Use as string pairs into a map such as (&quot;max_point_number&quot;, &quot;3&quot;).</p></li></ul><blockquote><p><strong>Notice:</strong> Although one measurement name can be used in multiple deltaObjects, the properties cannot be changed. I.e.<br> it&#39;s not allowed to add one measurement name for multiple times with different type or encoding.<br> Here is a bad example:</p></blockquote><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// The measurement &quot;sensor_1&quot; is float type</span></span>
<span class="line"><span style="color:#61AFEF;">addMeasurement</span><span style="color:#E06C75;">(</span><span style="color:#C678DD;">new</span><span style="color:#61AFEF;"> MeasurementSchema</span><span style="color:#E06C75;">(</span><span style="color:#98C379;">&quot;sensor_1&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSDataType</span><span style="color:#ABB2BF;">.</span><span style="color:#E5C07B;">FLOAT</span><span style="color:#ABB2BF;">,</span><span style="color:#E5C07B;"> TSEncoding</span><span style="color:#ABB2BF;">.</span><span style="color:#E5C07B;">RLE</span><span style="color:#E06C75;">))</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// This call will throw a WriteProcessException exception</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li></ol><p>addMeasurement(new MeasurementSchema(&quot;sensor_1&quot;, TSDataType.INT32, TSEncoding.RLE));</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span></span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span></span></span>
<span class="line"><span>3. insert and write data continually.</span></span>
<span class="line"><span></span></span>
<span class="line"><span> Use this interface to create a new `TSRecord`(a timestamp and device pair).</span></span>
<span class="line"><span> </span></span>
<span class="line"><span> ```java</span></span>
<span class="line"><span> public TSRecord(long timestamp, String deviceId)</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span> Then create a `DataPoint`(a measurement and value pair), and use the addTuple method to add the DataPoint to the correct</span></span>
<span class="line"><span> TsRecord.</span></span>
<span class="line"><span> </span></span>
<span class="line"><span> Use this method to write</span></span>
<span class="line"><span> </span></span>
<span class="line"><span> ```java</span></span>
<span class="line"><span> public void write(TSRecord record) throws IOException, WriteProcessException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><ol start="4"><li><p>call <code>close</code> to finish this writing process.</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#C678DD;"> void</span><span style="color:#61AFEF;"> close</span><span style="color:#E06C75;">() throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div></li></ol><p>We are also able to write data into a closed TsFile.</p><ol><li><p>Use <code>ForceAppendTsFileWriter</code> to open a closed file.</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> ForceAppendTsFileWriter</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">File</span><span style="color:#E06C75;"> file) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div></li><li><p>call <code>doTruncate</code> truncate the part of Metadata</p></li><li><p>Then use <code>ForceAppendTsFileWriter</code> to construct a new <code>TsFileWriter</code></p></li></ol><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#61AFEF;"> TsFileWriter</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">TsFileIOWriter</span><span style="color:#E06C75;"> fileWriter) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>Please note, we should redo the step of adding measurements before writing new data to the TsFile.</p><h3 id="example-for-writing-a-tsfile" tabindex="-1"><a class="header-anchor" href="#example-for-writing-a-tsfile"><span>Example for writing a TsFile</span></a></h3><p>You should install TsFile to your local maven repository.</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" data-title="shell" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#61AFEF;">mvn</span><span style="color:#98C379;"> clean</span><span style="color:#98C379;"> install</span><span style="color:#D19A66;"> -am</span><span style="color:#D19A66;"> -DskipTests</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>You could write a TsFile by constructing <strong>TSRecord</strong> if you have the <strong>non-aligned</strong> (e.g. not all sensors contain values) time series data.</p><p>A more thorough example can be found at <code>/example/src/main/java/org/apache/tsfile/tsfile/TsFileWriteWithTSRecord.java</code></p><p>You could write a TsFile by constructing <strong>Tablet</strong> if you have the <strong>aligned</strong> time series data.</p><p>A more thorough example can be found at <code>/example/src/main/java/org/apache/tsfile/tsfile/TsFileWriteWithTablet.java</code></p><p>You could write data into a closed TsFile by using <strong>ForceAppendTsFileWriter</strong>.</p><p>A more thorough example can be found at <code>/example/src/main/java/org/apache/tsfile/tsfile/TsFileForceAppendWrite.java</code></p><h3 id="interface-for-reading-tsfile" tabindex="-1"><a class="header-anchor" href="#interface-for-reading-tsfile"><span>Interface for Reading TsFile</span></a></h3><ul><li>Definition of Path</li></ul><p>A path is a dot-separated string which uniquely identifies a time-series in TsFile, e.g., &quot;root.area_1.device_1.sensor_1&quot;.<br> The last section &quot;sensor_1&quot; is called &quot;measurementId&quot; while the remaining parts &quot;root.area_1.device_1&quot; is called deviceId.<br> As mentioned above, the same measurement in different devices has the same data type and encoding, and devices are also unique.</p><p>In read interfaces, The parameter <code>paths</code> indicates the measurements to be selected.</p><p>Path instance can be easily constructed through the class <code>Path</code>. For example:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">Path</span><span style="color:#E06C75;"> p </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> Path</span><span style="color:#E06C75;">(</span><span style="color:#98C379;">&quot;device_1.sensor_1&quot;</span><span style="color:#E06C75;">)</span><span style="color:#ABB2BF;">;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>We will pass an ArrayList of paths for final query call to support multiple paths.</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">List</span><span style="color:#ABB2BF;">&lt;</span><span style="color:#E5C07B;">Path</span><span style="color:#ABB2BF;">&gt;</span><span style="color:#E06C75;"> paths </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#E5C07B;"> ArrayList</span><span style="color:#ABB2BF;">&lt;</span><span style="color:#E5C07B;">Path</span><span style="color:#ABB2BF;">&gt;</span><span style="color:#E06C75;">()</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#E5C07B;">paths</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">add</span><span style="color:#ABB2BF;">(</span><span style="color:#C678DD;">new</span><span style="color:#61AFEF;"> Path</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;device_1.sensor_1&quot;</span><span style="color:#ABB2BF;">));</span></span>
<span class="line"><span style="color:#E5C07B;">paths</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">add</span><span style="color:#ABB2BF;">(</span><span style="color:#C678DD;">new</span><span style="color:#61AFEF;"> Path</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;device_1.sensor_3&quot;</span><span style="color:#ABB2BF;">));</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p><strong>Notice:</strong> When constructing a Path, the format of the parameter should be a dot-separated string, the last part will<br> be recognized as measurementId while the remaining parts will be recognized as deviceId.</p></blockquote><ul><li><p>Definition of Filter</p></li><li><p>Usage Scenario<br> Filter is used in TsFile reading process to select data satisfying one or more given condition(s).</p></li><li><p>IExpression<br> The <code>IExpression</code> is a filter expression interface and it will be passed to our final query call.<br> We create one or more filter expressions and may use binary filter operators to link them to our final expression.</p></li><li><p><strong>Create a Filter Expression</strong></p><p>There are two types of filters.</p><ul><li><p>TimeFilter: A filter for <code>time</code> in time-series data.</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span>IExpression timeFilterExpr = new GlobalTimeExpression(TimeFilter);</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>Use the following relationships to get a <code>TimeFilter</code> object (value is a long int variable).</p><table><thead><tr><th>Relationship</th><th>Description</th></tr></thead><tbody><tr><td>TimeFilter.eq(value)</td><td>Choose the time equal to the value</td></tr><tr><td><a href="http://TimeFilter.lt" target="_blank" rel="noopener noreferrer">TimeFilter.lt</a>(value)</td><td>Choose the time less than the value</td></tr><tr><td><a href="http://TimeFilter.gt" target="_blank" rel="noopener noreferrer">TimeFilter.gt</a>(value)</td><td>Choose the time greater than the value</td></tr><tr><td>TimeFilter.ltEq(value)</td><td>Choose the time less than or equal to the value</td></tr><tr><td>TimeFilter.gtEq(value)</td><td>Choose the time greater than or equal to the value</td></tr><tr><td>TimeFilter.notEq(value)</td><td>Choose the time not equal to the value</td></tr><tr><td>TimeFilter.not(TimeFilter)</td><td>Choose the time not satisfy another TimeFilter</td></tr></tbody></table></li><li><p>ValueFilter: A filter for <code>value</code> in time-series data.</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span>IExpression valueFilterExpr = new SingleSeriesExpression(Path, ValueFilter);</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>The usage of <code>ValueFilter</code> is the same as using <code>TimeFilter</code>, just to make sure that the type of the value<br> equal to the measurement&#39;s(defined in the path).</p></li></ul></li><li><p><strong>Binary Filter Operators</strong></p><p>Binary filter operators can be used to link two single expressions.</p><ul><li>BinaryExpression.and(Expression, Expression): Choose the value satisfy for both expressions.</li><li>BinaryExpression.or(Expression, Expression): Choose the value satisfy for at least one expression.</li></ul></li></ul><p>Filter Expression Examples</p><ul><li><p><strong>TimeFilterExpression Examples</strong></p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">IExpression</span><span style="color:#E06C75;"> timeFilterExpr </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> GlobalTimeExpression</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">TimeFilter</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">eq</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">15</span><span style="color:#ABB2BF;">)</span><span style="color:#E06C75;">)</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // series time = 15</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div></li></ul><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span> ```java</span></span>
<span class="line"><span> IExpression timeFilterExpr = new GlobalTimeExpression(TimeFilter.ltEq(15)); // series time &lt;= 15</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;"> IExpression</span><span style="color:#E06C75;"> timeFilterExpr </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> GlobalTimeExpression</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">TimeFilter</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">lt</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">15</span><span style="color:#ABB2BF;">)</span><span style="color:#E06C75;">)</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // series time &lt; 15</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><pre><code>```java
</code></pre><p>IExpression timeFilterExpr = new GlobalTimeExpression(TimeFilter.gtEq(15)); // series time &gt;= 15<br><code></code>java<br> IExpression timeFilterExpr = new GlobalTimeExpression(TimeFilter.notEq(15)); // series time != 15</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" data-title="" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span> ```java</span></span>
<span class="line"><span> IExpression timeFilterExpr = BinaryExpression.and(</span></span>
<span class="line"><span> new GlobalTimeExpression(TimeFilter.gtEq(15L)),</span></span>
<span class="line"><span> new GlobalTimeExpression(TimeFilter.lt(25L))); // 15 &lt;= series time &lt; 25</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><pre><code>```java
IExpression timeFilterExpr = BinaryExpression.or(
new GlobalTimeExpression(TimeFilter.gtEq(15L)),
new GlobalTimeExpression(TimeFilter.lt(25L))); // series time &gt;= 15 or series time &lt; 25
```
</code></pre><ul><li>Read Interface</li></ul><p>First, we open the TsFile and get a <code>ReadOnlyTsFile</code> instance from a file path string <code>path</code>.</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">TsFileSequenceReader</span><span style="color:#E06C75;"> reader </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> TsFileSequenceReader</span><span style="color:#E06C75;">(path)</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#E06C75;"> </span></span>
<span class="line"><span style="color:#E5C07B;">ReadOnlyTsFile</span><span style="color:#E06C75;"> readTsFile </span><span style="color:#56B6C2;">=</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> ReadOnlyTsFile</span><span style="color:#E06C75;">(reader)</span><span style="color:#ABB2BF;">;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>Next, we prepare the path array and query expression, then get final <code>QueryExpression</code> object by this interface:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">QueryExpression</span><span style="color:#E06C75;"> queryExpression </span><span style="color:#56B6C2;">=</span><span style="color:#E5C07B;"> QueryExpression</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">create</span><span style="color:#ABB2BF;">(paths, statement);</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>The ReadOnlyTsFile class has two <code>query</code> method to perform a query.</p><ul><li><p><strong>Method 1</strong></p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#E5C07B;"> QueryDataSet</span><span style="color:#61AFEF;"> query</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">QueryExpression</span><span style="color:#E06C75;"> queryExpression) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div></li><li><p><strong>Method 2</strong></p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">public</span><span style="color:#E5C07B;"> QueryDataSet</span><span style="color:#61AFEF;"> query</span><span style="color:#E06C75;">(</span><span style="color:#E5C07B;">QueryExpression</span><span style="color:#E06C75;"> queryExpression</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> long</span><span style="color:#E06C75;"> partitionStartOffset</span><span style="color:#ABB2BF;">,</span><span style="color:#C678DD;"> long</span><span style="color:#E06C75;"> partitionEndOffset) throws </span><span style="color:#E5C07B;">IOException</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>This method is designed for advanced applications such as the TsFile-Spark Connector.</p><ul><li><p><strong>params</strong> : For method 2, two additional parameters are added to support partial query:</p><ul><li><code>partitionStartOffset</code>: start offset for a TsFile</li><li><code>partitionEndOffset</code>: end offset for a TsFile</li></ul><blockquote><p><strong>What is Partial Query ?</strong></p><p>In some distributed file systems(e.g. HDFS), a file is split into severval parts which are called &quot;Blocks&quot; and stored in different nodes. Executing a query paralleled in each nodes involved makes better efficiency. Thus Partial Query is needed. Paritial Query only selects the results stored in the part split by <code>QueryConstant.PARTITION_START_OFFSET</code> and <code>QueryConstant.PARTITION_END_OFFSET</code> for a TsFile.</p></blockquote></li></ul></li><li><p>QueryDataset Interface</p></li></ul><p>The query performed above will return a <code>QueryDataset</code> object.</p><p>Here&#39;s the useful interfaces for user.</p><ul><li><p><code>bool hasNext();</code></p><p>Return true if this dataset still has elements.</p></li><li><p><code>List&lt;Path&gt; getPaths()</code></p><p>Get the paths in this data set.</p></li><li><p><code>List&lt;TSDataType&gt; getDataTypes();</code></p></li></ul><p>Get the data types. The class TSDataType is an enum class, the value will be one of the following:</p><pre><code> BOOLEAN,
INT32,
INT64,
FLOAT,
DOUBLE,
TEXT;
</code></pre><ul><li><p><code>RowRecord next() throws IOException;</code></p><p>Get the next record.</p><p>The class <code>RowRecord</code> consists of a <code>long</code> timestamp and a <code>List&lt;Field&gt;</code> for data in different sensors,<br> we can use two getter methods to get them.</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">long</span><span style="color:#61AFEF;"> getTimestamp</span><span style="color:#E06C75;">()</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#E5C07B;">List</span><span style="color:#56B6C2;">&lt;</span><span style="color:#E06C75;">Field</span><span style="color:#56B6C2;">&gt;</span><span style="color:#61AFEF;"> getFields</span><span style="color:#E06C75;">()</span><span style="color:#ABB2BF;">;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><p>To get data from one Field, use these methods:</p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">TSDataType</span><span style="color:#61AFEF;"> getDataType</span><span style="color:#E06C75;">()</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#E5C07B;">Object</span><span style="color:#61AFEF;"> getObjectValue</span><span style="color:#E06C75;">()</span><span style="color:#ABB2BF;">;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div></li></ul><h3 id="example-for-reading-an-existing-tsfile" tabindex="-1"><a class="header-anchor" href="#example-for-reading-an-existing-tsfile"><span>Example for reading an existing TsFile</span></a></h3><p>You should install TsFile to your local maven repository.</p><p>A more thorough example with query statement can be found at<br><code>/example/src/main/java/org/apache/tsfile/TsFileRead.java</code></p><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#C678DD;">package</span><span style="color:#C678DD;"> org.apache.tsfile</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> java.io.IOException</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> java.util.ArrayList</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.ReadOnlyTsFile</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.TsFileSequenceReader</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.common.Path</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.expression.IExpression</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.expression.QueryExpression</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.expression.impl.BinaryExpression</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.expression.impl.GlobalTimeExpression</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.expression.impl.SingleSeriesExpression</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.filter.TimeFilter</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.filter.ValueFilter</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"><span style="color:#C678DD;">import</span><span style="color:#E5C07B;"> org.apache.tsfile.read.query.dataset.QueryDataSet</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">/**</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> * The class is to show how to read TsFile file named &quot;test.tsfile&quot;.</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> * The TsFile file &quot;test.tsfile&quot; is generated from class TsFileWrite.</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> * Run TsFileWrite to generate the test.tsfile first</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> */</span></span>
<span class="line"><span style="color:#C678DD;">public</span><span style="color:#C678DD;"> class</span><span style="color:#E5C07B;"> TsFileRead</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#C678DD;"> private</span><span style="color:#C678DD;"> static</span><span style="color:#C678DD;"> void</span><span style="color:#61AFEF;"> queryAndPrint</span><span style="color:#ABB2BF;">(</span><span style="color:#E5C07B;">ArrayList</span><span style="color:#ABB2BF;">&lt;</span><span style="color:#E5C07B;">Path</span><span style="color:#ABB2BF;">&gt; </span><span style="color:#E06C75;font-style:italic;">paths</span><span style="color:#ABB2BF;">, </span><span style="color:#E5C07B;">ReadOnlyTsFile</span><span style="color:#E06C75;font-style:italic;"> readTsFile</span><span style="color:#ABB2BF;">, </span><span style="color:#E5C07B;">IExpression</span><span style="color:#E06C75;font-style:italic;"> statement</span><span style="color:#ABB2BF;">)</span></span>
<span class="line"><span style="color:#C678DD;"> throws</span><span style="color:#E5C07B;"> IOException</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"><span style="color:#E5C07B;"> QueryExpression</span><span style="color:#E06C75;"> queryExpression</span><span style="color:#56B6C2;"> =</span><span style="color:#E5C07B;"> QueryExpression</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">create</span><span style="color:#ABB2BF;">(paths, statement);</span></span>
<span class="line"><span style="color:#E5C07B;"> QueryDataSet</span><span style="color:#E06C75;"> queryDataSet</span><span style="color:#56B6C2;"> =</span><span style="color:#E5C07B;"> readTsFile</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">query</span><span style="color:#ABB2BF;">(queryExpression);</span></span>
<span class="line"><span style="color:#C678DD;"> while</span><span style="color:#ABB2BF;"> (</span><span style="color:#E5C07B;">queryDataSet</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">hasNext</span><span style="color:#ABB2BF;">()) {</span></span>
<span class="line"><span style="color:#E5C07B;"> System</span><span style="color:#ABB2BF;">.</span><span style="color:#E5C07B;">out</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">println</span><span style="color:#ABB2BF;">(</span><span style="color:#E5C07B;">queryDataSet</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">next</span><span style="color:#ABB2BF;">());</span></span>
<span class="line"><span style="color:#ABB2BF;"> }</span></span>
<span class="line"><span style="color:#E5C07B;"> System</span><span style="color:#ABB2BF;">.</span><span style="color:#E5C07B;">out</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">println</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;------------&quot;</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#ABB2BF;"> }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C678DD;"> public</span><span style="color:#C678DD;"> static</span><span style="color:#C678DD;"> void</span><span style="color:#61AFEF;"> main</span><span style="color:#ABB2BF;">(</span><span style="color:#E5C07B;">String</span><span style="color:#ABB2BF;">[] </span><span style="color:#E06C75;font-style:italic;">args</span><span style="color:#ABB2BF;">)</span><span style="color:#C678DD;"> throws</span><span style="color:#E5C07B;"> IOException</span><span style="color:#ABB2BF;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> // file path</span></span>
<span class="line"><span style="color:#E5C07B;"> String</span><span style="color:#E06C75;"> path</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;test.tsfile&quot;</span><span style="color:#ABB2BF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> // create reader and get the readTsFile interface</span></span>
<span class="line"><span style="color:#E5C07B;"> TsFileSequenceReader</span><span style="color:#E06C75;"> reader</span><span style="color:#56B6C2;"> =</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> TsFileSequenceReader</span><span style="color:#ABB2BF;">(path);</span></span>
<span class="line"><span style="color:#E5C07B;"> ReadOnlyTsFile</span><span style="color:#E06C75;"> readTsFile</span><span style="color:#56B6C2;"> =</span><span style="color:#C678DD;"> new</span><span style="color:#61AFEF;"> ReadOnlyTsFile</span><span style="color:#ABB2BF;">(reader);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> // use these paths(all sensors) for all the queries</span></span>
<span class="line"><span style="color:#E5C07B;"> ArrayList</span><span style="color:#ABB2BF;">&lt;</span><span style="color:#E5C07B;">Path</span><span style="color:#ABB2BF;">&gt; </span><span style="color:#E06C75;">paths</span><span style="color:#56B6C2;"> =</span><span style="color:#C678DD;"> new</span><span style="color:#E5C07B;"> ArrayList</span><span style="color:#ABB2BF;">&lt;&gt;();</span></span>
<span class="line"><span style="color:#E5C07B;"> paths</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">add</span><span style="color:#ABB2BF;">(</span><span style="color:#C678DD;">new</span><span style="color:#61AFEF;"> Path</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;device_1.sensor_1&quot;</span><span style="color:#ABB2BF;">));</span></span>
<span class="line"><span style="color:#E5C07B;"> paths</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">add</span><span style="color:#ABB2BF;">(</span><span style="color:#C678DD;">new</span><span style="color:#61AFEF;"> Path</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;device_1.sensor_2&quot;</span><span style="color:#ABB2BF;">));</span></span>
<span class="line"><span style="color:#E5C07B;"> paths</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">add</span><span style="color:#ABB2BF;">(</span><span style="color:#C678DD;">new</span><span style="color:#61AFEF;"> Path</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;device_1.sensor_3&quot;</span><span style="color:#ABB2BF;">));</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> // no query statement</span></span>
<span class="line"><span style="color:#61AFEF;"> queryAndPrint</span><span style="color:#ABB2BF;">(paths, readTsFile, </span><span style="color:#D19A66;">null</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"> //close the reader when you left</span></span>
<span class="line"><span style="color:#E5C07B;"> reader</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">close</span><span style="color:#ABB2BF;">();</span></span>
<span class="line"><span style="color:#ABB2BF;"> }</span></span>
<span class="line"><span style="color:#ABB2BF;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="change-tsfile-configuration" tabindex="-1"><a class="header-anchor" href="#change-tsfile-configuration"><span>Change TsFile Configuration</span></a></h2><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" data-title="java" style="background-color:#282c34;color:#abb2bf;"><pre class="shiki one-dark-pro vp-code"><code><span class="line"><span style="color:#E5C07B;">TSFileConfig</span><span style="color:#E06C75;"> config </span><span style="color:#56B6C2;">=</span><span style="color:#E5C07B;"> TSFileDescriptor</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">getInstance</span><span style="color:#ABB2BF;">().</span><span style="color:#61AFEF;">getConfig</span><span style="color:#ABB2BF;">();</span></span>
<span class="line"><span style="color:#E5C07B;">config</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">setXXX</span><span style="color:#ABB2BF;">();</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div></div><!----><footer class="vp-page-meta"><div class="vp-meta-item edit-link"><a class="auto-link external-link vp-meta-label" href="https://github.com/apache/tsfile/edit/docs/dev/src/stage/QuickStart.md" aria-label="Found Error? Edit this page on GitHub" rel="noopener noreferrer" target="_blank" iconsizing="both"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon edit-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="edit icon" name="edit"><path d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"></path><path d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"></path></svg><!--]-->Found Error? Edit this page on GitHub<!----></a></div><div class="vp-meta-item git-info"><div class="update-time"><span class="vp-meta-label">Last update: </span><span class="vp-meta-info" data-allow-mismatch="text">12/30/2025, 3:29:28 AM</span></div><!----></div></footer><!----><!----><!----><!--]--></main><!--]--><footer style="padding-bottom:1rem;padding-top:1rem;"><span id="doc-version" style="display:none;">latest</span><p style="text-align:center;color:#909399;font-size:12px;margin:0 30px;">Copyright © 2025 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:#909399;font-size:12px;margin:0 30px;"><strong>Have a question?</strong> Connect with us on issues. </p></footer></div><!--]--><!--]--><!--[--><!----><!--[--><!--]--><!--]--><!--]--></div>
<script type="module" src="/assets/app-jw83bKft.js" defer></script>
</body>
</html>