From 47f0889774bafb6229a0c655bd2a3ec303b7da66 Mon Sep 17 00:00:00 2001 From: facebook-github-bot Date: Fri, 4 Oct 2024 16:42:25 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=208ca05?= =?UTF-8?q?361505499d5c09993b06ccdc44442ad02f9=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 4 ++-- _src/cli.md | 8 ++++---- assets/js/1a20bc57.540bd4bc.js | 1 + assets/js/1a20bc57.c20c945a.js | 1 - ...ime~main.478b5aa1.js => runtime~main.f2a12ae4.js} | 2 +- blog/archive/index.html | 4 ++-- blog/incremental/index.html | 4 ++-- blog/index.html | 4 ++-- blog/tags/glean/index.html | 4 ++-- blog/tags/incremental/index.html | 4 ++-- blog/tags/index.html | 4 ++-- docs/angle/advanced/index.html | 4 ++-- docs/angle/debugging/index.html | 4 ++-- docs/angle/efficiency/index.html | 4 ++-- docs/angle/guide/index.html | 4 ++-- docs/angle/intro/index.html | 4 ++-- docs/angle/reference/index.html | 4 ++-- docs/angle/style/index.html | 4 ++-- docs/building/index.html | 4 ++-- docs/cli/index.html | 12 ++++++------ docs/databases/index.html | 4 ++-- docs/derived/index.html | 4 ++-- docs/implementation/incrementality/index.html | 4 ++-- docs/indexer/cxx/index.html | 4 ++-- docs/indexer/flow/index.html | 4 ++-- docs/indexer/hack/index.html | 4 ++-- docs/indexer/haskell/index.html | 4 ++-- docs/indexer/intro/index.html | 4 ++-- docs/indexer/lsif-go/index.html | 4 ++-- docs/indexer/lsif-java/index.html | 4 ++-- docs/indexer/lsif-rust/index.html | 4 ++-- docs/indexer/lsif-typescript/index.html | 4 ++-- docs/indexer/scip-dotnet/index.html | 4 ++-- docs/indexer/scip-python/index.html | 4 ++-- docs/introduction/index.html | 4 ++-- docs/query/api/haskell/index.html | 4 ++-- docs/query/haskell/index.html | 4 ++-- docs/query/intro/index.html | 4 ++-- docs/running/index.html | 4 ++-- docs/schema/all/index.html | 4 ++-- docs/schema/basic/index.html | 4 ++-- docs/schema/changing/index.html | 4 ++-- docs/schema/design/index.html | 4 ++-- docs/schema/recursion/index.html | 4 ++-- docs/schema/syntax/index.html | 4 ++-- docs/schema/thrift/index.html | 4 ++-- docs/schema/types/index.html | 4 ++-- docs/schema/workflow/index.html | 4 ++-- docs/server/index.html | 4 ++-- docs/shell/index.html | 4 ++-- docs/trying/index.html | 4 ++-- docs/walkthrough/index.html | 4 ++-- docs/write/index.html | 4 ++-- index.html | 4 ++-- 54 files changed, 110 insertions(+), 110 deletions(-) create mode 100644 assets/js/1a20bc57.540bd4bc.js delete mode 100644 assets/js/1a20bc57.c20c945a.js rename assets/js/{runtime~main.478b5aa1.js => runtime~main.f2a12ae4.js} (98%) diff --git a/404.html b/404.html index 8103f4d8d..fdae4f2e9 100644 --- a/404.html +++ b/404.html @@ -5,14 +5,14 @@ Page Not Found | Glean - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/_src/cli.md b/_src/cli.md index 3bfc404e9..8b6473825 100644 --- a/_src/cli.md +++ b/_src/cli.md @@ -47,8 +47,8 @@ using this option, creation will fail if the current schema has a different definition for any predicate in the base DB schema; therefore predicates may only be added or removed relative to the base DB. * `FILE..`
-File(s) of facts to write into the database (JSON). See [Writing data -to Glean](./write.md). +File(s) of facts to write into the database. Accepts JSON or compressed (zstd) JSONs. +See [Writing data to Glean](./write.md). The schema for the new DB is given by: @@ -74,8 +74,8 @@ Write facts to a database. * `--db NAME/INSTANCE` or `--db-name NAME --db-instance INSTANCE`
Specifies the name and instance of the database * `FILE..`
-File(s) of facts to write into the database (JSON). See [Writing data -to Glean](./write.md). +File(s) of facts to write into the database. Accepts JSON or compressed (zstd) JSONs. +See [Writing data to Glean](./write.md). * `--finish`
Also mark the DB as complete diff --git a/assets/js/1a20bc57.540bd4bc.js b/assets/js/1a20bc57.540bd4bc.js new file mode 100644 index 000000000..06b654488 --- /dev/null +++ b/assets/js/1a20bc57.540bd4bc.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[9114],{15680:(e,n,a)=>{a.r(n),a.d(n,{MDXContext:()=>o,MDXProvider:()=>u,mdx:()=>h,useMDXComponents:()=>s,withMDXComponents:()=>p});var t=a(96540);function l(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function i(){return i=Object.assign||function(e){for(var n=1;n=0||(l[a]=e[a]);return l}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}var o=t.createContext({}),p=function(e){return function(n){var a=s(n.components);return t.createElement(e,i({},n,{components:a}))}},s=function(e){var n=t.useContext(o),a=n;return e&&(a="function"==typeof e?e(n):r(r({},n),e)),a},u=function(e){var n=s(e.components);return t.createElement(o.Provider,{value:n},e.children)},c="mdxType",x={inlineCode:"code",wrapper:function(e){var n=e.children;return t.createElement(t.Fragment,{},n)}},N=t.forwardRef((function(e,n){var a=e.components,l=e.mdxType,i=e.originalType,d=e.parentName,o=m(e,["components","mdxType","originalType","parentName"]),p=s(a),u=l,c=p["".concat(d,".").concat(u)]||p[u]||x[u]||i;return a?t.createElement(c,r(r({ref:n},o),{},{components:a})):t.createElement(c,r({ref:n},o))}));function h(e,n){var a=arguments,l=n&&n.mdxType;if("string"==typeof e||l){var i=a.length,d=new Array(i);d[0]=N;var r={};for(var m in n)hasOwnProperty.call(n,m)&&(r[m]=n[m]);r.originalType=e,r[c]="string"==typeof e?e:l,d[1]=r;for(var o=2;o{a.r(n),a.d(n,{assets:()=>m,contentTitle:()=>d,default:()=>u,frontMatter:()=>i,metadata:()=>r,toc:()=>o});var t=a(58168),l=(a(96540),a(15680));const i={id:"cli",title:"The Glean CLI tool",sidebar_label:"The Glean CLI tool"},d=void 0,r={unversionedId:"cli",id:"cli",title:"The Glean CLI tool",description:"The Glean CLI tool (glean) can create and write data into databases,",source:"@site/docs/cli.md",sourceDirName:".",slug:"/cli",permalink:"/docs/cli",draft:!1,editUrl:"https://github.com/facebookincubator/Glean/tree/main/glean/website/docs/cli.md",tags:[],version:"current",frontMatter:{id:"cli",title:"The Glean CLI tool",sidebar_label:"The Glean CLI tool"},sidebar:"someSidebar",previous:{title:"Running the Glean Server",permalink:"/docs/server"},next:{title:"Introduction",permalink:"/docs/indexer/intro"}},m={},o=[{value:"glean list",id:"glean-list",level:3},{value:"glean create",id:"glean-create",level:3},{value:"glean write",id:"glean-write",level:3},{value:"glean finish",id:"glean-finish",level:3},{value:"glean dump",id:"glean-dump",level:3},{value:"glean delete",id:"glean-delete",level:3},{value:"glean derive",id:"glean-derive",level:3},{value:"glean index",id:"glean-index",level:3},{value:"glean query",id:"glean-query",level:3},{value:"glean restore",id:"glean-restore",level:3},{value:"glean validate",id:"glean-validate",level:3},{value:"glean validate-schema",id:"glean-validate-schema",level:3},{value:"glean stats",id:"glean-stats",level:3},{value:"glean unfinish",id:"glean-unfinish",level:3}],p={toc:o},s="wrapper";function u(e){let{components:n,...a}=e;return(0,l.mdx)(s,(0,t.A)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,l.mdx)("p",null,"The Glean CLI tool (",(0,l.mdx)("inlineCode",{parentName:"p"},"glean"),") can create and write data into databases,\nperform a variety of admin tasks on databases, and also do one-off\nqueries."),(0,l.mdx)("p",null,"The ",(0,l.mdx)("inlineCode",{parentName:"p"},"glean")," tool accepts all the ",(0,l.mdx)("a",{parentName:"p",href:"/docs/running#common-options"},"common\noptions")," to specify how to connect to access\nthe databases."),(0,l.mdx)("p",null,"The available commands are as follows:"),(0,l.mdx)("h3",{id:"glean-list"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean list")),(0,l.mdx)("p",null,"List the available databases."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"[DBNAME]")," ",(0,l.mdx)("br",null),"\nList only databases that match ",(0,l.mdx)("inlineCode",{parentName:"li"},"DBNAME")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--format (tty|plain|json|compact-json)")," ",(0,l.mdx)("br",null),"\nVarious different formats for the output. JSON is useful for\nprocessing and filtering the result in a script, e.g. using ",(0,l.mdx)("inlineCode",{parentName:"li"},"jq"),"."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"-v")," / ",(0,l.mdx)("inlineCode",{parentName:"li"},"--verbose")," ",(0,l.mdx)("br",null),"\nShow the full metadata associated with each database."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--include-backups")," ",(0,l.mdx)("br",null),"\nAlso list databases in backup storage (note: may be slow).")),(0,l.mdx)("h3",{id:"glean-create"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean create")),(0,l.mdx)("p",null,"Create a new database."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--finish"),(0,l.mdx)("br",null),"\nAlso mark the DB as complete"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--stacked DB"),(0,l.mdx)("br",null),"\nCreate a stacked database on top of ",(0,l.mdx)("inlineCode",{parentName:"li"},"DB"),"."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--property NAME=VALUE"),(0,l.mdx)("br",null),"\nSet properties when creating a DB"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--update-schema-for-stacked"),(0,l.mdx)("br",null),"\nWhen creating a stacked DB, the schema is taken from the base DB. This\noption specifies that the current schema should be used instead. When\nusing this option, creation will fail if the current schema has\na different definition for any predicate in the base DB schema;\ntherefore predicates may only be added or removed relative to the base DB."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE.."),(0,l.mdx)("br",null),"\nFile(s) of facts to write into the database. Accepts JSON or compressed (zstd) JSONs.\nSee ",(0,l.mdx)("a",{parentName:"li",href:"/docs/write"},"Writing data to Glean"),".")),(0,l.mdx)("p",null,"The schema for the new DB is given by:"),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},"the property ",(0,l.mdx)("inlineCode",{parentName:"p"},"glean.schema_id")," if specified, or")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},"if ",(0,l.mdx)("inlineCode",{parentName:"p"},"--stacked")," or ",(0,l.mdx)("inlineCode",{parentName:"p"},"--incremental"),", then"),(0,l.mdx)("ul",{parentName:"li"},(0,l.mdx)("li",{parentName:"ul"},"if ",(0,l.mdx)("inlineCode",{parentName:"li"},"--update-schema-for-stacked")," is specified, then the default\nschema (or the one given by the ",(0,l.mdx)("inlineCode",{parentName:"li"},"--schema")," option),"),(0,l.mdx)("li",{parentName:"ul"},"otherwise, the schema from the base DB."))),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},"otherwise the default schema, or the one given by the ",(0,l.mdx)("inlineCode",{parentName:"p"},"--schema"),"\nflag."))),(0,l.mdx)("p",null,"Note that when creating a stacked DB, it is an error if the schema\ndoes not agree with the schema in the base DB for any predicate that\nhas facts. That is, you cannot change the schema in a stacked DB for\nexisting facts in the base DB."),(0,l.mdx)("h3",{id:"glean-write"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean write")),(0,l.mdx)("p",null,"Write facts to a database."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE.."),(0,l.mdx)("br",null),"\nFile(s) of facts to write into the database. Accepts JSON or compressed (zstd) JSONs.\nSee ",(0,l.mdx)("a",{parentName:"li",href:"/docs/write"},"Writing data to Glean"),"."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--finish"),(0,l.mdx)("br",null),"\nAlso mark the DB as complete")),(0,l.mdx)("h3",{id:"glean-finish"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean finish")),(0,l.mdx)("p",null,"Notify server that a database is complete."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("h3",{id:"glean-dump"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean dump")),(0,l.mdx)("p",null,"Dump the contents of the specified database into a file."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE"),(0,l.mdx)("br",null),"\nFile to write the facts into")),(0,l.mdx)("h3",{id:"glean-delete"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean delete")),(0,l.mdx)("p",null,"Delete a database."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("h3",{id:"glean-derive"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean derive")),(0,l.mdx)("p",null,"Derive and store a predicate. See ",(0,l.mdx)("a",{parentName:"p",href:"/docs/derived"},"Derived Predicates"),"."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-bytes BYTES"),(0,l.mdx)("br",null),"\nMaximum number of bytes per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-facts FACTS"),(0,l.mdx)("br",null),"\nMaximum number of facts per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"PREDICATE"),(0,l.mdx)("br",null),"\nPredicates to derive"))),(0,l.mdx)("h3",{id:"glean-index"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean index")),(0,l.mdx)("p",null,"Index some source code using one of the known indexers."),(0,l.mdx)("p",null,"The form of the command in general is"),(0,l.mdx)("pre",null,(0,l.mdx)("code",{parentName:"pre"},"glean index LANGUAGE DIR --db NAME/INSTANCE\n")),(0,l.mdx)("p",null,"There may also be additional options accepted for each ",(0,l.mdx)("inlineCode",{parentName:"p"},"LANGUAGE"),"; try\n",(0,l.mdx)("inlineCode",{parentName:"p"},"glean index LANGUAGE --help")," to find out."),(0,l.mdx)("p",null,"For information on each indexer, see ",(0,l.mdx)("a",{parentName:"p",href:"/docs/indexer/intro"},"Indexers"),"."),(0,l.mdx)("h3",{id:"glean-query"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean query")),(0,l.mdx)("p",null,"Execute an Angle query and print the results, or write them to a file."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"p"},"--db-name NAME"),(0,l.mdx)("br",null),"\nSpecifies the database to query")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-bytes BYTES"),(0,l.mdx)("br",null),"\nMaximum number of bytes per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-facts FACTS"),(0,l.mdx)("br",null),"\nMaximum number of facts per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--expand"),(0,l.mdx)("br",null),"\nFetch nested facts (slower)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--limit FACTS"),(0,l.mdx)("br",null),"\nMaximum number of facts to query (default: no limit)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"-o,--output FILE"),(0,l.mdx)("br",null),"\nOutput the facts to a file")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--stats FILE"),(0,l.mdx)("br",null),"\nOutput stats to a file ('-' for stdout)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--profile"),(0,l.mdx)("br",null),"\nGet full profiling information; use with ",(0,l.mdx)("inlineCode",{parentName:"p"},"--stats")," to include facts_searched")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--timeout MILLISECONDS"),"\nOverride the default query timeout")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"QUERY"),"\nquery to execute (",(0,l.mdx)("inlineCode",{parentName:"p"},"@file")," to read from file, ",(0,l.mdx)("inlineCode",{parentName:"p"},"-")," for stdin)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--omit-results"),"\nDon't print results; use with ",(0,l.mdx)("inlineCode",{parentName:"p"},"--stat")," to get a count of results"))),(0,l.mdx)("h3",{id:"glean-restore"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean restore")),(0,l.mdx)("p",null,"Restore a database from backup."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"LOCATOR"),(0,l.mdx)("br",null),"\nDB location, see ",(0,l.mdx)("inlineCode",{parentName:"li"},":list-all")," in glean shell.")),(0,l.mdx)("p",null,"Alternatively the DB to restore can be specified by:"),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME")," and (",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-instance INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--date YYY-MM-DD")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--latest"),")")),(0,l.mdx)("h3",{id:"glean-validate"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean validate")),(0,l.mdx)("p",null,"Perform checks on the internal integrity of a database. This is for\ntesting and debugging Glean itself."),(0,l.mdx)("p",null," a local database"),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"p"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--no-typecheck"),(0,l.mdx)("br",null),"\nDon't typecheck facts.")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--no-keys"),(0,l.mdx)("br",null),"\nDon't verify key uniqueness")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--limit N"),(0,l.mdx)("br",null),"\nOnly validate the first N facts"))),(0,l.mdx)("h3",{id:"glean-validate-schema"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean validate-schema")),(0,l.mdx)("p",null,"Validate a schema. Checks that a new schem does not modify any of the\npredicates in the existing schema, which could lead to problems."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE"),(0,l.mdx)("br",null),"\nName of schema file")),(0,l.mdx)("h3",{id:"glean-stats"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean stats")),(0,l.mdx)("p",null,"Get fact counts and sizes. Like the ",(0,l.mdx)("inlineCode",{parentName:"p"},":statistics")," command in the shell."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("h3",{id:"glean-unfinish"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean unfinish")),(0,l.mdx)("p",null,"Unfinish a local database (turn it from complete to incomplete\nstate). This is for testing and development and not for routine use:\nonce a database is marked complete it could be replicated, so we\nshouldn't be modifying it."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/1a20bc57.c20c945a.js b/assets/js/1a20bc57.c20c945a.js deleted file mode 100644 index 9e42b45f6..000000000 --- a/assets/js/1a20bc57.c20c945a.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[9114],{15680:(e,n,a)=>{a.r(n),a.d(n,{MDXContext:()=>o,MDXProvider:()=>u,mdx:()=>h,useMDXComponents:()=>s,withMDXComponents:()=>p});var t=a(96540);function l(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function i(){return i=Object.assign||function(e){for(var n=1;n=0||(l[a]=e[a]);return l}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}var o=t.createContext({}),p=function(e){return function(n){var a=s(n.components);return t.createElement(e,i({},n,{components:a}))}},s=function(e){var n=t.useContext(o),a=n;return e&&(a="function"==typeof e?e(n):r(r({},n),e)),a},u=function(e){var n=s(e.components);return t.createElement(o.Provider,{value:n},e.children)},c="mdxType",x={inlineCode:"code",wrapper:function(e){var n=e.children;return t.createElement(t.Fragment,{},n)}},N=t.forwardRef((function(e,n){var a=e.components,l=e.mdxType,i=e.originalType,d=e.parentName,o=m(e,["components","mdxType","originalType","parentName"]),p=s(a),u=l,c=p["".concat(d,".").concat(u)]||p[u]||x[u]||i;return a?t.createElement(c,r(r({ref:n},o),{},{components:a})):t.createElement(c,r({ref:n},o))}));function h(e,n){var a=arguments,l=n&&n.mdxType;if("string"==typeof e||l){var i=a.length,d=new Array(i);d[0]=N;var r={};for(var m in n)hasOwnProperty.call(n,m)&&(r[m]=n[m]);r.originalType=e,r[c]="string"==typeof e?e:l,d[1]=r;for(var o=2;o{a.r(n),a.d(n,{assets:()=>m,contentTitle:()=>d,default:()=>u,frontMatter:()=>i,metadata:()=>r,toc:()=>o});var t=a(58168),l=(a(96540),a(15680));const i={id:"cli",title:"The Glean CLI tool",sidebar_label:"The Glean CLI tool"},d=void 0,r={unversionedId:"cli",id:"cli",title:"The Glean CLI tool",description:"The Glean CLI tool (glean) can create and write data into databases,",source:"@site/docs/cli.md",sourceDirName:".",slug:"/cli",permalink:"/docs/cli",draft:!1,editUrl:"https://github.com/facebookincubator/Glean/tree/main/glean/website/docs/cli.md",tags:[],version:"current",frontMatter:{id:"cli",title:"The Glean CLI tool",sidebar_label:"The Glean CLI tool"},sidebar:"someSidebar",previous:{title:"Running the Glean Server",permalink:"/docs/server"},next:{title:"Introduction",permalink:"/docs/indexer/intro"}},m={},o=[{value:"glean list",id:"glean-list",level:3},{value:"glean create",id:"glean-create",level:3},{value:"glean write",id:"glean-write",level:3},{value:"glean finish",id:"glean-finish",level:3},{value:"glean dump",id:"glean-dump",level:3},{value:"glean delete",id:"glean-delete",level:3},{value:"glean derive",id:"glean-derive",level:3},{value:"glean index",id:"glean-index",level:3},{value:"glean query",id:"glean-query",level:3},{value:"glean restore",id:"glean-restore",level:3},{value:"glean validate",id:"glean-validate",level:3},{value:"glean validate-schema",id:"glean-validate-schema",level:3},{value:"glean stats",id:"glean-stats",level:3},{value:"glean unfinish",id:"glean-unfinish",level:3}],p={toc:o},s="wrapper";function u(e){let{components:n,...a}=e;return(0,l.mdx)(s,(0,t.A)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,l.mdx)("p",null,"The Glean CLI tool (",(0,l.mdx)("inlineCode",{parentName:"p"},"glean"),") can create and write data into databases,\nperform a variety of admin tasks on databases, and also do one-off\nqueries."),(0,l.mdx)("p",null,"The ",(0,l.mdx)("inlineCode",{parentName:"p"},"glean")," tool accepts all the ",(0,l.mdx)("a",{parentName:"p",href:"/docs/running#common-options"},"common\noptions")," to specify how to connect to access\nthe databases."),(0,l.mdx)("p",null,"The available commands are as follows:"),(0,l.mdx)("h3",{id:"glean-list"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean list")),(0,l.mdx)("p",null,"List the available databases."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"[DBNAME]")," ",(0,l.mdx)("br",null),"\nList only databases that match ",(0,l.mdx)("inlineCode",{parentName:"li"},"DBNAME")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--format (tty|plain|json|compact-json)")," ",(0,l.mdx)("br",null),"\nVarious different formats for the output. JSON is useful for\nprocessing and filtering the result in a script, e.g. using ",(0,l.mdx)("inlineCode",{parentName:"li"},"jq"),"."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"-v")," / ",(0,l.mdx)("inlineCode",{parentName:"li"},"--verbose")," ",(0,l.mdx)("br",null),"\nShow the full metadata associated with each database."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--include-backups")," ",(0,l.mdx)("br",null),"\nAlso list databases in backup storage (note: may be slow).")),(0,l.mdx)("h3",{id:"glean-create"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean create")),(0,l.mdx)("p",null,"Create a new database."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--finish"),(0,l.mdx)("br",null),"\nAlso mark the DB as complete"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--stacked DB"),(0,l.mdx)("br",null),"\nCreate a stacked database on top of ",(0,l.mdx)("inlineCode",{parentName:"li"},"DB"),"."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--property NAME=VALUE"),(0,l.mdx)("br",null),"\nSet properties when creating a DB"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--update-schema-for-stacked"),(0,l.mdx)("br",null),"\nWhen creating a stacked DB, the schema is taken from the base DB. This\noption specifies that the current schema should be used instead. When\nusing this option, creation will fail if the current schema has\na different definition for any predicate in the base DB schema;\ntherefore predicates may only be added or removed relative to the base DB."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE.."),(0,l.mdx)("br",null),"\nFile(s) of facts to write into the database (JSON). See ",(0,l.mdx)("a",{parentName:"li",href:"/docs/write"},"Writing data\nto Glean"),".")),(0,l.mdx)("p",null,"The schema for the new DB is given by:"),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},"the property ",(0,l.mdx)("inlineCode",{parentName:"p"},"glean.schema_id")," if specified, or")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},"if ",(0,l.mdx)("inlineCode",{parentName:"p"},"--stacked")," or ",(0,l.mdx)("inlineCode",{parentName:"p"},"--incremental"),", then"),(0,l.mdx)("ul",{parentName:"li"},(0,l.mdx)("li",{parentName:"ul"},"if ",(0,l.mdx)("inlineCode",{parentName:"li"},"--update-schema-for-stacked")," is specified, then the default\nschema (or the one given by the ",(0,l.mdx)("inlineCode",{parentName:"li"},"--schema")," option),"),(0,l.mdx)("li",{parentName:"ul"},"otherwise, the schema from the base DB."))),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},"otherwise the default schema, or the one given by the ",(0,l.mdx)("inlineCode",{parentName:"p"},"--schema"),"\nflag."))),(0,l.mdx)("p",null,"Note that when creating a stacked DB, it is an error if the schema\ndoes not agree with the schema in the base DB for any predicate that\nhas facts. That is, you cannot change the schema in a stacked DB for\nexisting facts in the base DB."),(0,l.mdx)("h3",{id:"glean-write"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean write")),(0,l.mdx)("p",null,"Write facts to a database."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE.."),(0,l.mdx)("br",null),"\nFile(s) of facts to write into the database (JSON). See ",(0,l.mdx)("a",{parentName:"li",href:"/docs/write"},"Writing data\nto Glean"),"."),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--finish"),(0,l.mdx)("br",null),"\nAlso mark the DB as complete")),(0,l.mdx)("h3",{id:"glean-finish"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean finish")),(0,l.mdx)("p",null,"Notify server that a database is complete."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("h3",{id:"glean-dump"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean dump")),(0,l.mdx)("p",null,"Dump the contents of the specified database into a file."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database"),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE"),(0,l.mdx)("br",null),"\nFile to write the facts into")),(0,l.mdx)("h3",{id:"glean-delete"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean delete")),(0,l.mdx)("p",null,"Delete a database."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("h3",{id:"glean-derive"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean derive")),(0,l.mdx)("p",null,"Derive and store a predicate. See ",(0,l.mdx)("a",{parentName:"p",href:"/docs/derived"},"Derived Predicates"),"."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-bytes BYTES"),(0,l.mdx)("br",null),"\nMaximum number of bytes per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-facts FACTS"),(0,l.mdx)("br",null),"\nMaximum number of facts per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"PREDICATE"),(0,l.mdx)("br",null),"\nPredicates to derive"))),(0,l.mdx)("h3",{id:"glean-index"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean index")),(0,l.mdx)("p",null,"Index some source code using one of the known indexers."),(0,l.mdx)("p",null,"The form of the command in general is"),(0,l.mdx)("pre",null,(0,l.mdx)("code",{parentName:"pre"},"glean index LANGUAGE DIR --db NAME/INSTANCE\n")),(0,l.mdx)("p",null,"There may also be additional options accepted for each ",(0,l.mdx)("inlineCode",{parentName:"p"},"LANGUAGE"),"; try\n",(0,l.mdx)("inlineCode",{parentName:"p"},"glean index LANGUAGE --help")," to find out."),(0,l.mdx)("p",null,"For information on each indexer, see ",(0,l.mdx)("a",{parentName:"p",href:"/docs/indexer/intro"},"Indexers"),"."),(0,l.mdx)("h3",{id:"glean-query"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean query")),(0,l.mdx)("p",null,"Execute an Angle query and print the results, or write them to a file."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"p"},"--db-name NAME"),(0,l.mdx)("br",null),"\nSpecifies the database to query")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-bytes BYTES"),(0,l.mdx)("br",null),"\nMaximum number of bytes per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--page-facts FACTS"),(0,l.mdx)("br",null),"\nMaximum number of facts per page")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--expand"),(0,l.mdx)("br",null),"\nFetch nested facts (slower)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--limit FACTS"),(0,l.mdx)("br",null),"\nMaximum number of facts to query (default: no limit)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"-o,--output FILE"),(0,l.mdx)("br",null),"\nOutput the facts to a file")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--stats FILE"),(0,l.mdx)("br",null),"\nOutput stats to a file ('-' for stdout)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--profile"),(0,l.mdx)("br",null),"\nGet full profiling information; use with ",(0,l.mdx)("inlineCode",{parentName:"p"},"--stats")," to include facts_searched")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--timeout MILLISECONDS"),"\nOverride the default query timeout")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"QUERY"),"\nquery to execute (",(0,l.mdx)("inlineCode",{parentName:"p"},"@file")," to read from file, ",(0,l.mdx)("inlineCode",{parentName:"p"},"-")," for stdin)")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--omit-results"),"\nDon't print results; use with ",(0,l.mdx)("inlineCode",{parentName:"p"},"--stat")," to get a count of results"))),(0,l.mdx)("h3",{id:"glean-restore"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean restore")),(0,l.mdx)("p",null,"Restore a database from backup."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"LOCATOR"),(0,l.mdx)("br",null),"\nDB location, see ",(0,l.mdx)("inlineCode",{parentName:"li"},":list-all")," in glean shell.")),(0,l.mdx)("p",null,"Alternatively the DB to restore can be specified by:"),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME")," and (",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-instance INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--date YYY-MM-DD")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--latest"),")")),(0,l.mdx)("h3",{id:"glean-validate"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean validate")),(0,l.mdx)("p",null,"Perform checks on the internal integrity of a database. This is for\ntesting and debugging Glean itself."),(0,l.mdx)("p",null," a local database"),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"p"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--no-typecheck"),(0,l.mdx)("br",null),"\nDon't typecheck facts.")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--no-keys"),(0,l.mdx)("br",null),"\nDon't verify key uniqueness")),(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("p",{parentName:"li"},(0,l.mdx)("inlineCode",{parentName:"p"},"--limit N"),(0,l.mdx)("br",null),"\nOnly validate the first N facts"))),(0,l.mdx)("h3",{id:"glean-validate-schema"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean validate-schema")),(0,l.mdx)("p",null,"Validate a schema. Checks that a new schem does not modify any of the\npredicates in the existing schema, which could lead to problems."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"FILE"),(0,l.mdx)("br",null),"\nName of schema file")),(0,l.mdx)("h3",{id:"glean-stats"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean stats")),(0,l.mdx)("p",null,"Get fact counts and sizes. Like the ",(0,l.mdx)("inlineCode",{parentName:"p"},":statistics")," command in the shell."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")),(0,l.mdx)("h3",{id:"glean-unfinish"},(0,l.mdx)("inlineCode",{parentName:"h3"},"glean unfinish")),(0,l.mdx)("p",null,"Unfinish a local database (turn it from complete to incomplete\nstate). This is for testing and development and not for routine use:\nonce a database is marked complete it could be replicated, so we\nshouldn't be modifying it."),(0,l.mdx)("ul",null,(0,l.mdx)("li",{parentName:"ul"},(0,l.mdx)("inlineCode",{parentName:"li"},"--db NAME/INSTANCE")," or ",(0,l.mdx)("inlineCode",{parentName:"li"},"--db-name NAME --db-instance INSTANCE"),(0,l.mdx)("br",null),"\nSpecifies the name and instance of the database")))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.478b5aa1.js b/assets/js/runtime~main.f2a12ae4.js similarity index 98% rename from assets/js/runtime~main.478b5aa1.js rename to assets/js/runtime~main.f2a12ae4.js index ab62a7d77..b5a52ba7a 100644 --- a/assets/js/runtime~main.478b5aa1.js +++ b/assets/js/runtime~main.f2a12ae4.js @@ -1 +1 @@ -(()=>{"use strict";var e,d,a,f,c,t={},r={};function b(e){var d=r[e];if(void 0!==d)return d.exports;var a=r[e]={id:e,loaded:!1,exports:{}};return t[e].call(a.exports,a,a.exports,b),a.loaded=!0,a.exports}b.m=t,b.c=r,e=[],b.O=(d,a,f,c)=>{if(!a){var t=1/0;for(i=0;i=c)&&Object.keys(b.O).every((e=>b.O[e](a[o])))?a.splice(o--,1):(r=!1,c0&&e[i-1][2]>c;i--)e[i]=e[i-1];e[i]=[a,f,c]},b.n=e=>{var d=e&&e.__esModule?()=>e.default:()=>e;return b.d(d,{a:d}),d},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,b.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var c=Object.create(null);b.r(c);var t={};d=d||[null,a({}),a([]),a(a)];for(var r=2&f&&e;"object"==typeof r&&!~d.indexOf(r);r=a(r))Object.getOwnPropertyNames(r).forEach((d=>t[d]=()=>e[d]));return t.default=()=>e,b.d(c,t),c},b.d=(e,d)=>{for(var a in d)b.o(d,a)&&!b.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:d[a]})},b.f={},b.e=e=>Promise.all(Object.keys(b.f).reduce(((d,a)=>(b.f[a](e,d),d)),[])),b.u=e=>"assets/js/"+({15:"cfd71120",76:"283d7b21",98:"7c10977a",119:"d558f29a",488:"a81f2d1d",513:"476d6aec",515:"21418ead",979:"373392d9",1224:"14a2b9f8",1493:"eb83943b",1577:"90f022e0",1739:"2dc45ced",1991:"b2b675dd",2008:"5e677a75",2184:"d22a0e6a",2329:"f349a764",2419:"27315305",2634:"c4f5d8e4",2711:"9e4087bc",2804:"a5dc57e5",2894:"e72a3ded",2982:"f228e963",2984:"cc8d6d7f",3249:"ccc49370",4024:"246b6efd",4319:"b16bf7d2",4324:"391ef999",4363:"3e65d5b4",4487:"af32bd62",4813:"6875c492",4959:"5baf5c08",5016:"9d050fe4",5033:"41206b0e",5147:"581d6198",5894:"b2f554cd",5899:"a09c2993",6002:"473435fa",6119:"31fe93dc",6307:"5c4c46e6",6533:"432e378d",6621:"37fc9d46",6669:"33b5e0ca",6835:"abda9da4",7472:"814f3328",7483:"ca95d5ad",7643:"a6aa9e1f",7733:"0b5ee478",7941:"b0b0b448",8025:"2dfecbce",8055:"60691868",8209:"01a85c17",8262:"af94d498",8401:"17896441",8481:"b8b1253e",8581:"935f2afb",8606:"8293a772",8690:"2651e53d",8714:"1be78505",9114:"1a20bc57",9159:"c83e76ae",9267:"a7023ddc",9387:"6b032a97",9427:"31d6d5ed",9698:"ea32bb6f"}[e]||e)+"."+{15:"0e3424f6",76:"5e2f56ef",98:"14a479b7",119:"7aef164b",488:"04aa09c0",513:"40d25fa8",515:"a068d6b1",979:"e31f0d8c",1224:"584980eb",1493:"f67b0724",1577:"786a77de",1739:"c57eab73",1774:"5aef21ac",1991:"7eab122b",2008:"5b8358ab",2184:"5a72a44e",2329:"8c461c82",2419:"33b16225",2634:"e7dbb636",2711:"5650a2bf",2804:"f911ce9c",2894:"314b6caa",2982:"4300764b",2984:"766feed5",3249:"4345b62e",4024:"b76e466d",4319:"7213ad76",4324:"fbc78807",4363:"f6fca71e",4487:"22886726",4813:"f50ab996",4959:"7c6395aa",5016:"b345a195",5033:"5fbe809e",5147:"fa67c57b",5894:"38dfd45f",5899:"9f2bd6dd",6002:"beb95366",6119:"e6643ee3",6307:"3b4667af",6533:"206c9773",6621:"3e683732",6669:"b5e28820",6835:"e8dedb6a",7472:"cd0a7a20",7483:"a7057d62",7643:"52906f0b",7733:"fc00aec3",7941:"2ae0b894",8025:"ff264481",8055:"c4c5408b",8209:"8a4d26a4",8262:"685909ea",8401:"e197501f",8481:"d0ca5d95",8581:"59aeca34",8606:"bfd857cd",8690:"a86bc727",8714:"3ec7ab82",9100:"5ce11220",9114:"c20c945a",9159:"697a8fc3",9267:"db0474c2",9387:"aa3161ce",9427:"319d3a6f",9698:"20a7fbb6"}[e]+".js",b.miniCssF=e=>{},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=(e,d)=>Object.prototype.hasOwnProperty.call(e,d),f={},c="website:",b.l=(e,d,a,t)=>{if(f[e])f[e].push(d);else{var r,o;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{r.onerror=r.onload=null,clearTimeout(s);var c=f[e];if(delete f[e],r.parentNode&&r.parentNode.removeChild(r),c&&c.forEach((e=>e(a))),d)return d(a)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=u.bind(null,r.onerror),r.onload=u.bind(null,r.onload),o&&document.head.appendChild(r)}},b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),b.p="/",b.gca=function(e){return e={17896441:"8401",27315305:"2419",60691868:"8055",cfd71120:"15","283d7b21":"76","7c10977a":"98",d558f29a:"119",a81f2d1d:"488","476d6aec":"513","21418ead":"515","373392d9":"979","14a2b9f8":"1224",eb83943b:"1493","90f022e0":"1577","2dc45ced":"1739",b2b675dd:"1991","5e677a75":"2008",d22a0e6a:"2184",f349a764:"2329",c4f5d8e4:"2634","9e4087bc":"2711",a5dc57e5:"2804",e72a3ded:"2894",f228e963:"2982",cc8d6d7f:"2984",ccc49370:"3249","246b6efd":"4024",b16bf7d2:"4319","391ef999":"4324","3e65d5b4":"4363",af32bd62:"4487","6875c492":"4813","5baf5c08":"4959","9d050fe4":"5016","41206b0e":"5033","581d6198":"5147",b2f554cd:"5894",a09c2993:"5899","473435fa":"6002","31fe93dc":"6119","5c4c46e6":"6307","432e378d":"6533","37fc9d46":"6621","33b5e0ca":"6669",abda9da4:"6835","814f3328":"7472",ca95d5ad:"7483",a6aa9e1f:"7643","0b5ee478":"7733",b0b0b448:"7941","2dfecbce":"8025","01a85c17":"8209",af94d498:"8262",b8b1253e:"8481","935f2afb":"8581","8293a772":"8606","2651e53d":"8690","1be78505":"8714","1a20bc57":"9114",c83e76ae:"9159",a7023ddc:"9267","6b032a97":"9387","31d6d5ed":"9427",ea32bb6f:"9698"}[e]||e,b.p+b.u(e)},(()=>{var e={5354:0,1869:0};b.f.j=(d,a)=>{var f=b.o(e,d)?e[d]:void 0;if(0!==f)if(f)a.push(f[2]);else if(/^(1869|5354)$/.test(d))e[d]=0;else{var c=new Promise(((a,c)=>f=e[d]=[a,c]));a.push(f[2]=c);var t=b.p+b.u(d),r=new Error;b.l(t,(a=>{if(b.o(e,d)&&(0!==(f=e[d])&&(e[d]=void 0),f)){var c=a&&("load"===a.type?"missing":a.type),t=a&&a.target&&a.target.src;r.message="Loading chunk "+d+" failed.\n("+c+": "+t+")",r.name="ChunkLoadError",r.type=c,r.request=t,f[1](r)}}),"chunk-"+d,d)}},b.O.j=d=>0===e[d];var d=(d,a)=>{var f,c,t=a[0],r=a[1],o=a[2],n=0;if(t.some((d=>0!==e[d]))){for(f in r)b.o(r,f)&&(b.m[f]=r[f]);if(o)var i=o(b)}for(d&&d(a);n{"use strict";var e,d,a,f,c,t={},r={};function b(e){var d=r[e];if(void 0!==d)return d.exports;var a=r[e]={id:e,loaded:!1,exports:{}};return t[e].call(a.exports,a,a.exports,b),a.loaded=!0,a.exports}b.m=t,b.c=r,e=[],b.O=(d,a,f,c)=>{if(!a){var t=1/0;for(i=0;i=c)&&Object.keys(b.O).every((e=>b.O[e](a[o])))?a.splice(o--,1):(r=!1,c0&&e[i-1][2]>c;i--)e[i]=e[i-1];e[i]=[a,f,c]},b.n=e=>{var d=e&&e.__esModule?()=>e.default:()=>e;return b.d(d,{a:d}),d},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,b.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var c=Object.create(null);b.r(c);var t={};d=d||[null,a({}),a([]),a(a)];for(var r=2&f&&e;"object"==typeof r&&!~d.indexOf(r);r=a(r))Object.getOwnPropertyNames(r).forEach((d=>t[d]=()=>e[d]));return t.default=()=>e,b.d(c,t),c},b.d=(e,d)=>{for(var a in d)b.o(d,a)&&!b.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:d[a]})},b.f={},b.e=e=>Promise.all(Object.keys(b.f).reduce(((d,a)=>(b.f[a](e,d),d)),[])),b.u=e=>"assets/js/"+({15:"cfd71120",76:"283d7b21",98:"7c10977a",119:"d558f29a",488:"a81f2d1d",513:"476d6aec",515:"21418ead",979:"373392d9",1224:"14a2b9f8",1493:"eb83943b",1577:"90f022e0",1739:"2dc45ced",1991:"b2b675dd",2008:"5e677a75",2184:"d22a0e6a",2329:"f349a764",2419:"27315305",2634:"c4f5d8e4",2711:"9e4087bc",2804:"a5dc57e5",2894:"e72a3ded",2982:"f228e963",2984:"cc8d6d7f",3249:"ccc49370",4024:"246b6efd",4319:"b16bf7d2",4324:"391ef999",4363:"3e65d5b4",4487:"af32bd62",4813:"6875c492",4959:"5baf5c08",5016:"9d050fe4",5033:"41206b0e",5147:"581d6198",5894:"b2f554cd",5899:"a09c2993",6002:"473435fa",6119:"31fe93dc",6307:"5c4c46e6",6533:"432e378d",6621:"37fc9d46",6669:"33b5e0ca",6835:"abda9da4",7472:"814f3328",7483:"ca95d5ad",7643:"a6aa9e1f",7733:"0b5ee478",7941:"b0b0b448",8025:"2dfecbce",8055:"60691868",8209:"01a85c17",8262:"af94d498",8401:"17896441",8481:"b8b1253e",8581:"935f2afb",8606:"8293a772",8690:"2651e53d",8714:"1be78505",9114:"1a20bc57",9159:"c83e76ae",9267:"a7023ddc",9387:"6b032a97",9427:"31d6d5ed",9698:"ea32bb6f"}[e]||e)+"."+{15:"0e3424f6",76:"5e2f56ef",98:"14a479b7",119:"7aef164b",488:"04aa09c0",513:"40d25fa8",515:"a068d6b1",979:"e31f0d8c",1224:"584980eb",1493:"f67b0724",1577:"786a77de",1739:"c57eab73",1774:"5aef21ac",1991:"7eab122b",2008:"5b8358ab",2184:"5a72a44e",2329:"8c461c82",2419:"33b16225",2634:"e7dbb636",2711:"5650a2bf",2804:"f911ce9c",2894:"314b6caa",2982:"4300764b",2984:"766feed5",3249:"4345b62e",4024:"b76e466d",4319:"7213ad76",4324:"fbc78807",4363:"f6fca71e",4487:"22886726",4813:"f50ab996",4959:"7c6395aa",5016:"b345a195",5033:"5fbe809e",5147:"fa67c57b",5894:"38dfd45f",5899:"9f2bd6dd",6002:"beb95366",6119:"e6643ee3",6307:"3b4667af",6533:"206c9773",6621:"3e683732",6669:"b5e28820",6835:"e8dedb6a",7472:"cd0a7a20",7483:"a7057d62",7643:"52906f0b",7733:"fc00aec3",7941:"2ae0b894",8025:"ff264481",8055:"c4c5408b",8209:"8a4d26a4",8262:"685909ea",8401:"e197501f",8481:"d0ca5d95",8581:"59aeca34",8606:"bfd857cd",8690:"a86bc727",8714:"3ec7ab82",9100:"5ce11220",9114:"540bd4bc",9159:"697a8fc3",9267:"db0474c2",9387:"aa3161ce",9427:"319d3a6f",9698:"20a7fbb6"}[e]+".js",b.miniCssF=e=>{},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=(e,d)=>Object.prototype.hasOwnProperty.call(e,d),f={},c="website:",b.l=(e,d,a,t)=>{if(f[e])f[e].push(d);else{var r,o;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{r.onerror=r.onload=null,clearTimeout(s);var c=f[e];if(delete f[e],r.parentNode&&r.parentNode.removeChild(r),c&&c.forEach((e=>e(a))),d)return d(a)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=u.bind(null,r.onerror),r.onload=u.bind(null,r.onload),o&&document.head.appendChild(r)}},b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),b.p="/",b.gca=function(e){return e={17896441:"8401",27315305:"2419",60691868:"8055",cfd71120:"15","283d7b21":"76","7c10977a":"98",d558f29a:"119",a81f2d1d:"488","476d6aec":"513","21418ead":"515","373392d9":"979","14a2b9f8":"1224",eb83943b:"1493","90f022e0":"1577","2dc45ced":"1739",b2b675dd:"1991","5e677a75":"2008",d22a0e6a:"2184",f349a764:"2329",c4f5d8e4:"2634","9e4087bc":"2711",a5dc57e5:"2804",e72a3ded:"2894",f228e963:"2982",cc8d6d7f:"2984",ccc49370:"3249","246b6efd":"4024",b16bf7d2:"4319","391ef999":"4324","3e65d5b4":"4363",af32bd62:"4487","6875c492":"4813","5baf5c08":"4959","9d050fe4":"5016","41206b0e":"5033","581d6198":"5147",b2f554cd:"5894",a09c2993:"5899","473435fa":"6002","31fe93dc":"6119","5c4c46e6":"6307","432e378d":"6533","37fc9d46":"6621","33b5e0ca":"6669",abda9da4:"6835","814f3328":"7472",ca95d5ad:"7483",a6aa9e1f:"7643","0b5ee478":"7733",b0b0b448:"7941","2dfecbce":"8025","01a85c17":"8209",af94d498:"8262",b8b1253e:"8481","935f2afb":"8581","8293a772":"8606","2651e53d":"8690","1be78505":"8714","1a20bc57":"9114",c83e76ae:"9159",a7023ddc:"9267","6b032a97":"9387","31d6d5ed":"9427",ea32bb6f:"9698"}[e]||e,b.p+b.u(e)},(()=>{var e={5354:0,1869:0};b.f.j=(d,a)=>{var f=b.o(e,d)?e[d]:void 0;if(0!==f)if(f)a.push(f[2]);else if(/^(1869|5354)$/.test(d))e[d]=0;else{var c=new Promise(((a,c)=>f=e[d]=[a,c]));a.push(f[2]=c);var t=b.p+b.u(d),r=new Error;b.l(t,(a=>{if(b.o(e,d)&&(0!==(f=e[d])&&(e[d]=void 0),f)){var c=a&&("load"===a.type?"missing":a.type),t=a&&a.target&&a.target.src;r.message="Loading chunk "+d+" failed.\n("+c+": "+t+")",r.name="ChunkLoadError",r.type=c,r.request=t,f[1](r)}}),"chunk-"+d,d)}},b.O.j=d=>0===e[d];var d=(d,a)=>{var f,c,t=a[0],r=a[1],o=a[2],n=0;if(t.some((d=>0!==e[d]))){for(f in r)b.o(r,f)&&(b.m[f]=r[f]);if(o)var i=o(b)}for(d&&d(a);n Archive | Glean - + - + \ No newline at end of file diff --git a/blog/incremental/index.html b/blog/incremental/index.html index 2aa8cf564..8c5700512 100644 --- a/blog/incremental/index.html +++ b/blog/incremental/index.html @@ -5,7 +5,7 @@ Incremental indexing with Glean | Glean - + @@ -89,7 +89,7 @@ ownership of x is {A} and y is {B,C} (because it is referred to from z which has owner B), so the final owner of d is {A} && {B,C}.

Tracking all this shouldn't be too expensive, but it's tricky to get right!

- + \ No newline at end of file diff --git a/blog/index.html b/blog/index.html index 4a86694f0..2c828c300 100644 --- a/blog/index.html +++ b/blog/index.html @@ -5,7 +5,7 @@ Blog | Glean - + @@ -89,7 +89,7 @@ ownership of x is {A} and y is {B,C} (because it is referred to from z which has owner B), so the final owner of d is {A} && {B,C}.

Tracking all this shouldn't be too expensive, but it's tricky to get right!

- + \ No newline at end of file diff --git a/blog/tags/glean/index.html b/blog/tags/glean/index.html index 8ec893d2b..76ca8afe1 100644 --- a/blog/tags/glean/index.html +++ b/blog/tags/glean/index.html @@ -5,7 +5,7 @@ One post tagged with "glean" | Glean - + @@ -89,7 +89,7 @@ ownership of x is {A} and y is {B,C} (because it is referred to from z which has owner B), so the final owner of d is {A} && {B,C}.

Tracking all this shouldn't be too expensive, but it's tricky to get right!

- + \ No newline at end of file diff --git a/blog/tags/incremental/index.html b/blog/tags/incremental/index.html index 6ad88364e..e34c54316 100644 --- a/blog/tags/incremental/index.html +++ b/blog/tags/incremental/index.html @@ -5,7 +5,7 @@ One post tagged with "incremental" | Glean - + @@ -89,7 +89,7 @@ ownership of x is {A} and y is {B,C} (because it is referred to from z which has owner B), so the final owner of d is {A} && {B,C}.

Tracking all this shouldn't be too expensive, but it's tricky to get right!

- + \ No newline at end of file diff --git a/blog/tags/index.html b/blog/tags/index.html index c5c59a2aa..200e8f84b 100644 --- a/blog/tags/index.html +++ b/blog/tags/index.html @@ -5,14 +5,14 @@ Tags | Glean - + - + \ No newline at end of file diff --git a/docs/angle/advanced/index.html b/docs/angle/advanced/index.html index db1e79924..7d04eca88 100644 --- a/docs/angle/advanced/index.html +++ b/docs/angle/advanced/index.html @@ -5,14 +5,14 @@ Advanced Query Features | Glean - +

Advanced Query Features

Types and signatures

Angle queries are strongly typed: the server will check your query for type-safety before executing it. Type-checking ensures that the query makes sense; that it's not trying to pattern-match strings against integers, or look for a field in a record that doesn't exist for example.

Angle's type-checker isn't very clever, though. It mostly doesn't do type inference, it checks that expressions have the intended type. When it doesn't know the intended type of an expression, it uses a dumb inference mode that can only infer the type when it's really obvious: like a fact match, or a string.

facts> P where C = { name = "Fish" }; example.Parent { C, P }
can't infer the type of: {name = "Fish"}
try adding a type annotation like ({name = "Fish"} : T)
or reverse the statement (Q = P instead of P = Q)

In cases like this, Angle's type-checker needs a bit of help. We can use a type signature to supply more information about the type:

facts> P where C = { name = "Fish" } : example.Class; example.Parent { C, P }
{ "id": 1024, "key": { "name": "Pet", "line": 10 } }

Here we used { name = "Fish" } : example.Class to tell Angle the expected type of the pattern. You should read the colon as "has type", and the type can be any valid Angle type, for details see Built-in types.

Explicit fact IDs

Every fact has an ID, which is a 64-bit integer that uniquely identifies the fact in a particular database. You've probably noticed these fact IDs in the query results: every result has an id field with the fact ID, and a key field with the fact key.

Most Angle queries don't need to mention fact IDs explicitly, but sometimes it's useful. For example, you might need to perform a query to fetch some results, do some custom filtering on the results and then query Glean again using some of the fact IDs from the first query.

WARNING: a fact ID only makes sense in the context of a particular database, so make sure that your query that mentions fact IDs is being made on the same database that you obtained the fact ID from originally.

Glean has a syntax for referring to fact IDs directly; for example

facts> $1026 : example.Class
{ "id": 1026, "key": { "name": "Fish", "line": 30 } }

the syntax is $<fact ID>, but you will often want to use it with a type signature, as $<fact ID> : <predicate>.

If you get the predicate wrong, Glean will complain:

facts> $1026 : example.Parent
*** Exception: fact has the wrong type

The type can be omitted only if it is clear from the context, for example

facts> example.Parent { child = $1026 }
{ "id": 1029, "key": { "child": { "id": 1026 }, "parent": { "id": 1024 } } }

Sometimes you might want to use multiple fact IDs in a query. Or-patterns come in handy here:

facts> example.Parent { child = $1026 | $1027 }

Functional predicates

All the predicates we've seen so far have been key-only predicates. A predicate can also have a value; we call these functional predicates or key-value predicates.

For example, we might model a reference to a class in our example schema like this:

predicate Reference :
{ file : string, line : nat, column : nat } -> Class

This says that for a given (file,line,column) there can be at most one reference to a Class. This uniqueness is the important property of a key-value predicate: for each key there is at most one value.

We query for key-value predicates using this syntax:

facts> C where example.Reference { file = "x", line = 1, column = 2 } -> C

The pattern after the -> matches the value. It can be an arbitrary pattern, just like the key. Note that facts cannot be efficiently searched by value, so the pattern that matches the value is a filter only.

- + \ No newline at end of file diff --git a/docs/angle/debugging/index.html b/docs/angle/debugging/index.html index 5d72dde2b..23a95ee0a 100644 --- a/docs/angle/debugging/index.html +++ b/docs/angle/debugging/index.html @@ -5,7 +5,7 @@ Debugging | Glean - + @@ -15,7 +15,7 @@ shell, where you can experiment with queries quickly and easily.

If you're writing particularly complex queries, then consider using Derived Predicates to structure your query and to allow parts of the query to be re-used. To iterate on derived predicates, see How do I write and test a derived predicate?

Debugging a slow query

Performance debugging can be tricky, because Angle is a very declarative language. There are often many ways to write the query that are correct, but not all of them will be fast.

The shell provides a few facilities to help with this.

> :profile full

Turning on query profiling allows you to see how many facts of each predicate are being searched by your query. For example:

fbsource> search.cxx.SearchByNameAndScope { name = "Future" }
...
Facts searched:
cxx1.RecordDeclaration.1 : 103
cxx1.TypeAliasDeclaration.2 : 11
cxx1.QName.1 : 8
cxx1.VariableDeclaration.2 : 7
cxx1.EnumDeclaration.1 : 7
cxx1.Name.1 : 1

If your query is expensive, then likely you will see some large numbers next to one or more predicates. This is a sign that you probably want to reorder the statements in your query, or lift out some nested queries into statements so that you can control the ordering more precisely.

Showing the internals

The shell provides ways to show what Glean's query engine is doing internally. This is mostly useful for those working on the query engine itself, but it might also be helpful when debugging queries.

danger

We provide no guarantees about this functionality and it might change without warning.

> :debug ir

Shows the internal representation of the query after parsing, name resolution, type checking, and various transformations to simplify it. In particular, all the nesting has been flattened at this stage, so you can see the exact order of the searches on each predicate, which might help with performance debugging.

> :debug bytecode

Shows the compiled bytecode for the query. This is what Glean's virtual machine (VM) will execute to perform the query. Probably not all that useful for debugging queries.

- + \ No newline at end of file diff --git a/docs/angle/efficiency/index.html b/docs/angle/efficiency/index.html index e869b5688..146bf33c9 100644 --- a/docs/angle/efficiency/index.html +++ b/docs/angle/efficiency/index.html @@ -5,14 +5,14 @@ Query Efficiency | Glean - +

Query Efficiency

There are two important aspects of a query that affect its efficiency;

  1. Which fields are specified in a pattern
  2. The ordering of statements

We’ll cover each of these in the following sections.

Efficient matching of facts

The order of fields in the schema matters a lot for efficiency. Glean indexes facts by a prefix of their keys, so if we know the prefix when searching for facts this will be a lot faster. Often this difference is absolutely crucial; the difference is between O(log n) and O(n), so when the database is large this can be many orders of magnitude.

For example, the example.Parent predicate we saw earlier is defined as

predicate Parent :
{
child : Person,
parent : Person,
}

We should think of this as a mapping from child to parent. Glean won’t stop you writing a query for { parent = ... }, but such a query will examine all of the example.Parent facts in the database. We can see how many facts are searched for our query using :profile full in the shell (see debugging for more details):

facts> :profile full
facts> example.Parent { parent = { name = "Pet" }}
(snip)
2 results, 2 facts, 0.40ms, 159440 bytes, 988 compiled bytes
Facts searched:
example.Parent.1 : 3

This tells us that although it found the 2 results we expected, it searched all 3 example.Parent facts in the process.

Making queries efficient using a derived predicate

What if we wanted to efficiently map from parent to child? That’s easy to accomplish using a derived predicate. We’re going to define a new predicate with a different field ordering, and automatically generate the facts of our new predicate by deriving them from the facts of the existing predicate. For full details see Derived Predicates, what follows will be a walkthrough showing how to use a derived predicate to make our queries more efficient.

First we’ll define our derived predicate in the schema, like this:

predicate Child :
{
parent : Class,
child : Class,
}
stored
{ P, C } where Parent { C, P }

We can try this out in the shell. First we have to create a new database to hold the derived facts that is stacked on top of the old database. Drop out of the shell and run this command to create the new database:

glean create --db-root /tmp/glean/db --schema dir:/tmp/glean/schema --db derived/1 --stacked facts/1

Now start the shell again and load the stacked database. Note that we can still query facts from the original database:

> :db derived/1
derived> example.Parent _
{ "id": 1028, "key": { "child": { "id": 1025 }, "parent": { "id": 1024 } } }
{ "id": 1029, "key": { "child": { "id": 1026 }, "parent": { "id": 1024 } } }
{ "id": 1030, "key": { "child": { "id": 1027 }, "parent": { "id": 1026 } } }

Initially we have no facts of the Child predicate:

derived> example.Child _
0 results, 0 facts, 0.91ms, 812952 bytes, 664 compiled bytes

But we can create them automatically:

derived> * example.Child _
{ "id": 1037, "key": { "parent": { "id": 1024 }, "child": { "id": 1025 } } }
{ "id": 1038, "key": { "parent": { "id": 1024 }, "child": { "id": 1026 } } }
{ "id": 1039, "key": { "parent": { "id": 1026 }, "child": { "id": 1027 } } }

(the * means “derive and store” the facts produced by the query. To derive facts for a production database you would use either glean derive from the command line, or the appropriate Thrift API in whatever language you’re using to talk to the Glean server).

Now we have 3 facts of our derived predicate:

derived> :stat
example.Child.1
count: 3
size: 87 (87 bytes) 100.0000%

And finally we can make efficient queries to find a parent’s children:

derived> example.Child { parent = { name = "Pet" }}
{ "id": 1037, "key": { "parent": { "id": 1024 }, "child": { "id": 1025 } } }
{ "id": 1038, "key": { "parent": { "id": 1024 }, "child": { "id": 1026 } } }

2 results, 2 facts, 0.41ms, 160992 bytes, 1013 compiled bytes
Facts searched:
example.Child.1 : 2
example.Class.1 : 1

We found the correct 2 results, and only searched 2 example.Child facts.

This idea of adding extra indices to your database using derived predicates is common practice when working with Glean data, so it’s worthwhile getting familiar with it.

The order of statements is important

Suppose we want to find the grandparent of the Goldfish class using our example schema. We would probably write it like this:

Q where
example.Parent { child = { name = "Goldfish" }, parent = P };
example.Parent { child = P, parent = Q }

Generally speaking the statements are matched top-to-bottom. For each of the facts that match the first statement, bind the variables in the pattern and then proceed with the second statement, and so on.

As written, this query works by first finding the parent of Goldfish and then finding its parent, which is exactly what we want. This query will be efficient, because both stages are matching on the first field of the example.Parent predicate.

If instead we swapped the order of the statements:

Q where
example.Parent { child = P, parent = Q };
example.Parent { child = { name = "Goldfish" }, parent = P }

The query still works, and means exactly the same thing, but it’s much less efficient. This query works as follows:

  • for each example.Parent fact, call the child P and the parent Q
  • search for an example.Parent fact with child { name = "Goldfish" } and parent P
  • if it exists, then Q is a result

This is going to involve searching all of the example.Parent facts, instead of just the ones for the parent of Goldfish.

The general rule of thumb is to do the more specific searches first. The search for example.Parent { child = { name = "Goldfish" }, parent = P } is efficient because we know the child, this binds he value of P which makes the search for example.Parent { child = P, parent = Q } also fast.


- + \ No newline at end of file diff --git a/docs/angle/guide/index.html b/docs/angle/guide/index.html index 3b4f785d8..380f09903 100644 --- a/docs/angle/guide/index.html +++ b/docs/angle/guide/index.html @@ -5,7 +5,7 @@ Angle Guide | Glean - + @@ -41,7 +41,7 @@ than it. If Y = Values[..] were outside of the negation, the meaning would be give me all X for which there is at least one Y that is not greater than it. The answer to that would be all elements.

- + \ No newline at end of file diff --git a/docs/angle/intro/index.html b/docs/angle/intro/index.html index b452dfd63..da70eaa37 100644 --- a/docs/angle/intro/index.html +++ b/docs/angle/intro/index.html @@ -5,7 +5,7 @@ Angle Introduction | Glean - + @@ -16,7 +16,7 @@ particularly suited for finding and extracting data from Glean.

To give you a flavour of the query language, here is how we could return the names of all the member declarations defined in a JavaScript file project/myfile.js:

N where
flow.FileDeclaration {
file = "project/myfile.js",
declaration = {
memberDecl = {
name = N
}
}
}

To learn about Angle, start with the Guide.

- + \ No newline at end of file diff --git a/docs/angle/reference/index.html b/docs/angle/reference/index.html index 77aa989e1..af4f6408b 100644 --- a/docs/angle/reference/index.html +++ b/docs/angle/reference/index.html @@ -5,7 +5,7 @@ Angle Reference | Glean - + @@ -24,7 +24,7 @@   term < term
  term <= term
  term !== term

Standard numerical comparisons. These work on values of type nat only, and they have value {} if the comparison succeeds, otherwise they fail (in the same way as a predicate match fails if there are no facts that match the pattern).

  term != term

Standard comparison between two terms of any type. It has a value of {} if the comparison succeeds, otherwise it fails in the same way as a predicate match fails if there are no facts that match the pattern.

- + \ No newline at end of file diff --git a/docs/angle/style/index.html b/docs/angle/style/index.html index 3430f76f8..b8f5978ff 100644 --- a/docs/angle/style/index.html +++ b/docs/angle/style/index.html @@ -5,14 +5,14 @@ Angle Style Guide | Glean - +

Angle Style Guide

Typical Angle style uses the following rules:

  • 2-column indentation
  • trailing commas
  • open/close braces on a line by themselves
  • camel case for record field names

e.g.

# Named parameter
type Parameter =
{
name : Name,
type : Type,
isVariadic : bool,
}

This uses quite a lot of vertical space, but it's clear and works well with source control.

It's OK to put things on a single line if they fit:

type Access = enum { public | protected | private }
- + \ No newline at end of file diff --git a/docs/building/index.html b/docs/building/index.html index fb66176f0..7612a9536 100644 --- a/docs/building/index.html +++ b/docs/building/index.html @@ -5,7 +5,7 @@ Building Glean from Source | Glean - + @@ -26,7 +26,7 @@ build and install its dependencies:

./install_deps.sh

Build Glean

Now you can build all the Glean parts:

make

If everything worked, the tests should pass:

make test

At this point you can cabal install to install the executables into ~/.cabal/bin.

Tips for faster builds

If you have 4 or more cores and at least 16G of ram, you can significantly speed up the build times by passing some flags to the build stages. On an 6 core machine with 16G of ram you might use, to save 50% or more of the build time.

./install_deps.sh --threads 6
make EXTRA_GHC_OPTS='-j4 +RTS -A128m -n2m -RTS'

Using clang++-12 and clang-12 as the C and C++ compilers can shave another 25% off the build time.

- + \ No newline at end of file diff --git a/docs/cli/index.html b/docs/cli/index.html index f8582383d..97a70ed41 100644 --- a/docs/cli/index.html +++ b/docs/cli/index.html @@ -5,7 +5,7 @@ The Glean CLI tool | Glean - + @@ -30,16 +30,16 @@ using this option, creation will fail if the current schema has a different definition for any predicate in the base DB schema; therefore predicates may only be added or removed relative to the base DB.
  • FILE..
    -File(s) of facts to write into the database (JSON). See Writing data -to Glean.
  • The schema for the new DB is given by:

    - + \ No newline at end of file diff --git a/docs/schema/all/index.html b/docs/schema/all/index.html index a40348de2..e833f5226 100644 --- a/docs/schema/all/index.html +++ b/docs/schema/all/index.html @@ -5,7 +5,7 @@ The special "all" schema | Glean - + @@ -26,7 +26,7 @@ all separately, and clients can select at build time which version they want to use. This enables incremental migration of code from one schema to another schema.

    - + \ No newline at end of file diff --git a/docs/schema/basic/index.html b/docs/schema/basic/index.html index 75ead859c..1c036cc88 100644 --- a/docs/schema/basic/index.html +++ b/docs/schema/basic/index.html @@ -5,7 +5,7 @@ Basic Concepts | Glean - + @@ -23,7 +23,7 @@ patterns that match multiple keys, and get back all the facts that match the pattern. More about this when we talk about Angle queries.

    - + \ No newline at end of file diff --git a/docs/schema/changing/index.html b/docs/schema/changing/index.html index f047ed824..29c9f9cfa 100644 --- a/docs/schema/changing/index.html +++ b/docs/schema/changing/index.html @@ -5,7 +5,7 @@ How do I change a schema? | Glean - + @@ -56,7 +56,7 @@ which can be useful if you want to perform schema changes in a more explicit way, or to rename schemas.

    The feature is enabled using a top-level directive

    schema my_schema.2 evolves my_schema.1

    This declaration has the effect of treating queries for my_schema.1 predicates as if they were for my_schema.2. That is the query results will be retrieved from the database in the shape of a my_schema.2 fact and transformed into a fact of the equivalent my_schema.1 predicate specified in the query.

    The new schema must contain all the predicates of the old schema, either with new versions or old versions, and their definitions must be backwards compatible. We can achieve this by copying the entire content of the old schema into the new one and modifying it there.

    Now what should Glean do when a client asks for a fact from an old schema?

    • Answer with db facts from the old schema
    • Answer with db facts from the new schema transformed into the old ones.

    If there are no facts of the old schema in in the database we will take option 2. If the database has any fact at all of the old schema we choose option 1.

    That is, schema evolutions only take effect if there are no facts of the old schema in the database; it is ignored otherwise.

    As an example suppose we start with the following schemas:

    schema src.1 {
    predicate File {
    path : string
    }
    }

    schema os.1 {
    import src.1

    predicate Permissions {
    file : File,
    permissions : nat
    }
    }

    schema info.1 {
    import src.1

    predicate IsTemporary {
    file : File
    } F where F = src.File { path = "/tmp".. }
    }

    Now we want to make a backward-compatible change to src.File and add an extension field. We could add this to the file:

    schema src.2 {
    predicate File {
    path : string,
    extension : string
    }
    }

    schema src.2 evolves src.1

    Now if the indexer is still producing only src.1 facts, all other predicates will work as before and queries for src.File.2 will return no results.

    Once the indexer is changed to produce only src.2 facts queries like src.File.1 _ will be fulfilled using data from the src.2 schema, converting the src.File.2 results to the shape of src.File.1 before returning to the client.

    This is also the case in the derivation query of info.IsTemporary. Although info imports src.1, the query will be transformed to use src.2 facts.

    On the other hand, os.Permissions will be empty. This must be the case because its first field references a src.File.1 fact, of which there is none in the database. For this predicate to continue being available we must evolve its schema as well.

    schema os.2 {             # changed
    import src.2 # changed

    predicate Permissions {
    file : File,
    permissions : nat
    }
    }

    schema os.2 evolves os.1 # changed
    - + \ No newline at end of file diff --git a/docs/schema/design/index.html b/docs/schema/design/index.html index af141a6ba..a40d79c6d 100644 --- a/docs/schema/design/index.html +++ b/docs/schema/design/index.html @@ -5,7 +5,7 @@ Schema Design | Glean - + @@ -52,7 +52,7 @@ example of this was described in What is the difference between a predicate and a type?.

    How to experiment with schema design

    • Generate some data and see how large it is, using :stat in the shell.

    • Write some example queries against your data, and check how much searching they do using :profile in the shell (see Query Debugging).

    - + \ No newline at end of file diff --git a/docs/schema/recursion/index.html b/docs/schema/recursion/index.html index 68068cd85..6c06c610c 100644 --- a/docs/schema/recursion/index.html +++ b/docs/schema/recursion/index.html @@ -5,7 +5,7 @@ Recursion | Glean - + @@ -23,7 +23,7 @@ keys would make this process significantly harder.

    Facts can be recursive in their values, but not their keys. A mutually recursive set of facts must be added to the database in a single batch, however.

    To summarise, recursion is

    • allowed between predicates
    • not allowed between keys
    • allowed between values
    - + \ No newline at end of file diff --git a/docs/schema/syntax/index.html b/docs/schema/syntax/index.html index 6d65c07c4..f04e52296 100644 --- a/docs/schema/syntax/index.html +++ b/docs/schema/syntax/index.html @@ -5,7 +5,7 @@ Syntax | Glean - + @@ -44,7 +44,7 @@ future. The process for safely changing schemas is described in Changing the Schema.

    schema example.2 : example.1 {
    predicate Class :
    {
    # new definition of Class
    }
    }

    Inheritance is useful for making changes to a schema by creating a new schema version:

    • Inheriting from a schema brings into scope all the types and predicates of that schema, both qualified and unqualified.
    • The new schema also exports all the types and predicates defined in the schemas it inherits from, except those that are re-defined.

    Specifically, in the above example:

    • We can import example.2 anywhere and get all the predicates defined in example.1, except that we'll get the new Class defined in example.2.
    • We can still import example.1 and get the old version of the schema.

    Note that if you have predicates that depend on a predicate that was revised in this way, you must also copy those predicates to the new schema, because the existing predicates will refer to the old version of the predicate you revised. (In due course Glean will probably provide a convenient way to do this; in the meantime you have to copy & paste. Not a big deal because you'll usually delete the old one at some point, and you can't modify it anyway.)

    Named schemas can not form cycles through their import or inheritance declarations.

    Naming rules and conventions

    Names take the form of a dot-separated sequence of alphanumeric words. For example, sys.Blob, clang.File, or cxx.objc.Name. The words up to the last dot are the namespace, the final word is the name.

    See Names for full details.

    Briefly:

    • Namespaces (schema names) are dot-separated sequences of identifiers each beginning with a lower-case letter
    • Names and namespaces can contain only alphanumeric characters, '_', or '.' (namespaces only)
    • There is a set of reserved words that can't be used for names, e.g. class. Syncing the schema will fail with an error if you use a reserved word.
    - + \ No newline at end of file diff --git a/docs/schema/thrift/index.html b/docs/schema/thrift/index.html index e627ccd83..6a0ee8fe4 100644 --- a/docs/schema/thrift/index.html +++ b/docs/schema/thrift/index.html @@ -5,7 +5,7 @@ Thrift and JSON | Glean - + @@ -20,7 +20,7 @@ shell, the results are printed as JSON-encoded Thrift; when you write data to Glean it can be in the form of JSON-encoded Thrift.

    The relationship between schema types and Thrift/JSON is given by the following table:

    Schema typeThrift typeJSON
    natNat (i64)123
    byteByte (i8)123
    stringstring"abc"
    boolbooltrue or false
    [byte]binarybase-64 encoded string *1
    [T]list<T>[...]
    {
      f₁ : T₁,
      ...,
      fₙ : Tₙ
    }
    struct Foo {
      1: T₁ f₁;
      ...
      n: Tₙ fₙ;
    }
    {
      "f₁" : q₁,
      ...
      "fₙ" : qₙ
    }
    {
      f₁ : T₁ |
      ... |
      fₙ : Tₙ
    }
    union Foo {
      1: T₁ f₁;
      ...
      n: Tₙ fₙ;
    }
    { "f" : t }
    for one of the fields f₁..fₙ
    maybe TIn a record field:
    optional T f
    f : t
    if the value is present
    enum {
      L₁|
      ...|
      Lₙ
    }
    enum Foo {
      L₁ = 1,
      ...
      Lₙ = n
    }
    the index of the value,
    e.g. 12
    predicate P : K -> Vstruct P {
      1: Id id
      2: optional K key
      3: optional V value
    }
    note*2
    refer to fact N:
    N or { "id": N }
    define a fact:
    { "id" : N,
       "key" : t } or
    { "key": t } or
    { "key": t,
        "value" : v }
    type N = Tdepending on T:
    struct N { .. }
    union N {...}
    enum N {...}
    typedef T N;
    same as type T
    1. The Thrift encoding of a binary field in JSON is a base-64-encoded string. However, not all Thrift implementations respect this. At the time of writing, the Python Thrift implementation doesn't base-64-encode binary values. For this reason we provide an option in the Glean Thrift API to disable base-64 encoding for binary if your client doesn't support it. The Glean Shell also uses this option to make it easier to work with binary.

    2. the key is optional - a nested fact may be expanded in place or represented by a reference to the fact ID only. When querying Glean data the query specifies which nested facts should be expanded in the result, and when writing data to Glean using Thrift or JSON, we can optionally specify the value of nested facts inline.

    - + \ No newline at end of file diff --git a/docs/schema/types/index.html b/docs/schema/types/index.html index 3602d325e..d0fb8e0fd 100644 --- a/docs/schema/types/index.html +++ b/docs/schema/types/index.html @@ -5,14 +5,14 @@ Built-in Types | Glean - +

    Built-in Types

    TypeMeaning
    nat64-bit natural numbers
    byte8-bit natural numbers
    stringUTF-8 encoded strings
    [T]lists of elements of type T
    { field₁ : T₁, ..., fieldₙ : Tₙ }a record with zero or more named fields
    { field₁ : T₁ | ... | fieldₙ : Tₙ }a sum (union) type with one or more named alternatives
    Pa reference to a fact of predicate P
    boolthe boolean type with values true and false
    maybe Tan optional value of type T
    enum { name₁ | ... | nameₙ }exactly one of the symbols name₁..nameₙ
    - + \ No newline at end of file diff --git a/docs/schema/workflow/index.html b/docs/schema/workflow/index.html index 0fa532dd1..1976a4a5c 100644 --- a/docs/schema/workflow/index.html +++ b/docs/schema/workflow/index.html @@ -5,7 +5,7 @@ Workflow | Glean - + @@ -15,7 +15,7 @@ glean/schema/thrift, which are then processed into Haskell code by

    make thrift-schema-hs

    and finally built by

    make glean

    Examples of code using these types:

    Experimenting with schemas

    1. Modify the source files in glean/schema/source

    2. Start up the shell locally using your schema:
      glean shell --db-root ~/local/gleandb --schema glean/schema/source
      If you don't already have a ~/local/gleandb for storing local DBs, create it with mkdir ~/local/gleandb.

    3. Test it with some example data: see Loading a DB from JSON in the shell.

    4. Iterate as necessary, using :reload in the shell to reload the schema.

    - + \ No newline at end of file diff --git a/docs/server/index.html b/docs/server/index.html index 87540801e..8b9bb3fc6 100644 --- a/docs/server/index.html +++ b/docs/server/index.html @@ -5,7 +5,7 @@ Running the Glean Server | Glean - + @@ -17,7 +17,7 @@ Port number to listen on.

    The server watches for changes in any configuration files specified with config:PATH, including the schema.

    - + \ No newline at end of file diff --git a/docs/shell/index.html b/docs/shell/index.html index a761a3b95..73feca4c0 100644 --- a/docs/shell/index.html +++ b/docs/shell/index.html @@ -5,7 +5,7 @@ Using the Shell | Glean - + @@ -55,7 +55,7 @@ test your changes.
  • :statistics [PREDICATE]
    Show statistics for the current database.
  • :quit
    Leave the shell.
  • - + \ No newline at end of file diff --git a/docs/trying/index.html b/docs/trying/index.html index 1248c6185..efea667fb 100644 --- a/docs/trying/index.html +++ b/docs/trying/index.html @@ -5,7 +5,7 @@ Trying Glean | Glean - + @@ -28,7 +28,7 @@ (http://localhost:8888/packages/react-dom/src/client/ReactDOMComponent.js) - note how Glean is accurately linking both local and imported symbols.

    - + \ No newline at end of file diff --git a/docs/walkthrough/index.html b/docs/walkthrough/index.html index 1f3852ee6..824ea78e3 100644 --- a/docs/walkthrough/index.html +++ b/docs/walkthrough/index.html @@ -5,7 +5,7 @@ Walkthrough | Glean - + @@ -22,7 +22,7 @@ in /tmp/glean/facts.glean. Then reload schema and create a database from the example data using :reload and :load <file> in the shell:

    > :reload
    reloading schema [2 schemas, 7 predicates]
    > :load /tmp/glean/facts.glean
    facts>

    Now head over to Angle Guide to try some example queries and learn about how the query language works.

    - + \ No newline at end of file diff --git a/docs/write/index.html b/docs/write/index.html index 54da1cae9..80f9007b5 100644 --- a/docs/write/index.html +++ b/docs/write/index.html @@ -5,7 +5,7 @@ Writing data to Glean | Glean - + @@ -22,7 +22,7 @@ have dependencies between them, so the server won't hand out a task until its dependencies are complete.

  • When all tasks are done, the server marks the database as complete.

  • APIs for writing

    If none of the above work for you, the Thrift API enable basic write access to the database.

    • kickOff can be used to create a new DB
    • sendJsonBatch is for sending facts in JSON-serialized form
    • finishBatch exposes the result of a previously sent JSON batch
    • workFinished closes a DB

    A rough outline of a client looks like:

    glean = make_glean_thrift_client()
    db_handle = make_uuid()
    glean.kickOff(my_repo, KickOffFill(writeHandle=db_handle))
    for json_batch in json_batches:
    handle = glean.sendJsonBatch(json_batch)
    result = glean.finishBatch(handle)
    # handle result
    glean.workFinished(my_repo, db_handle, success_or_failure)

    Writing from the command line

    JSON format

    The JSON format for Glean data is described in Thrift and JSON.

    Here's an example of JSON data for writing to Glean:

    [
    { "predicate": "cxx1.Name.1", # define facts for cxx1.Name.1
    "facts": [
    { "id": 1, "key": "abc" }, # define a fact with id 1
    { "id": 2, "key": "def" }
    ]
    },
    { "predicate": "cxx1.FunctionName.1", # define facts for cxx1.FunctionName.1
    "facts": [
    { "id": 3,
    "key": {
    "name": { "id": 1 }}} # reference to fact with id 1
    ]
    },
    { "predicate": "cxx1.FunctionQName.1", # define facts for cxx1.FunctionQName.1
    "facts": [
    { "key": {
    "name": 3, # 3 is shorthand for { "id": 3 }
    "scope": { "global_": {} } } },
    { "key": {
    "name": {
    "key": { # define a nested fact directly
    "name": {
    "key": "ghi" }}}, # another nested fact
    "scope": {
    "namespace_": {
    "key": {
    "name": {
    "key": "std" }}}}}
    ]
    }
    ]

    The rules of the game are:

    • Predicate names must include versions, i.e. cxx1.Name.1 rather than cxx1.Name.
    • The id field when defining a fact is optional. The id numbers in the input file will not be the final id numbers assigned to the facts in the database.
    • There are no restrictions on id values (any 64-bit integer will do) but an id value may not be reused within a file.
    • Later facts may refer to earlier ones using either { "id": N } or just N.
    • It is only possible to refer to ids from facts in the same file, if you are writing multiple files using glean write or via the sendJsonBatch API.
    • a nested facts can be defined inline, instead of defining it with an id first and then referencing it.
    • an inline nested fact can be given an id and referred to later.

    Loading a DB from JSON in the shell

    The shell is useful for experimenting with creating a DB from JSON data directly. Let's try loading the data above into a DB in the shell:

    $ mkdir /tmp/glean
    $ glean shell --db-root /tmp/glean
    Glean Shell, dev mode
    type :help for help.
    no fbsource database availabe
    > :load test/0 /home/smarlow/test
    I0514 01:19:37.137109 3566745 Work.hs:184] test/16: database complete

    Let's see what facts we loaded:

    test> :stat
    1
    count: 72
    size: 5988
    cxx1.FunctionName.1
    count: 2
    size: 66
    cxx1.FunctionQName.1
    count: 2
    size: 70
    cxx1.Name.1
    count: 4
    size: 148
    cxx1.NamespaceQName.1
    count: 1
    size: 35
    test>

    Note that there were 4 cxx1.Name.1 facts - some of those were defined as inline nested facts in the JSON. We can query them all:

    test> cxx1.Name _
    4 results, 1 queries, 4 facts, 0.22ms, 44296 bytes

    { "id": 1096, "key": "abc" }
    { "id": 1097, "key": "def" }
    { "id": 1100, "key": "ghi" }
    { "id": 1102, "key": "std" }

    Note that the id values here do not correspond to the id values in the input file.

    Creating a database using the command line

    The glean command-line tool can be used to create a database directly on the server.

    To create a database from a single file of JSON facts:

    glean create --service <write-server> --finish --db <name>/<instance> <filename>

    where

    • <write-server> is the host:port of the Glean server
    • <name> is the name for your DB. For indexing repositories we normally use the name of the repository, but it's just a string, so you can use whatever you want.
    • <hash> identifies this particular instance of your database. For repositories we normally use the revision hash, but, again, it's just a string.
    • <filename> the file containing the JSON facts.

    If the file is more than, say, 100MB, this operation will probably time out sending the data to the server. To send large amounts of data you need to batch it up into multiple files, and then send it like this:

    glean create --service <write-server> --db <name>/<hash>
    glean write --service <write-server> --db <name>/<hash> <filename1>
    glean write --service <write-server> --db <name>/<hash> <filename2>
    ...
    glean finish --service <write-server> --db <name>/<hash>

    To find out if your DB made it:

    glean shell --service <write-server> :list

    This will list the DBs available on the write server.

    - + \ No newline at end of file diff --git a/index.html b/index.html index 0d85d5f53..fe0fb593b 100644 --- a/index.html +++ b/index.html @@ -5,14 +5,14 @@ Glean | Glean - +
    Glean Logo

    Glean

    System for collecting, deriving and querying facts about source code

    Key Features

    Rich types

    Store detailed information about code

    Compact storage

    Store data about code at scale

    Efficient queries

    Build experiences with deep insights from code

    - + \ No newline at end of file