http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/fonts/fontawesome-webfont.woff ---------------------------------------------------------------------- diff --git a/avatica/site/fonts/fontawesome-webfont.woff b/avatica/site/fonts/fontawesome-webfont.woff new file mode 100755 index 0000000..628b6a5 Binary files /dev/null and b/avatica/site/fonts/fontawesome-webfont.woff differ
http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/img/cake.jpg ---------------------------------------------------------------------- diff --git a/avatica/site/img/cake.jpg b/avatica/site/img/cake.jpg new file mode 100644 index 0000000..af370c6 Binary files /dev/null and b/avatica/site/img/cake.jpg differ http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/img/feather.png ---------------------------------------------------------------------- diff --git a/avatica/site/img/feather.png b/avatica/site/img/feather.png new file mode 100644 index 0000000..a2da98a Binary files /dev/null and b/avatica/site/img/feather.png differ http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/img/logo.png ---------------------------------------------------------------------- diff --git a/avatica/site/img/logo.png b/avatica/site/img/logo.png new file mode 100644 index 0000000..b883465 Binary files /dev/null and b/avatica/site/img/logo.png differ http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/img/pie-chart.png ---------------------------------------------------------------------- diff --git a/avatica/site/img/pie-chart.png b/avatica/site/img/pie-chart.png new file mode 100644 index 0000000..59e2ddb Binary files /dev/null and b/avatica/site/img/pie-chart.png differ http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/img/window-types.png ---------------------------------------------------------------------- diff --git a/avatica/site/img/window-types.png b/avatica/site/img/window-types.png new file mode 100644 index 0000000..366c00a Binary files /dev/null and b/avatica/site/img/window-types.png differ http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/index.html ---------------------------------------------------------------------- diff --git a/avatica/site/index.html b/avatica/site/index.html new file mode 100644 index 0000000..8857d27 --- /dev/null +++ b/avatica/site/index.html @@ -0,0 +1,75 @@ +--- +layout: default +title: Apache Calcite • Dynamic data management framework +overview: true +--- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} + +<section class="intro"> + <div class="grid"> + <div class="unit whole center-on-mobiles"> + <p class="first">The foundation for your next high-performance database.</p> + </div> + </div> +</section> +<section class="features"> + <div class="grid"> + <div class="unit one-third"> + <h2>Standard SQL</h2> + <p>Industry-standard SQL parser, validator and JDBC driver.</p> + <a href="{{ site.baseurl }}/docs/reference.html">SQL →</a> + </div> + <div class="unit one-third"> + <h2>Query optimization</h2> + <p>Represent your query in relational algebra, transform using + planning rules, and optimize according to a cost model.</p> + <a href="{{ site.baseurl }}/docs/algebra.html">Relational algebra →</a> + </div> + <div class="unit one-third"> + <h2>Any data, anywhere</h2> + <p>Connect to third-party data sources, browse metadata, and optimize by pushing the computation to the data.</p> + <a href="{{ site.baseurl }}/docs/adapter.html">Adapters →</a> + </div> + <div class="clear"></div> + </div> +</section> +<section class="resources"> + <div class="grid"> + <div class="unit one-third"> + <summary> + <h3>Resources</h3> + <ul> + <li><a href="{{ site.baseurl }}/downloads">Downloads</a></li> + <li><a href="{{ site.baseurl }}/docs/history.html">History</a></li> + <li><a href="http://www.apache.org/security">Security</a></li> + </ul> + </summary> + </div> + <div class="unit one-third"> + <summary> + <h3>Apache</h3> + <ul> + <li><a href="http://www.apache.org/licenses">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Donate</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li> + <li><a href="http://www.apache.org">Website</a></li> + </ul> + </summary> + </div> + </div> +</section> http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/js/html5shiv.min.js ---------------------------------------------------------------------- diff --git a/avatica/site/js/html5shiv.min.js b/avatica/site/js/html5shiv.min.js new file mode 100644 index 0000000..d4c731a --- /dev/null +++ b/avatica/site/js/html5shiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag ()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined" ==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/js/respond.min.js ---------------------------------------------------------------------- diff --git a/avatica/site/js/respond.min.js b/avatica/site/js/respond.min.js new file mode 100644 index 0000000..80a7b69 --- /dev/null +++ b/avatica/site/js/respond.min.js @@ -0,0 +1,5 @@ +/*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl + * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT + * */ + +!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?: o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeC hild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substr ing(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&(" //"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmValue=t,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/news/index.html ---------------------------------------------------------------------- diff --git a/avatica/site/news/index.html b/avatica/site/news/index.html new file mode 100644 index 0000000..66d4dcd --- /dev/null +++ b/avatica/site/news/index.html @@ -0,0 +1,35 @@ +--- +layout: news +title: News +permalink: /news/ +author: all +--- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} + +{% for post in site.posts %} + {% include news_item.html %} +{% endfor %} + +<p></p> + +<h2>Calcite Twitter</h2> + +<p>The official <a href="https://twitter.com/ApacheCalcite">@ApacheCalcite</a> +Twitter account pushes announcements about Calcite. If you give a talk about +Calcite, let us know and we'll tweet it out and add it to the news section +of the website.</p> http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/site/news/releases/index.html ---------------------------------------------------------------------- diff --git a/avatica/site/news/releases/index.html b/avatica/site/news/releases/index.html new file mode 100644 index 0000000..c6c9fa6 --- /dev/null +++ b/avatica/site/news/releases/index.html @@ -0,0 +1,26 @@ +--- +layout: news +title: Releases +permalink: /news/releases/ +author: all +--- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} + +{% for post in site.categories.release %} + {% include news_item.html %} +{% endfor %} http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/config/assemblies/source-assembly.xml ---------------------------------------------------------------------- diff --git a/avatica/src/main/config/assemblies/source-assembly.xml b/avatica/src/main/config/assemblies/source-assembly.xml new file mode 100644 index 0000000..2b1f930 --- /dev/null +++ b/avatica/src/main/config/assemblies/source-assembly.xml @@ -0,0 +1,103 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<assembly> + <id>source-release</id> + <formats> + <format>zip</format> + <format>tar.gz</format> + </formats> + <fileSets> + <!-- main project directory structure --> + <fileSet> + <directory>.</directory> + <outputDirectory>/</outputDirectory> + <useDefaultExcludes>true</useDefaultExcludes> + <excludes> + <!-- build output --> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/).*${project.build.directory}.*] + </exclude> + + <!-- NOTE: Most of the following excludes should not be required + if the standard release process is followed. This is because the release + plugin checks out project sources into a location like target/checkout, then + runs the build from there. The result is a source-release archive that comes + from a pretty clean directory structure. HOWEVER, if the release plugin is + configured to run extra goals or generate a project website, it's definitely + possible that some of these files will be present. So, it's safer to exclude + them. --> + + <!-- IDEs --> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?maven-eclipse\.xml] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.project] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.classpath] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?[^/]*\.iws] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.idea(/.*)?] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?out(/.*)?] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?[^/]*\.ipr] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?[^/]*\.iml] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.settings(/.*)?] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.externalToolBuilders(/.*)?] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.deployables(/.*)?] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.wtpmodules(/.*)?] + </exclude> + + + <!-- scm --> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?\.gitignore(/.*)?] + </exclude> + + <exclude>**/.buildpath</exclude> + <exclude>**/sandbox/**</exclude> + + <!-- misc --> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?cobertura\.ser] + </exclude> + + <!-- release-plugin temp files --> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?pom\.xml\.releaseBackup] + </exclude> + <exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?release\.properties] + </exclude> + </excludes> + </fileSet> + <!-- LICENSE, NOTICE, DEPENDENCIES, git.properties, etc. calculated at build time --> + <fileSet> + <directory>${project.build.directory}/maven-shared-archive-resources/META-INF + </directory> + <outputDirectory>/</outputDirectory> + </fileSet> + <fileSet> + <directory>${project.build.directory}</directory> + <includes> + <include>git.properties</include> + </includes> + <outputDirectory>/</outputDirectory> + </fileSet> + </fileSets> +</assembly> http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/config/checkstyle/checker.xml ---------------------------------------------------------------------- diff --git a/avatica/src/main/config/checkstyle/checker.xml b/avatica/src/main/config/checkstyle/checker.xml new file mode 100644 index 0000000..167511b --- /dev/null +++ b/avatica/src/main/config/checkstyle/checker.xml @@ -0,0 +1,279 @@ +<?xml version="1.0"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> + +<!-- + This version of checkstyle is based on the Apache Giraph checkstyle + configuration, which in turn is based on Hadoop and common-math + configurations. + + The documentation for checkstyle is available at + + http://checkstyle.sourceforge.net +--> + +<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd"> + +<!-- Calcite customization of default Checkstyle behavior --> +<module name="Checker"> + <property name="localeLanguage" value="en"/> + + <!-- Checks for headers --> + <!-- See http://checkstyle.sf.net/config_header.html --> + <!-- Verify that EVERY source file has the appropriate license --> + <module name="Header"> + <property name="headerFile" value="${checkstyle.header.file}"/> + </module> + + <!-- Checks for Javadoc comments (checker). --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <!-- Require package javadoc --> + <module name="JavadocPackage"/> + + <!-- Miscellaneous other checks (checker). --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <!-- Require files to end with newline characters --> + <module name="NewlineAtEndOfFile"> + <property name="lineSeparator" value="lf"/> + </module> + + <!-- Checks for whitespace (tree walker) --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <!-- No tabs allowed! --> + <module name="FileTabCharacter"/> + + <module name="TreeWalker"> + <property name="cacheFile" value="target/checkstyle-cachefile"/> + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <!-- No empty blocks (i.e. catch); must contain at least a comment --> + <module name="EmptyBlock"> + <property name="option" value="text"/> + </module> + <module name="AvoidNestedBlocks"> + <property name="allowInSwitchCase" value="true"/> + </module> + <module name="LeftCurly"/> + <!-- No if/else/do/for/while without braces --> + <module name="NeedBraces"/> + <module name="RightCurly"/> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <!-- Utility class should not be instantiated, they must have a + private constructor --> + <module name="HideUtilityClassConstructor"/> + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <module name="EmptyStatement"/> + <!-- Require hash code override when equals is --> + <module name="EqualsHashCode"/> + <!-- Disallow unnecessary instantiation of Boolean, String --> + <module name="IllegalInstantiation"> + <property name="classes" value="java.lang.Boolean, java.lang.String"/> + </module> + <!-- Switch statements should be complete and with independent cases --> + <module name="FallThrough"/> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> + <!-- Only one statement per line allowed --> + <module name="OneStatementPerLine"/> + <!-- Don't add up parentheses when they are not required --> + <module name="UnnecessaryParentheses" /> + <!-- Don't use = or != for string comparisons --> + <module name="StringLiteralEquality" /> + <!-- Don't declare multiple variables in the same statement --> + <module name="MultipleVariableDeclarations" /> + <!-- String literals more than one character long should not be + repeated several times --> + <!-- the "unchecked" string is also accepted to allow + @SuppressWarnings("unchecked") --> + <!-- Disabling for now until we have a better ignoreStringsRegexp --> + <!-- + <module name="MultipleStringLiterals" > + <property name="ignoreStringsRegexp" value='^(("")|(".")|("unchecked"))$'/> + </module> + --> + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="RedundantImport"/> + <!-- Import should be explicit, and only from pure java packages. + But we allow imports that are only used in javadoc. --> + <module name="UnusedImports"> + <property name="processJavadoc" value="true"/> + </module> + <module name="IllegalImport" /> + <module name="AvoidStarImport" /> + <module name="ImportOrder"> + <property name="groups" value="org.apache.calcite,org.apache,au.com.,com.,io.,mondrian.,net.,org.,scala.,/^javax?\./"/> + <property name="ordered" value="true"/> + <property name="separated" value="true"/> + <property name="option" value="bottom"/> + </module> + + <!-- Checks for Javadoc comments (tree walker). --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <!-- Javadoc must be formatted correctly --> + <module name="JavadocStyle"> + <property name="checkFirstSentence" value="false"/> + </module> + <!-- Must have class / interface header comments --> + <module name="JavadocType"/> + + <!-- Miscellaneous other checks (tree walker). --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <!-- Java style arrays --> + <module name="ArrayTypeStyle"/> + <!-- Indentation --> + <module name="Indentation"> + <property name="caseIndent" value="0"/> + <property name="basicOffset" value="2"/> + <property name="braceAdjustment" value="0"/> + </module> + <!-- Turn this on to see what needs to be done + <module name="TodoComment"/> + --> + <module name="UpperEll"/> + + <module name="OperatorWrap"/> + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <!-- Use a consistent way to put modifiers --> + <module name="ModifierOrder"/> + <module name="RedundantModifier"/> + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <!-- Constant names should obey the traditional all uppercase + naming convention --> + <module name="ConstantName"/> + <module name="LocalFinalVariableName"> + <!-- Allow '_' except first. --> + <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> + </module> + <module name="LocalVariableName"> + <!-- Allow '_' except first. --> + <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> + </module> + <module name="MemberName"/> + <module name="MethodName"> + <!-- Allow trailing '_', signifying private methods. + Also allow '_' prefix, indicating disabled method or junit test. --> + <property name="format" value="^_?[a-z][a-zA-Z0-9]*_?$"/> + </module> + <module name="PackageName"/> + <module name="ParameterName"> + <!-- Allow trailing '_'. --> + <property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/> + </module> + <module name="StaticVariableName"/> + <module name="TypeName"/> + + <!-- Checks for regexp expressions. --> + <!-- See http://checkstyle.sf.net/config_regexp.html --> + + <!-- No trailing whitespace --> + <module name="Regexp"> + <property name="format" value="[ \t]+$"/> + <property name="illegalPattern" value="true"/> + <property name="message" value="Trailing whitespace"/> + </module> + + <!-- Authors should be in pom.xml file --> + <module name="Regexp"> + <property name="format" value="@author"/> + <property name="illegalPattern" value="true"/> + <property name="message" value="developers names should be in pom file"/> + </module> + + <!-- No multi-line C-style comments except at start of line. --> + <module name="Regexp"> + <property name="format" value="^ +/\*[^*][^/]$"/> + <property name="illegalPattern" value="true"/> + <property name="message" value="C-style comment"/> + </module> + + <module name="Regexp"> + <property name="format" value="^ +/\*$"/> + <property name="illegalPattern" value="true"/> + <property name="message" value="C-style comment"/> + </module> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <!-- Lines cannot exceed 80 chars, except if they are hyperlinks + or strings (possibly preceded by '+' and followed by say '),'. --> + <module name="LineLength"> + <property name="max" value="100"/> + <property name="ignorePattern" value="^import|@see|@link|@BaseMessage|href|^[ +]*".*"[);,]*$"/> + </module> + <!-- Over time, we will revise this down --> + <module name="MethodLength"> + <property name="max" value="390"/> + </module> + + <!-- Checks for whitespace (tree walker) --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="EmptyForIteratorPad"/> + <!-- Spacing around methods --> + <module name="MethodParamPad"> + <property name="option" value="nospace"/> + <property name="allowLineBreaks" value="true"/> + </module> + <!-- No whitespace before a token --> + <module name="NoWhitespaceBefore"/> + <!-- Whitespace after tokens is required --> + <module name="WhitespaceAfter"/> + <!-- Whitespace around tokens is required --> + <module name="WhitespaceAround"> + <property name="allowEmptyConstructors" value="true"/> + <property name="allowEmptyMethods" value="true"/> + </module> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <!-- No extra whitespace around types --> + <module name="GenericWhitespace"/> + + <!-- Required for SuppressionCommentFilter below --> + <module name="FileContentsHolder"/> + </module> + + <!-- Setup special comments to suppress specific checks from source files --> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE\: stop ([\w\|]+)"/> + <property name="onCommentFormat" value="CHECKSTYLE\: resume ([\w\|]+)"/> + <property name="checkFormat" value="$1"/> + </module> + + <!-- Turn off all checks between OFF and ON --> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE\: OFF"/> + <property name="onCommentFormat" value="CHECKSTYLE\: ON"/> + </module> + + <!-- Turn off checks for the next N lines. --> + <module name="SuppressWithNearbyCommentFilter"> + <property name="commentFormat" value="CHECKSTYLE: +IGNORE (\d+)"/> + <property name="influenceFormat" value="$1"/> + </module> + + <module name="net.hydromatic.toolbox.checkstyle.HydromaticFileSetCheck"/> +</module> http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/config/checkstyle/header.txt ---------------------------------------------------------------------- diff --git a/avatica/src/main/config/checkstyle/header.txt b/avatica/src/main/config/checkstyle/header.txt new file mode 100644 index 0000000..2a42971 --- /dev/null +++ b/avatica/src/main/config/checkstyle/header.txt @@ -0,0 +1,16 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/config/checkstyle/suppressions.xml ---------------------------------------------------------------------- diff --git a/avatica/src/main/config/checkstyle/suppressions.xml b/avatica/src/main/config/checkstyle/suppressions.xml new file mode 100644 index 0000000..d9ae88a --- /dev/null +++ b/avatica/src/main/config/checkstyle/suppressions.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!DOCTYPE suppressions PUBLIC + "-//Puppy Crawl//DTD Suppressions 1.1//EN" + "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<suppressions> + <!-- Suppress checks on generated files. --> + <suppress checks="Header" files="CalciteResource.properties"/> + <suppress checks=".*" files="org-apache-calcite-jdbc.properties"/> + <suppress checks=".*" files="Foo.java"/> + <suppress checks=".*" files=".*[/\\]target[/\\]maven-archiver[/\\]pom.properties"/> + <suppress checks=".*" files="git.properties"/> + <suppress checks=".*" files="trace.properties"/> + <suppress checks=".*" files="release.properties"/> + <suppress checks=".*" files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]calcite[/\\]avatica[/\\]proto"/> + <suppress checks=".*" files="log4j.properties"/> + + <!-- This file triggers https://github.com/checkstyle/checkstyle/issues/92, + through no fault of its own. --> + <suppress checks=".*" files="SqlSimpleParser.java"/> + + <!-- Don't complain about field names such as cust_id --> + <suppress checks=".*Name" files="JdbcExample.java"/> + + <!-- Suppress JavadocPackage in the test packages --> + <suppress checks="JavadocPackage" files="src[/\\]test[/\\]java[/\\]"/> + + <!-- And likewise in ubenchmark --> + <suppress checks="JavadocPackage" files="StatementTest.java"/> + + <!-- Method names in Resource can have underscores --> + <suppress checks="MethodName" files="CalciteResource.java"/> +</suppressions> http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/java/com/google/protobuf/HBaseZeroCopyByteString.java ---------------------------------------------------------------------- diff --git a/avatica/src/main/java/com/google/protobuf/HBaseZeroCopyByteString.java b/avatica/src/main/java/com/google/protobuf/HBaseZeroCopyByteString.java deleted file mode 100644 index 62c4dd2..0000000 --- a/avatica/src/main/java/com/google/protobuf/HBaseZeroCopyByteString.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.protobuf; - -/** - * Helper class to extract byte arrays from {@link ByteString} without copy. - * - * Without this protobufs would force us to copy every single byte array out - * of the objects de-serialized from the wire (which already do one copy, on - * top of the copies the JVM does to go from kernel buffer to C buffer and - * from C buffer to JVM buffer). - * - * Graciously copied from Apache HBase. - */ -public final class HBaseZeroCopyByteString extends LiteralByteString { - // Gotten from AsyncHBase code base with permission. - /** Private constructor so this class cannot be instantiated. */ - private HBaseZeroCopyByteString() { - super(null); - throw new UnsupportedOperationException("Should never be here."); - } - - /** - * Wraps a byte array in a {@link ByteString} without copying it. - * - * @param array The byte array to wrap - * @return a ByteString wrapping the <code>array</code> - */ - public static ByteString wrap(final byte[] array) { - return new LiteralByteString(array); - } - - /** - * Wraps a subset of a byte array in a {@link ByteString} without copying it. - * - * @param array The byte array to wrap - * @param offset the start of data in the array - * @param length The number of bytes of data at <code>offset</code> - * @return a ByteString wrapping the <code>array</code> - */ - public static ByteString wrap(final byte[] array, int offset, int length) { - return new BoundedByteString(array, offset, length); - } - - - /** - * Extracts the byte array from the given {@link ByteString} without copy. - * @param buf A buffer from which to extract the array. This buffer must be - * actually an instance of a {@code LiteralByteString}. - * - * @param buf <code>ByteString</code> to access - * @return The underlying byte array of the ByteString - */ - public static byte[] zeroCopyGetBytes(final ByteString buf) { - if (buf instanceof LiteralByteString) { - return ((LiteralByteString) buf).bytes; - } - throw new UnsupportedOperationException("Need a LiteralByteString, got a " - + buf.getClass().getName()); - } -} - -// End HBaseZeroCopyByteString.java http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/java/com/google/protobuf/package-info.java ---------------------------------------------------------------------- diff --git a/avatica/src/main/java/com/google/protobuf/package-info.java b/avatica/src/main/java/com/google/protobuf/package-info.java deleted file mode 100644 index 92f110e..0000000 --- a/avatica/src/main/java/com/google/protobuf/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Avatica-custom classes to access protected classes in Google Protobuf. - */ -@PackageMarker -package com.google.protobuf; - -import org.apache.calcite.avatica.util.PackageMarker; - -// End package-info.java http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/java/org/apache/calcite/avatica/AvaticaClientRuntimeException.java ---------------------------------------------------------------------- diff --git a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaClientRuntimeException.java b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaClientRuntimeException.java deleted file mode 100644 index df03b03..0000000 --- a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaClientRuntimeException.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.calcite.avatica; - -import org.apache.calcite.avatica.remote.AvaticaRuntimeException; -import org.apache.calcite.avatica.remote.Service.ErrorResponse; -import org.apache.calcite.avatica.remote.Service.RpcMetadataResponse; - -import java.util.Collections; -import java.util.List; - -/** - * The client-side representation of {@link AvaticaRuntimeException}. This exception is not intended - * for consumption by clients, {@link AvaticaSqlException} serves that purpose. This exception only - * exists to pass the original error attributes to a higher level of execution without modifying - * existing exception-handling logic. - */ -public class AvaticaClientRuntimeException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - private final int errorCode; - private final String sqlState; - private final AvaticaSeverity severity; - private final List<String> serverExceptions; - private final RpcMetadataResponse metadata; - - public AvaticaClientRuntimeException(String errorMessage, int errorCode, String sqlState, - AvaticaSeverity severity, List<String> serverExceptions, RpcMetadataResponse metadata) { - super(errorMessage); - this.errorCode = errorCode; - this.sqlState = sqlState; - this.severity = severity; - this.serverExceptions = serverExceptions; - this.metadata = metadata; - } - - public AvaticaClientRuntimeException(String message, Throwable cause) { - super(message, cause); - errorCode = ErrorResponse.UNKNOWN_ERROR_CODE; - sqlState = ErrorResponse.UNKNOWN_SQL_STATE; - severity = AvaticaSeverity.UNKNOWN; - serverExceptions = Collections.singletonList(""); - metadata = null; - } - - public int getErrorCode() { - return errorCode; - } - - public String getSqlState() { - return sqlState; - } - - public AvaticaSeverity getSeverity() { - return severity; - } - - public List<String> getServerExceptions() { - return serverExceptions; - } - - public RpcMetadataResponse getRpcMetadata() { - return metadata; - } - - @Override public String toString() { - StringBuilder sb = new StringBuilder(64); - sb.append(getClass().getSimpleName()).append(": ") - .append(getMessage()).append(". Error ").append(getErrorCode()) - .append(" (").append(sqlState).append(") ").append(getSeverity()).append("\n\n"); - for (String serverException : getServerExceptions()) { - sb.append(serverException).append("\n"); - } - return sb.toString(); - } - -} - -// End AvaticaClientRuntimeException.java http://git-wip-us.apache.org/repos/asf/calcite/blob/5cee486f/avatica/src/main/java/org/apache/calcite/avatica/AvaticaConnection.java ---------------------------------------------------------------------- diff --git a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaConnection.java b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaConnection.java deleted file mode 100644 index 2d89f45..0000000 --- a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaConnection.java +++ /dev/null @@ -1,696 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.calcite.avatica; - -import org.apache.calcite.avatica.Meta.MetaResultSet; -import org.apache.calcite.avatica.remote.Service.ErrorResponse; -import org.apache.calcite.avatica.remote.Service.OpenConnectionRequest; -import org.apache.calcite.avatica.remote.TypedValue; - -import java.sql.Array; -import java.sql.Blob; -import java.sql.CallableStatement; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Savepoint; -import java.sql.Statement; -import java.sql.Struct; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.TimeZone; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; - -/** - * Implementation of JDBC connection - * for the Avatica framework. - * - * <p>Abstract to allow newer versions of JDBC to add methods. - */ -public abstract class AvaticaConnection implements Connection { - - /** The name of the sole column returned by DML statements, containing - * the number of rows modified. */ - public static final String ROWCOUNT_COLUMN_NAME = "ROWCOUNT"; - - public static final String NUM_EXECUTE_RETRIES_KEY = "avatica.statement.retries"; - public static final String NUM_EXECUTE_RETRIES_DEFAULT = "5"; - - /** The name of the sole column returned by an EXPLAIN statement. - * - * <p>Actually Avatica does not care what this column is called, but here is - * a useful place to define a suggested value. */ - public static final String PLAN_COLUMN_NAME = "PLAN"; - - protected int statementCount; - private boolean closed; - private int holdability; - private int networkTimeout; - - public final String id; - public final Meta.ConnectionHandle handle; - protected final UnregisteredDriver driver; - protected final AvaticaFactory factory; - final String url; - protected final Properties info; - protected final Meta meta; - protected final AvaticaDatabaseMetaData metaData; - public final Helper helper = Helper.INSTANCE; - public final Map<InternalProperty, Object> properties = new HashMap<>(); - public final Map<Integer, AvaticaStatement> statementMap = - new ConcurrentHashMap<>(); - protected final long maxRetriesPerExecute; - - /** - * Creates an AvaticaConnection. - * - * <p>Not public; method is called only from the driver or a derived - * class.</p> - * - * @param driver Driver - * @param factory Factory for JDBC objects - * @param url Server URL - * @param info Other connection properties - */ - protected AvaticaConnection(UnregisteredDriver driver, - AvaticaFactory factory, - String url, - Properties info) { - this.id = UUID.randomUUID().toString(); - this.handle = new Meta.ConnectionHandle(this.id); - this.driver = driver; - this.factory = factory; - this.url = url; - this.info = info; - this.meta = driver.createMeta(this); - this.metaData = factory.newDatabaseMetaData(this); - this.holdability = metaData.getResultSetHoldability(); - this.maxRetriesPerExecute = getNumStatementRetries(info); - } - - /** Computes the number of retries - * {@link AvaticaStatement#executeInternal(Meta.Signature, boolean)} - * should retry before failing. */ - long getNumStatementRetries(Properties props) { - return Long.valueOf(Objects.requireNonNull(props) - .getProperty(NUM_EXECUTE_RETRIES_KEY, NUM_EXECUTE_RETRIES_DEFAULT)); - } - - /** Returns a view onto this connection's configuration properties. Code - * in Avatica and derived projects should use this view rather than calling - * {@link java.util.Properties#getProperty(String)}. Derived projects will - * almost certainly subclass {@link ConnectionConfig} with their own - * properties. */ - public ConnectionConfig config() { - return new ConnectionConfigImpl(info); - } - - /** - * Opens the connection on the server. - */ - public void openConnection() { - // Open the connection on the server - this.meta.openConnection(handle, OpenConnectionRequest.serializeProperties(info)); - } - - // Connection methods - - public AvaticaStatement createStatement() throws SQLException { - //noinspection MagicConstant - return createStatement(ResultSet.TYPE_FORWARD_ONLY, - ResultSet.CONCUR_READ_ONLY, - holdability); - } - - public PreparedStatement prepareStatement(String sql) throws SQLException { - //noinspection MagicConstant - return prepareStatement( - sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, - holdability); - } - - public CallableStatement prepareCall(String sql) throws SQLException { - throw helper.unsupported(); - } - - public String nativeSQL(String sql) throws SQLException { - throw helper.unsupported(); - } - - public void setAutoCommit(boolean autoCommit) throws SQLException { - meta.connectionSync(handle, new ConnectionPropertiesImpl().setAutoCommit(autoCommit)); - } - - public boolean getAutoCommit() throws SQLException { - return unbox(sync().isAutoCommit(), true); - } - - public void commit() throws SQLException { - meta.commit(handle); - } - - public void rollback() throws SQLException { - meta.rollback(handle); - } - - public void close() throws SQLException { - if (!closed) { - closed = true; - - // Per specification, if onConnectionClose throws, this method will throw - // a SQLException, but statement will still be closed. - try { - meta.closeConnection(handle); - driver.handler.onConnectionClose(this); - } catch (RuntimeException e) { - throw helper.createException("While closing connection", e); - } - } - } - - public boolean isClosed() throws SQLException { - return closed; - } - - public DatabaseMetaData getMetaData() throws SQLException { - return metaData; - } - - public void setReadOnly(boolean readOnly) throws SQLException { - meta.connectionSync(handle, new ConnectionPropertiesImpl().setReadOnly(readOnly)); - } - - public boolean isReadOnly() throws SQLException { - return unbox(sync().isReadOnly(), true); - } - - public void setCatalog(String catalog) throws SQLException { - meta.connectionSync(handle, new ConnectionPropertiesImpl().setCatalog(catalog)); - } - - public String getCatalog() { - return sync().getCatalog(); - } - - public void setTransactionIsolation(int level) throws SQLException { - meta.connectionSync(handle, new ConnectionPropertiesImpl().setTransactionIsolation(level)); - } - - public int getTransactionIsolation() throws SQLException { - //noinspection MagicConstant - return unbox(sync().getTransactionIsolation(), TRANSACTION_NONE); - } - - public SQLWarning getWarnings() throws SQLException { - return null; - } - - public void clearWarnings() throws SQLException { - // no-op since connection pooling often calls this. - } - - public Statement createStatement( - int resultSetType, int resultSetConcurrency) throws SQLException { - //noinspection MagicConstant - return createStatement(resultSetType, resultSetConcurrency, holdability); - } - - public PreparedStatement prepareStatement( - String sql, - int resultSetType, - int resultSetConcurrency) throws SQLException { - //noinspection MagicConstant - return prepareStatement( - sql, resultSetType, resultSetConcurrency, holdability); - } - - public CallableStatement prepareCall( - String sql, - int resultSetType, - int resultSetConcurrency) throws SQLException { - throw helper.unsupported(); - } - - public Map<String, Class<?>> getTypeMap() throws SQLException { - throw helper.unsupported(); - } - - public void setTypeMap(Map<String, Class<?>> map) throws SQLException { - throw helper.unsupported(); - } - - public void setHoldability(int holdability) throws SQLException { - if (!(holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT - || holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT)) { - throw new SQLException("invalid value"); - } - this.holdability = holdability; - } - - public int getHoldability() throws SQLException { - return holdability; - } - - public Savepoint setSavepoint() throws SQLException { - throw helper.unsupported(); - } - - public Savepoint setSavepoint(String name) throws SQLException { - throw helper.unsupported(); - } - - public void rollback(Savepoint savepoint) throws SQLException { - throw helper.unsupported(); - } - - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - throw helper.unsupported(); - } - - public AvaticaStatement createStatement( - int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return factory.newStatement(this, null, resultSetType, resultSetConcurrency, - resultSetHoldability); - } - - public PreparedStatement prepareStatement( - String sql, - int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - try { - final Meta.StatementHandle h = meta.prepare(handle, sql, -1); - return factory.newPreparedStatement(this, h, h.signature, resultSetType, - resultSetConcurrency, resultSetHoldability); - } catch (RuntimeException e) { - throw helper.createException("while preparing SQL: " + sql, e); - } - } - - public CallableStatement prepareCall( - String sql, - int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - throw helper.unsupported(); - } - - public PreparedStatement prepareStatement( - String sql, int autoGeneratedKeys) throws SQLException { - throw helper.unsupported(); - } - - public PreparedStatement prepareStatement( - String sql, int[] columnIndexes) throws SQLException { - throw helper.unsupported(); - } - - public PreparedStatement prepareStatement( - String sql, String[] columnNames) throws SQLException { - throw helper.unsupported(); - } - - public Clob createClob() throws SQLException { - throw helper.unsupported(); - } - - public Blob createBlob() throws SQLException { - throw helper.unsupported(); - } - - public NClob createNClob() throws SQLException { - throw helper.unsupported(); - } - - public SQLXML createSQLXML() throws SQLException { - throw helper.unsupported(); - } - - public boolean isValid(int timeout) throws SQLException { - throw helper.unsupported(); - } - - public void setClientInfo(String name, String value) - throws SQLClientInfoException { - throw helper.clientInfo(); - } - - public void setClientInfo(Properties properties) - throws SQLClientInfoException { - throw helper.clientInfo(); - } - - public String getClientInfo(String name) throws SQLException { - throw helper.unsupported(); - } - - public Properties getClientInfo() throws SQLException { - throw helper.unsupported(); - } - - public Array createArrayOf(String typeName, Object[] elements) - throws SQLException { - throw helper.unsupported(); - } - - public Struct createStruct(String typeName, Object[] attributes) - throws SQLException { - throw helper.unsupported(); - } - - public void setSchema(String schema) throws SQLException { - meta.connectionSync(handle, new ConnectionPropertiesImpl().setSchema(schema)); - } - - public String getSchema() { - return sync().getSchema(); - } - - public void abort(Executor executor) throws SQLException { - throw helper.unsupported(); - } - - public void setNetworkTimeout( - Executor executor, int milliseconds) throws SQLException { - this.networkTimeout = milliseconds; - } - - public int getNetworkTimeout() throws SQLException { - return networkTimeout; - } - - public <T> T unwrap(Class<T> iface) throws SQLException { - if (iface.isInstance(this)) { - return iface.cast(this); - } - throw helper.createException( - "does not implement '" + iface + "'"); - } - - public boolean isWrapperFor(Class<?> iface) throws SQLException { - return iface.isInstance(this); - } - - /** Returns the time zone of this connection. Determines the offset applied - * when converting datetime values from the database into - * {@link java.sql.Timestamp} values. */ - public TimeZone getTimeZone() { - final String timeZoneName = config().timeZone(); - return timeZoneName == null - ? TimeZone.getDefault() - : TimeZone.getTimeZone(timeZoneName); - } - - /** - * Executes a prepared query, closing any previously open result set. - * - * @param statement Statement - * @param signature Prepared query - * @param firstFrame First frame of rows, or null if we need to execute - * @param state The state used to create the given result - * @param isUpdate Was the caller context via {@link PreparedStatement#executeUpdate()}. - * @return Result set - * @throws java.sql.SQLException if a database error occurs - */ - protected ResultSet executeQueryInternal(AvaticaStatement statement, - Meta.Signature signature, Meta.Frame firstFrame, QueryState state, boolean isUpdate) - throws SQLException { - // Close the previous open result set, if there is one. - Meta.Frame frame = firstFrame; - Meta.Signature signature2 = signature; - - synchronized (statement) { - if (statement.openResultSet != null) { - final AvaticaResultSet rs = statement.openResultSet; - statement.openResultSet = null; - try { - rs.close(); - } catch (Exception e) { - throw helper.createException( - "Error while closing previous result set", e); - } - } - - try { - if (statement.isWrapperFor(AvaticaPreparedStatement.class)) { - final AvaticaPreparedStatement pstmt = (AvaticaPreparedStatement) statement; - Meta.StatementHandle handle = pstmt.handle; - if (isUpdate) { - // Make a copy of the StatementHandle, nulling out the Signature. - // CALCITE-1086 we don't need to send the Signature to the server - // when we're only performing an update. Saves on serialization. - handle = new Meta.StatementHandle(handle.connectionId, handle.id, null); - } - final Meta.ExecuteResult executeResult = - meta.execute(handle, pstmt.getParameterValues(), - statement.getFetchSize()); - final MetaResultSet metaResultSet = executeResult.resultSets.get(0); - frame = metaResultSet.firstFrame; - statement.updateCount = metaResultSet.updateCount; - signature2 = executeResult.resultSets.get(0).signature; - } - } catch (Exception e) { - e.printStackTrace(); - throw helper.createException(e.getMessage(), e); - } - - final TimeZone timeZone = getTimeZone(); - if (frame == null && signature2 == null && statement.updateCount != -1) { - statement.openResultSet = null; - } else { - // Duplicative SQL, for support non-prepared statements - statement.openResultSet = - factory.newResultSet(statement, state, signature2, timeZone, frame); - } - } - // Release the monitor before executing, to give another thread the - // opportunity to call cancel. - try { - if (statement.openResultSet != null) { - statement.openResultSet.execute(); - isUpdateCapable(statement); - } - } catch (Exception e) { - throw helper.createException( - "exception while executing query: " + e.getMessage(), e); - } - return statement.openResultSet; - } - - /** Returns whether a a statement is capable of updates and if so, - * and the statement's {@code updateCount} is still -1, proceeds to - * get updateCount value from statement's resultSet. - * - * <p>Handles "ROWCOUNT" object as Number or List - * - * @param statement Statement - * @throws SQLException on error - */ - private void isUpdateCapable(final AvaticaStatement statement) - throws SQLException { - Meta.Signature signature = statement.getSignature(); - if (signature == null || signature.statementType == null) { - return; - } - if (signature.statementType.canUpdate() && statement.updateCount == -1) { - statement.openResultSet.next(); - Object obj = statement.openResultSet.getObject(ROWCOUNT_COLUMN_NAME); - if (obj instanceof Number) { - statement.updateCount = ((Number) obj).intValue(); - } else if (obj instanceof List) { - @SuppressWarnings("unchecked") - final List<Number> numbers = (List<Number>) obj; - statement.updateCount = numbers.get(0).intValue(); - } else { - throw helper.createException("Not a valid return result."); - } - statement.openResultSet = null; - } - } - - protected Meta.ExecuteResult prepareAndExecuteInternal( - final AvaticaStatement statement, final String sql, long maxRowCount) - throws SQLException, NoSuchStatementException { - final Meta.PrepareCallback callback = - new Meta.PrepareCallback() { - public Object getMonitor() { - return statement; - } - - public void clear() throws SQLException { - if (statement.openResultSet != null) { - final AvaticaResultSet rs = statement.openResultSet; - statement.openResultSet = null; - try { - rs.close(); - } catch (Exception e) { - throw helper.createException( - "Error while closing previous result set", e); - } - } - } - - public void assign(Meta.Signature signature, Meta.Frame firstFrame, - long updateCount) throws SQLException { - statement.setSignature(signature); - - if (updateCount != -1) { - statement.updateCount = updateCount; - } else { - final TimeZone timeZone = getTimeZone(); - statement.openResultSet = factory.newResultSet(statement, new QueryState(sql), - signature, timeZone, firstFrame); - } - } - - public void execute() throws SQLException { - if (statement.openResultSet != null) { - statement.openResultSet.execute(); - isUpdateCapable(statement); - } - } - }; - return meta.prepareAndExecute(statement.handle, sql, maxRowCount, callback); - } - - protected ResultSet createResultSet(Meta.MetaResultSet metaResultSet, QueryState state) - throws SQLException { - final Meta.StatementHandle h = new Meta.StatementHandle( - metaResultSet.connectionId, metaResultSet.statementId, null); - final AvaticaStatement statement = lookupStatement(h); - // These are all the metadata operations, no updates - ResultSet resultSet = executeQueryInternal(statement, metaResultSet.signature.sanitize(), - metaResultSet.firstFrame, state, false); - if (metaResultSet.ownStatement) { - resultSet.getStatement().closeOnCompletion(); - } - return resultSet; - } - - /** Creates a statement wrapper around an existing handle. */ - protected AvaticaStatement lookupStatement(Meta.StatementHandle h) - throws SQLException { - final AvaticaStatement statement = statementMap.get(h.id); - if (statement != null) { - return statement; - } - //noinspection MagicConstant - return factory.newStatement(this, Objects.requireNonNull(h), - ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, holdability); - } - - // do not make public - protected static Trojan createTrojan() { - return new Trojan(); - } - - /** Converts a {@link Boolean} to a {@code boolean}, with a default value. */ - private boolean unbox(Boolean b, boolean defaultValue) { - return b == null ? defaultValue : b; - } - - /** Converts an {@link Integer} to an {@code int}, with a default value. */ - private int unbox(Integer i, int defaultValue) { - return i == null ? defaultValue : i; - } - - private Meta.ConnectionProperties sync() { - return meta.connectionSync(handle, new ConnectionPropertiesImpl()); - } - - /** A way to call package-protected methods. But only a sub-class of - * connection can create one. */ - public static class Trojan { - // must be private - private Trojan() { - } - - /** A means for anyone who has a trojan to call the protected method - * {@link org.apache.calcite.avatica.AvaticaResultSet#execute()}. - * @throws SQLException if execute fails for some reason. */ - public ResultSet execute(AvaticaResultSet resultSet) throws SQLException { - return resultSet.execute(); - } - - /** A means for anyone who has a trojan to call the protected method - * {@link org.apache.calcite.avatica.AvaticaStatement#getParameterValues()}. - */ - public List<TypedValue> getParameterValues(AvaticaStatement statement) { - return statement.getParameterValues(); - } - - /** A means for anyone who has a trojan to get the protected field - * {@link org.apache.calcite.avatica.AvaticaConnection#meta}. */ - public Meta getMeta(AvaticaConnection connection) { - return connection.meta; - } - } - - /** - * A Callable-like interface but without a "throws Exception". - * - * @param <T> The return type from {@code call}. - */ - public interface CallableWithoutException<T> { - T call(); - } - - /** - * Invokes the given "callable", retrying the call when the server responds with an error - * denoting that the connection is missing on the server. - * - * @param callable The function to invoke. - * @return The value from the result of the callable. - */ - public <T> T invokeWithRetries(CallableWithoutException<T> callable) { - RuntimeException lastException = null; - for (int i = 0; i < maxRetriesPerExecute; i++) { - try { - return callable.call(); - } catch (AvaticaClientRuntimeException e) { - lastException = e; - if (ErrorResponse.MISSING_CONNECTION_ERROR_CODE == e.getErrorCode()) { - this.openConnection(); - continue; - } - throw e; - } - } - if (null != lastException) { - throw lastException; - } else { - // Shouldn't ever happen. - throw new IllegalStateException(); - } - } -} - -// End AvaticaConnection.java
