Merge branch 'master' of https://github.com/sunyinqi0508/AQuery2
commit
83ad6d2330
@ -1,72 +1,72 @@
|
||||
test.lib
|
||||
test.exp
|
||||
*.pdb
|
||||
dll.lib
|
||||
dll.exp
|
||||
libaquery.a
|
||||
libaquery.lib
|
||||
server.lib
|
||||
server.exp
|
||||
*.idb
|
||||
aq
|
||||
aq.exe
|
||||
.cached
|
||||
*.json
|
||||
!sample_ast.json
|
||||
*.o
|
||||
*.pch
|
||||
*.gch
|
||||
a.out.*
|
||||
*.log
|
||||
*.pyc
|
||||
*.tab
|
||||
out
|
||||
.idea
|
||||
.svn
|
||||
*.iml
|
||||
/mo_sql_parsing.egg-info
|
||||
/build
|
||||
/dist
|
||||
/mo-sql-parsing
|
||||
vendor/
|
||||
._*
|
||||
.DS_Store
|
||||
.eggs
|
||||
.vscode
|
||||
out.k
|
||||
k
|
||||
*.so
|
||||
*.pdf
|
||||
**/*.cmake
|
||||
**/Debug
|
||||
**/Release
|
||||
test*.c*
|
||||
*.csv
|
||||
!test.csv
|
||||
!test2.csv
|
||||
!moving_avg.csv
|
||||
!nyctx100.csv
|
||||
*.out
|
||||
*.asm
|
||||
!mmw.so
|
||||
*.k
|
||||
!header.k
|
||||
!join.k
|
||||
**/.vs
|
||||
**/x64
|
||||
*.user
|
||||
*.filters
|
||||
*.tmp
|
||||
*.bin
|
||||
*.shm
|
||||
server/packages/**
|
||||
*.ipynb
|
||||
*.cmake
|
||||
*.stackdump
|
||||
saves
|
||||
*.exe
|
||||
out*.cpp
|
||||
udf*.hpp
|
||||
*.ipynb
|
||||
|
||||
|
||||
test.lib
|
||||
test.exp
|
||||
*.pdb
|
||||
dll.lib
|
||||
dll.exp
|
||||
libaquery.a
|
||||
libaquery.lib
|
||||
server.lib
|
||||
server.exp
|
||||
*.idb
|
||||
aq
|
||||
aq.exe
|
||||
.cached
|
||||
*.json
|
||||
!sample_ast.json
|
||||
*.o
|
||||
*.pch
|
||||
*.gch
|
||||
a.out.*
|
||||
*.log
|
||||
*.pyc
|
||||
*.tab
|
||||
out
|
||||
.idea
|
||||
.svn
|
||||
*.iml
|
||||
/mo_sql_parsing.egg-info
|
||||
/build
|
||||
/dist
|
||||
/mo-sql-parsing
|
||||
vendor/
|
||||
._*
|
||||
.DS_Store
|
||||
.eggs
|
||||
.vscode
|
||||
out.k
|
||||
k
|
||||
*.so
|
||||
*.pdf
|
||||
**/*.cmake
|
||||
**/Debug
|
||||
**/Release
|
||||
test*.c*
|
||||
*.csv
|
||||
!test.csv
|
||||
!test2.csv
|
||||
!moving_avg.csv
|
||||
!nyctx100.csv
|
||||
*.out
|
||||
*.asm
|
||||
!mmw.so
|
||||
*.k
|
||||
!header.k
|
||||
!join.k
|
||||
**/.vs
|
||||
**/x64
|
||||
*.user
|
||||
*.filters
|
||||
*.tmp
|
||||
*.bin
|
||||
*.shm
|
||||
server/packages/**
|
||||
*.ipynb
|
||||
*.cmake
|
||||
*.stackdump
|
||||
saves
|
||||
*.exe
|
||||
out*.cpp
|
||||
udf*.hpp
|
||||
*.ipynb
|
||||
|
||||
|
||||
|
@ -1,363 +1,363 @@
|
||||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. "Contributor"
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the terms of
|
||||
a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
|
||||
means a work that combines Covered Software with other material, in a
|
||||
separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether
|
||||
at the time of the initial grant or subsequently, any and all of the
|
||||
rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the License,
|
||||
by the making, using, selling, offering for sale, having made, import,
|
||||
or transfer of either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, "control" means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights to
|
||||
grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter the
|
||||
recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty, or
|
||||
limitations of liability) contained within the Source Code Form of the
|
||||
Covered Software, except that You may alter any license notices to the
|
||||
extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute,
|
||||
judicial order, or regulation then You must: (a) comply with the terms of
|
||||
this License to the maximum extent possible; and (b) describe the
|
||||
limitations and the code they affect. Such description must be placed in a
|
||||
text file included with all distributions of the Covered Software under
|
||||
this License. Except to the extent prohibited by statute or regulation,
|
||||
such description must be sufficiently detailed for a recipient of ordinary
|
||||
skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing
|
||||
basis, if such Contributor fails to notify You of the non-compliance by
|
||||
some reasonable means prior to 60 days after You have come back into
|
||||
compliance. Moreover, Your grants from a particular Contributor are
|
||||
reinstated on an ongoing basis if such Contributor notifies You of the
|
||||
non-compliance by some reasonable means, this is the first time You have
|
||||
received notice of non-compliance with this License from such
|
||||
Contributor, and You become compliant prior to 30 days after Your receipt
|
||||
of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an "as is" basis,
|
||||
without warranty of any kind, either expressed, implied, or statutory,
|
||||
including, without limitation, warranties that the Covered Software is free
|
||||
of defects, merchantable, fit for a particular purpose or non-infringing.
|
||||
The entire risk as to the quality and performance of the Covered Software
|
||||
is with You. Should any Covered Software prove defective in any respect,
|
||||
You (not any Contributor) assume the cost of any necessary servicing,
|
||||
repair, or correction. This disclaimer of warranty constitutes an essential
|
||||
part of this License. No use of any Covered Software is authorized under
|
||||
this License except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from
|
||||
such party's negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
||||
incidental or consequential damages, so this exclusion and limitation may
|
||||
not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts
|
||||
of a jurisdiction where the defendant maintains its principal place of
|
||||
business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
||||
in this Section shall prevent a party's ability to bring cross-claims or
|
||||
counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides that
|
||||
the language of a contract shall be construed against the drafter shall not
|
||||
be used to construe this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses If You choose to distribute Source Code Form that is
|
||||
Incompatible With Secondary Licenses under the terms of this version of
|
||||
the License, the notice described in Exhibit B of this License must be
|
||||
attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file,
|
||||
then You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a
|
||||
notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
|
||||
This Source Code Form is "Incompatible
|
||||
With Secondary Licenses", as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
||||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. "Contributor"
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the terms of
|
||||
a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
|
||||
means a work that combines Covered Software with other material, in a
|
||||
separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether
|
||||
at the time of the initial grant or subsequently, any and all of the
|
||||
rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the License,
|
||||
by the making, using, selling, offering for sale, having made, import,
|
||||
or transfer of either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, "control" means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights to
|
||||
grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter the
|
||||
recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty, or
|
||||
limitations of liability) contained within the Source Code Form of the
|
||||
Covered Software, except that You may alter any license notices to the
|
||||
extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute,
|
||||
judicial order, or regulation then You must: (a) comply with the terms of
|
||||
this License to the maximum extent possible; and (b) describe the
|
||||
limitations and the code they affect. Such description must be placed in a
|
||||
text file included with all distributions of the Covered Software under
|
||||
this License. Except to the extent prohibited by statute or regulation,
|
||||
such description must be sufficiently detailed for a recipient of ordinary
|
||||
skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing
|
||||
basis, if such Contributor fails to notify You of the non-compliance by
|
||||
some reasonable means prior to 60 days after You have come back into
|
||||
compliance. Moreover, Your grants from a particular Contributor are
|
||||
reinstated on an ongoing basis if such Contributor notifies You of the
|
||||
non-compliance by some reasonable means, this is the first time You have
|
||||
received notice of non-compliance with this License from such
|
||||
Contributor, and You become compliant prior to 30 days after Your receipt
|
||||
of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an "as is" basis,
|
||||
without warranty of any kind, either expressed, implied, or statutory,
|
||||
including, without limitation, warranties that the Covered Software is free
|
||||
of defects, merchantable, fit for a particular purpose or non-infringing.
|
||||
The entire risk as to the quality and performance of the Covered Software
|
||||
is with You. Should any Covered Software prove defective in any respect,
|
||||
You (not any Contributor) assume the cost of any necessary servicing,
|
||||
repair, or correction. This disclaimer of warranty constitutes an essential
|
||||
part of this License. No use of any Covered Software is authorized under
|
||||
this License except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from
|
||||
such party's negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
||||
incidental or consequential damages, so this exclusion and limitation may
|
||||
not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts
|
||||
of a jurisdiction where the defendant maintains its principal place of
|
||||
business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
||||
in this Section shall prevent a party's ability to bring cross-claims or
|
||||
counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides that
|
||||
the language of a contract shall be construed against the drafter shall not
|
||||
be used to construe this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses If You choose to distribute Source Code Form that is
|
||||
Incompatible With Secondary Licenses under the terms of this version of
|
||||
the License, the notice described in Exhibit B of this License must be
|
||||
attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file,
|
||||
then You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a
|
||||
notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
|
||||
This Source Code Form is "Incompatible
|
||||
With Secondary Licenses", as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
||||
|
@ -1,83 +1,83 @@
|
||||
|
||||
# AQuery++ Database
|
||||
## Introduction
|
||||
|
||||
AQuery++ Database is a cross-platform, In-Memory Column-Store Database that incorporates compiled query execution.
|
||||
|
||||
## Architecture
|
||||
![Architecture](./docs/arch-hybrid.svg)
|
||||
|
||||
### AQuery Compiler
|
||||
- The query is first processed by the AQuery Compiler which is composed of a frontend that parses the query into AST and a backend that generates target code that delivers the query.
|
||||
- Front end of AQuery++ Compiler is built on top of [mo-sql-parsing](https://github.com/klahnakoski/mo-sql-parsing) with modifications to handle AQuery dialect and extension.
|
||||
- Backend of AQuery++ Compiler generates target code dependent on the Execution Engine. It can either be the C++ code for AQuery Execution Engine or sql and C++ post-processor for Hybrid Engine or k9 for the k9 Engine.
|
||||
### Execution Engines
|
||||
- AQuery++ supports different execution engines thanks to the decoupled compiler structure.
|
||||
- AQuery Execution Engine: executes query by compiling the query plan to C++ code. Doesn't support joins and udf functions.
|
||||
- Hybrid Execution Engine: decouples the query into two parts. The sql-compliant part is executed by an Embedded version of Monetdb and everything else is executed by a post-process module which is generated by AQuery++ Compiler in C++ and then compiled and executed.
|
||||
- K9 Execution Engine: (discontinued).
|
||||
|
||||
## Roadmap
|
||||
- [x] SQL Parser -> AQuery Parser (Front End)
|
||||
- [x] AQuery-C++ Compiler (Back End)
|
||||
- [x] Schema and Data Model
|
||||
- [x] Data acquisition/output from/to csv file
|
||||
- [ ] Execution Engine
|
||||
- [x] Projections and single-group Aggregations
|
||||
- [x] Group by Aggregations
|
||||
- [x] Filters
|
||||
- [x] Order by
|
||||
- [x] Assumption
|
||||
- [x] Flatten
|
||||
- [x] UDFs (Hybrid Engine only)
|
||||
- [x] User Module
|
||||
- [ ] Triggers
|
||||
- [x] Join (Hybrid Engine only)
|
||||
- [ ] Subqueries
|
||||
- [x] Query Optimization
|
||||
- [x] Selection/Order by push-down
|
||||
- [x] Join Optimization (Only in Hybrid Engine)
|
||||
|
||||
## TODO:
|
||||
|
||||
- [x] User Module load syntax parsing (fn definition/registration)
|
||||
- [x] User Module initialize location
|
||||
-> User Module test
|
||||
-> Interval based triggers
|
||||
-> Optimize Compilation Process, using static libraries, hot reloading server binary
|
||||
- [x] Bug fixes: type deduction misaligned in Hybrid Engine
|
||||
-> Investigation: Using postproc only for q1 in Hybrid Engine (make is_special always on)
|
||||
- [x] Limitation: putting ColRefs back to monetdb.
|
||||
- [ ] Limitation: String operations and Date/Time data type.
|
||||
- [ ] C++ Meta-Programming: Eliminate template recursions as much as possible.
|
||||
- [ ] Limitation: Date and Time, String operations, Funcs in groupby agg.
|
||||
|
||||
# Installation
|
||||
## Requirements
|
||||
1. Recent version of Linux, Windows or MacOS, with recent C++ compiler that has C++17 (1z) support. (however c++20 is recommended if available for heterogeneous lookup on unordered containers)
|
||||
- GCC: 9.0 or above (g++ 7.x, 8.x fail to handle fold-expressions due to a compiler bug)
|
||||
- Clang: 5.0 or above (Recommended)
|
||||
- MSVC: 2017 or later (2022 or above is recommended)
|
||||
|
||||
2. Monetdb for Hybrid Engine
|
||||
- On windows, the required libraries and headers are already included in the repo.
|
||||
- On Linux, see [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) for instructions.
|
||||
- On MacOS, Monetdb can be easily installed in homebrew `brew install monetdb`.
|
||||
|
||||
3. Python 3.6 or above and install required packages in requirements.txt by `python3 -m pip install -r requirements.txt`
|
||||
## Usage
|
||||
`python3 prompt.py` will launch the interactive command prompt. The server binary will be autometically rebuilt and started.
|
||||
#### Commands:
|
||||
- `<sql statement>`: parse sql statement
|
||||
- `f <filename>`: parse all sql statements in file
|
||||
- `dbg` start debugging session
|
||||
- `print`: printout parsed sql statements
|
||||
- `exec`: execute last parsed statement(s) with AQuery Execution Engine. AQuery Execution Engine executes query by compiling it to C++ code and then executing it.
|
||||
|
||||
- `xexec`: execute last parsed statement(s) with Hybrid Execution Engine. Hybrid Execution Engine decouples the query into two parts. The sql-compliant part is executed by an Embedded version of Monetdb and everything else is executed by a post-process module which is generated by AQuery++ Compiler in C++ and then compiled and executed.
|
||||
- `r`: run the last generated code snippet
|
||||
- `save <OPTIONAL: filename>`: save current code snippet. will use random filename if not specified.
|
||||
- `exit`: quit the prompt
|
||||
#### Example:
|
||||
`f moving_avg.a` <br>
|
||||
`xexec`
|
||||
|
||||
# AQuery++ Database
|
||||
## Introduction
|
||||
|
||||
AQuery++ Database is a cross-platform, In-Memory Column-Store Database that incorporates compiled query execution.
|
||||
|
||||
## Architecture
|
||||
![Architecture](./docs/arch-hybrid.svg)
|
||||
|
||||
### AQuery Compiler
|
||||
- The query is first processed by the AQuery Compiler which is composed of a frontend that parses the query into AST and a backend that generates target code that delivers the query.
|
||||
- Front end of AQuery++ Compiler is built on top of [mo-sql-parsing](https://github.com/klahnakoski/mo-sql-parsing) with modifications to handle AQuery dialect and extension.
|
||||
- Backend of AQuery++ Compiler generates target code dependent on the Execution Engine. It can either be the C++ code for AQuery Execution Engine or sql and C++ post-processor for Hybrid Engine or k9 for the k9 Engine.
|
||||
### Execution Engines
|
||||
- AQuery++ supports different execution engines thanks to the decoupled compiler structure.
|
||||
- AQuery Execution Engine: executes query by compiling the query plan to C++ code. Doesn't support joins and udf functions.
|
||||
- Hybrid Execution Engine: decouples the query into two parts. The sql-compliant part is executed by an Embedded version of Monetdb and everything else is executed by a post-process module which is generated by AQuery++ Compiler in C++ and then compiled and executed.
|
||||
- K9 Execution Engine: (discontinued).
|
||||
|
||||
## Roadmap
|
||||
- [x] SQL Parser -> AQuery Parser (Front End)
|
||||
- [x] AQuery-C++ Compiler (Back End)
|
||||
- [x] Schema and Data Model
|
||||
- [x] Data acquisition/output from/to csv file
|
||||
- [ ] Execution Engine
|
||||
- [x] Projections and single-group Aggregations
|
||||
- [x] Group by Aggregations
|
||||
- [x] Filters
|
||||
- [x] Order by
|
||||
- [x] Assumption
|
||||
- [x] Flatten
|
||||
- [x] UDFs (Hybrid Engine only)
|
||||
- [x] User Module
|
||||
- [ ] Triggers
|
||||
- [x] Join (Hybrid Engine only)
|
||||
- [ ] Subqueries
|
||||
- [x] Query Optimization
|
||||
- [x] Selection/Order by push-down
|
||||
- [x] Join Optimization (Only in Hybrid Engine)
|
||||
|
||||
## TODO:
|
||||
|
||||
- [x] User Module load syntax parsing (fn definition/registration)
|
||||
- [x] User Module initialize location
|
||||
-> User Module test
|
||||
-> Interval based triggers
|
||||
-> Optimize Compilation Process, using static libraries, hot reloading server binary
|
||||
- [x] Bug fixes: type deduction misaligned in Hybrid Engine
|
||||
-> Investigation: Using postproc only for q1 in Hybrid Engine (make is_special always on)
|
||||
- [x] Limitation: putting ColRefs back to monetdb.
|
||||
- [ ] Limitation: String operations and Date/Time data type.
|
||||
- [ ] C++ Meta-Programming: Eliminate template recursions as much as possible.
|
||||
- [ ] Limitation: Date and Time, String operations, Funcs in groupby agg.
|
||||
|
||||
# Installation
|
||||
## Requirements
|
||||
1. Recent version of Linux, Windows or MacOS, with recent C++ compiler that has C++17 (1z) support. (however c++20 is recommended if available for heterogeneous lookup on unordered containers)
|
||||
- GCC: 9.0 or above (g++ 7.x, 8.x fail to handle fold-expressions due to a compiler bug)
|
||||
- Clang: 5.0 or above (Recommended)
|
||||
- MSVC: 2017 or later (2022 or above is recommended)
|
||||
|
||||
2. Monetdb for Hybrid Engine
|
||||
- On windows, the required libraries and headers are already included in the repo.
|
||||
- On Linux, see [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) for instructions.
|
||||
- On MacOS, Monetdb can be easily installed in homebrew `brew install monetdb`.
|
||||
|
||||
3. Python 3.6 or above and install required packages in requirements.txt by `python3 -m pip install -r requirements.txt`
|
||||
## Usage
|
||||
`python3 prompt.py` will launch the interactive command prompt. The server binary will be autometically rebuilt and started.
|
||||
#### Commands:
|
||||
- `<sql statement>`: parse sql statement
|
||||
- `f <filename>`: parse all sql statements in file
|
||||
- `dbg` start debugging session
|
||||
- `print`: printout parsed sql statements
|
||||
- `exec`: execute last parsed statement(s) with AQuery Execution Engine. AQuery Execution Engine executes query by compiling it to C++ code and then executing it.
|
||||
|
||||
- `xexec`: execute last parsed statement(s) with Hybrid Execution Engine. Hybrid Execution Engine decouples the query into two parts. The sql-compliant part is executed by an Embedded version of Monetdb and everything else is executed by a post-process module which is generated by AQuery++ Compiler in C++ and then compiled and executed.
|
||||
- `r`: run the last generated code snippet
|
||||
- `save <OPTIONAL: filename>`: save current code snippet. will use random filename if not specified.
|
||||
- `exit`: quit the prompt
|
||||
#### Example:
|
||||
`f moving_avg.a` <br>
|
||||
`xexec`
|
||||
|
@ -1,59 +1,59 @@
|
||||
# put environment specific configuration here
|
||||
|
||||
## GLOBAL CONFIGURATION FLAGS
|
||||
|
||||
version_string = '0.4.4a'
|
||||
add_path_to_ldpath = True
|
||||
rebuild_backend = False
|
||||
run_backend = True
|
||||
have_hge = False
|
||||
cygroot = 'c:/msys64/usr/bin'
|
||||
msbuildroot = ''
|
||||
os_platform = 'unknown'
|
||||
build_driver = 'Makefile'
|
||||
|
||||
def init_config():
|
||||
global __config_initialized__, os_platform, msbuildroot
|
||||
## SETUP ENVIRONMENT VARIABLES
|
||||
# __config_initialized__ = False
|
||||
#os_platform = 'unkown'
|
||||
#msbuildroot = 'd:/gg/vs22/MSBuild/Current/Bin'
|
||||
import os
|
||||
from engine.utils import add_dll_dir
|
||||
# os.environ['CXX'] = 'C:/Program Files/LLVM/bin/clang.exe'
|
||||
os.environ['THREADING'] = '1'
|
||||
|
||||
if ('__config_initialized__' not in globals() or
|
||||
not __config_initialized__):
|
||||
import sys
|
||||
if os.name == 'nt':
|
||||
if sys.platform == 'win32':
|
||||
os_platform = 'win'
|
||||
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
||||
os_platform = 'cygwin'
|
||||
elif os.name == 'posix':
|
||||
if sys.platform == 'darwin':
|
||||
os_platform = 'mac'
|
||||
elif 'linux' in sys.platform:
|
||||
os_platform = 'linux'
|
||||
elif 'bsd' in sys.platform:
|
||||
os_platform = 'bsd'
|
||||
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
||||
os_platform = 'cygwin'
|
||||
# deal with msys dependencies:
|
||||
if os_platform == 'win':
|
||||
add_dll_dir(cygroot)
|
||||
add_dll_dir(os.path.abspath('./msc-plugin'))
|
||||
import vswhere
|
||||
vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath')
|
||||
if vsloc:
|
||||
msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe'
|
||||
else:
|
||||
print('Warning: No Visual Studio installation found.')
|
||||
# print("adding path")
|
||||
else:
|
||||
import readline
|
||||
if os_platform == 'cygwin':
|
||||
add_dll_dir('./lib')
|
||||
__config_initialized__ = True
|
||||
|
||||
# put environment specific configuration here
|
||||
|
||||
## GLOBAL CONFIGURATION FLAGS
|
||||
|
||||
version_string = '0.4.4a'
|
||||
add_path_to_ldpath = True
|
||||
rebuild_backend = False
|
||||
run_backend = True
|
||||
have_hge = False
|
||||
cygroot = 'c:/msys64/usr/bin'
|
||||
msbuildroot = ''
|
||||
os_platform = 'unknown'
|
||||
build_driver = 'Makefile'
|
||||
|
||||
def init_config():
|
||||
global __config_initialized__, os_platform, msbuildroot
|
||||
## SETUP ENVIRONMENT VARIABLES
|
||||
# __config_initialized__ = False
|
||||
#os_platform = 'unkown'
|
||||
#msbuildroot = 'd:/gg/vs22/MSBuild/Current/Bin'
|
||||
import os
|
||||
from engine.utils import add_dll_dir
|
||||
# os.environ['CXX'] = 'C:/Program Files/LLVM/bin/clang.exe'
|
||||
os.environ['THREADING'] = '1'
|
||||
|
||||
if ('__config_initialized__' not in globals() or
|
||||
not __config_initialized__):
|
||||
import sys
|
||||
if os.name == 'nt':
|
||||
if sys.platform == 'win32':
|
||||
os_platform = 'win'
|
||||
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
||||
os_platform = 'cygwin'
|
||||
elif os.name == 'posix':
|
||||
if sys.platform == 'darwin':
|
||||
os_platform = 'mac'
|
||||
elif 'linux' in sys.platform:
|
||||
os_platform = 'linux'
|
||||
elif 'bsd' in sys.platform:
|
||||
os_platform = 'bsd'
|
||||
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
||||
os_platform = 'cygwin'
|
||||
# deal with msys dependencies:
|
||||
if os_platform == 'win':
|
||||
add_dll_dir(cygroot)
|
||||
add_dll_dir(os.path.abspath('./msc-plugin'))
|
||||
import vswhere
|
||||
vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath')
|
||||
if vsloc:
|
||||
msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe'
|
||||
else:
|
||||
print('Warning: No Visual Studio installation found.')
|
||||
# print("adding path")
|
||||
else:
|
||||
import readline
|
||||
if os_platform == 'cygwin':
|
||||
add_dll_dir('./lib')
|
||||
__config_initialized__ = True
|
||||
|
||||
|
@ -1,88 +1,88 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
|
||||
import json
|
||||
from threading import Lock
|
||||
|
||||
from aquery_parser.sql_parser import scrub
|
||||
from aquery_parser.utils import ansi_string, simple_op, normal_op
|
||||
|
||||
parse_locker = Lock() # ENSURE ONLY ONE PARSING AT A TIME
|
||||
common_parser = None
|
||||
mysql_parser = None
|
||||
sqlserver_parser = None
|
||||
|
||||
SQL_NULL = {"null": {}}
|
||||
|
||||
|
||||
def parse(sql, null=SQL_NULL, calls=simple_op):
|
||||
"""
|
||||
:param sql: String of SQL
|
||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||
:return: parse tree
|
||||
"""
|
||||
global common_parser
|
||||
|
||||
with parse_locker:
|
||||
if not common_parser:
|
||||
common_parser = sql_parser.common_parser()
|
||||
result = _parse(common_parser, sql, null, calls)
|
||||
return result
|
||||
|
||||
|
||||
def parse_mysql(sql, null=SQL_NULL, calls=simple_op):
|
||||
"""
|
||||
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
||||
:param sql: String of SQL
|
||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||
:return: parse tree
|
||||
"""
|
||||
global mysql_parser
|
||||
|
||||
with parse_locker:
|
||||
if not mysql_parser:
|
||||
mysql_parser = sql_parser.mysql_parser()
|
||||
return _parse(mysql_parser, sql, null, calls)
|
||||
|
||||
|
||||
def parse_sqlserver(sql, null=SQL_NULL, calls=simple_op):
|
||||
"""
|
||||
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
||||
:param sql: String of SQL
|
||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||
:return: parse tree
|
||||
"""
|
||||
global sqlserver_parser
|
||||
|
||||
with parse_locker:
|
||||
if not sqlserver_parser:
|
||||
sqlserver_parser = sql_parser.sqlserver_parser()
|
||||
return _parse(sqlserver_parser, sql, null, calls)
|
||||
|
||||
|
||||
parse_bigquery = parse_mysql
|
||||
|
||||
|
||||
def _parse(parser, sql, null, calls):
|
||||
utils.null_locations = []
|
||||
utils.scrub_op = calls
|
||||
sql = sql.rstrip().rstrip(";")
|
||||
parse_result = parser.parse_string(sql, parse_all=True)
|
||||
output = scrub(parse_result)
|
||||
for o, n in utils.null_locations:
|
||||
o[n] = null
|
||||
return output
|
||||
|
||||
|
||||
|
||||
_ = json.dumps
|
||||
|
||||
__all__ = ["parse", "format", "parse_mysql", "parse_bigquery", "normal_op", "simple_op"]
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
|
||||
import json
|
||||
from threading import Lock
|
||||
|
||||
from aquery_parser.sql_parser import scrub
|
||||
from aquery_parser.utils import ansi_string, simple_op, normal_op
|
||||
|
||||
parse_locker = Lock() # ENSURE ONLY ONE PARSING AT A TIME
|
||||
common_parser = None
|
||||
mysql_parser = None
|
||||
sqlserver_parser = None
|
||||
|
||||
SQL_NULL = {"null": {}}
|
||||
|
||||
|
||||
def parse(sql, null=SQL_NULL, calls=simple_op):
|
||||
"""
|
||||
:param sql: String of SQL
|
||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||
:return: parse tree
|
||||
"""
|
||||
global common_parser
|
||||
|
||||
with parse_locker:
|
||||
if not common_parser:
|
||||
common_parser = sql_parser.common_parser()
|
||||
result = _parse(common_parser, sql, null, calls)
|
||||
return result
|
||||
|
||||
|
||||
def parse_mysql(sql, null=SQL_NULL, calls=simple_op):
|
||||
"""
|
||||
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
||||
:param sql: String of SQL
|
||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||
:return: parse tree
|
||||
"""
|
||||
global mysql_parser
|
||||
|
||||
with parse_locker:
|
||||
if not mysql_parser:
|
||||
mysql_parser = sql_parser.mysql_parser()
|
||||
return _parse(mysql_parser, sql, null, calls)
|
||||
|
||||
|
||||
def parse_sqlserver(sql, null=SQL_NULL, calls=simple_op):
|
||||
"""
|
||||
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
||||
:param sql: String of SQL
|
||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||
:return: parse tree
|
||||
"""
|
||||
global sqlserver_parser
|
||||
|
||||
with parse_locker:
|
||||
if not sqlserver_parser:
|
||||
sqlserver_parser = sql_parser.sqlserver_parser()
|
||||
return _parse(sqlserver_parser, sql, null, calls)
|
||||
|
||||
|
||||
parse_bigquery = parse_mysql
|
||||
|
||||
|
||||
def _parse(parser, sql, null, calls):
|
||||
utils.null_locations = []
|
||||
utils.scrub_op = calls
|
||||
sql = sql.rstrip().rstrip(";")
|
||||
parse_result = parser.parse_string(sql, parse_all=True)
|
||||
output = scrub(parse_result)
|
||||
for o, n in utils.null_locations:
|
||||
o[n] = null
|
||||
return output
|
||||
|
||||
|
||||
|
||||
_ = json.dumps
|
||||
|
||||
__all__ = ["parse", "format", "parse_mysql", "parse_bigquery", "normal_op", "simple_op"]
|
||||
|
@ -1,417 +1,417 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
# SQL CONSTANTS
|
||||
from mo_parsing import *
|
||||
|
||||
from aquery_parser.utils import SQL_NULL, keyword
|
||||
|
||||
NULL = keyword("null") / (lambda: SQL_NULL)
|
||||
TRUE = keyword("true") / (lambda: True)
|
||||
FALSE = keyword("false") / (lambda: False)
|
||||
NOCASE = keyword("nocase")
|
||||
ASC = keyword("asc")
|
||||
DESC = keyword("desc")
|
||||
|
||||
# SIMPLE KEYWORDS
|
||||
AS = keyword("as").suppress()
|
||||
ASSUMING = keyword("assuming")
|
||||
ALL = keyword("all")
|
||||
BY = keyword("by").suppress()
|
||||
CAST = keyword("cast")
|
||||
CONSTRAINT = keyword("constraint").suppress()
|
||||
CREATE = keyword("create").suppress()
|
||||
CROSS = keyword("cross")
|
||||
DISTINCT = keyword("distinct")
|
||||
EXCEPT = keyword("except")
|
||||
FETCH = keyword("fetch").suppress()
|
||||
FROM = keyword("from").suppress()
|
||||
FULL = keyword("full")
|
||||
FUNCTION = keyword("function").suppress()
|
||||
AGGREGATION = keyword("aggregation").suppress()
|
||||
GROUP = keyword("group").suppress()
|
||||
HAVING = keyword("having").suppress()
|
||||
INNER = keyword("inner")
|
||||
INTERVAL = keyword("interval")
|
||||
JOIN = keyword("join")
|
||||
LEFT = keyword("left")
|
||||
LIKE = keyword("like")
|
||||
LIMIT = keyword("limit").suppress()
|
||||
MINUS = keyword("minus")
|
||||
OFFSET = keyword("offset").suppress()
|
||||
ON = keyword("on").suppress()
|
||||
ORDER = keyword("order").suppress()
|
||||
OUTER = keyword("outer")
|
||||
OVER = keyword("over").suppress()
|
||||
PARTITION = keyword("partition").suppress()
|
||||
# PERCENT = keyword("percent").suppress()
|
||||
RIGHT = keyword("right")
|
||||
RLIKE = keyword("rlike")
|
||||
SELECT = keyword("select").suppress()
|
||||
TABLE = keyword("table").suppress()
|
||||
THEN = keyword("then").suppress()
|
||||
TOP = keyword("top").suppress()
|
||||
UNION = keyword("union")
|
||||
INTERSECT = keyword("intersect")
|
||||
USING = keyword("using").suppress()
|
||||
WHEN = keyword("when").suppress()
|
||||
WHERE = keyword("where").suppress()
|
||||
WITH = keyword("with").suppress()
|
||||
WITHIN = keyword("within").suppress()
|
||||
PRIMARY = keyword("primary").suppress()
|
||||
FOREIGN = keyword("foreign").suppress()
|
||||
KEY = keyword("key").suppress()
|
||||
UNIQUE = keyword("unique").suppress()
|
||||
INDEX = keyword("index").suppress()
|
||||
REFERENCES = keyword("references").suppress()
|
||||
RECURSIVE = keyword("recursive").suppress()
|
||||
VALUES = keyword("values").suppress()
|
||||
WINDOW = keyword("window")
|
||||
INTO = keyword("into").suppress()
|
||||
IF = keyword("if").suppress()
|
||||
STATIC = keyword("static").suppress()
|
||||
ELIF = keyword("elif").suppress()
|
||||
ELSE = keyword("else").suppress()
|
||||
FOR = keyword("for").suppress()
|
||||
|
||||
PRIMARY_KEY = Group(PRIMARY + KEY).set_parser_name("primary_key")
|
||||
FOREIGN_KEY = Group(FOREIGN + KEY).set_parser_name("foreign_key")
|
||||
|
||||
# SIMPLE OPERATORS
|
||||
CONCAT = Literal("||").set_parser_name("concat")
|
||||
MUL = Literal("*").set_parser_name("mul")
|
||||
DIV = Literal("/").set_parser_name("div")
|
||||
MOD = Literal("%").set_parser_name("mod")
|
||||
NEG = Literal("-").set_parser_name("neg")
|
||||
ADD = Literal("+").set_parser_name("add")
|
||||
SUB = Literal("-").set_parser_name("sub")
|
||||
BINARY_NOT = Literal("~").set_parser_name("binary_not")
|
||||
BINARY_AND = Literal("&").set_parser_name("binary_and")
|
||||
BINARY_OR = Literal("|").set_parser_name("binary_or")
|
||||
GTE = Literal(">=").set_parser_name("gte")
|
||||
LTE = Literal("<=").set_parser_name("lte")
|
||||
LT = Literal("<").set_parser_name("lt")
|
||||
GT = Literal(">").set_parser_name("gt")
|
||||
EEQ = (
|
||||
# conservative equality https://github.com/klahnakoski/jx-sqlite/blob/dev/docs/Logical%20Equality.md#definitions
|
||||
Literal("==") | Literal("=")
|
||||
).set_parser_name("eq")
|
||||
DEQ = (
|
||||
# decisive equality
|
||||
# https://sparkbyexamples.com/apache-hive/hive-relational-arithmetic-logical-operators/
|
||||
Literal("<=>").set_parser_name("eq!")
|
||||
)
|
||||
IDF = (
|
||||
# decisive equality
|
||||
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
||||
keyword("is distinct from").set_parser_name("eq!")
|
||||
)
|
||||
INDF = (
|
||||
# decisive equality
|
||||
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
||||
keyword("is not distinct from").set_parser_name("ne!")
|
||||
)
|
||||
FASSIGN = Literal(":=").set_parser_name("fassign") # Assignment in UDFs
|
||||
PASSIGN = Literal("+=").set_parser_name("passign")
|
||||
MASSIGN = Literal("-=").set_parser_name("massign")
|
||||
MULASSIGN = Literal("*=").set_parser_name("mulassign")
|
||||
DASSIGN = Literal("/=").set_parser_name("dassign")
|
||||
COLON = Literal(":").set_parser_name("colon")
|
||||
NEQ = (Literal("!=") | Literal("<>")).set_parser_name("neq")
|
||||
LAMBDA = Literal("->").set_parser_name("lambda")
|
||||
DOT = Literal(".").set_parser_name("dot")
|
||||
|
||||
AND = keyword("and")
|
||||
BETWEEN = keyword("between")
|
||||
CASE = keyword("case").suppress()
|
||||
COLLATE = keyword("collate")
|
||||
END = keyword("end")
|
||||
ELSE = keyword("else").suppress()
|
||||
IN = keyword("in")
|
||||
IS = keyword("is")
|
||||
NOT = keyword("not")
|
||||
OR = keyword("or")
|
||||
LATERAL = keyword("lateral")
|
||||
VIEW = keyword("view")
|
||||
|
||||
# COMPOUND KEYWORDS
|
||||
|
||||
|
||||
joins = (
|
||||
(
|
||||
Optional(CROSS | OUTER | INNER | ((FULL | LEFT | RIGHT) + Optional(INNER | OUTER)))
|
||||
+ JOIN
|
||||
+ Optional(LATERAL)
|
||||
)
|
||||
| LATERAL + VIEW + Optional(OUTER)
|
||||
) / (lambda tokens: " ".join(tokens).lower())
|
||||
|
||||
UNION_ALL = (UNION + ALL).set_parser_name("union_all")
|
||||
WITHIN_GROUP = Group(WITHIN + GROUP).set_parser_name("within_group")
|
||||
SELECT_DISTINCT = Group(SELECT + DISTINCT).set_parser_name("select distinct")
|
||||
PARTITION_BY = Group(PARTITION + BY).set_parser_name("partition by")
|
||||
GROUP_BY = Group(GROUP + BY).set_parser_name("group by")
|
||||
ORDER_BY = Group(ORDER + BY).set_parser_name("order by")
|
||||
|
||||
# COMPOUND OPERATORS
|
||||
AT_TIME_ZONE = Group(keyword("at") + keyword("time") + keyword("zone"))
|
||||
NOT_BETWEEN = Group(NOT + BETWEEN).set_parser_name("not_between")
|
||||
NOT_LIKE = Group(NOT + LIKE).set_parser_name("not_like")
|
||||
NOT_RLIKE = Group(NOT + RLIKE).set_parser_name("not_rlike")
|
||||
NOT_IN = Group(NOT + IN).set_parser_name("nin")
|
||||
IS_NOT = Group(IS + NOT).set_parser_name("is_not")
|
||||
|
||||
_SIMILAR = keyword("similar")
|
||||
_TO = keyword("to")
|
||||
SIMILAR_TO = Group(_SIMILAR + _TO).set_parser_name("similar_to")
|
||||
NOT_SIMILAR_TO = Group(NOT + _SIMILAR + _TO).set_parser_name("not_similar_to")
|
||||
|
||||
RESERVED = MatchFirst([
|
||||
# ONY INCLUDE SINGLE WORDS
|
||||
ALL,
|
||||
AND,
|
||||
AS,
|
||||
ASC,
|
||||
ASSUMING,
|
||||
BETWEEN,
|
||||
BY,
|
||||
CASE,
|
||||
COLLATE,
|
||||
CONSTRAINT,
|
||||
CREATE,
|
||||
CROSS,
|
||||
DESC,
|
||||
DISTINCT,
|
||||
EXCEPT,
|
||||
ELSE,
|
||||
END,
|
||||
FALSE,
|
||||
FETCH,
|
||||
FOREIGN,
|
||||
FROM,
|
||||
FULL,
|
||||
FUNCTION,
|
||||
GROUP_BY,
|
||||
GROUP,
|
||||
HAVING,
|
||||
IN,
|
||||
INDEX,
|
||||
INNER,
|
||||
INTERSECT,
|
||||
INTERVAL,
|
||||
IS_NOT,
|
||||
IS,
|
||||
JOIN,
|
||||
KEY,
|
||||
LATERAL,
|
||||
LEFT,
|
||||
LIKE,
|
||||
LIMIT,
|
||||
MINUS,
|
||||
NOCASE,
|
||||
NOT,
|
||||
NULL,
|
||||
OFFSET,
|
||||
ON,
|
||||
OR,
|
||||
ORDER,
|
||||
OUTER,
|
||||
OVER,
|
||||
PARTITION,
|
||||
PRIMARY,
|
||||
REFERENCES,
|
||||
RIGHT,
|
||||
RLIKE,
|
||||
SELECT,
|
||||
THEN,
|
||||
TRUE,
|
||||
UNION,
|
||||
UNIQUE,
|
||||
USING,
|
||||
WHEN,
|
||||
WHERE,
|
||||
WINDOW,
|
||||
WITH,
|
||||
WITHIN,
|
||||
INTO,
|
||||
])
|
||||
L_INLINE = Literal("<k>").suppress()
|
||||
R_INLINE = Literal("</k>").suppress()
|
||||
LBRACE = Literal("{").suppress()
|
||||
RBRACE = Literal("}").suppress()
|
||||
LSB = Literal("[").suppress()
|
||||
RSB = Literal("]").suppress()
|
||||
LB = Literal("(").suppress()
|
||||
RB = Literal(")").suppress()
|
||||
EQ = Char("=").suppress()
|
||||
|
||||
join_keywords = {
|
||||
"join",
|
||||
"full join",
|
||||
"cross join",
|
||||
"inner join",
|
||||
"left join",
|
||||
"right join",
|
||||
"full outer join",
|
||||
"right outer join",
|
||||
"left outer join",
|
||||
}
|
||||
|
||||
precedence = {
|
||||
# https://www.sqlite.org/lang_expr.html
|
||||
"literal": -1,
|
||||
"interval": 0,
|
||||
"cast": 0,
|
||||
"collate": 0,
|
||||
"concat": 1,
|
||||
"mul": 2,
|
||||
"div": 1.5,
|
||||
"mod": 2,
|
||||
"neg": 3,
|
||||
"add": 3,
|
||||
"sub": 2.5,
|
||||
"binary_not": 4,
|
||||
"binary_and": 4,
|
||||
"binary_or": 4,
|
||||
"gte": 5,
|
||||
"lte": 5,
|
||||
"lt": 5,
|
||||
"gt": 6,
|
||||
"eq": 7,
|
||||
"neq": 7,
|
||||
"missing": 7,
|
||||
"exists": 7,
|
||||
"at_time_zone": 8,
|
||||
"between": 8,
|
||||
"not_between": 8,
|
||||
"in": 8,
|
||||
"nin": 8,
|
||||
"is": 8,
|
||||
"like": 8,
|
||||
"not_like": 8,
|
||||
"rlike": 8,
|
||||
"not_rlike": 8,
|
||||
"similar_to": 8,
|
||||
"not_similar_to": 8,
|
||||
"and": 10,
|
||||
"or": 11,
|
||||
"lambda": 12,
|
||||
"join": 18,
|
||||
"list": 18,
|
||||
"function": 30,
|
||||
"select": 30,
|
||||
"from": 30,
|
||||
"window": 35,
|
||||
"union": 40,
|
||||
"union_all": 40,
|
||||
"except": 40,
|
||||
"minus": 40,
|
||||
"intersect": 40,
|
||||
"order": 50,
|
||||
}
|
||||
|
||||
KNOWN_OPS = [
|
||||
COLLATE,
|
||||
CONCAT,
|
||||
MUL | DIV | MOD,
|
||||
NEG,
|
||||
ADD | SUB,
|
||||
BINARY_NOT,
|
||||
BINARY_AND,
|
||||
BINARY_OR,
|
||||
GTE | LTE | LT | GT,
|
||||
EEQ | NEQ | DEQ | IDF | INDF,
|
||||
AT_TIME_ZONE,
|
||||
(BETWEEN, AND),
|
||||
(NOT_BETWEEN, AND),
|
||||
IN,
|
||||
NOT_IN,
|
||||
IS_NOT,
|
||||
IS,
|
||||
LIKE,
|
||||
NOT_LIKE,
|
||||
RLIKE,
|
||||
NOT_RLIKE,
|
||||
SIMILAR_TO,
|
||||
NOT_SIMILAR_TO,
|
||||
NOT,
|
||||
AND,
|
||||
OR,
|
||||
LAMBDA,
|
||||
]
|
||||
|
||||
times = ["now", "today", "tomorrow", "eod"]
|
||||
|
||||
durations = {
|
||||
"microseconds": "microsecond",
|
||||
"microsecond": "microsecond",
|
||||
"microsecs": "microsecond",
|
||||
"microsec": "microsecond",
|
||||
"useconds": "microsecond",
|
||||
"usecond": "microsecond",
|
||||
"usecs": "microsecond",
|
||||
"usec": "microsecond",
|
||||
"us": "microsecond",
|
||||
"milliseconds": "millisecond",
|
||||
"millisecond": "millisecond",
|
||||
"millisecon": "millisecond",
|
||||
"mseconds": "millisecond",
|
||||
"msecond": "millisecond",
|
||||
"millisecs": "millisecond",
|
||||
"millisec": "millisecond",
|
||||
"msecs": "millisecond",
|
||||
"msec": "millisecond",
|
||||
"ms": "millisecond",
|
||||
"seconds": "second",
|
||||
"second": "second",
|
||||
"secs": "second",
|
||||
"sec": "second",
|
||||
"s": "second",
|
||||
"minutes": "minute",
|
||||
"minute": "minute",
|
||||
"mins": "minute",
|
||||
"min": "minute",
|
||||
"m": "minute",
|
||||
"hours": "hour",
|
||||
"hour": "hour",
|
||||
"hrs": "hour",
|
||||
"hr": "hour",
|
||||
"h": "hour",
|
||||
"days": "day",
|
||||
"day": "day",
|
||||
"d": "day",
|
||||
"dayofweek": "dow",
|
||||
"dow": "dow",
|
||||
"weekday": "dow",
|
||||
"weeks": "week",
|
||||
"week": "week",
|
||||
"w": "week",
|
||||
"months": "month",
|
||||
"month": "month",
|
||||
"mons": "month",
|
||||
"mon": "month",
|
||||
"quarters": "quarter",
|
||||
"quarter": "quarter",
|
||||
"years": "year",
|
||||
"year": "year",
|
||||
"decades": "decade",
|
||||
"decade": "decade",
|
||||
"decs": "decade",
|
||||
"dec": "decade",
|
||||
"centuries": "century",
|
||||
"century": "century",
|
||||
"cents": "century",
|
||||
"cent": "century",
|
||||
"c": "century",
|
||||
"millennia": "millennium",
|
||||
"millennium": "millennium",
|
||||
"mils": "millennium",
|
||||
"mil": "millennium",
|
||||
"epoch": "epoch",
|
||||
}
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
# SQL CONSTANTS
|
||||
from mo_parsing import *
|
||||
|
||||
from aquery_parser.utils import SQL_NULL, keyword
|
||||
|
||||
NULL = keyword("null") / (lambda: SQL_NULL)
|
||||
TRUE = keyword("true") / (lambda: True)
|
||||
FALSE = keyword("false") / (lambda: False)
|
||||
NOCASE = keyword("nocase")
|
||||
ASC = keyword("asc")
|
||||
DESC = keyword("desc")
|
||||
|
||||
# SIMPLE KEYWORDS
|
||||
AS = keyword("as").suppress()
|
||||
ASSUMING = keyword("assuming")
|
||||
ALL = keyword("all")
|
||||
BY = keyword("by").suppress()
|
||||
CAST = keyword("cast")
|
||||
CONSTRAINT = keyword("constraint").suppress()
|
||||
CREATE = keyword("create").suppress()
|
||||
CROSS = keyword("cross")
|
||||
DISTINCT = keyword("distinct")
|
||||
EXCEPT = keyword("except")
|
||||
FETCH = keyword("fetch").suppress()
|
||||
FROM = keyword("from").suppress()
|
||||
FULL = keyword("full")
|
||||
FUNCTION = keyword("function").suppress()
|
||||
AGGREGATION = keyword("aggregation").suppress()
|
||||
GROUP = keyword("group").suppress()
|
||||
HAVING = keyword("having").suppress()
|
||||
INNER = keyword("inner")
|
||||
INTERVAL = keyword("interval")
|
||||
JOIN = keyword("join")
|
||||
LEFT = keyword("left")
|
||||
LIKE = keyword("like")
|
||||
LIMIT = keyword("limit").suppress()
|
||||
MINUS = keyword("minus")
|
||||
OFFSET = keyword("offset").suppress()
|
||||
ON = keyword("on").suppress()
|
||||
ORDER = keyword("order").suppress()
|
||||
OUTER = keyword("outer")
|
||||
OVER = keyword("over").suppress()
|
||||
PARTITION = keyword("partition").suppress()
|
||||
# PERCENT = keyword("percent").suppress()
|
||||
RIGHT = keyword("right")
|
||||
RLIKE = keyword("rlike")
|
||||
SELECT = keyword("select").suppress()
|
||||
TABLE = keyword("table").suppress()
|
||||
THEN = keyword("then").suppress()
|
||||
TOP = keyword("top").suppress()
|
||||
UNION = keyword("union")
|
||||
INTERSECT = keyword("intersect")
|
||||
USING = keyword("using").suppress()
|
||||
WHEN = keyword("when").suppress()
|
||||
WHERE = keyword("where").suppress()
|
||||
WITH = keyword("with").suppress()
|
||||
WITHIN = keyword("within").suppress()
|
||||
PRIMARY = keyword("primary").suppress()
|
||||
FOREIGN = keyword("foreign").suppress()
|
||||
KEY = keyword("key").suppress()
|
||||
UNIQUE = keyword("unique").suppress()
|
||||
INDEX = keyword("index").suppress()
|
||||
REFERENCES = keyword("references").suppress()
|
||||
RECURSIVE = keyword("recursive").suppress()
|
||||
VALUES = keyword("values").suppress()
|
||||
WINDOW = keyword("window")
|
||||
INTO = keyword("into").suppress()
|
||||
IF = keyword("if").suppress()
|
||||
STATIC = keyword("static").suppress()
|
||||
ELIF = keyword("elif").suppress()
|
||||
ELSE = keyword("else").suppress()
|
||||
FOR = keyword("for").suppress()
|
||||
|
||||
PRIMARY_KEY = Group(PRIMARY + KEY).set_parser_name("primary_key")
|
||||
FOREIGN_KEY = Group(FOREIGN + KEY).set_parser_name("foreign_key")
|
||||
|
||||
# SIMPLE OPERATORS
|
||||
CONCAT = Literal("||").set_parser_name("concat")
|
||||
MUL = Literal("*").set_parser_name("mul")
|
||||
DIV = Literal("/").set_parser_name("div")
|
||||
MOD = Literal("%").set_parser_name("mod")
|
||||
NEG = Literal("-").set_parser_name("neg")
|
||||
ADD = Literal("+").set_parser_name("add")
|
||||
SUB = Literal("-").set_parser_name("sub")
|
||||
BINARY_NOT = Literal("~").set_parser_name("binary_not")
|
||||
BINARY_AND = Literal("&").set_parser_name("binary_and")
|
||||
BINARY_OR = Literal("|").set_parser_name("binary_or")
|
||||
GTE = Literal(">=").set_parser_name("gte")
|
||||
LTE = Literal("<=").set_parser_name("lte")
|
||||
LT = Literal("<").set_parser_name("lt")
|
||||
GT = Literal(">").set_parser_name("gt")
|
||||
EEQ = (
|
||||
# conservative equality https://github.com/klahnakoski/jx-sqlite/blob/dev/docs/Logical%20Equality.md#definitions
|
||||
Literal("==") | Literal("=")
|
||||
).set_parser_name("eq")
|
||||
DEQ = (
|
||||
# decisive equality
|
||||
# https://sparkbyexamples.com/apache-hive/hive-relational-arithmetic-logical-operators/
|
||||
Literal("<=>").set_parser_name("eq!")
|
||||
)
|
||||
IDF = (
|
||||
# decisive equality
|
||||
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
||||
keyword("is distinct from").set_parser_name("eq!")
|
||||
)
|
||||
INDF = (
|
||||
# decisive equality
|
||||
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
||||
keyword("is not distinct from").set_parser_name("ne!")
|
||||
)
|
||||
FASSIGN = Literal(":=").set_parser_name("fassign") # Assignment in UDFs
|
||||
PASSIGN = Literal("+=").set_parser_name("passign")
|
||||
MASSIGN = Literal("-=").set_parser_name("massign")
|
||||
MULASSIGN = Literal("*=").set_parser_name("mulassign")
|
||||
DASSIGN = Literal("/=").set_parser_name("dassign")
|
||||
COLON = Literal(":").set_parser_name("colon")
|
||||
NEQ = (Literal("!=") | Literal("<>")).set_parser_name("neq")
|
||||
LAMBDA = Literal("->").set_parser_name("lambda")
|
||||
DOT = Literal(".").set_parser_name("dot")
|
||||
|
||||
AND = keyword("and")
|
||||
BETWEEN = keyword("between")
|
||||
CASE = keyword("case").suppress()
|
||||
COLLATE = keyword("collate")
|
||||
END = keyword("end")
|
||||
ELSE = keyword("else").suppress()
|
||||
IN = keyword("in")
|
||||
IS = keyword("is")
|
||||
NOT = keyword("not")
|
||||
OR = keyword("or")
|
||||
LATERAL = keyword("lateral")
|
||||
VIEW = keyword("view")
|
||||
|
||||
# COMPOUND KEYWORDS
|
||||
|
||||
|
||||
joins = (
|
||||
(
|
||||
Optional(CROSS | OUTER | INNER | ((FULL | LEFT | RIGHT) + Optional(INNER | OUTER)))
|
||||
+ JOIN
|
||||
+ Optional(LATERAL)
|
||||
)
|
||||
| LATERAL + VIEW + Optional(OUTER)
|
||||
) / (lambda tokens: " ".join(tokens).lower())
|
||||
|
||||
UNION_ALL = (UNION + ALL).set_parser_name("union_all")
|
||||
WITHIN_GROUP = Group(WITHIN + GROUP).set_parser_name("within_group")
|
||||
SELECT_DISTINCT = Group(SELECT + DISTINCT).set_parser_name("select distinct")
|
||||
PARTITION_BY = Group(PARTITION + BY).set_parser_name("partition by")
|
||||
GROUP_BY = Group(GROUP + BY).set_parser_name("group by")
|
||||
ORDER_BY = Group(ORDER + BY).set_parser_name("order by")
|
||||
|
||||
# COMPOUND OPERATORS
|
||||
AT_TIME_ZONE = Group(keyword("at") + keyword("time") + keyword("zone"))
|
||||
NOT_BETWEEN = Group(NOT + BETWEEN).set_parser_name("not_between")
|
||||
NOT_LIKE = Group(NOT + LIKE).set_parser_name("not_like")
|
||||
NOT_RLIKE = Group(NOT + RLIKE).set_parser_name("not_rlike")
|
||||
NOT_IN = Group(NOT + IN).set_parser_name("nin")
|
||||
IS_NOT = Group(IS + NOT).set_parser_name("is_not")
|
||||
|
||||
_SIMILAR = keyword("similar")
|
||||
_TO = keyword("to")
|
||||
SIMILAR_TO = Group(_SIMILAR + _TO).set_parser_name("similar_to")
|
||||
NOT_SIMILAR_TO = Group(NOT + _SIMILAR + _TO).set_parser_name("not_similar_to")
|
||||
|
||||
RESERVED = MatchFirst([
|
||||
# ONY INCLUDE SINGLE WORDS
|
||||
ALL,
|
||||
AND,
|
||||
AS,
|
||||
ASC,
|
||||
ASSUMING,
|
||||
BETWEEN,
|
||||
BY,
|
||||
CASE,
|
||||
COLLATE,
|
||||
CONSTRAINT,
|
||||
CREATE,
|
||||
CROSS,
|
||||
DESC,
|
||||
DISTINCT,
|
||||
EXCEPT,
|
||||
ELSE,
|
||||
END,
|
||||
FALSE,
|
||||
FETCH,
|
||||
FOREIGN,
|
||||
FROM,
|
||||
FULL,
|
||||
FUNCTION,
|
||||
GROUP_BY,
|
||||
GROUP,
|
||||
HAVING,
|
||||
IN,
|
||||
INDEX,
|
||||
INNER,
|
||||
INTERSECT,
|
||||
INTERVAL,
|
||||
IS_NOT,
|
||||
IS,
|
||||
JOIN,
|
||||
KEY,
|
||||
LATERAL,
|
||||
LEFT,
|
||||
LIKE,
|
||||
LIMIT,
|
||||
MINUS,
|
||||
NOCASE,
|
||||
NOT,
|
||||
NULL,
|
||||
OFFSET,
|
||||
ON,
|
||||
OR,
|
||||
ORDER,
|
||||
OUTER,
|
||||
OVER,
|
||||
PARTITION,
|
||||
PRIMARY,
|
||||
REFERENCES,
|
||||
RIGHT,
|
||||
RLIKE,
|
||||
SELECT,
|
||||
THEN,
|
||||
TRUE,
|
||||
UNION,
|
||||
UNIQUE,
|
||||
USING,
|
||||
WHEN,
|
||||
WHERE,
|
||||
WINDOW,
|
||||
WITH,
|
||||
WITHIN,
|
||||
INTO,
|
||||
])
|
||||
L_INLINE = Literal("<k>").suppress()
|
||||
R_INLINE = Literal("</k>").suppress()
|
||||
LBRACE = Literal("{").suppress()
|
||||
RBRACE = Literal("}").suppress()
|
||||
LSB = Literal("[").suppress()
|
||||
RSB = Literal("]").suppress()
|
||||
LB = Literal("(").suppress()
|
||||
RB = Literal(")").suppress()
|
||||
EQ = Char("=").suppress()
|
||||
|
||||
join_keywords = {
|
||||
"join",
|
||||
"full join",
|
||||
"cross join",
|
||||
"inner join",
|
||||
"left join",
|
||||
"right join",
|
||||
"full outer join",
|
||||
"right outer join",
|
||||
"left outer join",
|
||||
}
|
||||
|
||||
precedence = {
|
||||
# https://www.sqlite.org/lang_expr.html
|
||||
"literal": -1,
|
||||
"interval": 0,
|
||||
"cast": 0,
|
||||
"collate": 0,
|
||||
"concat": 1,
|
||||
"mul": 2,
|
||||
"div": 1.5,
|
||||
"mod": 2,
|
||||
"neg": 3,
|
||||
"add": 3,
|
||||
"sub": 2.5,
|
||||
"binary_not": 4,
|
||||
"binary_and": 4,
|
||||
"binary_or": 4,
|
||||
"gte": 5,
|
||||
"lte": 5,
|
||||
"lt": 5,
|
||||
"gt": 6,
|
||||
"eq": 7,
|
||||
"neq": 7,
|
||||
"missing": 7,
|
||||
"exists": 7,
|
||||
"at_time_zone": 8,
|
||||
"between": 8,
|
||||
"not_between": 8,
|
||||
"in": 8,
|
||||
"nin": 8,
|
||||
"is": 8,
|
||||
"like": 8,
|
||||
"not_like": 8,
|
||||
"rlike": 8,
|
||||
"not_rlike": 8,
|
||||
"similar_to": 8,
|
||||
"not_similar_to": 8,
|
||||
"and": 10,
|
||||
"or": 11,
|
||||
"lambda": 12,
|
||||
"join": 18,
|
||||
"list": 18,
|
||||
"function": 30,
|
||||
"select": 30,
|
||||
"from": 30,
|
||||
"window": 35,
|
||||
"union": 40,
|
||||
"union_all": 40,
|
||||
"except": 40,
|
||||
"minus": 40,
|
||||
"intersect": 40,
|
||||
"order": 50,
|
||||
}
|
||||
|
||||
KNOWN_OPS = [
|
||||
COLLATE,
|
||||
CONCAT,
|
||||
MUL | DIV | MOD,
|
||||
NEG,
|
||||
ADD | SUB,
|
||||
BINARY_NOT,
|
||||
BINARY_AND,
|
||||
BINARY_OR,
|
||||
GTE | LTE | LT | GT,
|
||||
EEQ | NEQ | DEQ | IDF | INDF,
|
||||
AT_TIME_ZONE,
|
||||
(BETWEEN, AND),
|
||||
(NOT_BETWEEN, AND),
|
||||
IN,
|
||||
NOT_IN,
|
||||
IS_NOT,
|
||||
IS,
|
||||
LIKE,
|
||||
NOT_LIKE,
|
||||
RLIKE,
|
||||
NOT_RLIKE,
|
||||
SIMILAR_TO,
|
||||
NOT_SIMILAR_TO,
|
||||
NOT,
|
||||
AND,
|
||||
OR,
|
||||
LAMBDA,
|
||||
]
|
||||
|
||||
times = ["now", "today", "tomorrow", "eod"]
|
||||
|
||||
durations = {
|
||||
"microseconds": "microsecond",
|
||||
"microsecond": "microsecond",
|
||||
"microsecs": "microsecond",
|
||||
"microsec": "microsecond",
|
||||
"useconds": "microsecond",
|
||||
"usecond": "microsecond",
|
||||
"usecs": "microsecond",
|
||||
"usec": "microsecond",
|
||||
"us": "microsecond",
|
||||
"milliseconds": "millisecond",
|
||||
"millisecond": "millisecond",
|
||||
"millisecon": "millisecond",
|
||||
"mseconds": "millisecond",
|
||||
"msecond": "millisecond",
|
||||
"millisecs": "millisecond",
|
||||
"millisec": "millisecond",
|
||||
"msecs": "millisecond",
|
||||
"msec": "millisecond",
|
||||
"ms": "millisecond",
|
||||
"seconds": "second",
|
||||
"second": "second",
|
||||
"secs": "second",
|
||||
"sec": "second",
|
||||
"s": "second",
|
||||
"minutes": "minute",
|
||||
"minute": "minute",
|
||||
"mins": "minute",
|
||||
"min": "minute",
|
||||
"m": "minute",
|
||||
"hours": "hour",
|
||||
"hour": "hour",
|
||||
"hrs": "hour",
|
||||
"hr": "hour",
|
||||
"h": "hour",
|
||||
"days": "day",
|
||||
"day": "day",
|
||||
"d": "day",
|
||||
"dayofweek": "dow",
|
||||
"dow": "dow",
|
||||
"weekday": "dow",
|
||||
"weeks": "week",
|
||||
"week": "week",
|
||||
"w": "week",
|
||||
"months": "month",
|
||||
"month": "month",
|
||||
"mons": "month",
|
||||
"mon": "month",
|
||||
"quarters": "quarter",
|
||||
"quarter": "quarter",
|
||||
"years": "year",
|
||||
"year": "year",
|
||||
"decades": "decade",
|
||||
"decade": "decade",
|
||||
"decs": "decade",
|
||||
"dec": "decade",
|
||||
"centuries": "century",
|
||||
"century": "century",
|
||||
"cents": "century",
|
||||
"cent": "century",
|
||||
"c": "century",
|
||||
"millennia": "millennium",
|
||||
"millennium": "millennium",
|
||||
"mils": "millennium",
|
||||
"mil": "millennium",
|
||||
"epoch": "epoch",
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,223 +1,223 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
|
||||
# KNOWN TYPES
|
||||
from mo_parsing import Forward, Group, Optional, MatchFirst, Literal, ZeroOrMore, export
|
||||
from mo_parsing.infix import delimited_list, RIGHT_ASSOC, LEFT_ASSOC
|
||||
|
||||
from aquery_parser.keywords import (
|
||||
RB,
|
||||
LB,
|
||||
NEG,
|
||||
NOT,
|
||||
BINARY_NOT,
|
||||
NULL,
|
||||
EQ,
|
||||
KNOWN_OPS,
|
||||
LT,
|
||||
GT,
|
||||
)
|
||||
from aquery_parser.utils import (
|
||||
keyword,
|
||||
to_json_call,
|
||||
int_num,
|
||||
ansi_string,
|
||||
ansi_ident,
|
||||
assign,
|
||||
flag,
|
||||
)
|
||||
|
||||
_size = Optional(LB + int_num("params") + RB)
|
||||
_sizes = Optional(LB + delimited_list(int_num("params")) + RB)
|
||||
|
||||
simple_types = Forward()
|
||||
|
||||
BIGINT = Group(keyword("bigint")("op") + Optional(_size)+Optional(flag("unsigned"))) / to_json_call
|
||||
BOOL = Group(keyword("bool")("op")) / to_json_call
|
||||
BOOLEAN = Group(keyword("boolean")("op")) / to_json_call
|
||||
DOUBLE = Group(keyword("double")("op")) / to_json_call
|
||||
FLOAT64 = Group(keyword("float64")("op")) / to_json_call
|
||||
FLOAT = Group(keyword("float")("op")) / to_json_call
|
||||
GEOMETRY = Group(keyword("geometry")("op")) / to_json_call
|
||||
INTEGER = Group(keyword("integer")("op")) / to_json_call
|
||||
INT = (keyword("int")("op") + _size) / to_json_call
|
||||
INT32 = Group(keyword("int32")("op")) / to_json_call
|
||||
INT64 = Group(keyword("int64")("op")) / to_json_call
|
||||
REAL = Group(keyword("real")("op")) / to_json_call
|
||||
TEXT = Group(keyword("text")("op")) / to_json_call
|
||||
SMALLINT = Group(keyword("smallint")("op")) / to_json_call
|
||||
STRING = Group(keyword("string")("op")) / to_json_call
|
||||
|
||||
BLOB = (keyword("blob")("op") + _size) / to_json_call
|
||||
BYTES = (keyword("bytes")("op") + _size) / to_json_call
|
||||
CHAR = (keyword("char")("op") + _size) / to_json_call
|
||||
NCHAR = (keyword("nchar")("op") + _size) / to_json_call
|
||||
VARCHAR = (keyword("varchar")("op") + _size) / to_json_call
|
||||
VARCHAR2 = (keyword("varchar2")("op") + _size) / to_json_call
|
||||
VARBINARY = (keyword("varbinary")("op") + _size) / to_json_call
|
||||
TINYINT = (keyword("tinyint")("op") + _size) / to_json_call
|
||||
UUID = Group(keyword("uuid")("op")) / to_json_call
|
||||
|
||||
DECIMAL = (keyword("decimal")("op") + _sizes) / to_json_call
|
||||
DOUBLE_PRECISION = (
|
||||
Group((keyword("double precision") / (lambda: "double_precision"))("op"))
|
||||
/ to_json_call
|
||||
)
|
||||
NUMERIC = (keyword("numeric")("op") + _sizes) / to_json_call
|
||||
NUMBER = (keyword("number")("op") + _sizes) / to_json_call
|
||||
|
||||
MAP_TYPE = (
|
||||
keyword("map")("op") + LB + delimited_list(simple_types("params")) + RB
|
||||
) / to_json_call
|
||||
ARRAY_TYPE = (keyword("array")("op") + LB + simple_types("params") + RB) / to_json_call
|
||||
|
||||
DATE = keyword("date")
|
||||
DATETIME = keyword("datetime")
|
||||
DATETIME_W_TIMEZONE = keyword("datetime with time zone")
|
||||
TIME = keyword("time")
|
||||
TIMESTAMP = keyword("timestamp")
|
||||
TIMESTAMP_W_TIMEZONE = keyword("timestamp with time zone")
|
||||
TIMESTAMPTZ = keyword("timestamptz")
|
||||
TIMETZ = keyword("timetz")
|
||||
|
||||
time_functions = DATE | DATETIME | TIME | TIMESTAMP | TIMESTAMPTZ | TIMETZ
|
||||
|
||||
# KNOWNN TIME TYPES
|
||||
_format = Optional((ansi_string | ansi_ident)("params"))
|
||||
|
||||
DATE_TYPE = (DATE("op") + _format) / to_json_call
|
||||
DATETIME_TYPE = (DATETIME("op") + _format) / to_json_call
|
||||
DATETIME_W_TIMEZONE_TYPE = (DATETIME_W_TIMEZONE("op") + _format) / to_json_call
|
||||
TIME_TYPE = (TIME("op") + _format) / to_json_call
|
||||
TIMESTAMP_TYPE = (TIMESTAMP("op") + _format) / to_json_call
|
||||
TIMESTAMP_W_TIMEZONE_TYPE = (TIMESTAMP_W_TIMEZONE("op") + _format) / to_json_call
|
||||
TIMESTAMPTZ_TYPE = (TIMESTAMPTZ("op") + _format) / to_json_call
|
||||
TIMETZ_TYPE = (TIMETZ("op") + _format) / to_json_call
|
||||
|
||||
simple_types << MatchFirst([
|
||||
ARRAY_TYPE,
|
||||
BIGINT,
|
||||
BOOL,
|
||||
BOOLEAN,
|
||||
BLOB,
|
||||
BYTES,
|
||||
CHAR,
|
||||
DATE_TYPE,
|
||||
DATETIME_W_TIMEZONE_TYPE,
|
||||
DATETIME_TYPE,
|
||||
DECIMAL,
|
||||
DOUBLE_PRECISION,
|
||||
DOUBLE,
|
||||
FLOAT64,
|
||||
FLOAT,
|
||||
GEOMETRY,
|
||||
MAP_TYPE,
|
||||
INTEGER,
|
||||
INT,
|
||||
INT32,
|
||||
INT64,
|
||||
NCHAR,
|
||||
NUMBER,
|
||||
NUMERIC,
|
||||
REAL,
|
||||
TEXT,
|
||||
SMALLINT,
|
||||
STRING,
|
||||
TIME_TYPE,
|
||||
TIMESTAMP_W_TIMEZONE_TYPE,
|
||||
TIMESTAMP_TYPE,
|
||||
TIMESTAMPTZ_TYPE,
|
||||
TIMETZ_TYPE,
|
||||
TINYINT,
|
||||
UUID,
|
||||
VARCHAR,
|
||||
VARCHAR2,
|
||||
VARBINARY,
|
||||
])
|
||||
|
||||
CASTING = (Literal("::").suppress() + simple_types("params")).set_parser_name("cast")
|
||||
KNOWN_OPS.insert(0, CASTING)
|
||||
|
||||
unary_ops = {
|
||||
NEG: RIGHT_ASSOC,
|
||||
NOT: RIGHT_ASSOC,
|
||||
BINARY_NOT: RIGHT_ASSOC,
|
||||
CASTING: LEFT_ASSOC,
|
||||
}
|
||||
|
||||
|
||||
def get_column_type(expr, var_name, literal_string):
|
||||
column_definition = Forward()
|
||||
column_type = Forward().set_parser_name("column type")
|
||||
|
||||
struct_type = (
|
||||
keyword("struct")("op")
|
||||
+ LT.suppress()
|
||||
+ Group(delimited_list(column_definition))("params")
|
||||
+ GT.suppress()
|
||||
) / to_json_call
|
||||
|
||||
row_type = (
|
||||
keyword("row")("op")
|
||||
+ LB
|
||||
+ Group(delimited_list(column_definition))("params")
|
||||
+ RB
|
||||
) / to_json_call
|
||||
|
||||
array_type = (
|
||||
keyword("array")("op")
|
||||
+ (
|
||||
(
|
||||
LT.suppress()
|
||||
+ Group(delimited_list(column_type))("params")
|
||||
+ GT.suppress()
|
||||
)
|
||||
| (LB + Group(delimited_list(column_type))("params") + RB)
|
||||
)
|
||||
) / to_json_call
|
||||
|
||||
column_type << (struct_type | row_type | array_type | simple_types)
|
||||
|
||||
column_def_identity = (
|
||||
assign(
|
||||
"generated",
|
||||
(keyword("always") | keyword("by default") / (lambda: "by_default")),
|
||||
)
|
||||
+ keyword("as identity").suppress()
|
||||
+ Optional(assign("start with", int_num))
|
||||
+ Optional(assign("increment by", int_num))
|
||||
)
|
||||
|
||||
column_def_references = assign(
|
||||
"references", var_name("table") + LB + delimited_list(var_name)("columns") + RB,
|
||||
)
|
||||
|
||||
column_options = ZeroOrMore(
|
||||
((NOT + NULL) / (lambda: False))("nullable")
|
||||
| (NULL / (lambda t: True))("nullable")
|
||||
| flag("unique")
|
||||
| flag("auto_increment")
|
||||
| assign("comment", literal_string)
|
||||
| assign("collate", Optional(EQ) + var_name)
|
||||
| flag("primary key")
|
||||
| column_def_identity("identity")
|
||||
| column_def_references
|
||||
| assign("check", LB + expr + RB)
|
||||
| assign("default", expr)
|
||||
).set_parser_name("column_options")
|
||||
|
||||
column_definition << Group(
|
||||
var_name("name") + (column_type | var_name)("type") + column_options
|
||||
).set_parser_name("column_definition")
|
||||
|
||||
return column_type, column_definition, column_def_references
|
||||
|
||||
|
||||
export("aquery_parser.utils", unary_ops)
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
|
||||
# KNOWN TYPES
|
||||
from mo_parsing import Forward, Group, Optional, MatchFirst, Literal, ZeroOrMore, export
|
||||
from mo_parsing.infix import delimited_list, RIGHT_ASSOC, LEFT_ASSOC
|
||||
|
||||
from aquery_parser.keywords import (
|
||||
RB,
|
||||
LB,
|
||||
NEG,
|
||||
NOT,
|
||||
BINARY_NOT,
|
||||
NULL,
|
||||
EQ,
|
||||
KNOWN_OPS,
|
||||
LT,
|
||||
GT,
|
||||
)
|
||||
from aquery_parser.utils import (
|
||||
keyword,
|
||||
to_json_call,
|
||||
int_num,
|
||||
ansi_string,
|
||||
ansi_ident,
|
||||
assign,
|
||||
flag,
|
||||
)
|
||||
|
||||
_size = Optional(LB + int_num("params") + RB)
|
||||
_sizes = Optional(LB + delimited_list(int_num("params")) + RB)
|
||||
|
||||
simple_types = Forward()
|
||||
|
||||
BIGINT = Group(keyword("bigint")("op") + Optional(_size)+Optional(flag("unsigned"))) / to_json_call
|
||||
BOOL = Group(keyword("bool")("op")) / to_json_call
|
||||
BOOLEAN = Group(keyword("boolean")("op")) / to_json_call
|
||||
DOUBLE = Group(keyword("double")("op")) / to_json_call
|
||||
FLOAT64 = Group(keyword("float64")("op")) / to_json_call
|
||||
FLOAT = Group(keyword("float")("op")) / to_json_call
|
||||
GEOMETRY = Group(keyword("geometry")("op")) / to_json_call
|
||||
INTEGER = Group(keyword("integer")("op")) / to_json_call
|
||||
INT = (keyword("int")("op") + _size) / to_json_call
|
||||
INT32 = Group(keyword("int32")("op")) / to_json_call
|
||||
INT64 = Group(keyword("int64")("op")) / to_json_call
|
||||
REAL = Group(keyword("real")("op")) / to_json_call
|
||||
TEXT = Group(keyword("text")("op")) / to_json_call
|
||||
SMALLINT = Group(keyword("smallint")("op")) / to_json_call
|
||||
STRING = Group(keyword("string")("op")) / to_json_call
|
||||
|
||||
BLOB = (keyword("blob")("op") + _size) / to_json_call
|
||||
BYTES = (keyword("bytes")("op") + _size) / to_json_call
|
||||
CHAR = (keyword("char")("op") + _size) / to_json_call
|
||||
NCHAR = (keyword("nchar")("op") + _size) / to_json_call
|
||||
VARCHAR = (keyword("varchar")("op") + _size) / to_json_call
|
||||
VARCHAR2 = (keyword("varchar2")("op") + _size) / to_json_call
|
||||
VARBINARY = (keyword("varbinary")("op") + _size) / to_json_call
|
||||
TINYINT = (keyword("tinyint")("op") + _size) / to_json_call
|
||||
UUID = Group(keyword("uuid")("op")) / to_json_call
|
||||
|
||||
DECIMAL = (keyword("decimal")("op") + _sizes) / to_json_call
|
||||
DOUBLE_PRECISION = (
|
||||
Group((keyword("double precision") / (lambda: "double_precision"))("op"))
|
||||
/ to_json_call
|
||||
)
|
||||
NUMERIC = (keyword("numeric")("op") + _sizes) / to_json_call
|
||||
NUMBER = (keyword("number")("op") + _sizes) / to_json_call
|
||||
|
||||
MAP_TYPE = (
|
||||
keyword("map")("op") + LB + delimited_list(simple_types("params")) + RB
|
||||
) / to_json_call
|
||||
ARRAY_TYPE = (keyword("array")("op") + LB + simple_types("params") + RB) / to_json_call
|
||||
|
||||
DATE = keyword("date")
|
||||
DATETIME = keyword("datetime")
|
||||
DATETIME_W_TIMEZONE = keyword("datetime with time zone")
|
||||
TIME = keyword("time")
|
||||
TIMESTAMP = keyword("timestamp")
|
||||
TIMESTAMP_W_TIMEZONE = keyword("timestamp with time zone")
|
||||
TIMESTAMPTZ = keyword("timestamptz")
|
||||
TIMETZ = keyword("timetz")
|
||||
|
||||
time_functions = DATE | DATETIME | TIME | TIMESTAMP | TIMESTAMPTZ | TIMETZ
|
||||
|
||||
# KNOWNN TIME TYPES
|
||||
_format = Optional((ansi_string | ansi_ident)("params"))
|
||||
|
||||
DATE_TYPE = (DATE("op") + _format) / to_json_call
|
||||
DATETIME_TYPE = (DATETIME("op") + _format) / to_json_call
|
||||
DATETIME_W_TIMEZONE_TYPE = (DATETIME_W_TIMEZONE("op") + _format) / to_json_call
|
||||
TIME_TYPE = (TIME("op") + _format) / to_json_call
|
||||
TIMESTAMP_TYPE = (TIMESTAMP("op") + _format) / to_json_call
|
||||
TIMESTAMP_W_TIMEZONE_TYPE = (TIMESTAMP_W_TIMEZONE("op") + _format) / to_json_call
|
||||
TIMESTAMPTZ_TYPE = (TIMESTAMPTZ("op") + _format) / to_json_call
|
||||
TIMETZ_TYPE = (TIMETZ("op") + _format) / to_json_call
|
||||
|
||||
simple_types << MatchFirst([
|
||||
ARRAY_TYPE,
|
||||
BIGINT,
|
||||
BOOL,
|
||||
BOOLEAN,
|
||||
BLOB,
|
||||
BYTES,
|
||||
CHAR,
|
||||
DATE_TYPE,
|
||||
DATETIME_W_TIMEZONE_TYPE,
|
||||
DATETIME_TYPE,
|
||||
DECIMAL,
|
||||
DOUBLE_PRECISION,
|
||||
DOUBLE,
|
||||
FLOAT64,
|
||||
FLOAT,
|
||||
GEOMETRY,
|
||||
MAP_TYPE,
|
||||
INTEGER,
|
||||
INT,
|
||||
INT32,
|
||||
INT64,
|
||||
NCHAR,
|
||||
NUMBER,
|
||||
NUMERIC,
|
||||
REAL,
|
||||
TEXT,
|
||||
SMALLINT,
|
||||
STRING,
|
||||
TIME_TYPE,
|
||||
TIMESTAMP_W_TIMEZONE_TYPE,
|
||||
TIMESTAMP_TYPE,
|
||||
TIMESTAMPTZ_TYPE,
|
||||
TIMETZ_TYPE,
|
||||
TINYINT,
|
||||
UUID,
|
||||
VARCHAR,
|
||||
VARCHAR2,
|
||||
VARBINARY,
|
||||
])
|
||||
|
||||
CASTING = (Literal("::").suppress() + simple_types("params")).set_parser_name("cast")
|
||||
KNOWN_OPS.insert(0, CASTING)
|
||||
|
||||
unary_ops = {
|
||||
NEG: RIGHT_ASSOC,
|
||||
NOT: RIGHT_ASSOC,
|
||||
BINARY_NOT: RIGHT_ASSOC,
|
||||
CASTING: LEFT_ASSOC,
|
||||
}
|
||||
|
||||
|
||||
def get_column_type(expr, var_name, literal_string):
|
||||
column_definition = Forward()
|
||||
column_type = Forward().set_parser_name("column type")
|
||||
|
||||
struct_type = (
|
||||
keyword("struct")("op")
|
||||
+ LT.suppress()
|
||||
+ Group(delimited_list(column_definition))("params")
|
||||
+ GT.suppress()
|
||||
) / to_json_call
|
||||
|
||||
row_type = (
|
||||
keyword("row")("op")
|
||||
+ LB
|
||||
+ Group(delimited_list(column_definition))("params")
|
||||
+ RB
|
||||
) / to_json_call
|
||||
|
||||
array_type = (
|
||||
keyword("array")("op")
|
||||
+ (
|
||||
(
|
||||
LT.suppress()
|
||||
+ Group(delimited_list(column_type))("params")
|
||||
+ GT.suppress()
|
||||
)
|
||||
| (LB + Group(delimited_list(column_type))("params") + RB)
|
||||
)
|
||||
) / to_json_call
|
||||
|
||||
column_type << (struct_type | row_type | array_type | simple_types)
|
||||
|
||||
column_def_identity = (
|
||||
assign(
|
||||
"generated",
|
||||
(keyword("always") | keyword("by default") / (lambda: "by_default")),
|
||||
)
|
||||
+ keyword("as identity").suppress()
|
||||
+ Optional(assign("start with", int_num))
|
||||
+ Optional(assign("increment by", int_num))
|
||||
)
|
||||
|
||||
column_def_references = assign(
|
||||
"references", var_name("table") + LB + delimited_list(var_name)("columns") + RB,
|
||||
)
|
||||
|
||||
column_options = ZeroOrMore(
|
||||
((NOT + NULL) / (lambda: False))("nullable")
|
||||
| (NULL / (lambda t: True))("nullable")
|
||||
| flag("unique")
|
||||
| flag("auto_increment")
|
||||
| assign("comment", literal_string)
|
||||
| assign("collate", Optional(EQ) + var_name)
|
||||
| flag("primary key")
|
||||
| column_def_identity("identity")
|
||||
| column_def_references
|
||||
| assign("check", LB + expr + RB)
|
||||
| assign("default", expr)
|
||||
).set_parser_name("column_options")
|
||||
|
||||
column_definition << Group(
|
||||
var_name("name") + (column_type | var_name)("type") + column_options
|
||||
).set_parser_name("column_definition")
|
||||
|
||||
return column_type, column_definition, column_def_references
|
||||
|
||||
|
||||
export("aquery_parser.utils", unary_ops)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,107 +1,107 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
|
||||
from mo_parsing.infix import delimited_list
|
||||
|
||||
from aquery_parser.keywords import *
|
||||
from aquery_parser.utils import *
|
||||
|
||||
|
||||
# https://docs.microsoft.com/en-us/sql/t-sql/queries/select-over-clause-transact-sql?view=sql-server-ver15
|
||||
|
||||
|
||||
def _to_bound_call(tokens):
|
||||
zero = tokens["zero"]
|
||||
if zero:
|
||||
return {"min": 0, "max": 0}
|
||||
|
||||
direction = scrub(tokens["direction"])
|
||||
limit = scrub(tokens["limit"])
|
||||
if direction == "preceding":
|
||||
if limit == "unbounded":
|
||||
return {"max": 0}
|
||||
elif is_data(limit):
|
||||
return {"min": {"neg": limit}, "max": 0}
|
||||
else:
|
||||
return {"min": -limit, "max": 0}
|
||||
else: # following
|
||||
if limit == "unbounded":
|
||||
return {"min": 0}
|
||||
elif is_data(limit):
|
||||
return {"min": {"neg": limit}, "max": 0}
|
||||
else:
|
||||
return {"min": 0, "max": limit}
|
||||
|
||||
|
||||
def _to_between_call(tokens):
|
||||
minn = scrub(tokens["min"])
|
||||
maxx = scrub(tokens["max"])
|
||||
|
||||
if maxx.get("max") == 0:
|
||||
# following
|
||||
return {
|
||||
"min": minn.get("min"),
|
||||
"max": maxx.get("min"),
|
||||
}
|
||||
elif minn.get("min") == 0:
|
||||
# preceding
|
||||
return {"min": minn.get("max"), "max": maxx.get("max")}
|
||||
else:
|
||||
return {
|
||||
"min": minn.get("min"),
|
||||
"max": maxx.get("max"),
|
||||
}
|
||||
|
||||
|
||||
UNBOUNDED = keyword("unbounded")
|
||||
PRECEDING = keyword("preceding")
|
||||
FOLLOWING = keyword("following")
|
||||
CURRENT_ROW = keyword("current row")
|
||||
ROWS = keyword("rows")
|
||||
RANGE = keyword("range")
|
||||
|
||||
|
||||
def window(expr, var_name, sort_column):
|
||||
bound_row = (
|
||||
CURRENT_ROW("zero")
|
||||
| (UNBOUNDED | int_num)("limit") + (PRECEDING | FOLLOWING)("direction")
|
||||
) / _to_bound_call
|
||||
bound_expr = (
|
||||
CURRENT_ROW("zero")
|
||||
| (UNBOUNDED | expr)("limit") + (PRECEDING | FOLLOWING)("direction")
|
||||
) / _to_bound_call
|
||||
between_row = (
|
||||
BETWEEN + bound_row("min") + AND + bound_row("max")
|
||||
) / _to_between_call
|
||||
between_expr = (
|
||||
BETWEEN + bound_expr("min") + AND + bound_expr("max")
|
||||
) / _to_between_call
|
||||
|
||||
row_clause = (ROWS.suppress() + (between_row | bound_row)) | (
|
||||
RANGE.suppress() + (between_expr | bound_expr)
|
||||
)
|
||||
|
||||
over_clause = (
|
||||
LB
|
||||
+ Optional(PARTITION_BY + delimited_list(Group(expr))("partitionby"))
|
||||
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
||||
+ Optional(row_clause("range"))
|
||||
+ RB
|
||||
)
|
||||
|
||||
window_clause = Optional((
|
||||
WITHIN_GROUP
|
||||
+ LB
|
||||
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
||||
+ RB
|
||||
)("within")) + ((OVER + (over_clause | var_name) / to_over)("over"))
|
||||
|
||||
return window_clause, over_clause
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
|
||||
from mo_parsing.infix import delimited_list
|
||||
|
||||
from aquery_parser.keywords import *
|
||||
from aquery_parser.utils import *
|
||||
|
||||
|
||||
# https://docs.microsoft.com/en-us/sql/t-sql/queries/select-over-clause-transact-sql?view=sql-server-ver15
|
||||
|
||||
|
||||
def _to_bound_call(tokens):
|
||||
zero = tokens["zero"]
|
||||
if zero:
|
||||
return {"min": 0, "max": 0}
|
||||
|
||||
direction = scrub(tokens["direction"])
|
||||
limit = scrub(tokens["limit"])
|
||||
if direction == "preceding":
|
||||
if limit == "unbounded":
|
||||
return {"max": 0}
|
||||
elif is_data(limit):
|
||||
return {"min": {"neg": limit}, "max": 0}
|
||||
else:
|
||||
return {"min": -limit, "max": 0}
|
||||
else: # following
|
||||
if limit == "unbounded":
|
||||
return {"min": 0}
|
||||
elif is_data(limit):
|
||||
return {"min": {"neg": limit}, "max": 0}
|
||||
else:
|
||||
return {"min": 0, "max": limit}
|
||||
|
||||
|
||||
def _to_between_call(tokens):
|
||||
minn = scrub(tokens["min"])
|
||||
maxx = scrub(tokens["max"])
|
||||
|
||||
if maxx.get("max") == 0:
|
||||
# following
|
||||
return {
|
||||
"min": minn.get("min"),
|
||||
"max": maxx.get("min"),
|
||||
}
|
||||
elif minn.get("min") == 0:
|
||||
# preceding
|
||||
return {"min": minn.get("max"), "max": maxx.get("max")}
|
||||
else:
|
||||
return {
|
||||
"min": minn.get("min"),
|
||||
"max": maxx.get("max"),
|
||||
}
|
||||
|
||||
|
||||
UNBOUNDED = keyword("unbounded")
|
||||
PRECEDING = keyword("preceding")
|
||||
FOLLOWING = keyword("following")
|
||||
CURRENT_ROW = keyword("current row")
|
||||
ROWS = keyword("rows")
|
||||
RANGE = keyword("range")
|
||||
|
||||
|
||||
def window(expr, var_name, sort_column):
|
||||
bound_row = (
|
||||
CURRENT_ROW("zero")
|
||||
| (UNBOUNDED | int_num)("limit") + (PRECEDING | FOLLOWING)("direction")
|
||||
) / _to_bound_call
|
||||
bound_expr = (
|
||||
CURRENT_ROW("zero")
|
||||
| (UNBOUNDED | expr)("limit") + (PRECEDING | FOLLOWING)("direction")
|
||||
) / _to_bound_call
|
||||
between_row = (
|
||||
BETWEEN + bound_row("min") + AND + bound_row("max")
|
||||
) / _to_between_call
|
||||
between_expr = (
|
||||
BETWEEN + bound_expr("min") + AND + bound_expr("max")
|
||||
) / _to_between_call
|
||||
|
||||
row_clause = (ROWS.suppress() + (between_row | bound_row)) | (
|
||||
RANGE.suppress() + (between_expr | bound_expr)
|
||||
)
|
||||
|
||||
over_clause = (
|
||||
LB
|
||||
+ Optional(PARTITION_BY + delimited_list(Group(expr))("partitionby"))
|
||||
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
||||
+ Optional(row_clause("range"))
|
||||
+ RB
|
||||
)
|
||||
|
||||
window_clause = Optional((
|
||||
WITHIN_GROUP
|
||||
+ LB
|
||||
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
||||
+ RB
|
||||
)("within")) + ((OVER + (over_clause | var_name) / to_over)("over"))
|
||||
|
||||
return window_clause, over_clause
|
||||
|
@ -1,14 +1,14 @@
|
||||
## Windows
|
||||
- clang-msvc:
|
||||
- "%CXX%" -D_CRT_SECURE_NO_WARNINGS -shared server/server.cpp server/winhelper.cpp server/monetdb_conn.cpp -Imonetdb/msvc -Lmonetdb/msvc -lmonetdbe.lib --std=c++2a -o server.so
|
||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||
- gcc-mingw (link w/ msvc monetdb):
|
||||
- "%CXX%" -shared -fPIC server/server.cpp server/winhelper.cpp server/monetdb_conn.cpp -Imonetdb/msvc msc-plugin/monetdbe.dll --std=c++2a -o server.so
|
||||
- os.add_dll_directory('c:/msys64/usr/bin')
|
||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||
- gcc-mingw (link w/ mingw monetdb, can only load under mingw python):
|
||||
- $(CXX) server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) --std=c++1z -O3 -march=native -o server.so -I./monetdb/msys64 -L./lib -lmonetdbe
|
||||
- add_dll_dir(os.path.abspath('./lib'))
|
||||
- msvc:
|
||||
- D:\gg\vs22\MSBuild\Current\Bin\msbuild "d:\gg\AQuery++\server\server.vcxproj" /p:configuration=Release /p:platform=x64
|
||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||
## Windows
|
||||
- clang-msvc:
|
||||
- "%CXX%" -D_CRT_SECURE_NO_WARNINGS -shared server/server.cpp server/winhelper.cpp server/monetdb_conn.cpp -Imonetdb/msvc -Lmonetdb/msvc -lmonetdbe.lib --std=c++2a -o server.so
|
||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||
- gcc-mingw (link w/ msvc monetdb):
|
||||
- "%CXX%" -shared -fPIC server/server.cpp server/winhelper.cpp server/monetdb_conn.cpp -Imonetdb/msvc msc-plugin/monetdbe.dll --std=c++2a -o server.so
|
||||
- os.add_dll_directory('c:/msys64/usr/bin')
|
||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||
- gcc-mingw (link w/ mingw monetdb, can only load under mingw python):
|
||||
- $(CXX) server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) --std=c++1z -O3 -march=native -o server.so -I./monetdb/msys64 -L./lib -lmonetdbe
|
||||
- add_dll_dir(os.path.abspath('./lib'))
|
||||
- msvc:
|
||||
- D:\gg\vs22\MSBuild\Current\Bin\msbuild "d:\gg\AQuery++\server\server.vcxproj" /p:configuration=Release /p:platform=x64
|
||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||
|
|
@ -1,45 +1,45 @@
|
||||
import mariadb
|
||||
|
||||
class dbconn:
|
||||
def __init__(self) -> None:
|
||||
self.db = None
|
||||
self.cur = None
|
||||
def clear(self):
|
||||
drop_all = f'''
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
SET @tables = NULL;
|
||||
|
||||
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tables
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = '{self.db.database}';
|
||||
|
||||
SET @tables = CONCAT('DROP TABLE ', @tables);
|
||||
PREPARE stmt FROM @tables;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
'''
|
||||
if self.db:
|
||||
if not self.cur:
|
||||
self.cur = self.db.cursor()
|
||||
self.cur.execute(drop_all)
|
||||
|
||||
def connect(self, ip, password = '0508', user = 'root', db = 'db', port = 3306):
|
||||
try:
|
||||
self.db = mariadb.connect(
|
||||
user = user,
|
||||
password = password,
|
||||
host = ip,
|
||||
port = port,
|
||||
database = db
|
||||
)
|
||||
self.cur = self.db.cursor()
|
||||
|
||||
except mariadb.Error as e:
|
||||
print(e)
|
||||
self.db = None
|
||||
self.cur = None
|
||||
|
||||
def exec(self, sql, params = None):
|
||||
import mariadb
|
||||
|
||||
class dbconn:
|
||||
def __init__(self) -> None:
|
||||
self.db = None
|
||||
self.cur = None
|
||||
def clear(self):
|
||||
drop_all = f'''
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
SET @tables = NULL;
|
||||
|
||||
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tables
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = '{self.db.database}';
|
||||
|
||||
SET @tables = CONCAT('DROP TABLE ', @tables);
|
||||
PREPARE stmt FROM @tables;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
'''
|
||||
if self.db:
|
||||
if not self.cur:
|
||||
self.cur = self.db.cursor()
|
||||
self.cur.execute(drop_all)
|
||||
|
||||
def connect(self, ip, password = '0508', user = 'root', db = 'db', port = 3306):
|
||||
try:
|
||||
self.db = mariadb.connect(
|
||||
user = user,
|
||||
password = password,
|
||||
host = ip,
|
||||
port = port,
|
||||
database = db
|
||||
)
|
||||
self.cur = self.db.cursor()
|
||||
|
||||
except mariadb.Error as e:
|
||||
print(e)
|
||||
self.db = None
|
||||
self.cur = None
|
||||
|
||||
def exec(self, sql, params = None):
|
||||
self.cur.execute(sql)
|
@ -1,37 +1,37 @@
|
||||
from engine.ast import Context, ast_node
|
||||
saved_cxt = None
|
||||
|
||||
def initialize(cxt = None, keep = False):
|
||||
global saved_cxt
|
||||
if cxt is None or not keep or type(cxt) is not Context:
|
||||
if saved_cxt is None or not keep:
|
||||
cxt = Context()
|
||||
saved_cxt = cxt
|
||||
else:
|
||||
cxt = saved_cxt
|
||||
cxt.new()
|
||||
|
||||
return cxt
|
||||
|
||||
def generate(ast, cxt):
|
||||
for k in ast.keys():
|
||||
if k in ast_node.types.keys():
|
||||
root = ast_node.types[k](None, ast, cxt)
|
||||
|
||||
def exec(stmts, cxt = None, keep = None):
|
||||
cxt = initialize(cxt, keep)
|
||||
stmts_stmts = stmts['stmts']
|
||||
if type(stmts_stmts) is list:
|
||||
for s in stmts_stmts:
|
||||
generate(s, cxt)
|
||||
else:
|
||||
generate(stmts_stmts, cxt)
|
||||
|
||||
cxt.Info(cxt.ccode)
|
||||
with open('out.cpp', 'wb') as outfile:
|
||||
outfile.write((cxt.finalize()).encode('utf-8'))
|
||||
|
||||
return cxt
|
||||
|
||||
|
||||
__all__ = ["initialize", "generate", "exec", "saved_cxt"]
|
||||
from engine.ast import Context, ast_node
|
||||
saved_cxt = None
|
||||
|
||||
def initialize(cxt = None, keep = False):
|
||||
global saved_cxt
|
||||
if cxt is None or not keep or type(cxt) is not Context:
|
||||
if saved_cxt is None or not keep:
|
||||
cxt = Context()
|
||||
saved_cxt = cxt
|
||||
else:
|
||||
cxt = saved_cxt
|
||||
cxt.new()
|
||||
|
||||
return cxt
|
||||
|
||||
def generate(ast, cxt):
|
||||
for k in ast.keys():
|
||||
if k in ast_node.types.keys():
|
||||
root = ast_node.types[k](None, ast, cxt)
|
||||
|
||||
def exec(stmts, cxt = None, keep = None):
|
||||
cxt = initialize(cxt, keep)
|
||||
stmts_stmts = stmts['stmts']
|
||||
if type(stmts_stmts) is list:
|
||||
for s in stmts_stmts:
|
||||
generate(s, cxt)
|
||||
else:
|
||||
generate(stmts_stmts, cxt)
|
||||
|
||||
cxt.Info(cxt.ccode)
|
||||
with open('out.cpp', 'wb') as outfile:
|
||||
outfile.write((cxt.finalize()).encode('utf-8'))
|
||||
|
||||
return cxt
|
||||
|
||||
|
||||
__all__ = ["initialize", "generate", "exec", "saved_cxt"]
|
||||
|
@ -1,373 +1,373 @@
|
||||
from engine.utils import base62uuid
|
||||
from copy import copy
|
||||
from typing import *
|
||||
# replace column info with this later.
|
||||
class ColRef:
|
||||
def __init__(self, cname, _ty, cobj, cnt, table:'TableInfo', name, id, compound = False):
|
||||
self.cname = cname # column object location
|
||||
self.cxt_name = None # column object in context
|
||||
self.type = _ty
|
||||
self.cobj = cobj
|
||||
self.cnt = cnt
|
||||
self.table = table
|
||||
self.name = name
|
||||
self.id = id # position in table
|
||||
self.order_pending = None # order_pending
|
||||
self.compound = compound # compound field (list as a field)
|
||||
self.views = []
|
||||
self.aux_columns = [] # columns for temperary calculations
|
||||
# e.g. order by, group by, filter by expressions
|
||||
|
||||
self.__arr__ = (cname, _ty, cobj, cnt, table, name, id)
|
||||
|
||||
def reference(self):
|
||||
cxt = self.table.cxt
|
||||
self.table.reference()
|
||||
if self not in cxt.columns_in_context:
|
||||
counter = 0
|
||||
base_name = self.table.table_name + '_' + self.name
|
||||
if base_name in cxt.columns_in_context.values():
|
||||
while (f'{base_name}_{counter}') in cxt.columns_in_context.values():
|
||||
counter += 1
|
||||
base_name = f'{base_name}_{counter}'
|
||||
self.cxt_name = base_name
|
||||
cxt.columns_in_context[self] = base_name
|
||||
# TODO: change this to cname;
|
||||
cxt.emit(f'auto& {base_name} = *(ColRef<{self.type}> *)(&{self.table.cxt_name}->colrefs[{self.id}]);')
|
||||
elif self.cxt_name is None:
|
||||
self.cxt_name = cxt.columns_in_context[self]
|
||||
|
||||
return self.cxt_name
|
||||
|
||||
def __getitem__(self, key):
|
||||
if type(key) is str:
|
||||
return getattr(self, key)
|
||||
else:
|
||||
return self.__arr__[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.__arr__[key] = value
|
||||
|
||||
def __str__(self):
|
||||
return self.reference()
|
||||
def __repr__(self):
|
||||
return self.reference()
|
||||
|
||||
class TableInfo:
|
||||
|
||||
def __init__(self, table_name, cols, cxt:'Context'):
|
||||
# statics
|
||||
self.table_name = table_name
|
||||
self.alias = set([table_name])
|
||||
self.columns_byname = dict() # column_name, type
|
||||
self.columns = []
|
||||
self.cxt = cxt
|
||||
self.cxt_name = None
|
||||
self.views = set()
|
||||
#keep track of temp vars
|
||||
self.local_vars = dict()
|
||||
self.rec = None # a hook on get_col_d to record tables being referenced in the process
|
||||
self.groupinfo = None
|
||||
self.add_cols(cols)
|
||||
# runtime
|
||||
self.n_rows = 0 # number of cols
|
||||
self.order = [] # assumptions
|
||||
|
||||
cxt.tables_byname[self.table_name] = self # construct reverse map
|
||||
def reference(self):
|
||||
if self not in self.cxt.tables_in_context:
|
||||
counter = 0
|
||||
base_name = self.table_name
|
||||
if base_name in self.cxt.tables_in_context.values():
|
||||
while (f'{base_name}_{counter}') in self.cxt.tables_in_context.values():
|
||||
counter += 1
|
||||
base_name = f'{base_name}_{counter}'
|
||||
self.cxt_name = base_name
|
||||
self.cxt.tables_in_context[self] = base_name
|
||||
|
||||
type_tags = '<'
|
||||
for c in self.columns:
|
||||
type_tags += c.type + ','
|
||||
if type_tags.endswith(','):
|
||||
type_tags = type_tags[:-1]
|
||||
type_tags += '>'
|
||||
|
||||
self.cxt.emit(f'auto& {base_name} = *(TableInfo{type_tags} *)(cxt->tables["{self.table_name}"]);')
|
||||
return self.cxt_name
|
||||
def refer_all(self):
|
||||
self.reference()
|
||||
for c in self.columns:
|
||||
c.reference()
|
||||
def add_cols(self, cols, new = True):
|
||||
for i, c in enumerate(cols):
|
||||
self.add_col(c, new, i)
|
||||
def add_col(self, c, new = True, i = 0):
|
||||
_ty = c['type']
|
||||
if new:
|
||||
cname =f'get<{i}>({self.table_name})'
|
||||
_ty = _ty if type(c) is ColRef else list(_ty.keys())[0]
|
||||
col_object = ColRef(cname, _ty, c, 1, self,c['name'], len(self.columns))
|
||||
else:
|
||||
col_object = c
|
||||
cname = c.cname
|
||||
c.table = self
|
||||
self.cxt.ccols_byname[cname] = col_object
|
||||
self.columns_byname[c['name']] = col_object
|
||||
self.columns.append(col_object)
|
||||
def get_size(self):
|
||||
size_tmp = 'tmp_sz_'+base62uuid(6)
|
||||
self.cxt.emit(f'const auto& {size_tmp} = {self.columns[0].reference()}.size;')
|
||||
return size_tmp
|
||||
@property
|
||||
def n_cols(self):
|
||||
return len(self.columns)
|
||||
|
||||
def materialize_orderbys(self):
|
||||
view_stack = ''
|
||||
stack_name = ''
|
||||
for o in self.order:
|
||||
o.materialize()
|
||||
if len(view_stack) == 0:
|
||||
view_stack = o.view.name
|
||||
stack_name = view_stack
|
||||
else:
|
||||
view_stack = view_stack+'['+ o.view.name +']'
|
||||
# TODO: Optimize by doing everything in a stmt
|
||||
if len(view_stack) > 0:
|
||||
if len(self.order) > 1:
|
||||
self.cxt.emit(f'{stack_name}:{view_stack}')
|
||||
for c in self.columns:
|
||||
c.order_pending = stack_name
|
||||
self.order[0].node.view = stack_name
|
||||
self.order.clear()
|
||||
|
||||
def get_col_d(self, col_name):
|
||||
col = self.columns_byname[col_name]
|
||||
if type(self.rec) is set:
|
||||
self.rec.add(col)
|
||||
return col
|
||||
|
||||
def get_ccolname_d(self, col_name):
|
||||
return self.get_col_d(col_name).cname
|
||||
|
||||
def get_col(self, col_name):
|
||||
self.materialize_orderbys()
|
||||
col = self.get_col_d(col_name)
|
||||
if type(col.order_pending) is str:
|
||||
self.cxt.emit_no_flush(f'{col.cname}:{col.cname}[{col.order_pending}]')
|
||||
col.order_pending = None
|
||||
return col
|
||||
def get_ccolname(self, col_name):
|
||||
return self.get_col(col_name).cname
|
||||
|
||||
def add_alias(self, alias):
|
||||
# TODO: Scoping of alias should be constrainted in the query.
|
||||
if alias in self.cxt.tables_byname.keys():
|
||||
print("Error: table alias already exists")
|
||||
return
|
||||
self.cxt.tables_byname[alias] = self
|
||||
self.alias.add(alias)
|
||||
|
||||
def parse_col_names(self, colExpr, materialize = True, raw = False):
|
||||
# get_col = self.get_col if materialize else self.get_col_d
|
||||
|
||||
parsedColExpr = colExpr.split('.')
|
||||
ret = None
|
||||
if len(parsedColExpr) <= 1:
|
||||
ret = self.get_col_d(colExpr)
|
||||
else:
|
||||
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
||||
if datasource is None:
|
||||
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
||||
else:
|
||||
ret = datasource.parse_col_names(parsedColExpr[1], raw)
|
||||
from engine.expr import index_expr
|
||||
string = ret.reference() + index_expr
|
||||
if self.groupinfo is not None and ret and ret in self.groupinfo.raw_groups:
|
||||
string = f'get<{self.groupinfo.raw_groups.index(ret)}>({{y}})'
|
||||
return string, ret if raw else string
|
||||
|
||||
class View:
|
||||
def __init__(self, context, table = None, tmp = True):
|
||||
self.table: TableInfo = table
|
||||
self.name = 'v'+base62uuid(7)
|
||||
if type(table) is TableInfo:
|
||||
table.views.add(self)
|
||||
self.context = context
|
||||
|
||||
def construct(self):
|
||||
self.context.emit(f'{self.name}:()')
|
||||
|
||||
class Context:
|
||||
function_head = '''
|
||||
extern "C" int __DLLEXPORT__ dllmain(Context* cxt) {
|
||||
using namespace std;
|
||||
using namespace types;
|
||||
|
||||
'''
|
||||
LOG_INFO = 'INFO'
|
||||
LOG_ERROR = 'ERROR'
|
||||
LOG_SILENT = 'SILENT'
|
||||
from engine.types import Types
|
||||
type_table : Dict[str, Types] = dict()
|
||||
|
||||
def new(self):
|
||||
self.tmp_names = set()
|
||||
self.udf_map = dict()
|
||||
self.headers = set(['\"./server/libaquery.h\"'])
|
||||
self.finalized = False
|
||||
# read header
|
||||
self.ccode = str()
|
||||
self.ccodelet = str()
|
||||
with open('header.cxx', 'r') as outfile:
|
||||
self.ccode = outfile.read()
|
||||
# datasource will be availible after `from' clause is parsed
|
||||
# and will be deactivated when the `from' is out of scope
|
||||
self.datasource = None
|
||||
self.ds_stack = []
|
||||
self.scans = []
|
||||
self.removing_scan = False
|
||||
|
||||
def __init__(self):
|
||||
self.tables:list[TableInfo] = []
|
||||
self.tables_byname = dict()
|
||||
self.ccols_byname = dict()
|
||||
self.gc_name = 'gc_' + base62uuid(4)
|
||||
self.tmp_names = set()
|
||||
self.udf_map = dict()
|
||||
self.headers = set(['\"./server/libaquery.h\"'])
|
||||
self.finalized = False
|
||||
self.log_level = Context.LOG_SILENT
|
||||
self.print = print
|
||||
# read header
|
||||
self.ccode = str()
|
||||
self.ccodelet = str()
|
||||
self.columns_in_context = dict()
|
||||
self.tables_in_context = dict()
|
||||
with open('header.cxx', 'r') as outfile:
|
||||
self.ccode = outfile.read()
|
||||
# datasource will be availible after `from' clause is parsed
|
||||
# and will be deactivated when the `from' is out of scope
|
||||
self.datasource = None
|
||||
self.ds_stack = []
|
||||
self.scans = []
|
||||
self.removing_scan = False
|
||||
def add_table(self, table_name, cols):
|
||||
tbl = TableInfo(table_name, cols, self)
|
||||
self.tables.append(tbl)
|
||||
return tbl
|
||||
|
||||
def gen_tmptable(self):
|
||||
from engine.utils import base62uuid
|
||||
return f't{base62uuid(7)}'
|
||||
def reg_tmp(self, name, f):
|
||||
self.tmp_names.add(name)
|
||||
self.emit(f"{self.gc_name}.reg({{{name}, 0,0{'' if f is None else ',{f}'}}});")
|
||||
|
||||
def define_tmp(self, typename, isPtr = True, f = None):
|
||||
name = 'tmp_' + base62uuid()
|
||||
if isPtr:
|
||||
self.emit(f'auto* {name} = new {typename};')
|
||||
self.reg_tmp(name, f)
|
||||
else:
|
||||
self.emit(f'auto {name} = {typename};')
|
||||
return name
|
||||
def emit(self, codelet):
|
||||
self.ccode += self.ccodelet + codelet + '\n'
|
||||
self.ccodelet = ''
|
||||
def emit_no_flush(self, codelet):
|
||||
self.ccode += codelet + '\n'
|
||||
def emit_flush(self):
|
||||
self.ccode += self.ccodelet + '\n'
|
||||
self.ccodelet = ''
|
||||
def emit_nonewline(self, codelet):
|
||||
self.ccodelet += codelet
|
||||
|
||||
def datsource_top(self):
|
||||
if len(self.ds_stack) > 0:
|
||||
return self.ds_stack[-1]
|
||||
else:
|
||||
return None
|
||||
def datasource_pop(self):
|
||||
if len(self.ds_stack) > 0:
|
||||
self.ds_stack.pop()
|
||||
return self.ds_stack[-1]
|
||||
else:
|
||||
return None
|
||||
def datasource_push(self, ds):
|
||||
if type(ds) is TableInfo:
|
||||
self.ds_stack.append(ds)
|
||||
return ds
|
||||
else:
|
||||
return None
|
||||
def remove_scan(self, scan, str_scan):
|
||||
self.emit(str_scan)
|
||||
self.scans.remove(scan)
|
||||
|
||||
def Info(self, msg):
|
||||
if self.log_level.upper() == Context.LOG_INFO:
|
||||
self.print(msg)
|
||||
def Error(self, msg):
|
||||
if self.log_level.upper() == Context.LOG_ERROR:
|
||||
self.print(msg)
|
||||
else:
|
||||
self.Info(self, msg)
|
||||
|
||||
|
||||
def finalize(self):
|
||||
if not self.finalized:
|
||||
headers = ''
|
||||
for h in self.headers:
|
||||
if h[0] != '"':
|
||||
headers += '#include <' + h + '>\n'
|
||||
else:
|
||||
headers += '#include ' + h + '\n'
|
||||
self.ccode = headers + self.function_head + self.ccode + 'return 0;\n}'
|
||||
self.headers = set()
|
||||
return self.ccode
|
||||
def __str__(self):
|
||||
self.finalize()
|
||||
return self.ccode
|
||||
def __repr__(self) -> str:
|
||||
return self.__str__()
|
||||
|
||||
|
||||
class ast_node:
|
||||
types = dict()
|
||||
header = []
|
||||
def __init__(self, parent:"ast_node", node, context:Context = None):
|
||||
self.context = parent.context if context is None else context
|
||||
self.parent = parent
|
||||
self.datasource = None
|
||||
self.init(node)
|
||||
self.produce(node)
|
||||
self.spawn(node)
|
||||
self.consume(node)
|
||||
|
||||
def emit(self, code):
|
||||
self.context.emit(code)
|
||||
def emit_no_ln(self, code):
|
||||
self.context.emit_nonewline(code)
|
||||
|
||||
name = 'null'
|
||||
|
||||
# each ast node has 3 stages.
|
||||
# `produce' generates info for child nodes
|
||||
# `spawn' populates child nodes
|
||||
# `consume' consumes info from child nodes and finalizes codegen
|
||||
# For simple operators, there may not be need for some of these stages
|
||||
def init(self, _):
|
||||
pass
|
||||
def produce(self, _):
|
||||
pass
|
||||
def spawn(self, _):
|
||||
pass
|
||||
def consume(self, _):
|
||||
pass
|
||||
|
||||
# include classes in module as first order operators
|
||||
def include(objs):
|
||||
import inspect
|
||||
for _, cls in inspect.getmembers(objs):
|
||||
if inspect.isclass(cls) and issubclass(cls, ast_node) and not cls.name.startswith('_'):
|
||||
from engine.utils import base62uuid
|
||||
from copy import copy
|
||||
from typing import *
|
||||
# replace column info with this later.
|
||||
class ColRef:
|
||||
def __init__(self, cname, _ty, cobj, cnt, table:'TableInfo', name, id, compound = False):
|
||||
self.cname = cname # column object location
|
||||
self.cxt_name = None # column object in context
|
||||
self.type = _ty
|
||||
self.cobj = cobj
|
||||
self.cnt = cnt
|
||||
self.table = table
|
||||
self.name = name
|
||||
self.id = id # position in table
|
||||
self.order_pending = None # order_pending
|
||||
self.compound = compound # compound field (list as a field)
|
||||
self.views = []
|
||||
self.aux_columns = [] # columns for temperary calculations
|
||||
# e.g. order by, group by, filter by expressions
|
||||
|
||||
self.__arr__ = (cname, _ty, cobj, cnt, table, name, id)
|
||||
|
||||
def reference(self):
|
||||
cxt = self.table.cxt
|
||||
self.table.reference()
|
||||
if self not in cxt.columns_in_context:
|
||||
counter = 0
|
||||
base_name = self.table.table_name + '_' + self.name
|
||||
if base_name in cxt.columns_in_context.values():
|
||||
while (f'{base_name}_{counter}') in cxt.columns_in_context.values():
|
||||
counter += 1
|
||||
base_name = f'{base_name}_{counter}'
|
||||
self.cxt_name = base_name
|
||||
cxt.columns_in_context[self] = base_name
|
||||
# TODO: change this to cname;
|
||||
cxt.emit(f'auto& {base_name} = *(ColRef<{self.type}> *)(&{self.table.cxt_name}->colrefs[{self.id}]);')
|
||||
elif self.cxt_name is None:
|
||||
self.cxt_name = cxt.columns_in_context[self]
|
||||
|
||||
return self.cxt_name
|
||||
|
||||
def __getitem__(self, key):
|
||||
if type(key) is str:
|
||||
return getattr(self, key)
|
||||
else:
|
||||
return self.__arr__[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.__arr__[key] = value
|
||||
|
||||
def __str__(self):
|
||||
return self.reference()
|
||||
def __repr__(self):
|
||||
return self.reference()
|
||||
|
||||
class TableInfo:
|
||||
|
||||
def __init__(self, table_name, cols, cxt:'Context'):
|
||||
# statics
|
||||
self.table_name = table_name
|
||||
self.alias = set([table_name])
|
||||
self.columns_byname = dict() # column_name, type
|
||||
self.columns = []
|
||||
self.cxt = cxt
|
||||
self.cxt_name = None
|
||||
self.views = set()
|
||||
#keep track of temp vars
|
||||
self.local_vars = dict()
|
||||
self.rec = None # a hook on get_col_d to record tables being referenced in the process
|
||||
self.groupinfo = None
|
||||
self.add_cols(cols)
|
||||
# runtime
|
||||
self.n_rows = 0 # number of cols
|
||||
self.order = [] # assumptions
|
||||
|
||||
cxt.tables_byname[self.table_name] = self # construct reverse map
|
||||
def reference(self):
|
||||
if self not in self.cxt.tables_in_context:
|
||||
counter = 0
|
||||
base_name = self.table_name
|
||||
if base_name in self.cxt.tables_in_context.values():
|
||||
while (f'{base_name}_{counter}') in self.cxt.tables_in_context.values():
|
||||
counter += 1
|
||||
base_name = f'{base_name}_{counter}'
|
||||
self.cxt_name = base_name
|
||||
self.cxt.tables_in_context[self] = base_name
|
||||
|
||||
type_tags = '<'
|
||||
for c in self.columns:
|
||||
type_tags += c.type + ','
|
||||
if type_tags.endswith(','):
|
||||
type_tags = type_tags[:-1]
|
||||
type_tags += '>'
|
||||
|
||||
self.cxt.emit(f'auto& {base_name} = *(TableInfo{type_tags} *)(cxt->tables["{self.table_name}"]);')
|
||||
return self.cxt_name
|
||||
def refer_all(self):
|
||||
self.reference()
|
||||
for c in self.columns:
|
||||
c.reference()
|
||||
def add_cols(self, cols, new = True):
|
||||
for i, c in enumerate(cols):
|
||||
self.add_col(c, new, i)
|
||||
def add_col(self, c, new = True, i = 0):
|
||||
_ty = c['type']
|
||||
if new:
|
||||
cname =f'get<{i}>({self.table_name})'
|
||||
_ty = _ty if type(c) is ColRef else list(_ty.keys())[0]
|
||||
col_object = ColRef(cname, _ty, c, 1, self,c['name'], len(self.columns))
|
||||
else:
|
||||
col_object = c
|
||||
cname = c.cname
|
||||
c.table = self
|
||||
self.cxt.ccols_byname[cname] = col_object
|
||||
self.columns_byname[c['name']] = col_object
|
||||
self.columns.append(col_object)
|
||||
def get_size(self):
|
||||
size_tmp = 'tmp_sz_'+base62uuid(6)
|
||||
self.cxt.emit(f'const auto& {size_tmp} = {self.columns[0].reference()}.size;')
|
||||
return size_tmp
|
||||
@property
|
||||
def n_cols(self):
|
||||
return len(self.columns)
|
||||
|
||||
def materialize_orderbys(self):
|
||||
view_stack = ''
|
||||
stack_name = ''
|
||||
for o in self.order:
|
||||
o.materialize()
|
||||
if len(view_stack) == 0:
|
||||
view_stack = o.view.name
|
||||
stack_name = view_stack
|
||||
else:
|
||||
view_stack = view_stack+'['+ o.view.name +']'
|
||||
# TODO: Optimize by doing everything in a stmt
|
||||
if len(view_stack) > 0:
|
||||
if len(self.order) > 1:
|
||||
self.cxt.emit(f'{stack_name}:{view_stack}')
|
||||
for c in self.columns:
|
||||
c.order_pending = stack_name
|
||||
self.order[0].node.view = stack_name
|
||||
self.order.clear()
|
||||
|
||||
def get_col_d(self, col_name):
|
||||
col = self.columns_byname[col_name]
|
||||
if type(self.rec) is set:
|
||||
self.rec.add(col)
|
||||
return col
|
||||
|
||||
def get_ccolname_d(self, col_name):
|
||||
return self.get_col_d(col_name).cname
|
||||
|
||||
def get_col(self, col_name):
|
||||
self.materialize_orderbys()
|
||||
col = self.get_col_d(col_name)
|
||||
if type(col.order_pending) is str:
|
||||
self.cxt.emit_no_flush(f'{col.cname}:{col.cname}[{col.order_pending}]')
|
||||
col.order_pending = None
|
||||
return col
|
||||
def get_ccolname(self, col_name):
|
||||
return self.get_col(col_name).cname
|
||||
|
||||
def add_alias(self, alias):
|
||||
# TODO: Scoping of alias should be constrainted in the query.
|
||||
if alias in self.cxt.tables_byname.keys():
|
||||
print("Error: table alias already exists")
|
||||
return
|
||||
self.cxt.tables_byname[alias] = self
|
||||
self.alias.add(alias)
|
||||
|
||||
def parse_col_names(self, colExpr, materialize = True, raw = False):
|
||||
# get_col = self.get_col if materialize else self.get_col_d
|
||||
|
||||
parsedColExpr = colExpr.split('.')
|
||||
ret = None
|
||||
if len(parsedColExpr) <= 1:
|
||||
ret = self.get_col_d(colExpr)
|
||||
else:
|
||||
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
||||
if datasource is None:
|
||||
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
||||
else:
|
||||
ret = datasource.parse_col_names(parsedColExpr[1], raw)
|
||||
from engine.expr import index_expr
|
||||
string = ret.reference() + index_expr
|
||||
if self.groupinfo is not None and ret and ret in self.groupinfo.raw_groups:
|
||||
string = f'get<{self.groupinfo.raw_groups.index(ret)}>({{y}})'
|
||||
return string, ret if raw else string
|
||||
|
||||
class View:
|
||||
def __init__(self, context, table = None, tmp = True):
|
||||
self.table: TableInfo = table
|
||||
self.name = 'v'+base62uuid(7)
|
||||
if type(table) is TableInfo:
|
||||
table.views.add(self)
|
||||
self.context = context
|
||||
|
||||
def construct(self):
|
||||
self.context.emit(f'{self.name}:()')
|
||||
|
||||
class Context:
|
||||
function_head = '''
|
||||
extern "C" int __DLLEXPORT__ dllmain(Context* cxt) {
|
||||
using namespace std;
|
||||
using namespace types;
|
||||
|
||||
'''
|
||||
LOG_INFO = 'INFO'
|
||||
LOG_ERROR = 'ERROR'
|
||||
LOG_SILENT = 'SILENT'
|
||||
from engine.types import Types
|
||||
type_table : Dict[str, Types] = dict()
|
||||
|
||||
def new(self):
|
||||
self.tmp_names = set()
|
||||
self.udf_map = dict()
|
||||
self.headers = set(['\"./server/libaquery.h\"'])
|
||||
self.finalized = False
|
||||
# read header
|
||||
self.ccode = str()
|
||||
self.ccodelet = str()
|
||||
with open('header.cxx', 'r') as outfile:
|
||||
self.ccode = outfile.read()
|
||||
# datasource will be availible after `from' clause is parsed
|
||||
# and will be deactivated when the `from' is out of scope
|
||||
self.datasource = None
|
||||
self.ds_stack = []
|
||||
self.scans = []
|
||||
self.removing_scan = False
|
||||
|
||||
def __init__(self):
|
||||
self.tables:list[TableInfo] = []
|
||||
self.tables_byname = dict()
|
||||
self.ccols_byname = dict()
|
||||
self.gc_name = 'gc_' + base62uuid(4)
|
||||
self.tmp_names = set()
|
||||
self.udf_map = dict()
|
||||
self.headers = set(['\"./server/libaquery.h\"'])
|
||||
self.finalized = False
|
||||
self.log_level = Context.LOG_SILENT
|
||||
self.print = print
|
||||
# read header
|
||||
self.ccode = str()
|
||||
self.ccodelet = str()
|
||||
self.columns_in_context = dict()
|
||||
self.tables_in_context = dict()
|
||||
with open('header.cxx', 'r') as outfile:
|
||||
self.ccode = outfile.read()
|
||||
# datasource will be availible after `from' clause is parsed
|
||||
# and will be deactivated when the `from' is out of scope
|
||||
self.datasource = None
|
||||
self.ds_stack = []
|
||||
self.scans = []
|
||||
self.removing_scan = False
|
||||
def add_table(self, table_name, cols):
|
||||
tbl = TableInfo(table_name, cols, self)
|
||||
self.tables.append(tbl)
|
||||
return tbl
|
||||
|
||||
def gen_tmptable(self):
|
||||
from engine.utils import base62uuid
|
||||
return f't{base62uuid(7)}'
|
||||
def reg_tmp(self, name, f):
|
||||
self.tmp_names.add(name)
|
||||
self.emit(f"{self.gc_name}.reg({{{name}, 0,0{'' if f is None else ',{f}'}}});")
|
||||
|
||||
def define_tmp(self, typename, isPtr = True, f = None):
|
||||
name = 'tmp_' + base62uuid()
|
||||
if isPtr:
|
||||
self.emit(f'auto* {name} = new {typename};')
|
||||
self.reg_tmp(name, f)
|
||||
else:
|
||||
self.emit(f'auto {name} = {typename};')
|
||||
return name
|
||||
def emit(self, codelet):
|
||||
self.ccode += self.ccodelet + codelet + '\n'
|
||||
self.ccodelet = ''
|
||||
def emit_no_flush(self, codelet):
|
||||
self.ccode += codelet + '\n'
|
||||
def emit_flush(self):
|
||||
self.ccode += self.ccodelet + '\n'
|
||||
self.ccodelet = ''
|
||||
def emit_nonewline(self, codelet):
|
||||
self.ccodelet += codelet
|
||||
|
||||
def datsource_top(self):
|
||||
if len(self.ds_stack) > 0:
|
||||
return self.ds_stack[-1]
|
||||
else:
|
||||
return None
|
||||
def datasource_pop(self):
|
||||
if len(self.ds_stack) > 0:
|
||||
self.ds_stack.pop()
|
||||
return self.ds_stack[-1]
|
||||
else:
|
||||
return None
|
||||
def datasource_push(self, ds):
|
||||
if type(ds) is TableInfo:
|
||||
self.ds_stack.append(ds)
|
||||
return ds
|
||||
else:
|
||||
return None
|
||||
def remove_scan(self, scan, str_scan):
|
||||
self.emit(str_scan)
|
||||
self.scans.remove(scan)
|
||||
|
||||
def Info(self, msg):
|
||||
if self.log_level.upper() == Context.LOG_INFO:
|
||||
self.print(msg)
|
||||
def Error(self, msg):
|
||||
if self.log_level.upper() == Context.LOG_ERROR:
|
||||
self.print(msg)
|
||||
else:
|
||||
self.Info(self, msg)
|
||||
|
||||
|
||||
def finalize(self):
|
||||
if not self.finalized:
|
||||
headers = ''
|
||||
for h in self.headers:
|
||||
if h[0] != '"':
|
||||
headers += '#include <' + h + '>\n'
|
||||
else:
|
||||
headers += '#include ' + h + '\n'
|
||||
self.ccode = headers + self.function_head + self.ccode + 'return 0;\n}'
|
||||
self.headers = set()
|
||||
return self.ccode
|
||||
def __str__(self):
|
||||
self.finalize()
|
||||
return self.ccode
|
||||
def __repr__(self) -> str:
|
||||
return self.__str__()
|
||||
|
||||
|
||||
class ast_node:
|
||||
types = dict()
|
||||
header = []
|
||||
def __init__(self, parent:"ast_node", node, context:Context = None):
|
||||
self.context = parent.context if context is None else context
|
||||
self.parent = parent
|
||||
self.datasource = None
|
||||
self.init(node)
|
||||
self.produce(node)
|
||||
self.spawn(node)
|
||||
self.consume(node)
|
||||
|
||||
def emit(self, code):
|
||||
self.context.emit(code)
|
||||
def emit_no_ln(self, code):
|
||||
self.context.emit_nonewline(code)
|
||||
|
||||
name = 'null'
|
||||
|
||||
# each ast node has 3 stages.
|
||||
# `produce' generates info for child nodes
|
||||
# `spawn' populates child nodes
|
||||
# `consume' consumes info from child nodes and finalizes codegen
|
||||
# For simple operators, there may not be need for some of these stages
|
||||
def init(self, _):
|
||||
pass
|
||||
def produce(self, _):
|
||||
pass
|
||||
def spawn(self, _):
|
||||
pass
|
||||
def consume(self, _):
|
||||
pass
|
||||
|
||||
# include classes in module as first order operators
|
||||
def include(objs):
|
||||
import inspect
|
||||
for _, cls in inspect.getmembers(objs):
|
||||
if inspect.isclass(cls) and issubclass(cls, ast_node) and not cls.name.startswith('_'):
|
||||
ast_node.types[cls.name] = cls
|
@ -1,128 +1,128 @@
|
||||
# code-gen for data decl languages
|
||||
|
||||
from engine.orderby import orderby
|
||||
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
||||
from engine.scan import scan
|
||||
from engine.utils import base62uuid
|
||||
|
||||
class create_table(ast_node):
|
||||
name = 'create_table'
|
||||
def __init__(self, parent: "ast_node", node, context: Context = None, cexprs = None, lineage = False):
|
||||
self.cexprs = cexprs
|
||||
self.lineage = lineage
|
||||
super().__init__(parent, node, context)
|
||||
def produce(self, node):
|
||||
if type(node) is not TableInfo:
|
||||
ct = node[self.name]
|
||||
tbl = self.context.add_table(ct['name'], ct['columns'])
|
||||
else:
|
||||
tbl = node
|
||||
|
||||
col_type_str = ','.join([c.type for c in tbl.columns])
|
||||
# create tables in c
|
||||
self.emit(f"auto {tbl.table_name} = new TableInfo<{col_type_str}>(\"{tbl.table_name}\", {tbl.n_cols});")
|
||||
self.emit("cxt->tables.insert({\"" + tbl.table_name + f"\", {tbl.table_name}"+"});")
|
||||
self.context.tables_in_context[tbl] = tbl.table_name
|
||||
tbl.cxt_name = tbl.table_name
|
||||
tbl.refer_all()
|
||||
# create an empty new table
|
||||
if self.cexprs is None:
|
||||
for c in tbl.columns:
|
||||
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
||||
# create an output table
|
||||
else:
|
||||
# 1 to 1 lineage.
|
||||
if len(self.context.scans) == 0:
|
||||
if self.lineage:
|
||||
order = 'order_' + base62uuid(6)
|
||||
self.emit(f'auto {order} = {self.parent.datasource.cxt_name}->order_by<{orderby(self.parent, self.parent.assumptions).result()}>();')
|
||||
self.lineage = '*' + order
|
||||
else:
|
||||
self.lineage = None
|
||||
for i, c in enumerate(tbl.columns):
|
||||
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
||||
self.emit(f"{c.cxt_name} = {self.cexprs[i](self.lineage)};")
|
||||
self.lineage = None
|
||||
self.parent.assumptions = None
|
||||
else:
|
||||
scanner:scan = self.context.scans[-1]
|
||||
if self.lineage:
|
||||
lineage_var = 'lineage_' + base62uuid(6)
|
||||
counter_var = 'counter_' + base62uuid(6)
|
||||
scanner.add(f'auto {lineage_var} = {self.datasource.cxt_name}->bind({tbl.cxt_name});', "init")
|
||||
scanner.add(f'auto {counter_var} = 0;', "init")
|
||||
scanner.add(f"{lineage_var}.emplace_back({counter_var}++);", "front")
|
||||
self.lineage = f"{lineage_var}.rid"
|
||||
for i, c in enumerate(tbl.columns):
|
||||
scanner.add(f'{c.cxt_name}.init("{c.name}");', "init")
|
||||
scanner.add(f"{c.cxt_name} = {self.cexprs[i](scanner.it_ver)};")
|
||||
|
||||
class insert(ast_node):
|
||||
name = 'insert'
|
||||
def produce(self, node):
|
||||
ct = node[self.name]
|
||||
table:TableInfo = self.context.tables_byname[ct]
|
||||
|
||||
values = node['query']['select']
|
||||
if len(values) != table.n_cols:
|
||||
raise ValueError("Column Mismatch")
|
||||
table.refer_all()
|
||||
for i, s in enumerate(values):
|
||||
if 'value' in s:
|
||||
cname = table.columns[i].cxt_name
|
||||
self.emit(f"{cname}.emplace_back({s['value']});")
|
||||
else:
|
||||
# subquery, dispatch to select astnode
|
||||
pass
|
||||
|
||||
class c(ast_node):
|
||||
name='c'
|
||||
def produce(self, node):
|
||||
self.emit(node[self.name])
|
||||
|
||||
class load(ast_node):
|
||||
name="load"
|
||||
def produce(self, node):
|
||||
self.context.headers.add('"csv.h"')
|
||||
node = node[self.name]
|
||||
table:TableInfo = self.context.tables_byname[node['table']]
|
||||
table.refer_all()
|
||||
csv_reader_name = 'csv_reader_' + base62uuid(6)
|
||||
col_types = [c.type for c in table.columns]
|
||||
col_tmp_names = ['tmp_'+base62uuid(8) for _ in range(len(table.columns))]
|
||||
# col_type_str = ",".join(col_types)
|
||||
col_names = ','.join([f'"{c.name}"' for c in table.columns])
|
||||
|
||||
self.emit(f'io::CSVReader<{len(col_types)}> {csv_reader_name}("{node["file"]["literal"]}");')
|
||||
self.emit(f'{csv_reader_name}.read_header(io::ignore_extra_column, {col_names});')
|
||||
for t, n in zip(col_types, col_tmp_names):
|
||||
self.emit(f'{t} {n};')
|
||||
self.emit(f'while({csv_reader_name}.read_row({",".join(col_tmp_names)})) {{ \n')
|
||||
for i, c in enumerate(table.columns):
|
||||
self.emit(f'{c.cxt_name}.emplace_back({col_tmp_names[i]});')
|
||||
self.emit('}')
|
||||
|
||||
|
||||
class outfile(ast_node):
|
||||
name="_outfile"
|
||||
def produce(self, node):
|
||||
out_table:TableInfo = self.parent.out_table
|
||||
filename = node['loc']['literal'] if 'loc' in node else node['literal']
|
||||
sep = ',' if 'term' not in node else node['term']['literal']
|
||||
file_pointer = 'fp_' + base62uuid(6)
|
||||
self.emit(f'FILE* {file_pointer} = fopen("{filename}", "w");')
|
||||
self.emit(f'{out_table.cxt_name}->printall("{sep}", "\\n", nullptr, {file_pointer});')
|
||||
self.emit(f'fclose({file_pointer});')
|
||||
# self.context.headers.add('fstream')
|
||||
# cout_backup_buffer = 'stdout_' + base62uuid(4)
|
||||
# ofstream = 'ofstream_' + base62uuid(6)
|
||||
# self.emit(f'auto {cout_backup_buffer} = cout.rdbuf();')
|
||||
# self.emit(f'auto {ofstream} = ofstream("{filename}");')
|
||||
# self.emit(f'cout.rdbuf({ofstream}.rdbuf());')
|
||||
# TODO: ADD STMTS.
|
||||
# self.emit(f'cout.rdbuf({cout_backup_buffer});')
|
||||
# self.emit(f'{ofstream}.close();')
|
||||
|
||||
|
||||
import sys
|
||||
# code-gen for data decl languages
|
||||
|
||||
from engine.orderby import orderby
|
||||
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
||||
from engine.scan import scan
|
||||
from engine.utils import base62uuid
|
||||
|
||||
class create_table(ast_node):
|
||||
name = 'create_table'
|
||||
def __init__(self, parent: "ast_node", node, context: Context = None, cexprs = None, lineage = False):
|
||||
self.cexprs = cexprs
|
||||
self.lineage = lineage
|
||||
super().__init__(parent, node, context)
|
||||
def produce(self, node):
|
||||
if type(node) is not TableInfo:
|
||||
ct = node[self.name]
|
||||
tbl = self.context.add_table(ct['name'], ct['columns'])
|
||||
else:
|
||||
tbl = node
|
||||
|
||||
col_type_str = ','.join([c.type for c in tbl.columns])
|
||||
# create tables in c
|
||||
self.emit(f"auto {tbl.table_name} = new TableInfo<{col_type_str}>(\"{tbl.table_name}\", {tbl.n_cols});")
|
||||
self.emit("cxt->tables.insert({\"" + tbl.table_name + f"\", {tbl.table_name}"+"});")
|
||||
self.context.tables_in_context[tbl] = tbl.table_name
|
||||
tbl.cxt_name = tbl.table_name
|
||||
tbl.refer_all()
|
||||
# create an empty new table
|
||||
if self.cexprs is None:
|
||||
for c in tbl.columns:
|
||||
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
||||
# create an output table
|
||||
else:
|
||||
# 1 to 1 lineage.
|
||||
if len(self.context.scans) == 0:
|
||||
if self.lineage:
|
||||
order = 'order_' + base62uuid(6)
|
||||
self.emit(f'auto {order} = {self.parent.datasource.cxt_name}->order_by<{orderby(self.parent, self.parent.assumptions).result()}>();')
|
||||
self.lineage = '*' + order
|
||||
else:
|
||||
self.lineage = None
|
||||
for i, c in enumerate(tbl.columns):
|
||||
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
||||
self.emit(f"{c.cxt_name} = {self.cexprs[i](self.lineage)};")
|
||||
self.lineage = None
|
||||
self.parent.assumptions = None
|
||||
else:
|
||||
scanner:scan = self.context.scans[-1]
|
||||
if self.lineage:
|
||||
lineage_var = 'lineage_' + base62uuid(6)
|
||||
counter_var = 'counter_' + base62uuid(6)
|
||||
scanner.add(f'auto {lineage_var} = {self.datasource.cxt_name}->bind({tbl.cxt_name});', "init")
|
||||
scanner.add(f'auto {counter_var} = 0;', "init")
|
||||
scanner.add(f"{lineage_var}.emplace_back({counter_var}++);", "front")
|
||||
self.lineage = f"{lineage_var}.rid"
|
||||
for i, c in enumerate(tbl.columns):
|
||||
scanner.add(f'{c.cxt_name}.init("{c.name}");', "init")
|
||||
scanner.add(f"{c.cxt_name} = {self.cexprs[i](scanner.it_ver)};")
|
||||
|
||||
class insert(ast_node):
|
||||
name = 'insert'
|
||||
def produce(self, node):
|
||||
ct = node[self.name]
|
||||
table:TableInfo = self.context.tables_byname[ct]
|
||||
|
||||
values = node['query']['select']
|
||||
if len(values) != table.n_cols:
|
||||
raise ValueError("Column Mismatch")
|
||||
table.refer_all()
|
||||
for i, s in enumerate(values):
|
||||
if 'value' in s:
|
||||
cname = table.columns[i].cxt_name
|
||||
self.emit(f"{cname}.emplace_back({s['value']});")
|
||||
else:
|
||||
# subquery, dispatch to select astnode
|
||||
pass
|
||||
|
||||
class c(ast_node):
|
||||
name='c'
|
||||
def produce(self, node):
|
||||
self.emit(node[self.name])
|
||||
|
||||
class load(ast_node):
|
||||
name="load"
|
||||
def produce(self, node):
|
||||
self.context.headers.add('"csv.h"')
|
||||
node = node[self.name]
|
||||
table:TableInfo = self.context.tables_byname[node['table']]
|
||||
table.refer_all()
|
||||
csv_reader_name = 'csv_reader_' + base62uuid(6)
|
||||
col_types = [c.type for c in table.columns]
|
||||
col_tmp_names = ['tmp_'+base62uuid(8) for _ in range(len(table.columns))]
|
||||
# col_type_str = ",".join(col_types)
|
||||
col_names = ','.join([f'"{c.name}"' for c in table.columns])
|
||||
|
||||
self.emit(f'io::CSVReader<{len(col_types)}> {csv_reader_name}("{node["file"]["literal"]}");')
|
||||
self.emit(f'{csv_reader_name}.read_header(io::ignore_extra_column, {col_names});')
|
||||
for t, n in zip(col_types, col_tmp_names):
|
||||
self.emit(f'{t} {n};')
|
||||
self.emit(f'while({csv_reader_name}.read_row({",".join(col_tmp_names)})) {{ \n')
|
||||
for i, c in enumerate(table.columns):
|
||||
self.emit(f'{c.cxt_name}.emplace_back({col_tmp_names[i]});')
|
||||
self.emit('}')
|
||||
|
||||
|
||||
class outfile(ast_node):
|
||||
name="_outfile"
|
||||
def produce(self, node):
|
||||
out_table:TableInfo = self.parent.out_table
|
||||
filename = node['loc']['literal'] if 'loc' in node else node['literal']
|
||||
sep = ',' if 'term' not in node else node['term']['literal']
|
||||
file_pointer = 'fp_' + base62uuid(6)
|
||||
self.emit(f'FILE* {file_pointer} = fopen("{filename}", "w");')
|
||||
self.emit(f'{out_table.cxt_name}->printall("{sep}", "\\n", nullptr, {file_pointer});')
|
||||
self.emit(f'fclose({file_pointer});')
|
||||
# self.context.headers.add('fstream')
|
||||
# cout_backup_buffer = 'stdout_' + base62uuid(4)
|
||||
# ofstream = 'ofstream_' + base62uuid(6)
|
||||
# self.emit(f'auto {cout_backup_buffer} = cout.rdbuf();')
|
||||
# self.emit(f'auto {ofstream} = ofstream("{filename}");')
|
||||
# self.emit(f'cout.rdbuf({ofstream}.rdbuf());')
|
||||
# TODO: ADD STMTS.
|
||||
# self.emit(f'cout.rdbuf({cout_backup_buffer});')
|
||||
# self.emit(f'{ofstream}.close();')
|
||||
|
||||
|
||||
import sys
|
||||
include(sys.modules[__name__])
|
@ -1,135 +1,135 @@
|
||||
from engine.ast import ast_node, ColRef
|
||||
start_expr = 'f"'
|
||||
index_expr = '{\'\' if x is None and y is None else f\'[{x}]\'}'
|
||||
end_expr = '"'
|
||||
|
||||
class expr(ast_node):
|
||||
name='expr'
|
||||
builtin_func_maps = {
|
||||
'max': 'max',
|
||||
'min': 'min',
|
||||
'avg': 'avg',
|
||||
'sum': 'sum',
|
||||
'count' : 'count',
|
||||
'mins': ['mins', 'minw'],
|
||||
'maxs': ['maxs', 'maxw'],
|
||||
'avgs': ['avgs', 'avgw'],
|
||||
'sums': ['sums', 'sumw'],
|
||||
}
|
||||
|
||||
binary_ops = {
|
||||
'sub':'-',
|
||||
'add':'+',
|
||||
'mul':'*',
|
||||
'div':'/',
|
||||
'mod':'%',
|
||||
'and':'&&',
|
||||
'or':'||',
|
||||
'xor' : '^',
|
||||
'gt':'>',
|
||||
'lt':'<',
|
||||
'lte':'<=',
|
||||
'gte':'>=',
|
||||
'neq':'!=',
|
||||
'eq':'=='
|
||||
}
|
||||
|
||||
compound_ops = {
|
||||
'missing' : ['missing', lambda x: f'{x[0]} == nullval<decays<decltype({x[0]})>>'],
|
||||
}
|
||||
|
||||
unary_ops = {
|
||||
'neg' : '-',
|
||||
'not' : '!'
|
||||
}
|
||||
|
||||
coumpound_generating_ops = ['avgs', 'mins', 'maxs', 'sums'] + \
|
||||
list( binary_ops.keys()) + list(compound_ops.keys()) + list(unary_ops.keys() )
|
||||
|
||||
def __init__(self, parent, node, materialize_cols = True, abs_col = False):
|
||||
self.materialize_cols = materialize_cols
|
||||
self.raw_col = None
|
||||
self.__abs = abs_col
|
||||
self.inside_agg = False
|
||||
if(type(parent) is expr):
|
||||
self.inside_agg = parent.inside_agg
|
||||
self.__abs = parent.__abs
|
||||
ast_node.__init__(self, parent, node, None)
|
||||
|
||||
def init(self, _):
|
||||
from engine.projection import projection
|
||||
parent = self.parent
|
||||
self.isvector = parent.isvector if type(parent) is expr else False
|
||||
self.is_compound = parent.is_compound if type(parent) is expr else False
|
||||
if type(parent) in [projection, expr]:
|
||||
self.datasource = parent.datasource
|
||||
else:
|
||||
self.datasource = self.context.datasource
|
||||
self.udf_map = parent.context.udf_map
|
||||
self._expr = ''
|
||||
self.cexpr = None
|
||||
self.func_maps = {**self.udf_map, **self.builtin_func_maps}
|
||||
|
||||
def produce(self, node):
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.func_maps:
|
||||
# TODO: distinguish between UDF agg functions and other UDF functions.
|
||||
self.inside_agg = True
|
||||
self.context.headers.add('"./server/aggregations.h"')
|
||||
if type(val) is list and len(val) > 1:
|
||||
cfunc = self.func_maps[key]
|
||||
cfunc = cfunc[len(val) - 1] if type(cfunc) is list else cfunc
|
||||
self._expr += f"{cfunc}("
|
||||
for i, p in enumerate(val):
|
||||
self._expr += expr(self, p)._expr + (','if i<len(val)-1 else '')
|
||||
else:
|
||||
funcname = self.func_maps[key]
|
||||
funcname = funcname[0] if type(funcname) is list else funcname
|
||||
self._expr += f"{funcname}("
|
||||
self._expr += expr(self, val)._expr
|
||||
self._expr += ')'
|
||||
self.inside_agg = False
|
||||
elif key in self.binary_ops:
|
||||
l = expr(self, val[0])._expr
|
||||
r = expr(self, val[1])._expr
|
||||
self._expr += f'({l}{self.binary_ops[key]}{r})'
|
||||
elif key in self.compound_ops:
|
||||
x = []
|
||||
if type(val) is list:
|
||||
for v in val:
|
||||
x.append(expr(self, v)._expr)
|
||||
self._expr = self.compound_ops[key][1](x)
|
||||
elif key in self.unary_ops:
|
||||
self._expr += f'{self.unary_ops[key]}({expr(self, val)._expr})'
|
||||
else:
|
||||
self.context.Error(f'Undefined expr: {key}{val}')
|
||||
|
||||
if key in self.coumpound_generating_ops and not self.is_compound:
|
||||
self.is_compound = True
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.is_compound:
|
||||
p.is_compound = True
|
||||
p = p.parent
|
||||
|
||||
elif type(node) is str:
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.isvector:
|
||||
p.isvector = True
|
||||
p = p.parent
|
||||
|
||||
self._expr, self.raw_col = self.datasource.parse_col_names(node, self.materialize_cols, True)
|
||||
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
||||
if self.__abs and self.raw_col:
|
||||
self._expr = self.raw_col.reference() + ("" if self.inside_agg else index_expr)
|
||||
elif type(node) is bool:
|
||||
self._expr = '1' if node else '0'
|
||||
else:
|
||||
self._expr = f'{node}'
|
||||
def toCExpr(_expr):
|
||||
return lambda x = None, y = None : eval(start_expr + _expr + end_expr)
|
||||
def consume(self, _):
|
||||
self.cexpr = expr.toCExpr(self._expr)
|
||||
def __str__(self):
|
||||
return self.cexpr
|
||||
from engine.ast import ast_node, ColRef
|
||||
start_expr = 'f"'
|
||||
index_expr = '{\'\' if x is None and y is None else f\'[{x}]\'}'
|
||||
end_expr = '"'
|
||||
|
||||
class expr(ast_node):
|
||||
name='expr'
|
||||
builtin_func_maps = {
|
||||
'max': 'max',
|
||||
'min': 'min',
|
||||
'avg': 'avg',
|
||||
'sum': 'sum',
|
||||
'count' : 'count',
|
||||
'mins': ['mins', 'minw'],
|
||||
'maxs': ['maxs', 'maxw'],
|
||||
'avgs': ['avgs', 'avgw'],
|
||||
'sums': ['sums', 'sumw'],
|
||||
}
|
||||
|
||||
binary_ops = {
|
||||
'sub':'-',
|
||||
'add':'+',
|
||||
'mul':'*',
|
||||
'div':'/',
|
||||
'mod':'%',
|
||||
'and':'&&',
|
||||
'or':'||',
|
||||
'xor' : '^',
|
||||
'gt':'>',
|
||||
'lt':'<',
|
||||
'lte':'<=',
|
||||
'gte':'>=',
|
||||
'neq':'!=',
|
||||
'eq':'=='
|
||||
}
|
||||
|
||||
compound_ops = {
|
||||
'missing' : ['missing', lambda x: f'{x[0]} == nullval<decays<decltype({x[0]})>>'],
|
||||
}
|
||||
|
||||
unary_ops = {
|
||||
'neg' : '-',
|
||||
'not' : '!'
|
||||
}
|
||||
|
||||
coumpound_generating_ops = ['avgs', 'mins', 'maxs', 'sums'] + \
|
||||
list( binary_ops.keys()) + list(compound_ops.keys()) + list(unary_ops.keys() )
|
||||
|
||||
def __init__(self, parent, node, materialize_cols = True, abs_col = False):
|
||||
self.materialize_cols = materialize_cols
|
||||
self.raw_col = None
|
||||
self.__abs = abs_col
|
||||
self.inside_agg = False
|
||||
if(type(parent) is expr):
|
||||
self.inside_agg = parent.inside_agg
|
||||
self.__abs = parent.__abs
|
||||
ast_node.__init__(self, parent, node, None)
|
||||
|
||||
def init(self, _):
|
||||
from engine.projection import projection
|
||||
parent = self.parent
|
||||
self.isvector = parent.isvector if type(parent) is expr else False
|
||||
self.is_compound = parent.is_compound if type(parent) is expr else False
|
||||
if type(parent) in [projection, expr]:
|
||||
self.datasource = parent.datasource
|
||||
else:
|
||||
self.datasource = self.context.datasource
|
||||
self.udf_map = parent.context.udf_map
|
||||
self._expr = ''
|
||||
self.cexpr = None
|
||||
self.func_maps = {**self.udf_map, **self.builtin_func_maps}
|
||||
|
||||
def produce(self, node):
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.func_maps:
|
||||
# TODO: distinguish between UDF agg functions and other UDF functions.
|
||||
self.inside_agg = True
|
||||
self.context.headers.add('"./server/aggregations.h"')
|
||||
if type(val) is list and len(val) > 1:
|
||||
cfunc = self.func_maps[key]
|
||||
cfunc = cfunc[len(val) - 1] if type(cfunc) is list else cfunc
|
||||
self._expr += f"{cfunc}("
|
||||
for i, p in enumerate(val):
|
||||
self._expr += expr(self, p)._expr + (','if i<len(val)-1 else '')
|
||||
else:
|
||||
funcname = self.func_maps[key]
|
||||
funcname = funcname[0] if type(funcname) is list else funcname
|
||||
self._expr += f"{funcname}("
|
||||
self._expr += expr(self, val)._expr
|
||||
self._expr += ')'
|
||||
self.inside_agg = False
|
||||
elif key in self.binary_ops:
|
||||
l = expr(self, val[0])._expr
|
||||
r = expr(self, val[1])._expr
|
||||
self._expr += f'({l}{self.binary_ops[key]}{r})'
|
||||
elif key in self.compound_ops:
|
||||
x = []
|
||||
if type(val) is list:
|
||||
for v in val:
|
||||
x.append(expr(self, v)._expr)
|
||||
self._expr = self.compound_ops[key][1](x)
|
||||
elif key in self.unary_ops:
|
||||
self._expr += f'{self.unary_ops[key]}({expr(self, val)._expr})'
|
||||
else:
|
||||
self.context.Error(f'Undefined expr: {key}{val}')
|
||||
|
||||
if key in self.coumpound_generating_ops and not self.is_compound:
|
||||
self.is_compound = True
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.is_compound:
|
||||
p.is_compound = True
|
||||
p = p.parent
|
||||
|
||||
elif type(node) is str:
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.isvector:
|
||||
p.isvector = True
|
||||
p = p.parent
|
||||
|
||||
self._expr, self.raw_col = self.datasource.parse_col_names(node, self.materialize_cols, True)
|
||||
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
||||
if self.__abs and self.raw_col:
|
||||
self._expr = self.raw_col.reference() + ("" if self.inside_agg else index_expr)
|
||||
elif type(node) is bool:
|
||||
self._expr = '1' if node else '0'
|
||||
else:
|
||||
self._expr = f'{node}'
|
||||
def toCExpr(_expr):
|
||||
return lambda x = None, y = None : eval(start_expr + _expr + end_expr)
|
||||
def consume(self, _):
|
||||
self.cexpr = expr.toCExpr(self._expr)
|
||||
def __str__(self):
|
||||
return self.cexpr
|
||||
|
@ -1,72 +1,72 @@
|
||||
from engine.ast import ColRef, TableInfo, ast_node
|
||||
from engine.orderby import assumption
|
||||
from engine.scan import scan
|
||||
from engine.utils import base62uuid
|
||||
from engine.expr import expr
|
||||
|
||||
class groupby(ast_node):
|
||||
name = '_groupby'
|
||||
def init(self, _):
|
||||
self.context.headers.add('"./server/hasher.h"')
|
||||
self.context.headers.add('unordered_map')
|
||||
self.group = 'g' + base62uuid(7)
|
||||
self.group_type = 'record_type' + base62uuid(7)
|
||||
self.datasource = self.parent.datasource
|
||||
self.scanner = None
|
||||
self.datasource.rec = set()
|
||||
self.raw_groups = []
|
||||
def produce(self, node):
|
||||
|
||||
if type(node) is not list:
|
||||
node = [node]
|
||||
g_contents = ''
|
||||
g_contents_list = []
|
||||
first_col = ''
|
||||
for i, g in enumerate(node):
|
||||
v = g['value']
|
||||
e = expr(self, v)
|
||||
if type(e.raw_col) is ColRef:
|
||||
self.raw_groups.append(e.raw_col)
|
||||
e = e._expr
|
||||
# if v is compound expr, create tmp cols
|
||||
if type(v) is not str:
|
||||
tmpcol = 't' + base62uuid(7)
|
||||
self.emit(f'auto {tmpcol} = {e};')
|
||||
e = tmpcol
|
||||
if i == 0:
|
||||
first_col = e
|
||||
g_contents_list.append(e)
|
||||
g_contents_decltype = [f'decltype({c})' for c in g_contents_list]
|
||||
g_contents = expr.toCExpr(','.join(g_contents_list))
|
||||
self.emit(f'typedef record<{expr.toCExpr(",".join(g_contents_decltype))(0)}> {self.group_type};')
|
||||
self.emit(f'unordered_map<{self.group_type}, vector_type<uint32_t>, '
|
||||
f'transTypes<{self.group_type}, hasher>> {self.group};')
|
||||
self.n_grps = len(node)
|
||||
self.scanner = scan(self, self.datasource, expr.toCExpr(first_col)()+'.size')
|
||||
self.scanner.add(f'{self.group}[forward_as_tuple({g_contents(self.scanner.it_ver)})].emplace_back({self.scanner.it_ver});')
|
||||
|
||||
|
||||
def consume(self, _):
|
||||
self.referenced = self.datasource.rec
|
||||
self.datasource.rec = None
|
||||
self.scanner.finalize()
|
||||
|
||||
def deal_with_assumptions(self, assumption:assumption, out:TableInfo):
|
||||
gscanner = scan(self, self.group)
|
||||
val_var = 'val_'+base62uuid(7)
|
||||
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
||||
gscanner.add(f'{self.datasource.cxt_name}->order_by<{assumption.result()}>(&{val_var});')
|
||||
gscanner.finalize()
|
||||
|
||||
def finalize(self, cexprs, out:TableInfo):
|
||||
gscanner = scan(self, self.group)
|
||||
key_var = 'key_'+base62uuid(7)
|
||||
val_var = 'val_'+base62uuid(7)
|
||||
|
||||
gscanner.add(f'auto &{key_var} = {gscanner.it_ver}.first;')
|
||||
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
||||
gscanner.add(';\n'.join([f'{out.columns[i].reference()}.emplace_back({ce(x=val_var, y=key_var)})' for i, ce in enumerate(cexprs)])+';')
|
||||
|
||||
gscanner.finalize()
|
||||
|
||||
from engine.ast import ColRef, TableInfo, ast_node
|
||||
from engine.orderby import assumption
|
||||
from engine.scan import scan
|
||||
from engine.utils import base62uuid
|
||||
from engine.expr import expr
|
||||
|
||||
class groupby(ast_node):
|
||||
name = '_groupby'
|
||||
def init(self, _):
|
||||
self.context.headers.add('"./server/hasher.h"')
|
||||
self.context.headers.add('unordered_map')
|
||||
self.group = 'g' + base62uuid(7)
|
||||
self.group_type = 'record_type' + base62uuid(7)
|
||||
self.datasource = self.parent.datasource
|
||||
self.scanner = None
|
||||
self.datasource.rec = set()
|
||||
self.raw_groups = []
|
||||
def produce(self, node):
|
||||
|
||||
if type(node) is not list:
|
||||
node = [node]
|
||||
g_contents = ''
|
||||
g_contents_list = []
|
||||
first_col = ''
|
||||
for i, g in enumerate(node):
|
||||
v = g['value']
|
||||
e = expr(self, v)
|
||||
if type(e.raw_col) is ColRef:
|
||||
self.raw_groups.append(e.raw_col)
|
||||
e = e._expr
|
||||
# if v is compound expr, create tmp cols
|
||||
if type(v) is not str:
|
||||
tmpcol = 't' + base62uuid(7)
|
||||
self.emit(f'auto {tmpcol} = {e};')
|
||||
e = tmpcol
|
||||
if i == 0:
|
||||
first_col = e
|
||||
g_contents_list.append(e)
|
||||
g_contents_decltype = [f'decltype({c})' for c in g_contents_list]
|
||||
g_contents = expr.toCExpr(','.join(g_contents_list))
|
||||
self.emit(f'typedef record<{expr.toCExpr(",".join(g_contents_decltype))(0)}> {self.group_type};')
|
||||
self.emit(f'unordered_map<{self.group_type}, vector_type<uint32_t>, '
|
||||
f'transTypes<{self.group_type}, hasher>> {self.group};')
|
||||
self.n_grps = len(node)
|
||||
self.scanner = scan(self, self.datasource, expr.toCExpr(first_col)()+'.size')
|
||||
self.scanner.add(f'{self.group}[forward_as_tuple({g_contents(self.scanner.it_ver)})].emplace_back({self.scanner.it_ver});')
|
||||
|
||||
|
||||
def consume(self, _):
|
||||
self.referenced = self.datasource.rec
|
||||
self.datasource.rec = None
|
||||
self.scanner.finalize()
|
||||
|
||||
def deal_with_assumptions(self, assumption:assumption, out:TableInfo):
|
||||
gscanner = scan(self, self.group)
|
||||
val_var = 'val_'+base62uuid(7)
|
||||
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
||||
gscanner.add(f'{self.datasource.cxt_name}->order_by<{assumption.result()}>(&{val_var});')
|
||||
gscanner.finalize()
|
||||
|
||||
def finalize(self, cexprs, out:TableInfo):
|
||||
gscanner = scan(self, self.group)
|
||||
key_var = 'key_'+base62uuid(7)
|
||||
val_var = 'val_'+base62uuid(7)
|
||||
|
||||
gscanner.add(f'auto &{key_var} = {gscanner.it_ver}.first;')
|
||||
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
||||
gscanner.add(';\n'.join([f'{out.columns[i].reference()}.emplace_back({ce(x=val_var, y=key_var)})' for i, ce in enumerate(cexprs)])+';')
|
||||
|
||||
gscanner.finalize()
|
||||
|
||||
self.datasource.groupinfo = None
|
@ -1,6 +1,6 @@
|
||||
from engine.ast import ast_node
|
||||
|
||||
|
||||
class join(ast_node):
|
||||
name='join'
|
||||
from engine.ast import ast_node
|
||||
|
||||
|
||||
class join(ast_node):
|
||||
name='join'
|
||||
|
@ -1,180 +1,180 @@
|
||||
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
||||
from engine.groupby import groupby
|
||||
from engine.join import join
|
||||
from engine.expr import expr
|
||||
from engine.orderby import assumption, orderby
|
||||
from engine.scan import filter
|
||||
from engine.utils import base62uuid, enlist, base62alp, has_other
|
||||
from engine.ddl import create_table, outfile
|
||||
import copy
|
||||
|
||||
class projection(ast_node):
|
||||
name='select'
|
||||
def __init__(self, parent:ast_node, node, context:Context = None, outname = None, disp = True):
|
||||
self.disp = disp
|
||||
self.outname = outname
|
||||
self.group_node = None
|
||||
self.assumptions = None
|
||||
self.where = None
|
||||
ast_node.__init__(self, parent, node, context)
|
||||
def init(self, _):
|
||||
if self.outname is None:
|
||||
self.outname = self.context.gen_tmptable()
|
||||
|
||||
def produce(self, node):
|
||||
p = node['select']
|
||||
self.projections = p if type(p) is list else [p]
|
||||
self.context.Info(node)
|
||||
|
||||
def spawn(self, node):
|
||||
self.datasource = None
|
||||
if 'from' in node:
|
||||
from_clause = node['from']
|
||||
if type(from_clause) is list:
|
||||
# from joins
|
||||
join(self, from_clause)
|
||||
elif type(from_clause) is dict:
|
||||
if 'value' in from_clause:
|
||||
value = from_clause['value']
|
||||
if type(value) is dict:
|
||||
if 'select' in value:
|
||||
# from subquery
|
||||
projection(self, from_clause, disp = False)
|
||||
else:
|
||||
# TODO: from func over table
|
||||
print(f'from func over table{node}')
|
||||
elif type(value) is str:
|
||||
self.datasource = self.context.tables_byname[value]
|
||||
if 'name' in value:
|
||||
self.datasource.add_alias(value['name'])
|
||||
if 'assumptions' in from_clause:
|
||||
self.assumptions = enlist(from_clause['assumptions'])
|
||||
|
||||
elif type(from_clause) is str:
|
||||
self.datasource = self.context.tables_byname[from_clause]
|
||||
|
||||
if self.datasource is None:
|
||||
raise ValueError('spawn error: from clause')
|
||||
|
||||
if self.datasource is not None:
|
||||
self.datasource_changed = True
|
||||
self.prev_datasource = self.context.datasource
|
||||
self.context.datasource = self.datasource
|
||||
if 'where' in node:
|
||||
self.where = filter(self, node['where'], True)
|
||||
# self.datasource = filter(self, node['where'], True).output
|
||||
# self.context.datasource = self.datasource
|
||||
|
||||
if 'groupby' in node:
|
||||
self.group_node = groupby(self, node['groupby'])
|
||||
self.datasource = copy.copy(self.datasource) # shallow copy
|
||||
self.datasource.groupinfo = self.group_node
|
||||
else:
|
||||
self.group_node = None
|
||||
|
||||
def consume(self, node):
|
||||
self.inv = True
|
||||
disp_varname = 'd'+base62uuid(7)
|
||||
has_groupby = self.group_node is not None
|
||||
cexprs = []
|
||||
flatten = False
|
||||
cols = []
|
||||
self.out_table = TableInfo('out_'+base62uuid(4), [], self.context)
|
||||
if 'outfile' in node:
|
||||
flatten = True
|
||||
|
||||
new_names = []
|
||||
proj_raw_cols = []
|
||||
for i, proj in enumerate(self.projections):
|
||||
cname = ''
|
||||
compound = False
|
||||
self.datasource.rec = set()
|
||||
if type(proj) is dict:
|
||||
if 'value' in proj:
|
||||
e = proj['value']
|
||||
sname = expr(self, e)
|
||||
if type(sname.raw_col) is ColRef:
|
||||
proj_raw_cols.append(sname.raw_col)
|
||||
sname = sname._expr
|
||||
fname = expr.toCExpr(sname) # fastest access method at innermost context
|
||||
absname = expr(self, e, abs_col=True)._expr # absolute name at function scope
|
||||
# TODO: Make it single pass here.
|
||||
compound = True # compound column
|
||||
cexprs.append(fname)
|
||||
cname = e if type(e) is str else ''.join([a if a in base62alp else '' for a in expr.toCExpr(absname)()])
|
||||
if 'name' in proj: # renaming column by AS keyword
|
||||
cname = proj['name']
|
||||
new_names.append(cname)
|
||||
elif type(proj) is str:
|
||||
col = self.datasource.get_col_d(proj)
|
||||
if type(col) is ColRef:
|
||||
col.reference()
|
||||
|
||||
compound = compound and has_groupby and has_other(self.datasource.rec, self.group_node.referenced)
|
||||
self.datasource.rec = None
|
||||
|
||||
typename = f'decays<decltype({absname})>'
|
||||
if not compound:
|
||||
typename = f'value_type<{typename}>'
|
||||
|
||||
cols.append(ColRef(cname, expr.toCExpr(typename)(), self.out_table, 0, None, cname, i, compound=compound))
|
||||
|
||||
self.out_table.add_cols(cols, False)
|
||||
|
||||
lineage = None
|
||||
|
||||
if has_groupby:
|
||||
create_table(self, self.out_table) # creates empty out_table.
|
||||
if self.assumptions is not None:
|
||||
self.assumptions = assumption(self, self.assumptions, exclude=self.group_node.raw_groups)
|
||||
if not self.assumptions.empty():
|
||||
self.group_node.deal_with_assumptions(self.assumptions, self.out_table)
|
||||
self.assumptions = None
|
||||
self.group_node.finalize(cexprs, self.out_table)
|
||||
else:
|
||||
# if all assumptions in projections, treat as orderby
|
||||
lineage = self.assumptions is not None and has_other(self.assumptions, proj_raw_cols)
|
||||
spawn = create_table(self, self.out_table, cexprs = cexprs, lineage = lineage) # create and populate out_table.
|
||||
if lineage and type(spawn.lineage) is str:
|
||||
lineage = spawn.lineage
|
||||
self.assumptions = orderby(self, self.assumptions) # do not exclude proj_raw_cols
|
||||
else:
|
||||
lineage = None
|
||||
if self.where is not None:
|
||||
self.where.finalize()
|
||||
|
||||
if type(lineage) is str:
|
||||
order = 'order_' + base62uuid(6)
|
||||
self.emit(f'auto {order} = {self.datasource.cxt_name}->order_by<{self.assumptions.result()}>({lineage});')
|
||||
self.emit(f'{self.out_table.cxt_name}->materialize(*{order});')
|
||||
self.assumptions = None
|
||||
|
||||
if self.assumptions is not None:
|
||||
orderby_node = orderby(self, self.assumptions)
|
||||
else:
|
||||
orderby_node = None
|
||||
|
||||
if 'orderby' in node:
|
||||
self.datasource = self.out_table
|
||||
self.context.datasource = self.out_table # discard current ds
|
||||
orderbys = node['orderby']
|
||||
orderby_node = orderby(self, orderbys) if orderby_node is None else orderby_node.merge(orderbys)
|
||||
|
||||
if orderby_node is not None:
|
||||
self.emit(f'auto {disp_varname} = {self.out_table.reference()}->order_by_view<{orderby_node.result()}>();')
|
||||
else:
|
||||
disp_varname = f'*{self.out_table.cxt_name}'
|
||||
|
||||
if self.disp:
|
||||
self.emit(f'print({disp_varname});')
|
||||
|
||||
|
||||
if flatten:
|
||||
outfile(self, node['outfile'])
|
||||
|
||||
if self.datasource_changed:
|
||||
self.context.datasource = self.prev_datasource
|
||||
|
||||
|
||||
import sys
|
||||
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
||||
from engine.groupby import groupby
|
||||
from engine.join import join
|
||||
from engine.expr import expr
|
||||
from engine.orderby import assumption, orderby
|
||||
from engine.scan import filter
|
||||
from engine.utils import base62uuid, enlist, base62alp, has_other
|
||||
from engine.ddl import create_table, outfile
|
||||
import copy
|
||||
|
||||
class projection(ast_node):
|
||||
name='select'
|
||||
def __init__(self, parent:ast_node, node, context:Context = None, outname = None, disp = True):
|
||||
self.disp = disp
|
||||
self.outname = outname
|
||||
self.group_node = None
|
||||
self.assumptions = None
|
||||
self.where = None
|
||||
ast_node.__init__(self, parent, node, context)
|
||||
def init(self, _):
|
||||
if self.outname is None:
|
||||
self.outname = self.context.gen_tmptable()
|
||||
|
||||
def produce(self, node):
|
||||
p = node['select']
|
||||
self.projections = p if type(p) is list else [p]
|
||||
self.context.Info(node)
|
||||
|
||||
def spawn(self, node):
|
||||
self.datasource = None
|
||||
if 'from' in node:
|
||||
from_clause = node['from']
|
||||
if type(from_clause) is list:
|
||||
# from joins
|
||||
join(self, from_clause)
|
||||
elif type(from_clause) is dict:
|
||||
if 'value' in from_clause:
|
||||
value = from_clause['value']
|
||||
if type(value) is dict:
|
||||
if 'select' in value:
|
||||
# from subquery
|
||||
projection(self, from_clause, disp = False)
|
||||
else:
|
||||
# TODO: from func over table
|
||||
print(f'from func over table{node}')
|
||||
elif type(value) is str:
|
||||
self.datasource = self.context.tables_byname[value]
|
||||
if 'name' in value:
|
||||
self.datasource.add_alias(value['name'])
|
||||
if 'assumptions' in from_clause:
|
||||
self.assumptions = enlist(from_clause['assumptions'])
|
||||
|
||||
elif type(from_clause) is str:
|
||||
self.datasource = self.context.tables_byname[from_clause]
|
||||
|
||||
if self.datasource is None:
|
||||
raise ValueError('spawn error: from clause')
|
||||
|
||||
if self.datasource is not None:
|
||||
self.datasource_changed = True
|
||||
self.prev_datasource = self.context.datasource
|
||||
self.context.datasource = self.datasource
|
||||
if 'where' in node:
|
||||
self.where = filter(self, node['where'], True)
|
||||
# self.datasource = filter(self, node['where'], True).output
|
||||
# self.context.datasource = self.datasource
|
||||
|
||||
if 'groupby' in node:
|
||||
self.group_node = groupby(self, node['groupby'])
|
||||
self.datasource = copy.copy(self.datasource) # shallow copy
|
||||
self.datasource.groupinfo = self.group_node
|
||||
else:
|
||||
self.group_node = None
|
||||
|
||||
def consume(self, node):
|
||||
self.inv = True
|
||||
disp_varname = 'd'+base62uuid(7)
|
||||
has_groupby = self.group_node is not None
|
||||
cexprs = []
|
||||
flatten = False
|
||||
cols = []
|
||||
self.out_table = TableInfo('out_'+base62uuid(4), [], self.context)
|
||||
if 'outfile' in node:
|
||||
flatten = True
|
||||
|
||||
new_names = []
|
||||
proj_raw_cols = []
|
||||
for i, proj in enumerate(self.projections):
|
||||
cname = ''
|
||||
compound = False
|
||||
self.datasource.rec = set()
|
||||
if type(proj) is dict:
|
||||
if 'value' in proj:
|
||||
e = proj['value']
|
||||
sname = expr(self, e)
|
||||
if type(sname.raw_col) is ColRef:
|
||||
proj_raw_cols.append(sname.raw_col)
|
||||
sname = sname._expr
|
||||
fname = expr.toCExpr(sname) # fastest access method at innermost context
|
||||
absname = expr(self, e, abs_col=True)._expr # absolute name at function scope
|
||||
# TODO: Make it single pass here.
|
||||
compound = True # compound column
|
||||
cexprs.append(fname)
|
||||
cname = e if type(e) is str else ''.join([a if a in base62alp else '' for a in expr.toCExpr(absname)()])
|
||||
if 'name' in proj: # renaming column by AS keyword
|
||||
cname = proj['name']
|
||||
new_names.append(cname)
|
||||
elif type(proj) is str:
|
||||
col = self.datasource.get_col_d(proj)
|
||||
if type(col) is ColRef:
|
||||
col.reference()
|
||||
|
||||
compound = compound and has_groupby and has_other(self.datasource.rec, self.group_node.referenced)
|
||||
self.datasource.rec = None
|
||||
|
||||
typename = f'decays<decltype({absname})>'
|
||||
if not compound:
|
||||
typename = f'value_type<{typename}>'
|
||||
|
||||
cols.append(ColRef(cname, expr.toCExpr(typename)(), self.out_table, 0, None, cname, i, compound=compound))
|
||||
|
||||
self.out_table.add_cols(cols, False)
|
||||
|
||||
lineage = None
|
||||
|
||||
if has_groupby:
|
||||
create_table(self, self.out_table) # creates empty out_table.
|
||||
if self.assumptions is not None:
|
||||
self.assumptions = assumption(self, self.assumptions, exclude=self.group_node.raw_groups)
|
||||
if not self.assumptions.empty():
|
||||
self.group_node.deal_with_assumptions(self.assumptions, self.out_table)
|
||||
self.assumptions = None
|
||||
self.group_node.finalize(cexprs, self.out_table)
|
||||
else:
|
||||
# if all assumptions in projections, treat as orderby
|
||||
lineage = self.assumptions is not None and has_other(self.assumptions, proj_raw_cols)
|
||||
spawn = create_table(self, self.out_table, cexprs = cexprs, lineage = lineage) # create and populate out_table.
|
||||
if lineage and type(spawn.lineage) is str:
|
||||
lineage = spawn.lineage
|
||||
self.assumptions = orderby(self, self.assumptions) # do not exclude proj_raw_cols
|
||||
else:
|
||||
lineage = None
|
||||
if self.where is not None:
|
||||
self.where.finalize()
|
||||
|
||||
if type(lineage) is str:
|
||||
order = 'order_' + base62uuid(6)
|
||||
self.emit(f'auto {order} = {self.datasource.cxt_name}->order_by<{self.assumptions.result()}>({lineage});')
|
||||
self.emit(f'{self.out_table.cxt_name}->materialize(*{order});')
|
||||
self.assumptions = None
|
||||
|
||||
if self.assumptions is not None:
|
||||
orderby_node = orderby(self, self.assumptions)
|
||||
else:
|
||||
orderby_node = None
|
||||
|
||||
if 'orderby' in node:
|
||||
self.datasource = self.out_table
|
||||
self.context.datasource = self.out_table # discard current ds
|
||||
orderbys = node['orderby']
|
||||
orderby_node = orderby(self, orderbys) if orderby_node is None else orderby_node.merge(orderbys)
|
||||
|
||||
if orderby_node is not None:
|
||||
self.emit(f'auto {disp_varname} = {self.out_table.reference()}->order_by_view<{orderby_node.result()}>();')
|
||||
else:
|
||||
disp_varname = f'*{self.out_table.cxt_name}'
|
||||
|
||||
if self.disp:
|
||||
self.emit(f'print({disp_varname});')
|
||||
|
||||
|
||||
if flatten:
|
||||
outfile(self, node['outfile'])
|
||||
|
||||
if self.datasource_changed:
|
||||
self.context.datasource = self.prev_datasource
|
||||
|
||||
|
||||
import sys
|
||||
include(sys.modules[__name__])
|
@ -1,99 +1,99 @@
|
||||
from xmlrpc.client import Boolean
|
||||
from engine.ast import ColRef, TableInfo, View, ast_node, Context
|
||||
from engine.utils import base62uuid
|
||||
from engine.expr import expr
|
||||
|
||||
class scan(ast_node):
|
||||
name = 'scan'
|
||||
def __init__(self, parent: "ast_node", node, size = None, context: Context = None, const = False):
|
||||
self.type = type
|
||||
self.size = size
|
||||
self.const = "const " if const else ""
|
||||
super().__init__(parent, node, context)
|
||||
def init(self, _):
|
||||
self.datasource = self.context.datasource
|
||||
self.initializers = ''
|
||||
self.start = ''
|
||||
self.front = ''
|
||||
self.body = ''
|
||||
self.end = '}'
|
||||
self.mode = None
|
||||
self.filters = []
|
||||
scan_vars = set(s.it_var for s in self.context.scans)
|
||||
self.it_ver = 'i' + base62uuid(2)
|
||||
while(self.it_ver in scan_vars):
|
||||
self.it_ver = 'i' + base62uuid(6)
|
||||
self.parent.context.scans.append(self)
|
||||
def produce(self, node):
|
||||
if type(node) is ColRef:
|
||||
self.colref = node
|
||||
if self.size is None:
|
||||
self.mode = ["col", node.table]
|
||||
self.start += f'for ({self.const}auto& {self.it_ver} : {node.reference()}) {{\n'
|
||||
else:
|
||||
self.mode = ["idx", node.table]
|
||||
self.start += f"for (uint32_t {self.it_ver} = 0; {self.it_ver} < {node.reference()}.size; ++{self.it_ver}){{\\n"
|
||||
elif type(node) is str:
|
||||
self.mode = ["idx", None]
|
||||
self.start+= f'for({self.const}auto& {self.it_ver} : {node}) {{\n'
|
||||
else:
|
||||
self.mode = ["idx", node] # Node is the TableInfo
|
||||
self.start += f"for (uint32_t {self.it_ver} = 0; {self.it_ver} < {self.size}; ++{self.it_ver}){{\n"
|
||||
|
||||
def add(self, stmt, position = "body"):
|
||||
if position == "body":
|
||||
self.body += stmt + '\n'
|
||||
elif position == "init":
|
||||
self.initializers += stmt + '\n'
|
||||
else:
|
||||
self.front += stmt + '\n'
|
||||
|
||||
def finalize(self):
|
||||
for f in self.filters:
|
||||
self.start += f
|
||||
self.end += '}'
|
||||
self.context.remove_scan(self, self.initializers + self.start + self.front + self.body + self.end)
|
||||
|
||||
class filter(ast_node):
|
||||
name = 'filter'
|
||||
def __init__(self, parent: "ast_node", node, materialize = False, context = None):
|
||||
self.materialize = materialize
|
||||
super().__init__(parent, node, context)
|
||||
def init(self, _):
|
||||
self.datasource = self.context.datasource
|
||||
self.view = View(self.context, self.datasource)
|
||||
self.value = None
|
||||
|
||||
def spawn(self, node):
|
||||
# TODO: deal with subqueries
|
||||
self.modified_node = node
|
||||
return super().spawn(node)
|
||||
def __materialize__(self):
|
||||
if self.materialize:
|
||||
cols = [] if self.datasource is None else self.datasource.columns
|
||||
self.output = TableInfo('tn'+base62uuid(6), cols, self.context)
|
||||
self.output.construct()
|
||||
if type(self.value) is View: # cond filtered on tables.
|
||||
self.emit(f'{self.value.name}:&{self.value.name}')
|
||||
for o, c in zip(self.output.columns,self.value.table.columns):
|
||||
self.emit(f'{o.cname}:{c.cname}[{self.value.name}]')
|
||||
elif self.value is not None: # cond is scalar
|
||||
tmpVar = 't'+base62uuid(7)
|
||||
self.emit(f'{tmpVar}:{self.value}')
|
||||
for o, c in zip(self.output.columns, self.datasource.columns):
|
||||
self.emit(f'{o.cname}:$[{tmpVar};{c.cname};()]')
|
||||
|
||||
def finalize(self):
|
||||
self.scanner.finalize()
|
||||
def consume(self, _):
|
||||
# TODO: optimizations after converting expr to cnf
|
||||
self.scanner = None
|
||||
for s in self.context.scans:
|
||||
if self.datasource == s.mode[1]:
|
||||
self.scanner = s
|
||||
break
|
||||
if self.scanner is None:
|
||||
self.scanner = scan(self, self.datasource, self.datasource.get_size())
|
||||
self.expr = expr(self, self.modified_node)
|
||||
self.scanner.filters.append(f'if ({self.expr.cexpr(self.scanner.it_ver)}) {{\n')
|
||||
from xmlrpc.client import Boolean
|
||||
from engine.ast import ColRef, TableInfo, View, ast_node, Context
|
||||
from engine.utils import base62uuid
|
||||
from engine.expr import expr
|
||||
|
||||
class scan(ast_node):
|
||||
name = 'scan'
|
||||
def __init__(self, parent: "ast_node", node, size = None, context: Context = None, const = False):
|
||||
self.type = type
|
||||
self.size = size
|
||||
self.const = "const " if const else ""
|
||||
super().__init__(parent, node, context)
|
||||
def init(self, _):
|
||||
self.datasource = self.context.datasource
|
||||
self.initializers = ''
|
||||
self.start = ''
|
||||
self.front = ''
|
||||
self.body = ''
|
||||
self.end = '}'
|
||||
self.mode = None
|
||||
self.filters = []
|
||||
scan_vars = set(s.it_var for s in self.context.scans)
|
||||
self.it_ver = 'i' + base62uuid(2)
|
||||
while(self.it_ver in scan_vars):
|
||||
self.it_ver = 'i' + base62uuid(6)
|
||||
self.parent.context.scans.append(self)
|
||||
def produce(self, node):
|
||||
if type(node) is ColRef:
|
||||
self.colref = node
|
||||
if self.size is None:
|
||||
self.mode = ["col", node.table]
|
||||
self.start += f'for ({self.const}auto& {self.it_ver} : {node.reference()}) {{\n'
|
||||
else:
|
||||
self.mode = ["idx", node.table]
|
||||
self.start += f"for (uint32_t {self.it_ver} = 0; {self.it_ver} < {node.reference()}.size; ++{self.it_ver}){{\\n"
|
||||
elif type(node) is str:
|
||||
self.mode = ["idx", None]
|
||||
self.start+= f'for({self.const}auto& {self.it_ver} : {node}) {{\n'
|
||||
else:
|
||||
self.mode = ["idx", node] # Node is the TableInfo
|
||||
self.start += f"for (uint32_t {self.it_ver} = 0; {self.it_ver} < {self.size}; ++{self.it_ver}){{\n"
|
||||
|
||||
def add(self, stmt, position = "body"):
|
||||
if position == "body":
|
||||
self.body += stmt + '\n'
|
||||
elif position == "init":
|
||||
self.initializers += stmt + '\n'
|
||||
else:
|
||||
self.front += stmt + '\n'
|
||||
|
||||
def finalize(self):
|
||||
for f in self.filters:
|
||||
self.start += f
|
||||
self.end += '}'
|
||||
self.context.remove_scan(self, self.initializers + self.start + self.front + self.body + self.end)
|
||||
|
||||
class filter(ast_node):
|
||||
name = 'filter'
|
||||
def __init__(self, parent: "ast_node", node, materialize = False, context = None):
|
||||
self.materialize = materialize
|
||||
super().__init__(parent, node, context)
|
||||
def init(self, _):
|
||||
self.datasource = self.context.datasource
|
||||
self.view = View(self.context, self.datasource)
|
||||
self.value = None
|
||||
|
||||
def spawn(self, node):
|
||||
# TODO: deal with subqueries
|
||||
self.modified_node = node
|
||||
return super().spawn(node)
|
||||
def __materialize__(self):
|
||||
if self.materialize:
|
||||
cols = [] if self.datasource is None else self.datasource.columns
|
||||
self.output = TableInfo('tn'+base62uuid(6), cols, self.context)
|
||||
self.output.construct()
|
||||
if type(self.value) is View: # cond filtered on tables.
|
||||
self.emit(f'{self.value.name}:&{self.value.name}')
|
||||
for o, c in zip(self.output.columns,self.value.table.columns):
|
||||
self.emit(f'{o.cname}:{c.cname}[{self.value.name}]')
|
||||
elif self.value is not None: # cond is scalar
|
||||
tmpVar = 't'+base62uuid(7)
|
||||
self.emit(f'{tmpVar}:{self.value}')
|
||||
for o, c in zip(self.output.columns, self.datasource.columns):
|
||||
self.emit(f'{o.cname}:$[{tmpVar};{c.cname};()]')
|
||||
|
||||
def finalize(self):
|
||||
self.scanner.finalize()
|
||||
def consume(self, _):
|
||||
# TODO: optimizations after converting expr to cnf
|
||||
self.scanner = None
|
||||
for s in self.context.scans:
|
||||
if self.datasource == s.mode[1]:
|
||||
self.scanner = s
|
||||
break
|
||||
if self.scanner is None:
|
||||
self.scanner = scan(self, self.datasource, self.datasource.get_size())
|
||||
self.expr = expr(self, self.modified_node)
|
||||
self.scanner.filters.append(f'if ({self.expr.cexpr(self.scanner.it_ver)}) {{\n')
|
||||
|
@ -1,93 +1,93 @@
|
||||
import uuid
|
||||
|
||||
lower_alp = 'abcdefghijklmnopqrstuvwxyz'
|
||||
upper_alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
nums = '0123456789'
|
||||
base62alp = nums + lower_alp + upper_alp
|
||||
|
||||
reserved_monet = ['month']
|
||||
|
||||
def base62uuid(crop=8):
|
||||
_id = uuid.uuid4().int
|
||||
ret = ''
|
||||
|
||||
while _id:
|
||||
ret = base62alp[_id % 62] + ret
|
||||
_id //= 62
|
||||
|
||||
return ret[:crop] if len(ret) else '0'
|
||||
|
||||
def get_legal_name(name, lower = True):
|
||||
if name is not None:
|
||||
if lower:
|
||||
name = name.lower()
|
||||
name = ''.join([n for n in name if n in base62alp or n == '_'])
|
||||
|
||||
if name is None or len(name) == 0 or set(name) == set('_'):
|
||||
name = base62uuid(8)
|
||||
if(name[0] in nums):
|
||||
name = '_' + name
|
||||
|
||||
return name
|
||||
|
||||
def check_legal_name(name):
|
||||
all_underscores = True
|
||||
for c in name:
|
||||
if c not in base62alp and c != '_':
|
||||
return False
|
||||
if c != '_':
|
||||
all_underscores = False
|
||||
if all_underscores:
|
||||
return False
|
||||
if name[0] in nums:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def enlist(l):
|
||||
return l if type(l) is list else [l]
|
||||
|
||||
def seps(s, i, l):
|
||||
return s if i < len(l) - 1 else ''
|
||||
|
||||
def has_other(a, b):
|
||||
for ai in a:
|
||||
if ai not in b:
|
||||
return True
|
||||
return False
|
||||
|
||||
def defval(val, default):
|
||||
return default if val is None else val
|
||||
|
||||
# escape must be readonly
|
||||
from typing import Set
|
||||
def remove_last(pattern : str, string : str, escape : Set[str] = set()) -> str:
|
||||
idx = string.rfind(pattern)
|
||||
if idx == -1:
|
||||
return string
|
||||
else:
|
||||
if set(string[idx:]).difference(escape):
|
||||
return string
|
||||
else:
|
||||
return string[:idx] + string[idx+1:]
|
||||
|
||||
class _Counter:
|
||||
def __init__(self, cnt):
|
||||
self.cnt = cnt
|
||||
def inc(self, cnt = 1):
|
||||
self.cnt += cnt
|
||||
cnt = self.cnt - cnt
|
||||
return cnt
|
||||
|
||||
import re
|
||||
ws = re.compile(r'\s+')
|
||||
import os
|
||||
|
||||
def add_dll_dir(dll: str):
|
||||
import sys
|
||||
if sys.version_info.major >= 3 and sys.version_info.minor >7 and os.name == 'nt':
|
||||
os.add_dll_directory(dll)
|
||||
else:
|
||||
os.environ['PATH'] = os.path.abspath(dll) + os.pathsep + os.environ['PATH']
|
||||
|
||||
nullstream = open(os.devnull, 'w')
|
||||
import uuid
|
||||
|
||||
lower_alp = 'abcdefghijklmnopqrstuvwxyz'
|
||||
upper_alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
nums = '0123456789'
|
||||
base62alp = nums + lower_alp + upper_alp
|
||||
|
||||
reserved_monet = ['month']
|
||||
|
||||
def base62uuid(crop=8):
|
||||
_id = uuid.uuid4().int
|
||||
ret = ''
|
||||
|
||||
while _id:
|
||||
ret = base62alp[_id % 62] + ret
|
||||
_id //= 62
|
||||
|
||||
return ret[:crop] if len(ret) else '0'
|
||||
|
||||
def get_legal_name(name, lower = True):
|
||||
if name is not None:
|
||||
if lower:
|
||||
name = name.lower()
|
||||
name = ''.join([n for n in name if n in base62alp or n == '_'])
|
||||
|
||||
if name is None or len(name) == 0 or set(name) == set('_'):
|
||||
name = base62uuid(8)
|
||||
if(name[0] in nums):
|
||||
name = '_' + name
|
||||
|
||||
return name
|
||||
|
||||
def check_legal_name(name):
|
||||
all_underscores = True
|
||||
for c in name:
|
||||
if c not in base62alp and c != '_':
|
||||
return False
|
||||
if c != '_':
|
||||
all_underscores = False
|
||||
if all_underscores:
|
||||
return False
|
||||
if name[0] in nums:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def enlist(l):
|
||||
return l if type(l) is list else [l]
|
||||
|
||||
def seps(s, i, l):
|
||||
return s if i < len(l) - 1 else ''
|
||||
|
||||
def has_other(a, b):
|
||||
for ai in a:
|
||||
if ai not in b:
|
||||
return True
|
||||
return False
|
||||
|
||||
def defval(val, default):
|
||||
return default if val is None else val
|
||||
|
||||
# escape must be readonly
|
||||
from typing import Set
|
||||
def remove_last(pattern : str, string : str, escape : Set[str] = set()) -> str:
|
||||
idx = string.rfind(pattern)
|
||||
if idx == -1:
|
||||
return string
|
||||
else:
|
||||
if set(string[idx:]).difference(escape):
|
||||
return string
|
||||
else:
|
||||
return string[:idx] + string[idx+1:]
|
||||
|
||||
class _Counter:
|
||||
def __init__(self, cnt):
|
||||
self.cnt = cnt
|
||||
def inc(self, cnt = 1):
|
||||
self.cnt += cnt
|
||||
cnt = self.cnt - cnt
|
||||
return cnt
|
||||
|
||||
import re
|
||||
ws = re.compile(r'\s+')
|
||||
import os
|
||||
|
||||
def add_dll_dir(dll: str):
|
||||
import sys
|
||||
if sys.version_info.major >= 3 and sys.version_info.minor >7 and os.name == 'nt':
|
||||
os.add_dll_directory(dll)
|
||||
else:
|
||||
os.environ['PATH'] = os.path.abspath(dll) + os.pathsep + os.environ['PATH']
|
||||
|
||||
nullstream = open(os.devnull, 'w')
|
||||
|
@ -1,466 +1,466 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||
|
||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER < 1900
|
||||
#error Versions below Visual Studio 2015 are no longer supported
|
||||
#endif
|
||||
|
||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
|
||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||
#define HAVE_RAND_S 1
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||
#define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
||||
* versions. We need to include stdlib.h first or else we get
|
||||
* conflicting declarations. */
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* standard C-99 include files */
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/* Windows include files */
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* indicate to sqltypes.h that windows.h has already been included and
|
||||
that it doesn't have to define Windows constants */
|
||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||
|
||||
#define NATIVE_WIN32 1
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if !defined(WIN32) && (defined(__CYGWIN__) || defined(__MINGW32__))
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
// Section: monetdb configure defines
|
||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_IO_H 1
|
||||
/* #undef HAVE_KVM_H */
|
||||
/* #undef HAVE_LIBGEN_H */
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||
/* #undef HAVE_MACH_TASK_H */
|
||||
/* #undef HAVE_MACH_O_DYLD_H */
|
||||
/* #undef HAVE_NETDB_H */
|
||||
/* #undef HAVE_NETINET_IN_H */
|
||||
/* #undef HAVE_POLL_H */
|
||||
/* #undef HAVE_PROCFS_H */
|
||||
/* #undef HAVE_PWD_H */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
/* #undef HAVE_SYS_FILE_H */
|
||||
/* #undef HAVE_SYS_IOCTL_H */
|
||||
/* #undef HAVE_SYS_SYSCTL_H */
|
||||
/* #undef HAVE_SYS_MMAN_H */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
/* #undef HAVE_SYS_RANDOM_H */
|
||||
/* #undef HAVE_SYS_RESOURCE_H */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
/* #undef HAVE_SYS_UIO_H */
|
||||
/* #undef HAVE_SYS_UN_H */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
/* #undef HAVE_TERMIOS_H */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
/* #undef HAVE_UUID_UUID_H */
|
||||
#define HAVE_WINSOCK_H 1
|
||||
/* #undef HAVE_SEMAPHORE_H */
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
/* #undef HAVE_STDATOMIC_H */
|
||||
|
||||
/* #undef HAVE_DIRENT_H */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
/* #undef HAVE_ACCEPT4 */
|
||||
/* #undef HAVE_ASCTIME_R */
|
||||
/* #undef HAVE_CLOCK_GETTIME */
|
||||
/* #undef HAVE_CTIME_R */
|
||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||
/* #undef HAVE_FALLOCATE */
|
||||
/* #undef HAVE_FCNTL */
|
||||
/* #undef HAVE_FORK */
|
||||
/* #undef HAVE_FSYNC */
|
||||
#define HAVE_FTIME 1
|
||||
/* #undef HAVE_GETENTROPY */
|
||||
/* #undef HAVE_GETEXECNAME */
|
||||
/* #undef HAVE_GETLOGIN */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
/* #undef HAVE_GETRLIMIT */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
/* #undef HAVE_GETUID */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
/* #undef HAVE_LOCALTIME_R */
|
||||
/* #undef HAVE_STRERROR_R */
|
||||
/* #undef HAVE_LOCKF */
|
||||
/* #undef HAVE_MADVISE */
|
||||
/* #undef HAVE_MREMAP */
|
||||
/* #undef HAVE_NANOSLEEP */
|
||||
/* #undef HAVE_NL_LANGINFO */
|
||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||
/* #undef HAVE_PIPE2 */
|
||||
/* #undef HAVE_POLL */
|
||||
/* #undef HAVE_POPEN */
|
||||
/* #undef HAVE_POSIX_FADVISE */
|
||||
/* #undef HAVE_POSIX_FALLOCATE */
|
||||
/* #undef HAVE_POSIX_MADVISE */
|
||||
#define HAVE_PUTENV 1
|
||||
/* #undef HAVE_SETSID */
|
||||
#define HAVE_SHUTDOWN 1
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_STPCPY */
|
||||
/* #undef HAVE_STRCASESTR */
|
||||
/* #undef HAVE_STRNCASECMP */
|
||||
/* #undef HAVE_STRPTIME */
|
||||
/* #undef HAVE_STRSIGNAL */
|
||||
/* #undef HAVE_SYSCONF */
|
||||
/* #undef HAVE_TASK_INFO */
|
||||
/* #undef HAVE_TIMES */
|
||||
/* #undef HAVE_UNAME */
|
||||
/* #undef HAVE_SEMTIMEDOP */
|
||||
/* #undef HAVE_PTHREAD_KILL */
|
||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||
#define HAVE_GETOPT 1
|
||||
|
||||
#define ICONV_CONST
|
||||
#define FLEXIBLE_ARRAY_MEMBER
|
||||
#define ENABLE_MAPI 1
|
||||
#define HAVE_MAPI 1
|
||||
// End Section: monetdb configure defines
|
||||
|
||||
// Section: monetdb macro variables
|
||||
#define HAVE_ICONV 1
|
||||
/* #undef HAVE_PTHREAD_H */
|
||||
#define HAVE_LIBPCRE 1
|
||||
#define HAVE_LIBBZ2 1
|
||||
/* #undef HAVE_CURL */
|
||||
#define HAVE_LIBLZMA 1
|
||||
#define HAVE_LIBXML 1
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_LIBLZ4 1
|
||||
/* #undef HAVE_PROJ */
|
||||
/* #undef HAVE_SNAPPY */
|
||||
/* #undef HAVE_FITS */
|
||||
/* #undef HAVE_UUID */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
/* #undef HAVE_NETCDF */
|
||||
/* #undef HAVE_READLINE */
|
||||
/* #undef HAVE_LIBR */
|
||||
#define RHOME "/registry"
|
||||
#define HAVE_GEOM 1
|
||||
/* #undef HAVE_SHP */
|
||||
#define HAVE_LIBPY3 1
|
||||
|
||||
// #define SOCKET_LIBRARIES
|
||||
#define HAVE_GETADDRINFO 1
|
||||
/* #undef HAVE_CUDF */
|
||||
|
||||
#define MAPI_PORT 50000
|
||||
#define MAPI_PORT_STR "50000"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DIR_SEP '\\'
|
||||
#define PATH_SEP ';'
|
||||
#define DIR_SEP_STR "\\"
|
||||
#define SO_PREFIX ""
|
||||
#else
|
||||
#define DIR_SEP '/'
|
||||
#define PATH_SEP ':'
|
||||
#define DIR_SEP_STR "/"
|
||||
/* #undef SO_PREFIX */
|
||||
#endif
|
||||
#define SO_EXT ".dll"
|
||||
|
||||
#define BINDIR "C:/cygwin64/home/monet/x86_64/install/bin"
|
||||
#define LIBDIR "C:/cygwin64/home/monet/x86_64/install/lib"
|
||||
#define LOCALSTATEDIR "C:/cygwin64/home/monet/x86_64/install/var"
|
||||
|
||||
// End Section: monetdb macro variables
|
||||
|
||||
// Section: monetdb configure misc
|
||||
#define MONETDB_RELEASE "Jan2022-SP3"
|
||||
|
||||
#define MONETDB_VERSION "11.43.15"
|
||||
#define MONETDB_VERSION_MAJOR 11
|
||||
#define MONETDB_VERSION_MINOR 43
|
||||
#define MONETDB_VERSION_PATCH 15
|
||||
|
||||
#define GDK_VERSION "25.1.0"
|
||||
#define GDK_VERSION_MAJOR 25
|
||||
#define GDK_VERSION_MINOR 1
|
||||
#define GDK_VERSION_PATCH 0
|
||||
#define MAPI_VERSION "14.0.2"
|
||||
#define MAPI_VERSION_MAJOR 14
|
||||
#define MAPI_VERSION_MINOR 0
|
||||
#define MAPI_VERSION_PATCH 2
|
||||
#define MONETDB5_VERSION "32.0.6"
|
||||
#define MONETDB5_VERSION_MAJOR 32
|
||||
#define MONETDB5_VERSION_MINOR 0
|
||||
#define MONETDB5_VERSION_PATCH 6
|
||||
#define MONETDBE_VERSION "3.0.2"
|
||||
#define MONETDBE_VERSION_MAJOR 3
|
||||
#define MONETDBE_VERSION_MINOR 0
|
||||
#define MONETDBE_VERSION_PATCH 2
|
||||
#define STREAM_VERSION "16.0.1"
|
||||
#define STREAM_VERSION_MAJOR 16
|
||||
#define STREAM_VERSION_MINOR 0
|
||||
#define STREAM_VERSION_PATCH 1
|
||||
#define SQL_VERSION "12.0.5"
|
||||
#define SQL_VERSION_MAJOR 12
|
||||
#define SQL_VERSION_MINOR 0
|
||||
#define SQL_VERSION_PATCH 5
|
||||
|
||||
/* Host identifier */
|
||||
#define HOST "amd64-pc-windows-msvc"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH "SHA512"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||
|
||||
#ifndef _Noreturn
|
||||
#define _Noreturn __declspec(noreturn)
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
/* Does your compiler support `__restrict__' keyword? (C99 feature) */
|
||||
#ifndef __restrict__
|
||||
#define __restrict__ restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef __restrict__
|
||||
#define __restrict__ __restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure misc
|
||||
|
||||
// Section: monetdb configure sizes
|
||||
#define SIZEOF_SIZE_T 8
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 8
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_WCHAR_T 2
|
||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLPOINTER
|
||||
#endif
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#endif
|
||||
#define SIZEOF_SQLWCHAR 2
|
||||
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||
#ifndef ssize_t
|
||||
#define ssize_t int64_t
|
||||
#endif
|
||||
|
||||
/* The size of `__int128', as computed by sizeof. */
|
||||
/* #undef SIZEOF___INT128 */
|
||||
|
||||
/* The size of `__int128_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF___INT128_T */
|
||||
|
||||
/* The size of `__uint128_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF___UINT128_T */
|
||||
|
||||
#ifdef SIZEOF___INT128
|
||||
typedef __int128 hge;
|
||||
typedef unsigned __int128 uhge;
|
||||
#define HAVE_HGE 1
|
||||
#define SIZEOF_HGE SIZEOF___INT128
|
||||
#elif defined(SIZEOF___INT128_T) && defined(SIZEOF___UINT128_T)
|
||||
typedef __int128_t hge;
|
||||
typedef __uint128_t uhge;
|
||||
#define HAVE_HGE 1
|
||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure sizes
|
||||
|
||||
/* Does your compiler support `__attribute__' extension? */
|
||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || (__cplusplus < 201103L&&(!defined(_MSC_VER)||_MSC_VER<1600))
|
||||
#ifndef static_assert
|
||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
||||
* in many other compilers we ignore it if the compiler doesn't support it
|
||||
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||
#define static_assert(expr, mesg) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h> /* strcasecmp */
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define strdup(s) _strdup(s)
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef lstat
|
||||
#undef lstat
|
||||
#endif
|
||||
#define lstat _stat64
|
||||
#ifdef stat
|
||||
#undef stat
|
||||
#endif
|
||||
#define stat _stat64
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
#define fstat _fstat64
|
||||
|
||||
static inline char *
|
||||
stpcpy(char *__restrict__ dst, const char *__restrict__ src)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; src[i]; i++)
|
||||
dst[i] = src[i];
|
||||
dst[i] = 0;
|
||||
return dst + i;
|
||||
}
|
||||
|
||||
/* Define to 1 if the system has the type `socklen_t'. */
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
/* type used by connect */
|
||||
#define socklen_t int
|
||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* there is something very similar to localtime_r on Windows: */
|
||||
#include <time.h>
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
static inline struct tm *
|
||||
localtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||
{
|
||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
#define HAVE_GMTIME_R 1
|
||||
static inline struct tm *
|
||||
gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||
{
|
||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
|
||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTIME_R3 1
|
||||
/* there is something very similar to ctime_r on Windows: */
|
||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
#ifndef _MSC_VER
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
#endif
|
||||
|
||||
#ifndef _In_z_
|
||||
#define _In_z_
|
||||
#endif
|
||||
#ifndef _Printf_format_string_
|
||||
#define _Printf_format_string_
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||
static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||
#endif
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) \
|
||||
static void f(void) __attribute__((__constructor__)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||
|
||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER < 1900
|
||||
#error Versions below Visual Studio 2015 are no longer supported
|
||||
#endif
|
||||
|
||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
|
||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||
#define HAVE_RAND_S 1
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||
#define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
||||
* versions. We need to include stdlib.h first or else we get
|
||||
* conflicting declarations. */
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* standard C-99 include files */
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/* Windows include files */
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* indicate to sqltypes.h that windows.h has already been included and
|
||||
that it doesn't have to define Windows constants */
|
||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||
|
||||
#define NATIVE_WIN32 1
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if !defined(WIN32) && (defined(__CYGWIN__) || defined(__MINGW32__))
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
// Section: monetdb configure defines
|
||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_IO_H 1
|
||||
/* #undef HAVE_KVM_H */
|
||||
/* #undef HAVE_LIBGEN_H */
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||
/* #undef HAVE_MACH_TASK_H */
|
||||
/* #undef HAVE_MACH_O_DYLD_H */
|
||||
/* #undef HAVE_NETDB_H */
|
||||
/* #undef HAVE_NETINET_IN_H */
|
||||
/* #undef HAVE_POLL_H */
|
||||
/* #undef HAVE_PROCFS_H */
|
||||
/* #undef HAVE_PWD_H */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
/* #undef HAVE_SYS_FILE_H */
|
||||
/* #undef HAVE_SYS_IOCTL_H */
|
||||
/* #undef HAVE_SYS_SYSCTL_H */
|
||||
/* #undef HAVE_SYS_MMAN_H */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
/* #undef HAVE_SYS_RANDOM_H */
|
||||
/* #undef HAVE_SYS_RESOURCE_H */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
/* #undef HAVE_SYS_UIO_H */
|
||||
/* #undef HAVE_SYS_UN_H */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
/* #undef HAVE_TERMIOS_H */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
/* #undef HAVE_UUID_UUID_H */
|
||||
#define HAVE_WINSOCK_H 1
|
||||
/* #undef HAVE_SEMAPHORE_H */
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
/* #undef HAVE_STDATOMIC_H */
|
||||
|
||||
/* #undef HAVE_DIRENT_H */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
/* #undef HAVE_ACCEPT4 */
|
||||
/* #undef HAVE_ASCTIME_R */
|
||||
/* #undef HAVE_CLOCK_GETTIME */
|
||||
/* #undef HAVE_CTIME_R */
|
||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||
/* #undef HAVE_FALLOCATE */
|
||||
/* #undef HAVE_FCNTL */
|
||||
/* #undef HAVE_FORK */
|
||||
/* #undef HAVE_FSYNC */
|
||||
#define HAVE_FTIME 1
|
||||
/* #undef HAVE_GETENTROPY */
|
||||
/* #undef HAVE_GETEXECNAME */
|
||||
/* #undef HAVE_GETLOGIN */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
/* #undef HAVE_GETRLIMIT */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
/* #undef HAVE_GETUID */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
/* #undef HAVE_LOCALTIME_R */
|
||||
/* #undef HAVE_STRERROR_R */
|
||||
/* #undef HAVE_LOCKF */
|
||||
/* #undef HAVE_MADVISE */
|
||||
/* #undef HAVE_MREMAP */
|
||||
/* #undef HAVE_NANOSLEEP */
|
||||
/* #undef HAVE_NL_LANGINFO */
|
||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||
/* #undef HAVE_PIPE2 */
|
||||
/* #undef HAVE_POLL */
|
||||
/* #undef HAVE_POPEN */
|
||||
/* #undef HAVE_POSIX_FADVISE */
|
||||
/* #undef HAVE_POSIX_FALLOCATE */
|
||||
/* #undef HAVE_POSIX_MADVISE */
|
||||
#define HAVE_PUTENV 1
|
||||
/* #undef HAVE_SETSID */
|
||||
#define HAVE_SHUTDOWN 1
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_STPCPY */
|
||||
/* #undef HAVE_STRCASESTR */
|
||||
/* #undef HAVE_STRNCASECMP */
|
||||
/* #undef HAVE_STRPTIME */
|
||||
/* #undef HAVE_STRSIGNAL */
|
||||
/* #undef HAVE_SYSCONF */
|
||||
/* #undef HAVE_TASK_INFO */
|
||||
/* #undef HAVE_TIMES */
|
||||
/* #undef HAVE_UNAME */
|
||||
/* #undef HAVE_SEMTIMEDOP */
|
||||
/* #undef HAVE_PTHREAD_KILL */
|
||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||
#define HAVE_GETOPT 1
|
||||
|
||||
#define ICONV_CONST
|
||||
#define FLEXIBLE_ARRAY_MEMBER
|
||||
#define ENABLE_MAPI 1
|
||||
#define HAVE_MAPI 1
|
||||
// End Section: monetdb configure defines
|
||||
|
||||
// Section: monetdb macro variables
|
||||
#define HAVE_ICONV 1
|
||||
/* #undef HAVE_PTHREAD_H */
|
||||
#define HAVE_LIBPCRE 1
|
||||
#define HAVE_LIBBZ2 1
|
||||
/* #undef HAVE_CURL */
|
||||
#define HAVE_LIBLZMA 1
|
||||
#define HAVE_LIBXML 1
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_LIBLZ4 1
|
||||
/* #undef HAVE_PROJ */
|
||||
/* #undef HAVE_SNAPPY */
|
||||
/* #undef HAVE_FITS */
|
||||
/* #undef HAVE_UUID */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
/* #undef HAVE_NETCDF */
|
||||
/* #undef HAVE_READLINE */
|
||||
/* #undef HAVE_LIBR */
|
||||
#define RHOME "/registry"
|
||||
#define HAVE_GEOM 1
|
||||
/* #undef HAVE_SHP */
|
||||
#define HAVE_LIBPY3 1
|
||||
|
||||
// #define SOCKET_LIBRARIES
|
||||
#define HAVE_GETADDRINFO 1
|
||||
/* #undef HAVE_CUDF */
|
||||
|
||||
#define MAPI_PORT 50000
|
||||
#define MAPI_PORT_STR "50000"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DIR_SEP '\\'
|
||||
#define PATH_SEP ';'
|
||||
#define DIR_SEP_STR "\\"
|
||||
#define SO_PREFIX ""
|
||||
#else
|
||||
#define DIR_SEP '/'
|
||||
#define PATH_SEP ':'
|
||||
#define DIR_SEP_STR "/"
|
||||
/* #undef SO_PREFIX */
|
||||
#endif
|
||||
#define SO_EXT ".dll"
|
||||
|
||||
#define BINDIR "C:/cygwin64/home/monet/x86_64/install/bin"
|
||||
#define LIBDIR "C:/cygwin64/home/monet/x86_64/install/lib"
|
||||
#define LOCALSTATEDIR "C:/cygwin64/home/monet/x86_64/install/var"
|
||||
|
||||
// End Section: monetdb macro variables
|
||||
|
||||
// Section: monetdb configure misc
|
||||
#define MONETDB_RELEASE "Jan2022-SP3"
|
||||
|
||||
#define MONETDB_VERSION "11.43.15"
|
||||
#define MONETDB_VERSION_MAJOR 11
|
||||
#define MONETDB_VERSION_MINOR 43
|
||||
#define MONETDB_VERSION_PATCH 15
|
||||
|
||||
#define GDK_VERSION "25.1.0"
|
||||
#define GDK_VERSION_MAJOR 25
|
||||
#define GDK_VERSION_MINOR 1
|
||||
#define GDK_VERSION_PATCH 0
|
||||
#define MAPI_VERSION "14.0.2"
|
||||
#define MAPI_VERSION_MAJOR 14
|
||||
#define MAPI_VERSION_MINOR 0
|
||||
#define MAPI_VERSION_PATCH 2
|
||||
#define MONETDB5_VERSION "32.0.6"
|
||||
#define MONETDB5_VERSION_MAJOR 32
|
||||
#define MONETDB5_VERSION_MINOR 0
|
||||
#define MONETDB5_VERSION_PATCH 6
|
||||
#define MONETDBE_VERSION "3.0.2"
|
||||
#define MONETDBE_VERSION_MAJOR 3
|
||||
#define MONETDBE_VERSION_MINOR 0
|
||||
#define MONETDBE_VERSION_PATCH 2
|
||||
#define STREAM_VERSION "16.0.1"
|
||||
#define STREAM_VERSION_MAJOR 16
|
||||
#define STREAM_VERSION_MINOR 0
|
||||
#define STREAM_VERSION_PATCH 1
|
||||
#define SQL_VERSION "12.0.5"
|
||||
#define SQL_VERSION_MAJOR 12
|
||||
#define SQL_VERSION_MINOR 0
|
||||
#define SQL_VERSION_PATCH 5
|
||||
|
||||
/* Host identifier */
|
||||
#define HOST "amd64-pc-windows-msvc"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH "SHA512"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||
|
||||
#ifndef _Noreturn
|
||||
#define _Noreturn __declspec(noreturn)
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
/* Does your compiler support `__restrict__' keyword? (C99 feature) */
|
||||
#ifndef __restrict__
|
||||
#define __restrict__ restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef __restrict__
|
||||
#define __restrict__ __restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure misc
|
||||
|
||||
// Section: monetdb configure sizes
|
||||
#define SIZEOF_SIZE_T 8
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 8
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_WCHAR_T 2
|
||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLPOINTER
|
||||
#endif
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#endif
|
||||
#define SIZEOF_SQLWCHAR 2
|
||||
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||
#ifndef ssize_t
|
||||
#define ssize_t int64_t
|
||||
#endif
|
||||
|
||||
/* The size of `__int128', as computed by sizeof. */
|
||||
/* #undef SIZEOF___INT128 */
|
||||
|
||||
/* The size of `__int128_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF___INT128_T */
|
||||
|
||||
/* The size of `__uint128_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF___UINT128_T */
|
||||
|
||||
#ifdef SIZEOF___INT128
|
||||
typedef __int128 hge;
|
||||
typedef unsigned __int128 uhge;
|
||||
#define HAVE_HGE 1
|
||||
#define SIZEOF_HGE SIZEOF___INT128
|
||||
#elif defined(SIZEOF___INT128_T) && defined(SIZEOF___UINT128_T)
|
||||
typedef __int128_t hge;
|
||||
typedef __uint128_t uhge;
|
||||
#define HAVE_HGE 1
|
||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure sizes
|
||||
|
||||
/* Does your compiler support `__attribute__' extension? */
|
||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || (__cplusplus < 201103L&&(!defined(_MSC_VER)||_MSC_VER<1600))
|
||||
#ifndef static_assert
|
||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
||||
* in many other compilers we ignore it if the compiler doesn't support it
|
||||
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||
#define static_assert(expr, mesg) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h> /* strcasecmp */
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define strdup(s) _strdup(s)
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef lstat
|
||||
#undef lstat
|
||||
#endif
|
||||
#define lstat _stat64
|
||||
#ifdef stat
|
||||
#undef stat
|
||||
#endif
|
||||
#define stat _stat64
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
#define fstat _fstat64
|
||||
|
||||
static inline char *
|
||||
stpcpy(char *__restrict__ dst, const char *__restrict__ src)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; src[i]; i++)
|
||||
dst[i] = src[i];
|
||||
dst[i] = 0;
|
||||
return dst + i;
|
||||
}
|
||||
|
||||
/* Define to 1 if the system has the type `socklen_t'. */
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
/* type used by connect */
|
||||
#define socklen_t int
|
||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* there is something very similar to localtime_r on Windows: */
|
||||
#include <time.h>
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
static inline struct tm *
|
||||
localtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||
{
|
||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
#define HAVE_GMTIME_R 1
|
||||
static inline struct tm *
|
||||
gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||
{
|
||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
|
||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTIME_R3 1
|
||||
/* there is something very similar to ctime_r on Windows: */
|
||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
#ifndef _MSC_VER
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
#endif
|
||||
|
||||
#ifndef _In_z_
|
||||
#define _In_z_
|
||||
#endif
|
||||
#ifndef _Printf_format_string_
|
||||
#define _Printf_format_string_
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||
static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||
#endif
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) \
|
||||
static void f(void) __attribute__((__constructor__)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||
|
@ -1,473 +1,473 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||
|
||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER < 1900
|
||||
#error Versions below Visual Studio 2015 are no longer supported
|
||||
#endif
|
||||
|
||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
|
||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||
#define HAVE_RAND_S 1
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||
#define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
||||
* versions. We need to include stdlib.h first or else we get
|
||||
* conflicting declarations. */
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* standard C-99 include files */
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/* Windows include files */
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* indicate to sqltypes.h that windows.h has already been included and
|
||||
that it doesn't have to define Windows constants */
|
||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||
|
||||
#define NATIVE_WIN32 1
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if !defined(WIN32) && (defined(__CYGWIN__)||defined(__MINGW32__))
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
// Section: monetdb configure defines
|
||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_IO_H 1
|
||||
/* #undef HAVE_KVM_H */
|
||||
#define HAVE_LIBGEN_H 1
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||
/* #undef HAVE_MACH_TASK_H */
|
||||
/* #undef HAVE_MACH_O_DYLD_H */
|
||||
#define HAVE_NETDB_H 1
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
#define HAVE_POLL_H 1
|
||||
/* #undef HAVE_PROCFS_H */
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
/* #undef HAVE_SYS_SYSCTL_H */
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_RANDOM_H 1
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TIMES_H 1
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
#define HAVE_SYS_UN_H 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_TERMIOS_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_WINSOCK_H 1
|
||||
#define HAVE_SEMAPHORE_H 1
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
#define HAVE_STDATOMIC_H 1
|
||||
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_FDATASYNC 1
|
||||
#define HAVE_ACCEPT4 1
|
||||
#define HAVE_ASCTIME_R 1
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
#define HAVE_CTIME_R 1
|
||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||
/* #undef HAVE_FALLOCATE */
|
||||
#define HAVE_FCNTL 1
|
||||
#define HAVE_FORK 1
|
||||
#define HAVE_FSYNC 1
|
||||
#define HAVE_FTIME 1
|
||||
#define HAVE_GETENTROPY 1
|
||||
/* #undef HAVE_GETEXECNAME */
|
||||
#define HAVE_GETLOGIN 1
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
#define HAVE_GETRLIMIT 1
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
#define HAVE_GETUID 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_STRERROR_R 1
|
||||
#define HAVE_LOCKF 1
|
||||
#define HAVE_MADVISE 1
|
||||
/* #undef HAVE_MREMAP */
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_NL_LANGINFO 1
|
||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||
/* #undef HAVE_PIPE2 */
|
||||
#define HAVE_POLL 1
|
||||
#define HAVE_POPEN 1
|
||||
#define HAVE_POSIX_FADVISE 1
|
||||
#define HAVE_POSIX_FALLOCATE 1
|
||||
#define HAVE_POSIX_MADVISE 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_SETSID 1
|
||||
#define HAVE_SHUTDOWN 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_STPCPY 1
|
||||
#define HAVE_STRCASESTR 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_STRPTIME 1
|
||||
#define HAVE_STRSIGNAL 1
|
||||
#define HAVE_SYSCONF 1
|
||||
/* #undef HAVE_TASK_INFO */
|
||||
#define HAVE_TIMES 1
|
||||
#define HAVE_UNAME 1
|
||||
/* #undef HAVE_SEMTIMEDOP */
|
||||
#define HAVE_PTHREAD_KILL 1
|
||||
#define HAVE_PTHREAD_SIGMASK 1
|
||||
#define HAVE_GETOPT 1
|
||||
|
||||
#define ICONV_CONST
|
||||
#define FLEXIBLE_ARRAY_MEMBER
|
||||
#define ENABLE_MAPI 1
|
||||
#define HAVE_MAPI 1
|
||||
// End Section: monetdb configure defines
|
||||
|
||||
// Section: monetdb macro variables
|
||||
/* #undef HAVE_ICONV */
|
||||
#define HAVE_PTHREAD_H 1
|
||||
/* #undef HAVE_LIBPCRE */
|
||||
/* #undef HAVE_LIBBZ2 */
|
||||
/* #undef HAVE_CURL */
|
||||
/* #undef HAVE_LIBLZMA */
|
||||
/* #undef HAVE_LIBXML */
|
||||
/* #undef HAVE_LIBZ */
|
||||
/* #undef HAVE_LIBLZ4 */
|
||||
/* #undef HAVE_PROJ */
|
||||
/* #undef HAVE_SNAPPY */
|
||||
/* #undef HAVE_FITS */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
/* #undef HAVE_NETCDF */
|
||||
/* #undef HAVE_READLINE */
|
||||
/* #undef HAVE_LIBR */
|
||||
#define RHOME "/registry"
|
||||
/* #undef HAVE_GEOM */
|
||||
/* #undef HAVE_SHP */
|
||||
/* #undef HAVE_LIBPY3 */
|
||||
|
||||
// #define SOCKET_LIBRARIES
|
||||
#define HAVE_GETADDRINFO 1
|
||||
/* #undef HAVE_CUDF */
|
||||
|
||||
#define MAPI_PORT 50000
|
||||
#define MAPI_PORT_STR "50000"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DIR_SEP '\\'
|
||||
#define PATH_SEP ';'
|
||||
#define DIR_SEP_STR "\\"
|
||||
#define SO_PREFIX ""
|
||||
#else
|
||||
#define DIR_SEP '/'
|
||||
#define PATH_SEP ':'
|
||||
#define DIR_SEP_STR "/"
|
||||
#define SO_PREFIX "lib"
|
||||
#endif
|
||||
#define SO_EXT ".dll"
|
||||
|
||||
#define BINDIR "C:/Program Files (x86)/MonetDB/bin"
|
||||
#define LIBDIR "C:/Program Files (x86)/MonetDB/lib"
|
||||
#define LOCALSTATEDIR "C:/Program Files (x86)/MonetDB/var"
|
||||
|
||||
// End Section: monetdb macro variables
|
||||
|
||||
// Section: monetdb configure misc
|
||||
#define MONETDB_RELEASE "unreleased"
|
||||
|
||||
#define MONETDB_VERSION "11.44.0"
|
||||
#define MONETDB_VERSION_MAJOR 11
|
||||
#define MONETDB_VERSION_MINOR 44
|
||||
#define MONETDB_VERSION_PATCH 0
|
||||
|
||||
#define GDK_VERSION "25.1.0"
|
||||
#define GDK_VERSION_MAJOR 25
|
||||
#define GDK_VERSION_MINOR 1
|
||||
#define GDK_VERSION_PATCH 0
|
||||
#define MAPI_VERSION "14.0.2"
|
||||
#define MAPI_VERSION_MAJOR 14
|
||||
#define MAPI_VERSION_MINOR 0
|
||||
#define MAPI_VERSION_PATCH 2
|
||||
#define MONETDB5_VERSION "32.0.6"
|
||||
#define MONETDB5_VERSION_MAJOR 32
|
||||
#define MONETDB5_VERSION_MINOR 0
|
||||
#define MONETDB5_VERSION_PATCH 6
|
||||
#define MONETDBE_VERSION "3.0.2"
|
||||
#define MONETDBE_VERSION_MAJOR 3
|
||||
#define MONETDBE_VERSION_MINOR 0
|
||||
#define MONETDBE_VERSION_PATCH 2
|
||||
#define STREAM_VERSION "16.0.1"
|
||||
#define STREAM_VERSION_MAJOR 16
|
||||
#define STREAM_VERSION_MINOR 0
|
||||
#define STREAM_VERSION_PATCH 1
|
||||
#define SQL_VERSION "12.0.5"
|
||||
#define SQL_VERSION_MAJOR 12
|
||||
#define SQL_VERSION_MINOR 0
|
||||
#define SQL_VERSION_PATCH 5
|
||||
|
||||
/* Host identifier */
|
||||
#define HOST "amd64-pc-windows-gnu"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH "SHA512"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||
|
||||
#ifndef _Noreturn
|
||||
#ifdef __cplusplus
|
||||
#define _Noreturn
|
||||
#else
|
||||
/* #undef _Noreturn */
|
||||
#endif
|
||||
#endif
|
||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||
#ifndef inline
|
||||
#ifdef __cplusplus
|
||||
#define inline
|
||||
#else
|
||||
/* #undef inline */
|
||||
#endif
|
||||
#endif
|
||||
/* Does your compiler support `restrict' keyword? (C99 feature) */
|
||||
#ifndef restrict
|
||||
#ifdef __cplusplus
|
||||
#define restrict
|
||||
#else
|
||||
/* #undef restrict */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure misc
|
||||
|
||||
// Section: monetdb configure sizes
|
||||
#define SIZEOF_SIZE_T 8
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 8
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 8
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_WCHAR_T 2
|
||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLPOINTER
|
||||
#endif
|
||||
#else
|
||||
/* #undef LENP_OR_POINTER_T */
|
||||
#endif
|
||||
/* #undef SIZEOF_SQLWCHAR */
|
||||
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||
#ifndef ssize_t
|
||||
/* #undef ssize_t */
|
||||
#endif
|
||||
|
||||
/* The size of `__int128', as computed by sizeof. */
|
||||
#define SIZEOF___INT128 16
|
||||
|
||||
/* The size of `__int128_t', as computed by sizeof. */
|
||||
#define SIZEOF___INT128_T 16
|
||||
|
||||
/* The size of `__uint128_t', as computed by sizeof. */
|
||||
#define SIZEOF___UINT128_T 16
|
||||
|
||||
#define HAVE___INT128 1
|
||||
#define HAVE___INT128_T 1
|
||||
#define HAVE___UINT128_T 1
|
||||
/* #undef HAVE_HGE */
|
||||
|
||||
#ifdef HAVE_HGE
|
||||
#ifdef HAVE___INT128
|
||||
typedef __int128 hge;
|
||||
typedef unsigned __int128 uhge;
|
||||
#define SIZEOF_HGE SIZEOF___INT128
|
||||
#elif defined(HAVE___INT128_T) && defined(HAVE___UINT128_T)
|
||||
typedef __int128_t hge;
|
||||
typedef __uint128_t uhge;
|
||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure sizes
|
||||
|
||||
/* Does your compiler support `__attribute__' extension? */
|
||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || __cplusplus < 201103L
|
||||
#ifndef static_assert
|
||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
||||
* in many other compilers we ignore it if the compiler doesn't support it
|
||||
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||
#define static_assert(expr, mesg) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h> /* strcasecmp */
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define strdup(s) _strdup(s)
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef lstat
|
||||
#undef lstat
|
||||
#endif
|
||||
#define lstat _stat64
|
||||
#ifdef stat
|
||||
#undef stat
|
||||
#endif
|
||||
#define stat _stat64
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
#define fstat _fstat64
|
||||
|
||||
static inline char *
|
||||
stpcpy(char *restrict dst, const char *restrict src)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; src[i]; i++)
|
||||
dst[i] = src[i];
|
||||
dst[i] = 0;
|
||||
return dst + i;
|
||||
}
|
||||
|
||||
/* Define to 1 if the system has the type `socklen_t'. */
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
/* type used by connect */
|
||||
#define socklen_t int
|
||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* there is something very similar to localtime_r on Windows: */
|
||||
#include <time.h>
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
static inline struct tm *
|
||||
localtime_r(const time_t *restrict timep, struct tm *restrict result)
|
||||
{
|
||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
#define HAVE_GMTIME_R 1
|
||||
static inline struct tm *
|
||||
gmtime_r(const time_t *restrict timep, struct tm *restrict result)
|
||||
{
|
||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
|
||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTIME_R3 1
|
||||
/* there is something very similar to ctime_r on Windows: */
|
||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* #undef HAVE_SOCKLEN_T */
|
||||
#ifndef _MSC_VER
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
#endif
|
||||
|
||||
#ifndef _In_z_
|
||||
#define _In_z_
|
||||
#endif
|
||||
#ifndef _Printf_format_string_
|
||||
#define _Printf_format_string_
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||
static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||
#endif
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) \
|
||||
static void f(void) __attribute__((__constructor__)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||
|
||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER < 1900
|
||||
#error Versions below Visual Studio 2015 are no longer supported
|
||||
#endif
|
||||
|
||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
|
||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||
#define HAVE_RAND_S 1
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||
#define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
||||
* versions. We need to include stdlib.h first or else we get
|
||||
* conflicting declarations. */
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* standard C-99 include files */
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/* Windows include files */
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* indicate to sqltypes.h that windows.h has already been included and
|
||||
that it doesn't have to define Windows constants */
|
||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||
|
||||
#define NATIVE_WIN32 1
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if !defined(WIN32) && (defined(__CYGWIN__)||defined(__MINGW32__))
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
// Section: monetdb configure defines
|
||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_IO_H 1
|
||||
/* #undef HAVE_KVM_H */
|
||||
#define HAVE_LIBGEN_H 1
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||
/* #undef HAVE_MACH_TASK_H */
|
||||
/* #undef HAVE_MACH_O_DYLD_H */
|
||||
#define HAVE_NETDB_H 1
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
#define HAVE_POLL_H 1
|
||||
/* #undef HAVE_PROCFS_H */
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
/* #undef HAVE_SYS_SYSCTL_H */
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_RANDOM_H 1
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TIMES_H 1
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
#define HAVE_SYS_UN_H 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_TERMIOS_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_WINSOCK_H 1
|
||||
#define HAVE_SEMAPHORE_H 1
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
#define HAVE_STDATOMIC_H 1
|
||||
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_FDATASYNC 1
|
||||
#define HAVE_ACCEPT4 1
|
||||
#define HAVE_ASCTIME_R 1
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
#define HAVE_CTIME_R 1
|
||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||
/* #undef HAVE_FALLOCATE */
|
||||
#define HAVE_FCNTL 1
|
||||
#define HAVE_FORK 1
|
||||
#define HAVE_FSYNC 1
|
||||
#define HAVE_FTIME 1
|
||||
#define HAVE_GETENTROPY 1
|
||||
/* #undef HAVE_GETEXECNAME */
|
||||
#define HAVE_GETLOGIN 1
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
#define HAVE_GETRLIMIT 1
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
#define HAVE_GETUID 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_STRERROR_R 1
|
||||
#define HAVE_LOCKF 1
|
||||
#define HAVE_MADVISE 1
|
||||
/* #undef HAVE_MREMAP */
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_NL_LANGINFO 1
|
||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||
/* #undef HAVE_PIPE2 */
|
||||
#define HAVE_POLL 1
|
||||
#define HAVE_POPEN 1
|
||||
#define HAVE_POSIX_FADVISE 1
|
||||
#define HAVE_POSIX_FALLOCATE 1
|
||||
#define HAVE_POSIX_MADVISE 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_SETSID 1
|
||||
#define HAVE_SHUTDOWN 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_STPCPY 1
|
||||
#define HAVE_STRCASESTR 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_STRPTIME 1
|
||||
#define HAVE_STRSIGNAL 1
|
||||
#define HAVE_SYSCONF 1
|
||||
/* #undef HAVE_TASK_INFO */
|
||||
#define HAVE_TIMES 1
|
||||
#define HAVE_UNAME 1
|
||||
/* #undef HAVE_SEMTIMEDOP */
|
||||
#define HAVE_PTHREAD_KILL 1
|
||||
#define HAVE_PTHREAD_SIGMASK 1
|
||||
#define HAVE_GETOPT 1
|
||||
|
||||
#define ICONV_CONST
|
||||
#define FLEXIBLE_ARRAY_MEMBER
|
||||
#define ENABLE_MAPI 1
|
||||
#define HAVE_MAPI 1
|
||||
// End Section: monetdb configure defines
|
||||
|
||||
// Section: monetdb macro variables
|
||||
/* #undef HAVE_ICONV */
|
||||
#define HAVE_PTHREAD_H 1
|
||||
/* #undef HAVE_LIBPCRE */
|
||||
/* #undef HAVE_LIBBZ2 */
|
||||
/* #undef HAVE_CURL */
|
||||
/* #undef HAVE_LIBLZMA */
|
||||
/* #undef HAVE_LIBXML */
|
||||
/* #undef HAVE_LIBZ */
|
||||
/* #undef HAVE_LIBLZ4 */
|
||||
/* #undef HAVE_PROJ */
|
||||
/* #undef HAVE_SNAPPY */
|
||||
/* #undef HAVE_FITS */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
/* #undef HAVE_NETCDF */
|
||||
/* #undef HAVE_READLINE */
|
||||
/* #undef HAVE_LIBR */
|
||||
#define RHOME "/registry"
|
||||
/* #undef HAVE_GEOM */
|
||||
/* #undef HAVE_SHP */
|
||||
/* #undef HAVE_LIBPY3 */
|
||||
|
||||
// #define SOCKET_LIBRARIES
|
||||
#define HAVE_GETADDRINFO 1
|
||||
/* #undef HAVE_CUDF */
|
||||
|
||||
#define MAPI_PORT 50000
|
||||
#define MAPI_PORT_STR "50000"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DIR_SEP '\\'
|
||||
#define PATH_SEP ';'
|
||||
#define DIR_SEP_STR "\\"
|
||||
#define SO_PREFIX ""
|
||||
#else
|
||||
#define DIR_SEP '/'
|
||||
#define PATH_SEP ':'
|
||||
#define DIR_SEP_STR "/"
|
||||
#define SO_PREFIX "lib"
|
||||
#endif
|
||||
#define SO_EXT ".dll"
|
||||
|
||||
#define BINDIR "C:/Program Files (x86)/MonetDB/bin"
|
||||
#define LIBDIR "C:/Program Files (x86)/MonetDB/lib"
|
||||
#define LOCALSTATEDIR "C:/Program Files (x86)/MonetDB/var"
|
||||
|
||||
// End Section: monetdb macro variables
|
||||
|
||||
// Section: monetdb configure misc
|
||||
#define MONETDB_RELEASE "unreleased"
|
||||
|
||||
#define MONETDB_VERSION "11.44.0"
|
||||
#define MONETDB_VERSION_MAJOR 11
|
||||
#define MONETDB_VERSION_MINOR 44
|
||||
#define MONETDB_VERSION_PATCH 0
|
||||
|
||||
#define GDK_VERSION "25.1.0"
|
||||
#define GDK_VERSION_MAJOR 25
|
||||
#define GDK_VERSION_MINOR 1
|
||||
#define GDK_VERSION_PATCH 0
|
||||
#define MAPI_VERSION "14.0.2"
|
||||
#define MAPI_VERSION_MAJOR 14
|
||||
#define MAPI_VERSION_MINOR 0
|
||||
#define MAPI_VERSION_PATCH 2
|
||||
#define MONETDB5_VERSION "32.0.6"
|
||||
#define MONETDB5_VERSION_MAJOR 32
|
||||
#define MONETDB5_VERSION_MINOR 0
|
||||
#define MONETDB5_VERSION_PATCH 6
|
||||
#define MONETDBE_VERSION "3.0.2"
|
||||
#define MONETDBE_VERSION_MAJOR 3
|
||||
#define MONETDBE_VERSION_MINOR 0
|
||||
#define MONETDBE_VERSION_PATCH 2
|
||||
#define STREAM_VERSION "16.0.1"
|
||||
#define STREAM_VERSION_MAJOR 16
|
||||
#define STREAM_VERSION_MINOR 0
|
||||
#define STREAM_VERSION_PATCH 1
|
||||
#define SQL_VERSION "12.0.5"
|
||||
#define SQL_VERSION_MAJOR 12
|
||||
#define SQL_VERSION_MINOR 0
|
||||
#define SQL_VERSION_PATCH 5
|
||||
|
||||
/* Host identifier */
|
||||
#define HOST "amd64-pc-windows-gnu"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH "SHA512"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||
|
||||
#ifndef _Noreturn
|
||||
#ifdef __cplusplus
|
||||
#define _Noreturn
|
||||
#else
|
||||
/* #undef _Noreturn */
|
||||
#endif
|
||||
#endif
|
||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||
#ifndef inline
|
||||
#ifdef __cplusplus
|
||||
#define inline
|
||||
#else
|
||||
/* #undef inline */
|
||||
#endif
|
||||
#endif
|
||||
/* Does your compiler support `restrict' keyword? (C99 feature) */
|
||||
#ifndef restrict
|
||||
#ifdef __cplusplus
|
||||
#define restrict
|
||||
#else
|
||||
/* #undef restrict */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure misc
|
||||
|
||||
// Section: monetdb configure sizes
|
||||
#define SIZEOF_SIZE_T 8
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 8
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 8
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_WCHAR_T 2
|
||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLPOINTER
|
||||
#endif
|
||||
#else
|
||||
/* #undef LENP_OR_POINTER_T */
|
||||
#endif
|
||||
/* #undef SIZEOF_SQLWCHAR */
|
||||
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||
#ifndef ssize_t
|
||||
/* #undef ssize_t */
|
||||
#endif
|
||||
|
||||
/* The size of `__int128', as computed by sizeof. */
|
||||
#define SIZEOF___INT128 16
|
||||
|
||||
/* The size of `__int128_t', as computed by sizeof. */
|
||||
#define SIZEOF___INT128_T 16
|
||||
|
||||
/* The size of `__uint128_t', as computed by sizeof. */
|
||||
#define SIZEOF___UINT128_T 16
|
||||
|
||||
#define HAVE___INT128 1
|
||||
#define HAVE___INT128_T 1
|
||||
#define HAVE___UINT128_T 1
|
||||
/* #undef HAVE_HGE */
|
||||
|
||||
#ifdef HAVE_HGE
|
||||
#ifdef HAVE___INT128
|
||||
typedef __int128 hge;
|
||||
typedef unsigned __int128 uhge;
|
||||
#define SIZEOF_HGE SIZEOF___INT128
|
||||
#elif defined(HAVE___INT128_T) && defined(HAVE___UINT128_T)
|
||||
typedef __int128_t hge;
|
||||
typedef __uint128_t uhge;
|
||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure sizes
|
||||
|
||||
/* Does your compiler support `__attribute__' extension? */
|
||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || __cplusplus < 201103L
|
||||
#ifndef static_assert
|
||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
||||
* in many other compilers we ignore it if the compiler doesn't support it
|
||||
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||
#define static_assert(expr, mesg) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h> /* strcasecmp */
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define strdup(s) _strdup(s)
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef lstat
|
||||
#undef lstat
|
||||
#endif
|
||||
#define lstat _stat64
|
||||
#ifdef stat
|
||||
#undef stat
|
||||
#endif
|
||||
#define stat _stat64
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
#define fstat _fstat64
|
||||
|
||||
static inline char *
|
||||
stpcpy(char *restrict dst, const char *restrict src)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; src[i]; i++)
|
||||
dst[i] = src[i];
|
||||
dst[i] = 0;
|
||||
return dst + i;
|
||||
}
|
||||
|
||||
/* Define to 1 if the system has the type `socklen_t'. */
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
/* type used by connect */
|
||||
#define socklen_t int
|
||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* there is something very similar to localtime_r on Windows: */
|
||||
#include <time.h>
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
static inline struct tm *
|
||||
localtime_r(const time_t *restrict timep, struct tm *restrict result)
|
||||
{
|
||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
#define HAVE_GMTIME_R 1
|
||||
static inline struct tm *
|
||||
gmtime_r(const time_t *restrict timep, struct tm *restrict result)
|
||||
{
|
||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
|
||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTIME_R3 1
|
||||
/* there is something very similar to ctime_r on Windows: */
|
||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* #undef HAVE_SOCKLEN_T */
|
||||
#ifndef _MSC_VER
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
#endif
|
||||
|
||||
#ifndef _In_z_
|
||||
#define _In_z_
|
||||
#endif
|
||||
#ifndef _Printf_format_string_
|
||||
#define _Printf_format_string_
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||
static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||
#endif
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) \
|
||||
static void f(void) __attribute__((__constructor__)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||
|
@ -1,190 +1,190 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
|
||||
#ifndef _MONETDBE_LIB_
|
||||
#define _MONETDBE_LIB_
|
||||
|
||||
#include "monetdb_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef LIBMONETDBE
|
||||
#define monetdbe_export extern __declspec(dllimport)
|
||||
#else
|
||||
#define monetdbe_export extern __declspec(dllexport)
|
||||
#endif
|
||||
#else
|
||||
#define monetdbe_export extern
|
||||
#endif
|
||||
|
||||
typedef int64_t monetdbe_cnt;
|
||||
|
||||
typedef struct {
|
||||
unsigned char day;
|
||||
unsigned char month;
|
||||
short year;
|
||||
} monetdbe_data_date;
|
||||
|
||||
typedef struct {
|
||||
unsigned int ms;
|
||||
unsigned char seconds;
|
||||
unsigned char minutes;
|
||||
unsigned char hours;
|
||||
} monetdbe_data_time;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_data_date date;
|
||||
monetdbe_data_time time;
|
||||
} monetdbe_data_timestamp;
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
char* data;
|
||||
} monetdbe_data_blob;
|
||||
|
||||
typedef enum {
|
||||
monetdbe_bool, monetdbe_int8_t, monetdbe_int16_t, monetdbe_int32_t, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#endif
|
||||
monetdbe_size_t, monetdbe_float, monetdbe_double,
|
||||
monetdbe_str, monetdbe_blob,
|
||||
monetdbe_date, monetdbe_time, monetdbe_timestamp,
|
||||
|
||||
// should be last:
|
||||
monetdbe_type_unknown
|
||||
} monetdbe_types;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
unsigned int scale;
|
||||
unsigned int digits;
|
||||
} monetdbe_sql_type;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_types type;
|
||||
monetdbe_sql_type sql_type;
|
||||
void *data;
|
||||
size_t count;
|
||||
char* name;
|
||||
} monetdbe_column;
|
||||
|
||||
typedef struct {
|
||||
size_t nparam;
|
||||
monetdbe_types *type;
|
||||
} monetdbe_statement;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_cnt nrows;
|
||||
size_t ncols;
|
||||
char *name;
|
||||
monetdbe_cnt last_id; /* last auto incremented id */
|
||||
} monetdbe_result;
|
||||
|
||||
typedef void* monetdbe_database;
|
||||
|
||||
typedef struct {
|
||||
const char *host;
|
||||
int port;
|
||||
const char *database;
|
||||
const char *username;
|
||||
const char *password;
|
||||
const char *lang;
|
||||
} monetdbe_remote;
|
||||
|
||||
typedef struct {
|
||||
const char *host;
|
||||
const char* port;
|
||||
const char* usock;
|
||||
} monetdbe_mapi_server;
|
||||
|
||||
typedef struct {
|
||||
int memorylimit; // top off the amount of RAM to be used, in MB
|
||||
int querytimeout; // graceful terminate query after a few seconds
|
||||
int sessiontimeout; // graceful terminate the session after a few seconds
|
||||
int nr_threads; // maximum number of worker treads, limits level of parallelism
|
||||
monetdbe_remote* remote;
|
||||
monetdbe_mapi_server* mapi_server;
|
||||
const char *trace_file; // file to which log output should be written
|
||||
} monetdbe_options;
|
||||
|
||||
#define DEFAULT_STRUCT_DEFINITION(ctype, typename) \
|
||||
typedef struct \
|
||||
{ \
|
||||
monetdbe_types type; \
|
||||
monetdbe_sql_type sql_type; \
|
||||
ctype *data; \
|
||||
size_t count; \
|
||||
char *name; \
|
||||
ctype null_value; \
|
||||
double scale; \
|
||||
int (*is_null)(ctype *value); \
|
||||
} monetdbe_column_##typename
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(int8_t, bool);
|
||||
DEFAULT_STRUCT_DEFINITION(int8_t, int8_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int16_t, int16_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int32_t, int32_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int64_t, int64_t);
|
||||
#ifdef HAVE_HGE
|
||||
DEFAULT_STRUCT_DEFINITION(__int128, int128_t);
|
||||
#endif
|
||||
DEFAULT_STRUCT_DEFINITION(size_t, size_t);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(float, float);
|
||||
DEFAULT_STRUCT_DEFINITION(double, double);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(char *, str);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_blob, blob);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_date, date);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_time, time);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_timestamp, timestamp);
|
||||
// UUID, INET, XML ?
|
||||
|
||||
monetdbe_export const char *monetdbe_version(void);
|
||||
|
||||
monetdbe_export int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *opts);
|
||||
/* 0 ok, -1 (allocation failed), -2 error in db */
|
||||
monetdbe_export int monetdbe_close(monetdbe_database db);
|
||||
|
||||
monetdbe_export char* monetdbe_error(monetdbe_database db);
|
||||
|
||||
monetdbe_export char* monetdbe_get_autocommit(monetdbe_database dbhdl, int* result);
|
||||
monetdbe_export char* monetdbe_set_autocommit(monetdbe_database dbhdl, int value);
|
||||
monetdbe_export int monetdbe_in_transaction(monetdbe_database dbhdl);
|
||||
|
||||
monetdbe_export char* monetdbe_query(monetdbe_database dbhdl, char* query, monetdbe_result** result, monetdbe_cnt* affected_rows);
|
||||
monetdbe_export char* monetdbe_result_fetch(monetdbe_result *mres, monetdbe_column** res, size_t column_index);
|
||||
monetdbe_export char* monetdbe_cleanup_result(monetdbe_database dbhdl, monetdbe_result* result);
|
||||
|
||||
monetdbe_export char* monetdbe_prepare(monetdbe_database dbhdl, char *query, monetdbe_statement **stmt, monetdbe_result** result);
|
||||
monetdbe_export char* monetdbe_bind(monetdbe_statement *stmt, void *data, size_t parameter_nr);
|
||||
monetdbe_export char* monetdbe_execute(monetdbe_statement *stmt, monetdbe_result **result, monetdbe_cnt* affected_rows);
|
||||
monetdbe_export char* monetdbe_cleanup_statement(monetdbe_database dbhdl, monetdbe_statement *stmt);
|
||||
|
||||
monetdbe_export char* monetdbe_append(monetdbe_database dbhdl, const char* schema, const char* table, monetdbe_column **input, size_t column_count);
|
||||
monetdbe_export const void* monetdbe_null(monetdbe_database dbhdl, monetdbe_types t);
|
||||
|
||||
monetdbe_export char* monetdbe_get_columns(monetdbe_database dbhdl, const char* schema_name, const char *table_name, size_t *column_count, monetdbe_column **columns);
|
||||
|
||||
monetdbe_export char* monetdbe_dump_database(monetdbe_database dbhdl, const char *backupfile);
|
||||
monetdbe_export char* monetdbe_dump_table(monetdbe_database dbhdl, const char *schema_name, const char *table_name, const char *backupfile);
|
||||
monetdbe_export const char* monetdbe_get_mapi_port(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
|
||||
#ifndef _MONETDBE_LIB_
|
||||
#define _MONETDBE_LIB_
|
||||
|
||||
#include "monetdb_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef LIBMONETDBE
|
||||
#define monetdbe_export extern __declspec(dllimport)
|
||||
#else
|
||||
#define monetdbe_export extern __declspec(dllexport)
|
||||
#endif
|
||||
#else
|
||||
#define monetdbe_export extern
|
||||
#endif
|
||||
|
||||
typedef int64_t monetdbe_cnt;
|
||||
|
||||
typedef struct {
|
||||
unsigned char day;
|
||||
unsigned char month;
|
||||
short year;
|
||||
} monetdbe_data_date;
|
||||
|
||||
typedef struct {
|
||||
unsigned int ms;
|
||||
unsigned char seconds;
|
||||
unsigned char minutes;
|
||||
unsigned char hours;
|
||||
} monetdbe_data_time;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_data_date date;
|
||||
monetdbe_data_time time;
|
||||
} monetdbe_data_timestamp;
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
char* data;
|
||||
} monetdbe_data_blob;
|
||||
|
||||
typedef enum {
|
||||
monetdbe_bool, monetdbe_int8_t, monetdbe_int16_t, monetdbe_int32_t, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#endif
|
||||
monetdbe_size_t, monetdbe_float, monetdbe_double,
|
||||
monetdbe_str, monetdbe_blob,
|
||||
monetdbe_date, monetdbe_time, monetdbe_timestamp,
|
||||
|
||||
// should be last:
|
||||
monetdbe_type_unknown
|
||||
} monetdbe_types;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
unsigned int scale;
|
||||
unsigned int digits;
|
||||
} monetdbe_sql_type;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_types type;
|
||||
monetdbe_sql_type sql_type;
|
||||
void *data;
|
||||
size_t count;
|
||||
char* name;
|
||||
} monetdbe_column;
|
||||
|
||||
typedef struct {
|
||||
size_t nparam;
|
||||
monetdbe_types *type;
|
||||
} monetdbe_statement;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_cnt nrows;
|
||||
size_t ncols;
|
||||
char *name;
|
||||
monetdbe_cnt last_id; /* last auto incremented id */
|
||||
} monetdbe_result;
|
||||
|
||||
typedef void* monetdbe_database;
|
||||
|
||||
typedef struct {
|
||||
const char *host;
|
||||
int port;
|
||||
const char *database;
|
||||
const char *username;
|
||||
const char *password;
|
||||
const char *lang;
|
||||
} monetdbe_remote;
|
||||
|
||||
typedef struct {
|
||||
const char *host;
|
||||
const char* port;
|
||||
const char* usock;
|
||||
} monetdbe_mapi_server;
|
||||
|
||||
typedef struct {
|
||||
int memorylimit; // top off the amount of RAM to be used, in MB
|
||||
int querytimeout; // graceful terminate query after a few seconds
|
||||
int sessiontimeout; // graceful terminate the session after a few seconds
|
||||
int nr_threads; // maximum number of worker treads, limits level of parallelism
|
||||
monetdbe_remote* remote;
|
||||
monetdbe_mapi_server* mapi_server;
|
||||
const char *trace_file; // file to which log output should be written
|
||||
} monetdbe_options;
|
||||
|
||||
#define DEFAULT_STRUCT_DEFINITION(ctype, typename) \
|
||||
typedef struct \
|
||||
{ \
|
||||
monetdbe_types type; \
|
||||
monetdbe_sql_type sql_type; \
|
||||
ctype *data; \
|
||||
size_t count; \
|
||||
char *name; \
|
||||
ctype null_value; \
|
||||
double scale; \
|
||||
int (*is_null)(ctype *value); \
|
||||
} monetdbe_column_##typename
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(int8_t, bool);
|
||||
DEFAULT_STRUCT_DEFINITION(int8_t, int8_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int16_t, int16_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int32_t, int32_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int64_t, int64_t);
|
||||
#ifdef HAVE_HGE
|
||||
DEFAULT_STRUCT_DEFINITION(__int128, int128_t);
|
||||
#endif
|
||||
DEFAULT_STRUCT_DEFINITION(size_t, size_t);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(float, float);
|
||||
DEFAULT_STRUCT_DEFINITION(double, double);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(char *, str);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_blob, blob);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_date, date);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_time, time);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_timestamp, timestamp);
|
||||
// UUID, INET, XML ?
|
||||
|
||||
monetdbe_export const char *monetdbe_version(void);
|
||||
|
||||
monetdbe_export int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *opts);
|
||||
/* 0 ok, -1 (allocation failed), -2 error in db */
|
||||
monetdbe_export int monetdbe_close(monetdbe_database db);
|
||||
|
||||
monetdbe_export char* monetdbe_error(monetdbe_database db);
|
||||
|
||||
monetdbe_export char* monetdbe_get_autocommit(monetdbe_database dbhdl, int* result);
|
||||
monetdbe_export char* monetdbe_set_autocommit(monetdbe_database dbhdl, int value);
|
||||
monetdbe_export int monetdbe_in_transaction(monetdbe_database dbhdl);
|
||||
|
||||
monetdbe_export char* monetdbe_query(monetdbe_database dbhdl, char* query, monetdbe_result** result, monetdbe_cnt* affected_rows);
|
||||
monetdbe_export char* monetdbe_result_fetch(monetdbe_result *mres, monetdbe_column** res, size_t column_index);
|
||||
monetdbe_export char* monetdbe_cleanup_result(monetdbe_database dbhdl, monetdbe_result* result);
|
||||
|
||||
monetdbe_export char* monetdbe_prepare(monetdbe_database dbhdl, char *query, monetdbe_statement **stmt, monetdbe_result** result);
|
||||
monetdbe_export char* monetdbe_bind(monetdbe_statement *stmt, void *data, size_t parameter_nr);
|
||||
monetdbe_export char* monetdbe_execute(monetdbe_statement *stmt, monetdbe_result **result, monetdbe_cnt* affected_rows);
|
||||
monetdbe_export char* monetdbe_cleanup_statement(monetdbe_database dbhdl, monetdbe_statement *stmt);
|
||||
|
||||
monetdbe_export char* monetdbe_append(monetdbe_database dbhdl, const char* schema, const char* table, monetdbe_column **input, size_t column_count);
|
||||
monetdbe_export const void* monetdbe_null(monetdbe_database dbhdl, monetdbe_types t);
|
||||
|
||||
monetdbe_export char* monetdbe_get_columns(monetdbe_database dbhdl, const char* schema_name, const char *table_name, size_t *column_count, monetdbe_column **columns);
|
||||
|
||||
monetdbe_export char* monetdbe_dump_database(monetdbe_database dbhdl, const char *backupfile);
|
||||
monetdbe_export char* monetdbe_dump_table(monetdbe_database dbhdl, const char *schema_name, const char *table_name, const char *backupfile);
|
||||
monetdbe_export const char* monetdbe_get_mapi_port(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,239 +1,239 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{b52aacf7-16a6-4fca-90ad-867d367bda4f}</ProjectGuid>
|
||||
<RootNamespace>libaquery</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.lib</TargetExt>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.lib</TargetExt>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\csv.h" />
|
||||
<ClInclude Include="..\server\aggregations.h" />
|
||||
<ClInclude Include="..\server\gc.hpp" />
|
||||
<ClInclude Include="..\server\hasher.h" />
|
||||
<ClInclude Include="..\server\io.h" />
|
||||
<ClInclude Include="..\server\libaquery.h" />
|
||||
<ClInclude Include="..\server\priority_vector.hpp" />
|
||||
<ClInclude Include="..\server\table.h" />
|
||||
<ClInclude Include="..\server\types.h" />
|
||||
<ClInclude Include="..\server\utils.h" />
|
||||
<ClInclude Include="..\server\vector_type.hpp" />
|
||||
<ClInclude Include="..\server\winhelper.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\server\cpp.hint" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\server\server.cpp" />
|
||||
<ClCompile Include="..\server\winhelper.cpp" />
|
||||
<ClCompile Include="..\server\io.cpp" />
|
||||
<ClCompile Include="..\server\monetdb_conn.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{b52aacf7-16a6-4fca-90ad-867d367bda4f}</ProjectGuid>
|
||||
<RootNamespace>libaquery</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.lib</TargetExt>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.lib</TargetExt>
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\csv.h" />
|
||||
<ClInclude Include="..\server\aggregations.h" />
|
||||
<ClInclude Include="..\server\gc.hpp" />
|
||||
<ClInclude Include="..\server\hasher.h" />
|
||||
<ClInclude Include="..\server\io.h" />
|
||||
<ClInclude Include="..\server\libaquery.h" />
|
||||
<ClInclude Include="..\server\priority_vector.hpp" />
|
||||
<ClInclude Include="..\server\table.h" />
|
||||
<ClInclude Include="..\server\types.h" />
|
||||
<ClInclude Include="..\server\utils.h" />
|
||||
<ClInclude Include="..\server\vector_type.hpp" />
|
||||
<ClInclude Include="..\server\winhelper.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\server\cpp.hint" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\server\server.cpp" />
|
||||
<ClCompile Include="..\server\winhelper.cpp" />
|
||||
<ClCompile Include="..\server\io.cpp" />
|
||||
<ClCompile Include="..\server\monetdb_conn.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,236 +1,236 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8081fdaa-4d13-4b7a-adb2-8224af7f1c81}</ProjectGuid>
|
||||
<RootNamespace>Project1</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>msc-plugin</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
<EnableFuzzer>false</EnableFuzzer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<EnableModules>false</EnableModules>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<EnableModules>false</EnableModules>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_ALLOW_RTCc_IN_STL;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<EnableModules>false</EnableModules>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<SmallerTypeCheck>true</SmallerTypeCheck>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<EnableModules>false</EnableModules>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\out.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8081fdaa-4d13-4b7a-adb2-8224af7f1c81}</ProjectGuid>
|
||||
<RootNamespace>Project1</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>msc-plugin</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
<EnableFuzzer>false</EnableFuzzer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetExt />
|
||||
<TargetName>dll.so</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<EnableModules>false</EnableModules>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<EnableModules>false</EnableModules>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_ALLOW_RTCc_IN_STL;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<EnableModules>false</EnableModules>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<SmallerTypeCheck>true</SmallerTypeCheck>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||
<EnableModules>false</EnableModules>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AssemblyDebug>false</AssemblyDebug>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\out.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,167 +1,167 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{f954797b-c148-4cbf-9fb4-a9a450efec38}</ProjectGuid>
|
||||
<RootNamespace>Project1</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\sdk\aquery.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\sdk\aquery_mem.cpp" />
|
||||
<ClCompile Include="..\sdk\example.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{f954797b-c148-4cbf-9fb4-a9a450efec38}</ProjectGuid>
|
||||
<RootNamespace>Project1</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)..\</OutDir>
|
||||
<TargetName>test</TargetName>
|
||||
<TargetExt>.so</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\sdk\aquery.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\sdk\aquery_mem.cpp" />
|
||||
<ClCompile Include="..\sdk\example.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,63 +1,63 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>ccc243f5-663e-45b7-a6de-b2468c58b3a7</ProjectGuid>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>..\prompt.py</StartupFile>
|
||||
<SearchPath>..\msvs-py</SearchPath>
|
||||
<WorkingDirectory>..</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>msvs-py</Name>
|
||||
<RootNamespace>msvs-py</RootNamespace>
|
||||
<IsWindowsApplication>False</IsWindowsApplication>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="..\aquery_parser\" />
|
||||
<Folder Include="..\engine\" />
|
||||
<Folder Include="parser\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\aquery_parser\keywords.py" />
|
||||
<Compile Include="..\aquery_parser\sql_parser.py" />
|
||||
<Compile Include="..\aquery_parser\types.py" />
|
||||
<Compile Include="..\aquery_parser\utils.py" />
|
||||
<Compile Include="..\aquery_parser\windows.py" />
|
||||
<Compile Include="..\aquery_parser\__init__.py" />
|
||||
<Compile Include="..\engine\ast.py" />
|
||||
<Compile Include="..\engine\ddl.py" />
|
||||
<Compile Include="..\engine\expr.py" />
|
||||
<Compile Include="..\engine\groupby.py" />
|
||||
<Compile Include="..\engine\join.py" />
|
||||
<Compile Include="..\engine\orderby.py" />
|
||||
<Compile Include="..\engine\projection.py" />
|
||||
<Compile Include="..\engine\scan.py" />
|
||||
<Compile Include="..\engine\types.py" />
|
||||
<Compile Include="..\reconstruct\storage.py" />
|
||||
<Compile Include="..\reconstruct\expr.py" />
|
||||
<Compile Include="..\reconstruct\__init__.py" />
|
||||
<Compile Include="..\reconstruct\ast.py" />
|
||||
<Compile Include="..\engine\__init__.py" />
|
||||
<Compile Include="..\prompt.py" />
|
||||
<Compile Include="..\build.py" />
|
||||
<Compile Include="..\aquery_config.py" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>ccc243f5-663e-45b7-a6de-b2468c58b3a7</ProjectGuid>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>..\prompt.py</StartupFile>
|
||||
<SearchPath>..\msvs-py</SearchPath>
|
||||
<WorkingDirectory>..</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>msvs-py</Name>
|
||||
<RootNamespace>msvs-py</RootNamespace>
|
||||
<IsWindowsApplication>False</IsWindowsApplication>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="..\aquery_parser\" />
|
||||
<Folder Include="..\engine\" />
|
||||
<Folder Include="parser\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\aquery_parser\keywords.py" />
|
||||
<Compile Include="..\aquery_parser\sql_parser.py" />
|
||||
<Compile Include="..\aquery_parser\types.py" />
|
||||
<Compile Include="..\aquery_parser\utils.py" />
|
||||
<Compile Include="..\aquery_parser\windows.py" />
|
||||
<Compile Include="..\aquery_parser\__init__.py" />
|
||||
<Compile Include="..\engine\ast.py" />
|
||||
<Compile Include="..\engine\ddl.py" />
|
||||
<Compile Include="..\engine\expr.py" />
|
||||
<Compile Include="..\engine\groupby.py" />
|
||||
<Compile Include="..\engine\join.py" />
|
||||
<Compile Include="..\engine\orderby.py" />
|
||||
<Compile Include="..\engine\projection.py" />
|
||||
<Compile Include="..\engine\scan.py" />
|
||||
<Compile Include="..\engine\types.py" />
|
||||
<Compile Include="..\reconstruct\storage.py" />
|
||||
<Compile Include="..\reconstruct\expr.py" />
|
||||
<Compile Include="..\reconstruct\__init__.py" />
|
||||
<Compile Include="..\reconstruct\ast.py" />
|
||||
<Compile Include="..\engine\__init__.py" />
|
||||
<Compile Include="..\prompt.py" />
|
||||
<Compile Include="..\build.py" />
|
||||
<Compile Include="..\aquery_config.py" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
</Project>
|
@ -1,11 +1,11 @@
|
||||
# TODO:
|
||||
|
||||
## 1. double scans in projections
|
||||
- first for special aggrigations and singular columns
|
||||
- Then in group by node decide if we have special group by aggregations
|
||||
- If sp_gb_agg exists, the entire groupby aggregation is done in C plugin
|
||||
- If not, group by is done in SQL
|
||||
|
||||
## 2. ColRef supports multiple objects
|
||||
- A.a = B.b then in projection A.a B.b will refer to same projection
|
||||
# TODO:
|
||||
|
||||
## 1. double scans in projections
|
||||
- first for special aggrigations and singular columns
|
||||
- Then in group by node decide if we have special group by aggregations
|
||||
- If sp_gb_agg exists, the entire groupby aggregation is done in C plugin
|
||||
- If not, group by is done in SQL
|
||||
|
||||
## 2. ColRef supports multiple objects
|
||||
- A.a = B.b then in projection A.a B.b will refer to same projection
|
||||
- Colref::ProjEq(ColRef v) => this == v or v in this.proj_eqs
|
@ -1,32 +1,32 @@
|
||||
from reconstruct.ast import Context, ast_node
|
||||
saved_cxt = None
|
||||
|
||||
def initialize(cxt = None, keep = False):
|
||||
global saved_cxt
|
||||
if cxt is None or not keep or type(cxt) is not Context:
|
||||
if saved_cxt is None or not keep:
|
||||
cxt = Context()
|
||||
saved_cxt = cxt
|
||||
else:
|
||||
cxt = saved_cxt
|
||||
cxt.new()
|
||||
return cxt
|
||||
|
||||
def generate(ast, cxt):
|
||||
for k in ast.keys():
|
||||
if k in ast_node.types.keys():
|
||||
ast_node.types[k](None, ast, cxt)
|
||||
|
||||
def exec(stmts, cxt = None, keep = False):
|
||||
cxt = initialize(cxt, keep)
|
||||
stmts_stmts = stmts['stmts']
|
||||
if type(stmts_stmts) is list:
|
||||
for s in stmts_stmts:
|
||||
generate(s, cxt)
|
||||
else:
|
||||
generate(stmts_stmts, cxt)
|
||||
for q in cxt.queries:
|
||||
cxt.print(q.strip())
|
||||
return cxt
|
||||
|
||||
__all__ = ["initialize", "generate", "exec", "saved_cxt"]
|
||||
from reconstruct.ast import Context, ast_node
|
||||
saved_cxt = None
|
||||
|
||||
def initialize(cxt = None, keep = False):
|
||||
global saved_cxt
|
||||
if cxt is None or not keep or type(cxt) is not Context:
|
||||
if saved_cxt is None or not keep:
|
||||
cxt = Context()
|
||||
saved_cxt = cxt
|
||||
else:
|
||||
cxt = saved_cxt
|
||||
cxt.new()
|
||||
return cxt
|
||||
|
||||
def generate(ast, cxt):
|
||||
for k in ast.keys():
|
||||
if k in ast_node.types.keys():
|
||||
ast_node.types[k](None, ast, cxt)
|
||||
|
||||
def exec(stmts, cxt = None, keep = False):
|
||||
cxt = initialize(cxt, keep)
|
||||
stmts_stmts = stmts['stmts']
|
||||
if type(stmts_stmts) is list:
|
||||
for s in stmts_stmts:
|
||||
generate(s, cxt)
|
||||
else:
|
||||
generate(stmts_stmts, cxt)
|
||||
for q in cxt.queries:
|
||||
cxt.print(q.strip())
|
||||
return cxt
|
||||
|
||||
__all__ = ["initialize", "generate", "exec", "saved_cxt"]
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,338 +1,338 @@
|
||||
from typing import Optional
|
||||
from reconstruct.ast import ast_node
|
||||
from reconstruct.storage import ColRef, Context
|
||||
from engine.types import *
|
||||
|
||||
# TODO: Decouple expr and upgrade architecture
|
||||
# C_CODE : get ccode/sql code?
|
||||
# projections : C/SQL/decltype string
|
||||
# orderby/joins/where : SQL only
|
||||
# assumption/groupby : C/sql
|
||||
# is_udfexpr: C only
|
||||
|
||||
class expr(ast_node):
|
||||
name='expr'
|
||||
@property
|
||||
def udf_decltypecall(self):
|
||||
return self._udf_decltypecall if self._udf_decltypecall else self.sql
|
||||
|
||||
@udf_decltypecall.setter
|
||||
def udf_decltypecall(self, val):
|
||||
self._udf_decltypecall = val
|
||||
|
||||
@property
|
||||
def need_decltypestr(self):
|
||||
return self._udf_decltypecall is not None
|
||||
|
||||
def __init__(self, parent, node, *, c_code = None, supress_undefined = False):
|
||||
from reconstruct.ast import projection, udf
|
||||
|
||||
self.type = None
|
||||
self.raw_col = None
|
||||
self.udf : Optional[udf] = None
|
||||
self.inside_agg = False
|
||||
self.is_special = False
|
||||
self.is_ColExpr = False
|
||||
self.is_recursive_call_inudf = False
|
||||
self.codlets : list = []
|
||||
self.codebuf : Optional[str] = None
|
||||
self._udf_decltypecall = None
|
||||
self.node = node
|
||||
self.supress_undefined = supress_undefined
|
||||
if(type(parent) is expr):
|
||||
self.inside_agg = parent.inside_agg
|
||||
self.is_udfexpr = parent.is_udfexpr
|
||||
self.is_agg_func = parent.is_agg_func
|
||||
self.root : expr = parent.root
|
||||
self.c_code = parent.c_code
|
||||
self.builtin_vars = parent.builtin_vars
|
||||
else:
|
||||
self.is_agg_func = False
|
||||
self.is_udfexpr = type(parent) is udf
|
||||
self.root : expr = self
|
||||
self.c_code = self.is_udfexpr or type(parent) is projection
|
||||
if self.is_udfexpr:
|
||||
self.udf : udf = parent
|
||||
self.builtin_vars = self.udf.builtin.keys()
|
||||
else:
|
||||
self.builtin_vars = []
|
||||
if type(c_code) is bool:
|
||||
self.c_code = c_code
|
||||
|
||||
self.udf_called = None
|
||||
self.cols_mentioned : Optional[set[ColRef]] = None
|
||||
ast_node.__init__(self, parent, node, None)
|
||||
|
||||
def init(self, _):
|
||||
from reconstruct.ast import projection
|
||||
parent = self.parent
|
||||
self.isvector = parent.isvector if type(parent) is expr else False
|
||||
self.is_compound = parent.is_compound if type(parent) is expr else False
|
||||
if type(parent) in [projection, expr]:
|
||||
self.datasource = parent.datasource
|
||||
else:
|
||||
self.datasource = self.context.datasource
|
||||
self.udf_map = parent.context.udf_map
|
||||
self.func_maps = {**builtin_func, **self.udf_map, **user_module_func}
|
||||
self.operators = {**builtin_operators, **self.udf_map, **user_module_func}
|
||||
|
||||
def produce(self, node):
|
||||
from engine.utils import enlist
|
||||
from reconstruct.ast import udf
|
||||
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.operators:
|
||||
if key in builtin_func:
|
||||
if self.is_agg_func:
|
||||
self.root.is_special = True # Nested Aggregation
|
||||
else:
|
||||
self.is_agg_func = True
|
||||
|
||||
op = self.operators[key]
|
||||
|
||||
val = enlist(val)
|
||||
exp_vals = [expr(self, v, c_code = self.c_code) for v in val]
|
||||
str_vals = [e.sql for e in exp_vals]
|
||||
type_vals = [e.type for e in exp_vals]
|
||||
try:
|
||||
self.type = op.return_type(*type_vals)
|
||||
except AttributeError as e:
|
||||
if type(self.root) is not udf:
|
||||
# TODO: do something when this is not an error
|
||||
# print(f'alert: {e}')
|
||||
pass
|
||||
self.type = AnyT
|
||||
|
||||
self.sql = op(self.c_code, *str_vals)
|
||||
special_func = [*self.context.udf_map.keys(), *self.context.module_map.keys(), "maxs", "mins", "avgs", "sums"]
|
||||
if key in special_func and not self.is_special:
|
||||
self.is_special = True
|
||||
if key in self.context.udf_map:
|
||||
self.root.udf_called = self.context.udf_map[key]
|
||||
if self.is_udfexpr and key == self.root.udf.name:
|
||||
self.root.is_recursive_call_inudf = True
|
||||
elif key in user_module_func.keys():
|
||||
udf.try_init_udf(self.context)
|
||||
# TODO: make udf_called a set!
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.udf_called:
|
||||
p.udf_called = self.udf_called
|
||||
p = p.parent
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.is_special:
|
||||
p.is_special = True
|
||||
p = p.parent
|
||||
|
||||
need_decltypestr = any([e.need_decltypestr for e in exp_vals])
|
||||
if need_decltypestr or (self.udf_called and type(op) is udf):
|
||||
decltypestr_vals = [e.udf_decltypecall for e in exp_vals]
|
||||
self.udf_decltypecall = op(self.c_code, *decltypestr_vals)
|
||||
|
||||
if self.udf_called and type(op) is udf:
|
||||
self.udf_decltypecall = op.decltypecall(self.c_code, *decltypestr_vals)
|
||||
|
||||
elif self.is_udfexpr:
|
||||
var_table = self.root.udf.var_table
|
||||
vec = key.split('.')
|
||||
_vars = [*var_table, *self.builtin_vars]
|
||||
def get_vname (node):
|
||||
if node in self.builtin_vars:
|
||||
self.root.udf.builtin[node].enabled = True
|
||||
self.builtin_var = node
|
||||
return node
|
||||
else:
|
||||
return var_table[node]
|
||||
if vec[0] not in _vars:
|
||||
# print(f'Use of undefined variable {vec[0]}')
|
||||
# TODO: do something when this is not an error
|
||||
pass
|
||||
else:
|
||||
vname = get_vname(vec[0])
|
||||
val = enlist(val)
|
||||
if(len(val) > 2):
|
||||
print('Warning: more than 2 indexes found for subvec operator.')
|
||||
ex = [expr(self, v, c_code = self.c_code) for v in val]
|
||||
idxs = ', '.join([e.sql for e in ex])
|
||||
self.sql = f'{vname}.subvec({idxs})'
|
||||
if any([e.need_decltypestr for e in ex]):
|
||||
self.udf_decltypecall = f'{vname}.subvec({[", ".join([e.udf_decltypecall for e in ex])]})'
|
||||
if key == 'get' and len(val) > 1:
|
||||
ex_vname = expr(self, val[0], c_code=self.c_code)
|
||||
self.sql = f'{ex_vname.sql}[{expr(self, val[1], c_code=self.c_code).sql}]'
|
||||
if hasattr(ex_vname, 'builtin_var'):
|
||||
if not hasattr(self, 'builtin_var'):
|
||||
self.builtin_var = []
|
||||
self.builtin_var = [*self.builtin_var, *ex_vname.builtin_var]
|
||||
self.udf_decltypecall = ex_vname.sql
|
||||
else:
|
||||
print(f'Undefined expr: {key}{val}')
|
||||
|
||||
elif type(node) is str:
|
||||
if self.is_udfexpr:
|
||||
curr_udf : udf = self.root.udf
|
||||
var_table = curr_udf.var_table
|
||||
split = node.split('.')
|
||||
if split[0] in var_table:
|
||||
varname = var_table[split[0]]
|
||||
if curr_udf.agg and varname in curr_udf.vecs:
|
||||
if len(split) > 1:
|
||||
if split[1] == 'vec':
|
||||
self.sql += varname
|
||||
elif split[1] == 'len':
|
||||
self.sql += f'{varname}.size'
|
||||
else:
|
||||
print(f'no member {split[1]} in object {varname}')
|
||||
else:
|
||||
self.sql += f'{varname}[{curr_udf.idx_var}]'
|
||||
else:
|
||||
self.sql += varname
|
||||
elif self.supress_undefined or split[0] in self.builtin_vars:
|
||||
self.sql += node
|
||||
if split[0] in self.builtin_vars:
|
||||
curr_udf.builtin[split[0]].enabled = True
|
||||
self.builtin_var = split[0]
|
||||
else:
|
||||
print(f'Undefined varname: {split[0]}')
|
||||
|
||||
|
||||
# get the column from the datasource in SQL context
|
||||
else:
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.isvector:
|
||||
p.isvector = True
|
||||
p = p.parent
|
||||
if self.datasource is not None:
|
||||
self.raw_col = self.datasource.parse_col_names(node)
|
||||
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
||||
if self.raw_col is not None:
|
||||
self.is_ColExpr = True
|
||||
self.sql = self.raw_col.name
|
||||
self.type = self.raw_col.type
|
||||
else:
|
||||
self.sql = node
|
||||
self.type = StrT
|
||||
if self.c_code and self.datasource is not None:
|
||||
self.sql = f'{{y(\"{self.sql}\")}}'
|
||||
elif type(node) is bool:
|
||||
self.type = BoolT
|
||||
if self.c_code:
|
||||
self.sql = '1' if node else '0'
|
||||
else:
|
||||
self.sql = 'TRUE' if node else 'FALSE'
|
||||
else:
|
||||
self.sql = f'{node}'
|
||||
if type(node) is int:
|
||||
if (node >= 2**63 - 1 or node <= -2**63):
|
||||
self.type = LongT
|
||||
else:
|
||||
self.type = IntT
|
||||
elif type(node) is float:
|
||||
self.type = DoubleT
|
||||
|
||||
def finalize(self, override = False):
|
||||
from reconstruct.ast import udf
|
||||
if self.codebuf is None or override:
|
||||
self.codebuf = ''
|
||||
for c in self.codlets:
|
||||
if type(c) is str:
|
||||
self.codebuf += c
|
||||
elif type(c) is udf:
|
||||
self.codebuf += c()
|
||||
elif type(c) is expr:
|
||||
self.codebuf += c.finalize(override=override)
|
||||
return self.codebuf
|
||||
|
||||
def __str__(self):
|
||||
return self.sql
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
# builtins is readonly, so it's okay to set default value as an object
|
||||
# eval is only called at root expr.
|
||||
def eval(self, c_code = None, y = lambda t: t, materialize_builtin = False, _decltypestr = False, *, gettype = False):
|
||||
assert(self.is_root)
|
||||
def call(decltypestr = False) -> str:
|
||||
nonlocal c_code, y, materialize_builtin
|
||||
if self.udf_called is not None:
|
||||
loc = locals()
|
||||
builtin_vars = self.udf_called.builtin_used
|
||||
for b in self.udf_called.builtin_var.all:
|
||||
exec(f'loc["{b}"] = lambda: "{{{b}()}}"')
|
||||
if builtin_vars:
|
||||
if type(materialize_builtin) is dict:
|
||||
for b in builtin_vars:
|
||||
exec(f'loc["{b}"] = lambda: "{materialize_builtin[b]}"')
|
||||
elif self.is_recursive_call_inudf:
|
||||
for b in builtin_vars:
|
||||
exec(f'loc["{b}"] = lambda : "{b}"')
|
||||
|
||||
x = self.c_code if c_code is None else c_code
|
||||
if decltypestr:
|
||||
return eval('f\'' + self.udf_decltypecall + '\'')
|
||||
return eval('f\'' + self.sql + '\'')
|
||||
if self.is_recursive_call_inudf or (self.need_decltypestr and self.is_udfexpr) or gettype:
|
||||
return call
|
||||
else:
|
||||
return call(_decltypestr)
|
||||
|
||||
@property
|
||||
def is_root(self):
|
||||
return self.root == self
|
||||
|
||||
|
||||
# For UDFs: first check if agg variable is used as vector
|
||||
# if not, then check if its length is used
|
||||
class fastscan(expr):
|
||||
name = 'fastscan'
|
||||
|
||||
def init(self, _):
|
||||
self.vec_vars = set()
|
||||
self.requested_lens = set()
|
||||
super().init(self, _)
|
||||
|
||||
def process(self, key : str):
|
||||
segs = key.split('.')
|
||||
var_table = self.root.udf.var_table
|
||||
if segs[0] in var_table and len(segs) > 1:
|
||||
if segs[1] == 'vec':
|
||||
self.vec_vars.add(segs[0])
|
||||
elif segs[1] == 'len':
|
||||
self.requested_lens.add(segs[0])
|
||||
|
||||
def produce(self, node):
|
||||
from engine.utils import enlist
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.operators:
|
||||
val = enlist(val)
|
||||
elif self.is_udfexpr:
|
||||
self.process(key)
|
||||
[fastscan(self, v, c_code = self.c_code) for v in val]
|
||||
|
||||
elif type(node) is str:
|
||||
self.process(node)
|
||||
|
||||
|
||||
class getrefs(expr):
|
||||
name = 'getrefs'
|
||||
|
||||
def init(self, _):
|
||||
self.datasource.rec = set()
|
||||
self.rec = None
|
||||
|
||||
def produce(self, node):
|
||||
from engine.utils import enlist
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.operators:
|
||||
val = enlist(val)
|
||||
[getrefs(self, v, c_code = self.c_code) for v in val]
|
||||
|
||||
elif type(node) is str:
|
||||
self.datasource.parse_col_names(node)
|
||||
|
||||
def consume(self, _):
|
||||
if self.root == self:
|
||||
self.rec = self.datasource.rec
|
||||
from typing import Optional
|
||||
from reconstruct.ast import ast_node
|
||||
from reconstruct.storage import ColRef, Context
|
||||
from engine.types import *
|
||||
|
||||
# TODO: Decouple expr and upgrade architecture
|
||||
# C_CODE : get ccode/sql code?
|
||||
# projections : C/SQL/decltype string
|
||||
# orderby/joins/where : SQL only
|
||||
# assumption/groupby : C/sql
|
||||
# is_udfexpr: C only
|
||||
|
||||
class expr(ast_node):
|
||||
name='expr'
|
||||
@property
|
||||
def udf_decltypecall(self):
|
||||
return self._udf_decltypecall if self._udf_decltypecall else self.sql
|
||||
|
||||
@udf_decltypecall.setter
|
||||
def udf_decltypecall(self, val):
|
||||
self._udf_decltypecall = val
|
||||
|
||||
@property
|
||||
def need_decltypestr(self):
|
||||
return self._udf_decltypecall is not None
|
||||
|
||||
def __init__(self, parent, node, *, c_code = None, supress_undefined = False):
|
||||
from reconstruct.ast import projection, udf
|
||||
|
||||
self.type = None
|
||||
self.raw_col = None
|
||||
self.udf : Optional[udf] = None
|
||||
self.inside_agg = False
|
||||
self.is_special = False
|
||||
self.is_ColExpr = False
|
||||
self.is_recursive_call_inudf = False
|
||||
self.codlets : list = []
|
||||
self.codebuf : Optional[str] = None
|
||||
self._udf_decltypecall = None
|
||||
self.node = node
|
||||
self.supress_undefined = supress_undefined
|
||||
if(type(parent) is expr):
|
||||
self.inside_agg = parent.inside_agg
|
||||
self.is_udfexpr = parent.is_udfexpr
|
||||
self.is_agg_func = parent.is_agg_func
|
||||
self.root : expr = parent.root
|
||||
self.c_code = parent.c_code
|
||||
self.builtin_vars = parent.builtin_vars
|
||||
else:
|
||||
self.is_agg_func = False
|
||||
self.is_udfexpr = type(parent) is udf
|
||||
self.root : expr = self
|
||||
self.c_code = self.is_udfexpr or type(parent) is projection
|
||||
if self.is_udfexpr:
|
||||
self.udf : udf = parent
|
||||
self.builtin_vars = self.udf.builtin.keys()
|
||||
else:
|
||||
self.builtin_vars = []
|
||||
if type(c_code) is bool:
|
||||
self.c_code = c_code
|
||||
|
||||
self.udf_called = None
|
||||
self.cols_mentioned : Optional[set[ColRef]] = None
|
||||
ast_node.__init__(self, parent, node, None)
|
||||
|
||||
def init(self, _):
|
||||
from reconstruct.ast import projection
|
||||
parent = self.parent
|
||||
self.isvector = parent.isvector if type(parent) is expr else False
|
||||
self.is_compound = parent.is_compound if type(parent) is expr else False
|
||||
if type(parent) in [projection, expr]:
|
||||
self.datasource = parent.datasource
|
||||
else:
|
||||
self.datasource = self.context.datasource
|
||||
self.udf_map = parent.context.udf_map
|
||||
self.func_maps = {**builtin_func, **self.udf_map, **user_module_func}
|
||||
self.operators = {**builtin_operators, **self.udf_map, **user_module_func}
|
||||
|
||||
def produce(self, node):
|
||||
from engine.utils import enlist
|
||||
from reconstruct.ast import udf
|
||||
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.operators:
|
||||
if key in builtin_func:
|
||||
if self.is_agg_func:
|
||||
self.root.is_special = True # Nested Aggregation
|
||||
else:
|
||||
self.is_agg_func = True
|
||||
|
||||
op = self.operators[key]
|
||||
|
||||
val = enlist(val)
|
||||
exp_vals = [expr(self, v, c_code = self.c_code) for v in val]
|
||||
str_vals = [e.sql for e in exp_vals]
|
||||
type_vals = [e.type for e in exp_vals]
|
||||
try:
|
||||
self.type = op.return_type(*type_vals)
|
||||
except AttributeError as e:
|
||||
if type(self.root) is not udf:
|
||||
# TODO: do something when this is not an error
|
||||
# print(f'alert: {e}')
|
||||
pass
|
||||
self.type = AnyT
|
||||
|
||||
self.sql = op(self.c_code, *str_vals)
|
||||
special_func = [*self.context.udf_map.keys(), *self.context.module_map.keys(), "maxs", "mins", "avgs", "sums"]
|
||||
if key in special_func and not self.is_special:
|
||||
self.is_special = True
|
||||
if key in self.context.udf_map:
|
||||
self.root.udf_called = self.context.udf_map[key]
|
||||
if self.is_udfexpr and key == self.root.udf.name:
|
||||
self.root.is_recursive_call_inudf = True
|
||||
elif key in user_module_func.keys():
|
||||
udf.try_init_udf(self.context)
|
||||
# TODO: make udf_called a set!
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.udf_called:
|
||||
p.udf_called = self.udf_called
|
||||
p = p.parent
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.is_special:
|
||||
p.is_special = True
|
||||
p = p.parent
|
||||
|
||||
need_decltypestr = any([e.need_decltypestr for e in exp_vals])
|
||||
if need_decltypestr or (self.udf_called and type(op) is udf):
|
||||
decltypestr_vals = [e.udf_decltypecall for e in exp_vals]
|
||||
self.udf_decltypecall = op(self.c_code, *decltypestr_vals)
|
||||
|
||||
if self.udf_called and type(op) is udf:
|
||||
self.udf_decltypecall = op.decltypecall(self.c_code, *decltypestr_vals)
|
||||
|
||||
elif self.is_udfexpr:
|
||||
var_table = self.root.udf.var_table
|
||||
vec = key.split('.')
|
||||
_vars = [*var_table, *self.builtin_vars]
|
||||
def get_vname (node):
|
||||
if node in self.builtin_vars:
|
||||
self.root.udf.builtin[node].enabled = True
|
||||
self.builtin_var = node
|
||||
return node
|
||||
else:
|
||||
return var_table[node]
|
||||
if vec[0] not in _vars:
|
||||
# print(f'Use of undefined variable {vec[0]}')
|
||||
# TODO: do something when this is not an error
|
||||
pass
|
||||
else:
|
||||
vname = get_vname(vec[0])
|
||||
val = enlist(val)
|
||||
if(len(val) > 2):
|
||||
print('Warning: more than 2 indexes found for subvec operator.')
|
||||
ex = [expr(self, v, c_code = self.c_code) for v in val]
|
||||
idxs = ', '.join([e.sql for e in ex])
|
||||
self.sql = f'{vname}.subvec({idxs})'
|
||||
if any([e.need_decltypestr for e in ex]):
|
||||
self.udf_decltypecall = f'{vname}.subvec({[", ".join([e.udf_decltypecall for e in ex])]})'
|
||||
if key == 'get' and len(val) > 1:
|
||||
ex_vname = expr(self, val[0], c_code=self.c_code)
|
||||
self.sql = f'{ex_vname.sql}[{expr(self, val[1], c_code=self.c_code).sql}]'
|
||||
if hasattr(ex_vname, 'builtin_var'):
|
||||
if not hasattr(self, 'builtin_var'):
|
||||
self.builtin_var = []
|
||||
self.builtin_var = [*self.builtin_var, *ex_vname.builtin_var]
|
||||
self.udf_decltypecall = ex_vname.sql
|
||||
else:
|
||||
print(f'Undefined expr: {key}{val}')
|
||||
|
||||
elif type(node) is str:
|
||||
if self.is_udfexpr:
|
||||
curr_udf : udf = self.root.udf
|
||||
var_table = curr_udf.var_table
|
||||
split = node.split('.')
|
||||
if split[0] in var_table:
|
||||
varname = var_table[split[0]]
|
||||
if curr_udf.agg and varname in curr_udf.vecs:
|
||||
if len(split) > 1:
|
||||
if split[1] == 'vec':
|
||||
self.sql += varname
|
||||
elif split[1] == 'len':
|
||||
self.sql += f'{varname}.size'
|
||||
else:
|
||||
print(f'no member {split[1]} in object {varname}')
|
||||
else:
|
||||
self.sql += f'{varname}[{curr_udf.idx_var}]'
|
||||
else:
|
||||
self.sql += varname
|
||||
elif self.supress_undefined or split[0] in self.builtin_vars:
|
||||
self.sql += node
|
||||
if split[0] in self.builtin_vars:
|
||||
curr_udf.builtin[split[0]].enabled = True
|
||||
self.builtin_var = split[0]
|
||||
else:
|
||||
print(f'Undefined varname: {split[0]}')
|
||||
|
||||
|
||||
# get the column from the datasource in SQL context
|
||||
else:
|
||||
p = self.parent
|
||||
while type(p) is expr and not p.isvector:
|
||||
p.isvector = True
|
||||
p = p.parent
|
||||
if self.datasource is not None:
|
||||
self.raw_col = self.datasource.parse_col_names(node)
|
||||
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
||||
if self.raw_col is not None:
|
||||
self.is_ColExpr = True
|
||||
self.sql = self.raw_col.name
|
||||
self.type = self.raw_col.type
|
||||
else:
|
||||
self.sql = node
|
||||
self.type = StrT
|
||||
if self.c_code and self.datasource is not None:
|
||||
self.sql = f'{{y(\"{self.sql}\")}}'
|
||||
elif type(node) is bool:
|
||||
self.type = BoolT
|
||||
if self.c_code:
|
||||
self.sql = '1' if node else '0'
|
||||
else:
|
||||
self.sql = 'TRUE' if node else 'FALSE'
|
||||
else:
|
||||
self.sql = f'{node}'
|
||||
if type(node) is int:
|
||||
if (node >= 2**63 - 1 or node <= -2**63):
|
||||
self.type = LongT
|
||||
else:
|
||||
self.type = IntT
|
||||
elif type(node) is float:
|
||||
self.type = DoubleT
|
||||
|
||||
def finalize(self, override = False):
|
||||
from reconstruct.ast import udf
|
||||
if self.codebuf is None or override:
|
||||
self.codebuf = ''
|
||||
for c in self.codlets:
|
||||
if type(c) is str:
|
||||
self.codebuf += c
|
||||
elif type(c) is udf:
|
||||
self.codebuf += c()
|
||||
elif type(c) is expr:
|
||||
self.codebuf += c.finalize(override=override)
|
||||
return self.codebuf
|
||||
|
||||
def __str__(self):
|
||||
return self.sql
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
# builtins is readonly, so it's okay to set default value as an object
|
||||
# eval is only called at root expr.
|
||||
def eval(self, c_code = None, y = lambda t: t, materialize_builtin = False, _decltypestr = False, *, gettype = False):
|
||||
assert(self.is_root)
|
||||
def call(decltypestr = False) -> str:
|
||||
nonlocal c_code, y, materialize_builtin
|
||||
if self.udf_called is not None:
|
||||
loc = locals()
|
||||
builtin_vars = self.udf_called.builtin_used
|
||||
for b in self.udf_called.builtin_var.all:
|
||||
exec(f'loc["{b}"] = lambda: "{{{b}()}}"')
|
||||
if builtin_vars:
|
||||
if type(materialize_builtin) is dict:
|
||||
for b in builtin_vars:
|
||||
exec(f'loc["{b}"] = lambda: "{materialize_builtin[b]}"')
|
||||
elif self.is_recursive_call_inudf:
|
||||
for b in builtin_vars:
|
||||
exec(f'loc["{b}"] = lambda : "{b}"')
|
||||
|
||||
x = self.c_code if c_code is None else c_code
|
||||
if decltypestr:
|
||||
return eval('f\'' + self.udf_decltypecall + '\'')
|
||||
return eval('f\'' + self.sql + '\'')
|
||||
if self.is_recursive_call_inudf or (self.need_decltypestr and self.is_udfexpr) or gettype:
|
||||
return call
|
||||
else:
|
||||
return call(_decltypestr)
|
||||
|
||||
@property
|
||||
def is_root(self):
|
||||
return self.root == self
|
||||
|
||||
|
||||
# For UDFs: first check if agg variable is used as vector
|
||||
# if not, then check if its length is used
|
||||
class fastscan(expr):
|
||||
name = 'fastscan'
|
||||
|
||||
def init(self, _):
|
||||
self.vec_vars = set()
|
||||
self.requested_lens = set()
|
||||
super().init(self, _)
|
||||
|
||||
def process(self, key : str):
|
||||
segs = key.split('.')
|
||||
var_table = self.root.udf.var_table
|
||||
if segs[0] in var_table and len(segs) > 1:
|
||||
if segs[1] == 'vec':
|
||||
self.vec_vars.add(segs[0])
|
||||
elif segs[1] == 'len':
|
||||
self.requested_lens.add(segs[0])
|
||||
|
||||
def produce(self, node):
|
||||
from engine.utils import enlist
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.operators:
|
||||
val = enlist(val)
|
||||
elif self.is_udfexpr:
|
||||
self.process(key)
|
||||
[fastscan(self, v, c_code = self.c_code) for v in val]
|
||||
|
||||
elif type(node) is str:
|
||||
self.process(node)
|
||||
|
||||
|
||||
class getrefs(expr):
|
||||
name = 'getrefs'
|
||||
|
||||
def init(self, _):
|
||||
self.datasource.rec = set()
|
||||
self.rec = None
|
||||
|
||||
def produce(self, node):
|
||||
from engine.utils import enlist
|
||||
if type(node) is dict:
|
||||
for key, val in node.items():
|
||||
if key in self.operators:
|
||||
val = enlist(val)
|
||||
[getrefs(self, v, c_code = self.c_code) for v in val]
|
||||
|
||||
elif type(node) is str:
|
||||
self.datasource.parse_col_names(node)
|
||||
|
||||
def consume(self, _):
|
||||
if self.root == self:
|
||||
self.rec = self.datasource.rec
|
||||
self.datasource.rec = None
|
@ -1,203 +1,203 @@
|
||||
from engine.types import *
|
||||
from engine.utils import enlist
|
||||
from typing import List, Dict, Set
|
||||
|
||||
class ColRef:
|
||||
def __init__(self, _ty, cobj, table:'TableInfo', name, id, compound = False, _ty_args = None):
|
||||
self.type : Types = AnyT
|
||||
if type(_ty) is str:
|
||||
self.type = builtin_types[_ty.lower()]
|
||||
if _ty_args:
|
||||
self.type = self.type(enlist(_ty_args))
|
||||
elif type(_ty) is Types:
|
||||
self.type = _ty
|
||||
self.cobj = cobj
|
||||
self.table = table
|
||||
self.name = name
|
||||
self.alias = set()
|
||||
self.id = id # position in table
|
||||
self.compound = compound # compound field (list as a field)
|
||||
# e.g. order by, group by, filter by expressions
|
||||
|
||||
self.__arr__ = (_ty, cobj, table, name, id)
|
||||
def __getitem__(self, key):
|
||||
if type(key) is str:
|
||||
return getattr(self, key)
|
||||
else:
|
||||
return self.__arr__[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.__arr__[key] = value
|
||||
|
||||
class TableInfo:
|
||||
def __init__(self, table_name, cols, cxt:'Context'):
|
||||
# statics
|
||||
self.table_name : str = table_name
|
||||
self.contextname_cpp : str = ''
|
||||
self.alias : Set[str] = set([table_name])
|
||||
self.columns_byname : Dict[str, ColRef] = dict() # column_name, type
|
||||
self.columns : List[ColRef] = []
|
||||
self.cxt = cxt
|
||||
# keep track of temp vars
|
||||
self.rec = None
|
||||
self.add_cols(cols)
|
||||
# runtime
|
||||
self.order = [] # assumptions
|
||||
|
||||
cxt.tables_byname[self.table_name] = self # construct reverse map
|
||||
|
||||
def add_cols(self, cols, new = True):
|
||||
for i, c in enumerate(cols):
|
||||
self.add_col(c, new, i)
|
||||
|
||||
def add_col(self, c, new = True, i = 0):
|
||||
_ty = c['type']
|
||||
_ty_args = None
|
||||
if type(_ty) is dict:
|
||||
_ty_val = list(_ty.keys())[0]
|
||||
_ty_args = _ty[_ty_val]
|
||||
_ty = _ty_val
|
||||
if new:
|
||||
col_object = ColRef(_ty, c, self, c['name'], len(self.columns), _ty_args = _ty_args)
|
||||
else:
|
||||
col_object = c
|
||||
c.table = self
|
||||
self.columns_byname[c['name']] = col_object
|
||||
self.columns.append(col_object)
|
||||
|
||||
def add_alias(self, alias):
|
||||
if alias in self.cxt.tables_byname.keys():
|
||||
print("Error: table alias already exists")
|
||||
return
|
||||
self.cxt.tables_byname[alias] = self
|
||||
self.alias.add(alias)
|
||||
|
||||
def parse_col_names(self, colExpr) -> ColRef:
|
||||
parsedColExpr = colExpr.split('.')
|
||||
if len(parsedColExpr) <= 1:
|
||||
col = self.columns_byname[colExpr]
|
||||
if type(self.rec) is set:
|
||||
self.rec.add(col)
|
||||
return col
|
||||
else:
|
||||
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
||||
if datasource is None:
|
||||
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
||||
else:
|
||||
return datasource.parse_col_names(parsedColExpr[1])
|
||||
|
||||
|
||||
class Context:
|
||||
def new(self):
|
||||
self.headers = set(['\"./server/libaquery.h\"',
|
||||
'\"./server/monetdb_conn.h\"'])
|
||||
|
||||
self.ccode = ''
|
||||
self.sql = ''
|
||||
self.finalized = False
|
||||
self.udf = None
|
||||
self.scans = []
|
||||
self.procs = []
|
||||
self.queries = []
|
||||
self.module_init_loc = 0
|
||||
|
||||
def __init__(self):
|
||||
self.tables_byname = dict()
|
||||
self.col_byname = dict()
|
||||
self.tables = []
|
||||
self.cols = []
|
||||
self.datasource = None
|
||||
self.module_stubs = ''
|
||||
self.module_map = {}
|
||||
self.udf_map = dict()
|
||||
self.udf_agg_map = dict()
|
||||
self.use_columnstore = False
|
||||
self.print = print
|
||||
self.has_dll = False
|
||||
self.dialect = 'MonetDB'
|
||||
self.is_msvc = False
|
||||
self.have_hge = False
|
||||
self.Error = lambda *args: print(*args)
|
||||
self.Info = lambda *_: None
|
||||
|
||||
def emit(self, sql:str):
|
||||
self.sql += sql + ' '
|
||||
def emitc(self, c:str):
|
||||
self.ccode += c + '\n'
|
||||
def add_table(self, table_name, cols):
|
||||
tbl = TableInfo(table_name, cols, self)
|
||||
self.tables.append(tbl)
|
||||
return tbl
|
||||
def remove_scan(self, scan, str_scan):
|
||||
self.emitc(str_scan)
|
||||
self.scans.remove(scan)
|
||||
|
||||
function_deco = '__AQEXPORT__(int) '
|
||||
function_head = ('(Context* cxt) {\n' +
|
||||
'\tusing namespace std;\n' +
|
||||
'\tusing namespace types;\n' +
|
||||
'\tauto server = static_cast<Server*>(cxt->alt_server);\n')
|
||||
|
||||
udf_head = ('#pragma once\n'
|
||||
'#include \"./server/libaquery.h\"\n'
|
||||
'#include \"./server/aggregations.h\"\n\n'
|
||||
)
|
||||
|
||||
def get_init_func(self):
|
||||
if not self.module_map:
|
||||
return ''
|
||||
ret = '__AQEXPORT__(void) __builtin_init_user_module(Context* cxt){\n'
|
||||
for fname in self.module_map.keys():
|
||||
ret += f'{fname} = (decltype({fname}))(cxt->get_module_function("{fname}"));\n'
|
||||
self.queries.insert(self.module_init_loc, 'P__builtin_init_user_module')
|
||||
return ret + '}\n'
|
||||
|
||||
def sql_begin(self):
|
||||
self.sql = ''
|
||||
|
||||
def sql_end(self):
|
||||
# eliminate empty queries
|
||||
s = self.sql.strip()
|
||||
while(s and s[-1] == ';'):
|
||||
s = s[:-1].strip()
|
||||
if s and s.lower() != 'select':
|
||||
self.queries.append('Q' + self.sql)
|
||||
self.sql = ''
|
||||
|
||||
def postproc_begin(self, proc_name: str):
|
||||
self.ccode = self.function_deco + proc_name + self.function_head
|
||||
|
||||
def postproc_end(self, proc_name: str):
|
||||
self.procs.append(self.ccode + 'return 0;\n}')
|
||||
self.ccode = ''
|
||||
self.queries.append('P' + proc_name)
|
||||
|
||||
def finalize_udf(self):
|
||||
if self.udf is not None:
|
||||
return (Context.udf_head
|
||||
+ self.module_stubs
|
||||
+ self.get_init_func()
|
||||
+ self.udf
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
def finalize(self):
|
||||
from aquery_config import build_driver, os_platform
|
||||
if not self.finalized:
|
||||
headers = ''
|
||||
if build_driver == 'MSBuild':
|
||||
headers ='#include \"./server/pch.hpp\"\n'
|
||||
|
||||
for h in self.headers:
|
||||
if h[0] != '"':
|
||||
headers += '#include <' + h + '>\n'
|
||||
else:
|
||||
headers += '#include ' + h + '\n'
|
||||
if os_platform == 'win':
|
||||
headers += '#undef max\n'
|
||||
headers += '#undef min\n'
|
||||
|
||||
self.ccode = headers + '\n'.join(self.procs)
|
||||
self.headers = set()
|
||||
return self.ccode
|
||||
from engine.types import *
|
||||
from engine.utils import enlist
|
||||
from typing import List, Dict, Set
|
||||
|
||||
class ColRef:
|
||||
def __init__(self, _ty, cobj, table:'TableInfo', name, id, compound = False, _ty_args = None):
|
||||
self.type : Types = AnyT
|
||||
if type(_ty) is str:
|
||||
self.type = builtin_types[_ty.lower()]
|
||||
if _ty_args:
|
||||
self.type = self.type(enlist(_ty_args))
|
||||
elif type(_ty) is Types:
|
||||
self.type = _ty
|
||||
self.cobj = cobj
|
||||
self.table = table
|
||||
self.name = name
|
||||
self.alias = set()
|
||||
self.id = id # position in table
|
||||
self.compound = compound # compound field (list as a field)
|
||||
# e.g. order by, group by, filter by expressions
|
||||
|
||||
self.__arr__ = (_ty, cobj, table, name, id)
|
||||
def __getitem__(self, key):
|
||||
if type(key) is str:
|
||||
return getattr(self, key)
|
||||
else:
|
||||
return self.__arr__[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.__arr__[key] = value
|
||||
|
||||
class TableInfo:
|
||||
def __init__(self, table_name, cols, cxt:'Context'):
|
||||
# statics
|
||||
self.table_name : str = table_name
|
||||
self.contextname_cpp : str = ''
|
||||
self.alias : Set[str] = set([table_name])
|
||||
self.columns_byname : Dict[str, ColRef] = dict() # column_name, type
|
||||
self.columns : List[ColRef] = []
|
||||
self.cxt = cxt
|
||||
# keep track of temp vars
|
||||
self.rec = None
|
||||
self.add_cols(cols)
|
||||
# runtime
|
||||
self.order = [] # assumptions
|
||||
|
||||
cxt.tables_byname[self.table_name] = self # construct reverse map
|
||||
|
||||
def add_cols(self, cols, new = True):
|
||||
for i, c in enumerate(cols):
|
||||
self.add_col(c, new, i)
|
||||
|
||||
def add_col(self, c, new = True, i = 0):
|
||||
_ty = c['type']
|
||||
_ty_args = None
|
||||
if type(_ty) is dict:
|
||||
_ty_val = list(_ty.keys())[0]
|
||||
_ty_args = _ty[_ty_val]
|
||||
_ty = _ty_val
|
||||
if new:
|
||||
col_object = ColRef(_ty, c, self, c['name'], len(self.columns), _ty_args = _ty_args)
|
||||
else:
|
||||
col_object = c
|
||||
c.table = self
|
||||
self.columns_byname[c['name']] = col_object
|
||||
self.columns.append(col_object)
|
||||
|
||||
def add_alias(self, alias):
|
||||
if alias in self.cxt.tables_byname.keys():
|
||||
print("Error: table alias already exists")
|
||||
return
|
||||
self.cxt.tables_byname[alias] = self
|
||||
self.alias.add(alias)
|
||||
|
||||
def parse_col_names(self, colExpr) -> ColRef:
|
||||
parsedColExpr = colExpr.split('.')
|
||||
if len(parsedColExpr) <= 1:
|
||||
col = self.columns_byname[colExpr]
|
||||
if type(self.rec) is set:
|
||||
self.rec.add(col)
|
||||
return col
|
||||
else:
|
||||
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
||||
if datasource is None:
|
||||
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
||||
else:
|
||||
return datasource.parse_col_names(parsedColExpr[1])
|
||||
|
||||
|
||||
class Context:
|
||||
def new(self):
|
||||
self.headers = set(['\"./server/libaquery.h\"',
|
||||
'\"./server/monetdb_conn.h\"'])
|
||||
|
||||
self.ccode = ''
|
||||
self.sql = ''
|
||||
self.finalized = False
|
||||
self.udf = None
|
||||
self.scans = []
|
||||
self.procs = []
|
||||
self.queries = []
|
||||
self.module_init_loc = 0
|
||||
|
||||
def __init__(self):
|
||||
self.tables_byname = dict()
|
||||
self.col_byname = dict()
|
||||
self.tables = []
|
||||
self.cols = []
|
||||
self.datasource = None
|
||||
self.module_stubs = ''
|
||||
self.module_map = {}
|
||||
self.udf_map = dict()
|
||||
self.udf_agg_map = dict()
|
||||
self.use_columnstore = False
|
||||
self.print = print
|
||||
self.has_dll = False
|
||||
self.dialect = 'MonetDB'
|
||||
self.is_msvc = False
|
||||
self.have_hge = False
|
||||
self.Error = lambda *args: print(*args)
|
||||
self.Info = lambda *_: None
|
||||
|
||||
def emit(self, sql:str):
|
||||
self.sql += sql + ' '
|
||||
def emitc(self, c:str):
|
||||
self.ccode += c + '\n'
|
||||
def add_table(self, table_name, cols):
|
||||
tbl = TableInfo(table_name, cols, self)
|
||||
self.tables.append(tbl)
|
||||
return tbl
|
||||
def remove_scan(self, scan, str_scan):
|
||||
self.emitc(str_scan)
|
||||
self.scans.remove(scan)
|
||||
|
||||
function_deco = '__AQEXPORT__(int) '
|
||||
function_head = ('(Context* cxt) {\n' +
|
||||
'\tusing namespace std;\n' +
|
||||
'\tusing namespace types;\n' +
|
||||
'\tauto server = static_cast<Server*>(cxt->alt_server);\n')
|
||||
|
||||
udf_head = ('#pragma once\n'
|
||||
'#include \"./server/libaquery.h\"\n'
|
||||
'#include \"./server/aggregations.h\"\n\n'
|
||||
)
|
||||
|
||||
def get_init_func(self):
|
||||
if not self.module_map:
|
||||
return ''
|
||||
ret = '__AQEXPORT__(void) __builtin_init_user_module(Context* cxt){\n'
|
||||
for fname in self.module_map.keys():
|
||||
ret += f'{fname} = (decltype({fname}))(cxt->get_module_function("{fname}"));\n'
|
||||
self.queries.insert(self.module_init_loc, 'P__builtin_init_user_module')
|
||||
return ret + '}\n'
|
||||
|
||||
def sql_begin(self):
|
||||
self.sql = ''
|
||||
|
||||
def sql_end(self):
|
||||
# eliminate empty queries
|
||||
s = self.sql.strip()
|
||||
while(s and s[-1] == ';'):
|
||||
s = s[:-1].strip()
|
||||
if s and s.lower() != 'select':
|
||||
self.queries.append('Q' + self.sql)
|
||||
self.sql = ''
|
||||
|
||||
def postproc_begin(self, proc_name: str):
|
||||
self.ccode = self.function_deco + proc_name + self.function_head
|
||||
|
||||
def postproc_end(self, proc_name: str):
|
||||
self.procs.append(self.ccode + 'return 0;\n}')
|
||||
self.ccode = ''
|
||||
self.queries.append('P' + proc_name)
|
||||
|
||||
def finalize_udf(self):
|
||||
if self.udf is not None:
|
||||
return (Context.udf_head
|
||||
+ self.module_stubs
|
||||
+ self.get_init_func()
|
||||
+ self.udf
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
def finalize(self):
|
||||
from aquery_config import build_driver, os_platform
|
||||
if not self.finalized:
|
||||
headers = ''
|
||||
if build_driver == 'MSBuild':
|
||||
headers ='#include \"./server/pch.hpp\"\n'
|
||||
|
||||
for h in self.headers:
|
||||
if h[0] != '"':
|
||||
headers += '#include <' + h + '>\n'
|
||||
else:
|
||||
headers += '#include ' + h + '\n'
|
||||
if os_platform == 'win':
|
||||
headers += '#undef max\n'
|
||||
headers += '#undef min\n'
|
||||
|
||||
self.ccode = headers + '\n'.join(self.procs)
|
||||
self.headers = set()
|
||||
return self.ccode
|
||||
|
@ -1,9 +1,9 @@
|
||||
mo-future==6.2.21303
|
||||
mo-dots==9.173.22126
|
||||
mo-parsing==8.183.22158
|
||||
mo-imports==7.169.22121
|
||||
dataclasses; python_version < '3.7'
|
||||
readline; sys_platform == 'linux'
|
||||
vswhere; sys_platform == 'win32'
|
||||
numpy
|
||||
|
||||
mo-future==6.2.21303
|
||||
mo-dots==9.173.22126
|
||||
mo-parsing==8.183.22158
|
||||
mo-imports==7.169.22121
|
||||
dataclasses; python_version < '3.7'
|
||||
readline; sys_platform == 'linux'
|
||||
vswhere; sys_platform == 'win32'
|
||||
numpy
|
||||
|
||||
|
@ -1,222 +1,222 @@
|
||||
{
|
||||
"stmts": {
|
||||
"udf": {
|
||||
"fname": "covariances2",
|
||||
"params": ["x", "y", "w"],
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "xmeans",
|
||||
"op": ":=",
|
||||
"expr": 0.0
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "ymeans",
|
||||
"op": ":=",
|
||||
"expr": 0.0
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": "_builtin_len"
|
||||
}
|
||||
}, {
|
||||
"if": {
|
||||
"cond": {
|
||||
"gt": ["w", "l"]
|
||||
},
|
||||
"assignment": {
|
||||
"var": "w",
|
||||
"op": ":=",
|
||||
"expr": "l"
|
||||
},
|
||||
"elif": [{
|
||||
"cond": {
|
||||
"gt": ["w", {
|
||||
"add": ["l", 2]
|
||||
}]
|
||||
},
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": 3
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "w",
|
||||
"op": ":=",
|
||||
"expr": 4
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
"cond": {
|
||||
"lt": ["w", 99]
|
||||
},
|
||||
"stmt": {
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": 8
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"cond": {
|
||||
"lt": ["w", 999]
|
||||
},
|
||||
"assignment": {
|
||||
"var": "w",
|
||||
"op": ":=",
|
||||
"expr": 6
|
||||
}
|
||||
}],
|
||||
"else": {
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"div": ["l", 2]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"for": {
|
||||
"defs": {
|
||||
"var": ["i", "j"],
|
||||
"op": [":=", ":="],
|
||||
"expr": [0, 0]
|
||||
},
|
||||
"cond": {
|
||||
"lt": ["i", "w"]
|
||||
},
|
||||
"tail": {
|
||||
"var": "i",
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"add": ["i", 1]
|
||||
}
|
||||
},
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "xmeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"get": ["x", "i"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "ymeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"get": ["y", "i"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": {
|
||||
"get": ["_builtin_ret", "i"]
|
||||
},
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"avg": {
|
||||
"mul": [{
|
||||
"sub": [{
|
||||
"x": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "xmeans"]
|
||||
}, {
|
||||
"sub": [{
|
||||
"y": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "ymeans"]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"for": {
|
||||
"defs": {
|
||||
"var": "i",
|
||||
"op": ":=",
|
||||
"expr": 0
|
||||
},
|
||||
"cond": {
|
||||
"lt": ["i", "l"]
|
||||
},
|
||||
"tail": {
|
||||
"var": "i",
|
||||
"op": "+=",
|
||||
"expr": 1
|
||||
},
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "xmeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"div": [{
|
||||
"sub": [{
|
||||
"get": ["x", "i"]
|
||||
}, {
|
||||
"get": ["x", {
|
||||
"sub": ["i", "w"]
|
||||
}]
|
||||
}]
|
||||
}, "w"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "ymeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"div": [{
|
||||
"sub": [{
|
||||
"get": ["y", "i"]
|
||||
}, {
|
||||
"get": ["y", {
|
||||
"sub": ["i", "w"]
|
||||
}]
|
||||
}]
|
||||
}, "w"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": {
|
||||
"get": ["_builtin_ret", "i"]
|
||||
},
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"avg": {
|
||||
"mul": [{
|
||||
"sub": [{
|
||||
"x": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "xmeans"]
|
||||
}, {
|
||||
"sub": [{
|
||||
"y": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "ymeans"]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"ret": {
|
||||
"null": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"stmts": {
|
||||
"udf": {
|
||||
"fname": "covariances2",
|
||||
"params": ["x", "y", "w"],
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "xmeans",
|
||||
"op": ":=",
|
||||
"expr": 0.0
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "ymeans",
|
||||
"op": ":=",
|
||||
"expr": 0.0
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": "_builtin_len"
|
||||
}
|
||||
}, {
|
||||
"if": {
|
||||
"cond": {
|
||||
"gt": ["w", "l"]
|
||||
},
|
||||
"assignment": {
|
||||
"var": "w",
|
||||
"op": ":=",
|
||||
"expr": "l"
|
||||
},
|
||||
"elif": [{
|
||||
"cond": {
|
||||
"gt": ["w", {
|
||||
"add": ["l", 2]
|
||||
}]
|
||||
},
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": 3
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "w",
|
||||
"op": ":=",
|
||||
"expr": 4
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
"cond": {
|
||||
"lt": ["w", 99]
|
||||
},
|
||||
"stmt": {
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": 8
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"cond": {
|
||||
"lt": ["w", 999]
|
||||
},
|
||||
"assignment": {
|
||||
"var": "w",
|
||||
"op": ":=",
|
||||
"expr": 6
|
||||
}
|
||||
}],
|
||||
"else": {
|
||||
"assignment": {
|
||||
"var": "l",
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"div": ["l", 2]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"for": {
|
||||
"defs": {
|
||||
"var": ["i", "j"],
|
||||
"op": [":=", ":="],
|
||||
"expr": [0, 0]
|
||||
},
|
||||
"cond": {
|
||||
"lt": ["i", "w"]
|
||||
},
|
||||
"tail": {
|
||||
"var": "i",
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"add": ["i", 1]
|
||||
}
|
||||
},
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "xmeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"get": ["x", "i"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "ymeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"get": ["y", "i"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": {
|
||||
"get": ["_builtin_ret", "i"]
|
||||
},
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"avg": {
|
||||
"mul": [{
|
||||
"sub": [{
|
||||
"x": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "xmeans"]
|
||||
}, {
|
||||
"sub": [{
|
||||
"y": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "ymeans"]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"for": {
|
||||
"defs": {
|
||||
"var": "i",
|
||||
"op": ":=",
|
||||
"expr": 0
|
||||
},
|
||||
"cond": {
|
||||
"lt": ["i", "l"]
|
||||
},
|
||||
"tail": {
|
||||
"var": "i",
|
||||
"op": "+=",
|
||||
"expr": 1
|
||||
},
|
||||
"stmt": [{
|
||||
"assignment": {
|
||||
"var": "xmeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"div": [{
|
||||
"sub": [{
|
||||
"get": ["x", "i"]
|
||||
}, {
|
||||
"get": ["x", {
|
||||
"sub": ["i", "w"]
|
||||
}]
|
||||
}]
|
||||
}, "w"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": "ymeans",
|
||||
"op": "+=",
|
||||
"expr": {
|
||||
"div": [{
|
||||
"sub": [{
|
||||
"get": ["y", "i"]
|
||||
}, {
|
||||
"get": ["y", {
|
||||
"sub": ["i", "w"]
|
||||
}]
|
||||
}]
|
||||
}, "w"]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"assignment": {
|
||||
"var": {
|
||||
"get": ["_builtin_ret", "i"]
|
||||
},
|
||||
"op": ":=",
|
||||
"expr": {
|
||||
"avg": {
|
||||
"mul": [{
|
||||
"sub": [{
|
||||
"x": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "xmeans"]
|
||||
}, {
|
||||
"sub": [{
|
||||
"y": [{
|
||||
"sub": ["l", "w"]
|
||||
}, "l"]
|
||||
}, "ymeans"]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"ret": {
|
||||
"null": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,89 +1,89 @@
|
||||
#ifndef _AQUERY_H
|
||||
#define _AQUERY_H
|
||||
|
||||
enum Log_level {
|
||||
LOG_INFO,
|
||||
LOG_ERROR,
|
||||
LOG_SILENT
|
||||
};
|
||||
|
||||
enum Backend_Type {
|
||||
BACKEND_AQuery,
|
||||
BACKEND_MonetDB,
|
||||
BACKEND_MariaDB
|
||||
};
|
||||
|
||||
struct Config{
|
||||
int running, new_query, server_mode,
|
||||
backend_type, has_dll, n_buffers;
|
||||
int buffer_sizes[];
|
||||
};
|
||||
|
||||
struct Session{
|
||||
struct Statistic{
|
||||
unsigned long long total_active;
|
||||
unsigned long long cnt_object;
|
||||
unsigned long long total_alloc;
|
||||
};
|
||||
void* memory_map;
|
||||
};
|
||||
|
||||
struct Context{
|
||||
typedef int (*printf_type) (const char *format, ...);
|
||||
void* module_function_maps = 0;
|
||||
Config* cfg;
|
||||
|
||||
int n_buffers, *sz_bufs;
|
||||
void **buffers;
|
||||
|
||||
void* alt_server;
|
||||
Log_level log_level = LOG_INFO;
|
||||
|
||||
Session current;
|
||||
|
||||
|
||||
template <class ...Types>
|
||||
void log(Types... args) {
|
||||
if (log_level == LOG_INFO)
|
||||
print(args...);
|
||||
}
|
||||
template <class ...Types>
|
||||
void err(Types... args) {
|
||||
if (log_level <= LOG_ERROR)
|
||||
print(args...);
|
||||
}
|
||||
void init_session();
|
||||
void end_session();
|
||||
void* get_module_function(const char*);
|
||||
char remainder[];
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define __DLLEXPORT__
|
||||
#endif
|
||||
|
||||
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
||||
|
||||
typedef void (*deallocator_t) (void*);
|
||||
|
||||
extern void* Aalloc(unsigned long long sz);
|
||||
extern void Afree(void * mem);
|
||||
extern void register_memory(void* ptr, deallocator_t deallocator);
|
||||
|
||||
__AQEXPORT__(void) init_session(Context* cxt);
|
||||
|
||||
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
|
||||
void* memcpy(void*, void*, unsigned long long);
|
||||
struct ColRef_storage {
|
||||
void* container;
|
||||
unsigned int capacity, size;
|
||||
const char* name;
|
||||
int ty; // what if enum is not int?
|
||||
template <class Ty, template <typename> class VT>
|
||||
ColRef_storage(const VT<Ty>& vt) {
|
||||
memcpy(this, &vt, sizeof(ColRef_storage));
|
||||
}
|
||||
};
|
||||
#ifndef _AQUERY_H
|
||||
#define _AQUERY_H
|
||||
|
||||
enum Log_level {
|
||||
LOG_INFO,
|
||||
LOG_ERROR,
|
||||
LOG_SILENT
|
||||
};
|
||||
|
||||
enum Backend_Type {
|
||||
BACKEND_AQuery,
|
||||
BACKEND_MonetDB,
|
||||
BACKEND_MariaDB
|
||||
};
|
||||
|
||||
struct Config{
|
||||
int running, new_query, server_mode,
|
||||
backend_type, has_dll, n_buffers;
|
||||
int buffer_sizes[];
|
||||
};
|
||||
|
||||
struct Session{
|
||||
struct Statistic{
|
||||
unsigned long long total_active;
|
||||
unsigned long long cnt_object;
|
||||
unsigned long long total_alloc;
|
||||
};
|
||||
void* memory_map;
|
||||
};
|
||||
|
||||
struct Context{
|
||||
typedef int (*printf_type) (const char *format, ...);
|
||||
void* module_function_maps = 0;
|
||||
Config* cfg;
|
||||
|
||||
int n_buffers, *sz_bufs;
|
||||
void **buffers;
|
||||
|
||||
void* alt_server;
|
||||
Log_level log_level = LOG_INFO;
|
||||
|
||||
Session current;
|
||||
|
||||
|
||||
template <class ...Types>
|
||||
void log(Types... args) {
|
||||
if (log_level == LOG_INFO)
|
||||
print(args...);
|
||||
}
|
||||
template <class ...Types>
|
||||
void err(Types... args) {
|
||||
if (log_level <= LOG_ERROR)
|
||||
print(args...);
|
||||
}
|
||||
void init_session();
|
||||
void end_session();
|
||||
void* get_module_function(const char*);
|
||||
char remainder[];
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define __DLLEXPORT__
|
||||
#endif
|
||||
|
||||
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
||||
|
||||
typedef void (*deallocator_t) (void*);
|
||||
|
||||
extern void* Aalloc(unsigned long long sz);
|
||||
extern void Afree(void * mem);
|
||||
extern void register_memory(void* ptr, deallocator_t deallocator);
|
||||
|
||||
__AQEXPORT__(void) init_session(Context* cxt);
|
||||
|
||||
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
|
||||
void* memcpy(void*, void*, unsigned long long);
|
||||
struct ColRef_storage {
|
||||
void* container;
|
||||
unsigned int capacity, size;
|
||||
const char* name;
|
||||
int ty; // what if enum is not int?
|
||||
template <class Ty, template <typename> class VT>
|
||||
ColRef_storage(const VT<Ty>& vt) {
|
||||
memcpy(this, &vt, sizeof(ColRef_storage));
|
||||
}
|
||||
};
|
||||
#endif
|
@ -1,31 +1,31 @@
|
||||
#include "aquery.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
||||
Session* session;
|
||||
|
||||
|
||||
void* Aalloc(size_t sz, deallocator_t deallocator){
|
||||
void* mem = malloc(sz);
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||
memmap->operator[](mem) = deallocator;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void Afree(void* mem){
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||
memmap->operator[](mem)(mem);
|
||||
memmap->erase(mem);
|
||||
}
|
||||
|
||||
void register_memory(void* ptr, deallocator_t deallocator){
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||
memmap->operator[](ptr) = deallocator;
|
||||
}
|
||||
|
||||
__AQEXPORT__(void) init_session(Context* cxt){
|
||||
session = &cxt->current;
|
||||
}
|
||||
#include "aquery.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
||||
Session* session;
|
||||
|
||||
|
||||
void* Aalloc(size_t sz, deallocator_t deallocator){
|
||||
void* mem = malloc(sz);
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||
memmap->operator[](mem) = deallocator;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void Afree(void* mem){
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||
memmap->operator[](mem)(mem);
|
||||
memmap->erase(mem);
|
||||
}
|
||||
|
||||
void register_memory(void* ptr, deallocator_t deallocator){
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||
memmap->operator[](ptr) = deallocator;
|
||||
}
|
||||
|
||||
__AQEXPORT__(void) init_session(Context* cxt){
|
||||
session = &cxt->current;
|
||||
}
|
||||
|
@ -1,171 +1,171 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <utility>
|
||||
#include <limits>
|
||||
#include <deque>
|
||||
#include <cmath>
|
||||
#undef max
|
||||
#undef min
|
||||
template <class T, template<typename ...> class VT>
|
||||
size_t count(const VT<T>& v) {
|
||||
return v.size;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
constexpr static inline size_t count(const T&) { return 1; }
|
||||
|
||||
// TODO: Specializations for dt/str/none
|
||||
template<class T, template<typename ...> class VT>
|
||||
types::GetLongType<T> sum(const VT<T>& v) {
|
||||
types::GetLongType<T> ret = 0;
|
||||
for (const auto& _v : v)
|
||||
ret += _v;
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
types::GetFPType<T> avg(const VT<T>& v) {
|
||||
return static_cast<types::GetFPType<T>>(
|
||||
sum<T>(v) / static_cast<long double>(v.size));
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<double> sqrt(const VT<T>& v) {
|
||||
VT<double> ret {v.size};
|
||||
for (uint32_t i = 0; i < v.size; ++i){
|
||||
ret[i] = sqrt(v[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T, template<typename ...> class VT>
|
||||
T max(const VT<T>& v) {
|
||||
T max_v = std::numeric_limits<T>::min();
|
||||
for (const auto& _v : v)
|
||||
max_v = max_v > _v ? max_v : _v;
|
||||
return max_v;
|
||||
}
|
||||
template <class T, template<typename ...> class VT>
|
||||
T min(const VT<T>& v) {
|
||||
T min_v = std::numeric_limits<T>::max();
|
||||
for (const auto& _v : v)
|
||||
min_v = min_v < _v ? min_v : _v;
|
||||
return min_v;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> mins(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
decayed_t<VT,T> ret(len);
|
||||
T min = std::numeric_limits<T>::max();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (arr[i] < min)
|
||||
min = arr[i];
|
||||
ret[i] = min;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> maxs(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT,T> ret(len);
|
||||
T max = std::numeric_limits<T>::min();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (arr[i] > max)
|
||||
max = arr[i];
|
||||
ret[i] = max;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> minw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT,T> ret{len};
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
||||
cache.push_back({ arr[i], i });
|
||||
ret[i] = cache.front().first;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> maxw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, T> ret(len);
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
||||
cache.push_back({ arr[i], i });
|
||||
arr[i] = cache.front().first;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetLongType<T>> sums(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||
uint32_t i = 0;
|
||||
if(len) ret[i++] = arr[0];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + arr[i];
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<T>> avgs(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
typedef types::GetFPType<T> FPType;
|
||||
decayed_t<VT, FPType> ret(len);
|
||||
uint32_t i = 0;
|
||||
types::GetLongType<T> s;
|
||||
if(len) s = ret[i++] = arr[0];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = (s+=arr[i])/(FPType)(i+1);
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetLongType<T>> sumw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||
uint32_t i = 0;
|
||||
w = w > len ? len : w;
|
||||
if(len) ret[i++] = arr[0];
|
||||
for (; i < w; ++i)
|
||||
ret[i] = ret[i-1] + arr[i];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + arr[i] - arr[i-w];
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<types::GetLongType<T>>> avgw(uint32_t w, const VT<T>& arr) {
|
||||
typedef types::GetFPType<types::GetLongType<T>> FPType;
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, FPType> ret(len);
|
||||
uint32_t i = 0;
|
||||
types::GetLongType<T> s{};
|
||||
w = w > len ? len : w;
|
||||
if(len) s = ret[i++] = arr[0];
|
||||
for (; i < w; ++i)
|
||||
ret[i] = (s += arr[i])/(FPType)(i+1);
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + (arr[i] - arr[i-w])/(FPType)w;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T> constexpr inline T count(const T& v) { return 1; }
|
||||
template <class T> constexpr inline T max(const T& v) { return v; }
|
||||
template <class T> constexpr inline T min(const T& v) { return v; }
|
||||
template <class T> constexpr inline T avg(const T& v) { return v; }
|
||||
template <class T> constexpr inline T sum(const T& v) { return v; }
|
||||
template <class T> constexpr inline T maxw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T minw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T sumw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T maxs(const T& v) { return v; }
|
||||
template <class T> constexpr inline T mins(const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgs(const T& v) { return v; }
|
||||
template <class T> constexpr inline T sums(const T& v) { return v; }
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <utility>
|
||||
#include <limits>
|
||||
#include <deque>
|
||||
#include <cmath>
|
||||
#undef max
|
||||
#undef min
|
||||
template <class T, template<typename ...> class VT>
|
||||
size_t count(const VT<T>& v) {
|
||||
return v.size;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
constexpr static inline size_t count(const T&) { return 1; }
|
||||
|
||||
// TODO: Specializations for dt/str/none
|
||||
template<class T, template<typename ...> class VT>
|
||||
types::GetLongType<T> sum(const VT<T>& v) {
|
||||
types::GetLongType<T> ret = 0;
|
||||
for (const auto& _v : v)
|
||||
ret += _v;
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
types::GetFPType<T> avg(const VT<T>& v) {
|
||||
return static_cast<types::GetFPType<T>>(
|
||||
sum<T>(v) / static_cast<long double>(v.size));
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<double> sqrt(const VT<T>& v) {
|
||||
VT<double> ret {v.size};
|
||||
for (uint32_t i = 0; i < v.size; ++i){
|
||||
ret[i] = sqrt(v[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T, template<typename ...> class VT>
|
||||
T max(const VT<T>& v) {
|
||||
T max_v = std::numeric_limits<T>::min();
|
||||
for (const auto& _v : v)
|
||||
max_v = max_v > _v ? max_v : _v;
|
||||
return max_v;
|
||||
}
|
||||
template <class T, template<typename ...> class VT>
|
||||
T min(const VT<T>& v) {
|
||||
T min_v = std::numeric_limits<T>::max();
|
||||
for (const auto& _v : v)
|
||||
min_v = min_v < _v ? min_v : _v;
|
||||
return min_v;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> mins(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
decayed_t<VT,T> ret(len);
|
||||
T min = std::numeric_limits<T>::max();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (arr[i] < min)
|
||||
min = arr[i];
|
||||
ret[i] = min;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> maxs(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT,T> ret(len);
|
||||
T max = std::numeric_limits<T>::min();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (arr[i] > max)
|
||||
max = arr[i];
|
||||
ret[i] = max;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> minw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT,T> ret{len};
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
||||
cache.push_back({ arr[i], i });
|
||||
ret[i] = cache.front().first;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT,T> maxw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, T> ret(len);
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
||||
cache.push_back({ arr[i], i });
|
||||
arr[i] = cache.front().first;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetLongType<T>> sums(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||
uint32_t i = 0;
|
||||
if(len) ret[i++] = arr[0];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + arr[i];
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<T>> avgs(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
typedef types::GetFPType<T> FPType;
|
||||
decayed_t<VT, FPType> ret(len);
|
||||
uint32_t i = 0;
|
||||
types::GetLongType<T> s;
|
||||
if(len) s = ret[i++] = arr[0];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = (s+=arr[i])/(FPType)(i+1);
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetLongType<T>> sumw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||
uint32_t i = 0;
|
||||
w = w > len ? len : w;
|
||||
if(len) ret[i++] = arr[0];
|
||||
for (; i < w; ++i)
|
||||
ret[i] = ret[i-1] + arr[i];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + arr[i] - arr[i-w];
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<types::GetLongType<T>>> avgw(uint32_t w, const VT<T>& arr) {
|
||||
typedef types::GetFPType<types::GetLongType<T>> FPType;
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, FPType> ret(len);
|
||||
uint32_t i = 0;
|
||||
types::GetLongType<T> s{};
|
||||
w = w > len ? len : w;
|
||||
if(len) s = ret[i++] = arr[0];
|
||||
for (; i < w; ++i)
|
||||
ret[i] = (s += arr[i])/(FPType)(i+1);
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + (arr[i] - arr[i-w])/(FPType)w;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T> constexpr inline T count(const T& v) { return 1; }
|
||||
template <class T> constexpr inline T max(const T& v) { return v; }
|
||||
template <class T> constexpr inline T min(const T& v) { return v; }
|
||||
template <class T> constexpr inline T avg(const T& v) { return v; }
|
||||
template <class T> constexpr inline T sum(const T& v) { return v; }
|
||||
template <class T> constexpr inline T maxw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T minw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T sumw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T maxs(const T& v) { return v; }
|
||||
template <class T> constexpr inline T mins(const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgs(const T& v) { return v; }
|
||||
template <class T> constexpr inline T sums(const T& v) { return v; }
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define Ops(o) template<typename T> vector_type<typename types::Coercion<_Ty, T>::type> operator##o(const vector_type<T>& r) { [[likely]] if (r.size == size) { return add(r); } else if (r.size == 1 || size == 1) { const bool lr = size == 1; const uint32_t& _size = lr ? r.size : size; const auto& _container = lr ? r.container : container; const auto& scalar = *(lr ? container : r.container); vector_type<typename types::Coercion<_Ty, T>::type> ret(_size); for (int i = 0; i < _size; ++i) ret[i] = _container[i] o scalar; return ret; } }
|
||||
#define Op(o, x) template<typename T> vector_type<typename types::Coercion<_Ty, T>::type> inline x(const vector_type<T>& r) { vector_type<typename types::Coercion<_Ty, T>::type> ret(size); for (int i = 0; i < size; ++i) ret[i] = container[i] o r[i]; return ret; }
|
||||
#define _Make_Ops(M) M(+, add) M(-, minus) M(*, multi) M(/, div) M(%, mod) M(&, and) M(|, or) M(^, xor)
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define Ops(o) template<typename T> vector_type<typename types::Coercion<_Ty, T>::type> operator##o(const vector_type<T>& r) { [[likely]] if (r.size == size) { return add(r); } else if (r.size == 1 || size == 1) { const bool lr = size == 1; const uint32_t& _size = lr ? r.size : size; const auto& _container = lr ? r.container : container; const auto& scalar = *(lr ? container : r.container); vector_type<typename types::Coercion<_Ty, T>::type> ret(_size); for (int i = 0; i < _size; ++i) ret[i] = _container[i] o scalar; return ret; } }
|
||||
#define Op(o, x) template<typename T> vector_type<typename types::Coercion<_Ty, T>::type> inline x(const vector_type<T>& r) { vector_type<typename types::Coercion<_Ty, T>::type> ret(size); for (int i = 0; i < size; ++i) ret[i] = container[i] o r[i]; return ret; }
|
||||
#define _Make_Ops(M) M(+, add) M(-, minus) M(*, multi) M(/, div) M(%, mod) M(&, and) M(|, or) M(^, xor)
|
||||
|
@ -1,53 +1,53 @@
|
||||
#pragma once
|
||||
#include <vector_type>
|
||||
#include <utility>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
class GC {
|
||||
template<class T>
|
||||
using vector = vector_type<T>;
|
||||
template<class ...T>
|
||||
using tuple = std::tuple<T...>;
|
||||
size_t current_size, max_size, interval, forced_clean;
|
||||
bool running, alive;
|
||||
// ptr, dealloc, ref, sz
|
||||
vector<tuple<void*, void (*)(void*)>> q;
|
||||
std::thread handle;
|
||||
void gc()
|
||||
{
|
||||
|
||||
}
|
||||
void reg(void* v, uint32_t ref, uint32_t sz,
|
||||
void(*f)(void*) = [](void* v) {free (v); }) {
|
||||
current_size += sz;
|
||||
if (current_size > max_size)
|
||||
gc();
|
||||
q.push_back({ v, f });
|
||||
}
|
||||
void daemon() {
|
||||
using namespace std::chrono;
|
||||
while (alive) {
|
||||
if (running) {
|
||||
gc();
|
||||
std::this_thread::sleep_for(microseconds(interval));
|
||||
}
|
||||
else {
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
void start_deamon() {
|
||||
handle = std::thread(&daemon);
|
||||
alive = true;
|
||||
}
|
||||
void terminate_daemon() {
|
||||
running = false;
|
||||
alive = false;
|
||||
using namespace std::chrono;
|
||||
|
||||
if (handle.joinable()) {
|
||||
std::this_thread::sleep_for(microseconds(1000 + std::max(static_cast<size_t>(10000), interval)));
|
||||
handle.join();
|
||||
}
|
||||
}
|
||||
#pragma once
|
||||
#include <vector_type>
|
||||
#include <utility>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
class GC {
|
||||
template<class T>
|
||||
using vector = vector_type<T>;
|
||||
template<class ...T>
|
||||
using tuple = std::tuple<T...>;
|
||||
size_t current_size, max_size, interval, forced_clean;
|
||||
bool running, alive;
|
||||
// ptr, dealloc, ref, sz
|
||||
vector<tuple<void*, void (*)(void*)>> q;
|
||||
std::thread handle;
|
||||
void gc()
|
||||
{
|
||||
|
||||
}
|
||||
void reg(void* v, uint32_t ref, uint32_t sz,
|
||||
void(*f)(void*) = [](void* v) {free (v); }) {
|
||||
current_size += sz;
|
||||
if (current_size > max_size)
|
||||
gc();
|
||||
q.push_back({ v, f });
|
||||
}
|
||||
void daemon() {
|
||||
using namespace std::chrono;
|
||||
while (alive) {
|
||||
if (running) {
|
||||
gc();
|
||||
std::this_thread::sleep_for(microseconds(interval));
|
||||
}
|
||||
else {
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
void start_deamon() {
|
||||
handle = std::thread(&daemon);
|
||||
alive = true;
|
||||
}
|
||||
void terminate_daemon() {
|
||||
running = false;
|
||||
alive = false;
|
||||
using namespace std::chrono;
|
||||
|
||||
if (handle.joinable()) {
|
||||
std::this_thread::sleep_for(microseconds(1000 + std::max(static_cast<size_t>(10000), interval)));
|
||||
handle.join();
|
||||
}
|
||||
}
|
||||
};
|
@ -1,20 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
template <class ...Types>
|
||||
struct hasher {
|
||||
template <size_t i = 0> typename std::enable_if< i == sizeof...(Types),
|
||||
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <size_t i = 0> typename std::enable_if< i < sizeof ...(Types),
|
||||
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
||||
using current_type = typename std::decay<typename std::tuple_element<i, std::tuple<Types...>>::type>::type;
|
||||
return std::hash<current_type>()(std::get<i>(record)) ^ hashi<i+1>(record);
|
||||
}
|
||||
size_t operator()(const std::tuple<Types...>& record) const {
|
||||
return hashi(record);
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
template <class ...Types>
|
||||
struct hasher {
|
||||
template <size_t i = 0> typename std::enable_if< i == sizeof...(Types),
|
||||
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <size_t i = 0> typename std::enable_if< i < sizeof ...(Types),
|
||||
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
||||
using current_type = typename std::decay<typename std::tuple_element<i, std::tuple<Types...>>::type>::type;
|
||||
return std::hash<current_type>()(std::get<i>(record)) ^ hashi<i+1>(record);
|
||||
}
|
||||
size_t operator()(const std::tuple<Types...>& record) const {
|
||||
return hashi(record);
|
||||
}
|
||||
};
|
||||
|
@ -1,81 +1,81 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
template <class ...Types>
|
||||
std::string generate_printf_string(const char* sep = " ", const char* end = "\n") {
|
||||
std::string str;
|
||||
((str += types::printf_str[types::Types<value_type_r<Types>>::getType()], str += sep), ...);
|
||||
const auto trim = str.size() - strlen(sep);
|
||||
if (trim > 0)
|
||||
str.resize(trim);
|
||||
str += end;
|
||||
return str;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline decltype(auto) print_hook(const T& v){
|
||||
return v;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline decltype(auto) print_hook<bool>(const bool& v) {
|
||||
return v? "true" : "false";
|
||||
}
|
||||
|
||||
#ifdef __SIZEOF_INT128__
|
||||
constexpr struct __int128__struct{
|
||||
uint64_t low, high;
|
||||
// constexpr bool operator==(__int128_t x) const{
|
||||
// return (x>>64) == high and (x&0xffffffffffffffffull) == low;
|
||||
// }
|
||||
bool operator==(__int128_t x) const{
|
||||
return *((const __int128_t*) this) == x;
|
||||
}
|
||||
}__int128_max_v = {0x0000000000000000ull, 0x8000000000000000ull};
|
||||
|
||||
inline const char* get_int128str(__int128_t v, char* buf){
|
||||
bool neg = false;
|
||||
if (v < 0) {
|
||||
if(__int128_max_v == v)
|
||||
return "-170141183460469231731687303715884105728";
|
||||
v = -v;
|
||||
neg = true;
|
||||
}
|
||||
do {
|
||||
*--buf = v%10 + '0';
|
||||
v /= 10;
|
||||
} while(v);
|
||||
if (neg) *--buf = '-';
|
||||
return buf;
|
||||
}
|
||||
|
||||
inline const char* get_uint128str(__uint128_t v, char* buf){
|
||||
do {
|
||||
*--buf = v%10 + '0';
|
||||
v /= 10;
|
||||
} while(v);
|
||||
return buf;
|
||||
}
|
||||
extern char* gbuf;
|
||||
|
||||
void setgbuf(char* buf = 0);
|
||||
|
||||
template<>
|
||||
inline decltype(auto) print_hook<__int128_t>(const __int128_t& v) {
|
||||
*(gbuf+=40) = 0;
|
||||
return get_int128str(v, gbuf++);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline decltype(auto) print_hook<__uint128_t>(const __uint128_t& v) {
|
||||
*(gbuf+=40) = 0;
|
||||
return get_uint128str(v, gbuf++);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define setgbuf()
|
||||
#endif
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
template <class ...Types>
|
||||
std::string generate_printf_string(const char* sep = " ", const char* end = "\n") {
|
||||
std::string str;
|
||||
((str += types::printf_str[types::Types<value_type_r<Types>>::getType()], str += sep), ...);
|
||||
const auto trim = str.size() - strlen(sep);
|
||||
if (trim > 0)
|
||||
str.resize(trim);
|
||||
str += end;
|
||||
return str;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline decltype(auto) print_hook(const T& v){
|
||||
return v;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline decltype(auto) print_hook<bool>(const bool& v) {
|
||||
return v? "true" : "false";
|
||||
}
|
||||
|
||||
#ifdef __SIZEOF_INT128__
|
||||
constexpr struct __int128__struct{
|
||||
uint64_t low, high;
|
||||
// constexpr bool operator==(__int128_t x) const{
|
||||
// return (x>>64) == high and (x&0xffffffffffffffffull) == low;
|
||||
// }
|
||||
bool operator==(__int128_t x) const{
|
||||
return *((const __int128_t*) this) == x;
|
||||
}
|
||||
}__int128_max_v = {0x0000000000000000ull, 0x8000000000000000ull};
|
||||
|
||||
inline const char* get_int128str(__int128_t v, char* buf){
|
||||
bool neg = false;
|
||||
if (v < 0) {
|
||||
if(__int128_max_v == v)
|
||||
return "-170141183460469231731687303715884105728";
|
||||
v = -v;
|
||||
neg = true;
|
||||
}
|
||||
do {
|
||||
*--buf = v%10 + '0';
|
||||
v /= 10;
|
||||
} while(v);
|
||||
if (neg) *--buf = '-';
|
||||
return buf;
|
||||
}
|
||||
|
||||
inline const char* get_uint128str(__uint128_t v, char* buf){
|
||||
do {
|
||||
*--buf = v%10 + '0';
|
||||
v /= 10;
|
||||
} while(v);
|
||||
return buf;
|
||||
}
|
||||
extern char* gbuf;
|
||||
|
||||
void setgbuf(char* buf = 0);
|
||||
|
||||
template<>
|
||||
inline decltype(auto) print_hook<__int128_t>(const __int128_t& v) {
|
||||
*(gbuf+=40) = 0;
|
||||
return get_int128str(v, gbuf++);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline decltype(auto) print_hook<__uint128_t>(const __uint128_t& v) {
|
||||
*(gbuf+=40) = 0;
|
||||
return get_uint128str(v, gbuf++);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define setgbuf()
|
||||
#endif
|
||||
|
@ -1,79 +1,79 @@
|
||||
#ifndef _AQUERY_H
|
||||
#define _AQUERY_H
|
||||
|
||||
#include "table.h"
|
||||
#include <unordered_map>
|
||||
|
||||
enum Log_level {
|
||||
LOG_INFO,
|
||||
LOG_ERROR,
|
||||
LOG_SILENT
|
||||
};
|
||||
|
||||
enum Backend_Type {
|
||||
BACKEND_AQuery,
|
||||
BACKEND_MonetDB,
|
||||
BACKEND_MariaDB
|
||||
};
|
||||
struct Config{
|
||||
int running, new_query, server_mode,
|
||||
backend_type, has_dll, n_buffers;
|
||||
int buffer_sizes[];
|
||||
};
|
||||
|
||||
struct Session{
|
||||
struct Statistic{
|
||||
size_t total_active;
|
||||
size_t cnt_object;
|
||||
size_t total_alloc;
|
||||
} stats;
|
||||
void* memory_map;
|
||||
};
|
||||
|
||||
struct Context{
|
||||
typedef int (*printf_type) (const char *format, ...);
|
||||
|
||||
void* module_function_maps = 0;
|
||||
Config* cfg;
|
||||
|
||||
int n_buffers, *sz_bufs;
|
||||
void **buffers;
|
||||
|
||||
void* alt_server = 0;
|
||||
Log_level log_level = LOG_INFO;
|
||||
|
||||
Session current;
|
||||
|
||||
#ifdef THREADING
|
||||
void* thread_pool;
|
||||
#endif
|
||||
printf_type print = printf;
|
||||
Context();
|
||||
virtual ~Context();
|
||||
template <class ...Types>
|
||||
void log(Types... args) {
|
||||
if (log_level == LOG_INFO)
|
||||
print(args...);
|
||||
}
|
||||
template <class ...Types>
|
||||
void err(Types... args) {
|
||||
if (log_level <= LOG_ERROR)
|
||||
print(args...);
|
||||
}
|
||||
void init_session();
|
||||
void end_session();
|
||||
void* get_module_function(const char*);
|
||||
std::unordered_map<const char*, void*> tables;
|
||||
std::unordered_map<const char*, uColRef *> cols;
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define __DLLEXPORT__
|
||||
#endif
|
||||
|
||||
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
||||
typedef void (*deallocator_t) (void*);
|
||||
|
||||
#endif
|
||||
#ifndef _AQUERY_H
|
||||
#define _AQUERY_H
|
||||
|
||||
#include "table.h"
|
||||
#include <unordered_map>
|
||||
|
||||
enum Log_level {
|
||||
LOG_INFO,
|
||||
LOG_ERROR,
|
||||
LOG_SILENT
|
||||
};
|
||||
|
||||
enum Backend_Type {
|
||||
BACKEND_AQuery,
|
||||
BACKEND_MonetDB,
|
||||
BACKEND_MariaDB
|
||||
};
|
||||
struct Config{
|
||||
int running, new_query, server_mode,
|
||||
backend_type, has_dll, n_buffers;
|
||||
int buffer_sizes[];
|
||||
};
|
||||
|
||||
struct Session{
|
||||
struct Statistic{
|
||||
size_t total_active;
|
||||
size_t cnt_object;
|
||||
size_t total_alloc;
|
||||
} stats;
|
||||
void* memory_map;
|
||||
};
|
||||
|
||||
struct Context{
|
||||
typedef int (*printf_type) (const char *format, ...);
|
||||
|
||||
void* module_function_maps = 0;
|
||||
Config* cfg;
|
||||
|
||||
int n_buffers, *sz_bufs;
|
||||
void **buffers;
|
||||
|
||||
void* alt_server = 0;
|
||||
Log_level log_level = LOG_INFO;
|
||||
|
||||
Session current;
|
||||
|
||||
#ifdef THREADING
|
||||
void* thread_pool;
|
||||
#endif
|
||||
printf_type print = printf;
|
||||
Context();
|
||||
virtual ~Context();
|
||||
template <class ...Types>
|
||||
void log(Types... args) {
|
||||
if (log_level == LOG_INFO)
|
||||
print(args...);
|
||||
}
|
||||
template <class ...Types>
|
||||
void err(Types... args) {
|
||||
if (log_level <= LOG_ERROR)
|
||||
print(args...);
|
||||
}
|
||||
void init_session();
|
||||
void end_session();
|
||||
void* get_module_function(const char*);
|
||||
std::unordered_map<const char*, void*> tables;
|
||||
std::unordered_map<const char*, uColRef *> cols;
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define __DLLEXPORT__
|
||||
#endif
|
||||
|
||||
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
||||
typedef void (*deallocator_t) (void*);
|
||||
|
||||
#endif
|
||||
|
@ -1,19 +1,19 @@
|
||||
#pragma once
|
||||
#include "vector_type.hpp"
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
template <class Comparator, typename T = uint32_t>
|
||||
class priority_vector : public vector_type<T> {
|
||||
const Comparator comp;
|
||||
public:
|
||||
priority_vector(Comparator comp = std::less<T>{}) :
|
||||
comp(comp), vector_type<T>(0) {}
|
||||
void emplace_back(T val) {
|
||||
vector_type<T>::emplace_back(val);
|
||||
std::push_heap(container, container + size, comp);
|
||||
}
|
||||
void pop_back() {
|
||||
std::pop_heap(container, container + size, comp);
|
||||
--size;
|
||||
}
|
||||
#pragma once
|
||||
#include "vector_type.hpp"
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
template <class Comparator, typename T = uint32_t>
|
||||
class priority_vector : public vector_type<T> {
|
||||
const Comparator comp;
|
||||
public:
|
||||
priority_vector(Comparator comp = std::less<T>{}) :
|
||||
comp(comp), vector_type<T>(0) {}
|
||||
void emplace_back(T val) {
|
||||
vector_type<T>::emplace_back(val);
|
||||
std::push_heap(container, container + size, comp);
|
||||
}
|
||||
void pop_back() {
|
||||
std::pop_heap(container, container + size, comp);
|
||||
--size;
|
||||
}
|
||||
};
|
@ -1,369 +1,369 @@
|
||||
#include "pch.hpp"
|
||||
|
||||
#include "../csv.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
#include "libaquery.h"
|
||||
#include "monetdb_conn.h"
|
||||
#ifdef THREADING
|
||||
#include "threading.h"
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include "winhelper.h"
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
struct SharedMemory
|
||||
{
|
||||
int hFileMap;
|
||||
void* pData;
|
||||
SharedMemory(const char* fname) {
|
||||
hFileMap = open(fname, O_RDWR, 0);
|
||||
if (hFileMap != -1)
|
||||
pData = mmap(NULL, 8, PROT_READ | PROT_WRITE, MAP_SHARED, hFileMap, 0);
|
||||
else
|
||||
pData = 0;
|
||||
}
|
||||
void FreeMemoryMap() {
|
||||
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "aggregations.h"
|
||||
typedef int (*code_snippet)(void*);
|
||||
typedef void (*module_init_fn)(Context*);
|
||||
|
||||
int test_main();
|
||||
|
||||
int n_recv = 0;
|
||||
char** n_recvd = nullptr;
|
||||
|
||||
extern "C" void __DLLEXPORT__ receive_args(int argc, char**argv){
|
||||
n_recv = argc;
|
||||
n_recvd = argv;
|
||||
}
|
||||
|
||||
enum BinaryInfo_t {
|
||||
MSVC, MSYS, GCC, CLANG, AppleClang
|
||||
};
|
||||
|
||||
extern "C" int __DLLEXPORT__ binary_info() {
|
||||
#if defined(_MSC_VER) && !defined (__llvm__)
|
||||
return MSVC;
|
||||
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
return MSYS;
|
||||
#elif defined(__clang__)
|
||||
return CLANG;
|
||||
#elif defined(__GNUC__)
|
||||
return GCC;
|
||||
#endif
|
||||
}
|
||||
|
||||
__AQEXPORT__(bool) have_hge(){
|
||||
#if defined(__MONETDB_CONN_H__)
|
||||
return Server::havehge();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Context::Context() {
|
||||
current.memory_map = new std::unordered_map<void*, deallocator_t>;
|
||||
init_session();
|
||||
}
|
||||
|
||||
Context::~Context() {
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||
delete memmap;
|
||||
}
|
||||
|
||||
void Context::init_session(){
|
||||
if (log_level == LOG_INFO){
|
||||
memset(&(this->current.stats), 0, sizeof(Session::Statistic));
|
||||
}
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||
memmap->clear();
|
||||
}
|
||||
|
||||
void Context::end_session(){
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||
for (auto& mem : *memmap) {
|
||||
mem.second(mem.first);
|
||||
}
|
||||
memmap->clear();
|
||||
}
|
||||
|
||||
void* Context::get_module_function(const char* fname){
|
||||
auto fmap = static_cast<std::unordered_map<std::string, void*>*>
|
||||
(this->module_function_maps);
|
||||
printf("%p\n", fmap->find("mydiv")->second);
|
||||
for (const auto& [key, value] : *fmap){
|
||||
printf("%s %p\n", key.c_str(), value);
|
||||
}
|
||||
auto ret = fmap->find(fname);
|
||||
return ret == fmap->end() ? nullptr : ret->second;
|
||||
}
|
||||
|
||||
void initialize_module(const char* module_name, void* module_handle, Context* cxt){
|
||||
auto _init_module = reinterpret_cast<module_init_fn>(dlsym(module_handle, "init_session"));
|
||||
if (_init_module) {
|
||||
_init_module(cxt);
|
||||
}
|
||||
else {
|
||||
printf("Warning: module %s have no session support.\n", module_name);
|
||||
}
|
||||
}
|
||||
|
||||
int dll_main(int argc, char** argv, Context* cxt){
|
||||
Config *cfg = reinterpret_cast<Config *>(argv[0]);
|
||||
std::unordered_map<std::string, void*> user_module_map;
|
||||
if (cxt->module_function_maps == 0)
|
||||
cxt->module_function_maps = new std::unordered_map<std::string, void*>();
|
||||
auto module_fn_map =
|
||||
static_cast<std::unordered_map<std::string, void*>*>(cxt->module_function_maps);
|
||||
|
||||
auto buf_szs = cfg->buffer_sizes;
|
||||
void** buffers = (void**)malloc(sizeof(void*) * cfg->n_buffers);
|
||||
for (int i = 0; i < cfg->n_buffers; i++)
|
||||
buffers[i] = static_cast<void *>(argv[i + 1]);
|
||||
|
||||
cxt->buffers = buffers;
|
||||
cxt->cfg = cfg;
|
||||
cxt->n_buffers = cfg->n_buffers;
|
||||
cxt->sz_bufs = buf_szs;
|
||||
cxt->alt_server = NULL;
|
||||
|
||||
while(cfg->running){
|
||||
if (cfg->new_query) {
|
||||
void *handle = 0;
|
||||
void *user_module_handle = 0;
|
||||
if (cfg->backend_type == BACKEND_MonetDB){
|
||||
if (cxt->alt_server == 0)
|
||||
cxt->alt_server = new Server(cxt);
|
||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||
if(n_recv > 0){
|
||||
if (cfg->backend_type == BACKEND_AQuery || cfg->has_dll) {
|
||||
handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
}
|
||||
for (const auto& module : user_module_map){
|
||||
initialize_module(module.first.c_str(), module.second, cxt);
|
||||
}
|
||||
cxt->init_session();
|
||||
for(int i = 0; i < n_recv; ++i)
|
||||
{
|
||||
//printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q');
|
||||
switch(n_recvd[i][0]){
|
||||
case 'Q': // SQL query for monetdbe
|
||||
{
|
||||
server->exec(n_recvd[i] + 1);
|
||||
printf("Exec Q%d: %s", i, n_recvd[i]);
|
||||
}
|
||||
break;
|
||||
case 'P': // Postprocessing procedure
|
||||
if(handle && !server->haserror()) {
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i]+1));
|
||||
c(cxt);
|
||||
}
|
||||
break;
|
||||
case 'M': // Load Module
|
||||
{
|
||||
auto mname = n_recvd[i] + 1;
|
||||
user_module_handle = dlopen(mname, RTLD_LAZY);
|
||||
//getlasterror
|
||||
|
||||
if (!user_module_handle)
|
||||
#ifndef _MSC_VER
|
||||
puts(dlerror());
|
||||
#else
|
||||
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, GetLastError());
|
||||
#endif
|
||||
user_module_map[mname] = user_module_handle;
|
||||
initialize_module(mname, user_module_handle, cxt);
|
||||
}
|
||||
break;
|
||||
case 'F': // Register Function in Module
|
||||
{
|
||||
auto fname = n_recvd[i] + 1;
|
||||
printf("F:: %s: %p, %p\n", fname, user_module_handle, dlsym(user_module_handle, fname));
|
||||
module_fn_map->insert_or_assign(fname, dlsym(user_module_handle, fname));
|
||||
printf("F::: %p\n", module_fn_map->find("mydiv") != module_fn_map->end() ? module_fn_map->find("mydiv")->second : nullptr);
|
||||
}
|
||||
break;
|
||||
case 'U': // Unload Module
|
||||
{
|
||||
auto mname = n_recvd[i] + 1;
|
||||
auto it = user_module_map.find(mname);
|
||||
if (user_module_handle == it->second)
|
||||
user_module_handle = 0;
|
||||
dlclose(it->second);
|
||||
user_module_map.erase(it);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(handle) {
|
||||
dlclose(handle);
|
||||
handle = 0;
|
||||
}
|
||||
cxt->end_session();
|
||||
n_recv = 0;
|
||||
}
|
||||
if(server->last_error == nullptr){
|
||||
// TODO: Add feedback to prompt.
|
||||
}
|
||||
else{
|
||||
server->last_error = nullptr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// puts(cfg->has_dll ? "true" : "false");
|
||||
if (cfg->backend_type == BACKEND_AQuery) {
|
||||
handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||
c(cxt);
|
||||
}
|
||||
if (handle) dlclose(handle);
|
||||
cfg->new_query = 0;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int launcher(int argc, char** argv){
|
||||
#ifdef _WIN32
|
||||
constexpr char sep = '\\';
|
||||
#else
|
||||
constexpr char sep = '/';
|
||||
#endif
|
||||
std::string str = " ";
|
||||
std::string pwd = "";
|
||||
if (argc > 0)
|
||||
pwd = argv[0];
|
||||
|
||||
auto pos = pwd.find_last_of(sep);
|
||||
if (pos == std::string::npos)
|
||||
pos = 0;
|
||||
pwd = pwd.substr(0, pos);
|
||||
for (int i = 1; i < argc; i++){
|
||||
str += argv[i];
|
||||
str += " ";
|
||||
}
|
||||
str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str;
|
||||
return system(str.c_str());
|
||||
}
|
||||
|
||||
extern "C" int __DLLEXPORT__ main(int argc, char** argv) {
|
||||
#ifdef __AQ_BUILD_LAUNCHER__
|
||||
return launcher(argc, argv);
|
||||
#endif
|
||||
puts("running");
|
||||
Context* cxt = new Context();
|
||||
cxt->log("%d %s\n", argc, argv[1]);
|
||||
|
||||
#ifdef THREADING
|
||||
auto tp = new ThreadPool();
|
||||
cxt->thread_pool = tp;
|
||||
#endif
|
||||
|
||||
const char* shmname;
|
||||
if (argc < 0)
|
||||
return dll_main(argc, argv, cxt);
|
||||
else if (argc <= 1)
|
||||
return test_main();
|
||||
else
|
||||
shmname = argv[1];
|
||||
SharedMemory shm = SharedMemory(shmname);
|
||||
if (!shm.pData)
|
||||
return 1;
|
||||
bool &running = static_cast<bool*>(shm.pData)[0],
|
||||
&ready = static_cast<bool*>(shm.pData)[1];
|
||||
using namespace std::chrono_literals;
|
||||
cxt->log("running: %s\n", running? "true":"false");
|
||||
cxt->log("ready: %s\n", ready? "true":"false");
|
||||
while (running) {
|
||||
std::this_thread::sleep_for(1ms);
|
||||
if(ready){
|
||||
cxt->log("running: %s\n", running? "true":"false");
|
||||
cxt->log("ready: %s\n", ready? "true":"false");
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
cxt->log("handle: %p\n", handle);
|
||||
if (handle) {
|
||||
cxt->log("inner\n");
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||
cxt->log("routine: %p\n", c);
|
||||
if (c) {
|
||||
cxt->log("inner\n");
|
||||
cxt->err("return: %d\n", c(cxt));
|
||||
}
|
||||
}
|
||||
ready = false;
|
||||
}
|
||||
}
|
||||
shm.FreeMemoryMap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "utils.h"
|
||||
#include "table_ext_monetdb.hpp"
|
||||
int test_main()
|
||||
{
|
||||
Context* cxt = new Context();
|
||||
if (cxt->alt_server == 0)
|
||||
cxt->alt_server = new Server(cxt);
|
||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||
|
||||
|
||||
//TableInfo<int, float> table("sibal");
|
||||
//int col0[] = { 1,2,3,4,5 };
|
||||
//float col1[] = { 5.f, 4.f, 3.f, 2.f, 1.f };
|
||||
//table.get_col<0>().initfrom(5, col0, "a");
|
||||
//table.get_col<1>().initfrom(5, col1, "b");
|
||||
//table.monetdb_append_table(server);
|
||||
//
|
||||
//server->exec("select * from sibal;");
|
||||
//auto aa = server->getCol(0);
|
||||
//auto bb = server->getCol(1);
|
||||
//printf("sibal: %p %p\n", aa, bb);
|
||||
|
||||
const char* qs[]= {
|
||||
"CREATE TABLE test(a INT, b INT, c INT, d INT);",
|
||||
"COPY OFFSET 2 INTO test FROM 'c:/Users/sunyi/Desktop/AQuery2/data/test2.csv' ON SERVER USING DELIMITERS ',';",
|
||||
"SELECT (a + b), a,b,c FROM test ;",
|
||||
};
|
||||
n_recv = sizeof(qs)/(sizeof (char*));
|
||||
n_recvd = const_cast<char**>(qs);
|
||||
if (n_recv > 0) {
|
||||
for (int i = 0; i < n_recv; ++i)
|
||||
{
|
||||
server->exec(n_recvd[i]);
|
||||
printf("Exec Q%d: %s\n", i, n_recvd[i]);
|
||||
}
|
||||
n_recv = 0;
|
||||
}
|
||||
|
||||
cxt->log_level = LOG_INFO;
|
||||
puts(cpp_17 ?"true":"false");
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
cxt->log("handle: %p\n", handle);
|
||||
if (handle) {
|
||||
cxt->log("inner\n");
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dll_ZF5Shg"));
|
||||
cxt->log("routine: %p\n", c);
|
||||
if (c) {
|
||||
cxt->log("inner\n");
|
||||
cxt->log("return: %d\n", c(cxt));
|
||||
}
|
||||
dlclose(handle);
|
||||
}
|
||||
//static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include "../csv.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
#include "libaquery.h"
|
||||
#include "monetdb_conn.h"
|
||||
#ifdef THREADING
|
||||
#include "threading.h"
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include "winhelper.h"
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
struct SharedMemory
|
||||
{
|
||||
int hFileMap;
|
||||
void* pData;
|
||||
SharedMemory(const char* fname) {
|
||||
hFileMap = open(fname, O_RDWR, 0);
|
||||
if (hFileMap != -1)
|
||||
pData = mmap(NULL, 8, PROT_READ | PROT_WRITE, MAP_SHARED, hFileMap, 0);
|
||||
else
|
||||
pData = 0;
|
||||
}
|
||||
void FreeMemoryMap() {
|
||||
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "aggregations.h"
|
||||
typedef int (*code_snippet)(void*);
|
||||
typedef void (*module_init_fn)(Context*);
|
||||
|
||||
int test_main();
|
||||
|
||||
int n_recv = 0;
|
||||
char** n_recvd = nullptr;
|
||||
|
||||
extern "C" void __DLLEXPORT__ receive_args(int argc, char**argv){
|
||||
n_recv = argc;
|
||||
n_recvd = argv;
|
||||
}
|
||||
|
||||
enum BinaryInfo_t {
|
||||
MSVC, MSYS, GCC, CLANG, AppleClang
|
||||
};
|
||||
|
||||
extern "C" int __DLLEXPORT__ binary_info() {
|
||||
#if defined(_MSC_VER) && !defined (__llvm__)
|
||||
return MSVC;
|
||||
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
return MSYS;
|
||||
#elif defined(__clang__)
|
||||
return CLANG;
|
||||
#elif defined(__GNUC__)
|
||||
return GCC;
|
||||
#endif
|
||||
}
|
||||
|
||||
__AQEXPORT__(bool) have_hge(){
|
||||
#if defined(__MONETDB_CONN_H__)
|
||||
return Server::havehge();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Context::Context() {
|
||||
current.memory_map = new std::unordered_map<void*, deallocator_t>;
|
||||
init_session();
|
||||
}
|
||||
|
||||
Context::~Context() {
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||
delete memmap;
|
||||
}
|
||||
|
||||
void Context::init_session(){
|
||||
if (log_level == LOG_INFO){
|
||||
memset(&(this->current.stats), 0, sizeof(Session::Statistic));
|
||||
}
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||
memmap->clear();
|
||||
}
|
||||
|
||||
void Context::end_session(){
|
||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||
for (auto& mem : *memmap) {
|
||||
mem.second(mem.first);
|
||||
}
|
||||
memmap->clear();
|
||||
}
|
||||
|
||||
void* Context::get_module_function(const char* fname){
|
||||
auto fmap = static_cast<std::unordered_map<std::string, void*>*>
|
||||
(this->module_function_maps);
|
||||
printf("%p\n", fmap->find("mydiv")->second);
|
||||
for (const auto& [key, value] : *fmap){
|
||||
printf("%s %p\n", key.c_str(), value);
|
||||
}
|
||||
auto ret = fmap->find(fname);
|
||||
return ret == fmap->end() ? nullptr : ret->second;
|
||||
}
|
||||
|
||||
void initialize_module(const char* module_name, void* module_handle, Context* cxt){
|
||||
auto _init_module = reinterpret_cast<module_init_fn>(dlsym(module_handle, "init_session"));
|
||||
if (_init_module) {
|
||||
_init_module(cxt);
|
||||
}
|
||||
else {
|
||||
printf("Warning: module %s have no session support.\n", module_name);
|
||||
}
|
||||
}
|
||||
|
||||
int dll_main(int argc, char** argv, Context* cxt){
|
||||
Config *cfg = reinterpret_cast<Config *>(argv[0]);
|
||||
std::unordered_map<std::string, void*> user_module_map;
|
||||
if (cxt->module_function_maps == 0)
|
||||
cxt->module_function_maps = new std::unordered_map<std::string, void*>();
|
||||
auto module_fn_map =
|
||||
static_cast<std::unordered_map<std::string, void*>*>(cxt->module_function_maps);
|
||||
|
||||
auto buf_szs = cfg->buffer_sizes;
|
||||
void** buffers = (void**)malloc(sizeof(void*) * cfg->n_buffers);
|
||||
for (int i = 0; i < cfg->n_buffers; i++)
|
||||
buffers[i] = static_cast<void *>(argv[i + 1]);
|
||||
|
||||
cxt->buffers = buffers;
|
||||
cxt->cfg = cfg;
|
||||
cxt->n_buffers = cfg->n_buffers;
|
||||
cxt->sz_bufs = buf_szs;
|
||||
cxt->alt_server = NULL;
|
||||
|
||||
while(cfg->running){
|
||||
if (cfg->new_query) {
|
||||
void *handle = 0;
|
||||
void *user_module_handle = 0;
|
||||
if (cfg->backend_type == BACKEND_MonetDB){
|
||||
if (cxt->alt_server == 0)
|
||||
cxt->alt_server = new Server(cxt);
|
||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||
if(n_recv > 0){
|
||||
if (cfg->backend_type == BACKEND_AQuery || cfg->has_dll) {
|
||||
handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
}
|
||||
for (const auto& module : user_module_map){
|
||||
initialize_module(module.first.c_str(), module.second, cxt);
|
||||
}
|
||||
cxt->init_session();
|
||||
for(int i = 0; i < n_recv; ++i)
|
||||
{
|
||||
//printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q');
|
||||
switch(n_recvd[i][0]){
|
||||
case 'Q': // SQL query for monetdbe
|
||||
{
|
||||
server->exec(n_recvd[i] + 1);
|
||||
printf("Exec Q%d: %s", i, n_recvd[i]);
|
||||
}
|
||||
break;
|
||||
case 'P': // Postprocessing procedure
|
||||
if(handle && !server->haserror()) {
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i]+1));
|
||||
c(cxt);
|
||||
}
|
||||
break;
|
||||
case 'M': // Load Module
|
||||
{
|
||||
auto mname = n_recvd[i] + 1;
|
||||
user_module_handle = dlopen(mname, RTLD_LAZY);
|
||||
//getlasterror
|
||||
|
||||
if (!user_module_handle)
|
||||
#ifndef _MSC_VER
|
||||
puts(dlerror());
|
||||
#else
|
||||
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, GetLastError());
|
||||
#endif
|
||||
user_module_map[mname] = user_module_handle;
|
||||
initialize_module(mname, user_module_handle, cxt);
|
||||
}
|
||||
break;
|
||||
case 'F': // Register Function in Module
|
||||
{
|
||||
auto fname = n_recvd[i] + 1;
|
||||
printf("F:: %s: %p, %p\n", fname, user_module_handle, dlsym(user_module_handle, fname));
|
||||
module_fn_map->insert_or_assign(fname, dlsym(user_module_handle, fname));
|
||||
printf("F::: %p\n", module_fn_map->find("mydiv") != module_fn_map->end() ? module_fn_map->find("mydiv")->second : nullptr);
|
||||
}
|
||||
break;
|
||||
case 'U': // Unload Module
|
||||
{
|
||||
auto mname = n_recvd[i] + 1;
|
||||
auto it = user_module_map.find(mname);
|
||||
if (user_module_handle == it->second)
|
||||
user_module_handle = 0;
|
||||
dlclose(it->second);
|
||||
user_module_map.erase(it);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(handle) {
|
||||
dlclose(handle);
|
||||
handle = 0;
|
||||
}
|
||||
cxt->end_session();
|
||||
n_recv = 0;
|
||||
}
|
||||
if(server->last_error == nullptr){
|
||||
// TODO: Add feedback to prompt.
|
||||
}
|
||||
else{
|
||||
server->last_error = nullptr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// puts(cfg->has_dll ? "true" : "false");
|
||||
if (cfg->backend_type == BACKEND_AQuery) {
|
||||
handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||
c(cxt);
|
||||
}
|
||||
if (handle) dlclose(handle);
|
||||
cfg->new_query = 0;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int launcher(int argc, char** argv){
|
||||
#ifdef _WIN32
|
||||
constexpr char sep = '\\';
|
||||
#else
|
||||
constexpr char sep = '/';
|
||||
#endif
|
||||
std::string str = " ";
|
||||
std::string pwd = "";
|
||||
if (argc > 0)
|
||||
pwd = argv[0];
|
||||
|
||||
auto pos = pwd.find_last_of(sep);
|
||||
if (pos == std::string::npos)
|
||||
pos = 0;
|
||||
pwd = pwd.substr(0, pos);
|
||||
for (int i = 1; i < argc; i++){
|
||||
str += argv[i];
|
||||
str += " ";
|
||||
}
|
||||
str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str;
|
||||
return system(str.c_str());
|
||||
}
|
||||
|
||||
extern "C" int __DLLEXPORT__ main(int argc, char** argv) {
|
||||
#ifdef __AQ_BUILD_LAUNCHER__
|
||||
return launcher(argc, argv);
|
||||
#endif
|
||||
puts("running");
|
||||
Context* cxt = new Context();
|
||||
cxt->log("%d %s\n", argc, argv[1]);
|
||||
|
||||
#ifdef THREADING
|
||||
auto tp = new ThreadPool();
|
||||
cxt->thread_pool = tp;
|
||||
#endif
|
||||
|
||||
const char* shmname;
|
||||
if (argc < 0)
|
||||
return dll_main(argc, argv, cxt);
|
||||
else if (argc <= 1)
|
||||
return test_main();
|
||||
else
|
||||
shmname = argv[1];
|
||||
SharedMemory shm = SharedMemory(shmname);
|
||||
if (!shm.pData)
|
||||
return 1;
|
||||
bool &running = static_cast<bool*>(shm.pData)[0],
|
||||
&ready = static_cast<bool*>(shm.pData)[1];
|
||||
using namespace std::chrono_literals;
|
||||
cxt->log("running: %s\n", running? "true":"false");
|
||||
cxt->log("ready: %s\n", ready? "true":"false");
|
||||
while (running) {
|
||||
std::this_thread::sleep_for(1ms);
|
||||
if(ready){
|
||||
cxt->log("running: %s\n", running? "true":"false");
|
||||
cxt->log("ready: %s\n", ready? "true":"false");
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
cxt->log("handle: %p\n", handle);
|
||||
if (handle) {
|
||||
cxt->log("inner\n");
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||
cxt->log("routine: %p\n", c);
|
||||
if (c) {
|
||||
cxt->log("inner\n");
|
||||
cxt->err("return: %d\n", c(cxt));
|
||||
}
|
||||
}
|
||||
ready = false;
|
||||
}
|
||||
}
|
||||
shm.FreeMemoryMap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "utils.h"
|
||||
#include "table_ext_monetdb.hpp"
|
||||
int test_main()
|
||||
{
|
||||
Context* cxt = new Context();
|
||||
if (cxt->alt_server == 0)
|
||||
cxt->alt_server = new Server(cxt);
|
||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||
|
||||
|
||||
//TableInfo<int, float> table("sibal");
|
||||
//int col0[] = { 1,2,3,4,5 };
|
||||
//float col1[] = { 5.f, 4.f, 3.f, 2.f, 1.f };
|
||||
//table.get_col<0>().initfrom(5, col0, "a");
|
||||
//table.get_col<1>().initfrom(5, col1, "b");
|
||||
//table.monetdb_append_table(server);
|
||||
//
|
||||
//server->exec("select * from sibal;");
|
||||
//auto aa = server->getCol(0);
|
||||
//auto bb = server->getCol(1);
|
||||
//printf("sibal: %p %p\n", aa, bb);
|
||||
|
||||
const char* qs[]= {
|
||||
"CREATE TABLE test(a INT, b INT, c INT, d INT);",
|
||||
"COPY OFFSET 2 INTO test FROM 'c:/Users/sunyi/Desktop/AQuery2/data/test2.csv' ON SERVER USING DELIMITERS ',';",
|
||||
"SELECT (a + b), a,b,c FROM test ;",
|
||||
};
|
||||
n_recv = sizeof(qs)/(sizeof (char*));
|
||||
n_recvd = const_cast<char**>(qs);
|
||||
if (n_recv > 0) {
|
||||
for (int i = 0; i < n_recv; ++i)
|
||||
{
|
||||
server->exec(n_recvd[i]);
|
||||
printf("Exec Q%d: %s\n", i, n_recvd[i]);
|
||||
}
|
||||
n_recv = 0;
|
||||
}
|
||||
|
||||
cxt->log_level = LOG_INFO;
|
||||
puts(cpp_17 ?"true":"false");
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
cxt->log("handle: %p\n", handle);
|
||||
if (handle) {
|
||||
cxt->log("inner\n");
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dll_ZF5Shg"));
|
||||
cxt->log("routine: %p\n", c);
|
||||
if (c) {
|
||||
cxt->log("inner\n");
|
||||
cxt->log("return: %d\n", c(cxt));
|
||||
}
|
||||
dlclose(handle);
|
||||
}
|
||||
//static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,79 +1,79 @@
|
||||
// TODO: Think of a way of decoupling table.h part and
|
||||
// monetdbe.h part to speed up compilation.
|
||||
|
||||
#ifndef __TABLE_EXT_MONETDB_HPP__
|
||||
#define __TABLE_EXT_MONETDB_HPP__
|
||||
|
||||
#include "table.h"
|
||||
#include "monetdb_conn.h"
|
||||
#include "monetdbe.h"
|
||||
|
||||
inline constexpr monetdbe_types AQType_2_monetdbe[] = {
|
||||
monetdbe_int32_t, monetdbe_float, monetdbe_str, monetdbe_double, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#else
|
||||
monetdbe_int64_t,
|
||||
#endif
|
||||
monetdbe_int16_t, monetdbe_date, monetdbe_time, monetdbe_int8_t,
|
||||
monetdbe_int32_t, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#else
|
||||
monetdbe_int64_t,
|
||||
#endif
|
||||
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool, monetdbe_int64_t, monetdbe_int64_t, monetdbe_int64_t
|
||||
};
|
||||
|
||||
template<class ...Ts>
|
||||
void TableInfo<Ts ...>::monetdb_append_table(void* srv, const char* alt_name) {
|
||||
if (!alt_name){
|
||||
alt_name = this->name;
|
||||
}
|
||||
|
||||
monetdbe_column** monetdbe_cols = new monetdbe_column * [sizeof...(Ts)];
|
||||
|
||||
uint32_t i = 0;
|
||||
const auto get_col = [&monetdbe_cols, &i](auto v) {
|
||||
monetdbe_cols[i++] = (monetdbe_column*)v->monetdb_get_col();
|
||||
};
|
||||
(get_col((ColRef<Ts>*)(colrefs + i)), ...);
|
||||
|
||||
std::string create_table_str = "CREATE TABLE ";
|
||||
create_table_str += alt_name;
|
||||
create_table_str += " (";
|
||||
i = 0;
|
||||
const auto get_name_type = [&i, *this]() {
|
||||
return std::string(colrefs[i++].name) + ' ';
|
||||
};
|
||||
create_table_str += ((get_name_type() + types::SQL_Type[types::Types<Ts>::getType()] + ", ") + ... + std::string(""));
|
||||
auto last_comma = create_table_str.find_last_of(',');
|
||||
if (last_comma != static_cast<decltype(last_comma)>(-1)) {
|
||||
create_table_str[last_comma] = ')';
|
||||
Server* server = (Server*)srv;
|
||||
server->exec(create_table_str.c_str());
|
||||
if (!server->last_error) {
|
||||
auto err = monetdbe_append(*((monetdbe_database*)server->server), "sys", alt_name, monetdbe_cols, sizeof...(Ts));
|
||||
if (err)
|
||||
puts(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
puts("Error! Empty table.");
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void* ColRef<Type>::monetdb_get_col() {
|
||||
auto aq_type = AQType_2_monetdbe[types::Types<Type>::getType()];
|
||||
monetdbe_column* col = (monetdbe_column*)malloc(sizeof(monetdbe_column));
|
||||
|
||||
col->type = aq_type;
|
||||
col->count = this->size;
|
||||
col->data = this->container;
|
||||
col->name = const_cast<char*>(this->name);
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
#endif
|
||||
// TODO: Think of a way of decoupling table.h part and
|
||||
// monetdbe.h part to speed up compilation.
|
||||
|
||||
#ifndef __TABLE_EXT_MONETDB_HPP__
|
||||
#define __TABLE_EXT_MONETDB_HPP__
|
||||
|
||||
#include "table.h"
|
||||
#include "monetdb_conn.h"
|
||||
#include "monetdbe.h"
|
||||
|
||||
inline constexpr monetdbe_types AQType_2_monetdbe[] = {
|
||||
monetdbe_int32_t, monetdbe_float, monetdbe_str, monetdbe_double, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#else
|
||||
monetdbe_int64_t,
|
||||
#endif
|
||||
monetdbe_int16_t, monetdbe_date, monetdbe_time, monetdbe_int8_t,
|
||||
monetdbe_int32_t, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#else
|
||||
monetdbe_int64_t,
|
||||
#endif
|
||||
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool, monetdbe_int64_t, monetdbe_int64_t, monetdbe_int64_t
|
||||
};
|
||||
|
||||
template<class ...Ts>
|
||||
void TableInfo<Ts ...>::monetdb_append_table(void* srv, const char* alt_name) {
|
||||
if (!alt_name){
|
||||
alt_name = this->name;
|
||||
}
|
||||
|
||||
monetdbe_column** monetdbe_cols = new monetdbe_column * [sizeof...(Ts)];
|
||||
|
||||
uint32_t i = 0;
|
||||
const auto get_col = [&monetdbe_cols, &i](auto v) {
|
||||
monetdbe_cols[i++] = (monetdbe_column*)v->monetdb_get_col();
|
||||
};
|
||||
(get_col((ColRef<Ts>*)(colrefs + i)), ...);
|
||||
|
||||
std::string create_table_str = "CREATE TABLE ";
|
||||
create_table_str += alt_name;
|
||||
create_table_str += " (";
|
||||
i = 0;
|
||||
const auto get_name_type = [&i, *this]() {
|
||||
return std::string(colrefs[i++].name) + ' ';
|
||||
};
|
||||
create_table_str += ((get_name_type() + types::SQL_Type[types::Types<Ts>::getType()] + ", ") + ... + std::string(""));
|
||||
auto last_comma = create_table_str.find_last_of(',');
|
||||
if (last_comma != static_cast<decltype(last_comma)>(-1)) {
|
||||
create_table_str[last_comma] = ')';
|
||||
Server* server = (Server*)srv;
|
||||
server->exec(create_table_str.c_str());
|
||||
if (!server->last_error) {
|
||||
auto err = monetdbe_append(*((monetdbe_database*)server->server), "sys", alt_name, monetdbe_cols, sizeof...(Ts));
|
||||
if (err)
|
||||
puts(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
puts("Error! Empty table.");
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void* ColRef<Type>::monetdb_get_col() {
|
||||
auto aq_type = AQType_2_monetdbe[types::Types<Type>::getType()];
|
||||
monetdbe_column* col = (monetdbe_column*)malloc(sizeof(monetdbe_column));
|
||||
|
||||
col->type = aq_type;
|
||||
col->count = this->size;
|
||||
col->data = this->container;
|
||||
col->name = const_cast<char*>(this->name);
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,237 +1,237 @@
|
||||
#ifndef _TYPES_H
|
||||
#define _TYPES_H
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __restrict__ __restrict
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
constexpr static inline bool is_vector(const T&) {
|
||||
return false;
|
||||
}
|
||||
template <class T>
|
||||
struct is_vector_impl : std::false_type {};
|
||||
template <class T>
|
||||
constexpr static bool is_vector_type = is_vector_impl<T>::value;
|
||||
|
||||
namespace types {
|
||||
enum Type_t {
|
||||
AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT128, AINT16, ADATE, ATIME, AINT8,
|
||||
AUINT32, AUINT64, AUINT128, AUINT16, AUINT8, ABOOL, VECTOR, NONE, ERROR
|
||||
};
|
||||
static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%Lf", "%ld", "%d", "%hi", "%s", "%s", "%c",
|
||||
"%u", "%lu", "%s", "%hu", "%hhu", "%s", "%s", "Vector<%s>", "NULL", "ERROR" };
|
||||
static constexpr const char* SQL_Type[] = { "INT", "REAL", "TEXT", "DOUBLE", "DOUBLE", "BIGINT", "HUGEINT", "SMALLINT", "DATE", "TIME", "TINYINT",
|
||||
"INT", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "BIGINT", "BOOL", "BIGINT", "NULL", "ERROR"};
|
||||
|
||||
|
||||
// TODO: deal with data/time <=> str/uint conversion
|
||||
struct date_t {
|
||||
uint32_t val = 0;
|
||||
date_t(const char* d) {
|
||||
}
|
||||
std::string toString() const;
|
||||
};
|
||||
struct time_t {
|
||||
uint32_t val = 0;
|
||||
time_t(const char* d) {
|
||||
}
|
||||
std::string toString() const;
|
||||
};
|
||||
template <typename T>
|
||||
struct Types {
|
||||
typedef T type;
|
||||
constexpr Types() noexcept = default;
|
||||
#ifdef __SIZEOF_INT128__
|
||||
#define F_INT128(__F_) __F_(__int128_t, AINT128) \
|
||||
__F_(__uint128_t, AUINT128)
|
||||
#define ULL_Type __uint128_t
|
||||
#define LL_Type __int128_t
|
||||
#else
|
||||
#define F_INT128(__F_)
|
||||
#define ULL_Type unsigned long long
|
||||
#define LL_Type long long
|
||||
#endif
|
||||
|
||||
#define ConnectTypes(f) \
|
||||
f(int, AINT32) \
|
||||
f(float, AFLOAT) \
|
||||
f(const char*, ASTR) \
|
||||
f(double, ADOUBLE) \
|
||||
f(long double, ALDOUBLE) \
|
||||
f(long, AINT64) \
|
||||
f(short, AINT16) \
|
||||
f(date_t, ADATE) \
|
||||
f(time_t, ATIME) \
|
||||
f(unsigned char, AINT8) \
|
||||
f(unsigned int, AUINT32) \
|
||||
f(unsigned long, AUINT64) \
|
||||
f(unsigned short, AUINT16) \
|
||||
f(unsigned char, AUINT8) \
|
||||
f(bool, ABOOL) \
|
||||
F_INT128(f)
|
||||
|
||||
inline constexpr static Type_t getType() {
|
||||
#define TypeConnect(x, y) if constexpr(std::is_same<x, T>::value) return y; else
|
||||
ConnectTypes(TypeConnect)
|
||||
if constexpr (is_vector_type<T>)
|
||||
return VECTOR;
|
||||
else
|
||||
return NONE;
|
||||
}
|
||||
};
|
||||
#define ATypeSize(t, at) sizeof(t),
|
||||
static constexpr size_t AType_sizes[] = { ConnectTypes(ATypeSize) 1 };
|
||||
#define Cond(c, x, y) typename std::conditional<c, x, y>::type
|
||||
#define Comp(o) (sizeof(T1) o sizeof(T2))
|
||||
#define Same(x, y) (std::is_same_v<x, y>)
|
||||
#define __U(x) std::is_unsigned<x>::value
|
||||
#define Fp(x) std::is_floating_point<x>::value
|
||||
template <class T1, class T2>
|
||||
struct Coercion {
|
||||
using t1 = Cond(Comp(<= ), Cond(Comp(== ), Cond(Fp(T1), T1, Cond(Fp(T2), T2, Cond(__U(T1), T2, T1))), T2), T1);
|
||||
using t2 = Cond(Same(T1, T2), T1, Cond(Same(T1, const char*) || Same(T2, const char*), const char*, void));
|
||||
using type = Cond(Same(t2, void), Cond(Same(T1, date_t) && Same(T2, time_t) || Same(T1, time_t) && Same(T2, time_t), void, t1), t2);
|
||||
};
|
||||
#define __Eq(x) (sizeof(T) == sizeof(x))
|
||||
template<class T>
|
||||
struct GetFPTypeImpl {
|
||||
using type = Cond(__Eq(float), float, Cond(__Eq(double), double, double));
|
||||
};
|
||||
template<class T>
|
||||
using GetFPType = typename GetFPTypeImpl<typename std::decay<T>::type>::type;
|
||||
template<class T>
|
||||
struct GetLongTypeImpl {
|
||||
using type = Cond(__U(T), ULL_Type, Cond(Fp(T), double, LL_Type));
|
||||
};
|
||||
template<class T>
|
||||
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
|
||||
}
|
||||
|
||||
#define getT(i, t) std::tuple_element_t<i, std::tuple<t...>>
|
||||
template <template<typename ...> class T, typename ...Types>
|
||||
struct applyTemplates {
|
||||
using type = T<Types...>;
|
||||
};
|
||||
|
||||
template <class lT, template <typename ...> class rT>
|
||||
struct transTypes_s;
|
||||
template <template<typename ...> class lT, typename ...T, template<typename ...> class rT>
|
||||
struct transTypes_s<lT<T...>, rT> {
|
||||
using type = rT<T...>;
|
||||
};
|
||||
|
||||
// static_assert(std::is_same<transTypes<std::tuple<int, float>, std::unordered_map>, std::unordered_map<int, float>>::value);
|
||||
template <class lT, template <typename ...> class rT>
|
||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||
|
||||
template <class ...Types>
|
||||
struct record_types {};
|
||||
|
||||
template <class ...Types>
|
||||
using record = std::tuple<Types...>;
|
||||
|
||||
template <class T>
|
||||
struct decayS {
|
||||
using type = typename std::decay<T>::type;
|
||||
};
|
||||
template<template<typename ...> class T, typename ...Types>
|
||||
struct decayS <T<Types...>>{
|
||||
using type = T<typename std::decay<Types>::type ...>;
|
||||
};
|
||||
template <class T>
|
||||
using decays = typename decayS<typename std::decay<T>::type>::type;
|
||||
template <class T>
|
||||
using decay_inner = typename decayS<T>::type;
|
||||
|
||||
template <class, template <class...> class T>
|
||||
struct instance_of_impl : std::false_type {};
|
||||
template <class ...T1, template <class ...> class T2>
|
||||
struct instance_of_impl<T2<T1...>, T2> : std::true_type {};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct same_class_impl : std::false_type {};
|
||||
template <class ...T1s, class ...T2s, template <class...> class T1>
|
||||
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
||||
|
||||
template <class T1, class T2>
|
||||
bool same_class = same_class_impl<T1, T2>::value;
|
||||
template <class T1, template <class...> class T2>
|
||||
bool instance_of = instance_of_impl<T1, T2>::value;
|
||||
|
||||
template <class lT, template <typename ...> class rT>
|
||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||
|
||||
template <class lT, class vT, template <vT ...> class rT>
|
||||
struct transValues_s;
|
||||
template <class vT, template<class, vT ...> class lT, vT ...T, template<vT ...> class rT>
|
||||
struct transValues_s<lT<vT, T...>, vT, rT> {
|
||||
using type = rT<T...>;
|
||||
};
|
||||
|
||||
#include <utility>
|
||||
template <class vT, int i, template <vT ...> class rT>
|
||||
using transValues = typename transValues_s<std::make_integer_sequence<vT, i>, vT, rT>::type;
|
||||
template <int i, template <int ...> class rT>
|
||||
using applyIntegerSequence = typename transValues_s<std::make_integer_sequence<int, i>, int, rT>::type;
|
||||
template <template <class ...> class T, class ...Types>
|
||||
struct decayed_impl{ typedef T<Types...> type;};
|
||||
template <template <typename ...> class VT, class ...Types>
|
||||
using decayed_t = typename decayed_impl<VT, Types...>::type;
|
||||
|
||||
template <class First = void, class...Rest>
|
||||
struct get_first_impl {
|
||||
typedef First first;
|
||||
constexpr static size_t rest_len = sizeof...(Rest);
|
||||
typedef get_first_impl<Rest...> rest;
|
||||
};
|
||||
template <class ...T>
|
||||
using get_first = typename get_first_impl<T...>::first;
|
||||
template <class T>
|
||||
struct value_type_impl { typedef T type; };
|
||||
template <template <class...> class VT, class ...V>
|
||||
struct value_type_impl<VT<V...>> { typedef get_first<V...> type; };
|
||||
template <class T>
|
||||
using value_type = typename value_type_impl<T>::type;
|
||||
template <class ...T>
|
||||
using get_first = typename get_first_impl<T...>::first;
|
||||
template <class T>
|
||||
struct value_type_rec_impl { typedef T type; };
|
||||
template <template <class...> class VT, class ...V>
|
||||
struct value_type_rec_impl<VT<V...>> { typedef typename value_type_rec_impl<get_first<int>>::type type; };
|
||||
template <class T>
|
||||
using value_type_r = typename value_type_rec_impl<T>::type;
|
||||
|
||||
template <class T>
|
||||
struct nullval_impl { constexpr static T value = 0; };
|
||||
template <class T>
|
||||
constexpr static T nullval = nullval_impl<T>::value;
|
||||
#include <limits>
|
||||
template <>
|
||||
struct nullval_impl<int> { constexpr static int value = std::numeric_limits<int>::min(); };
|
||||
template<>
|
||||
struct nullval_impl<float> { constexpr static float value = -std::numeric_limits<float>::quiet_NaN(); };
|
||||
template<>
|
||||
struct nullval_impl<double> { constexpr static double value = -std::numeric_limits<double>::quiet_NaN(); };
|
||||
|
||||
constexpr size_t sum_type(size_t a[], size_t sz) {
|
||||
size_t ret = 0;
|
||||
for (int i = 0; i < sz; ++i)
|
||||
ret += a[i];
|
||||
return ret;
|
||||
}
|
||||
template<class Types, class ...T1>
|
||||
constexpr size_t sum_type() {
|
||||
size_t t[] = {std::is_same_v<Types, T1> ...};
|
||||
return sum_type(t, sizeof...(T1));
|
||||
}
|
||||
template<class ...T1, class ...Types>
|
||||
constexpr size_t count_type(std::tuple<Types...>* ts) {
|
||||
size_t t[] = {sum_type<Types, T1...>() ...};
|
||||
return sum_type(t, sizeof...(Types));
|
||||
}
|
||||
#endif // !_TYPES_H
|
||||
#ifndef _TYPES_H
|
||||
#define _TYPES_H
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __restrict__ __restrict
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
constexpr static inline bool is_vector(const T&) {
|
||||
return false;
|
||||
}
|
||||
template <class T>
|
||||
struct is_vector_impl : std::false_type {};
|
||||
template <class T>
|
||||
constexpr static bool is_vector_type = is_vector_impl<T>::value;
|
||||
|
||||
namespace types {
|
||||
enum Type_t {
|
||||
AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT128, AINT16, ADATE, ATIME, AINT8,
|
||||
AUINT32, AUINT64, AUINT128, AUINT16, AUINT8, ABOOL, VECTOR, NONE, ERROR
|
||||
};
|
||||
static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%Lf", "%ld", "%d", "%hi", "%s", "%s", "%c",
|
||||
"%u", "%lu", "%s", "%hu", "%hhu", "%s", "%s", "Vector<%s>", "NULL", "ERROR" };
|
||||
static constexpr const char* SQL_Type[] = { "INT", "REAL", "TEXT", "DOUBLE", "DOUBLE", "BIGINT", "HUGEINT", "SMALLINT", "DATE", "TIME", "TINYINT",
|
||||
"INT", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "BIGINT", "BOOL", "BIGINT", "NULL", "ERROR"};
|
||||
|
||||
|
||||
// TODO: deal with data/time <=> str/uint conversion
|
||||
struct date_t {
|
||||
uint32_t val = 0;
|
||||
date_t(const char* d) {
|
||||
}
|
||||
std::string toString() const;
|
||||
};
|
||||
struct time_t {
|
||||
uint32_t val = 0;
|
||||
time_t(const char* d) {
|
||||
}
|
||||
std::string toString() const;
|
||||
};
|
||||
template <typename T>
|
||||
struct Types {
|
||||
typedef T type;
|
||||
constexpr Types() noexcept = default;
|
||||
#ifdef __SIZEOF_INT128__
|
||||
#define F_INT128(__F_) __F_(__int128_t, AINT128) \
|
||||
__F_(__uint128_t, AUINT128)
|
||||
#define ULL_Type __uint128_t
|
||||
#define LL_Type __int128_t
|
||||
#else
|
||||
#define F_INT128(__F_)
|
||||
#define ULL_Type unsigned long long
|
||||
#define LL_Type long long
|
||||
#endif
|
||||
|
||||
#define ConnectTypes(f) \
|
||||
f(int, AINT32) \
|
||||
f(float, AFLOAT) \
|
||||
f(const char*, ASTR) \
|
||||
f(double, ADOUBLE) \
|
||||
f(long double, ALDOUBLE) \
|
||||
f(long, AINT64) \
|
||||
f(short, AINT16) \
|
||||
f(date_t, ADATE) \
|
||||
f(time_t, ATIME) \
|
||||
f(unsigned char, AINT8) \
|
||||
f(unsigned int, AUINT32) \
|
||||
f(unsigned long, AUINT64) \
|
||||
f(unsigned short, AUINT16) \
|
||||
f(unsigned char, AUINT8) \
|
||||
f(bool, ABOOL) \
|
||||
F_INT128(f)
|
||||
|
||||
inline constexpr static Type_t getType() {
|
||||
#define TypeConnect(x, y) if constexpr(std::is_same<x, T>::value) return y; else
|
||||
ConnectTypes(TypeConnect)
|
||||
if constexpr (is_vector_type<T>)
|
||||
return VECTOR;
|
||||
else
|
||||
return NONE;
|
||||
}
|
||||
};
|
||||
#define ATypeSize(t, at) sizeof(t),
|
||||
static constexpr size_t AType_sizes[] = { ConnectTypes(ATypeSize) 1 };
|
||||
#define Cond(c, x, y) typename std::conditional<c, x, y>::type
|
||||
#define Comp(o) (sizeof(T1) o sizeof(T2))
|
||||
#define Same(x, y) (std::is_same_v<x, y>)
|
||||
#define __U(x) std::is_unsigned<x>::value
|
||||
#define Fp(x) std::is_floating_point<x>::value
|
||||
template <class T1, class T2>
|
||||
struct Coercion {
|
||||
using t1 = Cond(Comp(<= ), Cond(Comp(== ), Cond(Fp(T1), T1, Cond(Fp(T2), T2, Cond(__U(T1), T2, T1))), T2), T1);
|
||||
using t2 = Cond(Same(T1, T2), T1, Cond(Same(T1, const char*) || Same(T2, const char*), const char*, void));
|
||||
using type = Cond(Same(t2, void), Cond(Same(T1, date_t) && Same(T2, time_t) || Same(T1, time_t) && Same(T2, time_t), void, t1), t2);
|
||||
};
|
||||
#define __Eq(x) (sizeof(T) == sizeof(x))
|
||||
template<class T>
|
||||
struct GetFPTypeImpl {
|
||||
using type = Cond(__Eq(float), float, Cond(__Eq(double), double, double));
|
||||
};
|
||||
template<class T>
|
||||
using GetFPType = typename GetFPTypeImpl<typename std::decay<T>::type>::type;
|
||||
template<class T>
|
||||
struct GetLongTypeImpl {
|
||||
using type = Cond(__U(T), ULL_Type, Cond(Fp(T), double, LL_Type));
|
||||
};
|
||||
template<class T>
|
||||
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
|
||||
}
|
||||
|
||||
#define getT(i, t) std::tuple_element_t<i, std::tuple<t...>>
|
||||
template <template<typename ...> class T, typename ...Types>
|
||||
struct applyTemplates {
|
||||
using type = T<Types...>;
|
||||
};
|
||||
|
||||
template <class lT, template <typename ...> class rT>
|
||||
struct transTypes_s;
|
||||
template <template<typename ...> class lT, typename ...T, template<typename ...> class rT>
|
||||
struct transTypes_s<lT<T...>, rT> {
|
||||
using type = rT<T...>;
|
||||
};
|
||||
|
||||
// static_assert(std::is_same<transTypes<std::tuple<int, float>, std::unordered_map>, std::unordered_map<int, float>>::value);
|
||||
template <class lT, template <typename ...> class rT>
|
||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||
|
||||
template <class ...Types>
|
||||
struct record_types {};
|
||||
|
||||
template <class ...Types>
|
||||
using record = std::tuple<Types...>;
|
||||
|
||||
template <class T>
|
||||
struct decayS {
|
||||
using type = typename std::decay<T>::type;
|
||||
};
|
||||
template<template<typename ...> class T, typename ...Types>
|
||||
struct decayS <T<Types...>>{
|
||||
using type = T<typename std::decay<Types>::type ...>;
|
||||
};
|
||||
template <class T>
|
||||
using decays = typename decayS<typename std::decay<T>::type>::type;
|
||||
template <class T>
|
||||
using decay_inner = typename decayS<T>::type;
|
||||
|
||||
template <class, template <class...> class T>
|
||||
struct instance_of_impl : std::false_type {};
|
||||
template <class ...T1, template <class ...> class T2>
|
||||
struct instance_of_impl<T2<T1...>, T2> : std::true_type {};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct same_class_impl : std::false_type {};
|
||||
template <class ...T1s, class ...T2s, template <class...> class T1>
|
||||
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
||||
|
||||
template <class T1, class T2>
|
||||
bool same_class = same_class_impl<T1, T2>::value;
|
||||
template <class T1, template <class...> class T2>
|
||||
bool instance_of = instance_of_impl<T1, T2>::value;
|
||||
|
||||
template <class lT, template <typename ...> class rT>
|
||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||
|
||||
template <class lT, class vT, template <vT ...> class rT>
|
||||
struct transValues_s;
|
||||
template <class vT, template<class, vT ...> class lT, vT ...T, template<vT ...> class rT>
|
||||
struct transValues_s<lT<vT, T...>, vT, rT> {
|
||||
using type = rT<T...>;
|
||||
};
|
||||
|
||||
#include <utility>
|
||||
template <class vT, int i, template <vT ...> class rT>
|
||||
using transValues = typename transValues_s<std::make_integer_sequence<vT, i>, vT, rT>::type;
|
||||
template <int i, template <int ...> class rT>
|
||||
using applyIntegerSequence = typename transValues_s<std::make_integer_sequence<int, i>, int, rT>::type;
|
||||
template <template <class ...> class T, class ...Types>
|
||||
struct decayed_impl{ typedef T<Types...> type;};
|
||||
template <template <typename ...> class VT, class ...Types>
|
||||
using decayed_t = typename decayed_impl<VT, Types...>::type;
|
||||
|
||||
template <class First = void, class...Rest>
|
||||
struct get_first_impl {
|
||||
typedef First first;
|
||||
constexpr static size_t rest_len = sizeof...(Rest);
|
||||
typedef get_first_impl<Rest...> rest;
|
||||
};
|
||||
template <class ...T>
|
||||
using get_first = typename get_first_impl<T...>::first;
|
||||
template <class T>
|
||||
struct value_type_impl { typedef T type; };
|
||||
template <template <class...> class VT, class ...V>
|
||||
struct value_type_impl<VT<V...>> { typedef get_first<V...> type; };
|
||||
template <class T>
|
||||
using value_type = typename value_type_impl<T>::type;
|
||||
template <class ...T>
|
||||
using get_first = typename get_first_impl<T...>::first;
|
||||
template <class T>
|
||||
struct value_type_rec_impl { typedef T type; };
|
||||
template <template <class...> class VT, class ...V>
|
||||
struct value_type_rec_impl<VT<V...>> { typedef typename value_type_rec_impl<get_first<int>>::type type; };
|
||||
template <class T>
|
||||
using value_type_r = typename value_type_rec_impl<T>::type;
|
||||
|
||||
template <class T>
|
||||
struct nullval_impl { constexpr static T value = 0; };
|
||||
template <class T>
|
||||
constexpr static T nullval = nullval_impl<T>::value;
|
||||
#include <limits>
|
||||
template <>
|
||||
struct nullval_impl<int> { constexpr static int value = std::numeric_limits<int>::min(); };
|
||||
template<>
|
||||
struct nullval_impl<float> { constexpr static float value = -std::numeric_limits<float>::quiet_NaN(); };
|
||||
template<>
|
||||
struct nullval_impl<double> { constexpr static double value = -std::numeric_limits<double>::quiet_NaN(); };
|
||||
|
||||
constexpr size_t sum_type(size_t a[], size_t sz) {
|
||||
size_t ret = 0;
|
||||
for (int i = 0; i < sz; ++i)
|
||||
ret += a[i];
|
||||
return ret;
|
||||
}
|
||||
template<class Types, class ...T1>
|
||||
constexpr size_t sum_type() {
|
||||
size_t t[] = {std::is_same_v<Types, T1> ...};
|
||||
return sum_type(t, sizeof...(T1));
|
||||
}
|
||||
template<class ...T1, class ...Types>
|
||||
constexpr size_t count_type(std::tuple<Types...>* ts) {
|
||||
size_t t[] = {sum_type<Types, T1...>() ...};
|
||||
return sum_type(t, sizeof...(Types));
|
||||
}
|
||||
#endif // !_TYPES_H
|
||||
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
constexpr static bool cpp_17 = true;
|
||||
#else
|
||||
constexpr static bool cpp_17 = false;
|
||||
#endif
|
||||
template <class T>
|
||||
inline const char* str(const T& v) {
|
||||
return "";
|
||||
}
|
||||
template <>
|
||||
inline const char* str(const bool& v) {
|
||||
return v ? "true" : "false";
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
constexpr static bool cpp_17 = true;
|
||||
#else
|
||||
constexpr static bool cpp_17 = false;
|
||||
#endif
|
||||
template <class T>
|
||||
inline const char* str(const T& v) {
|
||||
return "";
|
||||
}
|
||||
template <>
|
||||
inline const char* str(const bool& v) {
|
||||
return v ? "true" : "false";
|
||||
}
|
@ -1,325 +1,325 @@
|
||||
/*
|
||||
* Bill Sun 2022
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VECTOR_TYPE
|
||||
#define _VECTOR_TYPE
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
|
||||
#include <initializer_list>
|
||||
#include "types.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
template <typename _Ty>
|
||||
class vector_type {
|
||||
public:
|
||||
typedef vector_type<_Ty> Decayed_t;
|
||||
void inline _copy(const vector_type<_Ty>& vt) {
|
||||
// quick init while using malloc
|
||||
//if (capacity > 0) free(container);
|
||||
|
||||
this->size = vt.size;
|
||||
this->capacity = vt.capacity;
|
||||
if (capacity) {
|
||||
// puts("copy");
|
||||
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||
memcpy(container, vt.container, sizeof(_Ty) * size);
|
||||
}
|
||||
else {
|
||||
this->container = vt.container;
|
||||
}
|
||||
}
|
||||
void inline _move(vector_type<_Ty>&& vt) {
|
||||
if (capacity > 0) free(container);
|
||||
|
||||
this->size = vt.size;
|
||||
this->capacity = vt.capacity;
|
||||
this->container = vt.container;
|
||||
// puts("move");
|
||||
vt.size = vt.capacity = 0;
|
||||
vt.container = 0;
|
||||
}
|
||||
public:
|
||||
_Ty* container;
|
||||
uint32_t size, capacity;
|
||||
typedef _Ty* iterator_t;
|
||||
typedef _Ty value_t;
|
||||
vector_type(const uint32_t& size) : size(size), capacity(size) {
|
||||
container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||
}
|
||||
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||
size = capacity = _l.size();
|
||||
_Ty* _container = this->container = (_Ty*)malloc(sizeof(_Ty) * _l.size());
|
||||
for (const auto& l : _l) {
|
||||
*(_container++) = l;
|
||||
}
|
||||
}
|
||||
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
||||
constexpr vector_type(_Ty* container, uint32_t len) noexcept : size(len), capacity(0), container(container) {};
|
||||
constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
||||
_copy(vt);
|
||||
}
|
||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
||||
_move(std::move(vt));
|
||||
}
|
||||
// size >= capacity ==> readonly vector
|
||||
constexpr vector_type(const uint32_t size, void* data) :
|
||||
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
||||
|
||||
vector_type<_Ty>& operator =(const _Ty& vt) {
|
||||
if (!container) {
|
||||
container = (_Ty*)malloc(sizeof(_Ty));
|
||||
capacity = 1;
|
||||
}
|
||||
size = 1;
|
||||
container[0] = vt;
|
||||
return *this;
|
||||
}
|
||||
// template<template <typename ...> class VT, class T>
|
||||
// vector_type<_Ty>& operator =(VT<T>&& vt) {
|
||||
// this->container = (_Ty*)vt.container;
|
||||
// this->size = vt.size;
|
||||
// this->capacity = vt.capacity;
|
||||
// vt.capacity = 0; // rvalue's
|
||||
// return *this;
|
||||
// }
|
||||
vector_type<_Ty>& operator =(const vector_type<_Ty>& vt) {
|
||||
_copy(vt);
|
||||
return *this;
|
||||
}
|
||||
vector_type<_Ty>& operator =(vector_type<_Ty>&& vt) {
|
||||
_move(std::move(vt));
|
||||
return *this;
|
||||
}
|
||||
template <template <class> class VT>
|
||||
vector_type<_Ty>& operator =(const VT<_Ty>& vt) {
|
||||
if (capacity > 0) free(container);
|
||||
container = static_cast<_Ty*>(malloc(vt.size * sizeof(_Ty)));
|
||||
|
||||
size = vt.size;
|
||||
capacity = size;
|
||||
for(uint32_t i = 0; i < size; ++i)
|
||||
container[i] = vt[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
inline void grow() {
|
||||
if (size >= capacity) { // geometric growth
|
||||
uint32_t new_capacity = size + 1 + (size >> 1);
|
||||
_Ty* n_container = (_Ty*)malloc(new_capacity * sizeof(_Ty));
|
||||
memcpy(n_container, container, sizeof(_Ty) * size);
|
||||
memset(n_container + size, 0, sizeof(_Ty) * (new_capacity - size));
|
||||
if (capacity)
|
||||
free(container);
|
||||
container = n_container;
|
||||
capacity = new_capacity;
|
||||
}
|
||||
}
|
||||
void emplace_back(const _Ty& _val) {
|
||||
grow();
|
||||
container[size++] = _val;
|
||||
}
|
||||
void emplace_back(_Ty&& _val) {
|
||||
grow();
|
||||
container[size++] = std::move(_val);
|
||||
}
|
||||
iterator_t erase(iterator_t _it) {
|
||||
#ifdef DEBUG
|
||||
// Do bound checks
|
||||
if (!(size && capicity && container &&
|
||||
_it >= container && (_it - container) < size))
|
||||
return 0;
|
||||
#endif
|
||||
iterator_t curr = _it + 1, end = _it + --size;
|
||||
while (curr < end)
|
||||
*(curr - 1) = *(curr++);
|
||||
return _it;
|
||||
}
|
||||
|
||||
iterator_t begin() const {
|
||||
return container;
|
||||
}
|
||||
iterator_t end() const {
|
||||
return container + size;
|
||||
}
|
||||
|
||||
iterator_t find(const _Ty item) const {
|
||||
iterator_t curr = begin(), _end = end();
|
||||
while (curr != _end && *(curr++) != item);
|
||||
return curr;
|
||||
}
|
||||
|
||||
inline _Ty& operator[](const uint32_t _i) const {
|
||||
return container[_i];
|
||||
}
|
||||
|
||||
void shrink_to_fit() {
|
||||
if (size && capacity != size) {
|
||||
capacity = size;
|
||||
_Ty* _container = (_Ty*)malloc(sizeof(_Ty) * size);
|
||||
memcpy(_container, container, sizeof(_Ty) * size);
|
||||
free(container);
|
||||
container = _container;
|
||||
}
|
||||
}
|
||||
|
||||
_Ty& back() {
|
||||
return container[size - 1];
|
||||
}
|
||||
void qpop() {
|
||||
size = size ? size - 1 : size;
|
||||
}
|
||||
void pop_resize() {
|
||||
if (size) {
|
||||
--size;
|
||||
if (capacity > (size << 1))
|
||||
{
|
||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * size);
|
||||
memcpy(new_container, container, sizeof(_Ty) * size);
|
||||
free(container);
|
||||
container = new_container;
|
||||
capacity = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
_Ty pop() {
|
||||
return container[--size];
|
||||
}
|
||||
void merge(vector_type<_Ty>& _other) {
|
||||
if (capacity < this->size + _other.size)
|
||||
{
|
||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (_other.size + this->size));
|
||||
capacity = this->size + _other.size;
|
||||
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
||||
memcpy(new_container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
||||
free(container);
|
||||
container = new_container;
|
||||
}
|
||||
else
|
||||
memcpy(container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
||||
size = this->size + _other.size;
|
||||
}
|
||||
template<class _Iter>
|
||||
void merge(_Iter begin, _Iter end) {
|
||||
unsigned int dist = static_cast<unsigned int>(std::distance(begin, end));
|
||||
if (capacity < this->size + dist) {
|
||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (dist + this->size));
|
||||
capacity = this->size + dist;
|
||||
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
||||
free(container);
|
||||
container = new_container;
|
||||
}
|
||||
|
||||
for (int i = 0; i < dist; ++i) {
|
||||
container[i + this->size] = *(begin + i);
|
||||
}
|
||||
size = this->size + dist;
|
||||
}
|
||||
void out(uint32_t n = 4, const char* sep = " ") const;
|
||||
vector_type<_Ty> subvec_memcpy(uint32_t start, uint32_t end) const {
|
||||
vector_type<_Ty> subvec(end - start);
|
||||
memcpy(subvec.container, container + start, sizeof(_Ty) * (end - start));
|
||||
return subvec;
|
||||
}
|
||||
inline vector_type<_Ty> subvec(uint32_t start, uint32_t end) const {
|
||||
return vector_type<_Ty>(container + start, end - start);
|
||||
}
|
||||
vector_type<_Ty> subvec_deep(uint32_t start, uint32_t end) const {
|
||||
uint32_t len = end - start;
|
||||
vector_type<_Ty> subvec(len);
|
||||
for (uint32_t i = 0; i < len; ++i)
|
||||
subvec[i] = container[i];
|
||||
return subvec;
|
||||
}
|
||||
inline vector_type<_Ty> subvec(uint32_t start = 0) { return subvec(start, size); }
|
||||
inline vector_type<_Ty> subvec_memcpy(uint32_t start = 0) { return subvec_memcpy(start, size); }
|
||||
inline vector_type<_Ty> subvec_deep(uint32_t start = 0) { return subvec_deep(start, size); }
|
||||
|
||||
~vector_type() {
|
||||
if (capacity > 0) free(container);
|
||||
container = 0; size = capacity = 0;
|
||||
}
|
||||
#define Op(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> inline x(const vector_type<T>& r) const {\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> ret(size);\
|
||||
for (int i = 0; i < size; ++i)\
|
||||
ret[i] = container[i] o r[i];\
|
||||
return ret;\
|
||||
}
|
||||
|
||||
#define Opeq(o, x) \
|
||||
template<typename T>\
|
||||
inline vector_type<typename types::Coercion<_Ty, T>::type>& x##eq(const vector_type<T>& r) {\
|
||||
for (int i = 0; i < size; ++i)\
|
||||
container[i] = container[i] o##= r[i];\
|
||||
return *this;\
|
||||
}
|
||||
|
||||
#define Ops(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> operator o (const vector_type<T>& r) const {\
|
||||
/*[[likely]] if (r.size == size) {*/\
|
||||
return x(r);\
|
||||
/*}*/\
|
||||
}
|
||||
|
||||
#define Opseq(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> operator o##= (const vector_type<T>& r) {\
|
||||
/*[[likely]] if (r.size == size) {*/\
|
||||
return x##eq(r);\
|
||||
/*}*/\
|
||||
}
|
||||
|
||||
#define _Make_Ops(M) \
|
||||
M(+, add) \
|
||||
M(-, minus) \
|
||||
M(*, multi) \
|
||||
M(/, div) \
|
||||
M(%, mod)
|
||||
|
||||
_Make_Ops(Op)
|
||||
_Make_Ops(Opeq)
|
||||
_Make_Ops(Ops)
|
||||
_Make_Ops(Opseq)
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
class vector_type<void> {
|
||||
public:
|
||||
void* container;
|
||||
uint32_t size, capacity;
|
||||
typedef void* iterator_t;
|
||||
|
||||
vector_type(uint32_t size) : size(size), capacity(size) {
|
||||
container = (void*)malloc(size);
|
||||
}
|
||||
template<typename _Ty>
|
||||
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||
size = capacity = _l.size();
|
||||
this->container = malloc(sizeof(_Ty) * _l.size());
|
||||
_Ty* _container = (_Ty*)this->container;
|
||||
for (const auto& l : _l) {
|
||||
*(_container++) = l;
|
||||
}
|
||||
}
|
||||
constexpr vector_type() : size(0), capacity(0), container(0) {};
|
||||
void* get(uint32_t i, types::Type_t atype){
|
||||
return static_cast<void*>(static_cast<char*>(container) + (i * types::AType_sizes[atype]));
|
||||
}
|
||||
void operator[](const uint32_t& i);
|
||||
vector_type<void> subvec(uint32_t, uint32_t);
|
||||
vector_type<void> subvec_memcpy(uint32_t, uint32_t);
|
||||
vector_type<void> subvec_deep(uint32_t, uint32_t);
|
||||
vector_type<void> subvec(uint32_t);
|
||||
vector_type<void> subvec_memcpy(uint32_t);
|
||||
vector_type<void> subvec_deep(uint32_t);
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
/*
|
||||
* Bill Sun 2022
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VECTOR_TYPE
|
||||
#define _VECTOR_TYPE
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
|
||||
#include <initializer_list>
|
||||
#include "types.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
template <typename _Ty>
|
||||
class vector_type {
|
||||
public:
|
||||
typedef vector_type<_Ty> Decayed_t;
|
||||
void inline _copy(const vector_type<_Ty>& vt) {
|
||||
// quick init while using malloc
|
||||
//if (capacity > 0) free(container);
|
||||
|
||||
this->size = vt.size;
|
||||
this->capacity = vt.capacity;
|
||||
if (capacity) {
|
||||
// puts("copy");
|
||||
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||
memcpy(container, vt.container, sizeof(_Ty) * size);
|
||||
}
|
||||
else {
|
||||
this->container = vt.container;
|
||||
}
|
||||
}
|
||||
void inline _move(vector_type<_Ty>&& vt) {
|
||||
if (capacity > 0) free(container);
|
||||
|
||||
this->size = vt.size;
|
||||
this->capacity = vt.capacity;
|
||||
this->container = vt.container;
|
||||
// puts("move");
|
||||
vt.size = vt.capacity = 0;
|
||||
vt.container = 0;
|
||||
}
|
||||
public:
|
||||
_Ty* container;
|
||||
uint32_t size, capacity;
|
||||
typedef _Ty* iterator_t;
|
||||
typedef _Ty value_t;
|
||||
vector_type(const uint32_t& size) : size(size), capacity(size) {
|
||||
container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||
}
|
||||
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||
size = capacity = _l.size();
|
||||
_Ty* _container = this->container = (_Ty*)malloc(sizeof(_Ty) * _l.size());
|
||||
for (const auto& l : _l) {
|
||||
*(_container++) = l;
|
||||
}
|
||||
}
|
||||
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
||||
constexpr vector_type(_Ty* container, uint32_t len) noexcept : size(len), capacity(0), container(container) {};
|
||||
constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
||||
_copy(vt);
|
||||
}
|
||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
||||
_move(std::move(vt));
|
||||
}
|
||||
// size >= capacity ==> readonly vector
|
||||
constexpr vector_type(const uint32_t size, void* data) :
|
||||
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
||||
|
||||
vector_type<_Ty>& operator =(const _Ty& vt) {
|
||||
if (!container) {
|
||||
container = (_Ty*)malloc(sizeof(_Ty));
|
||||
capacity = 1;
|
||||
}
|
||||
size = 1;
|
||||
container[0] = vt;
|
||||
return *this;
|
||||
}
|
||||
// template<template <typename ...> class VT, class T>
|
||||
// vector_type<_Ty>& operator =(VT<T>&& vt) {
|
||||
// this->container = (_Ty*)vt.container;
|
||||
// this->size = vt.size;
|
||||
// this->capacity = vt.capacity;
|
||||
// vt.capacity = 0; // rvalue's
|
||||
// return *this;
|
||||
// }
|
||||
vector_type<_Ty>& operator =(const vector_type<_Ty>& vt) {
|
||||
_copy(vt);
|
||||
return *this;
|
||||
}
|
||||
vector_type<_Ty>& operator =(vector_type<_Ty>&& vt) {
|
||||
_move(std::move(vt));
|
||||
return *this;
|
||||
}
|
||||
template <template <class> class VT>
|
||||
vector_type<_Ty>& operator =(const VT<_Ty>& vt) {
|
||||
if (capacity > 0) free(container);
|
||||
container = static_cast<_Ty*>(malloc(vt.size * sizeof(_Ty)));
|
||||
|
||||
size = vt.size;
|
||||
capacity = size;
|
||||
for(uint32_t i = 0; i < size; ++i)
|
||||
container[i] = vt[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
inline void grow() {
|
||||
if (size >= capacity) { // geometric growth
|
||||
uint32_t new_capacity = size + 1 + (size >> 1);
|
||||
_Ty* n_container = (_Ty*)malloc(new_capacity * sizeof(_Ty));
|
||||
memcpy(n_container, container, sizeof(_Ty) * size);
|
||||
memset(n_container + size, 0, sizeof(_Ty) * (new_capacity - size));
|
||||
if (capacity)
|
||||
free(container);
|
||||
container = n_container;
|
||||
capacity = new_capacity;
|
||||
}
|
||||
}
|
||||
void emplace_back(const _Ty& _val) {
|
||||
grow();
|
||||
container[size++] = _val;
|
||||
}
|
||||
void emplace_back(_Ty&& _val) {
|
||||
grow();
|
||||
container[size++] = std::move(_val);
|
||||
}
|
||||
iterator_t erase(iterator_t _it) {
|
||||
#ifdef DEBUG
|
||||
// Do bound checks
|
||||
if (!(size && capicity && container &&
|
||||
_it >= container && (_it - container) < size))
|
||||
return 0;
|
||||
#endif
|
||||
iterator_t curr = _it + 1, end = _it + --size;
|
||||
while (curr < end)
|
||||
*(curr - 1) = *(curr++);
|
||||
return _it;
|
||||
}
|
||||
|
||||
iterator_t begin() const {
|
||||
return container;
|
||||
}
|
||||
iterator_t end() const {
|
||||
return container + size;
|
||||
}
|
||||
|
||||
iterator_t find(const _Ty item) const {
|
||||
iterator_t curr = begin(), _end = end();
|
||||
while (curr != _end && *(curr++) != item);
|
||||
return curr;
|
||||
}
|
||||
|
||||
inline _Ty& operator[](const uint32_t _i) const {
|
||||
return container[_i];
|
||||
}
|
||||
|
||||
void shrink_to_fit() {
|
||||
if (size && capacity != size) {
|
||||
capacity = size;
|
||||
_Ty* _container = (_Ty*)malloc(sizeof(_Ty) * size);
|
||||
memcpy(_container, container, sizeof(_Ty) * size);
|
||||
free(container);
|
||||
container = _container;
|
||||
}
|
||||
}
|
||||
|
||||
_Ty& back() {
|
||||
return container[size - 1];
|
||||
}
|
||||
void qpop() {
|
||||
size = size ? size - 1 : size;
|
||||
}
|
||||
void pop_resize() {
|
||||
if (size) {
|
||||
--size;
|
||||
if (capacity > (size << 1))
|
||||
{
|
||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * size);
|
||||
memcpy(new_container, container, sizeof(_Ty) * size);
|
||||
free(container);
|
||||
container = new_container;
|
||||
capacity = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
_Ty pop() {
|
||||
return container[--size];
|
||||
}
|
||||
void merge(vector_type<_Ty>& _other) {
|
||||
if (capacity < this->size + _other.size)
|
||||
{
|
||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (_other.size + this->size));
|
||||
capacity = this->size + _other.size;
|
||||
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
||||
memcpy(new_container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
||||
free(container);
|
||||
container = new_container;
|
||||
}
|
||||
else
|
||||
memcpy(container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
||||
size = this->size + _other.size;
|
||||
}
|
||||
template<class _Iter>
|
||||
void merge(_Iter begin, _Iter end) {
|
||||
unsigned int dist = static_cast<unsigned int>(std::distance(begin, end));
|
||||
if (capacity < this->size + dist) {
|
||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (dist + this->size));
|
||||
capacity = this->size + dist;
|
||||
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
||||
free(container);
|
||||
container = new_container;
|
||||
}
|
||||
|
||||
for (int i = 0; i < dist; ++i) {
|
||||
container[i + this->size] = *(begin + i);
|
||||
}
|
||||
size = this->size + dist;
|
||||
}
|
||||
void out(uint32_t n = 4, const char* sep = " ") const;
|
||||
vector_type<_Ty> subvec_memcpy(uint32_t start, uint32_t end) const {
|
||||
vector_type<_Ty> subvec(end - start);
|
||||
memcpy(subvec.container, container + start, sizeof(_Ty) * (end - start));
|
||||
return subvec;
|
||||
}
|
||||
inline vector_type<_Ty> subvec(uint32_t start, uint32_t end) const {
|
||||
return vector_type<_Ty>(container + start, end - start);
|
||||
}
|
||||
vector_type<_Ty> subvec_deep(uint32_t start, uint32_t end) const {
|
||||
uint32_t len = end - start;
|
||||
vector_type<_Ty> subvec(len);
|
||||
for (uint32_t i = 0; i < len; ++i)
|
||||
subvec[i] = container[i];
|
||||
return subvec;
|
||||
}
|
||||
inline vector_type<_Ty> subvec(uint32_t start = 0) { return subvec(start, size); }
|
||||
inline vector_type<_Ty> subvec_memcpy(uint32_t start = 0) { return subvec_memcpy(start, size); }
|
||||
inline vector_type<_Ty> subvec_deep(uint32_t start = 0) { return subvec_deep(start, size); }
|
||||
|
||||
~vector_type() {
|
||||
if (capacity > 0) free(container);
|
||||
container = 0; size = capacity = 0;
|
||||
}
|
||||
#define Op(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> inline x(const vector_type<T>& r) const {\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> ret(size);\
|
||||
for (int i = 0; i < size; ++i)\
|
||||
ret[i] = container[i] o r[i];\
|
||||
return ret;\
|
||||
}
|
||||
|
||||
#define Opeq(o, x) \
|
||||
template<typename T>\
|
||||
inline vector_type<typename types::Coercion<_Ty, T>::type>& x##eq(const vector_type<T>& r) {\
|
||||
for (int i = 0; i < size; ++i)\
|
||||
container[i] = container[i] o##= r[i];\
|
||||
return *this;\
|
||||
}
|
||||
|
||||
#define Ops(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> operator o (const vector_type<T>& r) const {\
|
||||
/*[[likely]] if (r.size == size) {*/\
|
||||
return x(r);\
|
||||
/*}*/\
|
||||
}
|
||||
|
||||
#define Opseq(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> operator o##= (const vector_type<T>& r) {\
|
||||
/*[[likely]] if (r.size == size) {*/\
|
||||
return x##eq(r);\
|
||||
/*}*/\
|
||||
}
|
||||
|
||||
#define _Make_Ops(M) \
|
||||
M(+, add) \
|
||||
M(-, minus) \
|
||||
M(*, multi) \
|
||||
M(/, div) \
|
||||
M(%, mod)
|
||||
|
||||
_Make_Ops(Op)
|
||||
_Make_Ops(Opeq)
|
||||
_Make_Ops(Ops)
|
||||
_Make_Ops(Opseq)
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
class vector_type<void> {
|
||||
public:
|
||||
void* container;
|
||||
uint32_t size, capacity;
|
||||
typedef void* iterator_t;
|
||||
|
||||
vector_type(uint32_t size) : size(size), capacity(size) {
|
||||
container = (void*)malloc(size);
|
||||
}
|
||||
template<typename _Ty>
|
||||
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||
size = capacity = _l.size();
|
||||
this->container = malloc(sizeof(_Ty) * _l.size());
|
||||
_Ty* _container = (_Ty*)this->container;
|
||||
for (const auto& l : _l) {
|
||||
*(_container++) = l;
|
||||
}
|
||||
}
|
||||
constexpr vector_type() : size(0), capacity(0), container(0) {};
|
||||
void* get(uint32_t i, types::Type_t atype){
|
||||
return static_cast<void*>(static_cast<char*>(container) + (i * types::AType_sizes[atype]));
|
||||
}
|
||||
void operator[](const uint32_t& i);
|
||||
vector_type<void> subvec(uint32_t, uint32_t);
|
||||
vector_type<void> subvec_memcpy(uint32_t, uint32_t);
|
||||
vector_type<void> subvec_deep(uint32_t, uint32_t);
|
||||
vector_type<void> subvec(uint32_t);
|
||||
vector_type<void> subvec_memcpy(uint32_t);
|
||||
vector_type<void> subvec_deep(uint32_t);
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
@ -1,40 +1,40 @@
|
||||
#include "pch.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winhelper.h"
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
void* dlopen(const char* lib, int)
|
||||
{
|
||||
return LoadLibraryA(lib);
|
||||
}
|
||||
|
||||
void* dlsym(void* handle, const char* proc)
|
||||
{
|
||||
return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), proc));
|
||||
}
|
||||
|
||||
int dlclose(void* handle)
|
||||
{
|
||||
return FreeLibrary(static_cast<HMODULE>(handle));
|
||||
}
|
||||
|
||||
SharedMemory::SharedMemory(const char* fname)
|
||||
{
|
||||
this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname);
|
||||
if (this->hFileMap)
|
||||
this->pData = MapViewOfFile(this->hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 2);
|
||||
else
|
||||
this->pData = NULL;
|
||||
}
|
||||
|
||||
void SharedMemory::FreeMemoryMap()
|
||||
{
|
||||
if (this->hFileMap)
|
||||
if (this->pData)
|
||||
UnmapViewOfFile(this->pData);
|
||||
if (this->hFileMap)
|
||||
CloseHandle(this->hFileMap);
|
||||
}
|
||||
#endif
|
||||
#include "pch.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winhelper.h"
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
void* dlopen(const char* lib, int)
|
||||
{
|
||||
return LoadLibraryA(lib);
|
||||
}
|
||||
|
||||
void* dlsym(void* handle, const char* proc)
|
||||
{
|
||||
return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), proc));
|
||||
}
|
||||
|
||||
int dlclose(void* handle)
|
||||
{
|
||||
return FreeLibrary(static_cast<HMODULE>(handle));
|
||||
}
|
||||
|
||||
SharedMemory::SharedMemory(const char* fname)
|
||||
{
|
||||
this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname);
|
||||
if (this->hFileMap)
|
||||
this->pData = MapViewOfFile(this->hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 2);
|
||||
else
|
||||
this->pData = NULL;
|
||||
}
|
||||
|
||||
void SharedMemory::FreeMemoryMap()
|
||||
{
|
||||
if (this->hFileMap)
|
||||
if (this->pData)
|
||||
UnmapViewOfFile(this->pData);
|
||||
if (this->hFileMap)
|
||||
CloseHandle(this->hFileMap);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,16 +1,16 @@
|
||||
#ifndef _WINHELPER_H
|
||||
#define _WINHELPER_H
|
||||
#ifdef _WIN32
|
||||
static constexpr int RTLD_LAZY = 1;
|
||||
void* dlopen(const char*, int);
|
||||
void* dlsym(void*, const char*);
|
||||
int dlclose(void*);
|
||||
struct SharedMemory
|
||||
{
|
||||
void* hFileMap;
|
||||
void* pData;
|
||||
SharedMemory(const char*);
|
||||
void FreeMemoryMap();
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _WINHELPER_H
|
||||
#define _WINHELPER_H
|
||||
#ifdef _WIN32
|
||||
static constexpr int RTLD_LAZY = 1;
|
||||
void* dlopen(const char*, int);
|
||||
void* dlsym(void*, const char*);
|
||||
int dlclose(void*);
|
||||
struct SharedMemory
|
||||
{
|
||||
void* hFileMap;
|
||||
void* pData;
|
||||
SharedMemory(const char*);
|
||||
void FreeMemoryMap();
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,25 +1,25 @@
|
||||
FUNCTION covariance (x , y ) {
|
||||
xmean := avg (x) ;
|
||||
ymean := avg (y) ;
|
||||
avg (( x - xmean ) * (y - ymean ))
|
||||
}
|
||||
|
||||
|
||||
FUNCTION sd ( x) {
|
||||
sqrt ( covariance (x , x) )
|
||||
}
|
||||
|
||||
FUNCTION pairCorr (x , y ) {
|
||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||
}
|
||||
|
||||
CREATE TABLE test1(a INT, b INT, c INT, d INT)
|
||||
|
||||
LOAD DATA INFILE "data/test.csv"
|
||||
INTO TABLE test1
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
SELECT pairCorr(c, b) * d, sum(a), b
|
||||
FROM test1
|
||||
group by c,b,d
|
||||
order by b ASC
|
||||
FUNCTION covariance (x , y ) {
|
||||
xmean := avg (x) ;
|
||||
ymean := avg (y) ;
|
||||
avg (( x - xmean ) * (y - ymean ))
|
||||
}
|
||||
|
||||
|
||||
FUNCTION sd ( x) {
|
||||
sqrt ( covariance (x , x) )
|
||||
}
|
||||
|
||||
FUNCTION pairCorr (x , y ) {
|
||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||
}
|
||||
|
||||
CREATE TABLE test1(a INT, b INT, c INT, d INT)
|
||||
|
||||
LOAD DATA INFILE "data/test.csv"
|
||||
INTO TABLE test1
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
SELECT pairCorr(c, b) * d, sum(a), b
|
||||
FROM test1
|
||||
group by c,b,d
|
||||
order by b ASC
|
||||
|
@ -1,34 +1,34 @@
|
||||
FUNCTION covariance (x , y ) {
|
||||
xmean := avg (x) ;
|
||||
ymean := avg (y) ;
|
||||
avg (( x - xmean ) * (y - ymean ))
|
||||
}
|
||||
|
||||
FUNCTION sd ( x) {
|
||||
sqrt ( covariance (x , x) )
|
||||
}
|
||||
|
||||
FUNCTION pairCorr (x , y ) {
|
||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||
}
|
||||
|
||||
-- FUNCTION covariances (w, x , y ) {
|
||||
-- xmean := avgs (w, x) ;
|
||||
-- ymean := avgs (y) ;
|
||||
-- avg (( x - xmean ) * (y - ymean ))
|
||||
-- }
|
||||
|
||||
CREATE TABLE tt(a INT, b INT, c INT, d INT)
|
||||
|
||||
LOAD DATA INFILE "data/test.csv"
|
||||
INTO TABLE tt
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
CREATE TABLE sale1(Mont INT, sales INT)
|
||||
|
||||
LOAD DATA INFILE "data/moving_avg.csv"
|
||||
INTO TABLE sale1
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
select sd(a) + sales from tt, sale1 where tt.a = sale1.Mont
|
||||
|
||||
FUNCTION covariance (x , y ) {
|
||||
xmean := avg (x) ;
|
||||
ymean := avg (y) ;
|
||||
avg (( x - xmean ) * (y - ymean ))
|
||||
}
|
||||
|
||||
FUNCTION sd ( x) {
|
||||
sqrt ( covariance (x , x) )
|
||||
}
|
||||
|
||||
FUNCTION pairCorr (x , y ) {
|
||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||
}
|
||||
|
||||
-- FUNCTION covariances (w, x , y ) {
|
||||
-- xmean := avgs (w, x) ;
|
||||
-- ymean := avgs (y) ;
|
||||
-- avg (( x - xmean ) * (y - ymean ))
|
||||
-- }
|
||||
|
||||
CREATE TABLE tt(a INT, b INT, c INT, d INT)
|
||||
|
||||
LOAD DATA INFILE "data/test.csv"
|
||||
INTO TABLE tt
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
CREATE TABLE sale1(Mont INT, sales INT)
|
||||
|
||||
LOAD DATA INFILE "data/moving_avg.csv"
|
||||
INTO TABLE sale1
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
select sd(a) + sales from tt, sale1 where tt.a = sale1.Mont
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
LOAD MODULE FROM "./test.so"
|
||||
FUNCTIONS (
|
||||
mydiv(a:int, b:int) -> double,
|
||||
mulvec(a:int, b:vecfloat) -> vecfloat
|
||||
);
|
||||
|
||||
select mydiv(2,3);
|
||||
|
||||
LOAD MODULE FROM "./test.so"
|
||||
FUNCTIONS (
|
||||
mydiv(a:int, b:int) -> double,
|
||||
mulvec(a:int, b:vecfloat) -> vecfloat
|
||||
);
|
||||
|
||||
select mydiv(2,3);
|
||||
|
||||
|
@ -1,112 +1,112 @@
|
||||
FUNCTION
|
||||
execStrategy ( alloc , mavgday , mavgmonth , px ) {
|
||||
buySignal := mavgday > mavgmonth ;
|
||||
f := a + b ;
|
||||
alloc * prd (
|
||||
CASE maxs ( buySignal )
|
||||
WHEN TRUE THEN
|
||||
CASE buySignal
|
||||
WHEN TRUE THEN 1 / px
|
||||
ELSE px
|
||||
END
|
||||
ELSE 1
|
||||
END )
|
||||
}
|
||||
FUNCTION covariance (x , y ) {
|
||||
xmean := avg (x) ;
|
||||
ymean := avg (y) ;
|
||||
avg (( x - xmean ) * (y - ymean ))
|
||||
}
|
||||
FUNCTION sd ( x) {
|
||||
sqrt ( covariance (x , x) )
|
||||
}
|
||||
FUNCTION pairCorr (x , y ) {
|
||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||
}
|
||||
<k>
|
||||
`
|
||||
p:5
|
||||
q:2
|
||||
phi:(p+1)?1.
|
||||
theta:q?1.
|
||||
"p q phi theta"
|
||||
p
|
||||
q
|
||||
phi
|
||||
theta
|
||||
l:()
|
||||
e:()
|
||||
|
||||
`
|
||||
L1:10?20
|
||||
Le1:10?2.
|
||||
L2:3?20
|
||||
Le2:3?2.
|
||||
"L1 Le1 L2 Le2"
|
||||
L1
|
||||
Le1
|
||||
L2
|
||||
Le2
|
||||
|
||||
`
|
||||
"Add L1, then predict"
|
||||
l:l,L1
|
||||
e:e,Le1
|
||||
predict:(phi(0)) + (sum ({[x](phi(x+1)) * (l(((#l)-1)-x))}[!p])) - (sum ({[x](theta(x)) * (e(((#e)-1)-x))}[!q]))
|
||||
predict
|
||||
|
||||
`
|
||||
"Add L2, then predict"
|
||||
l:l,L2
|
||||
e:e,Le2
|
||||
predict:(phi(0)) + (sum ({[x](phi(x+1)) * (l(((#l)-1)-x))}[!p])) - (sum ({[x](theta(x)) * (e(((#e)-1)-x))}[!q]))
|
||||
predict
|
||||
|
||||
</k>
|
||||
|
||||
WITH
|
||||
Target (Id , TradeDate , ClosePrice ) AS
|
||||
( SELECT
|
||||
Id , TradeDate , ClosePrice
|
||||
FROM price
|
||||
WHERE Id IN stock10 AND
|
||||
TradeDate >= startYear10 AND
|
||||
TradeDate <= startYear10 + 365 * 10),
|
||||
weekly (Id , bucket , name , low , high , mean ) AS
|
||||
( SELECT
|
||||
Id ,
|
||||
timeBucket ,
|
||||
" weekly " ,
|
||||
min ( ClosePrice ) ,
|
||||
max ( ClosePrice ) ,
|
||||
avg ( ClosePrice )
|
||||
FROM Target
|
||||
GROUP BY Id , getWeek ( TradeDate ) as
|
||||
timeBucket ),
|
||||
monthly ( Id , bucket , name , low , high , mean ) AS
|
||||
( SELECT
|
||||
Id ,
|
||||
timeBucket ,
|
||||
" monthly " ,
|
||||
min ( ClosePrice ) ,
|
||||
max ( ClosePrice ) ,
|
||||
avg ( ClosePrice )
|
||||
FROM Target
|
||||
GROUP BY Id , getMonth ( TradeDate ) as
|
||||
timeBucket ),
|
||||
yearly (Id , bucket , name , low , high , mean ) AS
|
||||
( SELECT
|
||||
Id ,
|
||||
timeBucket ,
|
||||
" yearly " ,
|
||||
min ( ClosePrice ) ,
|
||||
max ( ClosePrice ) ,
|
||||
avg ( ClosePrice )
|
||||
FROM Target
|
||||
GROUP BY Id , getYear ( TradeDate ) as
|
||||
timeBucket )
|
||||
SELECT
|
||||
Id , bucket , name , low , high , mean
|
||||
FROM
|
||||
CONCATENATE ( weekly , monthly , yearly )
|
||||
ASSUMING ASC Id , ASC name , ASC bucket
|
||||
FUNCTION
|
||||
execStrategy ( alloc , mavgday , mavgmonth , px ) {
|
||||
buySignal := mavgday > mavgmonth ;
|
||||
f := a + b ;
|
||||
alloc * prd (
|
||||
CASE maxs ( buySignal )
|
||||
WHEN TRUE THEN
|
||||
CASE buySignal
|
||||
WHEN TRUE THEN 1 / px
|
||||
ELSE px
|
||||
END
|
||||
ELSE 1
|
||||
END )
|
||||
}
|
||||
FUNCTION covariance (x , y ) {
|
||||
xmean := avg (x) ;
|
||||
ymean := avg (y) ;
|
||||
avg (( x - xmean ) * (y - ymean ))
|
||||
}
|
||||
FUNCTION sd ( x) {
|
||||
sqrt ( covariance (x , x) )
|
||||
}
|
||||
FUNCTION pairCorr (x , y ) {
|
||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||
}
|
||||
<k>
|
||||
`
|
||||
p:5
|
||||
q:2
|
||||
phi:(p+1)?1.
|
||||
theta:q?1.
|
||||
"p q phi theta"
|
||||
p
|
||||
q
|
||||
phi
|
||||
theta
|
||||
l:()
|
||||
e:()
|
||||
|
||||
`
|
||||
L1:10?20
|
||||
Le1:10?2.
|
||||
L2:3?20
|
||||
Le2:3?2.
|
||||
"L1 Le1 L2 Le2"
|
||||
L1
|
||||
Le1
|
||||
L2
|
||||
Le2
|
||||
|
||||
`
|
||||
"Add L1, then predict"
|
||||
l:l,L1
|
||||
e:e,Le1
|
||||
predict:(phi(0)) + (sum ({[x](phi(x+1)) * (l(((#l)-1)-x))}[!p])) - (sum ({[x](theta(x)) * (e(((#e)-1)-x))}[!q]))
|
||||
predict
|
||||
|
||||
`
|
||||
"Add L2, then predict"
|
||||
l:l,L2
|
||||
e:e,Le2
|
||||
predict:(phi(0)) + (sum ({[x](phi(x+1)) * (l(((#l)-1)-x))}[!p])) - (sum ({[x](theta(x)) * (e(((#e)-1)-x))}[!q]))
|
||||
predict
|
||||
|
||||
</k>
|
||||
|
||||
WITH
|
||||
Target (Id , TradeDate , ClosePrice ) AS
|
||||
( SELECT
|
||||
Id , TradeDate , ClosePrice
|
||||
FROM price
|
||||
WHERE Id IN stock10 AND
|
||||
TradeDate >= startYear10 AND
|
||||
TradeDate <= startYear10 + 365 * 10),
|
||||
weekly (Id , bucket , name , low , high , mean ) AS
|
||||
( SELECT
|
||||
Id ,
|
||||
timeBucket ,
|
||||
" weekly " ,
|
||||
min ( ClosePrice ) ,
|
||||
max ( ClosePrice ) ,
|
||||
avg ( ClosePrice )
|
||||
FROM Target
|
||||
GROUP BY Id , getWeek ( TradeDate ) as
|
||||
timeBucket ),
|
||||
monthly ( Id , bucket , name , low , high , mean ) AS
|
||||
( SELECT
|
||||
Id ,
|
||||
timeBucket ,
|
||||
" monthly " ,
|
||||
min ( ClosePrice ) ,
|
||||
max ( ClosePrice ) ,
|
||||
avg ( ClosePrice )
|
||||
FROM Target
|
||||
GROUP BY Id , getMonth ( TradeDate ) as
|
||||
timeBucket ),
|
||||
yearly (Id , bucket , name , low , high , mean ) AS
|
||||
( SELECT
|
||||
Id ,
|
||||
timeBucket ,
|
||||
" yearly " ,
|
||||
min ( ClosePrice ) ,
|
||||
max ( ClosePrice ) ,
|
||||
avg ( ClosePrice )
|
||||
FROM Target
|
||||
GROUP BY Id , getYear ( TradeDate ) as
|
||||
timeBucket )
|
||||
SELECT
|
||||
Id , bucket , name , low , high , mean
|
||||
FROM
|
||||
CONCATENATE ( weekly , monthly , yearly )
|
||||
ASSUMING ASC Id , ASC name , ASC bucket
|
||||
|
@ -1,14 +1,14 @@
|
||||
AGGREGATION FUNCTION covariances(x, y, w){
|
||||
static xmeans := 0., ymeans := 0., cnt := 0;
|
||||
if (cnt < w)
|
||||
{
|
||||
xmeans += x;
|
||||
ymeans += y;
|
||||
cnt+=1;
|
||||
}
|
||||
else {
|
||||
xmeans += (x - x.vec[cnt - w]) / w;
|
||||
ymeans += (y - y.vec[cnt - w]) / w;
|
||||
}
|
||||
avg (( x.vec(x.len-w, x.len) - xmeans ) * (y.vec(y.len - w, y.len) - ymeans ))
|
||||
}
|
||||
AGGREGATION FUNCTION covariances(x, y, w){
|
||||
static xmeans := 0., ymeans := 0., cnt := 0;
|
||||
if (cnt < w)
|
||||
{
|
||||
xmeans += x;
|
||||
ymeans += y;
|
||||
cnt+=1;
|
||||
}
|
||||
else {
|
||||
xmeans += (x - x.vec[cnt - w]) / w;
|
||||
ymeans += (y - y.vec[cnt - w]) / w;
|
||||
}
|
||||
avg (( x.vec(x.len-w, x.len) - xmeans ) * (y.vec(y.len - w, y.len) - ymeans ))
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
|
||||
|
||||
AGGREGATION FUNCTION covariances2(x, y, win){
|
||||
xmeans := 0.;
|
||||
ymeans := 0.;
|
||||
l := _builtin_len;
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
xmeans := x[0];
|
||||
ymeans := y[0];
|
||||
_builtin_ret[0] := 0.;
|
||||
}
|
||||
w := win;
|
||||
if (w > l)
|
||||
w := l;
|
||||
for (i := 1, j:= 0; i < w; i := i+1) {
|
||||
xmeans += x[i];
|
||||
ymeans += y[i];
|
||||
_builtin_ret[i] := avg (( x(0, i) - xmeans/i ) * (y(0, i) - ymeans/i ));
|
||||
}
|
||||
xmeans /= w;
|
||||
ymeans /= w;
|
||||
for (i := w; i < l; i += 1)
|
||||
{
|
||||
xmeans += (x[i] - x[i - w]) / w;
|
||||
ymeans += (y[i] - y[i - w]) / w;
|
||||
_builtin_ret[i] := avg (( x(i-w, i) - xmeans ) * (y(i - w, i) - ymeans ));
|
||||
}
|
||||
Null
|
||||
}
|
||||
|
||||
CREATE TABLE test(a INT, b INT, c INT, d INT)
|
||||
|
||||
LOAD DATA INFILE "data/test2.csv"
|
||||
INTO TABLE test
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
select covariances2(a, b, 4), a+b from test group by c;
|
||||
|
||||
|
||||
|
||||
AGGREGATION FUNCTION covariances2(x, y, win){
|
||||
xmeans := 0.;
|
||||
ymeans := 0.;
|
||||
l := _builtin_len;
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
xmeans := x[0];
|
||||
ymeans := y[0];
|
||||
_builtin_ret[0] := 0.;
|
||||
}
|
||||
w := win;
|
||||
if (w > l)
|
||||
w := l;
|
||||
for (i := 1, j:= 0; i < w; i := i+1) {
|
||||
xmeans += x[i];
|
||||
ymeans += y[i];
|
||||
_builtin_ret[i] := avg (( x(0, i) - xmeans/i ) * (y(0, i) - ymeans/i ));
|
||||
}
|
||||
xmeans /= w;
|
||||
ymeans /= w;
|
||||
for (i := w; i < l; i += 1)
|
||||
{
|
||||
xmeans += (x[i] - x[i - w]) / w;
|
||||
ymeans += (y[i] - y[i - w]) / w;
|
||||
_builtin_ret[i] := avg (( x(i-w, i) - xmeans ) * (y(i - w, i) - ymeans ));
|
||||
}
|
||||
Null
|
||||
}
|
||||
|
||||
CREATE TABLE test(a INT, b INT, c INT, d INT)
|
||||
|
||||
LOAD DATA INFILE "data/test2.csv"
|
||||
INTO TABLE test
|
||||
FIELDS TERMINATED BY ","
|
||||
|
||||
select covariances2(a, b, 4), a+b from test group by c;
|
||||
|
||||
|
Loading…
Reference in new issue