Merge branch 'master' of https://github.com/sunyinqi0508/AQuery2
commit
83ad6d2330
@ -1,72 +1,72 @@
|
|||||||
test.lib
|
test.lib
|
||||||
test.exp
|
test.exp
|
||||||
*.pdb
|
*.pdb
|
||||||
dll.lib
|
dll.lib
|
||||||
dll.exp
|
dll.exp
|
||||||
libaquery.a
|
libaquery.a
|
||||||
libaquery.lib
|
libaquery.lib
|
||||||
server.lib
|
server.lib
|
||||||
server.exp
|
server.exp
|
||||||
*.idb
|
*.idb
|
||||||
aq
|
aq
|
||||||
aq.exe
|
aq.exe
|
||||||
.cached
|
.cached
|
||||||
*.json
|
*.json
|
||||||
!sample_ast.json
|
!sample_ast.json
|
||||||
*.o
|
*.o
|
||||||
*.pch
|
*.pch
|
||||||
*.gch
|
*.gch
|
||||||
a.out.*
|
a.out.*
|
||||||
*.log
|
*.log
|
||||||
*.pyc
|
*.pyc
|
||||||
*.tab
|
*.tab
|
||||||
out
|
out
|
||||||
.idea
|
.idea
|
||||||
.svn
|
.svn
|
||||||
*.iml
|
*.iml
|
||||||
/mo_sql_parsing.egg-info
|
/mo_sql_parsing.egg-info
|
||||||
/build
|
/build
|
||||||
/dist
|
/dist
|
||||||
/mo-sql-parsing
|
/mo-sql-parsing
|
||||||
vendor/
|
vendor/
|
||||||
._*
|
._*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.eggs
|
.eggs
|
||||||
.vscode
|
.vscode
|
||||||
out.k
|
out.k
|
||||||
k
|
k
|
||||||
*.so
|
*.so
|
||||||
*.pdf
|
*.pdf
|
||||||
**/*.cmake
|
**/*.cmake
|
||||||
**/Debug
|
**/Debug
|
||||||
**/Release
|
**/Release
|
||||||
test*.c*
|
test*.c*
|
||||||
*.csv
|
*.csv
|
||||||
!test.csv
|
!test.csv
|
||||||
!test2.csv
|
!test2.csv
|
||||||
!moving_avg.csv
|
!moving_avg.csv
|
||||||
!nyctx100.csv
|
!nyctx100.csv
|
||||||
*.out
|
*.out
|
||||||
*.asm
|
*.asm
|
||||||
!mmw.so
|
!mmw.so
|
||||||
*.k
|
*.k
|
||||||
!header.k
|
!header.k
|
||||||
!join.k
|
!join.k
|
||||||
**/.vs
|
**/.vs
|
||||||
**/x64
|
**/x64
|
||||||
*.user
|
*.user
|
||||||
*.filters
|
*.filters
|
||||||
*.tmp
|
*.tmp
|
||||||
*.bin
|
*.bin
|
||||||
*.shm
|
*.shm
|
||||||
server/packages/**
|
server/packages/**
|
||||||
*.ipynb
|
*.ipynb
|
||||||
*.cmake
|
*.cmake
|
||||||
*.stackdump
|
*.stackdump
|
||||||
saves
|
saves
|
||||||
*.exe
|
*.exe
|
||||||
out*.cpp
|
out*.cpp
|
||||||
udf*.hpp
|
udf*.hpp
|
||||||
*.ipynb
|
*.ipynb
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,363 +1,363 @@
|
|||||||
Mozilla Public License, version 2.0
|
Mozilla Public License, version 2.0
|
||||||
|
|
||||||
1. Definitions
|
1. Definitions
|
||||||
|
|
||||||
1.1. "Contributor"
|
1.1. "Contributor"
|
||||||
|
|
||||||
means each individual or legal entity that creates, contributes to the
|
means each individual or legal entity that creates, contributes to the
|
||||||
creation of, or owns Covered Software.
|
creation of, or owns Covered Software.
|
||||||
|
|
||||||
1.2. "Contributor Version"
|
1.2. "Contributor Version"
|
||||||
|
|
||||||
means the combination of the Contributions of others (if any) used by a
|
means the combination of the Contributions of others (if any) used by a
|
||||||
Contributor and that particular Contributor's Contribution.
|
Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
1.3. "Contribution"
|
1.3. "Contribution"
|
||||||
|
|
||||||
means Covered Software of a particular Contributor.
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
1.4. "Covered Software"
|
1.4. "Covered Software"
|
||||||
|
|
||||||
means Source Code Form to which the initial Contributor has attached the
|
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
|
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||||
Modifications of such Source Code Form, in each case including portions
|
Modifications of such Source Code Form, in each case including portions
|
||||||
thereof.
|
thereof.
|
||||||
|
|
||||||
1.5. "Incompatible With Secondary Licenses"
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
means
|
means
|
||||||
|
|
||||||
a. that the initial Contributor has attached the notice described in
|
a. that the initial Contributor has attached the notice described in
|
||||||
Exhibit B to the Covered Software; or
|
Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
b. that the Covered Software was made available under the terms of
|
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
|
version 1.1 or earlier of the License, but not also under the terms of
|
||||||
a Secondary License.
|
a Secondary License.
|
||||||
|
|
||||||
1.6. "Executable Form"
|
1.6. "Executable Form"
|
||||||
|
|
||||||
means any form of the work other than Source Code Form.
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
1.7. "Larger Work"
|
1.7. "Larger Work"
|
||||||
|
|
||||||
means a work that combines Covered Software with other material, in a
|
means a work that combines Covered Software with other material, in a
|
||||||
separate file or files, that is not Covered Software.
|
separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
1.8. "License"
|
1.8. "License"
|
||||||
|
|
||||||
means this document.
|
means this document.
|
||||||
|
|
||||||
1.9. "Licensable"
|
1.9. "Licensable"
|
||||||
|
|
||||||
means having the right to grant, to the maximum extent possible, whether
|
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
|
at the time of the initial grant or subsequently, any and all of the
|
||||||
rights conveyed by this License.
|
rights conveyed by this License.
|
||||||
|
|
||||||
1.10. "Modifications"
|
1.10. "Modifications"
|
||||||
|
|
||||||
means any of the following:
|
means any of the following:
|
||||||
|
|
||||||
a. any file in Source Code Form that results from an addition to,
|
a. any file in Source Code Form that results from an addition to,
|
||||||
deletion from, or modification of the contents of Covered Software; or
|
deletion from, or modification of the contents of Covered Software; or
|
||||||
|
|
||||||
b. any new file in Source Code Form that contains any Covered Software.
|
b. any new file in Source Code Form that contains any Covered Software.
|
||||||
|
|
||||||
1.11. "Patent Claims" of a Contributor
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
|
||||||
means any patent claim(s), including without limitation, method,
|
means any patent claim(s), including without limitation, method,
|
||||||
process, and apparatus claims, in any patent Licensable by such
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
Contributor that would be infringed, but for the grant of the License,
|
Contributor that would be infringed, but for the grant of the License,
|
||||||
by the making, using, selling, offering for sale, having made, import,
|
by the making, using, selling, offering for sale, having made, import,
|
||||||
or transfer of either its Contributions or its Contributor Version.
|
or transfer of either its Contributions or its Contributor Version.
|
||||||
|
|
||||||
1.12. "Secondary License"
|
1.12. "Secondary License"
|
||||||
|
|
||||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||||
General Public License, Version 2.1, the GNU Affero General Public
|
General Public License, Version 2.1, the GNU Affero General Public
|
||||||
License, Version 3.0, or any later versions of those licenses.
|
License, Version 3.0, or any later versions of those licenses.
|
||||||
|
|
||||||
1.13. "Source Code Form"
|
1.13. "Source Code Form"
|
||||||
|
|
||||||
means the form of the work preferred for making modifications.
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
1.14. "You" (or "Your")
|
1.14. "You" (or "Your")
|
||||||
|
|
||||||
means an individual or a legal entity exercising rights under this
|
means an individual or a legal entity exercising rights under this
|
||||||
License. For legal entities, "You" includes any entity that controls, is
|
License. For legal entities, "You" includes any entity that controls, is
|
||||||
controlled by, or is under common control with You. For purposes of this
|
controlled by, or is under common control with You. For purposes of this
|
||||||
definition, "control" means (a) the power, direct or indirect, to cause
|
definition, "control" means (a) the power, direct or indirect, to cause
|
||||||
the direction or management of such entity, whether by contract or
|
the direction or management of such entity, whether by contract or
|
||||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||||
outstanding shares or beneficial ownership of such entity.
|
outstanding shares or beneficial ownership of such entity.
|
||||||
|
|
||||||
|
|
||||||
2. License Grants and Conditions
|
2. License Grants and Conditions
|
||||||
|
|
||||||
2.1. Grants
|
2.1. Grants
|
||||||
|
|
||||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
non-exclusive license:
|
non-exclusive license:
|
||||||
|
|
||||||
a. under intellectual property rights (other than patent or trademark)
|
a. under intellectual property rights (other than patent or trademark)
|
||||||
Licensable by such Contributor to use, reproduce, make available,
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
modify, display, perform, distribute, and otherwise exploit its
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
Contributions, either on an unmodified basis, with Modifications, or
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
as part of a Larger Work; and
|
as part of a Larger Work; and
|
||||||
|
|
||||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||||
sale, have made, import, and otherwise transfer either its
|
sale, have made, import, and otherwise transfer either its
|
||||||
Contributions or its Contributor Version.
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
2.2. Effective Date
|
2.2. Effective Date
|
||||||
|
|
||||||
The licenses granted in Section 2.1 with respect to any Contribution
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
become effective for each Contribution on the date the Contributor first
|
become effective for each Contribution on the date the Contributor first
|
||||||
distributes such Contribution.
|
distributes such Contribution.
|
||||||
|
|
||||||
2.3. Limitations on Grant Scope
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
The licenses granted in this Section 2 are the only rights granted under
|
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
|
this License. No additional rights or licenses will be implied from the
|
||||||
distribution or licensing of Covered Software under this License.
|
distribution or licensing of Covered Software under this License.
|
||||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
Contributor:
|
Contributor:
|
||||||
|
|
||||||
a. for any code that a Contributor has removed from Covered Software; or
|
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
|
b. for infringements caused by: (i) Your and any other third party's
|
||||||
modifications of Covered Software, or (ii) the combination of its
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
Contributions with other software (except as part of its Contributor
|
Contributions with other software (except as part of its Contributor
|
||||||
Version); or
|
Version); or
|
||||||
|
|
||||||
c. under Patent Claims infringed by Covered Software in the absence of
|
c. under Patent Claims infringed by Covered Software in the absence of
|
||||||
its Contributions.
|
its Contributions.
|
||||||
|
|
||||||
This License does not grant any rights in the trademarks, service marks,
|
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
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
the notice requirements in Section 3.4).
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
2.4. Subsequent Licenses
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
No Contributor makes additional grants as a result of Your choice to
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
distribute the Covered Software under a subsequent version of this
|
distribute the Covered Software under a subsequent version of this
|
||||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
permitted under the terms of Section 3.3).
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
2.5. Representation
|
2.5. Representation
|
||||||
|
|
||||||
Each Contributor represents that the Contributor believes its
|
Each Contributor represents that the Contributor believes its
|
||||||
Contributions are its original creation(s) or it has sufficient rights to
|
Contributions are its original creation(s) or it has sufficient rights to
|
||||||
grant the rights to its Contributions conveyed by this License.
|
grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
2.6. Fair Use
|
2.6. Fair Use
|
||||||
|
|
||||||
This License is not intended to limit any rights You have under
|
This License is not intended to limit any rights You have under
|
||||||
applicable copyright doctrines of fair use, fair dealing, or other
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
equivalents.
|
equivalents.
|
||||||
|
|
||||||
2.7. Conditions
|
2.7. Conditions
|
||||||
|
|
||||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||||
Section 2.1.
|
Section 2.1.
|
||||||
|
|
||||||
|
|
||||||
3. Responsibilities
|
3. Responsibilities
|
||||||
|
|
||||||
3.1. Distribution of Source Form
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
All distribution of Covered Software in Source Code Form, including any
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
Modifications that You create or to which You contribute, must be under
|
Modifications that You create or to which You contribute, must be under
|
||||||
the terms of this License. You must inform recipients that the Source
|
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
|
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
|
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
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
Form.
|
Form.
|
||||||
|
|
||||||
3.2. Distribution of Executable Form
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
If You distribute Covered Software in Executable Form then:
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
a. such Covered Software must also be made available in Source Code Form,
|
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
|
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
|
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
|
reasonable means in a timely manner, at a charge no more than the cost
|
||||||
of distribution to the recipient; and
|
of distribution to the recipient; and
|
||||||
|
|
||||||
b. You may distribute such Executable Form under the terms of this
|
b. You may distribute such Executable Form under the terms of this
|
||||||
License, or sublicense it under different terms, provided that the
|
License, or sublicense it under different terms, provided that the
|
||||||
license for the Executable Form does not attempt to limit or alter the
|
license for the Executable Form does not attempt to limit or alter the
|
||||||
recipients' rights in the Source Code Form under this License.
|
recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
3.3. Distribution of a Larger Work
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
You may create and distribute a Larger Work under terms of Your choice,
|
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
|
provided that You also comply with the requirements of this License for
|
||||||
the Covered Software. If the Larger Work is a combination of Covered
|
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
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
Covered Software is not Incompatible With Secondary Licenses, this
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
License permits You to additionally distribute such Covered Software
|
License permits You to additionally distribute such Covered Software
|
||||||
under the terms of such Secondary License(s), so that the recipient of
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
the Larger Work may, at their option, further distribute the Covered
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
Software under the terms of either this License or such Secondary
|
Software under the terms of either this License or such Secondary
|
||||||
License(s).
|
License(s).
|
||||||
|
|
||||||
3.4. Notices
|
3.4. Notices
|
||||||
|
|
||||||
You may not remove or alter the substance of any license notices
|
You may not remove or alter the substance of any license notices
|
||||||
(including copyright notices, patent notices, disclaimers of warranty, or
|
(including copyright notices, patent notices, disclaimers of warranty, or
|
||||||
limitations of liability) contained within the Source Code Form of the
|
limitations of liability) contained within the Source Code Form of the
|
||||||
Covered Software, except that You may alter any license notices to the
|
Covered Software, except that You may alter any license notices to the
|
||||||
extent required to remedy known factual inaccuracies.
|
extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
3.5. Application of Additional Terms
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
You may choose to offer, and to charge a fee for, warranty, support,
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
indemnity or liability obligations to one or more recipients of Covered
|
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
|
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
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
such warranty, support, indemnity, or liability obligation is offered by
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
You alone, and You hereby agree to indemnify every Contributor for any
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
liability incurred by such Contributor as a result of warranty, support,
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
indemnity or liability terms You offer. You may include additional
|
indemnity or liability terms You offer. You may include additional
|
||||||
disclaimers of warranty and limitations of liability specific to any
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
jurisdiction.
|
jurisdiction.
|
||||||
|
|
||||||
4. Inability to Comply Due to Statute or Regulation
|
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
|
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,
|
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
|
judicial order, or regulation then You must: (a) comply with the terms of
|
||||||
this License to the maximum extent possible; and (b) describe the
|
this License to the maximum extent possible; and (b) describe the
|
||||||
limitations and the code they affect. Such description must be placed in a
|
limitations and the code they affect. Such description must be placed in a
|
||||||
text file included with all distributions of the Covered Software under
|
text file included with all distributions of the Covered Software under
|
||||||
this License. Except to the extent prohibited by statute or regulation,
|
this License. Except to the extent prohibited by statute or regulation,
|
||||||
such description must be sufficiently detailed for a recipient of ordinary
|
such description must be sufficiently detailed for a recipient of ordinary
|
||||||
skill to be able to understand it.
|
skill to be able to understand it.
|
||||||
|
|
||||||
5. Termination
|
5. Termination
|
||||||
|
|
||||||
5.1. The rights granted under this License will terminate automatically if You
|
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,
|
fail to comply with any of its terms. However, if You become compliant,
|
||||||
then the rights granted under this License from a particular Contributor
|
then the rights granted under this License from a particular Contributor
|
||||||
are reinstated (a) provisionally, unless and until such Contributor
|
are reinstated (a) provisionally, unless and until such Contributor
|
||||||
explicitly and finally terminates Your grants, and (b) on an ongoing
|
explicitly and finally terminates Your grants, and (b) on an ongoing
|
||||||
basis, if such Contributor fails to notify You of the non-compliance by
|
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
|
some reasonable means prior to 60 days after You have come back into
|
||||||
compliance. Moreover, Your grants from a particular Contributor are
|
compliance. Moreover, Your grants from a particular Contributor are
|
||||||
reinstated on an ongoing basis if such Contributor notifies You of the
|
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
|
non-compliance by some reasonable means, this is the first time You have
|
||||||
received notice of non-compliance with this License from such
|
received notice of non-compliance with this License from such
|
||||||
Contributor, and You become compliant prior to 30 days after Your receipt
|
Contributor, and You become compliant prior to 30 days after Your receipt
|
||||||
of the notice.
|
of the notice.
|
||||||
|
|
||||||
5.2. If You initiate litigation against any entity by asserting a patent
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
infringement claim (excluding declaratory judgment actions,
|
infringement claim (excluding declaratory judgment actions,
|
||||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
directly or indirectly infringes any patent, then the rights granted to
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
You by any and all Contributors for the Covered Software under Section
|
You by any and all Contributors for the Covered Software under Section
|
||||||
2.1 of this License shall terminate.
|
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
|
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
|
license agreements (excluding distributors and resellers) which have been
|
||||||
validly granted by You or Your distributors under this License prior to
|
validly granted by You or Your distributors under this License prior to
|
||||||
termination shall survive termination.
|
termination shall survive termination.
|
||||||
|
|
||||||
6. Disclaimer of Warranty
|
6. Disclaimer of Warranty
|
||||||
|
|
||||||
Covered Software is provided under this License on an "as is" basis,
|
Covered Software is provided under this License on an "as is" basis,
|
||||||
without warranty of any kind, either expressed, implied, or statutory,
|
without warranty of any kind, either expressed, implied, or statutory,
|
||||||
including, without limitation, warranties that the Covered Software is free
|
including, without limitation, warranties that the Covered Software is free
|
||||||
of defects, merchantable, fit for a particular purpose or non-infringing.
|
of defects, merchantable, fit for a particular purpose or non-infringing.
|
||||||
The entire risk as to the quality and performance of the Covered Software
|
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,
|
is with You. Should any Covered Software prove defective in any respect,
|
||||||
You (not any Contributor) assume the cost of any necessary servicing,
|
You (not any Contributor) assume the cost of any necessary servicing,
|
||||||
repair, or correction. This disclaimer of warranty constitutes an essential
|
repair, or correction. This disclaimer of warranty constitutes an essential
|
||||||
part of this License. No use of any Covered Software is authorized under
|
part of this License. No use of any Covered Software is authorized under
|
||||||
this License except under this disclaimer.
|
this License except under this disclaimer.
|
||||||
|
|
||||||
7. Limitation of Liability
|
7. Limitation of Liability
|
||||||
|
|
||||||
Under no circumstances and under no legal theory, whether tort (including
|
Under no circumstances and under no legal theory, whether tort (including
|
||||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||||
distributes Covered Software as permitted above, be liable to You for any
|
distributes Covered Software as permitted above, be liable to You for any
|
||||||
direct, indirect, special, incidental, or consequential damages of any
|
direct, indirect, special, incidental, or consequential damages of any
|
||||||
character including, without limitation, damages for lost profits, loss of
|
character including, without limitation, damages for lost profits, loss of
|
||||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||||
other commercial damages or losses, even if such party shall have been
|
other commercial damages or losses, even if such party shall have been
|
||||||
informed of the possibility of such damages. This limitation of liability
|
informed of the possibility of such damages. This limitation of liability
|
||||||
shall not apply to liability for death or personal injury resulting from
|
shall not apply to liability for death or personal injury resulting from
|
||||||
such party's negligence to the extent applicable law prohibits such
|
such party's negligence to the extent applicable law prohibits such
|
||||||
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
||||||
incidental or consequential damages, so this exclusion and limitation may
|
incidental or consequential damages, so this exclusion and limitation may
|
||||||
not apply to You.
|
not apply to You.
|
||||||
|
|
||||||
8. Litigation
|
8. Litigation
|
||||||
|
|
||||||
Any litigation relating to this License may be brought only in the courts
|
Any litigation relating to this License may be brought only in the courts
|
||||||
of a jurisdiction where the defendant maintains its principal place of
|
of a jurisdiction where the defendant maintains its principal place of
|
||||||
business and such litigation shall be governed by laws of that
|
business and such litigation shall be governed by laws of that
|
||||||
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
||||||
in this Section shall prevent a party's ability to bring cross-claims or
|
in this Section shall prevent a party's ability to bring cross-claims or
|
||||||
counter-claims.
|
counter-claims.
|
||||||
|
|
||||||
9. Miscellaneous
|
9. Miscellaneous
|
||||||
|
|
||||||
This License represents the complete agreement concerning the subject
|
This License represents the complete agreement concerning the subject
|
||||||
matter hereof. If any provision of this License is held to be
|
matter hereof. If any provision of this License is held to be
|
||||||
unenforceable, such provision shall be reformed only to the extent
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
necessary to make it enforceable. Any law or regulation which provides that
|
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
|
the language of a contract shall be construed against the drafter shall not
|
||||||
be used to construe this License against a Contributor.
|
be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
|
||||||
10. Versions of the License
|
10. Versions of the License
|
||||||
|
|
||||||
10.1. New Versions
|
10.1. New Versions
|
||||||
|
|
||||||
Mozilla Foundation is the license steward. Except as provided in Section
|
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
|
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
|
publish new versions of this License. Each version will be given a
|
||||||
distinguishing version number.
|
distinguishing version number.
|
||||||
|
|
||||||
10.2. Effect of New Versions
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
You may distribute the Covered Software under the terms of the version
|
You may distribute the Covered Software under the terms of the version
|
||||||
of the License under which You originally received the Covered Software,
|
of the License under which You originally received the Covered Software,
|
||||||
or under the terms of any subsequent version published by the license
|
or under the terms of any subsequent version published by the license
|
||||||
steward.
|
steward.
|
||||||
|
|
||||||
10.3. Modified Versions
|
10.3. Modified Versions
|
||||||
|
|
||||||
If you create software not governed by this License, and you want to
|
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
|
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
|
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
|
any references to the name of the license steward (except to note that
|
||||||
such modified license differs from this License).
|
such modified license differs from this License).
|
||||||
|
|
||||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
Licenses If You choose to distribute Source Code Form that is
|
Licenses If You choose to distribute Source Code Form that is
|
||||||
Incompatible With Secondary Licenses under the terms of this version of
|
Incompatible With Secondary Licenses under the terms of this version of
|
||||||
the License, the notice described in Exhibit B of this License must be
|
the License, the notice described in Exhibit B of this License must be
|
||||||
attached.
|
attached.
|
||||||
|
|
||||||
Exhibit A - Source Code Form License Notice
|
Exhibit A - Source Code Form License Notice
|
||||||
|
|
||||||
This Source Code Form is subject to the
|
This Source Code Form is subject to the
|
||||||
terms of the Mozilla Public License, v.
|
terms of the Mozilla Public License, v.
|
||||||
2.0. If a copy of the MPL was not
|
2.0. If a copy of the MPL was not
|
||||||
distributed with this file, You can
|
distributed with this file, You can
|
||||||
obtain one at
|
obtain one at
|
||||||
http://mozilla.org/MPL/2.0/.
|
http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
If it is not possible or desirable to put the notice in a particular file,
|
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
|
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
|
relevant directory) where a recipient would be likely to look for such a
|
||||||
notice.
|
notice.
|
||||||
|
|
||||||
You may add additional accurate notices of copyright ownership.
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
|
||||||
This Source Code Form is "Incompatible
|
This Source Code Form is "Incompatible
|
||||||
With Secondary Licenses", as defined by
|
With Secondary Licenses", as defined by
|
||||||
the Mozilla Public License, v. 2.0.
|
the Mozilla Public License, v. 2.0.
|
||||||
|
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
|
|
||||||
# AQuery++ Database
|
# AQuery++ Database
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
AQuery++ Database is a cross-platform, In-Memory Column-Store Database that incorporates compiled query execution.
|
AQuery++ Database is a cross-platform, In-Memory Column-Store Database that incorporates compiled query execution.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
![Architecture](./docs/arch-hybrid.svg)
|
![Architecture](./docs/arch-hybrid.svg)
|
||||||
|
|
||||||
### AQuery Compiler
|
### 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.
|
- 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.
|
- 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.
|
- 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
|
### Execution Engines
|
||||||
- AQuery++ supports different execution engines thanks to the decoupled compiler structure.
|
- 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.
|
- 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.
|
- 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).
|
- K9 Execution Engine: (discontinued).
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
- [x] SQL Parser -> AQuery Parser (Front End)
|
- [x] SQL Parser -> AQuery Parser (Front End)
|
||||||
- [x] AQuery-C++ Compiler (Back End)
|
- [x] AQuery-C++ Compiler (Back End)
|
||||||
- [x] Schema and Data Model
|
- [x] Schema and Data Model
|
||||||
- [x] Data acquisition/output from/to csv file
|
- [x] Data acquisition/output from/to csv file
|
||||||
- [ ] Execution Engine
|
- [ ] Execution Engine
|
||||||
- [x] Projections and single-group Aggregations
|
- [x] Projections and single-group Aggregations
|
||||||
- [x] Group by Aggregations
|
- [x] Group by Aggregations
|
||||||
- [x] Filters
|
- [x] Filters
|
||||||
- [x] Order by
|
- [x] Order by
|
||||||
- [x] Assumption
|
- [x] Assumption
|
||||||
- [x] Flatten
|
- [x] Flatten
|
||||||
- [x] UDFs (Hybrid Engine only)
|
- [x] UDFs (Hybrid Engine only)
|
||||||
- [x] User Module
|
- [x] User Module
|
||||||
- [ ] Triggers
|
- [ ] Triggers
|
||||||
- [x] Join (Hybrid Engine only)
|
- [x] Join (Hybrid Engine only)
|
||||||
- [ ] Subqueries
|
- [ ] Subqueries
|
||||||
- [x] Query Optimization
|
- [x] Query Optimization
|
||||||
- [x] Selection/Order by push-down
|
- [x] Selection/Order by push-down
|
||||||
- [x] Join Optimization (Only in Hybrid Engine)
|
- [x] Join Optimization (Only in Hybrid Engine)
|
||||||
|
|
||||||
## TODO:
|
## TODO:
|
||||||
|
|
||||||
- [x] User Module load syntax parsing (fn definition/registration)
|
- [x] User Module load syntax parsing (fn definition/registration)
|
||||||
- [x] User Module initialize location
|
- [x] User Module initialize location
|
||||||
-> User Module test
|
-> User Module test
|
||||||
-> Interval based triggers
|
-> Interval based triggers
|
||||||
-> Optimize Compilation Process, using static libraries, hot reloading server binary
|
-> Optimize Compilation Process, using static libraries, hot reloading server binary
|
||||||
- [x] Bug fixes: type deduction misaligned in Hybrid Engine
|
- [x] Bug fixes: type deduction misaligned in Hybrid Engine
|
||||||
-> Investigation: Using postproc only for q1 in Hybrid Engine (make is_special always on)
|
-> Investigation: Using postproc only for q1 in Hybrid Engine (make is_special always on)
|
||||||
- [x] Limitation: putting ColRefs back to monetdb.
|
- [x] Limitation: putting ColRefs back to monetdb.
|
||||||
- [ ] Limitation: String operations and Date/Time data type.
|
- [ ] Limitation: String operations and Date/Time data type.
|
||||||
- [ ] C++ Meta-Programming: Eliminate template recursions as much as possible.
|
- [ ] C++ Meta-Programming: Eliminate template recursions as much as possible.
|
||||||
- [ ] Limitation: Date and Time, String operations, Funcs in groupby agg.
|
- [ ] Limitation: Date and Time, String operations, Funcs in groupby agg.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
## Requirements
|
## 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)
|
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)
|
- 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)
|
- Clang: 5.0 or above (Recommended)
|
||||||
- MSVC: 2017 or later (2022 or above is recommended)
|
- MSVC: 2017 or later (2022 or above is recommended)
|
||||||
|
|
||||||
2. Monetdb for Hybrid Engine
|
2. Monetdb for Hybrid Engine
|
||||||
- On windows, the required libraries and headers are already included in the repo.
|
- 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 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`.
|
- 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`
|
3. Python 3.6 or above and install required packages in requirements.txt by `python3 -m pip install -r requirements.txt`
|
||||||
## Usage
|
## Usage
|
||||||
`python3 prompt.py` will launch the interactive command prompt. The server binary will be autometically rebuilt and started.
|
`python3 prompt.py` will launch the interactive command prompt. The server binary will be autometically rebuilt and started.
|
||||||
#### Commands:
|
#### Commands:
|
||||||
- `<sql statement>`: parse sql statement
|
- `<sql statement>`: parse sql statement
|
||||||
- `f <filename>`: parse all sql statements in file
|
- `f <filename>`: parse all sql statements in file
|
||||||
- `dbg` start debugging session
|
- `dbg` start debugging session
|
||||||
- `print`: printout parsed sql statements
|
- `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.
|
- `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.
|
- `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
|
- `r`: run the last generated code snippet
|
||||||
- `save <OPTIONAL: filename>`: save current code snippet. will use random filename if not specified.
|
- `save <OPTIONAL: filename>`: save current code snippet. will use random filename if not specified.
|
||||||
- `exit`: quit the prompt
|
- `exit`: quit the prompt
|
||||||
#### Example:
|
#### Example:
|
||||||
`f moving_avg.a` <br>
|
`f moving_avg.a` <br>
|
||||||
`xexec`
|
`xexec`
|
||||||
|
@ -1,59 +1,59 @@
|
|||||||
# put environment specific configuration here
|
# put environment specific configuration here
|
||||||
|
|
||||||
## GLOBAL CONFIGURATION FLAGS
|
## GLOBAL CONFIGURATION FLAGS
|
||||||
|
|
||||||
version_string = '0.4.4a'
|
version_string = '0.4.4a'
|
||||||
add_path_to_ldpath = True
|
add_path_to_ldpath = True
|
||||||
rebuild_backend = False
|
rebuild_backend = False
|
||||||
run_backend = True
|
run_backend = True
|
||||||
have_hge = False
|
have_hge = False
|
||||||
cygroot = 'c:/msys64/usr/bin'
|
cygroot = 'c:/msys64/usr/bin'
|
||||||
msbuildroot = ''
|
msbuildroot = ''
|
||||||
os_platform = 'unknown'
|
os_platform = 'unknown'
|
||||||
build_driver = 'Makefile'
|
build_driver = 'Makefile'
|
||||||
|
|
||||||
def init_config():
|
def init_config():
|
||||||
global __config_initialized__, os_platform, msbuildroot
|
global __config_initialized__, os_platform, msbuildroot
|
||||||
## SETUP ENVIRONMENT VARIABLES
|
## SETUP ENVIRONMENT VARIABLES
|
||||||
# __config_initialized__ = False
|
# __config_initialized__ = False
|
||||||
#os_platform = 'unkown'
|
#os_platform = 'unkown'
|
||||||
#msbuildroot = 'd:/gg/vs22/MSBuild/Current/Bin'
|
#msbuildroot = 'd:/gg/vs22/MSBuild/Current/Bin'
|
||||||
import os
|
import os
|
||||||
from engine.utils import add_dll_dir
|
from engine.utils import add_dll_dir
|
||||||
# os.environ['CXX'] = 'C:/Program Files/LLVM/bin/clang.exe'
|
# os.environ['CXX'] = 'C:/Program Files/LLVM/bin/clang.exe'
|
||||||
os.environ['THREADING'] = '1'
|
os.environ['THREADING'] = '1'
|
||||||
|
|
||||||
if ('__config_initialized__' not in globals() or
|
if ('__config_initialized__' not in globals() or
|
||||||
not __config_initialized__):
|
not __config_initialized__):
|
||||||
import sys
|
import sys
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
os_platform = 'win'
|
os_platform = 'win'
|
||||||
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
||||||
os_platform = 'cygwin'
|
os_platform = 'cygwin'
|
||||||
elif os.name == 'posix':
|
elif os.name == 'posix':
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
os_platform = 'mac'
|
os_platform = 'mac'
|
||||||
elif 'linux' in sys.platform:
|
elif 'linux' in sys.platform:
|
||||||
os_platform = 'linux'
|
os_platform = 'linux'
|
||||||
elif 'bsd' in sys.platform:
|
elif 'bsd' in sys.platform:
|
||||||
os_platform = 'bsd'
|
os_platform = 'bsd'
|
||||||
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
elif sys.platform == 'cygwin' or sys.platform == 'msys':
|
||||||
os_platform = 'cygwin'
|
os_platform = 'cygwin'
|
||||||
# deal with msys dependencies:
|
# deal with msys dependencies:
|
||||||
if os_platform == 'win':
|
if os_platform == 'win':
|
||||||
add_dll_dir(cygroot)
|
add_dll_dir(cygroot)
|
||||||
add_dll_dir(os.path.abspath('./msc-plugin'))
|
add_dll_dir(os.path.abspath('./msc-plugin'))
|
||||||
import vswhere
|
import vswhere
|
||||||
vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath')
|
vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath')
|
||||||
if vsloc:
|
if vsloc:
|
||||||
msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe'
|
msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe'
|
||||||
else:
|
else:
|
||||||
print('Warning: No Visual Studio installation found.')
|
print('Warning: No Visual Studio installation found.')
|
||||||
# print("adding path")
|
# print("adding path")
|
||||||
else:
|
else:
|
||||||
import readline
|
import readline
|
||||||
if os_platform == 'cygwin':
|
if os_platform == 'cygwin':
|
||||||
add_dll_dir('./lib')
|
add_dll_dir('./lib')
|
||||||
__config_initialized__ = True
|
__config_initialized__ = True
|
||||||
|
|
||||||
|
@ -1,88 +1,88 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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,
|
# 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/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
#
|
#
|
||||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||||
#
|
#
|
||||||
|
|
||||||
from __future__ import absolute_import, division, unicode_literals
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from aquery_parser.sql_parser import scrub
|
from aquery_parser.sql_parser import scrub
|
||||||
from aquery_parser.utils import ansi_string, simple_op, normal_op
|
from aquery_parser.utils import ansi_string, simple_op, normal_op
|
||||||
|
|
||||||
parse_locker = Lock() # ENSURE ONLY ONE PARSING AT A TIME
|
parse_locker = Lock() # ENSURE ONLY ONE PARSING AT A TIME
|
||||||
common_parser = None
|
common_parser = None
|
||||||
mysql_parser = None
|
mysql_parser = None
|
||||||
sqlserver_parser = None
|
sqlserver_parser = None
|
||||||
|
|
||||||
SQL_NULL = {"null": {}}
|
SQL_NULL = {"null": {}}
|
||||||
|
|
||||||
|
|
||||||
def parse(sql, null=SQL_NULL, calls=simple_op):
|
def parse(sql, null=SQL_NULL, calls=simple_op):
|
||||||
"""
|
"""
|
||||||
:param sql: String of SQL
|
:param sql: String of SQL
|
||||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||||
:return: parse tree
|
:return: parse tree
|
||||||
"""
|
"""
|
||||||
global common_parser
|
global common_parser
|
||||||
|
|
||||||
with parse_locker:
|
with parse_locker:
|
||||||
if not common_parser:
|
if not common_parser:
|
||||||
common_parser = sql_parser.common_parser()
|
common_parser = sql_parser.common_parser()
|
||||||
result = _parse(common_parser, sql, null, calls)
|
result = _parse(common_parser, sql, null, calls)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def parse_mysql(sql, null=SQL_NULL, calls=simple_op):
|
def parse_mysql(sql, null=SQL_NULL, calls=simple_op):
|
||||||
"""
|
"""
|
||||||
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
||||||
:param sql: String of SQL
|
:param sql: String of SQL
|
||||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||||
:return: parse tree
|
:return: parse tree
|
||||||
"""
|
"""
|
||||||
global mysql_parser
|
global mysql_parser
|
||||||
|
|
||||||
with parse_locker:
|
with parse_locker:
|
||||||
if not mysql_parser:
|
if not mysql_parser:
|
||||||
mysql_parser = sql_parser.mysql_parser()
|
mysql_parser = sql_parser.mysql_parser()
|
||||||
return _parse(mysql_parser, sql, null, calls)
|
return _parse(mysql_parser, sql, null, calls)
|
||||||
|
|
||||||
|
|
||||||
def parse_sqlserver(sql, null=SQL_NULL, calls=simple_op):
|
def parse_sqlserver(sql, null=SQL_NULL, calls=simple_op):
|
||||||
"""
|
"""
|
||||||
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
PARSE MySQL ASSUME DOUBLE QUOTED STRINGS ARE LITERALS
|
||||||
:param sql: String of SQL
|
:param sql: String of SQL
|
||||||
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
:param null: What value to use as NULL (default is the null function `{"null":{}}`)
|
||||||
:return: parse tree
|
:return: parse tree
|
||||||
"""
|
"""
|
||||||
global sqlserver_parser
|
global sqlserver_parser
|
||||||
|
|
||||||
with parse_locker:
|
with parse_locker:
|
||||||
if not sqlserver_parser:
|
if not sqlserver_parser:
|
||||||
sqlserver_parser = sql_parser.sqlserver_parser()
|
sqlserver_parser = sql_parser.sqlserver_parser()
|
||||||
return _parse(sqlserver_parser, sql, null, calls)
|
return _parse(sqlserver_parser, sql, null, calls)
|
||||||
|
|
||||||
|
|
||||||
parse_bigquery = parse_mysql
|
parse_bigquery = parse_mysql
|
||||||
|
|
||||||
|
|
||||||
def _parse(parser, sql, null, calls):
|
def _parse(parser, sql, null, calls):
|
||||||
utils.null_locations = []
|
utils.null_locations = []
|
||||||
utils.scrub_op = calls
|
utils.scrub_op = calls
|
||||||
sql = sql.rstrip().rstrip(";")
|
sql = sql.rstrip().rstrip(";")
|
||||||
parse_result = parser.parse_string(sql, parse_all=True)
|
parse_result = parser.parse_string(sql, parse_all=True)
|
||||||
output = scrub(parse_result)
|
output = scrub(parse_result)
|
||||||
for o, n in utils.null_locations:
|
for o, n in utils.null_locations:
|
||||||
o[n] = null
|
o[n] = null
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_ = json.dumps
|
_ = json.dumps
|
||||||
|
|
||||||
__all__ = ["parse", "format", "parse_mysql", "parse_bigquery", "normal_op", "simple_op"]
|
__all__ = ["parse", "format", "parse_mysql", "parse_bigquery", "normal_op", "simple_op"]
|
||||||
|
@ -1,417 +1,417 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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,
|
# 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/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
#
|
#
|
||||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||||
#
|
#
|
||||||
|
|
||||||
# SQL CONSTANTS
|
# SQL CONSTANTS
|
||||||
from mo_parsing import *
|
from mo_parsing import *
|
||||||
|
|
||||||
from aquery_parser.utils import SQL_NULL, keyword
|
from aquery_parser.utils import SQL_NULL, keyword
|
||||||
|
|
||||||
NULL = keyword("null") / (lambda: SQL_NULL)
|
NULL = keyword("null") / (lambda: SQL_NULL)
|
||||||
TRUE = keyword("true") / (lambda: True)
|
TRUE = keyword("true") / (lambda: True)
|
||||||
FALSE = keyword("false") / (lambda: False)
|
FALSE = keyword("false") / (lambda: False)
|
||||||
NOCASE = keyword("nocase")
|
NOCASE = keyword("nocase")
|
||||||
ASC = keyword("asc")
|
ASC = keyword("asc")
|
||||||
DESC = keyword("desc")
|
DESC = keyword("desc")
|
||||||
|
|
||||||
# SIMPLE KEYWORDS
|
# SIMPLE KEYWORDS
|
||||||
AS = keyword("as").suppress()
|
AS = keyword("as").suppress()
|
||||||
ASSUMING = keyword("assuming")
|
ASSUMING = keyword("assuming")
|
||||||
ALL = keyword("all")
|
ALL = keyword("all")
|
||||||
BY = keyword("by").suppress()
|
BY = keyword("by").suppress()
|
||||||
CAST = keyword("cast")
|
CAST = keyword("cast")
|
||||||
CONSTRAINT = keyword("constraint").suppress()
|
CONSTRAINT = keyword("constraint").suppress()
|
||||||
CREATE = keyword("create").suppress()
|
CREATE = keyword("create").suppress()
|
||||||
CROSS = keyword("cross")
|
CROSS = keyword("cross")
|
||||||
DISTINCT = keyword("distinct")
|
DISTINCT = keyword("distinct")
|
||||||
EXCEPT = keyword("except")
|
EXCEPT = keyword("except")
|
||||||
FETCH = keyword("fetch").suppress()
|
FETCH = keyword("fetch").suppress()
|
||||||
FROM = keyword("from").suppress()
|
FROM = keyword("from").suppress()
|
||||||
FULL = keyword("full")
|
FULL = keyword("full")
|
||||||
FUNCTION = keyword("function").suppress()
|
FUNCTION = keyword("function").suppress()
|
||||||
AGGREGATION = keyword("aggregation").suppress()
|
AGGREGATION = keyword("aggregation").suppress()
|
||||||
GROUP = keyword("group").suppress()
|
GROUP = keyword("group").suppress()
|
||||||
HAVING = keyword("having").suppress()
|
HAVING = keyword("having").suppress()
|
||||||
INNER = keyword("inner")
|
INNER = keyword("inner")
|
||||||
INTERVAL = keyword("interval")
|
INTERVAL = keyword("interval")
|
||||||
JOIN = keyword("join")
|
JOIN = keyword("join")
|
||||||
LEFT = keyword("left")
|
LEFT = keyword("left")
|
||||||
LIKE = keyword("like")
|
LIKE = keyword("like")
|
||||||
LIMIT = keyword("limit").suppress()
|
LIMIT = keyword("limit").suppress()
|
||||||
MINUS = keyword("minus")
|
MINUS = keyword("minus")
|
||||||
OFFSET = keyword("offset").suppress()
|
OFFSET = keyword("offset").suppress()
|
||||||
ON = keyword("on").suppress()
|
ON = keyword("on").suppress()
|
||||||
ORDER = keyword("order").suppress()
|
ORDER = keyword("order").suppress()
|
||||||
OUTER = keyword("outer")
|
OUTER = keyword("outer")
|
||||||
OVER = keyword("over").suppress()
|
OVER = keyword("over").suppress()
|
||||||
PARTITION = keyword("partition").suppress()
|
PARTITION = keyword("partition").suppress()
|
||||||
# PERCENT = keyword("percent").suppress()
|
# PERCENT = keyword("percent").suppress()
|
||||||
RIGHT = keyword("right")
|
RIGHT = keyword("right")
|
||||||
RLIKE = keyword("rlike")
|
RLIKE = keyword("rlike")
|
||||||
SELECT = keyword("select").suppress()
|
SELECT = keyword("select").suppress()
|
||||||
TABLE = keyword("table").suppress()
|
TABLE = keyword("table").suppress()
|
||||||
THEN = keyword("then").suppress()
|
THEN = keyword("then").suppress()
|
||||||
TOP = keyword("top").suppress()
|
TOP = keyword("top").suppress()
|
||||||
UNION = keyword("union")
|
UNION = keyword("union")
|
||||||
INTERSECT = keyword("intersect")
|
INTERSECT = keyword("intersect")
|
||||||
USING = keyword("using").suppress()
|
USING = keyword("using").suppress()
|
||||||
WHEN = keyword("when").suppress()
|
WHEN = keyword("when").suppress()
|
||||||
WHERE = keyword("where").suppress()
|
WHERE = keyword("where").suppress()
|
||||||
WITH = keyword("with").suppress()
|
WITH = keyword("with").suppress()
|
||||||
WITHIN = keyword("within").suppress()
|
WITHIN = keyword("within").suppress()
|
||||||
PRIMARY = keyword("primary").suppress()
|
PRIMARY = keyword("primary").suppress()
|
||||||
FOREIGN = keyword("foreign").suppress()
|
FOREIGN = keyword("foreign").suppress()
|
||||||
KEY = keyword("key").suppress()
|
KEY = keyword("key").suppress()
|
||||||
UNIQUE = keyword("unique").suppress()
|
UNIQUE = keyword("unique").suppress()
|
||||||
INDEX = keyword("index").suppress()
|
INDEX = keyword("index").suppress()
|
||||||
REFERENCES = keyword("references").suppress()
|
REFERENCES = keyword("references").suppress()
|
||||||
RECURSIVE = keyword("recursive").suppress()
|
RECURSIVE = keyword("recursive").suppress()
|
||||||
VALUES = keyword("values").suppress()
|
VALUES = keyword("values").suppress()
|
||||||
WINDOW = keyword("window")
|
WINDOW = keyword("window")
|
||||||
INTO = keyword("into").suppress()
|
INTO = keyword("into").suppress()
|
||||||
IF = keyword("if").suppress()
|
IF = keyword("if").suppress()
|
||||||
STATIC = keyword("static").suppress()
|
STATIC = keyword("static").suppress()
|
||||||
ELIF = keyword("elif").suppress()
|
ELIF = keyword("elif").suppress()
|
||||||
ELSE = keyword("else").suppress()
|
ELSE = keyword("else").suppress()
|
||||||
FOR = keyword("for").suppress()
|
FOR = keyword("for").suppress()
|
||||||
|
|
||||||
PRIMARY_KEY = Group(PRIMARY + KEY).set_parser_name("primary_key")
|
PRIMARY_KEY = Group(PRIMARY + KEY).set_parser_name("primary_key")
|
||||||
FOREIGN_KEY = Group(FOREIGN + KEY).set_parser_name("foreign_key")
|
FOREIGN_KEY = Group(FOREIGN + KEY).set_parser_name("foreign_key")
|
||||||
|
|
||||||
# SIMPLE OPERATORS
|
# SIMPLE OPERATORS
|
||||||
CONCAT = Literal("||").set_parser_name("concat")
|
CONCAT = Literal("||").set_parser_name("concat")
|
||||||
MUL = Literal("*").set_parser_name("mul")
|
MUL = Literal("*").set_parser_name("mul")
|
||||||
DIV = Literal("/").set_parser_name("div")
|
DIV = Literal("/").set_parser_name("div")
|
||||||
MOD = Literal("%").set_parser_name("mod")
|
MOD = Literal("%").set_parser_name("mod")
|
||||||
NEG = Literal("-").set_parser_name("neg")
|
NEG = Literal("-").set_parser_name("neg")
|
||||||
ADD = Literal("+").set_parser_name("add")
|
ADD = Literal("+").set_parser_name("add")
|
||||||
SUB = Literal("-").set_parser_name("sub")
|
SUB = Literal("-").set_parser_name("sub")
|
||||||
BINARY_NOT = Literal("~").set_parser_name("binary_not")
|
BINARY_NOT = Literal("~").set_parser_name("binary_not")
|
||||||
BINARY_AND = Literal("&").set_parser_name("binary_and")
|
BINARY_AND = Literal("&").set_parser_name("binary_and")
|
||||||
BINARY_OR = Literal("|").set_parser_name("binary_or")
|
BINARY_OR = Literal("|").set_parser_name("binary_or")
|
||||||
GTE = Literal(">=").set_parser_name("gte")
|
GTE = Literal(">=").set_parser_name("gte")
|
||||||
LTE = Literal("<=").set_parser_name("lte")
|
LTE = Literal("<=").set_parser_name("lte")
|
||||||
LT = Literal("<").set_parser_name("lt")
|
LT = Literal("<").set_parser_name("lt")
|
||||||
GT = Literal(">").set_parser_name("gt")
|
GT = Literal(">").set_parser_name("gt")
|
||||||
EEQ = (
|
EEQ = (
|
||||||
# conservative equality https://github.com/klahnakoski/jx-sqlite/blob/dev/docs/Logical%20Equality.md#definitions
|
# conservative equality https://github.com/klahnakoski/jx-sqlite/blob/dev/docs/Logical%20Equality.md#definitions
|
||||||
Literal("==") | Literal("=")
|
Literal("==") | Literal("=")
|
||||||
).set_parser_name("eq")
|
).set_parser_name("eq")
|
||||||
DEQ = (
|
DEQ = (
|
||||||
# decisive equality
|
# decisive equality
|
||||||
# https://sparkbyexamples.com/apache-hive/hive-relational-arithmetic-logical-operators/
|
# https://sparkbyexamples.com/apache-hive/hive-relational-arithmetic-logical-operators/
|
||||||
Literal("<=>").set_parser_name("eq!")
|
Literal("<=>").set_parser_name("eq!")
|
||||||
)
|
)
|
||||||
IDF = (
|
IDF = (
|
||||||
# decisive equality
|
# decisive equality
|
||||||
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
||||||
keyword("is distinct from").set_parser_name("eq!")
|
keyword("is distinct from").set_parser_name("eq!")
|
||||||
)
|
)
|
||||||
INDF = (
|
INDF = (
|
||||||
# decisive equality
|
# decisive equality
|
||||||
# https://prestodb.io/docs/current/functions/comparison.html#is-distinct-from-and-is-not-distinct-from
|
# 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!")
|
keyword("is not distinct from").set_parser_name("ne!")
|
||||||
)
|
)
|
||||||
FASSIGN = Literal(":=").set_parser_name("fassign") # Assignment in UDFs
|
FASSIGN = Literal(":=").set_parser_name("fassign") # Assignment in UDFs
|
||||||
PASSIGN = Literal("+=").set_parser_name("passign")
|
PASSIGN = Literal("+=").set_parser_name("passign")
|
||||||
MASSIGN = Literal("-=").set_parser_name("massign")
|
MASSIGN = Literal("-=").set_parser_name("massign")
|
||||||
MULASSIGN = Literal("*=").set_parser_name("mulassign")
|
MULASSIGN = Literal("*=").set_parser_name("mulassign")
|
||||||
DASSIGN = Literal("/=").set_parser_name("dassign")
|
DASSIGN = Literal("/=").set_parser_name("dassign")
|
||||||
COLON = Literal(":").set_parser_name("colon")
|
COLON = Literal(":").set_parser_name("colon")
|
||||||
NEQ = (Literal("!=") | Literal("<>")).set_parser_name("neq")
|
NEQ = (Literal("!=") | Literal("<>")).set_parser_name("neq")
|
||||||
LAMBDA = Literal("->").set_parser_name("lambda")
|
LAMBDA = Literal("->").set_parser_name("lambda")
|
||||||
DOT = Literal(".").set_parser_name("dot")
|
DOT = Literal(".").set_parser_name("dot")
|
||||||
|
|
||||||
AND = keyword("and")
|
AND = keyword("and")
|
||||||
BETWEEN = keyword("between")
|
BETWEEN = keyword("between")
|
||||||
CASE = keyword("case").suppress()
|
CASE = keyword("case").suppress()
|
||||||
COLLATE = keyword("collate")
|
COLLATE = keyword("collate")
|
||||||
END = keyword("end")
|
END = keyword("end")
|
||||||
ELSE = keyword("else").suppress()
|
ELSE = keyword("else").suppress()
|
||||||
IN = keyword("in")
|
IN = keyword("in")
|
||||||
IS = keyword("is")
|
IS = keyword("is")
|
||||||
NOT = keyword("not")
|
NOT = keyword("not")
|
||||||
OR = keyword("or")
|
OR = keyword("or")
|
||||||
LATERAL = keyword("lateral")
|
LATERAL = keyword("lateral")
|
||||||
VIEW = keyword("view")
|
VIEW = keyword("view")
|
||||||
|
|
||||||
# COMPOUND KEYWORDS
|
# COMPOUND KEYWORDS
|
||||||
|
|
||||||
|
|
||||||
joins = (
|
joins = (
|
||||||
(
|
(
|
||||||
Optional(CROSS | OUTER | INNER | ((FULL | LEFT | RIGHT) + Optional(INNER | OUTER)))
|
Optional(CROSS | OUTER | INNER | ((FULL | LEFT | RIGHT) + Optional(INNER | OUTER)))
|
||||||
+ JOIN
|
+ JOIN
|
||||||
+ Optional(LATERAL)
|
+ Optional(LATERAL)
|
||||||
)
|
)
|
||||||
| LATERAL + VIEW + Optional(OUTER)
|
| LATERAL + VIEW + Optional(OUTER)
|
||||||
) / (lambda tokens: " ".join(tokens).lower())
|
) / (lambda tokens: " ".join(tokens).lower())
|
||||||
|
|
||||||
UNION_ALL = (UNION + ALL).set_parser_name("union_all")
|
UNION_ALL = (UNION + ALL).set_parser_name("union_all")
|
||||||
WITHIN_GROUP = Group(WITHIN + GROUP).set_parser_name("within_group")
|
WITHIN_GROUP = Group(WITHIN + GROUP).set_parser_name("within_group")
|
||||||
SELECT_DISTINCT = Group(SELECT + DISTINCT).set_parser_name("select distinct")
|
SELECT_DISTINCT = Group(SELECT + DISTINCT).set_parser_name("select distinct")
|
||||||
PARTITION_BY = Group(PARTITION + BY).set_parser_name("partition by")
|
PARTITION_BY = Group(PARTITION + BY).set_parser_name("partition by")
|
||||||
GROUP_BY = Group(GROUP + BY).set_parser_name("group by")
|
GROUP_BY = Group(GROUP + BY).set_parser_name("group by")
|
||||||
ORDER_BY = Group(ORDER + BY).set_parser_name("order by")
|
ORDER_BY = Group(ORDER + BY).set_parser_name("order by")
|
||||||
|
|
||||||
# COMPOUND OPERATORS
|
# COMPOUND OPERATORS
|
||||||
AT_TIME_ZONE = Group(keyword("at") + keyword("time") + keyword("zone"))
|
AT_TIME_ZONE = Group(keyword("at") + keyword("time") + keyword("zone"))
|
||||||
NOT_BETWEEN = Group(NOT + BETWEEN).set_parser_name("not_between")
|
NOT_BETWEEN = Group(NOT + BETWEEN).set_parser_name("not_between")
|
||||||
NOT_LIKE = Group(NOT + LIKE).set_parser_name("not_like")
|
NOT_LIKE = Group(NOT + LIKE).set_parser_name("not_like")
|
||||||
NOT_RLIKE = Group(NOT + RLIKE).set_parser_name("not_rlike")
|
NOT_RLIKE = Group(NOT + RLIKE).set_parser_name("not_rlike")
|
||||||
NOT_IN = Group(NOT + IN).set_parser_name("nin")
|
NOT_IN = Group(NOT + IN).set_parser_name("nin")
|
||||||
IS_NOT = Group(IS + NOT).set_parser_name("is_not")
|
IS_NOT = Group(IS + NOT).set_parser_name("is_not")
|
||||||
|
|
||||||
_SIMILAR = keyword("similar")
|
_SIMILAR = keyword("similar")
|
||||||
_TO = keyword("to")
|
_TO = keyword("to")
|
||||||
SIMILAR_TO = Group(_SIMILAR + _TO).set_parser_name("similar_to")
|
SIMILAR_TO = Group(_SIMILAR + _TO).set_parser_name("similar_to")
|
||||||
NOT_SIMILAR_TO = Group(NOT + _SIMILAR + _TO).set_parser_name("not_similar_to")
|
NOT_SIMILAR_TO = Group(NOT + _SIMILAR + _TO).set_parser_name("not_similar_to")
|
||||||
|
|
||||||
RESERVED = MatchFirst([
|
RESERVED = MatchFirst([
|
||||||
# ONY INCLUDE SINGLE WORDS
|
# ONY INCLUDE SINGLE WORDS
|
||||||
ALL,
|
ALL,
|
||||||
AND,
|
AND,
|
||||||
AS,
|
AS,
|
||||||
ASC,
|
ASC,
|
||||||
ASSUMING,
|
ASSUMING,
|
||||||
BETWEEN,
|
BETWEEN,
|
||||||
BY,
|
BY,
|
||||||
CASE,
|
CASE,
|
||||||
COLLATE,
|
COLLATE,
|
||||||
CONSTRAINT,
|
CONSTRAINT,
|
||||||
CREATE,
|
CREATE,
|
||||||
CROSS,
|
CROSS,
|
||||||
DESC,
|
DESC,
|
||||||
DISTINCT,
|
DISTINCT,
|
||||||
EXCEPT,
|
EXCEPT,
|
||||||
ELSE,
|
ELSE,
|
||||||
END,
|
END,
|
||||||
FALSE,
|
FALSE,
|
||||||
FETCH,
|
FETCH,
|
||||||
FOREIGN,
|
FOREIGN,
|
||||||
FROM,
|
FROM,
|
||||||
FULL,
|
FULL,
|
||||||
FUNCTION,
|
FUNCTION,
|
||||||
GROUP_BY,
|
GROUP_BY,
|
||||||
GROUP,
|
GROUP,
|
||||||
HAVING,
|
HAVING,
|
||||||
IN,
|
IN,
|
||||||
INDEX,
|
INDEX,
|
||||||
INNER,
|
INNER,
|
||||||
INTERSECT,
|
INTERSECT,
|
||||||
INTERVAL,
|
INTERVAL,
|
||||||
IS_NOT,
|
IS_NOT,
|
||||||
IS,
|
IS,
|
||||||
JOIN,
|
JOIN,
|
||||||
KEY,
|
KEY,
|
||||||
LATERAL,
|
LATERAL,
|
||||||
LEFT,
|
LEFT,
|
||||||
LIKE,
|
LIKE,
|
||||||
LIMIT,
|
LIMIT,
|
||||||
MINUS,
|
MINUS,
|
||||||
NOCASE,
|
NOCASE,
|
||||||
NOT,
|
NOT,
|
||||||
NULL,
|
NULL,
|
||||||
OFFSET,
|
OFFSET,
|
||||||
ON,
|
ON,
|
||||||
OR,
|
OR,
|
||||||
ORDER,
|
ORDER,
|
||||||
OUTER,
|
OUTER,
|
||||||
OVER,
|
OVER,
|
||||||
PARTITION,
|
PARTITION,
|
||||||
PRIMARY,
|
PRIMARY,
|
||||||
REFERENCES,
|
REFERENCES,
|
||||||
RIGHT,
|
RIGHT,
|
||||||
RLIKE,
|
RLIKE,
|
||||||
SELECT,
|
SELECT,
|
||||||
THEN,
|
THEN,
|
||||||
TRUE,
|
TRUE,
|
||||||
UNION,
|
UNION,
|
||||||
UNIQUE,
|
UNIQUE,
|
||||||
USING,
|
USING,
|
||||||
WHEN,
|
WHEN,
|
||||||
WHERE,
|
WHERE,
|
||||||
WINDOW,
|
WINDOW,
|
||||||
WITH,
|
WITH,
|
||||||
WITHIN,
|
WITHIN,
|
||||||
INTO,
|
INTO,
|
||||||
])
|
])
|
||||||
L_INLINE = Literal("<k>").suppress()
|
L_INLINE = Literal("<k>").suppress()
|
||||||
R_INLINE = Literal("</k>").suppress()
|
R_INLINE = Literal("</k>").suppress()
|
||||||
LBRACE = Literal("{").suppress()
|
LBRACE = Literal("{").suppress()
|
||||||
RBRACE = Literal("}").suppress()
|
RBRACE = Literal("}").suppress()
|
||||||
LSB = Literal("[").suppress()
|
LSB = Literal("[").suppress()
|
||||||
RSB = Literal("]").suppress()
|
RSB = Literal("]").suppress()
|
||||||
LB = Literal("(").suppress()
|
LB = Literal("(").suppress()
|
||||||
RB = Literal(")").suppress()
|
RB = Literal(")").suppress()
|
||||||
EQ = Char("=").suppress()
|
EQ = Char("=").suppress()
|
||||||
|
|
||||||
join_keywords = {
|
join_keywords = {
|
||||||
"join",
|
"join",
|
||||||
"full join",
|
"full join",
|
||||||
"cross join",
|
"cross join",
|
||||||
"inner join",
|
"inner join",
|
||||||
"left join",
|
"left join",
|
||||||
"right join",
|
"right join",
|
||||||
"full outer join",
|
"full outer join",
|
||||||
"right outer join",
|
"right outer join",
|
||||||
"left outer join",
|
"left outer join",
|
||||||
}
|
}
|
||||||
|
|
||||||
precedence = {
|
precedence = {
|
||||||
# https://www.sqlite.org/lang_expr.html
|
# https://www.sqlite.org/lang_expr.html
|
||||||
"literal": -1,
|
"literal": -1,
|
||||||
"interval": 0,
|
"interval": 0,
|
||||||
"cast": 0,
|
"cast": 0,
|
||||||
"collate": 0,
|
"collate": 0,
|
||||||
"concat": 1,
|
"concat": 1,
|
||||||
"mul": 2,
|
"mul": 2,
|
||||||
"div": 1.5,
|
"div": 1.5,
|
||||||
"mod": 2,
|
"mod": 2,
|
||||||
"neg": 3,
|
"neg": 3,
|
||||||
"add": 3,
|
"add": 3,
|
||||||
"sub": 2.5,
|
"sub": 2.5,
|
||||||
"binary_not": 4,
|
"binary_not": 4,
|
||||||
"binary_and": 4,
|
"binary_and": 4,
|
||||||
"binary_or": 4,
|
"binary_or": 4,
|
||||||
"gte": 5,
|
"gte": 5,
|
||||||
"lte": 5,
|
"lte": 5,
|
||||||
"lt": 5,
|
"lt": 5,
|
||||||
"gt": 6,
|
"gt": 6,
|
||||||
"eq": 7,
|
"eq": 7,
|
||||||
"neq": 7,
|
"neq": 7,
|
||||||
"missing": 7,
|
"missing": 7,
|
||||||
"exists": 7,
|
"exists": 7,
|
||||||
"at_time_zone": 8,
|
"at_time_zone": 8,
|
||||||
"between": 8,
|
"between": 8,
|
||||||
"not_between": 8,
|
"not_between": 8,
|
||||||
"in": 8,
|
"in": 8,
|
||||||
"nin": 8,
|
"nin": 8,
|
||||||
"is": 8,
|
"is": 8,
|
||||||
"like": 8,
|
"like": 8,
|
||||||
"not_like": 8,
|
"not_like": 8,
|
||||||
"rlike": 8,
|
"rlike": 8,
|
||||||
"not_rlike": 8,
|
"not_rlike": 8,
|
||||||
"similar_to": 8,
|
"similar_to": 8,
|
||||||
"not_similar_to": 8,
|
"not_similar_to": 8,
|
||||||
"and": 10,
|
"and": 10,
|
||||||
"or": 11,
|
"or": 11,
|
||||||
"lambda": 12,
|
"lambda": 12,
|
||||||
"join": 18,
|
"join": 18,
|
||||||
"list": 18,
|
"list": 18,
|
||||||
"function": 30,
|
"function": 30,
|
||||||
"select": 30,
|
"select": 30,
|
||||||
"from": 30,
|
"from": 30,
|
||||||
"window": 35,
|
"window": 35,
|
||||||
"union": 40,
|
"union": 40,
|
||||||
"union_all": 40,
|
"union_all": 40,
|
||||||
"except": 40,
|
"except": 40,
|
||||||
"minus": 40,
|
"minus": 40,
|
||||||
"intersect": 40,
|
"intersect": 40,
|
||||||
"order": 50,
|
"order": 50,
|
||||||
}
|
}
|
||||||
|
|
||||||
KNOWN_OPS = [
|
KNOWN_OPS = [
|
||||||
COLLATE,
|
COLLATE,
|
||||||
CONCAT,
|
CONCAT,
|
||||||
MUL | DIV | MOD,
|
MUL | DIV | MOD,
|
||||||
NEG,
|
NEG,
|
||||||
ADD | SUB,
|
ADD | SUB,
|
||||||
BINARY_NOT,
|
BINARY_NOT,
|
||||||
BINARY_AND,
|
BINARY_AND,
|
||||||
BINARY_OR,
|
BINARY_OR,
|
||||||
GTE | LTE | LT | GT,
|
GTE | LTE | LT | GT,
|
||||||
EEQ | NEQ | DEQ | IDF | INDF,
|
EEQ | NEQ | DEQ | IDF | INDF,
|
||||||
AT_TIME_ZONE,
|
AT_TIME_ZONE,
|
||||||
(BETWEEN, AND),
|
(BETWEEN, AND),
|
||||||
(NOT_BETWEEN, AND),
|
(NOT_BETWEEN, AND),
|
||||||
IN,
|
IN,
|
||||||
NOT_IN,
|
NOT_IN,
|
||||||
IS_NOT,
|
IS_NOT,
|
||||||
IS,
|
IS,
|
||||||
LIKE,
|
LIKE,
|
||||||
NOT_LIKE,
|
NOT_LIKE,
|
||||||
RLIKE,
|
RLIKE,
|
||||||
NOT_RLIKE,
|
NOT_RLIKE,
|
||||||
SIMILAR_TO,
|
SIMILAR_TO,
|
||||||
NOT_SIMILAR_TO,
|
NOT_SIMILAR_TO,
|
||||||
NOT,
|
NOT,
|
||||||
AND,
|
AND,
|
||||||
OR,
|
OR,
|
||||||
LAMBDA,
|
LAMBDA,
|
||||||
]
|
]
|
||||||
|
|
||||||
times = ["now", "today", "tomorrow", "eod"]
|
times = ["now", "today", "tomorrow", "eod"]
|
||||||
|
|
||||||
durations = {
|
durations = {
|
||||||
"microseconds": "microsecond",
|
"microseconds": "microsecond",
|
||||||
"microsecond": "microsecond",
|
"microsecond": "microsecond",
|
||||||
"microsecs": "microsecond",
|
"microsecs": "microsecond",
|
||||||
"microsec": "microsecond",
|
"microsec": "microsecond",
|
||||||
"useconds": "microsecond",
|
"useconds": "microsecond",
|
||||||
"usecond": "microsecond",
|
"usecond": "microsecond",
|
||||||
"usecs": "microsecond",
|
"usecs": "microsecond",
|
||||||
"usec": "microsecond",
|
"usec": "microsecond",
|
||||||
"us": "microsecond",
|
"us": "microsecond",
|
||||||
"milliseconds": "millisecond",
|
"milliseconds": "millisecond",
|
||||||
"millisecond": "millisecond",
|
"millisecond": "millisecond",
|
||||||
"millisecon": "millisecond",
|
"millisecon": "millisecond",
|
||||||
"mseconds": "millisecond",
|
"mseconds": "millisecond",
|
||||||
"msecond": "millisecond",
|
"msecond": "millisecond",
|
||||||
"millisecs": "millisecond",
|
"millisecs": "millisecond",
|
||||||
"millisec": "millisecond",
|
"millisec": "millisecond",
|
||||||
"msecs": "millisecond",
|
"msecs": "millisecond",
|
||||||
"msec": "millisecond",
|
"msec": "millisecond",
|
||||||
"ms": "millisecond",
|
"ms": "millisecond",
|
||||||
"seconds": "second",
|
"seconds": "second",
|
||||||
"second": "second",
|
"second": "second",
|
||||||
"secs": "second",
|
"secs": "second",
|
||||||
"sec": "second",
|
"sec": "second",
|
||||||
"s": "second",
|
"s": "second",
|
||||||
"minutes": "minute",
|
"minutes": "minute",
|
||||||
"minute": "minute",
|
"minute": "minute",
|
||||||
"mins": "minute",
|
"mins": "minute",
|
||||||
"min": "minute",
|
"min": "minute",
|
||||||
"m": "minute",
|
"m": "minute",
|
||||||
"hours": "hour",
|
"hours": "hour",
|
||||||
"hour": "hour",
|
"hour": "hour",
|
||||||
"hrs": "hour",
|
"hrs": "hour",
|
||||||
"hr": "hour",
|
"hr": "hour",
|
||||||
"h": "hour",
|
"h": "hour",
|
||||||
"days": "day",
|
"days": "day",
|
||||||
"day": "day",
|
"day": "day",
|
||||||
"d": "day",
|
"d": "day",
|
||||||
"dayofweek": "dow",
|
"dayofweek": "dow",
|
||||||
"dow": "dow",
|
"dow": "dow",
|
||||||
"weekday": "dow",
|
"weekday": "dow",
|
||||||
"weeks": "week",
|
"weeks": "week",
|
||||||
"week": "week",
|
"week": "week",
|
||||||
"w": "week",
|
"w": "week",
|
||||||
"months": "month",
|
"months": "month",
|
||||||
"month": "month",
|
"month": "month",
|
||||||
"mons": "month",
|
"mons": "month",
|
||||||
"mon": "month",
|
"mon": "month",
|
||||||
"quarters": "quarter",
|
"quarters": "quarter",
|
||||||
"quarter": "quarter",
|
"quarter": "quarter",
|
||||||
"years": "year",
|
"years": "year",
|
||||||
"year": "year",
|
"year": "year",
|
||||||
"decades": "decade",
|
"decades": "decade",
|
||||||
"decade": "decade",
|
"decade": "decade",
|
||||||
"decs": "decade",
|
"decs": "decade",
|
||||||
"dec": "decade",
|
"dec": "decade",
|
||||||
"centuries": "century",
|
"centuries": "century",
|
||||||
"century": "century",
|
"century": "century",
|
||||||
"cents": "century",
|
"cents": "century",
|
||||||
"cent": "century",
|
"cent": "century",
|
||||||
"c": "century",
|
"c": "century",
|
||||||
"millennia": "millennium",
|
"millennia": "millennium",
|
||||||
"millennium": "millennium",
|
"millennium": "millennium",
|
||||||
"mils": "millennium",
|
"mils": "millennium",
|
||||||
"mil": "millennium",
|
"mil": "millennium",
|
||||||
"epoch": "epoch",
|
"epoch": "epoch",
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,223 +1,223 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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,
|
# 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/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
#
|
#
|
||||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
# KNOWN TYPES
|
# KNOWN TYPES
|
||||||
from mo_parsing import Forward, Group, Optional, MatchFirst, Literal, ZeroOrMore, export
|
from mo_parsing import Forward, Group, Optional, MatchFirst, Literal, ZeroOrMore, export
|
||||||
from mo_parsing.infix import delimited_list, RIGHT_ASSOC, LEFT_ASSOC
|
from mo_parsing.infix import delimited_list, RIGHT_ASSOC, LEFT_ASSOC
|
||||||
|
|
||||||
from aquery_parser.keywords import (
|
from aquery_parser.keywords import (
|
||||||
RB,
|
RB,
|
||||||
LB,
|
LB,
|
||||||
NEG,
|
NEG,
|
||||||
NOT,
|
NOT,
|
||||||
BINARY_NOT,
|
BINARY_NOT,
|
||||||
NULL,
|
NULL,
|
||||||
EQ,
|
EQ,
|
||||||
KNOWN_OPS,
|
KNOWN_OPS,
|
||||||
LT,
|
LT,
|
||||||
GT,
|
GT,
|
||||||
)
|
)
|
||||||
from aquery_parser.utils import (
|
from aquery_parser.utils import (
|
||||||
keyword,
|
keyword,
|
||||||
to_json_call,
|
to_json_call,
|
||||||
int_num,
|
int_num,
|
||||||
ansi_string,
|
ansi_string,
|
||||||
ansi_ident,
|
ansi_ident,
|
||||||
assign,
|
assign,
|
||||||
flag,
|
flag,
|
||||||
)
|
)
|
||||||
|
|
||||||
_size = Optional(LB + int_num("params") + RB)
|
_size = Optional(LB + int_num("params") + RB)
|
||||||
_sizes = Optional(LB + delimited_list(int_num("params")) + RB)
|
_sizes = Optional(LB + delimited_list(int_num("params")) + RB)
|
||||||
|
|
||||||
simple_types = Forward()
|
simple_types = Forward()
|
||||||
|
|
||||||
BIGINT = Group(keyword("bigint")("op") + Optional(_size)+Optional(flag("unsigned"))) / to_json_call
|
BIGINT = Group(keyword("bigint")("op") + Optional(_size)+Optional(flag("unsigned"))) / to_json_call
|
||||||
BOOL = Group(keyword("bool")("op")) / to_json_call
|
BOOL = Group(keyword("bool")("op")) / to_json_call
|
||||||
BOOLEAN = Group(keyword("boolean")("op")) / to_json_call
|
BOOLEAN = Group(keyword("boolean")("op")) / to_json_call
|
||||||
DOUBLE = Group(keyword("double")("op")) / to_json_call
|
DOUBLE = Group(keyword("double")("op")) / to_json_call
|
||||||
FLOAT64 = Group(keyword("float64")("op")) / to_json_call
|
FLOAT64 = Group(keyword("float64")("op")) / to_json_call
|
||||||
FLOAT = Group(keyword("float")("op")) / to_json_call
|
FLOAT = Group(keyword("float")("op")) / to_json_call
|
||||||
GEOMETRY = Group(keyword("geometry")("op")) / to_json_call
|
GEOMETRY = Group(keyword("geometry")("op")) / to_json_call
|
||||||
INTEGER = Group(keyword("integer")("op")) / to_json_call
|
INTEGER = Group(keyword("integer")("op")) / to_json_call
|
||||||
INT = (keyword("int")("op") + _size) / to_json_call
|
INT = (keyword("int")("op") + _size) / to_json_call
|
||||||
INT32 = Group(keyword("int32")("op")) / to_json_call
|
INT32 = Group(keyword("int32")("op")) / to_json_call
|
||||||
INT64 = Group(keyword("int64")("op")) / to_json_call
|
INT64 = Group(keyword("int64")("op")) / to_json_call
|
||||||
REAL = Group(keyword("real")("op")) / to_json_call
|
REAL = Group(keyword("real")("op")) / to_json_call
|
||||||
TEXT = Group(keyword("text")("op")) / to_json_call
|
TEXT = Group(keyword("text")("op")) / to_json_call
|
||||||
SMALLINT = Group(keyword("smallint")("op")) / to_json_call
|
SMALLINT = Group(keyword("smallint")("op")) / to_json_call
|
||||||
STRING = Group(keyword("string")("op")) / to_json_call
|
STRING = Group(keyword("string")("op")) / to_json_call
|
||||||
|
|
||||||
BLOB = (keyword("blob")("op") + _size) / to_json_call
|
BLOB = (keyword("blob")("op") + _size) / to_json_call
|
||||||
BYTES = (keyword("bytes")("op") + _size) / to_json_call
|
BYTES = (keyword("bytes")("op") + _size) / to_json_call
|
||||||
CHAR = (keyword("char")("op") + _size) / to_json_call
|
CHAR = (keyword("char")("op") + _size) / to_json_call
|
||||||
NCHAR = (keyword("nchar")("op") + _size) / to_json_call
|
NCHAR = (keyword("nchar")("op") + _size) / to_json_call
|
||||||
VARCHAR = (keyword("varchar")("op") + _size) / to_json_call
|
VARCHAR = (keyword("varchar")("op") + _size) / to_json_call
|
||||||
VARCHAR2 = (keyword("varchar2")("op") + _size) / to_json_call
|
VARCHAR2 = (keyword("varchar2")("op") + _size) / to_json_call
|
||||||
VARBINARY = (keyword("varbinary")("op") + _size) / to_json_call
|
VARBINARY = (keyword("varbinary")("op") + _size) / to_json_call
|
||||||
TINYINT = (keyword("tinyint")("op") + _size) / to_json_call
|
TINYINT = (keyword("tinyint")("op") + _size) / to_json_call
|
||||||
UUID = Group(keyword("uuid")("op")) / to_json_call
|
UUID = Group(keyword("uuid")("op")) / to_json_call
|
||||||
|
|
||||||
DECIMAL = (keyword("decimal")("op") + _sizes) / to_json_call
|
DECIMAL = (keyword("decimal")("op") + _sizes) / to_json_call
|
||||||
DOUBLE_PRECISION = (
|
DOUBLE_PRECISION = (
|
||||||
Group((keyword("double precision") / (lambda: "double_precision"))("op"))
|
Group((keyword("double precision") / (lambda: "double_precision"))("op"))
|
||||||
/ to_json_call
|
/ to_json_call
|
||||||
)
|
)
|
||||||
NUMERIC = (keyword("numeric")("op") + _sizes) / to_json_call
|
NUMERIC = (keyword("numeric")("op") + _sizes) / to_json_call
|
||||||
NUMBER = (keyword("number")("op") + _sizes) / to_json_call
|
NUMBER = (keyword("number")("op") + _sizes) / to_json_call
|
||||||
|
|
||||||
MAP_TYPE = (
|
MAP_TYPE = (
|
||||||
keyword("map")("op") + LB + delimited_list(simple_types("params")) + RB
|
keyword("map")("op") + LB + delimited_list(simple_types("params")) + RB
|
||||||
) / to_json_call
|
) / to_json_call
|
||||||
ARRAY_TYPE = (keyword("array")("op") + LB + simple_types("params") + RB) / to_json_call
|
ARRAY_TYPE = (keyword("array")("op") + LB + simple_types("params") + RB) / to_json_call
|
||||||
|
|
||||||
DATE = keyword("date")
|
DATE = keyword("date")
|
||||||
DATETIME = keyword("datetime")
|
DATETIME = keyword("datetime")
|
||||||
DATETIME_W_TIMEZONE = keyword("datetime with time zone")
|
DATETIME_W_TIMEZONE = keyword("datetime with time zone")
|
||||||
TIME = keyword("time")
|
TIME = keyword("time")
|
||||||
TIMESTAMP = keyword("timestamp")
|
TIMESTAMP = keyword("timestamp")
|
||||||
TIMESTAMP_W_TIMEZONE = keyword("timestamp with time zone")
|
TIMESTAMP_W_TIMEZONE = keyword("timestamp with time zone")
|
||||||
TIMESTAMPTZ = keyword("timestamptz")
|
TIMESTAMPTZ = keyword("timestamptz")
|
||||||
TIMETZ = keyword("timetz")
|
TIMETZ = keyword("timetz")
|
||||||
|
|
||||||
time_functions = DATE | DATETIME | TIME | TIMESTAMP | TIMESTAMPTZ | TIMETZ
|
time_functions = DATE | DATETIME | TIME | TIMESTAMP | TIMESTAMPTZ | TIMETZ
|
||||||
|
|
||||||
# KNOWNN TIME TYPES
|
# KNOWNN TIME TYPES
|
||||||
_format = Optional((ansi_string | ansi_ident)("params"))
|
_format = Optional((ansi_string | ansi_ident)("params"))
|
||||||
|
|
||||||
DATE_TYPE = (DATE("op") + _format) / to_json_call
|
DATE_TYPE = (DATE("op") + _format) / to_json_call
|
||||||
DATETIME_TYPE = (DATETIME("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
|
DATETIME_W_TIMEZONE_TYPE = (DATETIME_W_TIMEZONE("op") + _format) / to_json_call
|
||||||
TIME_TYPE = (TIME("op") + _format) / to_json_call
|
TIME_TYPE = (TIME("op") + _format) / to_json_call
|
||||||
TIMESTAMP_TYPE = (TIMESTAMP("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
|
TIMESTAMP_W_TIMEZONE_TYPE = (TIMESTAMP_W_TIMEZONE("op") + _format) / to_json_call
|
||||||
TIMESTAMPTZ_TYPE = (TIMESTAMPTZ("op") + _format) / to_json_call
|
TIMESTAMPTZ_TYPE = (TIMESTAMPTZ("op") + _format) / to_json_call
|
||||||
TIMETZ_TYPE = (TIMETZ("op") + _format) / to_json_call
|
TIMETZ_TYPE = (TIMETZ("op") + _format) / to_json_call
|
||||||
|
|
||||||
simple_types << MatchFirst([
|
simple_types << MatchFirst([
|
||||||
ARRAY_TYPE,
|
ARRAY_TYPE,
|
||||||
BIGINT,
|
BIGINT,
|
||||||
BOOL,
|
BOOL,
|
||||||
BOOLEAN,
|
BOOLEAN,
|
||||||
BLOB,
|
BLOB,
|
||||||
BYTES,
|
BYTES,
|
||||||
CHAR,
|
CHAR,
|
||||||
DATE_TYPE,
|
DATE_TYPE,
|
||||||
DATETIME_W_TIMEZONE_TYPE,
|
DATETIME_W_TIMEZONE_TYPE,
|
||||||
DATETIME_TYPE,
|
DATETIME_TYPE,
|
||||||
DECIMAL,
|
DECIMAL,
|
||||||
DOUBLE_PRECISION,
|
DOUBLE_PRECISION,
|
||||||
DOUBLE,
|
DOUBLE,
|
||||||
FLOAT64,
|
FLOAT64,
|
||||||
FLOAT,
|
FLOAT,
|
||||||
GEOMETRY,
|
GEOMETRY,
|
||||||
MAP_TYPE,
|
MAP_TYPE,
|
||||||
INTEGER,
|
INTEGER,
|
||||||
INT,
|
INT,
|
||||||
INT32,
|
INT32,
|
||||||
INT64,
|
INT64,
|
||||||
NCHAR,
|
NCHAR,
|
||||||
NUMBER,
|
NUMBER,
|
||||||
NUMERIC,
|
NUMERIC,
|
||||||
REAL,
|
REAL,
|
||||||
TEXT,
|
TEXT,
|
||||||
SMALLINT,
|
SMALLINT,
|
||||||
STRING,
|
STRING,
|
||||||
TIME_TYPE,
|
TIME_TYPE,
|
||||||
TIMESTAMP_W_TIMEZONE_TYPE,
|
TIMESTAMP_W_TIMEZONE_TYPE,
|
||||||
TIMESTAMP_TYPE,
|
TIMESTAMP_TYPE,
|
||||||
TIMESTAMPTZ_TYPE,
|
TIMESTAMPTZ_TYPE,
|
||||||
TIMETZ_TYPE,
|
TIMETZ_TYPE,
|
||||||
TINYINT,
|
TINYINT,
|
||||||
UUID,
|
UUID,
|
||||||
VARCHAR,
|
VARCHAR,
|
||||||
VARCHAR2,
|
VARCHAR2,
|
||||||
VARBINARY,
|
VARBINARY,
|
||||||
])
|
])
|
||||||
|
|
||||||
CASTING = (Literal("::").suppress() + simple_types("params")).set_parser_name("cast")
|
CASTING = (Literal("::").suppress() + simple_types("params")).set_parser_name("cast")
|
||||||
KNOWN_OPS.insert(0, CASTING)
|
KNOWN_OPS.insert(0, CASTING)
|
||||||
|
|
||||||
unary_ops = {
|
unary_ops = {
|
||||||
NEG: RIGHT_ASSOC,
|
NEG: RIGHT_ASSOC,
|
||||||
NOT: RIGHT_ASSOC,
|
NOT: RIGHT_ASSOC,
|
||||||
BINARY_NOT: RIGHT_ASSOC,
|
BINARY_NOT: RIGHT_ASSOC,
|
||||||
CASTING: LEFT_ASSOC,
|
CASTING: LEFT_ASSOC,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_column_type(expr, var_name, literal_string):
|
def get_column_type(expr, var_name, literal_string):
|
||||||
column_definition = Forward()
|
column_definition = Forward()
|
||||||
column_type = Forward().set_parser_name("column type")
|
column_type = Forward().set_parser_name("column type")
|
||||||
|
|
||||||
struct_type = (
|
struct_type = (
|
||||||
keyword("struct")("op")
|
keyword("struct")("op")
|
||||||
+ LT.suppress()
|
+ LT.suppress()
|
||||||
+ Group(delimited_list(column_definition))("params")
|
+ Group(delimited_list(column_definition))("params")
|
||||||
+ GT.suppress()
|
+ GT.suppress()
|
||||||
) / to_json_call
|
) / to_json_call
|
||||||
|
|
||||||
row_type = (
|
row_type = (
|
||||||
keyword("row")("op")
|
keyword("row")("op")
|
||||||
+ LB
|
+ LB
|
||||||
+ Group(delimited_list(column_definition))("params")
|
+ Group(delimited_list(column_definition))("params")
|
||||||
+ RB
|
+ RB
|
||||||
) / to_json_call
|
) / to_json_call
|
||||||
|
|
||||||
array_type = (
|
array_type = (
|
||||||
keyword("array")("op")
|
keyword("array")("op")
|
||||||
+ (
|
+ (
|
||||||
(
|
(
|
||||||
LT.suppress()
|
LT.suppress()
|
||||||
+ Group(delimited_list(column_type))("params")
|
+ Group(delimited_list(column_type))("params")
|
||||||
+ GT.suppress()
|
+ GT.suppress()
|
||||||
)
|
)
|
||||||
| (LB + Group(delimited_list(column_type))("params") + RB)
|
| (LB + Group(delimited_list(column_type))("params") + RB)
|
||||||
)
|
)
|
||||||
) / to_json_call
|
) / to_json_call
|
||||||
|
|
||||||
column_type << (struct_type | row_type | array_type | simple_types)
|
column_type << (struct_type | row_type | array_type | simple_types)
|
||||||
|
|
||||||
column_def_identity = (
|
column_def_identity = (
|
||||||
assign(
|
assign(
|
||||||
"generated",
|
"generated",
|
||||||
(keyword("always") | keyword("by default") / (lambda: "by_default")),
|
(keyword("always") | keyword("by default") / (lambda: "by_default")),
|
||||||
)
|
)
|
||||||
+ keyword("as identity").suppress()
|
+ keyword("as identity").suppress()
|
||||||
+ Optional(assign("start with", int_num))
|
+ Optional(assign("start with", int_num))
|
||||||
+ Optional(assign("increment by", int_num))
|
+ Optional(assign("increment by", int_num))
|
||||||
)
|
)
|
||||||
|
|
||||||
column_def_references = assign(
|
column_def_references = assign(
|
||||||
"references", var_name("table") + LB + delimited_list(var_name)("columns") + RB,
|
"references", var_name("table") + LB + delimited_list(var_name)("columns") + RB,
|
||||||
)
|
)
|
||||||
|
|
||||||
column_options = ZeroOrMore(
|
column_options = ZeroOrMore(
|
||||||
((NOT + NULL) / (lambda: False))("nullable")
|
((NOT + NULL) / (lambda: False))("nullable")
|
||||||
| (NULL / (lambda t: True))("nullable")
|
| (NULL / (lambda t: True))("nullable")
|
||||||
| flag("unique")
|
| flag("unique")
|
||||||
| flag("auto_increment")
|
| flag("auto_increment")
|
||||||
| assign("comment", literal_string)
|
| assign("comment", literal_string)
|
||||||
| assign("collate", Optional(EQ) + var_name)
|
| assign("collate", Optional(EQ) + var_name)
|
||||||
| flag("primary key")
|
| flag("primary key")
|
||||||
| column_def_identity("identity")
|
| column_def_identity("identity")
|
||||||
| column_def_references
|
| column_def_references
|
||||||
| assign("check", LB + expr + RB)
|
| assign("check", LB + expr + RB)
|
||||||
| assign("default", expr)
|
| assign("default", expr)
|
||||||
).set_parser_name("column_options")
|
).set_parser_name("column_options")
|
||||||
|
|
||||||
column_definition << Group(
|
column_definition << Group(
|
||||||
var_name("name") + (column_type | var_name)("type") + column_options
|
var_name("name") + (column_type | var_name)("type") + column_options
|
||||||
).set_parser_name("column_definition")
|
).set_parser_name("column_definition")
|
||||||
|
|
||||||
return column_type, column_definition, column_def_references
|
return column_type, column_definition, column_def_references
|
||||||
|
|
||||||
|
|
||||||
export("aquery_parser.utils", unary_ops)
|
export("aquery_parser.utils", unary_ops)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,107 +1,107 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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,
|
# 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/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
#
|
#
|
||||||
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)
|
||||||
#
|
#
|
||||||
|
|
||||||
from __future__ import absolute_import, division, unicode_literals
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
|
|
||||||
from mo_parsing.infix import delimited_list
|
from mo_parsing.infix import delimited_list
|
||||||
|
|
||||||
from aquery_parser.keywords import *
|
from aquery_parser.keywords import *
|
||||||
from aquery_parser.utils 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
|
# https://docs.microsoft.com/en-us/sql/t-sql/queries/select-over-clause-transact-sql?view=sql-server-ver15
|
||||||
|
|
||||||
|
|
||||||
def _to_bound_call(tokens):
|
def _to_bound_call(tokens):
|
||||||
zero = tokens["zero"]
|
zero = tokens["zero"]
|
||||||
if zero:
|
if zero:
|
||||||
return {"min": 0, "max": 0}
|
return {"min": 0, "max": 0}
|
||||||
|
|
||||||
direction = scrub(tokens["direction"])
|
direction = scrub(tokens["direction"])
|
||||||
limit = scrub(tokens["limit"])
|
limit = scrub(tokens["limit"])
|
||||||
if direction == "preceding":
|
if direction == "preceding":
|
||||||
if limit == "unbounded":
|
if limit == "unbounded":
|
||||||
return {"max": 0}
|
return {"max": 0}
|
||||||
elif is_data(limit):
|
elif is_data(limit):
|
||||||
return {"min": {"neg": limit}, "max": 0}
|
return {"min": {"neg": limit}, "max": 0}
|
||||||
else:
|
else:
|
||||||
return {"min": -limit, "max": 0}
|
return {"min": -limit, "max": 0}
|
||||||
else: # following
|
else: # following
|
||||||
if limit == "unbounded":
|
if limit == "unbounded":
|
||||||
return {"min": 0}
|
return {"min": 0}
|
||||||
elif is_data(limit):
|
elif is_data(limit):
|
||||||
return {"min": {"neg": limit}, "max": 0}
|
return {"min": {"neg": limit}, "max": 0}
|
||||||
else:
|
else:
|
||||||
return {"min": 0, "max": limit}
|
return {"min": 0, "max": limit}
|
||||||
|
|
||||||
|
|
||||||
def _to_between_call(tokens):
|
def _to_between_call(tokens):
|
||||||
minn = scrub(tokens["min"])
|
minn = scrub(tokens["min"])
|
||||||
maxx = scrub(tokens["max"])
|
maxx = scrub(tokens["max"])
|
||||||
|
|
||||||
if maxx.get("max") == 0:
|
if maxx.get("max") == 0:
|
||||||
# following
|
# following
|
||||||
return {
|
return {
|
||||||
"min": minn.get("min"),
|
"min": minn.get("min"),
|
||||||
"max": maxx.get("min"),
|
"max": maxx.get("min"),
|
||||||
}
|
}
|
||||||
elif minn.get("min") == 0:
|
elif minn.get("min") == 0:
|
||||||
# preceding
|
# preceding
|
||||||
return {"min": minn.get("max"), "max": maxx.get("max")}
|
return {"min": minn.get("max"), "max": maxx.get("max")}
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
"min": minn.get("min"),
|
"min": minn.get("min"),
|
||||||
"max": maxx.get("max"),
|
"max": maxx.get("max"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UNBOUNDED = keyword("unbounded")
|
UNBOUNDED = keyword("unbounded")
|
||||||
PRECEDING = keyword("preceding")
|
PRECEDING = keyword("preceding")
|
||||||
FOLLOWING = keyword("following")
|
FOLLOWING = keyword("following")
|
||||||
CURRENT_ROW = keyword("current row")
|
CURRENT_ROW = keyword("current row")
|
||||||
ROWS = keyword("rows")
|
ROWS = keyword("rows")
|
||||||
RANGE = keyword("range")
|
RANGE = keyword("range")
|
||||||
|
|
||||||
|
|
||||||
def window(expr, var_name, sort_column):
|
def window(expr, var_name, sort_column):
|
||||||
bound_row = (
|
bound_row = (
|
||||||
CURRENT_ROW("zero")
|
CURRENT_ROW("zero")
|
||||||
| (UNBOUNDED | int_num)("limit") + (PRECEDING | FOLLOWING)("direction")
|
| (UNBOUNDED | int_num)("limit") + (PRECEDING | FOLLOWING)("direction")
|
||||||
) / _to_bound_call
|
) / _to_bound_call
|
||||||
bound_expr = (
|
bound_expr = (
|
||||||
CURRENT_ROW("zero")
|
CURRENT_ROW("zero")
|
||||||
| (UNBOUNDED | expr)("limit") + (PRECEDING | FOLLOWING)("direction")
|
| (UNBOUNDED | expr)("limit") + (PRECEDING | FOLLOWING)("direction")
|
||||||
) / _to_bound_call
|
) / _to_bound_call
|
||||||
between_row = (
|
between_row = (
|
||||||
BETWEEN + bound_row("min") + AND + bound_row("max")
|
BETWEEN + bound_row("min") + AND + bound_row("max")
|
||||||
) / _to_between_call
|
) / _to_between_call
|
||||||
between_expr = (
|
between_expr = (
|
||||||
BETWEEN + bound_expr("min") + AND + bound_expr("max")
|
BETWEEN + bound_expr("min") + AND + bound_expr("max")
|
||||||
) / _to_between_call
|
) / _to_between_call
|
||||||
|
|
||||||
row_clause = (ROWS.suppress() + (between_row | bound_row)) | (
|
row_clause = (ROWS.suppress() + (between_row | bound_row)) | (
|
||||||
RANGE.suppress() + (between_expr | bound_expr)
|
RANGE.suppress() + (between_expr | bound_expr)
|
||||||
)
|
)
|
||||||
|
|
||||||
over_clause = (
|
over_clause = (
|
||||||
LB
|
LB
|
||||||
+ Optional(PARTITION_BY + delimited_list(Group(expr))("partitionby"))
|
+ Optional(PARTITION_BY + delimited_list(Group(expr))("partitionby"))
|
||||||
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
||||||
+ Optional(row_clause("range"))
|
+ Optional(row_clause("range"))
|
||||||
+ RB
|
+ RB
|
||||||
)
|
)
|
||||||
|
|
||||||
window_clause = Optional((
|
window_clause = Optional((
|
||||||
WITHIN_GROUP
|
WITHIN_GROUP
|
||||||
+ LB
|
+ LB
|
||||||
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
+ Optional(ORDER_BY + delimited_list(Group(sort_column))("orderby"))
|
||||||
+ RB
|
+ RB
|
||||||
)("within")) + ((OVER + (over_clause | var_name) / to_over)("over"))
|
)("within")) + ((OVER + (over_clause | var_name) / to_over)("over"))
|
||||||
|
|
||||||
return window_clause, over_clause
|
return window_clause, over_clause
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
## Windows
|
## Windows
|
||||||
- clang-msvc:
|
- 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
|
- "%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'))
|
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||||
- gcc-mingw (link w/ msvc monetdb):
|
- 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
|
- "%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('c:/msys64/usr/bin')
|
||||||
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||||
- gcc-mingw (link w/ mingw monetdb, can only load under mingw python):
|
- 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
|
- $(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'))
|
- add_dll_dir(os.path.abspath('./lib'))
|
||||||
- msvc:
|
- msvc:
|
||||||
- D:\gg\vs22\MSBuild\Current\Bin\msbuild "d:\gg\AQuery++\server\server.vcxproj" /p:configuration=Release /p:platform=x64
|
- 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'))
|
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
|
||||||
|
|
@ -1,45 +1,45 @@
|
|||||||
import mariadb
|
import mariadb
|
||||||
|
|
||||||
class dbconn:
|
class dbconn:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.db = None
|
self.db = None
|
||||||
self.cur = None
|
self.cur = None
|
||||||
def clear(self):
|
def clear(self):
|
||||||
drop_all = f'''
|
drop_all = f'''
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
SET @tables = NULL;
|
SET @tables = NULL;
|
||||||
|
|
||||||
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tables
|
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tables
|
||||||
FROM information_schema.tables
|
FROM information_schema.tables
|
||||||
WHERE table_schema = '{self.db.database}';
|
WHERE table_schema = '{self.db.database}';
|
||||||
|
|
||||||
SET @tables = CONCAT('DROP TABLE ', @tables);
|
SET @tables = CONCAT('DROP TABLE ', @tables);
|
||||||
PREPARE stmt FROM @tables;
|
PREPARE stmt FROM @tables;
|
||||||
EXECUTE stmt;
|
EXECUTE stmt;
|
||||||
DEALLOCATE PREPARE stmt;
|
DEALLOCATE PREPARE stmt;
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
'''
|
'''
|
||||||
if self.db:
|
if self.db:
|
||||||
if not self.cur:
|
if not self.cur:
|
||||||
self.cur = self.db.cursor()
|
self.cur = self.db.cursor()
|
||||||
self.cur.execute(drop_all)
|
self.cur.execute(drop_all)
|
||||||
|
|
||||||
def connect(self, ip, password = '0508', user = 'root', db = 'db', port = 3306):
|
def connect(self, ip, password = '0508', user = 'root', db = 'db', port = 3306):
|
||||||
try:
|
try:
|
||||||
self.db = mariadb.connect(
|
self.db = mariadb.connect(
|
||||||
user = user,
|
user = user,
|
||||||
password = password,
|
password = password,
|
||||||
host = ip,
|
host = ip,
|
||||||
port = port,
|
port = port,
|
||||||
database = db
|
database = db
|
||||||
)
|
)
|
||||||
self.cur = self.db.cursor()
|
self.cur = self.db.cursor()
|
||||||
|
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(e)
|
print(e)
|
||||||
self.db = None
|
self.db = None
|
||||||
self.cur = None
|
self.cur = None
|
||||||
|
|
||||||
def exec(self, sql, params = None):
|
def exec(self, sql, params = None):
|
||||||
self.cur.execute(sql)
|
self.cur.execute(sql)
|
@ -1,37 +1,37 @@
|
|||||||
from engine.ast import Context, ast_node
|
from engine.ast import Context, ast_node
|
||||||
saved_cxt = None
|
saved_cxt = None
|
||||||
|
|
||||||
def initialize(cxt = None, keep = False):
|
def initialize(cxt = None, keep = False):
|
||||||
global saved_cxt
|
global saved_cxt
|
||||||
if cxt is None or not keep or type(cxt) is not Context:
|
if cxt is None or not keep or type(cxt) is not Context:
|
||||||
if saved_cxt is None or not keep:
|
if saved_cxt is None or not keep:
|
||||||
cxt = Context()
|
cxt = Context()
|
||||||
saved_cxt = cxt
|
saved_cxt = cxt
|
||||||
else:
|
else:
|
||||||
cxt = saved_cxt
|
cxt = saved_cxt
|
||||||
cxt.new()
|
cxt.new()
|
||||||
|
|
||||||
return cxt
|
return cxt
|
||||||
|
|
||||||
def generate(ast, cxt):
|
def generate(ast, cxt):
|
||||||
for k in ast.keys():
|
for k in ast.keys():
|
||||||
if k in ast_node.types.keys():
|
if k in ast_node.types.keys():
|
||||||
root = ast_node.types[k](None, ast, cxt)
|
root = ast_node.types[k](None, ast, cxt)
|
||||||
|
|
||||||
def exec(stmts, cxt = None, keep = None):
|
def exec(stmts, cxt = None, keep = None):
|
||||||
cxt = initialize(cxt, keep)
|
cxt = initialize(cxt, keep)
|
||||||
stmts_stmts = stmts['stmts']
|
stmts_stmts = stmts['stmts']
|
||||||
if type(stmts_stmts) is list:
|
if type(stmts_stmts) is list:
|
||||||
for s in stmts_stmts:
|
for s in stmts_stmts:
|
||||||
generate(s, cxt)
|
generate(s, cxt)
|
||||||
else:
|
else:
|
||||||
generate(stmts_stmts, cxt)
|
generate(stmts_stmts, cxt)
|
||||||
|
|
||||||
cxt.Info(cxt.ccode)
|
cxt.Info(cxt.ccode)
|
||||||
with open('out.cpp', 'wb') as outfile:
|
with open('out.cpp', 'wb') as outfile:
|
||||||
outfile.write((cxt.finalize()).encode('utf-8'))
|
outfile.write((cxt.finalize()).encode('utf-8'))
|
||||||
|
|
||||||
return cxt
|
return cxt
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["initialize", "generate", "exec", "saved_cxt"]
|
__all__ = ["initialize", "generate", "exec", "saved_cxt"]
|
||||||
|
@ -1,373 +1,373 @@
|
|||||||
from engine.utils import base62uuid
|
from engine.utils import base62uuid
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from typing import *
|
from typing import *
|
||||||
# replace column info with this later.
|
# replace column info with this later.
|
||||||
class ColRef:
|
class ColRef:
|
||||||
def __init__(self, cname, _ty, cobj, cnt, table:'TableInfo', name, id, compound = False):
|
def __init__(self, cname, _ty, cobj, cnt, table:'TableInfo', name, id, compound = False):
|
||||||
self.cname = cname # column object location
|
self.cname = cname # column object location
|
||||||
self.cxt_name = None # column object in context
|
self.cxt_name = None # column object in context
|
||||||
self.type = _ty
|
self.type = _ty
|
||||||
self.cobj = cobj
|
self.cobj = cobj
|
||||||
self.cnt = cnt
|
self.cnt = cnt
|
||||||
self.table = table
|
self.table = table
|
||||||
self.name = name
|
self.name = name
|
||||||
self.id = id # position in table
|
self.id = id # position in table
|
||||||
self.order_pending = None # order_pending
|
self.order_pending = None # order_pending
|
||||||
self.compound = compound # compound field (list as a field)
|
self.compound = compound # compound field (list as a field)
|
||||||
self.views = []
|
self.views = []
|
||||||
self.aux_columns = [] # columns for temperary calculations
|
self.aux_columns = [] # columns for temperary calculations
|
||||||
# e.g. order by, group by, filter by expressions
|
# e.g. order by, group by, filter by expressions
|
||||||
|
|
||||||
self.__arr__ = (cname, _ty, cobj, cnt, table, name, id)
|
self.__arr__ = (cname, _ty, cobj, cnt, table, name, id)
|
||||||
|
|
||||||
def reference(self):
|
def reference(self):
|
||||||
cxt = self.table.cxt
|
cxt = self.table.cxt
|
||||||
self.table.reference()
|
self.table.reference()
|
||||||
if self not in cxt.columns_in_context:
|
if self not in cxt.columns_in_context:
|
||||||
counter = 0
|
counter = 0
|
||||||
base_name = self.table.table_name + '_' + self.name
|
base_name = self.table.table_name + '_' + self.name
|
||||||
if base_name in cxt.columns_in_context.values():
|
if base_name in cxt.columns_in_context.values():
|
||||||
while (f'{base_name}_{counter}') in cxt.columns_in_context.values():
|
while (f'{base_name}_{counter}') in cxt.columns_in_context.values():
|
||||||
counter += 1
|
counter += 1
|
||||||
base_name = f'{base_name}_{counter}'
|
base_name = f'{base_name}_{counter}'
|
||||||
self.cxt_name = base_name
|
self.cxt_name = base_name
|
||||||
cxt.columns_in_context[self] = base_name
|
cxt.columns_in_context[self] = base_name
|
||||||
# TODO: change this to cname;
|
# TODO: change this to cname;
|
||||||
cxt.emit(f'auto& {base_name} = *(ColRef<{self.type}> *)(&{self.table.cxt_name}->colrefs[{self.id}]);')
|
cxt.emit(f'auto& {base_name} = *(ColRef<{self.type}> *)(&{self.table.cxt_name}->colrefs[{self.id}]);')
|
||||||
elif self.cxt_name is None:
|
elif self.cxt_name is None:
|
||||||
self.cxt_name = cxt.columns_in_context[self]
|
self.cxt_name = cxt.columns_in_context[self]
|
||||||
|
|
||||||
return self.cxt_name
|
return self.cxt_name
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if type(key) is str:
|
if type(key) is str:
|
||||||
return getattr(self, key)
|
return getattr(self, key)
|
||||||
else:
|
else:
|
||||||
return self.__arr__[key]
|
return self.__arr__[key]
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self.__arr__[key] = value
|
self.__arr__[key] = value
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.reference()
|
return self.reference()
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.reference()
|
return self.reference()
|
||||||
|
|
||||||
class TableInfo:
|
class TableInfo:
|
||||||
|
|
||||||
def __init__(self, table_name, cols, cxt:'Context'):
|
def __init__(self, table_name, cols, cxt:'Context'):
|
||||||
# statics
|
# statics
|
||||||
self.table_name = table_name
|
self.table_name = table_name
|
||||||
self.alias = set([table_name])
|
self.alias = set([table_name])
|
||||||
self.columns_byname = dict() # column_name, type
|
self.columns_byname = dict() # column_name, type
|
||||||
self.columns = []
|
self.columns = []
|
||||||
self.cxt = cxt
|
self.cxt = cxt
|
||||||
self.cxt_name = None
|
self.cxt_name = None
|
||||||
self.views = set()
|
self.views = set()
|
||||||
#keep track of temp vars
|
#keep track of temp vars
|
||||||
self.local_vars = dict()
|
self.local_vars = dict()
|
||||||
self.rec = None # a hook on get_col_d to record tables being referenced in the process
|
self.rec = None # a hook on get_col_d to record tables being referenced in the process
|
||||||
self.groupinfo = None
|
self.groupinfo = None
|
||||||
self.add_cols(cols)
|
self.add_cols(cols)
|
||||||
# runtime
|
# runtime
|
||||||
self.n_rows = 0 # number of cols
|
self.n_rows = 0 # number of cols
|
||||||
self.order = [] # assumptions
|
self.order = [] # assumptions
|
||||||
|
|
||||||
cxt.tables_byname[self.table_name] = self # construct reverse map
|
cxt.tables_byname[self.table_name] = self # construct reverse map
|
||||||
def reference(self):
|
def reference(self):
|
||||||
if self not in self.cxt.tables_in_context:
|
if self not in self.cxt.tables_in_context:
|
||||||
counter = 0
|
counter = 0
|
||||||
base_name = self.table_name
|
base_name = self.table_name
|
||||||
if base_name in self.cxt.tables_in_context.values():
|
if base_name in self.cxt.tables_in_context.values():
|
||||||
while (f'{base_name}_{counter}') in self.cxt.tables_in_context.values():
|
while (f'{base_name}_{counter}') in self.cxt.tables_in_context.values():
|
||||||
counter += 1
|
counter += 1
|
||||||
base_name = f'{base_name}_{counter}'
|
base_name = f'{base_name}_{counter}'
|
||||||
self.cxt_name = base_name
|
self.cxt_name = base_name
|
||||||
self.cxt.tables_in_context[self] = base_name
|
self.cxt.tables_in_context[self] = base_name
|
||||||
|
|
||||||
type_tags = '<'
|
type_tags = '<'
|
||||||
for c in self.columns:
|
for c in self.columns:
|
||||||
type_tags += c.type + ','
|
type_tags += c.type + ','
|
||||||
if type_tags.endswith(','):
|
if type_tags.endswith(','):
|
||||||
type_tags = type_tags[:-1]
|
type_tags = type_tags[:-1]
|
||||||
type_tags += '>'
|
type_tags += '>'
|
||||||
|
|
||||||
self.cxt.emit(f'auto& {base_name} = *(TableInfo{type_tags} *)(cxt->tables["{self.table_name}"]);')
|
self.cxt.emit(f'auto& {base_name} = *(TableInfo{type_tags} *)(cxt->tables["{self.table_name}"]);')
|
||||||
return self.cxt_name
|
return self.cxt_name
|
||||||
def refer_all(self):
|
def refer_all(self):
|
||||||
self.reference()
|
self.reference()
|
||||||
for c in self.columns:
|
for c in self.columns:
|
||||||
c.reference()
|
c.reference()
|
||||||
def add_cols(self, cols, new = True):
|
def add_cols(self, cols, new = True):
|
||||||
for i, c in enumerate(cols):
|
for i, c in enumerate(cols):
|
||||||
self.add_col(c, new, i)
|
self.add_col(c, new, i)
|
||||||
def add_col(self, c, new = True, i = 0):
|
def add_col(self, c, new = True, i = 0):
|
||||||
_ty = c['type']
|
_ty = c['type']
|
||||||
if new:
|
if new:
|
||||||
cname =f'get<{i}>({self.table_name})'
|
cname =f'get<{i}>({self.table_name})'
|
||||||
_ty = _ty if type(c) is ColRef else list(_ty.keys())[0]
|
_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))
|
col_object = ColRef(cname, _ty, c, 1, self,c['name'], len(self.columns))
|
||||||
else:
|
else:
|
||||||
col_object = c
|
col_object = c
|
||||||
cname = c.cname
|
cname = c.cname
|
||||||
c.table = self
|
c.table = self
|
||||||
self.cxt.ccols_byname[cname] = col_object
|
self.cxt.ccols_byname[cname] = col_object
|
||||||
self.columns_byname[c['name']] = col_object
|
self.columns_byname[c['name']] = col_object
|
||||||
self.columns.append(col_object)
|
self.columns.append(col_object)
|
||||||
def get_size(self):
|
def get_size(self):
|
||||||
size_tmp = 'tmp_sz_'+base62uuid(6)
|
size_tmp = 'tmp_sz_'+base62uuid(6)
|
||||||
self.cxt.emit(f'const auto& {size_tmp} = {self.columns[0].reference()}.size;')
|
self.cxt.emit(f'const auto& {size_tmp} = {self.columns[0].reference()}.size;')
|
||||||
return size_tmp
|
return size_tmp
|
||||||
@property
|
@property
|
||||||
def n_cols(self):
|
def n_cols(self):
|
||||||
return len(self.columns)
|
return len(self.columns)
|
||||||
|
|
||||||
def materialize_orderbys(self):
|
def materialize_orderbys(self):
|
||||||
view_stack = ''
|
view_stack = ''
|
||||||
stack_name = ''
|
stack_name = ''
|
||||||
for o in self.order:
|
for o in self.order:
|
||||||
o.materialize()
|
o.materialize()
|
||||||
if len(view_stack) == 0:
|
if len(view_stack) == 0:
|
||||||
view_stack = o.view.name
|
view_stack = o.view.name
|
||||||
stack_name = view_stack
|
stack_name = view_stack
|
||||||
else:
|
else:
|
||||||
view_stack = view_stack+'['+ o.view.name +']'
|
view_stack = view_stack+'['+ o.view.name +']'
|
||||||
# TODO: Optimize by doing everything in a stmt
|
# TODO: Optimize by doing everything in a stmt
|
||||||
if len(view_stack) > 0:
|
if len(view_stack) > 0:
|
||||||
if len(self.order) > 1:
|
if len(self.order) > 1:
|
||||||
self.cxt.emit(f'{stack_name}:{view_stack}')
|
self.cxt.emit(f'{stack_name}:{view_stack}')
|
||||||
for c in self.columns:
|
for c in self.columns:
|
||||||
c.order_pending = stack_name
|
c.order_pending = stack_name
|
||||||
self.order[0].node.view = stack_name
|
self.order[0].node.view = stack_name
|
||||||
self.order.clear()
|
self.order.clear()
|
||||||
|
|
||||||
def get_col_d(self, col_name):
|
def get_col_d(self, col_name):
|
||||||
col = self.columns_byname[col_name]
|
col = self.columns_byname[col_name]
|
||||||
if type(self.rec) is set:
|
if type(self.rec) is set:
|
||||||
self.rec.add(col)
|
self.rec.add(col)
|
||||||
return col
|
return col
|
||||||
|
|
||||||
def get_ccolname_d(self, col_name):
|
def get_ccolname_d(self, col_name):
|
||||||
return self.get_col_d(col_name).cname
|
return self.get_col_d(col_name).cname
|
||||||
|
|
||||||
def get_col(self, col_name):
|
def get_col(self, col_name):
|
||||||
self.materialize_orderbys()
|
self.materialize_orderbys()
|
||||||
col = self.get_col_d(col_name)
|
col = self.get_col_d(col_name)
|
||||||
if type(col.order_pending) is str:
|
if type(col.order_pending) is str:
|
||||||
self.cxt.emit_no_flush(f'{col.cname}:{col.cname}[{col.order_pending}]')
|
self.cxt.emit_no_flush(f'{col.cname}:{col.cname}[{col.order_pending}]')
|
||||||
col.order_pending = None
|
col.order_pending = None
|
||||||
return col
|
return col
|
||||||
def get_ccolname(self, col_name):
|
def get_ccolname(self, col_name):
|
||||||
return self.get_col(col_name).cname
|
return self.get_col(col_name).cname
|
||||||
|
|
||||||
def add_alias(self, alias):
|
def add_alias(self, alias):
|
||||||
# TODO: Scoping of alias should be constrainted in the query.
|
# TODO: Scoping of alias should be constrainted in the query.
|
||||||
if alias in self.cxt.tables_byname.keys():
|
if alias in self.cxt.tables_byname.keys():
|
||||||
print("Error: table alias already exists")
|
print("Error: table alias already exists")
|
||||||
return
|
return
|
||||||
self.cxt.tables_byname[alias] = self
|
self.cxt.tables_byname[alias] = self
|
||||||
self.alias.add(alias)
|
self.alias.add(alias)
|
||||||
|
|
||||||
def parse_col_names(self, colExpr, materialize = True, raw = False):
|
def parse_col_names(self, colExpr, materialize = True, raw = False):
|
||||||
# get_col = self.get_col if materialize else self.get_col_d
|
# get_col = self.get_col if materialize else self.get_col_d
|
||||||
|
|
||||||
parsedColExpr = colExpr.split('.')
|
parsedColExpr = colExpr.split('.')
|
||||||
ret = None
|
ret = None
|
||||||
if len(parsedColExpr) <= 1:
|
if len(parsedColExpr) <= 1:
|
||||||
ret = self.get_col_d(colExpr)
|
ret = self.get_col_d(colExpr)
|
||||||
else:
|
else:
|
||||||
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
||||||
if datasource is None:
|
if datasource is None:
|
||||||
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
||||||
else:
|
else:
|
||||||
ret = datasource.parse_col_names(parsedColExpr[1], raw)
|
ret = datasource.parse_col_names(parsedColExpr[1], raw)
|
||||||
from engine.expr import index_expr
|
from engine.expr import index_expr
|
||||||
string = ret.reference() + index_expr
|
string = ret.reference() + index_expr
|
||||||
if self.groupinfo is not None and ret and ret in self.groupinfo.raw_groups:
|
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}})'
|
string = f'get<{self.groupinfo.raw_groups.index(ret)}>({{y}})'
|
||||||
return string, ret if raw else string
|
return string, ret if raw else string
|
||||||
|
|
||||||
class View:
|
class View:
|
||||||
def __init__(self, context, table = None, tmp = True):
|
def __init__(self, context, table = None, tmp = True):
|
||||||
self.table: TableInfo = table
|
self.table: TableInfo = table
|
||||||
self.name = 'v'+base62uuid(7)
|
self.name = 'v'+base62uuid(7)
|
||||||
if type(table) is TableInfo:
|
if type(table) is TableInfo:
|
||||||
table.views.add(self)
|
table.views.add(self)
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
self.context.emit(f'{self.name}:()')
|
self.context.emit(f'{self.name}:()')
|
||||||
|
|
||||||
class Context:
|
class Context:
|
||||||
function_head = '''
|
function_head = '''
|
||||||
extern "C" int __DLLEXPORT__ dllmain(Context* cxt) {
|
extern "C" int __DLLEXPORT__ dllmain(Context* cxt) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace types;
|
using namespace types;
|
||||||
|
|
||||||
'''
|
'''
|
||||||
LOG_INFO = 'INFO'
|
LOG_INFO = 'INFO'
|
||||||
LOG_ERROR = 'ERROR'
|
LOG_ERROR = 'ERROR'
|
||||||
LOG_SILENT = 'SILENT'
|
LOG_SILENT = 'SILENT'
|
||||||
from engine.types import Types
|
from engine.types import Types
|
||||||
type_table : Dict[str, Types] = dict()
|
type_table : Dict[str, Types] = dict()
|
||||||
|
|
||||||
def new(self):
|
def new(self):
|
||||||
self.tmp_names = set()
|
self.tmp_names = set()
|
||||||
self.udf_map = dict()
|
self.udf_map = dict()
|
||||||
self.headers = set(['\"./server/libaquery.h\"'])
|
self.headers = set(['\"./server/libaquery.h\"'])
|
||||||
self.finalized = False
|
self.finalized = False
|
||||||
# read header
|
# read header
|
||||||
self.ccode = str()
|
self.ccode = str()
|
||||||
self.ccodelet = str()
|
self.ccodelet = str()
|
||||||
with open('header.cxx', 'r') as outfile:
|
with open('header.cxx', 'r') as outfile:
|
||||||
self.ccode = outfile.read()
|
self.ccode = outfile.read()
|
||||||
# datasource will be availible after `from' clause is parsed
|
# datasource will be availible after `from' clause is parsed
|
||||||
# and will be deactivated when the `from' is out of scope
|
# and will be deactivated when the `from' is out of scope
|
||||||
self.datasource = None
|
self.datasource = None
|
||||||
self.ds_stack = []
|
self.ds_stack = []
|
||||||
self.scans = []
|
self.scans = []
|
||||||
self.removing_scan = False
|
self.removing_scan = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tables:list[TableInfo] = []
|
self.tables:list[TableInfo] = []
|
||||||
self.tables_byname = dict()
|
self.tables_byname = dict()
|
||||||
self.ccols_byname = dict()
|
self.ccols_byname = dict()
|
||||||
self.gc_name = 'gc_' + base62uuid(4)
|
self.gc_name = 'gc_' + base62uuid(4)
|
||||||
self.tmp_names = set()
|
self.tmp_names = set()
|
||||||
self.udf_map = dict()
|
self.udf_map = dict()
|
||||||
self.headers = set(['\"./server/libaquery.h\"'])
|
self.headers = set(['\"./server/libaquery.h\"'])
|
||||||
self.finalized = False
|
self.finalized = False
|
||||||
self.log_level = Context.LOG_SILENT
|
self.log_level = Context.LOG_SILENT
|
||||||
self.print = print
|
self.print = print
|
||||||
# read header
|
# read header
|
||||||
self.ccode = str()
|
self.ccode = str()
|
||||||
self.ccodelet = str()
|
self.ccodelet = str()
|
||||||
self.columns_in_context = dict()
|
self.columns_in_context = dict()
|
||||||
self.tables_in_context = dict()
|
self.tables_in_context = dict()
|
||||||
with open('header.cxx', 'r') as outfile:
|
with open('header.cxx', 'r') as outfile:
|
||||||
self.ccode = outfile.read()
|
self.ccode = outfile.read()
|
||||||
# datasource will be availible after `from' clause is parsed
|
# datasource will be availible after `from' clause is parsed
|
||||||
# and will be deactivated when the `from' is out of scope
|
# and will be deactivated when the `from' is out of scope
|
||||||
self.datasource = None
|
self.datasource = None
|
||||||
self.ds_stack = []
|
self.ds_stack = []
|
||||||
self.scans = []
|
self.scans = []
|
||||||
self.removing_scan = False
|
self.removing_scan = False
|
||||||
def add_table(self, table_name, cols):
|
def add_table(self, table_name, cols):
|
||||||
tbl = TableInfo(table_name, cols, self)
|
tbl = TableInfo(table_name, cols, self)
|
||||||
self.tables.append(tbl)
|
self.tables.append(tbl)
|
||||||
return tbl
|
return tbl
|
||||||
|
|
||||||
def gen_tmptable(self):
|
def gen_tmptable(self):
|
||||||
from engine.utils import base62uuid
|
from engine.utils import base62uuid
|
||||||
return f't{base62uuid(7)}'
|
return f't{base62uuid(7)}'
|
||||||
def reg_tmp(self, name, f):
|
def reg_tmp(self, name, f):
|
||||||
self.tmp_names.add(name)
|
self.tmp_names.add(name)
|
||||||
self.emit(f"{self.gc_name}.reg({{{name}, 0,0{'' if f is None else ',{f}'}}});")
|
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):
|
def define_tmp(self, typename, isPtr = True, f = None):
|
||||||
name = 'tmp_' + base62uuid()
|
name = 'tmp_' + base62uuid()
|
||||||
if isPtr:
|
if isPtr:
|
||||||
self.emit(f'auto* {name} = new {typename};')
|
self.emit(f'auto* {name} = new {typename};')
|
||||||
self.reg_tmp(name, f)
|
self.reg_tmp(name, f)
|
||||||
else:
|
else:
|
||||||
self.emit(f'auto {name} = {typename};')
|
self.emit(f'auto {name} = {typename};')
|
||||||
return name
|
return name
|
||||||
def emit(self, codelet):
|
def emit(self, codelet):
|
||||||
self.ccode += self.ccodelet + codelet + '\n'
|
self.ccode += self.ccodelet + codelet + '\n'
|
||||||
self.ccodelet = ''
|
self.ccodelet = ''
|
||||||
def emit_no_flush(self, codelet):
|
def emit_no_flush(self, codelet):
|
||||||
self.ccode += codelet + '\n'
|
self.ccode += codelet + '\n'
|
||||||
def emit_flush(self):
|
def emit_flush(self):
|
||||||
self.ccode += self.ccodelet + '\n'
|
self.ccode += self.ccodelet + '\n'
|
||||||
self.ccodelet = ''
|
self.ccodelet = ''
|
||||||
def emit_nonewline(self, codelet):
|
def emit_nonewline(self, codelet):
|
||||||
self.ccodelet += codelet
|
self.ccodelet += codelet
|
||||||
|
|
||||||
def datsource_top(self):
|
def datsource_top(self):
|
||||||
if len(self.ds_stack) > 0:
|
if len(self.ds_stack) > 0:
|
||||||
return self.ds_stack[-1]
|
return self.ds_stack[-1]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
def datasource_pop(self):
|
def datasource_pop(self):
|
||||||
if len(self.ds_stack) > 0:
|
if len(self.ds_stack) > 0:
|
||||||
self.ds_stack.pop()
|
self.ds_stack.pop()
|
||||||
return self.ds_stack[-1]
|
return self.ds_stack[-1]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
def datasource_push(self, ds):
|
def datasource_push(self, ds):
|
||||||
if type(ds) is TableInfo:
|
if type(ds) is TableInfo:
|
||||||
self.ds_stack.append(ds)
|
self.ds_stack.append(ds)
|
||||||
return ds
|
return ds
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
def remove_scan(self, scan, str_scan):
|
def remove_scan(self, scan, str_scan):
|
||||||
self.emit(str_scan)
|
self.emit(str_scan)
|
||||||
self.scans.remove(scan)
|
self.scans.remove(scan)
|
||||||
|
|
||||||
def Info(self, msg):
|
def Info(self, msg):
|
||||||
if self.log_level.upper() == Context.LOG_INFO:
|
if self.log_level.upper() == Context.LOG_INFO:
|
||||||
self.print(msg)
|
self.print(msg)
|
||||||
def Error(self, msg):
|
def Error(self, msg):
|
||||||
if self.log_level.upper() == Context.LOG_ERROR:
|
if self.log_level.upper() == Context.LOG_ERROR:
|
||||||
self.print(msg)
|
self.print(msg)
|
||||||
else:
|
else:
|
||||||
self.Info(self, msg)
|
self.Info(self, msg)
|
||||||
|
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
if not self.finalized:
|
if not self.finalized:
|
||||||
headers = ''
|
headers = ''
|
||||||
for h in self.headers:
|
for h in self.headers:
|
||||||
if h[0] != '"':
|
if h[0] != '"':
|
||||||
headers += '#include <' + h + '>\n'
|
headers += '#include <' + h + '>\n'
|
||||||
else:
|
else:
|
||||||
headers += '#include ' + h + '\n'
|
headers += '#include ' + h + '\n'
|
||||||
self.ccode = headers + self.function_head + self.ccode + 'return 0;\n}'
|
self.ccode = headers + self.function_head + self.ccode + 'return 0;\n}'
|
||||||
self.headers = set()
|
self.headers = set()
|
||||||
return self.ccode
|
return self.ccode
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
self.finalize()
|
self.finalize()
|
||||||
return self.ccode
|
return self.ccode
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return self.__str__()
|
return self.__str__()
|
||||||
|
|
||||||
|
|
||||||
class ast_node:
|
class ast_node:
|
||||||
types = dict()
|
types = dict()
|
||||||
header = []
|
header = []
|
||||||
def __init__(self, parent:"ast_node", node, context:Context = None):
|
def __init__(self, parent:"ast_node", node, context:Context = None):
|
||||||
self.context = parent.context if context is None else context
|
self.context = parent.context if context is None else context
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.datasource = None
|
self.datasource = None
|
||||||
self.init(node)
|
self.init(node)
|
||||||
self.produce(node)
|
self.produce(node)
|
||||||
self.spawn(node)
|
self.spawn(node)
|
||||||
self.consume(node)
|
self.consume(node)
|
||||||
|
|
||||||
def emit(self, code):
|
def emit(self, code):
|
||||||
self.context.emit(code)
|
self.context.emit(code)
|
||||||
def emit_no_ln(self, code):
|
def emit_no_ln(self, code):
|
||||||
self.context.emit_nonewline(code)
|
self.context.emit_nonewline(code)
|
||||||
|
|
||||||
name = 'null'
|
name = 'null'
|
||||||
|
|
||||||
# each ast node has 3 stages.
|
# each ast node has 3 stages.
|
||||||
# `produce' generates info for child nodes
|
# `produce' generates info for child nodes
|
||||||
# `spawn' populates child nodes
|
# `spawn' populates child nodes
|
||||||
# `consume' consumes info from child nodes and finalizes codegen
|
# `consume' consumes info from child nodes and finalizes codegen
|
||||||
# For simple operators, there may not be need for some of these stages
|
# For simple operators, there may not be need for some of these stages
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
pass
|
pass
|
||||||
def produce(self, _):
|
def produce(self, _):
|
||||||
pass
|
pass
|
||||||
def spawn(self, _):
|
def spawn(self, _):
|
||||||
pass
|
pass
|
||||||
def consume(self, _):
|
def consume(self, _):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# include classes in module as first order operators
|
# include classes in module as first order operators
|
||||||
def include(objs):
|
def include(objs):
|
||||||
import inspect
|
import inspect
|
||||||
for _, cls in inspect.getmembers(objs):
|
for _, cls in inspect.getmembers(objs):
|
||||||
if inspect.isclass(cls) and issubclass(cls, ast_node) and not cls.name.startswith('_'):
|
if inspect.isclass(cls) and issubclass(cls, ast_node) and not cls.name.startswith('_'):
|
||||||
ast_node.types[cls.name] = cls
|
ast_node.types[cls.name] = cls
|
@ -1,128 +1,128 @@
|
|||||||
# code-gen for data decl languages
|
# code-gen for data decl languages
|
||||||
|
|
||||||
from engine.orderby import orderby
|
from engine.orderby import orderby
|
||||||
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
||||||
from engine.scan import scan
|
from engine.scan import scan
|
||||||
from engine.utils import base62uuid
|
from engine.utils import base62uuid
|
||||||
|
|
||||||
class create_table(ast_node):
|
class create_table(ast_node):
|
||||||
name = 'create_table'
|
name = 'create_table'
|
||||||
def __init__(self, parent: "ast_node", node, context: Context = None, cexprs = None, lineage = False):
|
def __init__(self, parent: "ast_node", node, context: Context = None, cexprs = None, lineage = False):
|
||||||
self.cexprs = cexprs
|
self.cexprs = cexprs
|
||||||
self.lineage = lineage
|
self.lineage = lineage
|
||||||
super().__init__(parent, node, context)
|
super().__init__(parent, node, context)
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
if type(node) is not TableInfo:
|
if type(node) is not TableInfo:
|
||||||
ct = node[self.name]
|
ct = node[self.name]
|
||||||
tbl = self.context.add_table(ct['name'], ct['columns'])
|
tbl = self.context.add_table(ct['name'], ct['columns'])
|
||||||
else:
|
else:
|
||||||
tbl = node
|
tbl = node
|
||||||
|
|
||||||
col_type_str = ','.join([c.type for c in tbl.columns])
|
col_type_str = ','.join([c.type for c in tbl.columns])
|
||||||
# create tables in c
|
# create tables in c
|
||||||
self.emit(f"auto {tbl.table_name} = new TableInfo<{col_type_str}>(\"{tbl.table_name}\", {tbl.n_cols});")
|
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.emit("cxt->tables.insert({\"" + tbl.table_name + f"\", {tbl.table_name}"+"});")
|
||||||
self.context.tables_in_context[tbl] = tbl.table_name
|
self.context.tables_in_context[tbl] = tbl.table_name
|
||||||
tbl.cxt_name = tbl.table_name
|
tbl.cxt_name = tbl.table_name
|
||||||
tbl.refer_all()
|
tbl.refer_all()
|
||||||
# create an empty new table
|
# create an empty new table
|
||||||
if self.cexprs is None:
|
if self.cexprs is None:
|
||||||
for c in tbl.columns:
|
for c in tbl.columns:
|
||||||
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
||||||
# create an output table
|
# create an output table
|
||||||
else:
|
else:
|
||||||
# 1 to 1 lineage.
|
# 1 to 1 lineage.
|
||||||
if len(self.context.scans) == 0:
|
if len(self.context.scans) == 0:
|
||||||
if self.lineage:
|
if self.lineage:
|
||||||
order = 'order_' + base62uuid(6)
|
order = 'order_' + base62uuid(6)
|
||||||
self.emit(f'auto {order} = {self.parent.datasource.cxt_name}->order_by<{orderby(self.parent, self.parent.assumptions).result()}>();')
|
self.emit(f'auto {order} = {self.parent.datasource.cxt_name}->order_by<{orderby(self.parent, self.parent.assumptions).result()}>();')
|
||||||
self.lineage = '*' + order
|
self.lineage = '*' + order
|
||||||
else:
|
else:
|
||||||
self.lineage = None
|
self.lineage = None
|
||||||
for i, c in enumerate(tbl.columns):
|
for i, c in enumerate(tbl.columns):
|
||||||
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
self.emit(f'{c.cxt_name}.init("{c.name}");')
|
||||||
self.emit(f"{c.cxt_name} = {self.cexprs[i](self.lineage)};")
|
self.emit(f"{c.cxt_name} = {self.cexprs[i](self.lineage)};")
|
||||||
self.lineage = None
|
self.lineage = None
|
||||||
self.parent.assumptions = None
|
self.parent.assumptions = None
|
||||||
else:
|
else:
|
||||||
scanner:scan = self.context.scans[-1]
|
scanner:scan = self.context.scans[-1]
|
||||||
if self.lineage:
|
if self.lineage:
|
||||||
lineage_var = 'lineage_' + base62uuid(6)
|
lineage_var = 'lineage_' + base62uuid(6)
|
||||||
counter_var = 'counter_' + 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 {lineage_var} = {self.datasource.cxt_name}->bind({tbl.cxt_name});', "init")
|
||||||
scanner.add(f'auto {counter_var} = 0;', "init")
|
scanner.add(f'auto {counter_var} = 0;', "init")
|
||||||
scanner.add(f"{lineage_var}.emplace_back({counter_var}++);", "front")
|
scanner.add(f"{lineage_var}.emplace_back({counter_var}++);", "front")
|
||||||
self.lineage = f"{lineage_var}.rid"
|
self.lineage = f"{lineage_var}.rid"
|
||||||
for i, c in enumerate(tbl.columns):
|
for i, c in enumerate(tbl.columns):
|
||||||
scanner.add(f'{c.cxt_name}.init("{c.name}");', "init")
|
scanner.add(f'{c.cxt_name}.init("{c.name}");', "init")
|
||||||
scanner.add(f"{c.cxt_name} = {self.cexprs[i](scanner.it_ver)};")
|
scanner.add(f"{c.cxt_name} = {self.cexprs[i](scanner.it_ver)};")
|
||||||
|
|
||||||
class insert(ast_node):
|
class insert(ast_node):
|
||||||
name = 'insert'
|
name = 'insert'
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
ct = node[self.name]
|
ct = node[self.name]
|
||||||
table:TableInfo = self.context.tables_byname[ct]
|
table:TableInfo = self.context.tables_byname[ct]
|
||||||
|
|
||||||
values = node['query']['select']
|
values = node['query']['select']
|
||||||
if len(values) != table.n_cols:
|
if len(values) != table.n_cols:
|
||||||
raise ValueError("Column Mismatch")
|
raise ValueError("Column Mismatch")
|
||||||
table.refer_all()
|
table.refer_all()
|
||||||
for i, s in enumerate(values):
|
for i, s in enumerate(values):
|
||||||
if 'value' in s:
|
if 'value' in s:
|
||||||
cname = table.columns[i].cxt_name
|
cname = table.columns[i].cxt_name
|
||||||
self.emit(f"{cname}.emplace_back({s['value']});")
|
self.emit(f"{cname}.emplace_back({s['value']});")
|
||||||
else:
|
else:
|
||||||
# subquery, dispatch to select astnode
|
# subquery, dispatch to select astnode
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class c(ast_node):
|
class c(ast_node):
|
||||||
name='c'
|
name='c'
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
self.emit(node[self.name])
|
self.emit(node[self.name])
|
||||||
|
|
||||||
class load(ast_node):
|
class load(ast_node):
|
||||||
name="load"
|
name="load"
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
self.context.headers.add('"csv.h"')
|
self.context.headers.add('"csv.h"')
|
||||||
node = node[self.name]
|
node = node[self.name]
|
||||||
table:TableInfo = self.context.tables_byname[node['table']]
|
table:TableInfo = self.context.tables_byname[node['table']]
|
||||||
table.refer_all()
|
table.refer_all()
|
||||||
csv_reader_name = 'csv_reader_' + base62uuid(6)
|
csv_reader_name = 'csv_reader_' + base62uuid(6)
|
||||||
col_types = [c.type for c in table.columns]
|
col_types = [c.type for c in table.columns]
|
||||||
col_tmp_names = ['tmp_'+base62uuid(8) for _ in range(len(table.columns))]
|
col_tmp_names = ['tmp_'+base62uuid(8) for _ in range(len(table.columns))]
|
||||||
# col_type_str = ",".join(col_types)
|
# col_type_str = ",".join(col_types)
|
||||||
col_names = ','.join([f'"{c.name}"' for c in table.columns])
|
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'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});')
|
self.emit(f'{csv_reader_name}.read_header(io::ignore_extra_column, {col_names});')
|
||||||
for t, n in zip(col_types, col_tmp_names):
|
for t, n in zip(col_types, col_tmp_names):
|
||||||
self.emit(f'{t} {n};')
|
self.emit(f'{t} {n};')
|
||||||
self.emit(f'while({csv_reader_name}.read_row({",".join(col_tmp_names)})) {{ \n')
|
self.emit(f'while({csv_reader_name}.read_row({",".join(col_tmp_names)})) {{ \n')
|
||||||
for i, c in enumerate(table.columns):
|
for i, c in enumerate(table.columns):
|
||||||
self.emit(f'{c.cxt_name}.emplace_back({col_tmp_names[i]});')
|
self.emit(f'{c.cxt_name}.emplace_back({col_tmp_names[i]});')
|
||||||
self.emit('}')
|
self.emit('}')
|
||||||
|
|
||||||
|
|
||||||
class outfile(ast_node):
|
class outfile(ast_node):
|
||||||
name="_outfile"
|
name="_outfile"
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
out_table:TableInfo = self.parent.out_table
|
out_table:TableInfo = self.parent.out_table
|
||||||
filename = node['loc']['literal'] if 'loc' in node else node['literal']
|
filename = node['loc']['literal'] if 'loc' in node else node['literal']
|
||||||
sep = ',' if 'term' not in node else node['term']['literal']
|
sep = ',' if 'term' not in node else node['term']['literal']
|
||||||
file_pointer = 'fp_' + base62uuid(6)
|
file_pointer = 'fp_' + base62uuid(6)
|
||||||
self.emit(f'FILE* {file_pointer} = fopen("{filename}", "w");')
|
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'{out_table.cxt_name}->printall("{sep}", "\\n", nullptr, {file_pointer});')
|
||||||
self.emit(f'fclose({file_pointer});')
|
self.emit(f'fclose({file_pointer});')
|
||||||
# self.context.headers.add('fstream')
|
# self.context.headers.add('fstream')
|
||||||
# cout_backup_buffer = 'stdout_' + base62uuid(4)
|
# cout_backup_buffer = 'stdout_' + base62uuid(4)
|
||||||
# ofstream = 'ofstream_' + base62uuid(6)
|
# ofstream = 'ofstream_' + base62uuid(6)
|
||||||
# self.emit(f'auto {cout_backup_buffer} = cout.rdbuf();')
|
# self.emit(f'auto {cout_backup_buffer} = cout.rdbuf();')
|
||||||
# self.emit(f'auto {ofstream} = ofstream("{filename}");')
|
# self.emit(f'auto {ofstream} = ofstream("{filename}");')
|
||||||
# self.emit(f'cout.rdbuf({ofstream}.rdbuf());')
|
# self.emit(f'cout.rdbuf({ofstream}.rdbuf());')
|
||||||
# TODO: ADD STMTS.
|
# TODO: ADD STMTS.
|
||||||
# self.emit(f'cout.rdbuf({cout_backup_buffer});')
|
# self.emit(f'cout.rdbuf({cout_backup_buffer});')
|
||||||
# self.emit(f'{ofstream}.close();')
|
# self.emit(f'{ofstream}.close();')
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
include(sys.modules[__name__])
|
include(sys.modules[__name__])
|
@ -1,135 +1,135 @@
|
|||||||
from engine.ast import ast_node, ColRef
|
from engine.ast import ast_node, ColRef
|
||||||
start_expr = 'f"'
|
start_expr = 'f"'
|
||||||
index_expr = '{\'\' if x is None and y is None else f\'[{x}]\'}'
|
index_expr = '{\'\' if x is None and y is None else f\'[{x}]\'}'
|
||||||
end_expr = '"'
|
end_expr = '"'
|
||||||
|
|
||||||
class expr(ast_node):
|
class expr(ast_node):
|
||||||
name='expr'
|
name='expr'
|
||||||
builtin_func_maps = {
|
builtin_func_maps = {
|
||||||
'max': 'max',
|
'max': 'max',
|
||||||
'min': 'min',
|
'min': 'min',
|
||||||
'avg': 'avg',
|
'avg': 'avg',
|
||||||
'sum': 'sum',
|
'sum': 'sum',
|
||||||
'count' : 'count',
|
'count' : 'count',
|
||||||
'mins': ['mins', 'minw'],
|
'mins': ['mins', 'minw'],
|
||||||
'maxs': ['maxs', 'maxw'],
|
'maxs': ['maxs', 'maxw'],
|
||||||
'avgs': ['avgs', 'avgw'],
|
'avgs': ['avgs', 'avgw'],
|
||||||
'sums': ['sums', 'sumw'],
|
'sums': ['sums', 'sumw'],
|
||||||
}
|
}
|
||||||
|
|
||||||
binary_ops = {
|
binary_ops = {
|
||||||
'sub':'-',
|
'sub':'-',
|
||||||
'add':'+',
|
'add':'+',
|
||||||
'mul':'*',
|
'mul':'*',
|
||||||
'div':'/',
|
'div':'/',
|
||||||
'mod':'%',
|
'mod':'%',
|
||||||
'and':'&&',
|
'and':'&&',
|
||||||
'or':'||',
|
'or':'||',
|
||||||
'xor' : '^',
|
'xor' : '^',
|
||||||
'gt':'>',
|
'gt':'>',
|
||||||
'lt':'<',
|
'lt':'<',
|
||||||
'lte':'<=',
|
'lte':'<=',
|
||||||
'gte':'>=',
|
'gte':'>=',
|
||||||
'neq':'!=',
|
'neq':'!=',
|
||||||
'eq':'=='
|
'eq':'=='
|
||||||
}
|
}
|
||||||
|
|
||||||
compound_ops = {
|
compound_ops = {
|
||||||
'missing' : ['missing', lambda x: f'{x[0]} == nullval<decays<decltype({x[0]})>>'],
|
'missing' : ['missing', lambda x: f'{x[0]} == nullval<decays<decltype({x[0]})>>'],
|
||||||
}
|
}
|
||||||
|
|
||||||
unary_ops = {
|
unary_ops = {
|
||||||
'neg' : '-',
|
'neg' : '-',
|
||||||
'not' : '!'
|
'not' : '!'
|
||||||
}
|
}
|
||||||
|
|
||||||
coumpound_generating_ops = ['avgs', 'mins', 'maxs', 'sums'] + \
|
coumpound_generating_ops = ['avgs', 'mins', 'maxs', 'sums'] + \
|
||||||
list( binary_ops.keys()) + list(compound_ops.keys()) + list(unary_ops.keys() )
|
list( binary_ops.keys()) + list(compound_ops.keys()) + list(unary_ops.keys() )
|
||||||
|
|
||||||
def __init__(self, parent, node, materialize_cols = True, abs_col = False):
|
def __init__(self, parent, node, materialize_cols = True, abs_col = False):
|
||||||
self.materialize_cols = materialize_cols
|
self.materialize_cols = materialize_cols
|
||||||
self.raw_col = None
|
self.raw_col = None
|
||||||
self.__abs = abs_col
|
self.__abs = abs_col
|
||||||
self.inside_agg = False
|
self.inside_agg = False
|
||||||
if(type(parent) is expr):
|
if(type(parent) is expr):
|
||||||
self.inside_agg = parent.inside_agg
|
self.inside_agg = parent.inside_agg
|
||||||
self.__abs = parent.__abs
|
self.__abs = parent.__abs
|
||||||
ast_node.__init__(self, parent, node, None)
|
ast_node.__init__(self, parent, node, None)
|
||||||
|
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
from engine.projection import projection
|
from engine.projection import projection
|
||||||
parent = self.parent
|
parent = self.parent
|
||||||
self.isvector = parent.isvector if type(parent) is expr else False
|
self.isvector = parent.isvector if type(parent) is expr else False
|
||||||
self.is_compound = parent.is_compound 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]:
|
if type(parent) in [projection, expr]:
|
||||||
self.datasource = parent.datasource
|
self.datasource = parent.datasource
|
||||||
else:
|
else:
|
||||||
self.datasource = self.context.datasource
|
self.datasource = self.context.datasource
|
||||||
self.udf_map = parent.context.udf_map
|
self.udf_map = parent.context.udf_map
|
||||||
self._expr = ''
|
self._expr = ''
|
||||||
self.cexpr = None
|
self.cexpr = None
|
||||||
self.func_maps = {**self.udf_map, **self.builtin_func_maps}
|
self.func_maps = {**self.udf_map, **self.builtin_func_maps}
|
||||||
|
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
if type(node) is dict:
|
if type(node) is dict:
|
||||||
for key, val in node.items():
|
for key, val in node.items():
|
||||||
if key in self.func_maps:
|
if key in self.func_maps:
|
||||||
# TODO: distinguish between UDF agg functions and other UDF functions.
|
# TODO: distinguish between UDF agg functions and other UDF functions.
|
||||||
self.inside_agg = True
|
self.inside_agg = True
|
||||||
self.context.headers.add('"./server/aggregations.h"')
|
self.context.headers.add('"./server/aggregations.h"')
|
||||||
if type(val) is list and len(val) > 1:
|
if type(val) is list and len(val) > 1:
|
||||||
cfunc = self.func_maps[key]
|
cfunc = self.func_maps[key]
|
||||||
cfunc = cfunc[len(val) - 1] if type(cfunc) is list else cfunc
|
cfunc = cfunc[len(val) - 1] if type(cfunc) is list else cfunc
|
||||||
self._expr += f"{cfunc}("
|
self._expr += f"{cfunc}("
|
||||||
for i, p in enumerate(val):
|
for i, p in enumerate(val):
|
||||||
self._expr += expr(self, p)._expr + (','if i<len(val)-1 else '')
|
self._expr += expr(self, p)._expr + (','if i<len(val)-1 else '')
|
||||||
else:
|
else:
|
||||||
funcname = self.func_maps[key]
|
funcname = self.func_maps[key]
|
||||||
funcname = funcname[0] if type(funcname) is list else funcname
|
funcname = funcname[0] if type(funcname) is list else funcname
|
||||||
self._expr += f"{funcname}("
|
self._expr += f"{funcname}("
|
||||||
self._expr += expr(self, val)._expr
|
self._expr += expr(self, val)._expr
|
||||||
self._expr += ')'
|
self._expr += ')'
|
||||||
self.inside_agg = False
|
self.inside_agg = False
|
||||||
elif key in self.binary_ops:
|
elif key in self.binary_ops:
|
||||||
l = expr(self, val[0])._expr
|
l = expr(self, val[0])._expr
|
||||||
r = expr(self, val[1])._expr
|
r = expr(self, val[1])._expr
|
||||||
self._expr += f'({l}{self.binary_ops[key]}{r})'
|
self._expr += f'({l}{self.binary_ops[key]}{r})'
|
||||||
elif key in self.compound_ops:
|
elif key in self.compound_ops:
|
||||||
x = []
|
x = []
|
||||||
if type(val) is list:
|
if type(val) is list:
|
||||||
for v in val:
|
for v in val:
|
||||||
x.append(expr(self, v)._expr)
|
x.append(expr(self, v)._expr)
|
||||||
self._expr = self.compound_ops[key][1](x)
|
self._expr = self.compound_ops[key][1](x)
|
||||||
elif key in self.unary_ops:
|
elif key in self.unary_ops:
|
||||||
self._expr += f'{self.unary_ops[key]}({expr(self, val)._expr})'
|
self._expr += f'{self.unary_ops[key]}({expr(self, val)._expr})'
|
||||||
else:
|
else:
|
||||||
self.context.Error(f'Undefined expr: {key}{val}')
|
self.context.Error(f'Undefined expr: {key}{val}')
|
||||||
|
|
||||||
if key in self.coumpound_generating_ops and not self.is_compound:
|
if key in self.coumpound_generating_ops and not self.is_compound:
|
||||||
self.is_compound = True
|
self.is_compound = True
|
||||||
p = self.parent
|
p = self.parent
|
||||||
while type(p) is expr and not p.is_compound:
|
while type(p) is expr and not p.is_compound:
|
||||||
p.is_compound = True
|
p.is_compound = True
|
||||||
p = p.parent
|
p = p.parent
|
||||||
|
|
||||||
elif type(node) is str:
|
elif type(node) is str:
|
||||||
p = self.parent
|
p = self.parent
|
||||||
while type(p) is expr and not p.isvector:
|
while type(p) is expr and not p.isvector:
|
||||||
p.isvector = True
|
p.isvector = True
|
||||||
p = p.parent
|
p = p.parent
|
||||||
|
|
||||||
self._expr, self.raw_col = self.datasource.parse_col_names(node, self.materialize_cols, True)
|
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
|
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
||||||
if self.__abs and self.raw_col:
|
if self.__abs and self.raw_col:
|
||||||
self._expr = self.raw_col.reference() + ("" if self.inside_agg else index_expr)
|
self._expr = self.raw_col.reference() + ("" if self.inside_agg else index_expr)
|
||||||
elif type(node) is bool:
|
elif type(node) is bool:
|
||||||
self._expr = '1' if node else '0'
|
self._expr = '1' if node else '0'
|
||||||
else:
|
else:
|
||||||
self._expr = f'{node}'
|
self._expr = f'{node}'
|
||||||
def toCExpr(_expr):
|
def toCExpr(_expr):
|
||||||
return lambda x = None, y = None : eval(start_expr + _expr + end_expr)
|
return lambda x = None, y = None : eval(start_expr + _expr + end_expr)
|
||||||
def consume(self, _):
|
def consume(self, _):
|
||||||
self.cexpr = expr.toCExpr(self._expr)
|
self.cexpr = expr.toCExpr(self._expr)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.cexpr
|
return self.cexpr
|
||||||
|
|
@ -1,72 +1,72 @@
|
|||||||
from engine.ast import ColRef, TableInfo, ast_node
|
from engine.ast import ColRef, TableInfo, ast_node
|
||||||
from engine.orderby import assumption
|
from engine.orderby import assumption
|
||||||
from engine.scan import scan
|
from engine.scan import scan
|
||||||
from engine.utils import base62uuid
|
from engine.utils import base62uuid
|
||||||
from engine.expr import expr
|
from engine.expr import expr
|
||||||
|
|
||||||
class groupby(ast_node):
|
class groupby(ast_node):
|
||||||
name = '_groupby'
|
name = '_groupby'
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
self.context.headers.add('"./server/hasher.h"')
|
self.context.headers.add('"./server/hasher.h"')
|
||||||
self.context.headers.add('unordered_map')
|
self.context.headers.add('unordered_map')
|
||||||
self.group = 'g' + base62uuid(7)
|
self.group = 'g' + base62uuid(7)
|
||||||
self.group_type = 'record_type' + base62uuid(7)
|
self.group_type = 'record_type' + base62uuid(7)
|
||||||
self.datasource = self.parent.datasource
|
self.datasource = self.parent.datasource
|
||||||
self.scanner = None
|
self.scanner = None
|
||||||
self.datasource.rec = set()
|
self.datasource.rec = set()
|
||||||
self.raw_groups = []
|
self.raw_groups = []
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
|
|
||||||
if type(node) is not list:
|
if type(node) is not list:
|
||||||
node = [node]
|
node = [node]
|
||||||
g_contents = ''
|
g_contents = ''
|
||||||
g_contents_list = []
|
g_contents_list = []
|
||||||
first_col = ''
|
first_col = ''
|
||||||
for i, g in enumerate(node):
|
for i, g in enumerate(node):
|
||||||
v = g['value']
|
v = g['value']
|
||||||
e = expr(self, v)
|
e = expr(self, v)
|
||||||
if type(e.raw_col) is ColRef:
|
if type(e.raw_col) is ColRef:
|
||||||
self.raw_groups.append(e.raw_col)
|
self.raw_groups.append(e.raw_col)
|
||||||
e = e._expr
|
e = e._expr
|
||||||
# if v is compound expr, create tmp cols
|
# if v is compound expr, create tmp cols
|
||||||
if type(v) is not str:
|
if type(v) is not str:
|
||||||
tmpcol = 't' + base62uuid(7)
|
tmpcol = 't' + base62uuid(7)
|
||||||
self.emit(f'auto {tmpcol} = {e};')
|
self.emit(f'auto {tmpcol} = {e};')
|
||||||
e = tmpcol
|
e = tmpcol
|
||||||
if i == 0:
|
if i == 0:
|
||||||
first_col = e
|
first_col = e
|
||||||
g_contents_list.append(e)
|
g_contents_list.append(e)
|
||||||
g_contents_decltype = [f'decltype({c})' for c in g_contents_list]
|
g_contents_decltype = [f'decltype({c})' for c in g_contents_list]
|
||||||
g_contents = expr.toCExpr(','.join(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'typedef record<{expr.toCExpr(",".join(g_contents_decltype))(0)}> {self.group_type};')
|
||||||
self.emit(f'unordered_map<{self.group_type}, vector_type<uint32_t>, '
|
self.emit(f'unordered_map<{self.group_type}, vector_type<uint32_t>, '
|
||||||
f'transTypes<{self.group_type}, hasher>> {self.group};')
|
f'transTypes<{self.group_type}, hasher>> {self.group};')
|
||||||
self.n_grps = len(node)
|
self.n_grps = len(node)
|
||||||
self.scanner = scan(self, self.datasource, expr.toCExpr(first_col)()+'.size')
|
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});')
|
self.scanner.add(f'{self.group}[forward_as_tuple({g_contents(self.scanner.it_ver)})].emplace_back({self.scanner.it_ver});')
|
||||||
|
|
||||||
|
|
||||||
def consume(self, _):
|
def consume(self, _):
|
||||||
self.referenced = self.datasource.rec
|
self.referenced = self.datasource.rec
|
||||||
self.datasource.rec = None
|
self.datasource.rec = None
|
||||||
self.scanner.finalize()
|
self.scanner.finalize()
|
||||||
|
|
||||||
def deal_with_assumptions(self, assumption:assumption, out:TableInfo):
|
def deal_with_assumptions(self, assumption:assumption, out:TableInfo):
|
||||||
gscanner = scan(self, self.group)
|
gscanner = scan(self, self.group)
|
||||||
val_var = 'val_'+base62uuid(7)
|
val_var = 'val_'+base62uuid(7)
|
||||||
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
||||||
gscanner.add(f'{self.datasource.cxt_name}->order_by<{assumption.result()}>(&{val_var});')
|
gscanner.add(f'{self.datasource.cxt_name}->order_by<{assumption.result()}>(&{val_var});')
|
||||||
gscanner.finalize()
|
gscanner.finalize()
|
||||||
|
|
||||||
def finalize(self, cexprs, out:TableInfo):
|
def finalize(self, cexprs, out:TableInfo):
|
||||||
gscanner = scan(self, self.group)
|
gscanner = scan(self, self.group)
|
||||||
key_var = 'key_'+base62uuid(7)
|
key_var = 'key_'+base62uuid(7)
|
||||||
val_var = 'val_'+base62uuid(7)
|
val_var = 'val_'+base62uuid(7)
|
||||||
|
|
||||||
gscanner.add(f'auto &{key_var} = {gscanner.it_ver}.first;')
|
gscanner.add(f'auto &{key_var} = {gscanner.it_ver}.first;')
|
||||||
gscanner.add(f'auto &{val_var} = {gscanner.it_ver}.second;')
|
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.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()
|
gscanner.finalize()
|
||||||
|
|
||||||
self.datasource.groupinfo = None
|
self.datasource.groupinfo = None
|
@ -1,6 +1,6 @@
|
|||||||
from engine.ast import ast_node
|
from engine.ast import ast_node
|
||||||
|
|
||||||
|
|
||||||
class join(ast_node):
|
class join(ast_node):
|
||||||
name='join'
|
name='join'
|
||||||
|
|
@ -1,180 +1,180 @@
|
|||||||
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
from engine.ast import ColRef, TableInfo, ast_node, Context, include
|
||||||
from engine.groupby import groupby
|
from engine.groupby import groupby
|
||||||
from engine.join import join
|
from engine.join import join
|
||||||
from engine.expr import expr
|
from engine.expr import expr
|
||||||
from engine.orderby import assumption, orderby
|
from engine.orderby import assumption, orderby
|
||||||
from engine.scan import filter
|
from engine.scan import filter
|
||||||
from engine.utils import base62uuid, enlist, base62alp, has_other
|
from engine.utils import base62uuid, enlist, base62alp, has_other
|
||||||
from engine.ddl import create_table, outfile
|
from engine.ddl import create_table, outfile
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
class projection(ast_node):
|
class projection(ast_node):
|
||||||
name='select'
|
name='select'
|
||||||
def __init__(self, parent:ast_node, node, context:Context = None, outname = None, disp = True):
|
def __init__(self, parent:ast_node, node, context:Context = None, outname = None, disp = True):
|
||||||
self.disp = disp
|
self.disp = disp
|
||||||
self.outname = outname
|
self.outname = outname
|
||||||
self.group_node = None
|
self.group_node = None
|
||||||
self.assumptions = None
|
self.assumptions = None
|
||||||
self.where = None
|
self.where = None
|
||||||
ast_node.__init__(self, parent, node, context)
|
ast_node.__init__(self, parent, node, context)
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
if self.outname is None:
|
if self.outname is None:
|
||||||
self.outname = self.context.gen_tmptable()
|
self.outname = self.context.gen_tmptable()
|
||||||
|
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
p = node['select']
|
p = node['select']
|
||||||
self.projections = p if type(p) is list else [p]
|
self.projections = p if type(p) is list else [p]
|
||||||
self.context.Info(node)
|
self.context.Info(node)
|
||||||
|
|
||||||
def spawn(self, node):
|
def spawn(self, node):
|
||||||
self.datasource = None
|
self.datasource = None
|
||||||
if 'from' in node:
|
if 'from' in node:
|
||||||
from_clause = node['from']
|
from_clause = node['from']
|
||||||
if type(from_clause) is list:
|
if type(from_clause) is list:
|
||||||
# from joins
|
# from joins
|
||||||
join(self, from_clause)
|
join(self, from_clause)
|
||||||
elif type(from_clause) is dict:
|
elif type(from_clause) is dict:
|
||||||
if 'value' in from_clause:
|
if 'value' in from_clause:
|
||||||
value = from_clause['value']
|
value = from_clause['value']
|
||||||
if type(value) is dict:
|
if type(value) is dict:
|
||||||
if 'select' in value:
|
if 'select' in value:
|
||||||
# from subquery
|
# from subquery
|
||||||
projection(self, from_clause, disp = False)
|
projection(self, from_clause, disp = False)
|
||||||
else:
|
else:
|
||||||
# TODO: from func over table
|
# TODO: from func over table
|
||||||
print(f'from func over table{node}')
|
print(f'from func over table{node}')
|
||||||
elif type(value) is str:
|
elif type(value) is str:
|
||||||
self.datasource = self.context.tables_byname[value]
|
self.datasource = self.context.tables_byname[value]
|
||||||
if 'name' in value:
|
if 'name' in value:
|
||||||
self.datasource.add_alias(value['name'])
|
self.datasource.add_alias(value['name'])
|
||||||
if 'assumptions' in from_clause:
|
if 'assumptions' in from_clause:
|
||||||
self.assumptions = enlist(from_clause['assumptions'])
|
self.assumptions = enlist(from_clause['assumptions'])
|
||||||
|
|
||||||
elif type(from_clause) is str:
|
elif type(from_clause) is str:
|
||||||
self.datasource = self.context.tables_byname[from_clause]
|
self.datasource = self.context.tables_byname[from_clause]
|
||||||
|
|
||||||
if self.datasource is None:
|
if self.datasource is None:
|
||||||
raise ValueError('spawn error: from clause')
|
raise ValueError('spawn error: from clause')
|
||||||
|
|
||||||
if self.datasource is not None:
|
if self.datasource is not None:
|
||||||
self.datasource_changed = True
|
self.datasource_changed = True
|
||||||
self.prev_datasource = self.context.datasource
|
self.prev_datasource = self.context.datasource
|
||||||
self.context.datasource = self.datasource
|
self.context.datasource = self.datasource
|
||||||
if 'where' in node:
|
if 'where' in node:
|
||||||
self.where = filter(self, node['where'], True)
|
self.where = filter(self, node['where'], True)
|
||||||
# self.datasource = filter(self, node['where'], True).output
|
# self.datasource = filter(self, node['where'], True).output
|
||||||
# self.context.datasource = self.datasource
|
# self.context.datasource = self.datasource
|
||||||
|
|
||||||
if 'groupby' in node:
|
if 'groupby' in node:
|
||||||
self.group_node = groupby(self, node['groupby'])
|
self.group_node = groupby(self, node['groupby'])
|
||||||
self.datasource = copy.copy(self.datasource) # shallow copy
|
self.datasource = copy.copy(self.datasource) # shallow copy
|
||||||
self.datasource.groupinfo = self.group_node
|
self.datasource.groupinfo = self.group_node
|
||||||
else:
|
else:
|
||||||
self.group_node = None
|
self.group_node = None
|
||||||
|
|
||||||
def consume(self, node):
|
def consume(self, node):
|
||||||
self.inv = True
|
self.inv = True
|
||||||
disp_varname = 'd'+base62uuid(7)
|
disp_varname = 'd'+base62uuid(7)
|
||||||
has_groupby = self.group_node is not None
|
has_groupby = self.group_node is not None
|
||||||
cexprs = []
|
cexprs = []
|
||||||
flatten = False
|
flatten = False
|
||||||
cols = []
|
cols = []
|
||||||
self.out_table = TableInfo('out_'+base62uuid(4), [], self.context)
|
self.out_table = TableInfo('out_'+base62uuid(4), [], self.context)
|
||||||
if 'outfile' in node:
|
if 'outfile' in node:
|
||||||
flatten = True
|
flatten = True
|
||||||
|
|
||||||
new_names = []
|
new_names = []
|
||||||
proj_raw_cols = []
|
proj_raw_cols = []
|
||||||
for i, proj in enumerate(self.projections):
|
for i, proj in enumerate(self.projections):
|
||||||
cname = ''
|
cname = ''
|
||||||
compound = False
|
compound = False
|
||||||
self.datasource.rec = set()
|
self.datasource.rec = set()
|
||||||
if type(proj) is dict:
|
if type(proj) is dict:
|
||||||
if 'value' in proj:
|
if 'value' in proj:
|
||||||
e = proj['value']
|
e = proj['value']
|
||||||
sname = expr(self, e)
|
sname = expr(self, e)
|
||||||
if type(sname.raw_col) is ColRef:
|
if type(sname.raw_col) is ColRef:
|
||||||
proj_raw_cols.append(sname.raw_col)
|
proj_raw_cols.append(sname.raw_col)
|
||||||
sname = sname._expr
|
sname = sname._expr
|
||||||
fname = expr.toCExpr(sname) # fastest access method at innermost context
|
fname = expr.toCExpr(sname) # fastest access method at innermost context
|
||||||
absname = expr(self, e, abs_col=True)._expr # absolute name at function scope
|
absname = expr(self, e, abs_col=True)._expr # absolute name at function scope
|
||||||
# TODO: Make it single pass here.
|
# TODO: Make it single pass here.
|
||||||
compound = True # compound column
|
compound = True # compound column
|
||||||
cexprs.append(fname)
|
cexprs.append(fname)
|
||||||
cname = e if type(e) is str else ''.join([a if a in base62alp else '' for a in expr.toCExpr(absname)()])
|
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
|
if 'name' in proj: # renaming column by AS keyword
|
||||||
cname = proj['name']
|
cname = proj['name']
|
||||||
new_names.append(cname)
|
new_names.append(cname)
|
||||||
elif type(proj) is str:
|
elif type(proj) is str:
|
||||||
col = self.datasource.get_col_d(proj)
|
col = self.datasource.get_col_d(proj)
|
||||||
if type(col) is ColRef:
|
if type(col) is ColRef:
|
||||||
col.reference()
|
col.reference()
|
||||||
|
|
||||||
compound = compound and has_groupby and has_other(self.datasource.rec, self.group_node.referenced)
|
compound = compound and has_groupby and has_other(self.datasource.rec, self.group_node.referenced)
|
||||||
self.datasource.rec = None
|
self.datasource.rec = None
|
||||||
|
|
||||||
typename = f'decays<decltype({absname})>'
|
typename = f'decays<decltype({absname})>'
|
||||||
if not compound:
|
if not compound:
|
||||||
typename = f'value_type<{typename}>'
|
typename = f'value_type<{typename}>'
|
||||||
|
|
||||||
cols.append(ColRef(cname, expr.toCExpr(typename)(), self.out_table, 0, None, cname, i, compound=compound))
|
cols.append(ColRef(cname, expr.toCExpr(typename)(), self.out_table, 0, None, cname, i, compound=compound))
|
||||||
|
|
||||||
self.out_table.add_cols(cols, False)
|
self.out_table.add_cols(cols, False)
|
||||||
|
|
||||||
lineage = None
|
lineage = None
|
||||||
|
|
||||||
if has_groupby:
|
if has_groupby:
|
||||||
create_table(self, self.out_table) # creates empty out_table.
|
create_table(self, self.out_table) # creates empty out_table.
|
||||||
if self.assumptions is not None:
|
if self.assumptions is not None:
|
||||||
self.assumptions = assumption(self, self.assumptions, exclude=self.group_node.raw_groups)
|
self.assumptions = assumption(self, self.assumptions, exclude=self.group_node.raw_groups)
|
||||||
if not self.assumptions.empty():
|
if not self.assumptions.empty():
|
||||||
self.group_node.deal_with_assumptions(self.assumptions, self.out_table)
|
self.group_node.deal_with_assumptions(self.assumptions, self.out_table)
|
||||||
self.assumptions = None
|
self.assumptions = None
|
||||||
self.group_node.finalize(cexprs, self.out_table)
|
self.group_node.finalize(cexprs, self.out_table)
|
||||||
else:
|
else:
|
||||||
# if all assumptions in projections, treat as orderby
|
# if all assumptions in projections, treat as orderby
|
||||||
lineage = self.assumptions is not None and has_other(self.assumptions, proj_raw_cols)
|
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.
|
spawn = create_table(self, self.out_table, cexprs = cexprs, lineage = lineage) # create and populate out_table.
|
||||||
if lineage and type(spawn.lineage) is str:
|
if lineage and type(spawn.lineage) is str:
|
||||||
lineage = spawn.lineage
|
lineage = spawn.lineage
|
||||||
self.assumptions = orderby(self, self.assumptions) # do not exclude proj_raw_cols
|
self.assumptions = orderby(self, self.assumptions) # do not exclude proj_raw_cols
|
||||||
else:
|
else:
|
||||||
lineage = None
|
lineage = None
|
||||||
if self.where is not None:
|
if self.where is not None:
|
||||||
self.where.finalize()
|
self.where.finalize()
|
||||||
|
|
||||||
if type(lineage) is str:
|
if type(lineage) is str:
|
||||||
order = 'order_' + base62uuid(6)
|
order = 'order_' + base62uuid(6)
|
||||||
self.emit(f'auto {order} = {self.datasource.cxt_name}->order_by<{self.assumptions.result()}>({lineage});')
|
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.emit(f'{self.out_table.cxt_name}->materialize(*{order});')
|
||||||
self.assumptions = None
|
self.assumptions = None
|
||||||
|
|
||||||
if self.assumptions is not None:
|
if self.assumptions is not None:
|
||||||
orderby_node = orderby(self, self.assumptions)
|
orderby_node = orderby(self, self.assumptions)
|
||||||
else:
|
else:
|
||||||
orderby_node = None
|
orderby_node = None
|
||||||
|
|
||||||
if 'orderby' in node:
|
if 'orderby' in node:
|
||||||
self.datasource = self.out_table
|
self.datasource = self.out_table
|
||||||
self.context.datasource = self.out_table # discard current ds
|
self.context.datasource = self.out_table # discard current ds
|
||||||
orderbys = node['orderby']
|
orderbys = node['orderby']
|
||||||
orderby_node = orderby(self, orderbys) if orderby_node is None else orderby_node.merge(orderbys)
|
orderby_node = orderby(self, orderbys) if orderby_node is None else orderby_node.merge(orderbys)
|
||||||
|
|
||||||
if orderby_node is not None:
|
if orderby_node is not None:
|
||||||
self.emit(f'auto {disp_varname} = {self.out_table.reference()}->order_by_view<{orderby_node.result()}>();')
|
self.emit(f'auto {disp_varname} = {self.out_table.reference()}->order_by_view<{orderby_node.result()}>();')
|
||||||
else:
|
else:
|
||||||
disp_varname = f'*{self.out_table.cxt_name}'
|
disp_varname = f'*{self.out_table.cxt_name}'
|
||||||
|
|
||||||
if self.disp:
|
if self.disp:
|
||||||
self.emit(f'print({disp_varname});')
|
self.emit(f'print({disp_varname});')
|
||||||
|
|
||||||
|
|
||||||
if flatten:
|
if flatten:
|
||||||
outfile(self, node['outfile'])
|
outfile(self, node['outfile'])
|
||||||
|
|
||||||
if self.datasource_changed:
|
if self.datasource_changed:
|
||||||
self.context.datasource = self.prev_datasource
|
self.context.datasource = self.prev_datasource
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
include(sys.modules[__name__])
|
include(sys.modules[__name__])
|
@ -1,99 +1,99 @@
|
|||||||
from xmlrpc.client import Boolean
|
from xmlrpc.client import Boolean
|
||||||
from engine.ast import ColRef, TableInfo, View, ast_node, Context
|
from engine.ast import ColRef, TableInfo, View, ast_node, Context
|
||||||
from engine.utils import base62uuid
|
from engine.utils import base62uuid
|
||||||
from engine.expr import expr
|
from engine.expr import expr
|
||||||
|
|
||||||
class scan(ast_node):
|
class scan(ast_node):
|
||||||
name = 'scan'
|
name = 'scan'
|
||||||
def __init__(self, parent: "ast_node", node, size = None, context: Context = None, const = False):
|
def __init__(self, parent: "ast_node", node, size = None, context: Context = None, const = False):
|
||||||
self.type = type
|
self.type = type
|
||||||
self.size = size
|
self.size = size
|
||||||
self.const = "const " if const else ""
|
self.const = "const " if const else ""
|
||||||
super().__init__(parent, node, context)
|
super().__init__(parent, node, context)
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
self.datasource = self.context.datasource
|
self.datasource = self.context.datasource
|
||||||
self.initializers = ''
|
self.initializers = ''
|
||||||
self.start = ''
|
self.start = ''
|
||||||
self.front = ''
|
self.front = ''
|
||||||
self.body = ''
|
self.body = ''
|
||||||
self.end = '}'
|
self.end = '}'
|
||||||
self.mode = None
|
self.mode = None
|
||||||
self.filters = []
|
self.filters = []
|
||||||
scan_vars = set(s.it_var for s in self.context.scans)
|
scan_vars = set(s.it_var for s in self.context.scans)
|
||||||
self.it_ver = 'i' + base62uuid(2)
|
self.it_ver = 'i' + base62uuid(2)
|
||||||
while(self.it_ver in scan_vars):
|
while(self.it_ver in scan_vars):
|
||||||
self.it_ver = 'i' + base62uuid(6)
|
self.it_ver = 'i' + base62uuid(6)
|
||||||
self.parent.context.scans.append(self)
|
self.parent.context.scans.append(self)
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
if type(node) is ColRef:
|
if type(node) is ColRef:
|
||||||
self.colref = node
|
self.colref = node
|
||||||
if self.size is None:
|
if self.size is None:
|
||||||
self.mode = ["col", node.table]
|
self.mode = ["col", node.table]
|
||||||
self.start += f'for ({self.const}auto& {self.it_ver} : {node.reference()}) {{\n'
|
self.start += f'for ({self.const}auto& {self.it_ver} : {node.reference()}) {{\n'
|
||||||
else:
|
else:
|
||||||
self.mode = ["idx", node.table]
|
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"
|
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:
|
elif type(node) is str:
|
||||||
self.mode = ["idx", None]
|
self.mode = ["idx", None]
|
||||||
self.start+= f'for({self.const}auto& {self.it_ver} : {node}) {{\n'
|
self.start+= f'for({self.const}auto& {self.it_ver} : {node}) {{\n'
|
||||||
else:
|
else:
|
||||||
self.mode = ["idx", node] # Node is the TableInfo
|
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"
|
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"):
|
def add(self, stmt, position = "body"):
|
||||||
if position == "body":
|
if position == "body":
|
||||||
self.body += stmt + '\n'
|
self.body += stmt + '\n'
|
||||||
elif position == "init":
|
elif position == "init":
|
||||||
self.initializers += stmt + '\n'
|
self.initializers += stmt + '\n'
|
||||||
else:
|
else:
|
||||||
self.front += stmt + '\n'
|
self.front += stmt + '\n'
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
for f in self.filters:
|
for f in self.filters:
|
||||||
self.start += f
|
self.start += f
|
||||||
self.end += '}'
|
self.end += '}'
|
||||||
self.context.remove_scan(self, self.initializers + self.start + self.front + self.body + self.end)
|
self.context.remove_scan(self, self.initializers + self.start + self.front + self.body + self.end)
|
||||||
|
|
||||||
class filter(ast_node):
|
class filter(ast_node):
|
||||||
name = 'filter'
|
name = 'filter'
|
||||||
def __init__(self, parent: "ast_node", node, materialize = False, context = None):
|
def __init__(self, parent: "ast_node", node, materialize = False, context = None):
|
||||||
self.materialize = materialize
|
self.materialize = materialize
|
||||||
super().__init__(parent, node, context)
|
super().__init__(parent, node, context)
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
self.datasource = self.context.datasource
|
self.datasource = self.context.datasource
|
||||||
self.view = View(self.context, self.datasource)
|
self.view = View(self.context, self.datasource)
|
||||||
self.value = None
|
self.value = None
|
||||||
|
|
||||||
def spawn(self, node):
|
def spawn(self, node):
|
||||||
# TODO: deal with subqueries
|
# TODO: deal with subqueries
|
||||||
self.modified_node = node
|
self.modified_node = node
|
||||||
return super().spawn(node)
|
return super().spawn(node)
|
||||||
def __materialize__(self):
|
def __materialize__(self):
|
||||||
if self.materialize:
|
if self.materialize:
|
||||||
cols = [] if self.datasource is None else self.datasource.columns
|
cols = [] if self.datasource is None else self.datasource.columns
|
||||||
self.output = TableInfo('tn'+base62uuid(6), cols, self.context)
|
self.output = TableInfo('tn'+base62uuid(6), cols, self.context)
|
||||||
self.output.construct()
|
self.output.construct()
|
||||||
if type(self.value) is View: # cond filtered on tables.
|
if type(self.value) is View: # cond filtered on tables.
|
||||||
self.emit(f'{self.value.name}:&{self.value.name}')
|
self.emit(f'{self.value.name}:&{self.value.name}')
|
||||||
for o, c in zip(self.output.columns,self.value.table.columns):
|
for o, c in zip(self.output.columns,self.value.table.columns):
|
||||||
self.emit(f'{o.cname}:{c.cname}[{self.value.name}]')
|
self.emit(f'{o.cname}:{c.cname}[{self.value.name}]')
|
||||||
elif self.value is not None: # cond is scalar
|
elif self.value is not None: # cond is scalar
|
||||||
tmpVar = 't'+base62uuid(7)
|
tmpVar = 't'+base62uuid(7)
|
||||||
self.emit(f'{tmpVar}:{self.value}')
|
self.emit(f'{tmpVar}:{self.value}')
|
||||||
for o, c in zip(self.output.columns, self.datasource.columns):
|
for o, c in zip(self.output.columns, self.datasource.columns):
|
||||||
self.emit(f'{o.cname}:$[{tmpVar};{c.cname};()]')
|
self.emit(f'{o.cname}:$[{tmpVar};{c.cname};()]')
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
self.scanner.finalize()
|
self.scanner.finalize()
|
||||||
def consume(self, _):
|
def consume(self, _):
|
||||||
# TODO: optimizations after converting expr to cnf
|
# TODO: optimizations after converting expr to cnf
|
||||||
self.scanner = None
|
self.scanner = None
|
||||||
for s in self.context.scans:
|
for s in self.context.scans:
|
||||||
if self.datasource == s.mode[1]:
|
if self.datasource == s.mode[1]:
|
||||||
self.scanner = s
|
self.scanner = s
|
||||||
break
|
break
|
||||||
if self.scanner is None:
|
if self.scanner is None:
|
||||||
self.scanner = scan(self, self.datasource, self.datasource.get_size())
|
self.scanner = scan(self, self.datasource, self.datasource.get_size())
|
||||||
self.expr = expr(self, self.modified_node)
|
self.expr = expr(self, self.modified_node)
|
||||||
self.scanner.filters.append(f'if ({self.expr.cexpr(self.scanner.it_ver)}) {{\n')
|
self.scanner.filters.append(f'if ({self.expr.cexpr(self.scanner.it_ver)}) {{\n')
|
||||||
|
|
@ -1,93 +1,93 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
lower_alp = 'abcdefghijklmnopqrstuvwxyz'
|
lower_alp = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
upper_alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
upper_alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
nums = '0123456789'
|
nums = '0123456789'
|
||||||
base62alp = nums + lower_alp + upper_alp
|
base62alp = nums + lower_alp + upper_alp
|
||||||
|
|
||||||
reserved_monet = ['month']
|
reserved_monet = ['month']
|
||||||
|
|
||||||
def base62uuid(crop=8):
|
def base62uuid(crop=8):
|
||||||
_id = uuid.uuid4().int
|
_id = uuid.uuid4().int
|
||||||
ret = ''
|
ret = ''
|
||||||
|
|
||||||
while _id:
|
while _id:
|
||||||
ret = base62alp[_id % 62] + ret
|
ret = base62alp[_id % 62] + ret
|
||||||
_id //= 62
|
_id //= 62
|
||||||
|
|
||||||
return ret[:crop] if len(ret) else '0'
|
return ret[:crop] if len(ret) else '0'
|
||||||
|
|
||||||
def get_legal_name(name, lower = True):
|
def get_legal_name(name, lower = True):
|
||||||
if name is not None:
|
if name is not None:
|
||||||
if lower:
|
if lower:
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
name = ''.join([n for n in name if n in base62alp or n == '_'])
|
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('_'):
|
if name is None or len(name) == 0 or set(name) == set('_'):
|
||||||
name = base62uuid(8)
|
name = base62uuid(8)
|
||||||
if(name[0] in nums):
|
if(name[0] in nums):
|
||||||
name = '_' + name
|
name = '_' + name
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def check_legal_name(name):
|
def check_legal_name(name):
|
||||||
all_underscores = True
|
all_underscores = True
|
||||||
for c in name:
|
for c in name:
|
||||||
if c not in base62alp and c != '_':
|
if c not in base62alp and c != '_':
|
||||||
return False
|
return False
|
||||||
if c != '_':
|
if c != '_':
|
||||||
all_underscores = False
|
all_underscores = False
|
||||||
if all_underscores:
|
if all_underscores:
|
||||||
return False
|
return False
|
||||||
if name[0] in nums:
|
if name[0] in nums:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def enlist(l):
|
def enlist(l):
|
||||||
return l if type(l) is list else [l]
|
return l if type(l) is list else [l]
|
||||||
|
|
||||||
def seps(s, i, l):
|
def seps(s, i, l):
|
||||||
return s if i < len(l) - 1 else ''
|
return s if i < len(l) - 1 else ''
|
||||||
|
|
||||||
def has_other(a, b):
|
def has_other(a, b):
|
||||||
for ai in a:
|
for ai in a:
|
||||||
if ai not in b:
|
if ai not in b:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def defval(val, default):
|
def defval(val, default):
|
||||||
return default if val is None else val
|
return default if val is None else val
|
||||||
|
|
||||||
# escape must be readonly
|
# escape must be readonly
|
||||||
from typing import Set
|
from typing import Set
|
||||||
def remove_last(pattern : str, string : str, escape : Set[str] = set()) -> str:
|
def remove_last(pattern : str, string : str, escape : Set[str] = set()) -> str:
|
||||||
idx = string.rfind(pattern)
|
idx = string.rfind(pattern)
|
||||||
if idx == -1:
|
if idx == -1:
|
||||||
return string
|
return string
|
||||||
else:
|
else:
|
||||||
if set(string[idx:]).difference(escape):
|
if set(string[idx:]).difference(escape):
|
||||||
return string
|
return string
|
||||||
else:
|
else:
|
||||||
return string[:idx] + string[idx+1:]
|
return string[:idx] + string[idx+1:]
|
||||||
|
|
||||||
class _Counter:
|
class _Counter:
|
||||||
def __init__(self, cnt):
|
def __init__(self, cnt):
|
||||||
self.cnt = cnt
|
self.cnt = cnt
|
||||||
def inc(self, cnt = 1):
|
def inc(self, cnt = 1):
|
||||||
self.cnt += cnt
|
self.cnt += cnt
|
||||||
cnt = self.cnt - cnt
|
cnt = self.cnt - cnt
|
||||||
return cnt
|
return cnt
|
||||||
|
|
||||||
import re
|
import re
|
||||||
ws = re.compile(r'\s+')
|
ws = re.compile(r'\s+')
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def add_dll_dir(dll: str):
|
def add_dll_dir(dll: str):
|
||||||
import sys
|
import sys
|
||||||
if sys.version_info.major >= 3 and sys.version_info.minor >7 and os.name == 'nt':
|
if sys.version_info.major >= 3 and sys.version_info.minor >7 and os.name == 'nt':
|
||||||
os.add_dll_directory(dll)
|
os.add_dll_directory(dll)
|
||||||
else:
|
else:
|
||||||
os.environ['PATH'] = os.path.abspath(dll) + os.pathsep + os.environ['PATH']
|
os.environ['PATH'] = os.path.abspath(dll) + os.pathsep + os.environ['PATH']
|
||||||
|
|
||||||
nullstream = open(os.devnull, 'w')
|
nullstream = open(os.devnull, 'w')
|
||||||
|
@ -1,466 +1,466 @@
|
|||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* 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
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*
|
*
|
||||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||||
*/
|
*/
|
||||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||||
|
|
||||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#if _MSC_VER < 1900
|
#if _MSC_VER < 1900
|
||||||
#error Versions below Visual Studio 2015 are no longer supported
|
#error Versions below Visual Studio 2015 are no longer supported
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||||
#define HAVE_RAND_S 1
|
#define HAVE_RAND_S 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||||
#define _XOPEN_SOURCE 700
|
#define _XOPEN_SOURCE 700
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
/* 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
|
* versions. We need to include stdlib.h first or else we get
|
||||||
* conflicting declarations. */
|
* conflicting declarations. */
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
#define HAVE_SYS_TYPES_H 1
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* standard C-99 include files */
|
/* standard C-99 include files */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
/* Windows include files */
|
/* Windows include files */
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
/* indicate to sqltypes.h that windows.h has already been included and
|
/* indicate to sqltypes.h that windows.h has already been included and
|
||||||
that it doesn't have to define Windows constants */
|
that it doesn't have to define Windows constants */
|
||||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||||
|
|
||||||
#define NATIVE_WIN32 1
|
#define NATIVE_WIN32 1
|
||||||
|
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#if !defined(WIN32) && (defined(__CYGWIN__) || defined(__MINGW32__))
|
#if !defined(WIN32) && (defined(__CYGWIN__) || defined(__MINGW32__))
|
||||||
#define WIN32 1
|
#define WIN32 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Section: monetdb configure defines
|
// Section: monetdb configure defines
|
||||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||||
/* #undef HAVE_DLFCN_H */
|
/* #undef HAVE_DLFCN_H */
|
||||||
#define HAVE_FCNTL_H 1
|
#define HAVE_FCNTL_H 1
|
||||||
#define HAVE_IO_H 1
|
#define HAVE_IO_H 1
|
||||||
/* #undef HAVE_KVM_H */
|
/* #undef HAVE_KVM_H */
|
||||||
/* #undef HAVE_LIBGEN_H */
|
/* #undef HAVE_LIBGEN_H */
|
||||||
/* #undef HAVE_LIBINTL_H */
|
/* #undef HAVE_LIBINTL_H */
|
||||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||||
/* #undef HAVE_MACH_TASK_H */
|
/* #undef HAVE_MACH_TASK_H */
|
||||||
/* #undef HAVE_MACH_O_DYLD_H */
|
/* #undef HAVE_MACH_O_DYLD_H */
|
||||||
/* #undef HAVE_NETDB_H */
|
/* #undef HAVE_NETDB_H */
|
||||||
/* #undef HAVE_NETINET_IN_H */
|
/* #undef HAVE_NETINET_IN_H */
|
||||||
/* #undef HAVE_POLL_H */
|
/* #undef HAVE_POLL_H */
|
||||||
/* #undef HAVE_PROCFS_H */
|
/* #undef HAVE_PROCFS_H */
|
||||||
/* #undef HAVE_PWD_H */
|
/* #undef HAVE_PWD_H */
|
||||||
/* #undef HAVE_STRINGS_H */
|
/* #undef HAVE_STRINGS_H */
|
||||||
/* #undef HAVE_STROPTS_H */
|
/* #undef HAVE_STROPTS_H */
|
||||||
/* #undef HAVE_SYS_FILE_H */
|
/* #undef HAVE_SYS_FILE_H */
|
||||||
/* #undef HAVE_SYS_IOCTL_H */
|
/* #undef HAVE_SYS_IOCTL_H */
|
||||||
/* #undef HAVE_SYS_SYSCTL_H */
|
/* #undef HAVE_SYS_SYSCTL_H */
|
||||||
/* #undef HAVE_SYS_MMAN_H */
|
/* #undef HAVE_SYS_MMAN_H */
|
||||||
/* #undef HAVE_SYS_PARAM_H */
|
/* #undef HAVE_SYS_PARAM_H */
|
||||||
/* #undef HAVE_SYS_RANDOM_H */
|
/* #undef HAVE_SYS_RANDOM_H */
|
||||||
/* #undef HAVE_SYS_RESOURCE_H */
|
/* #undef HAVE_SYS_RESOURCE_H */
|
||||||
/* #undef HAVE_SYS_TIME_H */
|
/* #undef HAVE_SYS_TIME_H */
|
||||||
/* #undef HAVE_SYS_TIMES_H */
|
/* #undef HAVE_SYS_TIMES_H */
|
||||||
/* #undef HAVE_SYS_UIO_H */
|
/* #undef HAVE_SYS_UIO_H */
|
||||||
/* #undef HAVE_SYS_UN_H */
|
/* #undef HAVE_SYS_UN_H */
|
||||||
/* #undef HAVE_SYS_WAIT_H */
|
/* #undef HAVE_SYS_WAIT_H */
|
||||||
/* #undef HAVE_TERMIOS_H */
|
/* #undef HAVE_TERMIOS_H */
|
||||||
/* #undef HAVE_UNISTD_H */
|
/* #undef HAVE_UNISTD_H */
|
||||||
/* #undef HAVE_UUID_UUID_H */
|
/* #undef HAVE_UUID_UUID_H */
|
||||||
#define HAVE_WINSOCK_H 1
|
#define HAVE_WINSOCK_H 1
|
||||||
/* #undef HAVE_SEMAPHORE_H */
|
/* #undef HAVE_SEMAPHORE_H */
|
||||||
#define HAVE_GETOPT_H 1
|
#define HAVE_GETOPT_H 1
|
||||||
|
|
||||||
/* #undef HAVE_STDATOMIC_H */
|
/* #undef HAVE_STDATOMIC_H */
|
||||||
|
|
||||||
/* #undef HAVE_DIRENT_H */
|
/* #undef HAVE_DIRENT_H */
|
||||||
/* #undef HAVE_SYS_SOCKET_H */
|
/* #undef HAVE_SYS_SOCKET_H */
|
||||||
/* #undef HAVE_GETTIMEOFDAY */
|
/* #undef HAVE_GETTIMEOFDAY */
|
||||||
#define HAVE_SYS_STAT_H 1
|
#define HAVE_SYS_STAT_H 1
|
||||||
/* #undef HAVE_FDATASYNC */
|
/* #undef HAVE_FDATASYNC */
|
||||||
/* #undef HAVE_ACCEPT4 */
|
/* #undef HAVE_ACCEPT4 */
|
||||||
/* #undef HAVE_ASCTIME_R */
|
/* #undef HAVE_ASCTIME_R */
|
||||||
/* #undef HAVE_CLOCK_GETTIME */
|
/* #undef HAVE_CLOCK_GETTIME */
|
||||||
/* #undef HAVE_CTIME_R */
|
/* #undef HAVE_CTIME_R */
|
||||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||||
/* #undef HAVE_FALLOCATE */
|
/* #undef HAVE_FALLOCATE */
|
||||||
/* #undef HAVE_FCNTL */
|
/* #undef HAVE_FCNTL */
|
||||||
/* #undef HAVE_FORK */
|
/* #undef HAVE_FORK */
|
||||||
/* #undef HAVE_FSYNC */
|
/* #undef HAVE_FSYNC */
|
||||||
#define HAVE_FTIME 1
|
#define HAVE_FTIME 1
|
||||||
/* #undef HAVE_GETENTROPY */
|
/* #undef HAVE_GETENTROPY */
|
||||||
/* #undef HAVE_GETEXECNAME */
|
/* #undef HAVE_GETEXECNAME */
|
||||||
/* #undef HAVE_GETLOGIN */
|
/* #undef HAVE_GETLOGIN */
|
||||||
#define HAVE_GETOPT_LONG 1
|
#define HAVE_GETOPT_LONG 1
|
||||||
/* #undef HAVE_GETRLIMIT */
|
/* #undef HAVE_GETRLIMIT */
|
||||||
/* #undef HAVE_GETTIMEOFDAY */
|
/* #undef HAVE_GETTIMEOFDAY */
|
||||||
/* #undef HAVE_GETUID */
|
/* #undef HAVE_GETUID */
|
||||||
/* #undef HAVE_GMTIME_R */
|
/* #undef HAVE_GMTIME_R */
|
||||||
/* #undef HAVE_LOCALTIME_R */
|
/* #undef HAVE_LOCALTIME_R */
|
||||||
/* #undef HAVE_STRERROR_R */
|
/* #undef HAVE_STRERROR_R */
|
||||||
/* #undef HAVE_LOCKF */
|
/* #undef HAVE_LOCKF */
|
||||||
/* #undef HAVE_MADVISE */
|
/* #undef HAVE_MADVISE */
|
||||||
/* #undef HAVE_MREMAP */
|
/* #undef HAVE_MREMAP */
|
||||||
/* #undef HAVE_NANOSLEEP */
|
/* #undef HAVE_NANOSLEEP */
|
||||||
/* #undef HAVE_NL_LANGINFO */
|
/* #undef HAVE_NL_LANGINFO */
|
||||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||||
/* #undef HAVE_PIPE2 */
|
/* #undef HAVE_PIPE2 */
|
||||||
/* #undef HAVE_POLL */
|
/* #undef HAVE_POLL */
|
||||||
/* #undef HAVE_POPEN */
|
/* #undef HAVE_POPEN */
|
||||||
/* #undef HAVE_POSIX_FADVISE */
|
/* #undef HAVE_POSIX_FADVISE */
|
||||||
/* #undef HAVE_POSIX_FALLOCATE */
|
/* #undef HAVE_POSIX_FALLOCATE */
|
||||||
/* #undef HAVE_POSIX_MADVISE */
|
/* #undef HAVE_POSIX_MADVISE */
|
||||||
#define HAVE_PUTENV 1
|
#define HAVE_PUTENV 1
|
||||||
/* #undef HAVE_SETSID */
|
/* #undef HAVE_SETSID */
|
||||||
#define HAVE_SHUTDOWN 1
|
#define HAVE_SHUTDOWN 1
|
||||||
/* #undef HAVE_SIGACTION */
|
/* #undef HAVE_SIGACTION */
|
||||||
/* #undef HAVE_STPCPY */
|
/* #undef HAVE_STPCPY */
|
||||||
/* #undef HAVE_STRCASESTR */
|
/* #undef HAVE_STRCASESTR */
|
||||||
/* #undef HAVE_STRNCASECMP */
|
/* #undef HAVE_STRNCASECMP */
|
||||||
/* #undef HAVE_STRPTIME */
|
/* #undef HAVE_STRPTIME */
|
||||||
/* #undef HAVE_STRSIGNAL */
|
/* #undef HAVE_STRSIGNAL */
|
||||||
/* #undef HAVE_SYSCONF */
|
/* #undef HAVE_SYSCONF */
|
||||||
/* #undef HAVE_TASK_INFO */
|
/* #undef HAVE_TASK_INFO */
|
||||||
/* #undef HAVE_TIMES */
|
/* #undef HAVE_TIMES */
|
||||||
/* #undef HAVE_UNAME */
|
/* #undef HAVE_UNAME */
|
||||||
/* #undef HAVE_SEMTIMEDOP */
|
/* #undef HAVE_SEMTIMEDOP */
|
||||||
/* #undef HAVE_PTHREAD_KILL */
|
/* #undef HAVE_PTHREAD_KILL */
|
||||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||||
#define HAVE_GETOPT 1
|
#define HAVE_GETOPT 1
|
||||||
|
|
||||||
#define ICONV_CONST
|
#define ICONV_CONST
|
||||||
#define FLEXIBLE_ARRAY_MEMBER
|
#define FLEXIBLE_ARRAY_MEMBER
|
||||||
#define ENABLE_MAPI 1
|
#define ENABLE_MAPI 1
|
||||||
#define HAVE_MAPI 1
|
#define HAVE_MAPI 1
|
||||||
// End Section: monetdb configure defines
|
// End Section: monetdb configure defines
|
||||||
|
|
||||||
// Section: monetdb macro variables
|
// Section: monetdb macro variables
|
||||||
#define HAVE_ICONV 1
|
#define HAVE_ICONV 1
|
||||||
/* #undef HAVE_PTHREAD_H */
|
/* #undef HAVE_PTHREAD_H */
|
||||||
#define HAVE_LIBPCRE 1
|
#define HAVE_LIBPCRE 1
|
||||||
#define HAVE_LIBBZ2 1
|
#define HAVE_LIBBZ2 1
|
||||||
/* #undef HAVE_CURL */
|
/* #undef HAVE_CURL */
|
||||||
#define HAVE_LIBLZMA 1
|
#define HAVE_LIBLZMA 1
|
||||||
#define HAVE_LIBXML 1
|
#define HAVE_LIBXML 1
|
||||||
#define HAVE_LIBZ 1
|
#define HAVE_LIBZ 1
|
||||||
#define HAVE_LIBLZ4 1
|
#define HAVE_LIBLZ4 1
|
||||||
/* #undef HAVE_PROJ */
|
/* #undef HAVE_PROJ */
|
||||||
/* #undef HAVE_SNAPPY */
|
/* #undef HAVE_SNAPPY */
|
||||||
/* #undef HAVE_FITS */
|
/* #undef HAVE_FITS */
|
||||||
/* #undef HAVE_UUID */
|
/* #undef HAVE_UUID */
|
||||||
/* #undef HAVE_VALGRIND */
|
/* #undef HAVE_VALGRIND */
|
||||||
/* #undef HAVE_NETCDF */
|
/* #undef HAVE_NETCDF */
|
||||||
/* #undef HAVE_READLINE */
|
/* #undef HAVE_READLINE */
|
||||||
/* #undef HAVE_LIBR */
|
/* #undef HAVE_LIBR */
|
||||||
#define RHOME "/registry"
|
#define RHOME "/registry"
|
||||||
#define HAVE_GEOM 1
|
#define HAVE_GEOM 1
|
||||||
/* #undef HAVE_SHP */
|
/* #undef HAVE_SHP */
|
||||||
#define HAVE_LIBPY3 1
|
#define HAVE_LIBPY3 1
|
||||||
|
|
||||||
// #define SOCKET_LIBRARIES
|
// #define SOCKET_LIBRARIES
|
||||||
#define HAVE_GETADDRINFO 1
|
#define HAVE_GETADDRINFO 1
|
||||||
/* #undef HAVE_CUDF */
|
/* #undef HAVE_CUDF */
|
||||||
|
|
||||||
#define MAPI_PORT 50000
|
#define MAPI_PORT 50000
|
||||||
#define MAPI_PORT_STR "50000"
|
#define MAPI_PORT_STR "50000"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define DIR_SEP '\\'
|
#define DIR_SEP '\\'
|
||||||
#define PATH_SEP ';'
|
#define PATH_SEP ';'
|
||||||
#define DIR_SEP_STR "\\"
|
#define DIR_SEP_STR "\\"
|
||||||
#define SO_PREFIX ""
|
#define SO_PREFIX ""
|
||||||
#else
|
#else
|
||||||
#define DIR_SEP '/'
|
#define DIR_SEP '/'
|
||||||
#define PATH_SEP ':'
|
#define PATH_SEP ':'
|
||||||
#define DIR_SEP_STR "/"
|
#define DIR_SEP_STR "/"
|
||||||
/* #undef SO_PREFIX */
|
/* #undef SO_PREFIX */
|
||||||
#endif
|
#endif
|
||||||
#define SO_EXT ".dll"
|
#define SO_EXT ".dll"
|
||||||
|
|
||||||
#define BINDIR "C:/cygwin64/home/monet/x86_64/install/bin"
|
#define BINDIR "C:/cygwin64/home/monet/x86_64/install/bin"
|
||||||
#define LIBDIR "C:/cygwin64/home/monet/x86_64/install/lib"
|
#define LIBDIR "C:/cygwin64/home/monet/x86_64/install/lib"
|
||||||
#define LOCALSTATEDIR "C:/cygwin64/home/monet/x86_64/install/var"
|
#define LOCALSTATEDIR "C:/cygwin64/home/monet/x86_64/install/var"
|
||||||
|
|
||||||
// End Section: monetdb macro variables
|
// End Section: monetdb macro variables
|
||||||
|
|
||||||
// Section: monetdb configure misc
|
// Section: monetdb configure misc
|
||||||
#define MONETDB_RELEASE "Jan2022-SP3"
|
#define MONETDB_RELEASE "Jan2022-SP3"
|
||||||
|
|
||||||
#define MONETDB_VERSION "11.43.15"
|
#define MONETDB_VERSION "11.43.15"
|
||||||
#define MONETDB_VERSION_MAJOR 11
|
#define MONETDB_VERSION_MAJOR 11
|
||||||
#define MONETDB_VERSION_MINOR 43
|
#define MONETDB_VERSION_MINOR 43
|
||||||
#define MONETDB_VERSION_PATCH 15
|
#define MONETDB_VERSION_PATCH 15
|
||||||
|
|
||||||
#define GDK_VERSION "25.1.0"
|
#define GDK_VERSION "25.1.0"
|
||||||
#define GDK_VERSION_MAJOR 25
|
#define GDK_VERSION_MAJOR 25
|
||||||
#define GDK_VERSION_MINOR 1
|
#define GDK_VERSION_MINOR 1
|
||||||
#define GDK_VERSION_PATCH 0
|
#define GDK_VERSION_PATCH 0
|
||||||
#define MAPI_VERSION "14.0.2"
|
#define MAPI_VERSION "14.0.2"
|
||||||
#define MAPI_VERSION_MAJOR 14
|
#define MAPI_VERSION_MAJOR 14
|
||||||
#define MAPI_VERSION_MINOR 0
|
#define MAPI_VERSION_MINOR 0
|
||||||
#define MAPI_VERSION_PATCH 2
|
#define MAPI_VERSION_PATCH 2
|
||||||
#define MONETDB5_VERSION "32.0.6"
|
#define MONETDB5_VERSION "32.0.6"
|
||||||
#define MONETDB5_VERSION_MAJOR 32
|
#define MONETDB5_VERSION_MAJOR 32
|
||||||
#define MONETDB5_VERSION_MINOR 0
|
#define MONETDB5_VERSION_MINOR 0
|
||||||
#define MONETDB5_VERSION_PATCH 6
|
#define MONETDB5_VERSION_PATCH 6
|
||||||
#define MONETDBE_VERSION "3.0.2"
|
#define MONETDBE_VERSION "3.0.2"
|
||||||
#define MONETDBE_VERSION_MAJOR 3
|
#define MONETDBE_VERSION_MAJOR 3
|
||||||
#define MONETDBE_VERSION_MINOR 0
|
#define MONETDBE_VERSION_MINOR 0
|
||||||
#define MONETDBE_VERSION_PATCH 2
|
#define MONETDBE_VERSION_PATCH 2
|
||||||
#define STREAM_VERSION "16.0.1"
|
#define STREAM_VERSION "16.0.1"
|
||||||
#define STREAM_VERSION_MAJOR 16
|
#define STREAM_VERSION_MAJOR 16
|
||||||
#define STREAM_VERSION_MINOR 0
|
#define STREAM_VERSION_MINOR 0
|
||||||
#define STREAM_VERSION_PATCH 1
|
#define STREAM_VERSION_PATCH 1
|
||||||
#define SQL_VERSION "12.0.5"
|
#define SQL_VERSION "12.0.5"
|
||||||
#define SQL_VERSION_MAJOR 12
|
#define SQL_VERSION_MAJOR 12
|
||||||
#define SQL_VERSION_MINOR 0
|
#define SQL_VERSION_MINOR 0
|
||||||
#define SQL_VERSION_PATCH 5
|
#define SQL_VERSION_PATCH 5
|
||||||
|
|
||||||
/* Host identifier */
|
/* Host identifier */
|
||||||
#define HOST "amd64-pc-windows-msvc"
|
#define HOST "amd64-pc-windows-msvc"
|
||||||
|
|
||||||
/* The used password hash algorithm */
|
/* The used password hash algorithm */
|
||||||
#define MONETDB5_PASSWDHASH "SHA512"
|
#define MONETDB5_PASSWDHASH "SHA512"
|
||||||
|
|
||||||
/* The used password hash algorithm */
|
/* The used password hash algorithm */
|
||||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||||
|
|
||||||
#ifndef _Noreturn
|
#ifndef _Noreturn
|
||||||
#define _Noreturn __declspec(noreturn)
|
#define _Noreturn __declspec(noreturn)
|
||||||
#endif
|
#endif
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||||
#ifndef inline
|
#ifndef inline
|
||||||
#define inline __inline
|
#define inline __inline
|
||||||
#endif
|
#endif
|
||||||
/* Does your compiler support `__restrict__' keyword? (C99 feature) */
|
/* Does your compiler support `__restrict__' keyword? (C99 feature) */
|
||||||
#ifndef __restrict__
|
#ifndef __restrict__
|
||||||
#define __restrict__ restrict
|
#define __restrict__ restrict
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifndef __restrict__
|
#ifndef __restrict__
|
||||||
#define __restrict__ __restrict
|
#define __restrict__ __restrict
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// End Section: monetdb configure misc
|
// End Section: monetdb configure misc
|
||||||
|
|
||||||
// Section: monetdb configure sizes
|
// Section: monetdb configure sizes
|
||||||
#define SIZEOF_SIZE_T 8
|
#define SIZEOF_SIZE_T 8
|
||||||
|
|
||||||
/* The size of `void *', as computed by sizeof. */
|
/* The size of `void *', as computed by sizeof. */
|
||||||
#define SIZEOF_VOID_P 8
|
#define SIZEOF_VOID_P 8
|
||||||
|
|
||||||
#define SIZEOF_CHAR 1
|
#define SIZEOF_CHAR 1
|
||||||
#define SIZEOF_SHORT 2
|
#define SIZEOF_SHORT 2
|
||||||
#define SIZEOF_INT 4
|
#define SIZEOF_INT 4
|
||||||
#define SIZEOF_LONG 4
|
#define SIZEOF_LONG 4
|
||||||
#define SIZEOF_LONG_LONG 8
|
#define SIZEOF_LONG_LONG 8
|
||||||
#define SIZEOF_DOUBLE 8
|
#define SIZEOF_DOUBLE 8
|
||||||
#define SIZEOF_WCHAR_T 2
|
#define SIZEOF_WCHAR_T 2
|
||||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define LENP_OR_POINTER_T SQLLEN *
|
#define LENP_OR_POINTER_T SQLLEN *
|
||||||
#else
|
#else
|
||||||
#define LENP_OR_POINTER_T SQLPOINTER
|
#define LENP_OR_POINTER_T SQLPOINTER
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define LENP_OR_POINTER_T SQLLEN *
|
#define LENP_OR_POINTER_T SQLLEN *
|
||||||
#endif
|
#endif
|
||||||
#define SIZEOF_SQLWCHAR 2
|
#define SIZEOF_SQLWCHAR 2
|
||||||
|
|
||||||
/* #undef WORDS_BIGENDIAN */
|
/* #undef WORDS_BIGENDIAN */
|
||||||
|
|
||||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||||
#ifndef ssize_t
|
#ifndef ssize_t
|
||||||
#define ssize_t int64_t
|
#define ssize_t int64_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The size of `__int128', as computed by sizeof. */
|
/* The size of `__int128', as computed by sizeof. */
|
||||||
/* #undef SIZEOF___INT128 */
|
/* #undef SIZEOF___INT128 */
|
||||||
|
|
||||||
/* The size of `__int128_t', as computed by sizeof. */
|
/* The size of `__int128_t', as computed by sizeof. */
|
||||||
/* #undef SIZEOF___INT128_T */
|
/* #undef SIZEOF___INT128_T */
|
||||||
|
|
||||||
/* The size of `__uint128_t', as computed by sizeof. */
|
/* The size of `__uint128_t', as computed by sizeof. */
|
||||||
/* #undef SIZEOF___UINT128_T */
|
/* #undef SIZEOF___UINT128_T */
|
||||||
|
|
||||||
#ifdef SIZEOF___INT128
|
#ifdef SIZEOF___INT128
|
||||||
typedef __int128 hge;
|
typedef __int128 hge;
|
||||||
typedef unsigned __int128 uhge;
|
typedef unsigned __int128 uhge;
|
||||||
#define HAVE_HGE 1
|
#define HAVE_HGE 1
|
||||||
#define SIZEOF_HGE SIZEOF___INT128
|
#define SIZEOF_HGE SIZEOF___INT128
|
||||||
#elif defined(SIZEOF___INT128_T) && defined(SIZEOF___UINT128_T)
|
#elif defined(SIZEOF___INT128_T) && defined(SIZEOF___UINT128_T)
|
||||||
typedef __int128_t hge;
|
typedef __int128_t hge;
|
||||||
typedef __uint128_t uhge;
|
typedef __uint128_t uhge;
|
||||||
#define HAVE_HGE 1
|
#define HAVE_HGE 1
|
||||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// End Section: monetdb configure sizes
|
// End Section: monetdb configure sizes
|
||||||
|
|
||||||
/* Does your compiler support `__attribute__' extension? */
|
/* Does your compiler support `__attribute__' extension? */
|
||||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||||
#define __attribute__(a)
|
#define __attribute__(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__cplusplus) || (__cplusplus < 201103L&&(!defined(_MSC_VER)||_MSC_VER<1600))
|
#if !defined(__cplusplus) || (__cplusplus < 201103L&&(!defined(_MSC_VER)||_MSC_VER<1600))
|
||||||
#ifndef static_assert
|
#ifndef static_assert
|
||||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
/* 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
|
* 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 */
|
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||||
#define static_assert(expr, mesg) ((void) 0)
|
#define static_assert(expr, mesg) ((void) 0)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
#include <strings.h> /* strcasecmp */
|
#include <strings.h> /* strcasecmp */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#define strdup(s) _strdup(s)
|
#define strdup(s) _strdup(s)
|
||||||
|
|
||||||
#ifndef strcasecmp
|
#ifndef strcasecmp
|
||||||
#define strcasecmp(x,y) _stricmp(x,y)
|
#define strcasecmp(x,y) _stricmp(x,y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the `strncasecmp' function. */
|
/* Define to 1 if you have the `strncasecmp' function. */
|
||||||
#define HAVE_STRNCASECMP 1
|
#define HAVE_STRNCASECMP 1
|
||||||
#ifndef strncasecmp
|
#ifndef strncasecmp
|
||||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef lstat
|
#ifdef lstat
|
||||||
#undef lstat
|
#undef lstat
|
||||||
#endif
|
#endif
|
||||||
#define lstat _stat64
|
#define lstat _stat64
|
||||||
#ifdef stat
|
#ifdef stat
|
||||||
#undef stat
|
#undef stat
|
||||||
#endif
|
#endif
|
||||||
#define stat _stat64
|
#define stat _stat64
|
||||||
#ifdef fstat
|
#ifdef fstat
|
||||||
#undef fstat
|
#undef fstat
|
||||||
#endif
|
#endif
|
||||||
#define fstat _fstat64
|
#define fstat _fstat64
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
stpcpy(char *__restrict__ dst, const char *__restrict__ src)
|
stpcpy(char *__restrict__ dst, const char *__restrict__ src)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; src[i]; i++)
|
for (i = 0; src[i]; i++)
|
||||||
dst[i] = src[i];
|
dst[i] = src[i];
|
||||||
dst[i] = 0;
|
dst[i] = 0;
|
||||||
return dst + i;
|
return dst + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `socklen_t'. */
|
/* Define to 1 if the system has the type `socklen_t'. */
|
||||||
#define HAVE_SOCKLEN_T 1
|
#define HAVE_SOCKLEN_T 1
|
||||||
/* type used by connect */
|
/* type used by connect */
|
||||||
#define socklen_t int
|
#define socklen_t int
|
||||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||||
|
|
||||||
#define HAVE_GETOPT_LONG 1
|
#define HAVE_GETOPT_LONG 1
|
||||||
|
|
||||||
/* there is something very similar to localtime_r on Windows: */
|
/* there is something very similar to localtime_r on Windows: */
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#define HAVE_LOCALTIME_R 1
|
#define HAVE_LOCALTIME_R 1
|
||||||
static inline struct tm *
|
static inline struct tm *
|
||||||
localtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
localtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||||
{
|
{
|
||||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||||
}
|
}
|
||||||
#define HAVE_GMTIME_R 1
|
#define HAVE_GMTIME_R 1
|
||||||
static inline struct tm *
|
static inline struct tm *
|
||||||
gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||||
{
|
{
|
||||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||||
#define HAVE_CTIME_R 1
|
#define HAVE_CTIME_R 1
|
||||||
#define HAVE_CTIME_R3 1
|
#define HAVE_CTIME_R3 1
|
||||||
/* there is something very similar to ctime_r on Windows: */
|
/* there is something very similar to ctime_r on Windows: */
|
||||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||||
|
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#define HAVE_SOCKLEN_T 1
|
#define HAVE_SOCKLEN_T 1
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#define closesocket close
|
#define closesocket close
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _In_z_
|
#ifndef _In_z_
|
||||||
#define _In_z_
|
#define _In_z_
|
||||||
#endif
|
#endif
|
||||||
#ifndef _Printf_format_string_
|
#ifndef _Printf_format_string_
|
||||||
#define _Printf_format_string_
|
#define _Printf_format_string_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||||
static void f(void); \
|
static void f(void); \
|
||||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||||
static void f(void)
|
static void f(void)
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||||
#else
|
#else
|
||||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define LIB_STARTUP_FUNC(f) \
|
#define LIB_STARTUP_FUNC(f) \
|
||||||
static void f(void) __attribute__((__constructor__)); \
|
static void f(void) __attribute__((__constructor__)); \
|
||||||
static void f(void)
|
static void f(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||||
|
@ -1,473 +1,473 @@
|
|||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* 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
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*
|
*
|
||||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||||
*/
|
*/
|
||||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||||
|
|
||||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#if _MSC_VER < 1900
|
#if _MSC_VER < 1900
|
||||||
#error Versions below Visual Studio 2015 are no longer supported
|
#error Versions below Visual Studio 2015 are no longer supported
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||||
#define HAVE_RAND_S 1
|
#define HAVE_RAND_S 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||||
#define _XOPEN_SOURCE 700
|
#define _XOPEN_SOURCE 700
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
/* 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
|
* versions. We need to include stdlib.h first or else we get
|
||||||
* conflicting declarations. */
|
* conflicting declarations. */
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
#define HAVE_SYS_TYPES_H 1
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* standard C-99 include files */
|
/* standard C-99 include files */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
/* Windows include files */
|
/* Windows include files */
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
/* indicate to sqltypes.h that windows.h has already been included and
|
/* indicate to sqltypes.h that windows.h has already been included and
|
||||||
that it doesn't have to define Windows constants */
|
that it doesn't have to define Windows constants */
|
||||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||||
|
|
||||||
#define NATIVE_WIN32 1
|
#define NATIVE_WIN32 1
|
||||||
|
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#if !defined(WIN32) && (defined(__CYGWIN__)||defined(__MINGW32__))
|
#if !defined(WIN32) && (defined(__CYGWIN__)||defined(__MINGW32__))
|
||||||
#define WIN32 1
|
#define WIN32 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Section: monetdb configure defines
|
// Section: monetdb configure defines
|
||||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||||
#define HAVE_DLFCN_H 1
|
#define HAVE_DLFCN_H 1
|
||||||
#define HAVE_FCNTL_H 1
|
#define HAVE_FCNTL_H 1
|
||||||
#define HAVE_IO_H 1
|
#define HAVE_IO_H 1
|
||||||
/* #undef HAVE_KVM_H */
|
/* #undef HAVE_KVM_H */
|
||||||
#define HAVE_LIBGEN_H 1
|
#define HAVE_LIBGEN_H 1
|
||||||
/* #undef HAVE_LIBINTL_H */
|
/* #undef HAVE_LIBINTL_H */
|
||||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||||
/* #undef HAVE_MACH_TASK_H */
|
/* #undef HAVE_MACH_TASK_H */
|
||||||
/* #undef HAVE_MACH_O_DYLD_H */
|
/* #undef HAVE_MACH_O_DYLD_H */
|
||||||
#define HAVE_NETDB_H 1
|
#define HAVE_NETDB_H 1
|
||||||
#define HAVE_NETINET_IN_H 1
|
#define HAVE_NETINET_IN_H 1
|
||||||
#define HAVE_POLL_H 1
|
#define HAVE_POLL_H 1
|
||||||
/* #undef HAVE_PROCFS_H */
|
/* #undef HAVE_PROCFS_H */
|
||||||
#define HAVE_PWD_H 1
|
#define HAVE_PWD_H 1
|
||||||
#define HAVE_STRINGS_H 1
|
#define HAVE_STRINGS_H 1
|
||||||
/* #undef HAVE_STROPTS_H */
|
/* #undef HAVE_STROPTS_H */
|
||||||
#define HAVE_SYS_FILE_H 1
|
#define HAVE_SYS_FILE_H 1
|
||||||
#define HAVE_SYS_IOCTL_H 1
|
#define HAVE_SYS_IOCTL_H 1
|
||||||
/* #undef HAVE_SYS_SYSCTL_H */
|
/* #undef HAVE_SYS_SYSCTL_H */
|
||||||
#define HAVE_SYS_MMAN_H 1
|
#define HAVE_SYS_MMAN_H 1
|
||||||
#define HAVE_SYS_PARAM_H 1
|
#define HAVE_SYS_PARAM_H 1
|
||||||
#define HAVE_SYS_RANDOM_H 1
|
#define HAVE_SYS_RANDOM_H 1
|
||||||
#define HAVE_SYS_RESOURCE_H 1
|
#define HAVE_SYS_RESOURCE_H 1
|
||||||
#define HAVE_SYS_TIME_H 1
|
#define HAVE_SYS_TIME_H 1
|
||||||
#define HAVE_SYS_TIMES_H 1
|
#define HAVE_SYS_TIMES_H 1
|
||||||
#define HAVE_SYS_UIO_H 1
|
#define HAVE_SYS_UIO_H 1
|
||||||
#define HAVE_SYS_UN_H 1
|
#define HAVE_SYS_UN_H 1
|
||||||
#define HAVE_SYS_WAIT_H 1
|
#define HAVE_SYS_WAIT_H 1
|
||||||
#define HAVE_TERMIOS_H 1
|
#define HAVE_TERMIOS_H 1
|
||||||
#define HAVE_UNISTD_H 1
|
#define HAVE_UNISTD_H 1
|
||||||
#define HAVE_WINSOCK_H 1
|
#define HAVE_WINSOCK_H 1
|
||||||
#define HAVE_SEMAPHORE_H 1
|
#define HAVE_SEMAPHORE_H 1
|
||||||
#define HAVE_GETOPT_H 1
|
#define HAVE_GETOPT_H 1
|
||||||
|
|
||||||
#define HAVE_STDATOMIC_H 1
|
#define HAVE_STDATOMIC_H 1
|
||||||
|
|
||||||
#define HAVE_DIRENT_H 1
|
#define HAVE_DIRENT_H 1
|
||||||
#define HAVE_SYS_SOCKET_H 1
|
#define HAVE_SYS_SOCKET_H 1
|
||||||
#define HAVE_GETTIMEOFDAY 1
|
#define HAVE_GETTIMEOFDAY 1
|
||||||
#define HAVE_SYS_STAT_H 1
|
#define HAVE_SYS_STAT_H 1
|
||||||
#define HAVE_FDATASYNC 1
|
#define HAVE_FDATASYNC 1
|
||||||
#define HAVE_ACCEPT4 1
|
#define HAVE_ACCEPT4 1
|
||||||
#define HAVE_ASCTIME_R 1
|
#define HAVE_ASCTIME_R 1
|
||||||
#define HAVE_CLOCK_GETTIME 1
|
#define HAVE_CLOCK_GETTIME 1
|
||||||
#define HAVE_CTIME_R 1
|
#define HAVE_CTIME_R 1
|
||||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||||
/* #undef HAVE_FALLOCATE */
|
/* #undef HAVE_FALLOCATE */
|
||||||
#define HAVE_FCNTL 1
|
#define HAVE_FCNTL 1
|
||||||
#define HAVE_FORK 1
|
#define HAVE_FORK 1
|
||||||
#define HAVE_FSYNC 1
|
#define HAVE_FSYNC 1
|
||||||
#define HAVE_FTIME 1
|
#define HAVE_FTIME 1
|
||||||
#define HAVE_GETENTROPY 1
|
#define HAVE_GETENTROPY 1
|
||||||
/* #undef HAVE_GETEXECNAME */
|
/* #undef HAVE_GETEXECNAME */
|
||||||
#define HAVE_GETLOGIN 1
|
#define HAVE_GETLOGIN 1
|
||||||
#define HAVE_GETOPT_LONG 1
|
#define HAVE_GETOPT_LONG 1
|
||||||
#define HAVE_GETRLIMIT 1
|
#define HAVE_GETRLIMIT 1
|
||||||
#define HAVE_GETTIMEOFDAY 1
|
#define HAVE_GETTIMEOFDAY 1
|
||||||
#define HAVE_GETUID 1
|
#define HAVE_GETUID 1
|
||||||
#define HAVE_GMTIME_R 1
|
#define HAVE_GMTIME_R 1
|
||||||
#define HAVE_LOCALTIME_R 1
|
#define HAVE_LOCALTIME_R 1
|
||||||
#define HAVE_STRERROR_R 1
|
#define HAVE_STRERROR_R 1
|
||||||
#define HAVE_LOCKF 1
|
#define HAVE_LOCKF 1
|
||||||
#define HAVE_MADVISE 1
|
#define HAVE_MADVISE 1
|
||||||
/* #undef HAVE_MREMAP */
|
/* #undef HAVE_MREMAP */
|
||||||
#define HAVE_NANOSLEEP 1
|
#define HAVE_NANOSLEEP 1
|
||||||
#define HAVE_NL_LANGINFO 1
|
#define HAVE_NL_LANGINFO 1
|
||||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||||
/* #undef HAVE_PIPE2 */
|
/* #undef HAVE_PIPE2 */
|
||||||
#define HAVE_POLL 1
|
#define HAVE_POLL 1
|
||||||
#define HAVE_POPEN 1
|
#define HAVE_POPEN 1
|
||||||
#define HAVE_POSIX_FADVISE 1
|
#define HAVE_POSIX_FADVISE 1
|
||||||
#define HAVE_POSIX_FALLOCATE 1
|
#define HAVE_POSIX_FALLOCATE 1
|
||||||
#define HAVE_POSIX_MADVISE 1
|
#define HAVE_POSIX_MADVISE 1
|
||||||
#define HAVE_PUTENV 1
|
#define HAVE_PUTENV 1
|
||||||
#define HAVE_SETSID 1
|
#define HAVE_SETSID 1
|
||||||
#define HAVE_SHUTDOWN 1
|
#define HAVE_SHUTDOWN 1
|
||||||
#define HAVE_SIGACTION 1
|
#define HAVE_SIGACTION 1
|
||||||
#define HAVE_STPCPY 1
|
#define HAVE_STPCPY 1
|
||||||
#define HAVE_STRCASESTR 1
|
#define HAVE_STRCASESTR 1
|
||||||
#define HAVE_STRNCASECMP 1
|
#define HAVE_STRNCASECMP 1
|
||||||
#define HAVE_STRPTIME 1
|
#define HAVE_STRPTIME 1
|
||||||
#define HAVE_STRSIGNAL 1
|
#define HAVE_STRSIGNAL 1
|
||||||
#define HAVE_SYSCONF 1
|
#define HAVE_SYSCONF 1
|
||||||
/* #undef HAVE_TASK_INFO */
|
/* #undef HAVE_TASK_INFO */
|
||||||
#define HAVE_TIMES 1
|
#define HAVE_TIMES 1
|
||||||
#define HAVE_UNAME 1
|
#define HAVE_UNAME 1
|
||||||
/* #undef HAVE_SEMTIMEDOP */
|
/* #undef HAVE_SEMTIMEDOP */
|
||||||
#define HAVE_PTHREAD_KILL 1
|
#define HAVE_PTHREAD_KILL 1
|
||||||
#define HAVE_PTHREAD_SIGMASK 1
|
#define HAVE_PTHREAD_SIGMASK 1
|
||||||
#define HAVE_GETOPT 1
|
#define HAVE_GETOPT 1
|
||||||
|
|
||||||
#define ICONV_CONST
|
#define ICONV_CONST
|
||||||
#define FLEXIBLE_ARRAY_MEMBER
|
#define FLEXIBLE_ARRAY_MEMBER
|
||||||
#define ENABLE_MAPI 1
|
#define ENABLE_MAPI 1
|
||||||
#define HAVE_MAPI 1
|
#define HAVE_MAPI 1
|
||||||
// End Section: monetdb configure defines
|
// End Section: monetdb configure defines
|
||||||
|
|
||||||
// Section: monetdb macro variables
|
// Section: monetdb macro variables
|
||||||
/* #undef HAVE_ICONV */
|
/* #undef HAVE_ICONV */
|
||||||
#define HAVE_PTHREAD_H 1
|
#define HAVE_PTHREAD_H 1
|
||||||
/* #undef HAVE_LIBPCRE */
|
/* #undef HAVE_LIBPCRE */
|
||||||
/* #undef HAVE_LIBBZ2 */
|
/* #undef HAVE_LIBBZ2 */
|
||||||
/* #undef HAVE_CURL */
|
/* #undef HAVE_CURL */
|
||||||
/* #undef HAVE_LIBLZMA */
|
/* #undef HAVE_LIBLZMA */
|
||||||
/* #undef HAVE_LIBXML */
|
/* #undef HAVE_LIBXML */
|
||||||
/* #undef HAVE_LIBZ */
|
/* #undef HAVE_LIBZ */
|
||||||
/* #undef HAVE_LIBLZ4 */
|
/* #undef HAVE_LIBLZ4 */
|
||||||
/* #undef HAVE_PROJ */
|
/* #undef HAVE_PROJ */
|
||||||
/* #undef HAVE_SNAPPY */
|
/* #undef HAVE_SNAPPY */
|
||||||
/* #undef HAVE_FITS */
|
/* #undef HAVE_FITS */
|
||||||
/* #undef HAVE_VALGRIND */
|
/* #undef HAVE_VALGRIND */
|
||||||
/* #undef HAVE_NETCDF */
|
/* #undef HAVE_NETCDF */
|
||||||
/* #undef HAVE_READLINE */
|
/* #undef HAVE_READLINE */
|
||||||
/* #undef HAVE_LIBR */
|
/* #undef HAVE_LIBR */
|
||||||
#define RHOME "/registry"
|
#define RHOME "/registry"
|
||||||
/* #undef HAVE_GEOM */
|
/* #undef HAVE_GEOM */
|
||||||
/* #undef HAVE_SHP */
|
/* #undef HAVE_SHP */
|
||||||
/* #undef HAVE_LIBPY3 */
|
/* #undef HAVE_LIBPY3 */
|
||||||
|
|
||||||
// #define SOCKET_LIBRARIES
|
// #define SOCKET_LIBRARIES
|
||||||
#define HAVE_GETADDRINFO 1
|
#define HAVE_GETADDRINFO 1
|
||||||
/* #undef HAVE_CUDF */
|
/* #undef HAVE_CUDF */
|
||||||
|
|
||||||
#define MAPI_PORT 50000
|
#define MAPI_PORT 50000
|
||||||
#define MAPI_PORT_STR "50000"
|
#define MAPI_PORT_STR "50000"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define DIR_SEP '\\'
|
#define DIR_SEP '\\'
|
||||||
#define PATH_SEP ';'
|
#define PATH_SEP ';'
|
||||||
#define DIR_SEP_STR "\\"
|
#define DIR_SEP_STR "\\"
|
||||||
#define SO_PREFIX ""
|
#define SO_PREFIX ""
|
||||||
#else
|
#else
|
||||||
#define DIR_SEP '/'
|
#define DIR_SEP '/'
|
||||||
#define PATH_SEP ':'
|
#define PATH_SEP ':'
|
||||||
#define DIR_SEP_STR "/"
|
#define DIR_SEP_STR "/"
|
||||||
#define SO_PREFIX "lib"
|
#define SO_PREFIX "lib"
|
||||||
#endif
|
#endif
|
||||||
#define SO_EXT ".dll"
|
#define SO_EXT ".dll"
|
||||||
|
|
||||||
#define BINDIR "C:/Program Files (x86)/MonetDB/bin"
|
#define BINDIR "C:/Program Files (x86)/MonetDB/bin"
|
||||||
#define LIBDIR "C:/Program Files (x86)/MonetDB/lib"
|
#define LIBDIR "C:/Program Files (x86)/MonetDB/lib"
|
||||||
#define LOCALSTATEDIR "C:/Program Files (x86)/MonetDB/var"
|
#define LOCALSTATEDIR "C:/Program Files (x86)/MonetDB/var"
|
||||||
|
|
||||||
// End Section: monetdb macro variables
|
// End Section: monetdb macro variables
|
||||||
|
|
||||||
// Section: monetdb configure misc
|
// Section: monetdb configure misc
|
||||||
#define MONETDB_RELEASE "unreleased"
|
#define MONETDB_RELEASE "unreleased"
|
||||||
|
|
||||||
#define MONETDB_VERSION "11.44.0"
|
#define MONETDB_VERSION "11.44.0"
|
||||||
#define MONETDB_VERSION_MAJOR 11
|
#define MONETDB_VERSION_MAJOR 11
|
||||||
#define MONETDB_VERSION_MINOR 44
|
#define MONETDB_VERSION_MINOR 44
|
||||||
#define MONETDB_VERSION_PATCH 0
|
#define MONETDB_VERSION_PATCH 0
|
||||||
|
|
||||||
#define GDK_VERSION "25.1.0"
|
#define GDK_VERSION "25.1.0"
|
||||||
#define GDK_VERSION_MAJOR 25
|
#define GDK_VERSION_MAJOR 25
|
||||||
#define GDK_VERSION_MINOR 1
|
#define GDK_VERSION_MINOR 1
|
||||||
#define GDK_VERSION_PATCH 0
|
#define GDK_VERSION_PATCH 0
|
||||||
#define MAPI_VERSION "14.0.2"
|
#define MAPI_VERSION "14.0.2"
|
||||||
#define MAPI_VERSION_MAJOR 14
|
#define MAPI_VERSION_MAJOR 14
|
||||||
#define MAPI_VERSION_MINOR 0
|
#define MAPI_VERSION_MINOR 0
|
||||||
#define MAPI_VERSION_PATCH 2
|
#define MAPI_VERSION_PATCH 2
|
||||||
#define MONETDB5_VERSION "32.0.6"
|
#define MONETDB5_VERSION "32.0.6"
|
||||||
#define MONETDB5_VERSION_MAJOR 32
|
#define MONETDB5_VERSION_MAJOR 32
|
||||||
#define MONETDB5_VERSION_MINOR 0
|
#define MONETDB5_VERSION_MINOR 0
|
||||||
#define MONETDB5_VERSION_PATCH 6
|
#define MONETDB5_VERSION_PATCH 6
|
||||||
#define MONETDBE_VERSION "3.0.2"
|
#define MONETDBE_VERSION "3.0.2"
|
||||||
#define MONETDBE_VERSION_MAJOR 3
|
#define MONETDBE_VERSION_MAJOR 3
|
||||||
#define MONETDBE_VERSION_MINOR 0
|
#define MONETDBE_VERSION_MINOR 0
|
||||||
#define MONETDBE_VERSION_PATCH 2
|
#define MONETDBE_VERSION_PATCH 2
|
||||||
#define STREAM_VERSION "16.0.1"
|
#define STREAM_VERSION "16.0.1"
|
||||||
#define STREAM_VERSION_MAJOR 16
|
#define STREAM_VERSION_MAJOR 16
|
||||||
#define STREAM_VERSION_MINOR 0
|
#define STREAM_VERSION_MINOR 0
|
||||||
#define STREAM_VERSION_PATCH 1
|
#define STREAM_VERSION_PATCH 1
|
||||||
#define SQL_VERSION "12.0.5"
|
#define SQL_VERSION "12.0.5"
|
||||||
#define SQL_VERSION_MAJOR 12
|
#define SQL_VERSION_MAJOR 12
|
||||||
#define SQL_VERSION_MINOR 0
|
#define SQL_VERSION_MINOR 0
|
||||||
#define SQL_VERSION_PATCH 5
|
#define SQL_VERSION_PATCH 5
|
||||||
|
|
||||||
/* Host identifier */
|
/* Host identifier */
|
||||||
#define HOST "amd64-pc-windows-gnu"
|
#define HOST "amd64-pc-windows-gnu"
|
||||||
|
|
||||||
/* The used password hash algorithm */
|
/* The used password hash algorithm */
|
||||||
#define MONETDB5_PASSWDHASH "SHA512"
|
#define MONETDB5_PASSWDHASH "SHA512"
|
||||||
|
|
||||||
/* The used password hash algorithm */
|
/* The used password hash algorithm */
|
||||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||||
|
|
||||||
#ifndef _Noreturn
|
#ifndef _Noreturn
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define _Noreturn
|
#define _Noreturn
|
||||||
#else
|
#else
|
||||||
/* #undef _Noreturn */
|
/* #undef _Noreturn */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||||
#ifndef inline
|
#ifndef inline
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define inline
|
#define inline
|
||||||
#else
|
#else
|
||||||
/* #undef inline */
|
/* #undef inline */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* Does your compiler support `restrict' keyword? (C99 feature) */
|
/* Does your compiler support `restrict' keyword? (C99 feature) */
|
||||||
#ifndef restrict
|
#ifndef restrict
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define restrict
|
#define restrict
|
||||||
#else
|
#else
|
||||||
/* #undef restrict */
|
/* #undef restrict */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// End Section: monetdb configure misc
|
// End Section: monetdb configure misc
|
||||||
|
|
||||||
// Section: monetdb configure sizes
|
// Section: monetdb configure sizes
|
||||||
#define SIZEOF_SIZE_T 8
|
#define SIZEOF_SIZE_T 8
|
||||||
|
|
||||||
/* The size of `void *', as computed by sizeof. */
|
/* The size of `void *', as computed by sizeof. */
|
||||||
#define SIZEOF_VOID_P 8
|
#define SIZEOF_VOID_P 8
|
||||||
|
|
||||||
#define SIZEOF_CHAR 1
|
#define SIZEOF_CHAR 1
|
||||||
#define SIZEOF_SHORT 2
|
#define SIZEOF_SHORT 2
|
||||||
#define SIZEOF_INT 4
|
#define SIZEOF_INT 4
|
||||||
#define SIZEOF_LONG 8
|
#define SIZEOF_LONG 8
|
||||||
#define SIZEOF_LONG_LONG 8
|
#define SIZEOF_LONG_LONG 8
|
||||||
#define SIZEOF_DOUBLE 8
|
#define SIZEOF_DOUBLE 8
|
||||||
#define SIZEOF_WCHAR_T 2
|
#define SIZEOF_WCHAR_T 2
|
||||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define LENP_OR_POINTER_T SQLLEN *
|
#define LENP_OR_POINTER_T SQLLEN *
|
||||||
#else
|
#else
|
||||||
#define LENP_OR_POINTER_T SQLPOINTER
|
#define LENP_OR_POINTER_T SQLPOINTER
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
/* #undef LENP_OR_POINTER_T */
|
/* #undef LENP_OR_POINTER_T */
|
||||||
#endif
|
#endif
|
||||||
/* #undef SIZEOF_SQLWCHAR */
|
/* #undef SIZEOF_SQLWCHAR */
|
||||||
|
|
||||||
/* #undef WORDS_BIGENDIAN */
|
/* #undef WORDS_BIGENDIAN */
|
||||||
|
|
||||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||||
#ifndef ssize_t
|
#ifndef ssize_t
|
||||||
/* #undef ssize_t */
|
/* #undef ssize_t */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The size of `__int128', as computed by sizeof. */
|
/* The size of `__int128', as computed by sizeof. */
|
||||||
#define SIZEOF___INT128 16
|
#define SIZEOF___INT128 16
|
||||||
|
|
||||||
/* The size of `__int128_t', as computed by sizeof. */
|
/* The size of `__int128_t', as computed by sizeof. */
|
||||||
#define SIZEOF___INT128_T 16
|
#define SIZEOF___INT128_T 16
|
||||||
|
|
||||||
/* The size of `__uint128_t', as computed by sizeof. */
|
/* The size of `__uint128_t', as computed by sizeof. */
|
||||||
#define SIZEOF___UINT128_T 16
|
#define SIZEOF___UINT128_T 16
|
||||||
|
|
||||||
#define HAVE___INT128 1
|
#define HAVE___INT128 1
|
||||||
#define HAVE___INT128_T 1
|
#define HAVE___INT128_T 1
|
||||||
#define HAVE___UINT128_T 1
|
#define HAVE___UINT128_T 1
|
||||||
/* #undef HAVE_HGE */
|
/* #undef HAVE_HGE */
|
||||||
|
|
||||||
#ifdef HAVE_HGE
|
#ifdef HAVE_HGE
|
||||||
#ifdef HAVE___INT128
|
#ifdef HAVE___INT128
|
||||||
typedef __int128 hge;
|
typedef __int128 hge;
|
||||||
typedef unsigned __int128 uhge;
|
typedef unsigned __int128 uhge;
|
||||||
#define SIZEOF_HGE SIZEOF___INT128
|
#define SIZEOF_HGE SIZEOF___INT128
|
||||||
#elif defined(HAVE___INT128_T) && defined(HAVE___UINT128_T)
|
#elif defined(HAVE___INT128_T) && defined(HAVE___UINT128_T)
|
||||||
typedef __int128_t hge;
|
typedef __int128_t hge;
|
||||||
typedef __uint128_t uhge;
|
typedef __uint128_t uhge;
|
||||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// End Section: monetdb configure sizes
|
// End Section: monetdb configure sizes
|
||||||
|
|
||||||
/* Does your compiler support `__attribute__' extension? */
|
/* Does your compiler support `__attribute__' extension? */
|
||||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||||
#define __attribute__(a)
|
#define __attribute__(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__cplusplus) || __cplusplus < 201103L
|
#if !defined(__cplusplus) || __cplusplus < 201103L
|
||||||
#ifndef static_assert
|
#ifndef static_assert
|
||||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
/* 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
|
* 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 */
|
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||||
#define static_assert(expr, mesg) ((void) 0)
|
#define static_assert(expr, mesg) ((void) 0)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
#include <strings.h> /* strcasecmp */
|
#include <strings.h> /* strcasecmp */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#define strdup(s) _strdup(s)
|
#define strdup(s) _strdup(s)
|
||||||
|
|
||||||
#ifndef strcasecmp
|
#ifndef strcasecmp
|
||||||
#define strcasecmp(x,y) _stricmp(x,y)
|
#define strcasecmp(x,y) _stricmp(x,y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the `strncasecmp' function. */
|
/* Define to 1 if you have the `strncasecmp' function. */
|
||||||
#define HAVE_STRNCASECMP 1
|
#define HAVE_STRNCASECMP 1
|
||||||
#ifndef strncasecmp
|
#ifndef strncasecmp
|
||||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef lstat
|
#ifdef lstat
|
||||||
#undef lstat
|
#undef lstat
|
||||||
#endif
|
#endif
|
||||||
#define lstat _stat64
|
#define lstat _stat64
|
||||||
#ifdef stat
|
#ifdef stat
|
||||||
#undef stat
|
#undef stat
|
||||||
#endif
|
#endif
|
||||||
#define stat _stat64
|
#define stat _stat64
|
||||||
#ifdef fstat
|
#ifdef fstat
|
||||||
#undef fstat
|
#undef fstat
|
||||||
#endif
|
#endif
|
||||||
#define fstat _fstat64
|
#define fstat _fstat64
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
stpcpy(char *restrict dst, const char *restrict src)
|
stpcpy(char *restrict dst, const char *restrict src)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; src[i]; i++)
|
for (i = 0; src[i]; i++)
|
||||||
dst[i] = src[i];
|
dst[i] = src[i];
|
||||||
dst[i] = 0;
|
dst[i] = 0;
|
||||||
return dst + i;
|
return dst + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `socklen_t'. */
|
/* Define to 1 if the system has the type `socklen_t'. */
|
||||||
#define HAVE_SOCKLEN_T 1
|
#define HAVE_SOCKLEN_T 1
|
||||||
/* type used by connect */
|
/* type used by connect */
|
||||||
#define socklen_t int
|
#define socklen_t int
|
||||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||||
|
|
||||||
#define HAVE_GETOPT_LONG 1
|
#define HAVE_GETOPT_LONG 1
|
||||||
|
|
||||||
/* there is something very similar to localtime_r on Windows: */
|
/* there is something very similar to localtime_r on Windows: */
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#define HAVE_LOCALTIME_R 1
|
#define HAVE_LOCALTIME_R 1
|
||||||
static inline struct tm *
|
static inline struct tm *
|
||||||
localtime_r(const time_t *restrict timep, struct tm *restrict result)
|
localtime_r(const time_t *restrict timep, struct tm *restrict result)
|
||||||
{
|
{
|
||||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||||
}
|
}
|
||||||
#define HAVE_GMTIME_R 1
|
#define HAVE_GMTIME_R 1
|
||||||
static inline struct tm *
|
static inline struct tm *
|
||||||
gmtime_r(const time_t *restrict timep, struct tm *restrict result)
|
gmtime_r(const time_t *restrict timep, struct tm *restrict result)
|
||||||
{
|
{
|
||||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||||
#define HAVE_CTIME_R 1
|
#define HAVE_CTIME_R 1
|
||||||
#define HAVE_CTIME_R3 1
|
#define HAVE_CTIME_R3 1
|
||||||
/* there is something very similar to ctime_r on Windows: */
|
/* there is something very similar to ctime_r on Windows: */
|
||||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||||
|
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
/* #undef HAVE_SOCKLEN_T */
|
/* #undef HAVE_SOCKLEN_T */
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#define closesocket close
|
#define closesocket close
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _In_z_
|
#ifndef _In_z_
|
||||||
#define _In_z_
|
#define _In_z_
|
||||||
#endif
|
#endif
|
||||||
#ifndef _Printf_format_string_
|
#ifndef _Printf_format_string_
|
||||||
#define _Printf_format_string_
|
#define _Printf_format_string_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||||
static void f(void); \
|
static void f(void); \
|
||||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||||
static void f(void)
|
static void f(void)
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||||
#else
|
#else
|
||||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define LIB_STARTUP_FUNC(f) \
|
#define LIB_STARTUP_FUNC(f) \
|
||||||
static void f(void) __attribute__((__constructor__)); \
|
static void f(void) __attribute__((__constructor__)); \
|
||||||
static void f(void)
|
static void f(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||||
|
@ -1,190 +1,190 @@
|
|||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* 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
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*
|
*
|
||||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MONETDBE_LIB_
|
#ifndef _MONETDBE_LIB_
|
||||||
#define _MONETDBE_LIB_
|
#define _MONETDBE_LIB_
|
||||||
|
|
||||||
#include "monetdb_config.h"
|
#include "monetdb_config.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#ifndef LIBMONETDBE
|
#ifndef LIBMONETDBE
|
||||||
#define monetdbe_export extern __declspec(dllimport)
|
#define monetdbe_export extern __declspec(dllimport)
|
||||||
#else
|
#else
|
||||||
#define monetdbe_export extern __declspec(dllexport)
|
#define monetdbe_export extern __declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define monetdbe_export extern
|
#define monetdbe_export extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int64_t monetdbe_cnt;
|
typedef int64_t monetdbe_cnt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char day;
|
unsigned char day;
|
||||||
unsigned char month;
|
unsigned char month;
|
||||||
short year;
|
short year;
|
||||||
} monetdbe_data_date;
|
} monetdbe_data_date;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int ms;
|
unsigned int ms;
|
||||||
unsigned char seconds;
|
unsigned char seconds;
|
||||||
unsigned char minutes;
|
unsigned char minutes;
|
||||||
unsigned char hours;
|
unsigned char hours;
|
||||||
} monetdbe_data_time;
|
} monetdbe_data_time;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
monetdbe_data_date date;
|
monetdbe_data_date date;
|
||||||
monetdbe_data_time time;
|
monetdbe_data_time time;
|
||||||
} monetdbe_data_timestamp;
|
} monetdbe_data_timestamp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t size;
|
size_t size;
|
||||||
char* data;
|
char* data;
|
||||||
} monetdbe_data_blob;
|
} monetdbe_data_blob;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
monetdbe_bool, monetdbe_int8_t, monetdbe_int16_t, monetdbe_int32_t, monetdbe_int64_t,
|
monetdbe_bool, monetdbe_int8_t, monetdbe_int16_t, monetdbe_int32_t, monetdbe_int64_t,
|
||||||
#ifdef HAVE_HGE
|
#ifdef HAVE_HGE
|
||||||
monetdbe_int128_t,
|
monetdbe_int128_t,
|
||||||
#endif
|
#endif
|
||||||
monetdbe_size_t, monetdbe_float, monetdbe_double,
|
monetdbe_size_t, monetdbe_float, monetdbe_double,
|
||||||
monetdbe_str, monetdbe_blob,
|
monetdbe_str, monetdbe_blob,
|
||||||
monetdbe_date, monetdbe_time, monetdbe_timestamp,
|
monetdbe_date, monetdbe_time, monetdbe_timestamp,
|
||||||
|
|
||||||
// should be last:
|
// should be last:
|
||||||
monetdbe_type_unknown
|
monetdbe_type_unknown
|
||||||
} monetdbe_types;
|
} monetdbe_types;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* name;
|
char* name;
|
||||||
unsigned int scale;
|
unsigned int scale;
|
||||||
unsigned int digits;
|
unsigned int digits;
|
||||||
} monetdbe_sql_type;
|
} monetdbe_sql_type;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
monetdbe_types type;
|
monetdbe_types type;
|
||||||
monetdbe_sql_type sql_type;
|
monetdbe_sql_type sql_type;
|
||||||
void *data;
|
void *data;
|
||||||
size_t count;
|
size_t count;
|
||||||
char* name;
|
char* name;
|
||||||
} monetdbe_column;
|
} monetdbe_column;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t nparam;
|
size_t nparam;
|
||||||
monetdbe_types *type;
|
monetdbe_types *type;
|
||||||
} monetdbe_statement;
|
} monetdbe_statement;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
monetdbe_cnt nrows;
|
monetdbe_cnt nrows;
|
||||||
size_t ncols;
|
size_t ncols;
|
||||||
char *name;
|
char *name;
|
||||||
monetdbe_cnt last_id; /* last auto incremented id */
|
monetdbe_cnt last_id; /* last auto incremented id */
|
||||||
} monetdbe_result;
|
} monetdbe_result;
|
||||||
|
|
||||||
typedef void* monetdbe_database;
|
typedef void* monetdbe_database;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *host;
|
const char *host;
|
||||||
int port;
|
int port;
|
||||||
const char *database;
|
const char *database;
|
||||||
const char *username;
|
const char *username;
|
||||||
const char *password;
|
const char *password;
|
||||||
const char *lang;
|
const char *lang;
|
||||||
} monetdbe_remote;
|
} monetdbe_remote;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *host;
|
const char *host;
|
||||||
const char* port;
|
const char* port;
|
||||||
const char* usock;
|
const char* usock;
|
||||||
} monetdbe_mapi_server;
|
} monetdbe_mapi_server;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int memorylimit; // top off the amount of RAM to be used, in MB
|
int memorylimit; // top off the amount of RAM to be used, in MB
|
||||||
int querytimeout; // graceful terminate query after a few seconds
|
int querytimeout; // graceful terminate query after a few seconds
|
||||||
int sessiontimeout; // graceful terminate the session 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
|
int nr_threads; // maximum number of worker treads, limits level of parallelism
|
||||||
monetdbe_remote* remote;
|
monetdbe_remote* remote;
|
||||||
monetdbe_mapi_server* mapi_server;
|
monetdbe_mapi_server* mapi_server;
|
||||||
const char *trace_file; // file to which log output should be written
|
const char *trace_file; // file to which log output should be written
|
||||||
} monetdbe_options;
|
} monetdbe_options;
|
||||||
|
|
||||||
#define DEFAULT_STRUCT_DEFINITION(ctype, typename) \
|
#define DEFAULT_STRUCT_DEFINITION(ctype, typename) \
|
||||||
typedef struct \
|
typedef struct \
|
||||||
{ \
|
{ \
|
||||||
monetdbe_types type; \
|
monetdbe_types type; \
|
||||||
monetdbe_sql_type sql_type; \
|
monetdbe_sql_type sql_type; \
|
||||||
ctype *data; \
|
ctype *data; \
|
||||||
size_t count; \
|
size_t count; \
|
||||||
char *name; \
|
char *name; \
|
||||||
ctype null_value; \
|
ctype null_value; \
|
||||||
double scale; \
|
double scale; \
|
||||||
int (*is_null)(ctype *value); \
|
int (*is_null)(ctype *value); \
|
||||||
} monetdbe_column_##typename
|
} monetdbe_column_##typename
|
||||||
|
|
||||||
DEFAULT_STRUCT_DEFINITION(int8_t, bool);
|
DEFAULT_STRUCT_DEFINITION(int8_t, bool);
|
||||||
DEFAULT_STRUCT_DEFINITION(int8_t, int8_t);
|
DEFAULT_STRUCT_DEFINITION(int8_t, int8_t);
|
||||||
DEFAULT_STRUCT_DEFINITION(int16_t, int16_t);
|
DEFAULT_STRUCT_DEFINITION(int16_t, int16_t);
|
||||||
DEFAULT_STRUCT_DEFINITION(int32_t, int32_t);
|
DEFAULT_STRUCT_DEFINITION(int32_t, int32_t);
|
||||||
DEFAULT_STRUCT_DEFINITION(int64_t, int64_t);
|
DEFAULT_STRUCT_DEFINITION(int64_t, int64_t);
|
||||||
#ifdef HAVE_HGE
|
#ifdef HAVE_HGE
|
||||||
DEFAULT_STRUCT_DEFINITION(__int128, int128_t);
|
DEFAULT_STRUCT_DEFINITION(__int128, int128_t);
|
||||||
#endif
|
#endif
|
||||||
DEFAULT_STRUCT_DEFINITION(size_t, size_t);
|
DEFAULT_STRUCT_DEFINITION(size_t, size_t);
|
||||||
|
|
||||||
DEFAULT_STRUCT_DEFINITION(float, float);
|
DEFAULT_STRUCT_DEFINITION(float, float);
|
||||||
DEFAULT_STRUCT_DEFINITION(double, double);
|
DEFAULT_STRUCT_DEFINITION(double, double);
|
||||||
|
|
||||||
DEFAULT_STRUCT_DEFINITION(char *, str);
|
DEFAULT_STRUCT_DEFINITION(char *, str);
|
||||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_blob, blob);
|
DEFAULT_STRUCT_DEFINITION(monetdbe_data_blob, blob);
|
||||||
|
|
||||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_date, date);
|
DEFAULT_STRUCT_DEFINITION(monetdbe_data_date, date);
|
||||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_time, time);
|
DEFAULT_STRUCT_DEFINITION(monetdbe_data_time, time);
|
||||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_timestamp, timestamp);
|
DEFAULT_STRUCT_DEFINITION(monetdbe_data_timestamp, timestamp);
|
||||||
// UUID, INET, XML ?
|
// UUID, INET, XML ?
|
||||||
|
|
||||||
monetdbe_export const char *monetdbe_version(void);
|
monetdbe_export const char *monetdbe_version(void);
|
||||||
|
|
||||||
monetdbe_export int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *opts);
|
monetdbe_export int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *opts);
|
||||||
/* 0 ok, -1 (allocation failed), -2 error in db */
|
/* 0 ok, -1 (allocation failed), -2 error in db */
|
||||||
monetdbe_export int monetdbe_close(monetdbe_database db);
|
monetdbe_export int monetdbe_close(monetdbe_database db);
|
||||||
|
|
||||||
monetdbe_export char* monetdbe_error(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_get_autocommit(monetdbe_database dbhdl, int* result);
|
||||||
monetdbe_export char* monetdbe_set_autocommit(monetdbe_database dbhdl, int value);
|
monetdbe_export char* monetdbe_set_autocommit(monetdbe_database dbhdl, int value);
|
||||||
monetdbe_export int monetdbe_in_transaction(monetdbe_database dbhdl);
|
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_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_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_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_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_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_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_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 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 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_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_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 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);
|
monetdbe_export const char* monetdbe_get_mapi_port(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,239 +1,239 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|x64">
|
<ProjectConfiguration Include="Release|x64">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{b52aacf7-16a6-4fca-90ad-867d367bda4f}</ProjectGuid>
|
<ProjectGuid>{b52aacf7-16a6-4fca-90ad-867d367bda4f}</ProjectGuid>
|
||||||
<RootNamespace>libaquery</RootNamespace>
|
<RootNamespace>libaquery</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="Shared">
|
<ImportGroup Label="Shared">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetExt>.lib</TargetExt>
|
<TargetExt>.lib</TargetExt>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetExt>.lib</TargetExt>
|
<TargetExt>.lib</TargetExt>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||||
</Lib>
|
</Lib>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<ExceptionHandling>false</ExceptionHandling>
|
<ExceptionHandling>false</ExceptionHandling>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<ControlFlowGuard>false</ControlFlowGuard>
|
<ControlFlowGuard>false</ControlFlowGuard>
|
||||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<AssemblyDebug>false</AssemblyDebug>
|
<AssemblyDebug>false</AssemblyDebug>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||||
</Lib>
|
</Lib>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||||
</Lib>
|
</Lib>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<ExceptionHandling>false</ExceptionHandling>
|
<ExceptionHandling>false</ExceptionHandling>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<ControlFlowGuard>false</ControlFlowGuard>
|
<ControlFlowGuard>false</ControlFlowGuard>
|
||||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<AssemblyDebug>false</AssemblyDebug>
|
<AssemblyDebug>false</AssemblyDebug>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;</AdditionalDependencies>
|
||||||
</Lib>
|
</Lib>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\csv.h" />
|
<ClInclude Include="..\csv.h" />
|
||||||
<ClInclude Include="..\server\aggregations.h" />
|
<ClInclude Include="..\server\aggregations.h" />
|
||||||
<ClInclude Include="..\server\gc.hpp" />
|
<ClInclude Include="..\server\gc.hpp" />
|
||||||
<ClInclude Include="..\server\hasher.h" />
|
<ClInclude Include="..\server\hasher.h" />
|
||||||
<ClInclude Include="..\server\io.h" />
|
<ClInclude Include="..\server\io.h" />
|
||||||
<ClInclude Include="..\server\libaquery.h" />
|
<ClInclude Include="..\server\libaquery.h" />
|
||||||
<ClInclude Include="..\server\priority_vector.hpp" />
|
<ClInclude Include="..\server\priority_vector.hpp" />
|
||||||
<ClInclude Include="..\server\table.h" />
|
<ClInclude Include="..\server\table.h" />
|
||||||
<ClInclude Include="..\server\types.h" />
|
<ClInclude Include="..\server\types.h" />
|
||||||
<ClInclude Include="..\server\utils.h" />
|
<ClInclude Include="..\server\utils.h" />
|
||||||
<ClInclude Include="..\server\vector_type.hpp" />
|
<ClInclude Include="..\server\vector_type.hpp" />
|
||||||
<ClInclude Include="..\server\winhelper.h" />
|
<ClInclude Include="..\server\winhelper.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\server\cpp.hint" />
|
<None Include="..\server\cpp.hint" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\server\server.cpp" />
|
<ClCompile Include="..\server\server.cpp" />
|
||||||
<ClCompile Include="..\server\winhelper.cpp" />
|
<ClCompile Include="..\server\winhelper.cpp" />
|
||||||
<ClCompile Include="..\server\io.cpp" />
|
<ClCompile Include="..\server\io.cpp" />
|
||||||
<ClCompile Include="..\server\monetdb_conn.cpp" />
|
<ClCompile Include="..\server\monetdb_conn.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,236 +1,236 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|x64">
|
<ProjectConfiguration Include="Release|x64">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{8081fdaa-4d13-4b7a-adb2-8224af7f1c81}</ProjectGuid>
|
<ProjectGuid>{8081fdaa-4d13-4b7a-adb2-8224af7f1c81}</ProjectGuid>
|
||||||
<RootNamespace>Project1</RootNamespace>
|
<RootNamespace>Project1</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
<ProjectName>msc-plugin</ProjectName>
|
<ProjectName>msc-plugin</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>false</EnableASAN>
|
<EnableASAN>false</EnableASAN>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>false</EnableASAN>
|
<EnableASAN>false</EnableASAN>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>false</EnableASAN>
|
<EnableASAN>false</EnableASAN>
|
||||||
<EnableFuzzer>false</EnableFuzzer>
|
<EnableFuzzer>false</EnableFuzzer>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<EnableASAN>false</EnableASAN>
|
<EnableASAN>false</EnableASAN>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="Shared">
|
<ImportGroup Label="Shared">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<TargetExt />
|
<TargetExt />
|
||||||
<TargetName>dll.so</TargetName>
|
<TargetName>dll.so</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<TargetExt />
|
<TargetExt />
|
||||||
<TargetName>dll.so</TargetName>
|
<TargetName>dll.so</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<TargetExt />
|
<TargetExt />
|
||||||
<TargetName>dll.so</TargetName>
|
<TargetName>dll.so</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<TargetExt />
|
<TargetExt />
|
||||||
<TargetName>dll.so</TargetName>
|
<TargetName>dll.so</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||||
<EnableModules>false</EnableModules>
|
<EnableModules>false</EnableModules>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||||
<AssemblyDebug>true</AssemblyDebug>
|
<AssemblyDebug>true</AssemblyDebug>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<ExceptionHandling>false</ExceptionHandling>
|
<ExceptionHandling>false</ExceptionHandling>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<ControlFlowGuard>false</ControlFlowGuard>
|
<ControlFlowGuard>false</ControlFlowGuard>
|
||||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
<EnableModules>false</EnableModules>
|
<EnableModules>false</EnableModules>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AssemblyDebug>false</AssemblyDebug>
|
<AssemblyDebug>false</AssemblyDebug>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_ALLOW_RTCc_IN_STL;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_ALLOW_RTCc_IN_STL;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||||
<EnableModules>false</EnableModules>
|
<EnableModules>false</EnableModules>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
||||||
<OmitFramePointers>false</OmitFramePointers>
|
<OmitFramePointers>false</OmitFramePointers>
|
||||||
<SmallerTypeCheck>true</SmallerTypeCheck>
|
<SmallerTypeCheck>true</SmallerTypeCheck>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/WL %(AdditionalOptions)</AdditionalOptions>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||||
<AssemblyDebug>true</AssemblyDebug>
|
<AssemblyDebug>true</AssemblyDebug>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<ExceptionHandling>false</ExceptionHandling>
|
<ExceptionHandling>false</ExceptionHandling>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<ControlFlowGuard>false</ControlFlowGuard>
|
<ControlFlowGuard>false</ControlFlowGuard>
|
||||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||||
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
|
||||||
<EnableModules>false</EnableModules>
|
<EnableModules>false</EnableModules>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
<OutputFile>$(ProjectDir)\..\dll.so</OutputFile>
|
||||||
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AssemblyDebug>false</AssemblyDebug>
|
<AssemblyDebug>false</AssemblyDebug>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\out.cpp" />
|
<ClCompile Include="..\out.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,167 +1,167 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|x64">
|
<ProjectConfiguration Include="Release|x64">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{f954797b-c148-4cbf-9fb4-a9a450efec38}</ProjectGuid>
|
<ProjectGuid>{f954797b-c148-4cbf-9fb4-a9a450efec38}</ProjectGuid>
|
||||||
<RootNamespace>Project1</RootNamespace>
|
<RootNamespace>Project1</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="Shared">
|
<ImportGroup Label="Shared">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
<TargetName>test</TargetName>
|
<TargetName>test</TargetName>
|
||||||
<TargetExt>.so</TargetExt>
|
<TargetExt>.so</TargetExt>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
<TargetName>test</TargetName>
|
<TargetName>test</TargetName>
|
||||||
<TargetExt>.so</TargetExt>
|
<TargetExt>.so</TargetExt>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
<TargetName>test</TargetName>
|
<TargetName>test</TargetName>
|
||||||
<TargetExt>.so</TargetExt>
|
<TargetExt>.so</TargetExt>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
<TargetName>test</TargetName>
|
<TargetName>test</TargetName>
|
||||||
<TargetExt>.so</TargetExt>
|
<TargetExt>.so</TargetExt>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\sdk\aquery.h" />
|
<ClInclude Include="..\sdk\aquery.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\sdk\aquery_mem.cpp" />
|
<ClCompile Include="..\sdk\aquery_mem.cpp" />
|
||||||
<ClCompile Include="..\sdk\example.cpp" />
|
<ClCompile Include="..\sdk\example.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,63 +1,63 @@
|
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>ccc243f5-663e-45b7-a6de-b2468c58b3a7</ProjectGuid>
|
<ProjectGuid>ccc243f5-663e-45b7-a6de-b2468c58b3a7</ProjectGuid>
|
||||||
<ProjectHome>.</ProjectHome>
|
<ProjectHome>.</ProjectHome>
|
||||||
<StartupFile>..\prompt.py</StartupFile>
|
<StartupFile>..\prompt.py</StartupFile>
|
||||||
<SearchPath>..\msvs-py</SearchPath>
|
<SearchPath>..\msvs-py</SearchPath>
|
||||||
<WorkingDirectory>..</WorkingDirectory>
|
<WorkingDirectory>..</WorkingDirectory>
|
||||||
<OutputPath>.</OutputPath>
|
<OutputPath>.</OutputPath>
|
||||||
<Name>msvs-py</Name>
|
<Name>msvs-py</Name>
|
||||||
<RootNamespace>msvs-py</RootNamespace>
|
<RootNamespace>msvs-py</RootNamespace>
|
||||||
<IsWindowsApplication>False</IsWindowsApplication>
|
<IsWindowsApplication>False</IsWindowsApplication>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="..\aquery_parser\" />
|
<Folder Include="..\aquery_parser\" />
|
||||||
<Folder Include="..\engine\" />
|
<Folder Include="..\engine\" />
|
||||||
<Folder Include="parser\" />
|
<Folder Include="parser\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\aquery_parser\keywords.py" />
|
<Compile Include="..\aquery_parser\keywords.py" />
|
||||||
<Compile Include="..\aquery_parser\sql_parser.py" />
|
<Compile Include="..\aquery_parser\sql_parser.py" />
|
||||||
<Compile Include="..\aquery_parser\types.py" />
|
<Compile Include="..\aquery_parser\types.py" />
|
||||||
<Compile Include="..\aquery_parser\utils.py" />
|
<Compile Include="..\aquery_parser\utils.py" />
|
||||||
<Compile Include="..\aquery_parser\windows.py" />
|
<Compile Include="..\aquery_parser\windows.py" />
|
||||||
<Compile Include="..\aquery_parser\__init__.py" />
|
<Compile Include="..\aquery_parser\__init__.py" />
|
||||||
<Compile Include="..\engine\ast.py" />
|
<Compile Include="..\engine\ast.py" />
|
||||||
<Compile Include="..\engine\ddl.py" />
|
<Compile Include="..\engine\ddl.py" />
|
||||||
<Compile Include="..\engine\expr.py" />
|
<Compile Include="..\engine\expr.py" />
|
||||||
<Compile Include="..\engine\groupby.py" />
|
<Compile Include="..\engine\groupby.py" />
|
||||||
<Compile Include="..\engine\join.py" />
|
<Compile Include="..\engine\join.py" />
|
||||||
<Compile Include="..\engine\orderby.py" />
|
<Compile Include="..\engine\orderby.py" />
|
||||||
<Compile Include="..\engine\projection.py" />
|
<Compile Include="..\engine\projection.py" />
|
||||||
<Compile Include="..\engine\scan.py" />
|
<Compile Include="..\engine\scan.py" />
|
||||||
<Compile Include="..\engine\types.py" />
|
<Compile Include="..\engine\types.py" />
|
||||||
<Compile Include="..\reconstruct\storage.py" />
|
<Compile Include="..\reconstruct\storage.py" />
|
||||||
<Compile Include="..\reconstruct\expr.py" />
|
<Compile Include="..\reconstruct\expr.py" />
|
||||||
<Compile Include="..\reconstruct\__init__.py" />
|
<Compile Include="..\reconstruct\__init__.py" />
|
||||||
<Compile Include="..\reconstruct\ast.py" />
|
<Compile Include="..\reconstruct\ast.py" />
|
||||||
<Compile Include="..\engine\__init__.py" />
|
<Compile Include="..\engine\__init__.py" />
|
||||||
<Compile Include="..\prompt.py" />
|
<Compile Include="..\prompt.py" />
|
||||||
<Compile Include="..\build.py" />
|
<Compile Include="..\build.py" />
|
||||||
<Compile Include="..\aquery_config.py" />
|
<Compile Include="..\aquery_config.py" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||||
Visual Studio and specify your pre- and post-build commands in
|
Visual Studio and specify your pre- and post-build commands in
|
||||||
the BeforeBuild and AfterBuild targets below. -->
|
the BeforeBuild and AfterBuild targets below. -->
|
||||||
<!--<Target Name="CoreCompile" />-->
|
<!--<Target Name="CoreCompile" />-->
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
</Target>
|
</Target>
|
||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
@ -1,11 +1,11 @@
|
|||||||
# TODO:
|
# TODO:
|
||||||
|
|
||||||
## 1. double scans in projections
|
## 1. double scans in projections
|
||||||
- first for special aggrigations and singular columns
|
- first for special aggrigations and singular columns
|
||||||
- Then in group by node decide if we have special group by aggregations
|
- 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 sp_gb_agg exists, the entire groupby aggregation is done in C plugin
|
||||||
- If not, group by is done in SQL
|
- If not, group by is done in SQL
|
||||||
|
|
||||||
## 2. ColRef supports multiple objects
|
## 2. ColRef supports multiple objects
|
||||||
- A.a = B.b then in projection A.a B.b will refer to same projection
|
- 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
|
- Colref::ProjEq(ColRef v) => this == v or v in this.proj_eqs
|
@ -1,32 +1,32 @@
|
|||||||
from reconstruct.ast import Context, ast_node
|
from reconstruct.ast import Context, ast_node
|
||||||
saved_cxt = None
|
saved_cxt = None
|
||||||
|
|
||||||
def initialize(cxt = None, keep = False):
|
def initialize(cxt = None, keep = False):
|
||||||
global saved_cxt
|
global saved_cxt
|
||||||
if cxt is None or not keep or type(cxt) is not Context:
|
if cxt is None or not keep or type(cxt) is not Context:
|
||||||
if saved_cxt is None or not keep:
|
if saved_cxt is None or not keep:
|
||||||
cxt = Context()
|
cxt = Context()
|
||||||
saved_cxt = cxt
|
saved_cxt = cxt
|
||||||
else:
|
else:
|
||||||
cxt = saved_cxt
|
cxt = saved_cxt
|
||||||
cxt.new()
|
cxt.new()
|
||||||
return cxt
|
return cxt
|
||||||
|
|
||||||
def generate(ast, cxt):
|
def generate(ast, cxt):
|
||||||
for k in ast.keys():
|
for k in ast.keys():
|
||||||
if k in ast_node.types.keys():
|
if k in ast_node.types.keys():
|
||||||
ast_node.types[k](None, ast, cxt)
|
ast_node.types[k](None, ast, cxt)
|
||||||
|
|
||||||
def exec(stmts, cxt = None, keep = False):
|
def exec(stmts, cxt = None, keep = False):
|
||||||
cxt = initialize(cxt, keep)
|
cxt = initialize(cxt, keep)
|
||||||
stmts_stmts = stmts['stmts']
|
stmts_stmts = stmts['stmts']
|
||||||
if type(stmts_stmts) is list:
|
if type(stmts_stmts) is list:
|
||||||
for s in stmts_stmts:
|
for s in stmts_stmts:
|
||||||
generate(s, cxt)
|
generate(s, cxt)
|
||||||
else:
|
else:
|
||||||
generate(stmts_stmts, cxt)
|
generate(stmts_stmts, cxt)
|
||||||
for q in cxt.queries:
|
for q in cxt.queries:
|
||||||
cxt.print(q.strip())
|
cxt.print(q.strip())
|
||||||
return cxt
|
return cxt
|
||||||
|
|
||||||
__all__ = ["initialize", "generate", "exec", "saved_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 typing import Optional
|
||||||
from reconstruct.ast import ast_node
|
from reconstruct.ast import ast_node
|
||||||
from reconstruct.storage import ColRef, Context
|
from reconstruct.storage import ColRef, Context
|
||||||
from engine.types import *
|
from engine.types import *
|
||||||
|
|
||||||
# TODO: Decouple expr and upgrade architecture
|
# TODO: Decouple expr and upgrade architecture
|
||||||
# C_CODE : get ccode/sql code?
|
# C_CODE : get ccode/sql code?
|
||||||
# projections : C/SQL/decltype string
|
# projections : C/SQL/decltype string
|
||||||
# orderby/joins/where : SQL only
|
# orderby/joins/where : SQL only
|
||||||
# assumption/groupby : C/sql
|
# assumption/groupby : C/sql
|
||||||
# is_udfexpr: C only
|
# is_udfexpr: C only
|
||||||
|
|
||||||
class expr(ast_node):
|
class expr(ast_node):
|
||||||
name='expr'
|
name='expr'
|
||||||
@property
|
@property
|
||||||
def udf_decltypecall(self):
|
def udf_decltypecall(self):
|
||||||
return self._udf_decltypecall if self._udf_decltypecall else self.sql
|
return self._udf_decltypecall if self._udf_decltypecall else self.sql
|
||||||
|
|
||||||
@udf_decltypecall.setter
|
@udf_decltypecall.setter
|
||||||
def udf_decltypecall(self, val):
|
def udf_decltypecall(self, val):
|
||||||
self._udf_decltypecall = val
|
self._udf_decltypecall = val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def need_decltypestr(self):
|
def need_decltypestr(self):
|
||||||
return self._udf_decltypecall is not None
|
return self._udf_decltypecall is not None
|
||||||
|
|
||||||
def __init__(self, parent, node, *, c_code = None, supress_undefined = False):
|
def __init__(self, parent, node, *, c_code = None, supress_undefined = False):
|
||||||
from reconstruct.ast import projection, udf
|
from reconstruct.ast import projection, udf
|
||||||
|
|
||||||
self.type = None
|
self.type = None
|
||||||
self.raw_col = None
|
self.raw_col = None
|
||||||
self.udf : Optional[udf] = None
|
self.udf : Optional[udf] = None
|
||||||
self.inside_agg = False
|
self.inside_agg = False
|
||||||
self.is_special = False
|
self.is_special = False
|
||||||
self.is_ColExpr = False
|
self.is_ColExpr = False
|
||||||
self.is_recursive_call_inudf = False
|
self.is_recursive_call_inudf = False
|
||||||
self.codlets : list = []
|
self.codlets : list = []
|
||||||
self.codebuf : Optional[str] = None
|
self.codebuf : Optional[str] = None
|
||||||
self._udf_decltypecall = None
|
self._udf_decltypecall = None
|
||||||
self.node = node
|
self.node = node
|
||||||
self.supress_undefined = supress_undefined
|
self.supress_undefined = supress_undefined
|
||||||
if(type(parent) is expr):
|
if(type(parent) is expr):
|
||||||
self.inside_agg = parent.inside_agg
|
self.inside_agg = parent.inside_agg
|
||||||
self.is_udfexpr = parent.is_udfexpr
|
self.is_udfexpr = parent.is_udfexpr
|
||||||
self.is_agg_func = parent.is_agg_func
|
self.is_agg_func = parent.is_agg_func
|
||||||
self.root : expr = parent.root
|
self.root : expr = parent.root
|
||||||
self.c_code = parent.c_code
|
self.c_code = parent.c_code
|
||||||
self.builtin_vars = parent.builtin_vars
|
self.builtin_vars = parent.builtin_vars
|
||||||
else:
|
else:
|
||||||
self.is_agg_func = False
|
self.is_agg_func = False
|
||||||
self.is_udfexpr = type(parent) is udf
|
self.is_udfexpr = type(parent) is udf
|
||||||
self.root : expr = self
|
self.root : expr = self
|
||||||
self.c_code = self.is_udfexpr or type(parent) is projection
|
self.c_code = self.is_udfexpr or type(parent) is projection
|
||||||
if self.is_udfexpr:
|
if self.is_udfexpr:
|
||||||
self.udf : udf = parent
|
self.udf : udf = parent
|
||||||
self.builtin_vars = self.udf.builtin.keys()
|
self.builtin_vars = self.udf.builtin.keys()
|
||||||
else:
|
else:
|
||||||
self.builtin_vars = []
|
self.builtin_vars = []
|
||||||
if type(c_code) is bool:
|
if type(c_code) is bool:
|
||||||
self.c_code = c_code
|
self.c_code = c_code
|
||||||
|
|
||||||
self.udf_called = None
|
self.udf_called = None
|
||||||
self.cols_mentioned : Optional[set[ColRef]] = None
|
self.cols_mentioned : Optional[set[ColRef]] = None
|
||||||
ast_node.__init__(self, parent, node, None)
|
ast_node.__init__(self, parent, node, None)
|
||||||
|
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
from reconstruct.ast import projection
|
from reconstruct.ast import projection
|
||||||
parent = self.parent
|
parent = self.parent
|
||||||
self.isvector = parent.isvector if type(parent) is expr else False
|
self.isvector = parent.isvector if type(parent) is expr else False
|
||||||
self.is_compound = parent.is_compound 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]:
|
if type(parent) in [projection, expr]:
|
||||||
self.datasource = parent.datasource
|
self.datasource = parent.datasource
|
||||||
else:
|
else:
|
||||||
self.datasource = self.context.datasource
|
self.datasource = self.context.datasource
|
||||||
self.udf_map = parent.context.udf_map
|
self.udf_map = parent.context.udf_map
|
||||||
self.func_maps = {**builtin_func, **self.udf_map, **user_module_func}
|
self.func_maps = {**builtin_func, **self.udf_map, **user_module_func}
|
||||||
self.operators = {**builtin_operators, **self.udf_map, **user_module_func}
|
self.operators = {**builtin_operators, **self.udf_map, **user_module_func}
|
||||||
|
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
from engine.utils import enlist
|
from engine.utils import enlist
|
||||||
from reconstruct.ast import udf
|
from reconstruct.ast import udf
|
||||||
|
|
||||||
if type(node) is dict:
|
if type(node) is dict:
|
||||||
for key, val in node.items():
|
for key, val in node.items():
|
||||||
if key in self.operators:
|
if key in self.operators:
|
||||||
if key in builtin_func:
|
if key in builtin_func:
|
||||||
if self.is_agg_func:
|
if self.is_agg_func:
|
||||||
self.root.is_special = True # Nested Aggregation
|
self.root.is_special = True # Nested Aggregation
|
||||||
else:
|
else:
|
||||||
self.is_agg_func = True
|
self.is_agg_func = True
|
||||||
|
|
||||||
op = self.operators[key]
|
op = self.operators[key]
|
||||||
|
|
||||||
val = enlist(val)
|
val = enlist(val)
|
||||||
exp_vals = [expr(self, v, c_code = self.c_code) for v in val]
|
exp_vals = [expr(self, v, c_code = self.c_code) for v in val]
|
||||||
str_vals = [e.sql for e in exp_vals]
|
str_vals = [e.sql for e in exp_vals]
|
||||||
type_vals = [e.type for e in exp_vals]
|
type_vals = [e.type for e in exp_vals]
|
||||||
try:
|
try:
|
||||||
self.type = op.return_type(*type_vals)
|
self.type = op.return_type(*type_vals)
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
if type(self.root) is not udf:
|
if type(self.root) is not udf:
|
||||||
# TODO: do something when this is not an error
|
# TODO: do something when this is not an error
|
||||||
# print(f'alert: {e}')
|
# print(f'alert: {e}')
|
||||||
pass
|
pass
|
||||||
self.type = AnyT
|
self.type = AnyT
|
||||||
|
|
||||||
self.sql = op(self.c_code, *str_vals)
|
self.sql = op(self.c_code, *str_vals)
|
||||||
special_func = [*self.context.udf_map.keys(), *self.context.module_map.keys(), "maxs", "mins", "avgs", "sums"]
|
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:
|
if key in special_func and not self.is_special:
|
||||||
self.is_special = True
|
self.is_special = True
|
||||||
if key in self.context.udf_map:
|
if key in self.context.udf_map:
|
||||||
self.root.udf_called = self.context.udf_map[key]
|
self.root.udf_called = self.context.udf_map[key]
|
||||||
if self.is_udfexpr and key == self.root.udf.name:
|
if self.is_udfexpr and key == self.root.udf.name:
|
||||||
self.root.is_recursive_call_inudf = True
|
self.root.is_recursive_call_inudf = True
|
||||||
elif key in user_module_func.keys():
|
elif key in user_module_func.keys():
|
||||||
udf.try_init_udf(self.context)
|
udf.try_init_udf(self.context)
|
||||||
# TODO: make udf_called a set!
|
# TODO: make udf_called a set!
|
||||||
p = self.parent
|
p = self.parent
|
||||||
while type(p) is expr and not p.udf_called:
|
while type(p) is expr and not p.udf_called:
|
||||||
p.udf_called = self.udf_called
|
p.udf_called = self.udf_called
|
||||||
p = p.parent
|
p = p.parent
|
||||||
p = self.parent
|
p = self.parent
|
||||||
while type(p) is expr and not p.is_special:
|
while type(p) is expr and not p.is_special:
|
||||||
p.is_special = True
|
p.is_special = True
|
||||||
p = p.parent
|
p = p.parent
|
||||||
|
|
||||||
need_decltypestr = any([e.need_decltypestr for e in exp_vals])
|
need_decltypestr = any([e.need_decltypestr for e in exp_vals])
|
||||||
if need_decltypestr or (self.udf_called and type(op) is udf):
|
if need_decltypestr or (self.udf_called and type(op) is udf):
|
||||||
decltypestr_vals = [e.udf_decltypecall for e in exp_vals]
|
decltypestr_vals = [e.udf_decltypecall for e in exp_vals]
|
||||||
self.udf_decltypecall = op(self.c_code, *decltypestr_vals)
|
self.udf_decltypecall = op(self.c_code, *decltypestr_vals)
|
||||||
|
|
||||||
if self.udf_called and type(op) is udf:
|
if self.udf_called and type(op) is udf:
|
||||||
self.udf_decltypecall = op.decltypecall(self.c_code, *decltypestr_vals)
|
self.udf_decltypecall = op.decltypecall(self.c_code, *decltypestr_vals)
|
||||||
|
|
||||||
elif self.is_udfexpr:
|
elif self.is_udfexpr:
|
||||||
var_table = self.root.udf.var_table
|
var_table = self.root.udf.var_table
|
||||||
vec = key.split('.')
|
vec = key.split('.')
|
||||||
_vars = [*var_table, *self.builtin_vars]
|
_vars = [*var_table, *self.builtin_vars]
|
||||||
def get_vname (node):
|
def get_vname (node):
|
||||||
if node in self.builtin_vars:
|
if node in self.builtin_vars:
|
||||||
self.root.udf.builtin[node].enabled = True
|
self.root.udf.builtin[node].enabled = True
|
||||||
self.builtin_var = node
|
self.builtin_var = node
|
||||||
return node
|
return node
|
||||||
else:
|
else:
|
||||||
return var_table[node]
|
return var_table[node]
|
||||||
if vec[0] not in _vars:
|
if vec[0] not in _vars:
|
||||||
# print(f'Use of undefined variable {vec[0]}')
|
# print(f'Use of undefined variable {vec[0]}')
|
||||||
# TODO: do something when this is not an error
|
# TODO: do something when this is not an error
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
vname = get_vname(vec[0])
|
vname = get_vname(vec[0])
|
||||||
val = enlist(val)
|
val = enlist(val)
|
||||||
if(len(val) > 2):
|
if(len(val) > 2):
|
||||||
print('Warning: more than 2 indexes found for subvec operator.')
|
print('Warning: more than 2 indexes found for subvec operator.')
|
||||||
ex = [expr(self, v, c_code = self.c_code) for v in val]
|
ex = [expr(self, v, c_code = self.c_code) for v in val]
|
||||||
idxs = ', '.join([e.sql for e in ex])
|
idxs = ', '.join([e.sql for e in ex])
|
||||||
self.sql = f'{vname}.subvec({idxs})'
|
self.sql = f'{vname}.subvec({idxs})'
|
||||||
if any([e.need_decltypestr for e in ex]):
|
if any([e.need_decltypestr for e in ex]):
|
||||||
self.udf_decltypecall = f'{vname}.subvec({[", ".join([e.udf_decltypecall 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:
|
if key == 'get' and len(val) > 1:
|
||||||
ex_vname = expr(self, val[0], c_code=self.c_code)
|
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}]'
|
self.sql = f'{ex_vname.sql}[{expr(self, val[1], c_code=self.c_code).sql}]'
|
||||||
if hasattr(ex_vname, 'builtin_var'):
|
if hasattr(ex_vname, 'builtin_var'):
|
||||||
if not hasattr(self, 'builtin_var'):
|
if not hasattr(self, 'builtin_var'):
|
||||||
self.builtin_var = []
|
self.builtin_var = []
|
||||||
self.builtin_var = [*self.builtin_var, *ex_vname.builtin_var]
|
self.builtin_var = [*self.builtin_var, *ex_vname.builtin_var]
|
||||||
self.udf_decltypecall = ex_vname.sql
|
self.udf_decltypecall = ex_vname.sql
|
||||||
else:
|
else:
|
||||||
print(f'Undefined expr: {key}{val}')
|
print(f'Undefined expr: {key}{val}')
|
||||||
|
|
||||||
elif type(node) is str:
|
elif type(node) is str:
|
||||||
if self.is_udfexpr:
|
if self.is_udfexpr:
|
||||||
curr_udf : udf = self.root.udf
|
curr_udf : udf = self.root.udf
|
||||||
var_table = curr_udf.var_table
|
var_table = curr_udf.var_table
|
||||||
split = node.split('.')
|
split = node.split('.')
|
||||||
if split[0] in var_table:
|
if split[0] in var_table:
|
||||||
varname = var_table[split[0]]
|
varname = var_table[split[0]]
|
||||||
if curr_udf.agg and varname in curr_udf.vecs:
|
if curr_udf.agg and varname in curr_udf.vecs:
|
||||||
if len(split) > 1:
|
if len(split) > 1:
|
||||||
if split[1] == 'vec':
|
if split[1] == 'vec':
|
||||||
self.sql += varname
|
self.sql += varname
|
||||||
elif split[1] == 'len':
|
elif split[1] == 'len':
|
||||||
self.sql += f'{varname}.size'
|
self.sql += f'{varname}.size'
|
||||||
else:
|
else:
|
||||||
print(f'no member {split[1]} in object {varname}')
|
print(f'no member {split[1]} in object {varname}')
|
||||||
else:
|
else:
|
||||||
self.sql += f'{varname}[{curr_udf.idx_var}]'
|
self.sql += f'{varname}[{curr_udf.idx_var}]'
|
||||||
else:
|
else:
|
||||||
self.sql += varname
|
self.sql += varname
|
||||||
elif self.supress_undefined or split[0] in self.builtin_vars:
|
elif self.supress_undefined or split[0] in self.builtin_vars:
|
||||||
self.sql += node
|
self.sql += node
|
||||||
if split[0] in self.builtin_vars:
|
if split[0] in self.builtin_vars:
|
||||||
curr_udf.builtin[split[0]].enabled = True
|
curr_udf.builtin[split[0]].enabled = True
|
||||||
self.builtin_var = split[0]
|
self.builtin_var = split[0]
|
||||||
else:
|
else:
|
||||||
print(f'Undefined varname: {split[0]}')
|
print(f'Undefined varname: {split[0]}')
|
||||||
|
|
||||||
|
|
||||||
# get the column from the datasource in SQL context
|
# get the column from the datasource in SQL context
|
||||||
else:
|
else:
|
||||||
p = self.parent
|
p = self.parent
|
||||||
while type(p) is expr and not p.isvector:
|
while type(p) is expr and not p.isvector:
|
||||||
p.isvector = True
|
p.isvector = True
|
||||||
p = p.parent
|
p = p.parent
|
||||||
if self.datasource is not None:
|
if self.datasource is not None:
|
||||||
self.raw_col = self.datasource.parse_col_names(node)
|
self.raw_col = self.datasource.parse_col_names(node)
|
||||||
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
self.raw_col = self.raw_col if type(self.raw_col) is ColRef else None
|
||||||
if self.raw_col is not None:
|
if self.raw_col is not None:
|
||||||
self.is_ColExpr = True
|
self.is_ColExpr = True
|
||||||
self.sql = self.raw_col.name
|
self.sql = self.raw_col.name
|
||||||
self.type = self.raw_col.type
|
self.type = self.raw_col.type
|
||||||
else:
|
else:
|
||||||
self.sql = node
|
self.sql = node
|
||||||
self.type = StrT
|
self.type = StrT
|
||||||
if self.c_code and self.datasource is not None:
|
if self.c_code and self.datasource is not None:
|
||||||
self.sql = f'{{y(\"{self.sql}\")}}'
|
self.sql = f'{{y(\"{self.sql}\")}}'
|
||||||
elif type(node) is bool:
|
elif type(node) is bool:
|
||||||
self.type = BoolT
|
self.type = BoolT
|
||||||
if self.c_code:
|
if self.c_code:
|
||||||
self.sql = '1' if node else '0'
|
self.sql = '1' if node else '0'
|
||||||
else:
|
else:
|
||||||
self.sql = 'TRUE' if node else 'FALSE'
|
self.sql = 'TRUE' if node else 'FALSE'
|
||||||
else:
|
else:
|
||||||
self.sql = f'{node}'
|
self.sql = f'{node}'
|
||||||
if type(node) is int:
|
if type(node) is int:
|
||||||
if (node >= 2**63 - 1 or node <= -2**63):
|
if (node >= 2**63 - 1 or node <= -2**63):
|
||||||
self.type = LongT
|
self.type = LongT
|
||||||
else:
|
else:
|
||||||
self.type = IntT
|
self.type = IntT
|
||||||
elif type(node) is float:
|
elif type(node) is float:
|
||||||
self.type = DoubleT
|
self.type = DoubleT
|
||||||
|
|
||||||
def finalize(self, override = False):
|
def finalize(self, override = False):
|
||||||
from reconstruct.ast import udf
|
from reconstruct.ast import udf
|
||||||
if self.codebuf is None or override:
|
if self.codebuf is None or override:
|
||||||
self.codebuf = ''
|
self.codebuf = ''
|
||||||
for c in self.codlets:
|
for c in self.codlets:
|
||||||
if type(c) is str:
|
if type(c) is str:
|
||||||
self.codebuf += c
|
self.codebuf += c
|
||||||
elif type(c) is udf:
|
elif type(c) is udf:
|
||||||
self.codebuf += c()
|
self.codebuf += c()
|
||||||
elif type(c) is expr:
|
elif type(c) is expr:
|
||||||
self.codebuf += c.finalize(override=override)
|
self.codebuf += c.finalize(override=override)
|
||||||
return self.codebuf
|
return self.codebuf
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.sql
|
return self.sql
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.__str__()
|
return self.__str__()
|
||||||
|
|
||||||
# builtins is readonly, so it's okay to set default value as an object
|
# builtins is readonly, so it's okay to set default value as an object
|
||||||
# eval is only called at root expr.
|
# eval is only called at root expr.
|
||||||
def eval(self, c_code = None, y = lambda t: t, materialize_builtin = False, _decltypestr = False, *, gettype = False):
|
def eval(self, c_code = None, y = lambda t: t, materialize_builtin = False, _decltypestr = False, *, gettype = False):
|
||||||
assert(self.is_root)
|
assert(self.is_root)
|
||||||
def call(decltypestr = False) -> str:
|
def call(decltypestr = False) -> str:
|
||||||
nonlocal c_code, y, materialize_builtin
|
nonlocal c_code, y, materialize_builtin
|
||||||
if self.udf_called is not None:
|
if self.udf_called is not None:
|
||||||
loc = locals()
|
loc = locals()
|
||||||
builtin_vars = self.udf_called.builtin_used
|
builtin_vars = self.udf_called.builtin_used
|
||||||
for b in self.udf_called.builtin_var.all:
|
for b in self.udf_called.builtin_var.all:
|
||||||
exec(f'loc["{b}"] = lambda: "{{{b}()}}"')
|
exec(f'loc["{b}"] = lambda: "{{{b}()}}"')
|
||||||
if builtin_vars:
|
if builtin_vars:
|
||||||
if type(materialize_builtin) is dict:
|
if type(materialize_builtin) is dict:
|
||||||
for b in builtin_vars:
|
for b in builtin_vars:
|
||||||
exec(f'loc["{b}"] = lambda: "{materialize_builtin[b]}"')
|
exec(f'loc["{b}"] = lambda: "{materialize_builtin[b]}"')
|
||||||
elif self.is_recursive_call_inudf:
|
elif self.is_recursive_call_inudf:
|
||||||
for b in builtin_vars:
|
for b in builtin_vars:
|
||||||
exec(f'loc["{b}"] = lambda : "{b}"')
|
exec(f'loc["{b}"] = lambda : "{b}"')
|
||||||
|
|
||||||
x = self.c_code if c_code is None else c_code
|
x = self.c_code if c_code is None else c_code
|
||||||
if decltypestr:
|
if decltypestr:
|
||||||
return eval('f\'' + self.udf_decltypecall + '\'')
|
return eval('f\'' + self.udf_decltypecall + '\'')
|
||||||
return eval('f\'' + self.sql + '\'')
|
return eval('f\'' + self.sql + '\'')
|
||||||
if self.is_recursive_call_inudf or (self.need_decltypestr and self.is_udfexpr) or gettype:
|
if self.is_recursive_call_inudf or (self.need_decltypestr and self.is_udfexpr) or gettype:
|
||||||
return call
|
return call
|
||||||
else:
|
else:
|
||||||
return call(_decltypestr)
|
return call(_decltypestr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_root(self):
|
def is_root(self):
|
||||||
return self.root == self
|
return self.root == self
|
||||||
|
|
||||||
|
|
||||||
# For UDFs: first check if agg variable is used as vector
|
# For UDFs: first check if agg variable is used as vector
|
||||||
# if not, then check if its length is used
|
# if not, then check if its length is used
|
||||||
class fastscan(expr):
|
class fastscan(expr):
|
||||||
name = 'fastscan'
|
name = 'fastscan'
|
||||||
|
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
self.vec_vars = set()
|
self.vec_vars = set()
|
||||||
self.requested_lens = set()
|
self.requested_lens = set()
|
||||||
super().init(self, _)
|
super().init(self, _)
|
||||||
|
|
||||||
def process(self, key : str):
|
def process(self, key : str):
|
||||||
segs = key.split('.')
|
segs = key.split('.')
|
||||||
var_table = self.root.udf.var_table
|
var_table = self.root.udf.var_table
|
||||||
if segs[0] in var_table and len(segs) > 1:
|
if segs[0] in var_table and len(segs) > 1:
|
||||||
if segs[1] == 'vec':
|
if segs[1] == 'vec':
|
||||||
self.vec_vars.add(segs[0])
|
self.vec_vars.add(segs[0])
|
||||||
elif segs[1] == 'len':
|
elif segs[1] == 'len':
|
||||||
self.requested_lens.add(segs[0])
|
self.requested_lens.add(segs[0])
|
||||||
|
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
from engine.utils import enlist
|
from engine.utils import enlist
|
||||||
if type(node) is dict:
|
if type(node) is dict:
|
||||||
for key, val in node.items():
|
for key, val in node.items():
|
||||||
if key in self.operators:
|
if key in self.operators:
|
||||||
val = enlist(val)
|
val = enlist(val)
|
||||||
elif self.is_udfexpr:
|
elif self.is_udfexpr:
|
||||||
self.process(key)
|
self.process(key)
|
||||||
[fastscan(self, v, c_code = self.c_code) for v in val]
|
[fastscan(self, v, c_code = self.c_code) for v in val]
|
||||||
|
|
||||||
elif type(node) is str:
|
elif type(node) is str:
|
||||||
self.process(node)
|
self.process(node)
|
||||||
|
|
||||||
|
|
||||||
class getrefs(expr):
|
class getrefs(expr):
|
||||||
name = 'getrefs'
|
name = 'getrefs'
|
||||||
|
|
||||||
def init(self, _):
|
def init(self, _):
|
||||||
self.datasource.rec = set()
|
self.datasource.rec = set()
|
||||||
self.rec = None
|
self.rec = None
|
||||||
|
|
||||||
def produce(self, node):
|
def produce(self, node):
|
||||||
from engine.utils import enlist
|
from engine.utils import enlist
|
||||||
if type(node) is dict:
|
if type(node) is dict:
|
||||||
for key, val in node.items():
|
for key, val in node.items():
|
||||||
if key in self.operators:
|
if key in self.operators:
|
||||||
val = enlist(val)
|
val = enlist(val)
|
||||||
[getrefs(self, v, c_code = self.c_code) for v in val]
|
[getrefs(self, v, c_code = self.c_code) for v in val]
|
||||||
|
|
||||||
elif type(node) is str:
|
elif type(node) is str:
|
||||||
self.datasource.parse_col_names(node)
|
self.datasource.parse_col_names(node)
|
||||||
|
|
||||||
def consume(self, _):
|
def consume(self, _):
|
||||||
if self.root == self:
|
if self.root == self:
|
||||||
self.rec = self.datasource.rec
|
self.rec = self.datasource.rec
|
||||||
self.datasource.rec = None
|
self.datasource.rec = None
|
@ -1,203 +1,203 @@
|
|||||||
from engine.types import *
|
from engine.types import *
|
||||||
from engine.utils import enlist
|
from engine.utils import enlist
|
||||||
from typing import List, Dict, Set
|
from typing import List, Dict, Set
|
||||||
|
|
||||||
class ColRef:
|
class ColRef:
|
||||||
def __init__(self, _ty, cobj, table:'TableInfo', name, id, compound = False, _ty_args = None):
|
def __init__(self, _ty, cobj, table:'TableInfo', name, id, compound = False, _ty_args = None):
|
||||||
self.type : Types = AnyT
|
self.type : Types = AnyT
|
||||||
if type(_ty) is str:
|
if type(_ty) is str:
|
||||||
self.type = builtin_types[_ty.lower()]
|
self.type = builtin_types[_ty.lower()]
|
||||||
if _ty_args:
|
if _ty_args:
|
||||||
self.type = self.type(enlist(_ty_args))
|
self.type = self.type(enlist(_ty_args))
|
||||||
elif type(_ty) is Types:
|
elif type(_ty) is Types:
|
||||||
self.type = _ty
|
self.type = _ty
|
||||||
self.cobj = cobj
|
self.cobj = cobj
|
||||||
self.table = table
|
self.table = table
|
||||||
self.name = name
|
self.name = name
|
||||||
self.alias = set()
|
self.alias = set()
|
||||||
self.id = id # position in table
|
self.id = id # position in table
|
||||||
self.compound = compound # compound field (list as a field)
|
self.compound = compound # compound field (list as a field)
|
||||||
# e.g. order by, group by, filter by expressions
|
# e.g. order by, group by, filter by expressions
|
||||||
|
|
||||||
self.__arr__ = (_ty, cobj, table, name, id)
|
self.__arr__ = (_ty, cobj, table, name, id)
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if type(key) is str:
|
if type(key) is str:
|
||||||
return getattr(self, key)
|
return getattr(self, key)
|
||||||
else:
|
else:
|
||||||
return self.__arr__[key]
|
return self.__arr__[key]
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self.__arr__[key] = value
|
self.__arr__[key] = value
|
||||||
|
|
||||||
class TableInfo:
|
class TableInfo:
|
||||||
def __init__(self, table_name, cols, cxt:'Context'):
|
def __init__(self, table_name, cols, cxt:'Context'):
|
||||||
# statics
|
# statics
|
||||||
self.table_name : str = table_name
|
self.table_name : str = table_name
|
||||||
self.contextname_cpp : str = ''
|
self.contextname_cpp : str = ''
|
||||||
self.alias : Set[str] = set([table_name])
|
self.alias : Set[str] = set([table_name])
|
||||||
self.columns_byname : Dict[str, ColRef] = dict() # column_name, type
|
self.columns_byname : Dict[str, ColRef] = dict() # column_name, type
|
||||||
self.columns : List[ColRef] = []
|
self.columns : List[ColRef] = []
|
||||||
self.cxt = cxt
|
self.cxt = cxt
|
||||||
# keep track of temp vars
|
# keep track of temp vars
|
||||||
self.rec = None
|
self.rec = None
|
||||||
self.add_cols(cols)
|
self.add_cols(cols)
|
||||||
# runtime
|
# runtime
|
||||||
self.order = [] # assumptions
|
self.order = [] # assumptions
|
||||||
|
|
||||||
cxt.tables_byname[self.table_name] = self # construct reverse map
|
cxt.tables_byname[self.table_name] = self # construct reverse map
|
||||||
|
|
||||||
def add_cols(self, cols, new = True):
|
def add_cols(self, cols, new = True):
|
||||||
for i, c in enumerate(cols):
|
for i, c in enumerate(cols):
|
||||||
self.add_col(c, new, i)
|
self.add_col(c, new, i)
|
||||||
|
|
||||||
def add_col(self, c, new = True, i = 0):
|
def add_col(self, c, new = True, i = 0):
|
||||||
_ty = c['type']
|
_ty = c['type']
|
||||||
_ty_args = None
|
_ty_args = None
|
||||||
if type(_ty) is dict:
|
if type(_ty) is dict:
|
||||||
_ty_val = list(_ty.keys())[0]
|
_ty_val = list(_ty.keys())[0]
|
||||||
_ty_args = _ty[_ty_val]
|
_ty_args = _ty[_ty_val]
|
||||||
_ty = _ty_val
|
_ty = _ty_val
|
||||||
if new:
|
if new:
|
||||||
col_object = ColRef(_ty, c, self, c['name'], len(self.columns), _ty_args = _ty_args)
|
col_object = ColRef(_ty, c, self, c['name'], len(self.columns), _ty_args = _ty_args)
|
||||||
else:
|
else:
|
||||||
col_object = c
|
col_object = c
|
||||||
c.table = self
|
c.table = self
|
||||||
self.columns_byname[c['name']] = col_object
|
self.columns_byname[c['name']] = col_object
|
||||||
self.columns.append(col_object)
|
self.columns.append(col_object)
|
||||||
|
|
||||||
def add_alias(self, alias):
|
def add_alias(self, alias):
|
||||||
if alias in self.cxt.tables_byname.keys():
|
if alias in self.cxt.tables_byname.keys():
|
||||||
print("Error: table alias already exists")
|
print("Error: table alias already exists")
|
||||||
return
|
return
|
||||||
self.cxt.tables_byname[alias] = self
|
self.cxt.tables_byname[alias] = self
|
||||||
self.alias.add(alias)
|
self.alias.add(alias)
|
||||||
|
|
||||||
def parse_col_names(self, colExpr) -> ColRef:
|
def parse_col_names(self, colExpr) -> ColRef:
|
||||||
parsedColExpr = colExpr.split('.')
|
parsedColExpr = colExpr.split('.')
|
||||||
if len(parsedColExpr) <= 1:
|
if len(parsedColExpr) <= 1:
|
||||||
col = self.columns_byname[colExpr]
|
col = self.columns_byname[colExpr]
|
||||||
if type(self.rec) is set:
|
if type(self.rec) is set:
|
||||||
self.rec.add(col)
|
self.rec.add(col)
|
||||||
return col
|
return col
|
||||||
else:
|
else:
|
||||||
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
datasource = self.cxt.tables_byname[parsedColExpr[0]]
|
||||||
if datasource is None:
|
if datasource is None:
|
||||||
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
raise ValueError(f'Table name/alias not defined{parsedColExpr[0]}')
|
||||||
else:
|
else:
|
||||||
return datasource.parse_col_names(parsedColExpr[1])
|
return datasource.parse_col_names(parsedColExpr[1])
|
||||||
|
|
||||||
|
|
||||||
class Context:
|
class Context:
|
||||||
def new(self):
|
def new(self):
|
||||||
self.headers = set(['\"./server/libaquery.h\"',
|
self.headers = set(['\"./server/libaquery.h\"',
|
||||||
'\"./server/monetdb_conn.h\"'])
|
'\"./server/monetdb_conn.h\"'])
|
||||||
|
|
||||||
self.ccode = ''
|
self.ccode = ''
|
||||||
self.sql = ''
|
self.sql = ''
|
||||||
self.finalized = False
|
self.finalized = False
|
||||||
self.udf = None
|
self.udf = None
|
||||||
self.scans = []
|
self.scans = []
|
||||||
self.procs = []
|
self.procs = []
|
||||||
self.queries = []
|
self.queries = []
|
||||||
self.module_init_loc = 0
|
self.module_init_loc = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tables_byname = dict()
|
self.tables_byname = dict()
|
||||||
self.col_byname = dict()
|
self.col_byname = dict()
|
||||||
self.tables = []
|
self.tables = []
|
||||||
self.cols = []
|
self.cols = []
|
||||||
self.datasource = None
|
self.datasource = None
|
||||||
self.module_stubs = ''
|
self.module_stubs = ''
|
||||||
self.module_map = {}
|
self.module_map = {}
|
||||||
self.udf_map = dict()
|
self.udf_map = dict()
|
||||||
self.udf_agg_map = dict()
|
self.udf_agg_map = dict()
|
||||||
self.use_columnstore = False
|
self.use_columnstore = False
|
||||||
self.print = print
|
self.print = print
|
||||||
self.has_dll = False
|
self.has_dll = False
|
||||||
self.dialect = 'MonetDB'
|
self.dialect = 'MonetDB'
|
||||||
self.is_msvc = False
|
self.is_msvc = False
|
||||||
self.have_hge = False
|
self.have_hge = False
|
||||||
self.Error = lambda *args: print(*args)
|
self.Error = lambda *args: print(*args)
|
||||||
self.Info = lambda *_: None
|
self.Info = lambda *_: None
|
||||||
|
|
||||||
def emit(self, sql:str):
|
def emit(self, sql:str):
|
||||||
self.sql += sql + ' '
|
self.sql += sql + ' '
|
||||||
def emitc(self, c:str):
|
def emitc(self, c:str):
|
||||||
self.ccode += c + '\n'
|
self.ccode += c + '\n'
|
||||||
def add_table(self, table_name, cols):
|
def add_table(self, table_name, cols):
|
||||||
tbl = TableInfo(table_name, cols, self)
|
tbl = TableInfo(table_name, cols, self)
|
||||||
self.tables.append(tbl)
|
self.tables.append(tbl)
|
||||||
return tbl
|
return tbl
|
||||||
def remove_scan(self, scan, str_scan):
|
def remove_scan(self, scan, str_scan):
|
||||||
self.emitc(str_scan)
|
self.emitc(str_scan)
|
||||||
self.scans.remove(scan)
|
self.scans.remove(scan)
|
||||||
|
|
||||||
function_deco = '__AQEXPORT__(int) '
|
function_deco = '__AQEXPORT__(int) '
|
||||||
function_head = ('(Context* cxt) {\n' +
|
function_head = ('(Context* cxt) {\n' +
|
||||||
'\tusing namespace std;\n' +
|
'\tusing namespace std;\n' +
|
||||||
'\tusing namespace types;\n' +
|
'\tusing namespace types;\n' +
|
||||||
'\tauto server = static_cast<Server*>(cxt->alt_server);\n')
|
'\tauto server = static_cast<Server*>(cxt->alt_server);\n')
|
||||||
|
|
||||||
udf_head = ('#pragma once\n'
|
udf_head = ('#pragma once\n'
|
||||||
'#include \"./server/libaquery.h\"\n'
|
'#include \"./server/libaquery.h\"\n'
|
||||||
'#include \"./server/aggregations.h\"\n\n'
|
'#include \"./server/aggregations.h\"\n\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_init_func(self):
|
def get_init_func(self):
|
||||||
if not self.module_map:
|
if not self.module_map:
|
||||||
return ''
|
return ''
|
||||||
ret = '__AQEXPORT__(void) __builtin_init_user_module(Context* cxt){\n'
|
ret = '__AQEXPORT__(void) __builtin_init_user_module(Context* cxt){\n'
|
||||||
for fname in self.module_map.keys():
|
for fname in self.module_map.keys():
|
||||||
ret += f'{fname} = (decltype({fname}))(cxt->get_module_function("{fname}"));\n'
|
ret += f'{fname} = (decltype({fname}))(cxt->get_module_function("{fname}"));\n'
|
||||||
self.queries.insert(self.module_init_loc, 'P__builtin_init_user_module')
|
self.queries.insert(self.module_init_loc, 'P__builtin_init_user_module')
|
||||||
return ret + '}\n'
|
return ret + '}\n'
|
||||||
|
|
||||||
def sql_begin(self):
|
def sql_begin(self):
|
||||||
self.sql = ''
|
self.sql = ''
|
||||||
|
|
||||||
def sql_end(self):
|
def sql_end(self):
|
||||||
# eliminate empty queries
|
# eliminate empty queries
|
||||||
s = self.sql.strip()
|
s = self.sql.strip()
|
||||||
while(s and s[-1] == ';'):
|
while(s and s[-1] == ';'):
|
||||||
s = s[:-1].strip()
|
s = s[:-1].strip()
|
||||||
if s and s.lower() != 'select':
|
if s and s.lower() != 'select':
|
||||||
self.queries.append('Q' + self.sql)
|
self.queries.append('Q' + self.sql)
|
||||||
self.sql = ''
|
self.sql = ''
|
||||||
|
|
||||||
def postproc_begin(self, proc_name: str):
|
def postproc_begin(self, proc_name: str):
|
||||||
self.ccode = self.function_deco + proc_name + self.function_head
|
self.ccode = self.function_deco + proc_name + self.function_head
|
||||||
|
|
||||||
def postproc_end(self, proc_name: str):
|
def postproc_end(self, proc_name: str):
|
||||||
self.procs.append(self.ccode + 'return 0;\n}')
|
self.procs.append(self.ccode + 'return 0;\n}')
|
||||||
self.ccode = ''
|
self.ccode = ''
|
||||||
self.queries.append('P' + proc_name)
|
self.queries.append('P' + proc_name)
|
||||||
|
|
||||||
def finalize_udf(self):
|
def finalize_udf(self):
|
||||||
if self.udf is not None:
|
if self.udf is not None:
|
||||||
return (Context.udf_head
|
return (Context.udf_head
|
||||||
+ self.module_stubs
|
+ self.module_stubs
|
||||||
+ self.get_init_func()
|
+ self.get_init_func()
|
||||||
+ self.udf
|
+ self.udf
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
from aquery_config import build_driver, os_platform
|
from aquery_config import build_driver, os_platform
|
||||||
if not self.finalized:
|
if not self.finalized:
|
||||||
headers = ''
|
headers = ''
|
||||||
if build_driver == 'MSBuild':
|
if build_driver == 'MSBuild':
|
||||||
headers ='#include \"./server/pch.hpp\"\n'
|
headers ='#include \"./server/pch.hpp\"\n'
|
||||||
|
|
||||||
for h in self.headers:
|
for h in self.headers:
|
||||||
if h[0] != '"':
|
if h[0] != '"':
|
||||||
headers += '#include <' + h + '>\n'
|
headers += '#include <' + h + '>\n'
|
||||||
else:
|
else:
|
||||||
headers += '#include ' + h + '\n'
|
headers += '#include ' + h + '\n'
|
||||||
if os_platform == 'win':
|
if os_platform == 'win':
|
||||||
headers += '#undef max\n'
|
headers += '#undef max\n'
|
||||||
headers += '#undef min\n'
|
headers += '#undef min\n'
|
||||||
|
|
||||||
self.ccode = headers + '\n'.join(self.procs)
|
self.ccode = headers + '\n'.join(self.procs)
|
||||||
self.headers = set()
|
self.headers = set()
|
||||||
return self.ccode
|
return self.ccode
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
mo-future==6.2.21303
|
mo-future==6.2.21303
|
||||||
mo-dots==9.173.22126
|
mo-dots==9.173.22126
|
||||||
mo-parsing==8.183.22158
|
mo-parsing==8.183.22158
|
||||||
mo-imports==7.169.22121
|
mo-imports==7.169.22121
|
||||||
dataclasses; python_version < '3.7'
|
dataclasses; python_version < '3.7'
|
||||||
readline; sys_platform == 'linux'
|
readline; sys_platform == 'linux'
|
||||||
vswhere; sys_platform == 'win32'
|
vswhere; sys_platform == 'win32'
|
||||||
numpy
|
numpy
|
||||||
|
|
||||||
|
@ -1,222 +1,222 @@
|
|||||||
{
|
{
|
||||||
"stmts": {
|
"stmts": {
|
||||||
"udf": {
|
"udf": {
|
||||||
"fname": "covariances2",
|
"fname": "covariances2",
|
||||||
"params": ["x", "y", "w"],
|
"params": ["x", "y", "w"],
|
||||||
"stmt": [{
|
"stmt": [{
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "xmeans",
|
"var": "xmeans",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 0.0
|
"expr": 0.0
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "ymeans",
|
"var": "ymeans",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 0.0
|
"expr": 0.0
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "l",
|
"var": "l",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": "_builtin_len"
|
"expr": "_builtin_len"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"if": {
|
"if": {
|
||||||
"cond": {
|
"cond": {
|
||||||
"gt": ["w", "l"]
|
"gt": ["w", "l"]
|
||||||
},
|
},
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "w",
|
"var": "w",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": "l"
|
"expr": "l"
|
||||||
},
|
},
|
||||||
"elif": [{
|
"elif": [{
|
||||||
"cond": {
|
"cond": {
|
||||||
"gt": ["w", {
|
"gt": ["w", {
|
||||||
"add": ["l", 2]
|
"add": ["l", 2]
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"stmt": [{
|
"stmt": [{
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "l",
|
"var": "l",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 3
|
"expr": 3
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "w",
|
"var": "w",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 4
|
"expr": 4
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
"cond": {
|
"cond": {
|
||||||
"lt": ["w", 99]
|
"lt": ["w", 99]
|
||||||
},
|
},
|
||||||
"stmt": {
|
"stmt": {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "l",
|
"var": "l",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 8
|
"expr": 8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"cond": {
|
"cond": {
|
||||||
"lt": ["w", 999]
|
"lt": ["w", 999]
|
||||||
},
|
},
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "w",
|
"var": "w",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 6
|
"expr": 6
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"else": {
|
"else": {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "l",
|
"var": "l",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"div": ["l", 2]
|
"div": ["l", 2]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"for": {
|
"for": {
|
||||||
"defs": {
|
"defs": {
|
||||||
"var": ["i", "j"],
|
"var": ["i", "j"],
|
||||||
"op": [":=", ":="],
|
"op": [":=", ":="],
|
||||||
"expr": [0, 0]
|
"expr": [0, 0]
|
||||||
},
|
},
|
||||||
"cond": {
|
"cond": {
|
||||||
"lt": ["i", "w"]
|
"lt": ["i", "w"]
|
||||||
},
|
},
|
||||||
"tail": {
|
"tail": {
|
||||||
"var": "i",
|
"var": "i",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"add": ["i", 1]
|
"add": ["i", 1]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stmt": [{
|
"stmt": [{
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "xmeans",
|
"var": "xmeans",
|
||||||
"op": "+=",
|
"op": "+=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"get": ["x", "i"]
|
"get": ["x", "i"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "ymeans",
|
"var": "ymeans",
|
||||||
"op": "+=",
|
"op": "+=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"get": ["y", "i"]
|
"get": ["y", "i"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": {
|
"var": {
|
||||||
"get": ["_builtin_ret", "i"]
|
"get": ["_builtin_ret", "i"]
|
||||||
},
|
},
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"avg": {
|
"avg": {
|
||||||
"mul": [{
|
"mul": [{
|
||||||
"sub": [{
|
"sub": [{
|
||||||
"x": [{
|
"x": [{
|
||||||
"sub": ["l", "w"]
|
"sub": ["l", "w"]
|
||||||
}, "l"]
|
}, "l"]
|
||||||
}, "xmeans"]
|
}, "xmeans"]
|
||||||
}, {
|
}, {
|
||||||
"sub": [{
|
"sub": [{
|
||||||
"y": [{
|
"y": [{
|
||||||
"sub": ["l", "w"]
|
"sub": ["l", "w"]
|
||||||
}, "l"]
|
}, "l"]
|
||||||
}, "ymeans"]
|
}, "ymeans"]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"for": {
|
"for": {
|
||||||
"defs": {
|
"defs": {
|
||||||
"var": "i",
|
"var": "i",
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": 0
|
"expr": 0
|
||||||
},
|
},
|
||||||
"cond": {
|
"cond": {
|
||||||
"lt": ["i", "l"]
|
"lt": ["i", "l"]
|
||||||
},
|
},
|
||||||
"tail": {
|
"tail": {
|
||||||
"var": "i",
|
"var": "i",
|
||||||
"op": "+=",
|
"op": "+=",
|
||||||
"expr": 1
|
"expr": 1
|
||||||
},
|
},
|
||||||
"stmt": [{
|
"stmt": [{
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "xmeans",
|
"var": "xmeans",
|
||||||
"op": "+=",
|
"op": "+=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"div": [{
|
"div": [{
|
||||||
"sub": [{
|
"sub": [{
|
||||||
"get": ["x", "i"]
|
"get": ["x", "i"]
|
||||||
}, {
|
}, {
|
||||||
"get": ["x", {
|
"get": ["x", {
|
||||||
"sub": ["i", "w"]
|
"sub": ["i", "w"]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}, "w"]
|
}, "w"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": "ymeans",
|
"var": "ymeans",
|
||||||
"op": "+=",
|
"op": "+=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"div": [{
|
"div": [{
|
||||||
"sub": [{
|
"sub": [{
|
||||||
"get": ["y", "i"]
|
"get": ["y", "i"]
|
||||||
}, {
|
}, {
|
||||||
"get": ["y", {
|
"get": ["y", {
|
||||||
"sub": ["i", "w"]
|
"sub": ["i", "w"]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}, "w"]
|
}, "w"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"assignment": {
|
"assignment": {
|
||||||
"var": {
|
"var": {
|
||||||
"get": ["_builtin_ret", "i"]
|
"get": ["_builtin_ret", "i"]
|
||||||
},
|
},
|
||||||
"op": ":=",
|
"op": ":=",
|
||||||
"expr": {
|
"expr": {
|
||||||
"avg": {
|
"avg": {
|
||||||
"mul": [{
|
"mul": [{
|
||||||
"sub": [{
|
"sub": [{
|
||||||
"x": [{
|
"x": [{
|
||||||
"sub": ["l", "w"]
|
"sub": ["l", "w"]
|
||||||
}, "l"]
|
}, "l"]
|
||||||
}, "xmeans"]
|
}, "xmeans"]
|
||||||
}, {
|
}, {
|
||||||
"sub": [{
|
"sub": [{
|
||||||
"y": [{
|
"y": [{
|
||||||
"sub": ["l", "w"]
|
"sub": ["l", "w"]
|
||||||
}, "l"]
|
}, "l"]
|
||||||
}, "ymeans"]
|
}, "ymeans"]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"ret": {
|
"ret": {
|
||||||
"null": {}
|
"null": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,89 +1,89 @@
|
|||||||
#ifndef _AQUERY_H
|
#ifndef _AQUERY_H
|
||||||
#define _AQUERY_H
|
#define _AQUERY_H
|
||||||
|
|
||||||
enum Log_level {
|
enum Log_level {
|
||||||
LOG_INFO,
|
LOG_INFO,
|
||||||
LOG_ERROR,
|
LOG_ERROR,
|
||||||
LOG_SILENT
|
LOG_SILENT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Backend_Type {
|
enum Backend_Type {
|
||||||
BACKEND_AQuery,
|
BACKEND_AQuery,
|
||||||
BACKEND_MonetDB,
|
BACKEND_MonetDB,
|
||||||
BACKEND_MariaDB
|
BACKEND_MariaDB
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Config{
|
struct Config{
|
||||||
int running, new_query, server_mode,
|
int running, new_query, server_mode,
|
||||||
backend_type, has_dll, n_buffers;
|
backend_type, has_dll, n_buffers;
|
||||||
int buffer_sizes[];
|
int buffer_sizes[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Session{
|
struct Session{
|
||||||
struct Statistic{
|
struct Statistic{
|
||||||
unsigned long long total_active;
|
unsigned long long total_active;
|
||||||
unsigned long long cnt_object;
|
unsigned long long cnt_object;
|
||||||
unsigned long long total_alloc;
|
unsigned long long total_alloc;
|
||||||
};
|
};
|
||||||
void* memory_map;
|
void* memory_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Context{
|
struct Context{
|
||||||
typedef int (*printf_type) (const char *format, ...);
|
typedef int (*printf_type) (const char *format, ...);
|
||||||
void* module_function_maps = 0;
|
void* module_function_maps = 0;
|
||||||
Config* cfg;
|
Config* cfg;
|
||||||
|
|
||||||
int n_buffers, *sz_bufs;
|
int n_buffers, *sz_bufs;
|
||||||
void **buffers;
|
void **buffers;
|
||||||
|
|
||||||
void* alt_server;
|
void* alt_server;
|
||||||
Log_level log_level = LOG_INFO;
|
Log_level log_level = LOG_INFO;
|
||||||
|
|
||||||
Session current;
|
Session current;
|
||||||
|
|
||||||
|
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
void log(Types... args) {
|
void log(Types... args) {
|
||||||
if (log_level == LOG_INFO)
|
if (log_level == LOG_INFO)
|
||||||
print(args...);
|
print(args...);
|
||||||
}
|
}
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
void err(Types... args) {
|
void err(Types... args) {
|
||||||
if (log_level <= LOG_ERROR)
|
if (log_level <= LOG_ERROR)
|
||||||
print(args...);
|
print(args...);
|
||||||
}
|
}
|
||||||
void init_session();
|
void init_session();
|
||||||
void end_session();
|
void end_session();
|
||||||
void* get_module_function(const char*);
|
void* get_module_function(const char*);
|
||||||
char remainder[];
|
char remainder[];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
||||||
#else
|
#else
|
||||||
#define __DLLEXPORT__
|
#define __DLLEXPORT__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
||||||
|
|
||||||
typedef void (*deallocator_t) (void*);
|
typedef void (*deallocator_t) (void*);
|
||||||
|
|
||||||
extern void* Aalloc(unsigned long long sz);
|
extern void* Aalloc(unsigned long long sz);
|
||||||
extern void Afree(void * mem);
|
extern void Afree(void * mem);
|
||||||
extern void register_memory(void* ptr, deallocator_t deallocator);
|
extern void register_memory(void* ptr, deallocator_t deallocator);
|
||||||
|
|
||||||
__AQEXPORT__(void) init_session(Context* cxt);
|
__AQEXPORT__(void) init_session(Context* cxt);
|
||||||
|
|
||||||
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
|
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
|
||||||
void* memcpy(void*, void*, unsigned long long);
|
void* memcpy(void*, void*, unsigned long long);
|
||||||
struct ColRef_storage {
|
struct ColRef_storage {
|
||||||
void* container;
|
void* container;
|
||||||
unsigned int capacity, size;
|
unsigned int capacity, size;
|
||||||
const char* name;
|
const char* name;
|
||||||
int ty; // what if enum is not int?
|
int ty; // what if enum is not int?
|
||||||
template <class Ty, template <typename> class VT>
|
template <class Ty, template <typename> class VT>
|
||||||
ColRef_storage(const VT<Ty>& vt) {
|
ColRef_storage(const VT<Ty>& vt) {
|
||||||
memcpy(this, &vt, sizeof(ColRef_storage));
|
memcpy(this, &vt, sizeof(ColRef_storage));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
@ -1,31 +1,31 @@
|
|||||||
#include "aquery.h"
|
#include "aquery.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
Session* session;
|
Session* session;
|
||||||
|
|
||||||
|
|
||||||
void* Aalloc(size_t sz, deallocator_t deallocator){
|
void* Aalloc(size_t sz, deallocator_t deallocator){
|
||||||
void* mem = malloc(sz);
|
void* mem = malloc(sz);
|
||||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||||
memmap->operator[](mem) = deallocator;
|
memmap->operator[](mem) = deallocator;
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Afree(void* mem){
|
void Afree(void* mem){
|
||||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||||
memmap->operator[](mem)(mem);
|
memmap->operator[](mem)(mem);
|
||||||
memmap->erase(mem);
|
memmap->erase(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_memory(void* ptr, deallocator_t deallocator){
|
void register_memory(void* ptr, deallocator_t deallocator){
|
||||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
auto memmap = (std::unordered_map<void*, deallocator_t>*) session->memory_map;
|
||||||
memmap->operator[](ptr) = deallocator;
|
memmap->operator[](ptr) = deallocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
__AQEXPORT__(void) init_session(Context* cxt){
|
__AQEXPORT__(void) init_session(Context* cxt){
|
||||||
session = &cxt->current;
|
session = &cxt->current;
|
||||||
}
|
}
|
||||||
|
@ -1,171 +1,171 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#undef max
|
#undef max
|
||||||
#undef min
|
#undef min
|
||||||
template <class T, template<typename ...> class VT>
|
template <class T, template<typename ...> class VT>
|
||||||
size_t count(const VT<T>& v) {
|
size_t count(const VT<T>& v) {
|
||||||
return v.size;
|
return v.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr static inline size_t count(const T&) { return 1; }
|
constexpr static inline size_t count(const T&) { return 1; }
|
||||||
|
|
||||||
// TODO: Specializations for dt/str/none
|
// TODO: Specializations for dt/str/none
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
types::GetLongType<T> sum(const VT<T>& v) {
|
types::GetLongType<T> sum(const VT<T>& v) {
|
||||||
types::GetLongType<T> ret = 0;
|
types::GetLongType<T> ret = 0;
|
||||||
for (const auto& _v : v)
|
for (const auto& _v : v)
|
||||||
ret += _v;
|
ret += _v;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
types::GetFPType<T> avg(const VT<T>& v) {
|
types::GetFPType<T> avg(const VT<T>& v) {
|
||||||
return static_cast<types::GetFPType<T>>(
|
return static_cast<types::GetFPType<T>>(
|
||||||
sum<T>(v) / static_cast<long double>(v.size));
|
sum<T>(v) / static_cast<long double>(v.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
VT<double> sqrt(const VT<T>& v) {
|
VT<double> sqrt(const VT<T>& v) {
|
||||||
VT<double> ret {v.size};
|
VT<double> ret {v.size};
|
||||||
for (uint32_t i = 0; i < v.size; ++i){
|
for (uint32_t i = 0; i < v.size; ++i){
|
||||||
ret[i] = sqrt(v[i]);
|
ret[i] = sqrt(v[i]);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, template<typename ...> class VT>
|
template <class T, template<typename ...> class VT>
|
||||||
T max(const VT<T>& v) {
|
T max(const VT<T>& v) {
|
||||||
T max_v = std::numeric_limits<T>::min();
|
T max_v = std::numeric_limits<T>::min();
|
||||||
for (const auto& _v : v)
|
for (const auto& _v : v)
|
||||||
max_v = max_v > _v ? max_v : _v;
|
max_v = max_v > _v ? max_v : _v;
|
||||||
return max_v;
|
return max_v;
|
||||||
}
|
}
|
||||||
template <class T, template<typename ...> class VT>
|
template <class T, template<typename ...> class VT>
|
||||||
T min(const VT<T>& v) {
|
T min(const VT<T>& v) {
|
||||||
T min_v = std::numeric_limits<T>::max();
|
T min_v = std::numeric_limits<T>::max();
|
||||||
for (const auto& _v : v)
|
for (const auto& _v : v)
|
||||||
min_v = min_v < _v ? min_v : _v;
|
min_v = min_v < _v ? min_v : _v;
|
||||||
return min_v;
|
return min_v;
|
||||||
}
|
}
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT,T> mins(const VT<T>& arr) {
|
decayed_t<VT,T> mins(const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
std::deque<std::pair<T, uint32_t>> cache;
|
std::deque<std::pair<T, uint32_t>> cache;
|
||||||
decayed_t<VT,T> ret(len);
|
decayed_t<VT,T> ret(len);
|
||||||
T min = std::numeric_limits<T>::max();
|
T min = std::numeric_limits<T>::max();
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
if (arr[i] < min)
|
if (arr[i] < min)
|
||||||
min = arr[i];
|
min = arr[i];
|
||||||
ret[i] = min;
|
ret[i] = min;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT,T> maxs(const VT<T>& arr) {
|
decayed_t<VT,T> maxs(const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
decayed_t<VT,T> ret(len);
|
decayed_t<VT,T> ret(len);
|
||||||
T max = std::numeric_limits<T>::min();
|
T max = std::numeric_limits<T>::min();
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
if (arr[i] > max)
|
if (arr[i] > max)
|
||||||
max = arr[i];
|
max = arr[i];
|
||||||
ret[i] = max;
|
ret[i] = max;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT,T> minw(uint32_t w, const VT<T>& arr) {
|
decayed_t<VT,T> minw(uint32_t w, const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
decayed_t<VT,T> ret{len};
|
decayed_t<VT,T> ret{len};
|
||||||
std::deque<std::pair<T, uint32_t>> cache;
|
std::deque<std::pair<T, uint32_t>> cache;
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||||
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
||||||
cache.push_back({ arr[i], i });
|
cache.push_back({ arr[i], i });
|
||||||
ret[i] = cache.front().first;
|
ret[i] = cache.front().first;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT,T> maxw(uint32_t w, const VT<T>& arr) {
|
decayed_t<VT,T> maxw(uint32_t w, const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
decayed_t<VT, T> ret(len);
|
decayed_t<VT, T> ret(len);
|
||||||
std::deque<std::pair<T, uint32_t>> cache;
|
std::deque<std::pair<T, uint32_t>> cache;
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||||
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
while (!cache.empty() && cache.back().first > arr[i]) cache.pop_back();
|
||||||
cache.push_back({ arr[i], i });
|
cache.push_back({ arr[i], i });
|
||||||
arr[i] = cache.front().first;
|
arr[i] = cache.front().first;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT, types::GetLongType<T>> sums(const VT<T>& arr) {
|
decayed_t<VT, types::GetLongType<T>> sums(const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
if(len) ret[i++] = arr[0];
|
if(len) ret[i++] = arr[0];
|
||||||
for (; i < len; ++i)
|
for (; i < len; ++i)
|
||||||
ret[i] = ret[i-1] + arr[i];
|
ret[i] = ret[i-1] + arr[i];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT, types::GetFPType<T>> avgs(const VT<T>& arr) {
|
decayed_t<VT, types::GetFPType<T>> avgs(const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
typedef types::GetFPType<T> FPType;
|
typedef types::GetFPType<T> FPType;
|
||||||
decayed_t<VT, FPType> ret(len);
|
decayed_t<VT, FPType> ret(len);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
types::GetLongType<T> s;
|
types::GetLongType<T> s;
|
||||||
if(len) s = ret[i++] = arr[0];
|
if(len) s = ret[i++] = arr[0];
|
||||||
for (; i < len; ++i)
|
for (; i < len; ++i)
|
||||||
ret[i] = (s+=arr[i])/(FPType)(i+1);
|
ret[i] = (s+=arr[i])/(FPType)(i+1);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT, types::GetLongType<T>> sumw(uint32_t w, const VT<T>& arr) {
|
decayed_t<VT, types::GetLongType<T>> sumw(uint32_t w, const VT<T>& arr) {
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
w = w > len ? len : w;
|
w = w > len ? len : w;
|
||||||
if(len) ret[i++] = arr[0];
|
if(len) ret[i++] = arr[0];
|
||||||
for (; i < w; ++i)
|
for (; i < w; ++i)
|
||||||
ret[i] = ret[i-1] + arr[i];
|
ret[i] = ret[i-1] + arr[i];
|
||||||
for (; i < len; ++i)
|
for (; i < len; ++i)
|
||||||
ret[i] = ret[i-1] + arr[i] - arr[i-w];
|
ret[i] = ret[i-1] + arr[i] - arr[i-w];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
template<class T, template<typename ...> class VT>
|
template<class T, template<typename ...> class VT>
|
||||||
decayed_t<VT, types::GetFPType<types::GetLongType<T>>> avgw(uint32_t w, const VT<T>& arr) {
|
decayed_t<VT, types::GetFPType<types::GetLongType<T>>> avgw(uint32_t w, const VT<T>& arr) {
|
||||||
typedef types::GetFPType<types::GetLongType<T>> FPType;
|
typedef types::GetFPType<types::GetLongType<T>> FPType;
|
||||||
const uint32_t& len = arr.size;
|
const uint32_t& len = arr.size;
|
||||||
decayed_t<VT, FPType> ret(len);
|
decayed_t<VT, FPType> ret(len);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
types::GetLongType<T> s{};
|
types::GetLongType<T> s{};
|
||||||
w = w > len ? len : w;
|
w = w > len ? len : w;
|
||||||
if(len) s = ret[i++] = arr[0];
|
if(len) s = ret[i++] = arr[0];
|
||||||
for (; i < w; ++i)
|
for (; i < w; ++i)
|
||||||
ret[i] = (s += arr[i])/(FPType)(i+1);
|
ret[i] = (s += arr[i])/(FPType)(i+1);
|
||||||
for (; i < len; ++i)
|
for (; i < len; ++i)
|
||||||
ret[i] = ret[i-1] + (arr[i] - arr[i-w])/(FPType)w;
|
ret[i] = ret[i-1] + (arr[i] - arr[i-w])/(FPType)w;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> constexpr inline T count(const T& v) { return 1; }
|
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 max(const T& v) { return v; }
|
||||||
template <class T> constexpr inline T min(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 avg(const T& v) { return v; }
|
||||||
template <class T> constexpr inline T sum(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 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 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 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 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 maxs(const T& v) { return v; }
|
||||||
template <class T> constexpr inline T mins(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 avgs(const T& v) { return v; }
|
||||||
template <class T> constexpr inline T sums(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
|
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||||
// such as names of functions and macros.
|
// such as names of functions and macros.
|
||||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
// 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 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 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)
|
#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
|
#pragma once
|
||||||
#include <vector_type>
|
#include <vector_type>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
class GC {
|
class GC {
|
||||||
template<class T>
|
template<class T>
|
||||||
using vector = vector_type<T>;
|
using vector = vector_type<T>;
|
||||||
template<class ...T>
|
template<class ...T>
|
||||||
using tuple = std::tuple<T...>;
|
using tuple = std::tuple<T...>;
|
||||||
size_t current_size, max_size, interval, forced_clean;
|
size_t current_size, max_size, interval, forced_clean;
|
||||||
bool running, alive;
|
bool running, alive;
|
||||||
// ptr, dealloc, ref, sz
|
// ptr, dealloc, ref, sz
|
||||||
vector<tuple<void*, void (*)(void*)>> q;
|
vector<tuple<void*, void (*)(void*)>> q;
|
||||||
std::thread handle;
|
std::thread handle;
|
||||||
void gc()
|
void gc()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void reg(void* v, uint32_t ref, uint32_t sz,
|
void reg(void* v, uint32_t ref, uint32_t sz,
|
||||||
void(*f)(void*) = [](void* v) {free (v); }) {
|
void(*f)(void*) = [](void* v) {free (v); }) {
|
||||||
current_size += sz;
|
current_size += sz;
|
||||||
if (current_size > max_size)
|
if (current_size > max_size)
|
||||||
gc();
|
gc();
|
||||||
q.push_back({ v, f });
|
q.push_back({ v, f });
|
||||||
}
|
}
|
||||||
void daemon() {
|
void daemon() {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
while (alive) {
|
while (alive) {
|
||||||
if (running) {
|
if (running) {
|
||||||
gc();
|
gc();
|
||||||
std::this_thread::sleep_for(microseconds(interval));
|
std::this_thread::sleep_for(microseconds(interval));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::this_thread::sleep_for(10ms);
|
std::this_thread::sleep_for(10ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void start_deamon() {
|
void start_deamon() {
|
||||||
handle = std::thread(&daemon);
|
handle = std::thread(&daemon);
|
||||||
alive = true;
|
alive = true;
|
||||||
}
|
}
|
||||||
void terminate_daemon() {
|
void terminate_daemon() {
|
||||||
running = false;
|
running = false;
|
||||||
alive = false;
|
alive = false;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
if (handle.joinable()) {
|
if (handle.joinable()) {
|
||||||
std::this_thread::sleep_for(microseconds(1000 + std::max(static_cast<size_t>(10000), interval)));
|
std::this_thread::sleep_for(microseconds(1000 + std::max(static_cast<size_t>(10000), interval)));
|
||||||
handle.join();
|
handle.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,20 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
struct hasher {
|
struct hasher {
|
||||||
template <size_t i = 0> typename std::enable_if< i == sizeof...(Types),
|
template <size_t i = 0> typename std::enable_if< i == sizeof...(Types),
|
||||||
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t i = 0> typename std::enable_if< i < sizeof ...(Types),
|
template <size_t i = 0> typename std::enable_if< i < sizeof ...(Types),
|
||||||
size_t>::type hashi(const std::tuple<Types...>& record) const {
|
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;
|
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);
|
return std::hash<current_type>()(std::get<i>(record)) ^ hashi<i+1>(record);
|
||||||
}
|
}
|
||||||
size_t operator()(const std::tuple<Types...>& record) const {
|
size_t operator()(const std::tuple<Types...>& record) const {
|
||||||
return hashi(record);
|
return hashi(record);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,81 +1,81 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
std::string generate_printf_string(const char* sep = " ", const char* end = "\n") {
|
std::string generate_printf_string(const char* sep = " ", const char* end = "\n") {
|
||||||
std::string str;
|
std::string str;
|
||||||
((str += types::printf_str[types::Types<value_type_r<Types>>::getType()], str += sep), ...);
|
((str += types::printf_str[types::Types<value_type_r<Types>>::getType()], str += sep), ...);
|
||||||
const auto trim = str.size() - strlen(sep);
|
const auto trim = str.size() - strlen(sep);
|
||||||
if (trim > 0)
|
if (trim > 0)
|
||||||
str.resize(trim);
|
str.resize(trim);
|
||||||
str += end;
|
str += end;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline decltype(auto) print_hook(const T& v){
|
inline decltype(auto) print_hook(const T& v){
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline decltype(auto) print_hook<bool>(const bool& v) {
|
inline decltype(auto) print_hook<bool>(const bool& v) {
|
||||||
return v? "true" : "false";
|
return v? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __SIZEOF_INT128__
|
#ifdef __SIZEOF_INT128__
|
||||||
constexpr struct __int128__struct{
|
constexpr struct __int128__struct{
|
||||||
uint64_t low, high;
|
uint64_t low, high;
|
||||||
// constexpr bool operator==(__int128_t x) const{
|
// constexpr bool operator==(__int128_t x) const{
|
||||||
// return (x>>64) == high and (x&0xffffffffffffffffull) == low;
|
// return (x>>64) == high and (x&0xffffffffffffffffull) == low;
|
||||||
// }
|
// }
|
||||||
bool operator==(__int128_t x) const{
|
bool operator==(__int128_t x) const{
|
||||||
return *((const __int128_t*) this) == x;
|
return *((const __int128_t*) this) == x;
|
||||||
}
|
}
|
||||||
}__int128_max_v = {0x0000000000000000ull, 0x8000000000000000ull};
|
}__int128_max_v = {0x0000000000000000ull, 0x8000000000000000ull};
|
||||||
|
|
||||||
inline const char* get_int128str(__int128_t v, char* buf){
|
inline const char* get_int128str(__int128_t v, char* buf){
|
||||||
bool neg = false;
|
bool neg = false;
|
||||||
if (v < 0) {
|
if (v < 0) {
|
||||||
if(__int128_max_v == v)
|
if(__int128_max_v == v)
|
||||||
return "-170141183460469231731687303715884105728";
|
return "-170141183460469231731687303715884105728";
|
||||||
v = -v;
|
v = -v;
|
||||||
neg = true;
|
neg = true;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
*--buf = v%10 + '0';
|
*--buf = v%10 + '0';
|
||||||
v /= 10;
|
v /= 10;
|
||||||
} while(v);
|
} while(v);
|
||||||
if (neg) *--buf = '-';
|
if (neg) *--buf = '-';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* get_uint128str(__uint128_t v, char* buf){
|
inline const char* get_uint128str(__uint128_t v, char* buf){
|
||||||
do {
|
do {
|
||||||
*--buf = v%10 + '0';
|
*--buf = v%10 + '0';
|
||||||
v /= 10;
|
v /= 10;
|
||||||
} while(v);
|
} while(v);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
extern char* gbuf;
|
extern char* gbuf;
|
||||||
|
|
||||||
void setgbuf(char* buf = 0);
|
void setgbuf(char* buf = 0);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline decltype(auto) print_hook<__int128_t>(const __int128_t& v) {
|
inline decltype(auto) print_hook<__int128_t>(const __int128_t& v) {
|
||||||
*(gbuf+=40) = 0;
|
*(gbuf+=40) = 0;
|
||||||
return get_int128str(v, gbuf++);
|
return get_int128str(v, gbuf++);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline decltype(auto) print_hook<__uint128_t>(const __uint128_t& v) {
|
inline decltype(auto) print_hook<__uint128_t>(const __uint128_t& v) {
|
||||||
*(gbuf+=40) = 0;
|
*(gbuf+=40) = 0;
|
||||||
return get_uint128str(v, gbuf++);
|
return get_uint128str(v, gbuf++);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define setgbuf()
|
#define setgbuf()
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,79 +1,79 @@
|
|||||||
#ifndef _AQUERY_H
|
#ifndef _AQUERY_H
|
||||||
#define _AQUERY_H
|
#define _AQUERY_H
|
||||||
|
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
enum Log_level {
|
enum Log_level {
|
||||||
LOG_INFO,
|
LOG_INFO,
|
||||||
LOG_ERROR,
|
LOG_ERROR,
|
||||||
LOG_SILENT
|
LOG_SILENT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Backend_Type {
|
enum Backend_Type {
|
||||||
BACKEND_AQuery,
|
BACKEND_AQuery,
|
||||||
BACKEND_MonetDB,
|
BACKEND_MonetDB,
|
||||||
BACKEND_MariaDB
|
BACKEND_MariaDB
|
||||||
};
|
};
|
||||||
struct Config{
|
struct Config{
|
||||||
int running, new_query, server_mode,
|
int running, new_query, server_mode,
|
||||||
backend_type, has_dll, n_buffers;
|
backend_type, has_dll, n_buffers;
|
||||||
int buffer_sizes[];
|
int buffer_sizes[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Session{
|
struct Session{
|
||||||
struct Statistic{
|
struct Statistic{
|
||||||
size_t total_active;
|
size_t total_active;
|
||||||
size_t cnt_object;
|
size_t cnt_object;
|
||||||
size_t total_alloc;
|
size_t total_alloc;
|
||||||
} stats;
|
} stats;
|
||||||
void* memory_map;
|
void* memory_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Context{
|
struct Context{
|
||||||
typedef int (*printf_type) (const char *format, ...);
|
typedef int (*printf_type) (const char *format, ...);
|
||||||
|
|
||||||
void* module_function_maps = 0;
|
void* module_function_maps = 0;
|
||||||
Config* cfg;
|
Config* cfg;
|
||||||
|
|
||||||
int n_buffers, *sz_bufs;
|
int n_buffers, *sz_bufs;
|
||||||
void **buffers;
|
void **buffers;
|
||||||
|
|
||||||
void* alt_server = 0;
|
void* alt_server = 0;
|
||||||
Log_level log_level = LOG_INFO;
|
Log_level log_level = LOG_INFO;
|
||||||
|
|
||||||
Session current;
|
Session current;
|
||||||
|
|
||||||
#ifdef THREADING
|
#ifdef THREADING
|
||||||
void* thread_pool;
|
void* thread_pool;
|
||||||
#endif
|
#endif
|
||||||
printf_type print = printf;
|
printf_type print = printf;
|
||||||
Context();
|
Context();
|
||||||
virtual ~Context();
|
virtual ~Context();
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
void log(Types... args) {
|
void log(Types... args) {
|
||||||
if (log_level == LOG_INFO)
|
if (log_level == LOG_INFO)
|
||||||
print(args...);
|
print(args...);
|
||||||
}
|
}
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
void err(Types... args) {
|
void err(Types... args) {
|
||||||
if (log_level <= LOG_ERROR)
|
if (log_level <= LOG_ERROR)
|
||||||
print(args...);
|
print(args...);
|
||||||
}
|
}
|
||||||
void init_session();
|
void init_session();
|
||||||
void end_session();
|
void end_session();
|
||||||
void* get_module_function(const char*);
|
void* get_module_function(const char*);
|
||||||
std::unordered_map<const char*, void*> tables;
|
std::unordered_map<const char*, void*> tables;
|
||||||
std::unordered_map<const char*, uColRef *> cols;
|
std::unordered_map<const char*, uColRef *> cols;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
#define __DLLEXPORT__ __declspec(dllexport) __stdcall
|
||||||
#else
|
#else
|
||||||
#define __DLLEXPORT__
|
#define __DLLEXPORT__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
#define __AQEXPORT__(_Ty) extern "C" _Ty __DLLEXPORT__
|
||||||
typedef void (*deallocator_t) (void*);
|
typedef void (*deallocator_t) (void*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "vector_type.hpp"
|
#include "vector_type.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
template <class Comparator, typename T = uint32_t>
|
template <class Comparator, typename T = uint32_t>
|
||||||
class priority_vector : public vector_type<T> {
|
class priority_vector : public vector_type<T> {
|
||||||
const Comparator comp;
|
const Comparator comp;
|
||||||
public:
|
public:
|
||||||
priority_vector(Comparator comp = std::less<T>{}) :
|
priority_vector(Comparator comp = std::less<T>{}) :
|
||||||
comp(comp), vector_type<T>(0) {}
|
comp(comp), vector_type<T>(0) {}
|
||||||
void emplace_back(T val) {
|
void emplace_back(T val) {
|
||||||
vector_type<T>::emplace_back(val);
|
vector_type<T>::emplace_back(val);
|
||||||
std::push_heap(container, container + size, comp);
|
std::push_heap(container, container + size, comp);
|
||||||
}
|
}
|
||||||
void pop_back() {
|
void pop_back() {
|
||||||
std::pop_heap(container, container + size, comp);
|
std::pop_heap(container, container + size, comp);
|
||||||
--size;
|
--size;
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,369 +1,369 @@
|
|||||||
#include "pch.hpp"
|
#include "pch.hpp"
|
||||||
|
|
||||||
#include "../csv.h"
|
#include "../csv.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "libaquery.h"
|
#include "libaquery.h"
|
||||||
#include "monetdb_conn.h"
|
#include "monetdb_conn.h"
|
||||||
#ifdef THREADING
|
#ifdef THREADING
|
||||||
#include "threading.h"
|
#include "threading.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "winhelper.h"
|
#include "winhelper.h"
|
||||||
#else
|
#else
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
struct SharedMemory
|
struct SharedMemory
|
||||||
{
|
{
|
||||||
int hFileMap;
|
int hFileMap;
|
||||||
void* pData;
|
void* pData;
|
||||||
SharedMemory(const char* fname) {
|
SharedMemory(const char* fname) {
|
||||||
hFileMap = open(fname, O_RDWR, 0);
|
hFileMap = open(fname, O_RDWR, 0);
|
||||||
if (hFileMap != -1)
|
if (hFileMap != -1)
|
||||||
pData = mmap(NULL, 8, PROT_READ | PROT_WRITE, MAP_SHARED, hFileMap, 0);
|
pData = mmap(NULL, 8, PROT_READ | PROT_WRITE, MAP_SHARED, hFileMap, 0);
|
||||||
else
|
else
|
||||||
pData = 0;
|
pData = 0;
|
||||||
}
|
}
|
||||||
void FreeMemoryMap() {
|
void FreeMemoryMap() {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "aggregations.h"
|
#include "aggregations.h"
|
||||||
typedef int (*code_snippet)(void*);
|
typedef int (*code_snippet)(void*);
|
||||||
typedef void (*module_init_fn)(Context*);
|
typedef void (*module_init_fn)(Context*);
|
||||||
|
|
||||||
int test_main();
|
int test_main();
|
||||||
|
|
||||||
int n_recv = 0;
|
int n_recv = 0;
|
||||||
char** n_recvd = nullptr;
|
char** n_recvd = nullptr;
|
||||||
|
|
||||||
extern "C" void __DLLEXPORT__ receive_args(int argc, char**argv){
|
extern "C" void __DLLEXPORT__ receive_args(int argc, char**argv){
|
||||||
n_recv = argc;
|
n_recv = argc;
|
||||||
n_recvd = argv;
|
n_recvd = argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BinaryInfo_t {
|
enum BinaryInfo_t {
|
||||||
MSVC, MSYS, GCC, CLANG, AppleClang
|
MSVC, MSYS, GCC, CLANG, AppleClang
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" int __DLLEXPORT__ binary_info() {
|
extern "C" int __DLLEXPORT__ binary_info() {
|
||||||
#if defined(_MSC_VER) && !defined (__llvm__)
|
#if defined(_MSC_VER) && !defined (__llvm__)
|
||||||
return MSVC;
|
return MSVC;
|
||||||
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
|
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
return MSYS;
|
return MSYS;
|
||||||
#elif defined(__clang__)
|
#elif defined(__clang__)
|
||||||
return CLANG;
|
return CLANG;
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
return GCC;
|
return GCC;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
__AQEXPORT__(bool) have_hge(){
|
__AQEXPORT__(bool) have_hge(){
|
||||||
#if defined(__MONETDB_CONN_H__)
|
#if defined(__MONETDB_CONN_H__)
|
||||||
return Server::havehge();
|
return Server::havehge();
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::Context() {
|
Context::Context() {
|
||||||
current.memory_map = new std::unordered_map<void*, deallocator_t>;
|
current.memory_map = new std::unordered_map<void*, deallocator_t>;
|
||||||
init_session();
|
init_session();
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::~Context() {
|
Context::~Context() {
|
||||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||||
delete memmap;
|
delete memmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::init_session(){
|
void Context::init_session(){
|
||||||
if (log_level == LOG_INFO){
|
if (log_level == LOG_INFO){
|
||||||
memset(&(this->current.stats), 0, sizeof(Session::Statistic));
|
memset(&(this->current.stats), 0, sizeof(Session::Statistic));
|
||||||
}
|
}
|
||||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||||
memmap->clear();
|
memmap->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::end_session(){
|
void Context::end_session(){
|
||||||
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
auto memmap = (std::unordered_map<void*, deallocator_t>*) this->current.memory_map;
|
||||||
for (auto& mem : *memmap) {
|
for (auto& mem : *memmap) {
|
||||||
mem.second(mem.first);
|
mem.second(mem.first);
|
||||||
}
|
}
|
||||||
memmap->clear();
|
memmap->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Context::get_module_function(const char* fname){
|
void* Context::get_module_function(const char* fname){
|
||||||
auto fmap = static_cast<std::unordered_map<std::string, void*>*>
|
auto fmap = static_cast<std::unordered_map<std::string, void*>*>
|
||||||
(this->module_function_maps);
|
(this->module_function_maps);
|
||||||
printf("%p\n", fmap->find("mydiv")->second);
|
printf("%p\n", fmap->find("mydiv")->second);
|
||||||
for (const auto& [key, value] : *fmap){
|
for (const auto& [key, value] : *fmap){
|
||||||
printf("%s %p\n", key.c_str(), value);
|
printf("%s %p\n", key.c_str(), value);
|
||||||
}
|
}
|
||||||
auto ret = fmap->find(fname);
|
auto ret = fmap->find(fname);
|
||||||
return ret == fmap->end() ? nullptr : ret->second;
|
return ret == fmap->end() ? nullptr : ret->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_module(const char* module_name, void* module_handle, Context* cxt){
|
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"));
|
auto _init_module = reinterpret_cast<module_init_fn>(dlsym(module_handle, "init_session"));
|
||||||
if (_init_module) {
|
if (_init_module) {
|
||||||
_init_module(cxt);
|
_init_module(cxt);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Warning: module %s have no session support.\n", module_name);
|
printf("Warning: module %s have no session support.\n", module_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int dll_main(int argc, char** argv, Context* cxt){
|
int dll_main(int argc, char** argv, Context* cxt){
|
||||||
Config *cfg = reinterpret_cast<Config *>(argv[0]);
|
Config *cfg = reinterpret_cast<Config *>(argv[0]);
|
||||||
std::unordered_map<std::string, void*> user_module_map;
|
std::unordered_map<std::string, void*> user_module_map;
|
||||||
if (cxt->module_function_maps == 0)
|
if (cxt->module_function_maps == 0)
|
||||||
cxt->module_function_maps = new std::unordered_map<std::string, void*>();
|
cxt->module_function_maps = new std::unordered_map<std::string, void*>();
|
||||||
auto module_fn_map =
|
auto module_fn_map =
|
||||||
static_cast<std::unordered_map<std::string, void*>*>(cxt->module_function_maps);
|
static_cast<std::unordered_map<std::string, void*>*>(cxt->module_function_maps);
|
||||||
|
|
||||||
auto buf_szs = cfg->buffer_sizes;
|
auto buf_szs = cfg->buffer_sizes;
|
||||||
void** buffers = (void**)malloc(sizeof(void*) * cfg->n_buffers);
|
void** buffers = (void**)malloc(sizeof(void*) * cfg->n_buffers);
|
||||||
for (int i = 0; i < cfg->n_buffers; i++)
|
for (int i = 0; i < cfg->n_buffers; i++)
|
||||||
buffers[i] = static_cast<void *>(argv[i + 1]);
|
buffers[i] = static_cast<void *>(argv[i + 1]);
|
||||||
|
|
||||||
cxt->buffers = buffers;
|
cxt->buffers = buffers;
|
||||||
cxt->cfg = cfg;
|
cxt->cfg = cfg;
|
||||||
cxt->n_buffers = cfg->n_buffers;
|
cxt->n_buffers = cfg->n_buffers;
|
||||||
cxt->sz_bufs = buf_szs;
|
cxt->sz_bufs = buf_szs;
|
||||||
cxt->alt_server = NULL;
|
cxt->alt_server = NULL;
|
||||||
|
|
||||||
while(cfg->running){
|
while(cfg->running){
|
||||||
if (cfg->new_query) {
|
if (cfg->new_query) {
|
||||||
void *handle = 0;
|
void *handle = 0;
|
||||||
void *user_module_handle = 0;
|
void *user_module_handle = 0;
|
||||||
if (cfg->backend_type == BACKEND_MonetDB){
|
if (cfg->backend_type == BACKEND_MonetDB){
|
||||||
if (cxt->alt_server == 0)
|
if (cxt->alt_server == 0)
|
||||||
cxt->alt_server = new Server(cxt);
|
cxt->alt_server = new Server(cxt);
|
||||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||||
if(n_recv > 0){
|
if(n_recv > 0){
|
||||||
if (cfg->backend_type == BACKEND_AQuery || cfg->has_dll) {
|
if (cfg->backend_type == BACKEND_AQuery || cfg->has_dll) {
|
||||||
handle = dlopen("./dll.so", RTLD_LAZY);
|
handle = dlopen("./dll.so", RTLD_LAZY);
|
||||||
}
|
}
|
||||||
for (const auto& module : user_module_map){
|
for (const auto& module : user_module_map){
|
||||||
initialize_module(module.first.c_str(), module.second, cxt);
|
initialize_module(module.first.c_str(), module.second, cxt);
|
||||||
}
|
}
|
||||||
cxt->init_session();
|
cxt->init_session();
|
||||||
for(int i = 0; i < n_recv; ++i)
|
for(int i = 0; i < n_recv; ++i)
|
||||||
{
|
{
|
||||||
//printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q');
|
//printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q');
|
||||||
switch(n_recvd[i][0]){
|
switch(n_recvd[i][0]){
|
||||||
case 'Q': // SQL query for monetdbe
|
case 'Q': // SQL query for monetdbe
|
||||||
{
|
{
|
||||||
server->exec(n_recvd[i] + 1);
|
server->exec(n_recvd[i] + 1);
|
||||||
printf("Exec Q%d: %s", i, n_recvd[i]);
|
printf("Exec Q%d: %s", i, n_recvd[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'P': // Postprocessing procedure
|
case 'P': // Postprocessing procedure
|
||||||
if(handle && !server->haserror()) {
|
if(handle && !server->haserror()) {
|
||||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i]+1));
|
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i]+1));
|
||||||
c(cxt);
|
c(cxt);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'M': // Load Module
|
case 'M': // Load Module
|
||||||
{
|
{
|
||||||
auto mname = n_recvd[i] + 1;
|
auto mname = n_recvd[i] + 1;
|
||||||
user_module_handle = dlopen(mname, RTLD_LAZY);
|
user_module_handle = dlopen(mname, RTLD_LAZY);
|
||||||
//getlasterror
|
//getlasterror
|
||||||
|
|
||||||
if (!user_module_handle)
|
if (!user_module_handle)
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
puts(dlerror());
|
puts(dlerror());
|
||||||
#else
|
#else
|
||||||
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, GetLastError());
|
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, GetLastError());
|
||||||
#endif
|
#endif
|
||||||
user_module_map[mname] = user_module_handle;
|
user_module_map[mname] = user_module_handle;
|
||||||
initialize_module(mname, user_module_handle, cxt);
|
initialize_module(mname, user_module_handle, cxt);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'F': // Register Function in Module
|
case 'F': // Register Function in Module
|
||||||
{
|
{
|
||||||
auto fname = n_recvd[i] + 1;
|
auto fname = n_recvd[i] + 1;
|
||||||
printf("F:: %s: %p, %p\n", fname, user_module_handle, dlsym(user_module_handle, fname));
|
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));
|
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);
|
printf("F::: %p\n", module_fn_map->find("mydiv") != module_fn_map->end() ? module_fn_map->find("mydiv")->second : nullptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'U': // Unload Module
|
case 'U': // Unload Module
|
||||||
{
|
{
|
||||||
auto mname = n_recvd[i] + 1;
|
auto mname = n_recvd[i] + 1;
|
||||||
auto it = user_module_map.find(mname);
|
auto it = user_module_map.find(mname);
|
||||||
if (user_module_handle == it->second)
|
if (user_module_handle == it->second)
|
||||||
user_module_handle = 0;
|
user_module_handle = 0;
|
||||||
dlclose(it->second);
|
dlclose(it->second);
|
||||||
user_module_map.erase(it);
|
user_module_map.erase(it);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(handle) {
|
if(handle) {
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
handle = 0;
|
handle = 0;
|
||||||
}
|
}
|
||||||
cxt->end_session();
|
cxt->end_session();
|
||||||
n_recv = 0;
|
n_recv = 0;
|
||||||
}
|
}
|
||||||
if(server->last_error == nullptr){
|
if(server->last_error == nullptr){
|
||||||
// TODO: Add feedback to prompt.
|
// TODO: Add feedback to prompt.
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
server->last_error = nullptr;
|
server->last_error = nullptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// puts(cfg->has_dll ? "true" : "false");
|
// puts(cfg->has_dll ? "true" : "false");
|
||||||
if (cfg->backend_type == BACKEND_AQuery) {
|
if (cfg->backend_type == BACKEND_AQuery) {
|
||||||
handle = dlopen("./dll.so", RTLD_LAZY);
|
handle = dlopen("./dll.so", RTLD_LAZY);
|
||||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||||
c(cxt);
|
c(cxt);
|
||||||
}
|
}
|
||||||
if (handle) dlclose(handle);
|
if (handle) dlclose(handle);
|
||||||
cfg->new_query = 0;
|
cfg->new_query = 0;
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int launcher(int argc, char** argv){
|
int launcher(int argc, char** argv){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
constexpr char sep = '\\';
|
constexpr char sep = '\\';
|
||||||
#else
|
#else
|
||||||
constexpr char sep = '/';
|
constexpr char sep = '/';
|
||||||
#endif
|
#endif
|
||||||
std::string str = " ";
|
std::string str = " ";
|
||||||
std::string pwd = "";
|
std::string pwd = "";
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
pwd = argv[0];
|
pwd = argv[0];
|
||||||
|
|
||||||
auto pos = pwd.find_last_of(sep);
|
auto pos = pwd.find_last_of(sep);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
pos = 0;
|
pos = 0;
|
||||||
pwd = pwd.substr(0, pos);
|
pwd = pwd.substr(0, pos);
|
||||||
for (int i = 1; i < argc; i++){
|
for (int i = 1; i < argc; i++){
|
||||||
str += argv[i];
|
str += argv[i];
|
||||||
str += " ";
|
str += " ";
|
||||||
}
|
}
|
||||||
str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str;
|
str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str;
|
||||||
return system(str.c_str());
|
return system(str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int __DLLEXPORT__ main(int argc, char** argv) {
|
extern "C" int __DLLEXPORT__ main(int argc, char** argv) {
|
||||||
#ifdef __AQ_BUILD_LAUNCHER__
|
#ifdef __AQ_BUILD_LAUNCHER__
|
||||||
return launcher(argc, argv);
|
return launcher(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
puts("running");
|
puts("running");
|
||||||
Context* cxt = new Context();
|
Context* cxt = new Context();
|
||||||
cxt->log("%d %s\n", argc, argv[1]);
|
cxt->log("%d %s\n", argc, argv[1]);
|
||||||
|
|
||||||
#ifdef THREADING
|
#ifdef THREADING
|
||||||
auto tp = new ThreadPool();
|
auto tp = new ThreadPool();
|
||||||
cxt->thread_pool = tp;
|
cxt->thread_pool = tp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* shmname;
|
const char* shmname;
|
||||||
if (argc < 0)
|
if (argc < 0)
|
||||||
return dll_main(argc, argv, cxt);
|
return dll_main(argc, argv, cxt);
|
||||||
else if (argc <= 1)
|
else if (argc <= 1)
|
||||||
return test_main();
|
return test_main();
|
||||||
else
|
else
|
||||||
shmname = argv[1];
|
shmname = argv[1];
|
||||||
SharedMemory shm = SharedMemory(shmname);
|
SharedMemory shm = SharedMemory(shmname);
|
||||||
if (!shm.pData)
|
if (!shm.pData)
|
||||||
return 1;
|
return 1;
|
||||||
bool &running = static_cast<bool*>(shm.pData)[0],
|
bool &running = static_cast<bool*>(shm.pData)[0],
|
||||||
&ready = static_cast<bool*>(shm.pData)[1];
|
&ready = static_cast<bool*>(shm.pData)[1];
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
cxt->log("running: %s\n", running? "true":"false");
|
cxt->log("running: %s\n", running? "true":"false");
|
||||||
cxt->log("ready: %s\n", ready? "true":"false");
|
cxt->log("ready: %s\n", ready? "true":"false");
|
||||||
while (running) {
|
while (running) {
|
||||||
std::this_thread::sleep_for(1ms);
|
std::this_thread::sleep_for(1ms);
|
||||||
if(ready){
|
if(ready){
|
||||||
cxt->log("running: %s\n", running? "true":"false");
|
cxt->log("running: %s\n", running? "true":"false");
|
||||||
cxt->log("ready: %s\n", ready? "true":"false");
|
cxt->log("ready: %s\n", ready? "true":"false");
|
||||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||||
cxt->log("handle: %p\n", handle);
|
cxt->log("handle: %p\n", handle);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
cxt->log("inner\n");
|
cxt->log("inner\n");
|
||||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||||
cxt->log("routine: %p\n", c);
|
cxt->log("routine: %p\n", c);
|
||||||
if (c) {
|
if (c) {
|
||||||
cxt->log("inner\n");
|
cxt->log("inner\n");
|
||||||
cxt->err("return: %d\n", c(cxt));
|
cxt->err("return: %d\n", c(cxt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ready = false;
|
ready = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shm.FreeMemoryMap();
|
shm.FreeMemoryMap();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "table_ext_monetdb.hpp"
|
#include "table_ext_monetdb.hpp"
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
Context* cxt = new Context();
|
Context* cxt = new Context();
|
||||||
if (cxt->alt_server == 0)
|
if (cxt->alt_server == 0)
|
||||||
cxt->alt_server = new Server(cxt);
|
cxt->alt_server = new Server(cxt);
|
||||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||||
|
|
||||||
|
|
||||||
//TableInfo<int, float> table("sibal");
|
//TableInfo<int, float> table("sibal");
|
||||||
//int col0[] = { 1,2,3,4,5 };
|
//int col0[] = { 1,2,3,4,5 };
|
||||||
//float col1[] = { 5.f, 4.f, 3.f, 2.f, 1.f };
|
//float col1[] = { 5.f, 4.f, 3.f, 2.f, 1.f };
|
||||||
//table.get_col<0>().initfrom(5, col0, "a");
|
//table.get_col<0>().initfrom(5, col0, "a");
|
||||||
//table.get_col<1>().initfrom(5, col1, "b");
|
//table.get_col<1>().initfrom(5, col1, "b");
|
||||||
//table.monetdb_append_table(server);
|
//table.monetdb_append_table(server);
|
||||||
//
|
//
|
||||||
//server->exec("select * from sibal;");
|
//server->exec("select * from sibal;");
|
||||||
//auto aa = server->getCol(0);
|
//auto aa = server->getCol(0);
|
||||||
//auto bb = server->getCol(1);
|
//auto bb = server->getCol(1);
|
||||||
//printf("sibal: %p %p\n", aa, bb);
|
//printf("sibal: %p %p\n", aa, bb);
|
||||||
|
|
||||||
const char* qs[]= {
|
const char* qs[]= {
|
||||||
"CREATE TABLE test(a INT, b INT, c INT, d INT);",
|
"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 ',';",
|
"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 ;",
|
"SELECT (a + b), a,b,c FROM test ;",
|
||||||
};
|
};
|
||||||
n_recv = sizeof(qs)/(sizeof (char*));
|
n_recv = sizeof(qs)/(sizeof (char*));
|
||||||
n_recvd = const_cast<char**>(qs);
|
n_recvd = const_cast<char**>(qs);
|
||||||
if (n_recv > 0) {
|
if (n_recv > 0) {
|
||||||
for (int i = 0; i < n_recv; ++i)
|
for (int i = 0; i < n_recv; ++i)
|
||||||
{
|
{
|
||||||
server->exec(n_recvd[i]);
|
server->exec(n_recvd[i]);
|
||||||
printf("Exec Q%d: %s\n", i, n_recvd[i]);
|
printf("Exec Q%d: %s\n", i, n_recvd[i]);
|
||||||
}
|
}
|
||||||
n_recv = 0;
|
n_recv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cxt->log_level = LOG_INFO;
|
cxt->log_level = LOG_INFO;
|
||||||
puts(cpp_17 ?"true":"false");
|
puts(cpp_17 ?"true":"false");
|
||||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||||
cxt->log("handle: %p\n", handle);
|
cxt->log("handle: %p\n", handle);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
cxt->log("inner\n");
|
cxt->log("inner\n");
|
||||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dll_ZF5Shg"));
|
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dll_ZF5Shg"));
|
||||||
cxt->log("routine: %p\n", c);
|
cxt->log("routine: %p\n", c);
|
||||||
if (c) {
|
if (c) {
|
||||||
cxt->log("inner\n");
|
cxt->log("inner\n");
|
||||||
cxt->log("return: %d\n", c(cxt));
|
cxt->log("return: %d\n", c(cxt));
|
||||||
}
|
}
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
//static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
|
//static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
|
||||||
|
|
||||||
return 0;
|
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
|
// TODO: Think of a way of decoupling table.h part and
|
||||||
// monetdbe.h part to speed up compilation.
|
// monetdbe.h part to speed up compilation.
|
||||||
|
|
||||||
#ifndef __TABLE_EXT_MONETDB_HPP__
|
#ifndef __TABLE_EXT_MONETDB_HPP__
|
||||||
#define __TABLE_EXT_MONETDB_HPP__
|
#define __TABLE_EXT_MONETDB_HPP__
|
||||||
|
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include "monetdb_conn.h"
|
#include "monetdb_conn.h"
|
||||||
#include "monetdbe.h"
|
#include "monetdbe.h"
|
||||||
|
|
||||||
inline constexpr monetdbe_types AQType_2_monetdbe[] = {
|
inline constexpr monetdbe_types AQType_2_monetdbe[] = {
|
||||||
monetdbe_int32_t, monetdbe_float, monetdbe_str, monetdbe_double, monetdbe_int64_t,
|
monetdbe_int32_t, monetdbe_float, monetdbe_str, monetdbe_double, monetdbe_int64_t,
|
||||||
#ifdef HAVE_HGE
|
#ifdef HAVE_HGE
|
||||||
monetdbe_int128_t,
|
monetdbe_int128_t,
|
||||||
#else
|
#else
|
||||||
monetdbe_int64_t,
|
monetdbe_int64_t,
|
||||||
#endif
|
#endif
|
||||||
monetdbe_int16_t, monetdbe_date, monetdbe_time, monetdbe_int8_t,
|
monetdbe_int16_t, monetdbe_date, monetdbe_time, monetdbe_int8_t,
|
||||||
monetdbe_int32_t, monetdbe_int64_t,
|
monetdbe_int32_t, monetdbe_int64_t,
|
||||||
#ifdef HAVE_HGE
|
#ifdef HAVE_HGE
|
||||||
monetdbe_int128_t,
|
monetdbe_int128_t,
|
||||||
#else
|
#else
|
||||||
monetdbe_int64_t,
|
monetdbe_int64_t,
|
||||||
#endif
|
#endif
|
||||||
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool, monetdbe_int64_t, monetdbe_int64_t, monetdbe_int64_t
|
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool, monetdbe_int64_t, monetdbe_int64_t, monetdbe_int64_t
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ...Ts>
|
template<class ...Ts>
|
||||||
void TableInfo<Ts ...>::monetdb_append_table(void* srv, const char* alt_name) {
|
void TableInfo<Ts ...>::monetdb_append_table(void* srv, const char* alt_name) {
|
||||||
if (!alt_name){
|
if (!alt_name){
|
||||||
alt_name = this->name;
|
alt_name = this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
monetdbe_column** monetdbe_cols = new monetdbe_column * [sizeof...(Ts)];
|
monetdbe_column** monetdbe_cols = new monetdbe_column * [sizeof...(Ts)];
|
||||||
|
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
const auto get_col = [&monetdbe_cols, &i](auto v) {
|
const auto get_col = [&monetdbe_cols, &i](auto v) {
|
||||||
monetdbe_cols[i++] = (monetdbe_column*)v->monetdb_get_col();
|
monetdbe_cols[i++] = (monetdbe_column*)v->monetdb_get_col();
|
||||||
};
|
};
|
||||||
(get_col((ColRef<Ts>*)(colrefs + i)), ...);
|
(get_col((ColRef<Ts>*)(colrefs + i)), ...);
|
||||||
|
|
||||||
std::string create_table_str = "CREATE TABLE ";
|
std::string create_table_str = "CREATE TABLE ";
|
||||||
create_table_str += alt_name;
|
create_table_str += alt_name;
|
||||||
create_table_str += " (";
|
create_table_str += " (";
|
||||||
i = 0;
|
i = 0;
|
||||||
const auto get_name_type = [&i, *this]() {
|
const auto get_name_type = [&i, *this]() {
|
||||||
return std::string(colrefs[i++].name) + ' ';
|
return std::string(colrefs[i++].name) + ' ';
|
||||||
};
|
};
|
||||||
create_table_str += ((get_name_type() + types::SQL_Type[types::Types<Ts>::getType()] + ", ") + ... + std::string(""));
|
create_table_str += ((get_name_type() + types::SQL_Type[types::Types<Ts>::getType()] + ", ") + ... + std::string(""));
|
||||||
auto last_comma = create_table_str.find_last_of(',');
|
auto last_comma = create_table_str.find_last_of(',');
|
||||||
if (last_comma != static_cast<decltype(last_comma)>(-1)) {
|
if (last_comma != static_cast<decltype(last_comma)>(-1)) {
|
||||||
create_table_str[last_comma] = ')';
|
create_table_str[last_comma] = ')';
|
||||||
Server* server = (Server*)srv;
|
Server* server = (Server*)srv;
|
||||||
server->exec(create_table_str.c_str());
|
server->exec(create_table_str.c_str());
|
||||||
if (!server->last_error) {
|
if (!server->last_error) {
|
||||||
auto err = monetdbe_append(*((monetdbe_database*)server->server), "sys", alt_name, monetdbe_cols, sizeof...(Ts));
|
auto err = monetdbe_append(*((monetdbe_database*)server->server), "sys", alt_name, monetdbe_cols, sizeof...(Ts));
|
||||||
if (err)
|
if (err)
|
||||||
puts(err);
|
puts(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
puts("Error! Empty table.");
|
puts("Error! Empty table.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void* ColRef<Type>::monetdb_get_col() {
|
void* ColRef<Type>::monetdb_get_col() {
|
||||||
auto aq_type = AQType_2_monetdbe[types::Types<Type>::getType()];
|
auto aq_type = AQType_2_monetdbe[types::Types<Type>::getType()];
|
||||||
monetdbe_column* col = (monetdbe_column*)malloc(sizeof(monetdbe_column));
|
monetdbe_column* col = (monetdbe_column*)malloc(sizeof(monetdbe_column));
|
||||||
|
|
||||||
col->type = aq_type;
|
col->type = aq_type;
|
||||||
col->count = this->size;
|
col->count = this->size;
|
||||||
col->data = this->container;
|
col->data = this->container;
|
||||||
col->name = const_cast<char*>(this->name);
|
col->name = const_cast<char*>(this->name);
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,237 +1,237 @@
|
|||||||
#ifndef _TYPES_H
|
#ifndef _TYPES_H
|
||||||
#define _TYPES_H
|
#define _TYPES_H
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define __restrict__ __restrict
|
#define __restrict__ __restrict
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr static inline bool is_vector(const T&) {
|
constexpr static inline bool is_vector(const T&) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
struct is_vector_impl : std::false_type {};
|
struct is_vector_impl : std::false_type {};
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr static bool is_vector_type = is_vector_impl<T>::value;
|
constexpr static bool is_vector_type = is_vector_impl<T>::value;
|
||||||
|
|
||||||
namespace types {
|
namespace types {
|
||||||
enum Type_t {
|
enum Type_t {
|
||||||
AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT128, AINT16, ADATE, ATIME, AINT8,
|
AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT128, AINT16, ADATE, ATIME, AINT8,
|
||||||
AUINT32, AUINT64, AUINT128, AUINT16, AUINT8, ABOOL, VECTOR, NONE, ERROR
|
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",
|
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" };
|
"%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",
|
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"};
|
"INT", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "BIGINT", "BOOL", "BIGINT", "NULL", "ERROR"};
|
||||||
|
|
||||||
|
|
||||||
// TODO: deal with data/time <=> str/uint conversion
|
// TODO: deal with data/time <=> str/uint conversion
|
||||||
struct date_t {
|
struct date_t {
|
||||||
uint32_t val = 0;
|
uint32_t val = 0;
|
||||||
date_t(const char* d) {
|
date_t(const char* d) {
|
||||||
}
|
}
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
};
|
};
|
||||||
struct time_t {
|
struct time_t {
|
||||||
uint32_t val = 0;
|
uint32_t val = 0;
|
||||||
time_t(const char* d) {
|
time_t(const char* d) {
|
||||||
}
|
}
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Types {
|
struct Types {
|
||||||
typedef T type;
|
typedef T type;
|
||||||
constexpr Types() noexcept = default;
|
constexpr Types() noexcept = default;
|
||||||
#ifdef __SIZEOF_INT128__
|
#ifdef __SIZEOF_INT128__
|
||||||
#define F_INT128(__F_) __F_(__int128_t, AINT128) \
|
#define F_INT128(__F_) __F_(__int128_t, AINT128) \
|
||||||
__F_(__uint128_t, AUINT128)
|
__F_(__uint128_t, AUINT128)
|
||||||
#define ULL_Type __uint128_t
|
#define ULL_Type __uint128_t
|
||||||
#define LL_Type __int128_t
|
#define LL_Type __int128_t
|
||||||
#else
|
#else
|
||||||
#define F_INT128(__F_)
|
#define F_INT128(__F_)
|
||||||
#define ULL_Type unsigned long long
|
#define ULL_Type unsigned long long
|
||||||
#define LL_Type long long
|
#define LL_Type long long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ConnectTypes(f) \
|
#define ConnectTypes(f) \
|
||||||
f(int, AINT32) \
|
f(int, AINT32) \
|
||||||
f(float, AFLOAT) \
|
f(float, AFLOAT) \
|
||||||
f(const char*, ASTR) \
|
f(const char*, ASTR) \
|
||||||
f(double, ADOUBLE) \
|
f(double, ADOUBLE) \
|
||||||
f(long double, ALDOUBLE) \
|
f(long double, ALDOUBLE) \
|
||||||
f(long, AINT64) \
|
f(long, AINT64) \
|
||||||
f(short, AINT16) \
|
f(short, AINT16) \
|
||||||
f(date_t, ADATE) \
|
f(date_t, ADATE) \
|
||||||
f(time_t, ATIME) \
|
f(time_t, ATIME) \
|
||||||
f(unsigned char, AINT8) \
|
f(unsigned char, AINT8) \
|
||||||
f(unsigned int, AUINT32) \
|
f(unsigned int, AUINT32) \
|
||||||
f(unsigned long, AUINT64) \
|
f(unsigned long, AUINT64) \
|
||||||
f(unsigned short, AUINT16) \
|
f(unsigned short, AUINT16) \
|
||||||
f(unsigned char, AUINT8) \
|
f(unsigned char, AUINT8) \
|
||||||
f(bool, ABOOL) \
|
f(bool, ABOOL) \
|
||||||
F_INT128(f)
|
F_INT128(f)
|
||||||
|
|
||||||
inline constexpr static Type_t getType() {
|
inline constexpr static Type_t getType() {
|
||||||
#define TypeConnect(x, y) if constexpr(std::is_same<x, T>::value) return y; else
|
#define TypeConnect(x, y) if constexpr(std::is_same<x, T>::value) return y; else
|
||||||
ConnectTypes(TypeConnect)
|
ConnectTypes(TypeConnect)
|
||||||
if constexpr (is_vector_type<T>)
|
if constexpr (is_vector_type<T>)
|
||||||
return VECTOR;
|
return VECTOR;
|
||||||
else
|
else
|
||||||
return NONE;
|
return NONE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#define ATypeSize(t, at) sizeof(t),
|
#define ATypeSize(t, at) sizeof(t),
|
||||||
static constexpr size_t AType_sizes[] = { ConnectTypes(ATypeSize) 1 };
|
static constexpr size_t AType_sizes[] = { ConnectTypes(ATypeSize) 1 };
|
||||||
#define Cond(c, x, y) typename std::conditional<c, x, y>::type
|
#define Cond(c, x, y) typename std::conditional<c, x, y>::type
|
||||||
#define Comp(o) (sizeof(T1) o sizeof(T2))
|
#define Comp(o) (sizeof(T1) o sizeof(T2))
|
||||||
#define Same(x, y) (std::is_same_v<x, y>)
|
#define Same(x, y) (std::is_same_v<x, y>)
|
||||||
#define __U(x) std::is_unsigned<x>::value
|
#define __U(x) std::is_unsigned<x>::value
|
||||||
#define Fp(x) std::is_floating_point<x>::value
|
#define Fp(x) std::is_floating_point<x>::value
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
struct Coercion {
|
struct Coercion {
|
||||||
using t1 = Cond(Comp(<= ), Cond(Comp(== ), Cond(Fp(T1), T1, Cond(Fp(T2), T2, Cond(__U(T1), T2, T1))), T2), T1);
|
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 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);
|
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))
|
#define __Eq(x) (sizeof(T) == sizeof(x))
|
||||||
template<class T>
|
template<class T>
|
||||||
struct GetFPTypeImpl {
|
struct GetFPTypeImpl {
|
||||||
using type = Cond(__Eq(float), float, Cond(__Eq(double), double, double));
|
using type = Cond(__Eq(float), float, Cond(__Eq(double), double, double));
|
||||||
};
|
};
|
||||||
template<class T>
|
template<class T>
|
||||||
using GetFPType = typename GetFPTypeImpl<typename std::decay<T>::type>::type;
|
using GetFPType = typename GetFPTypeImpl<typename std::decay<T>::type>::type;
|
||||||
template<class T>
|
template<class T>
|
||||||
struct GetLongTypeImpl {
|
struct GetLongTypeImpl {
|
||||||
using type = Cond(__U(T), ULL_Type, Cond(Fp(T), double, LL_Type));
|
using type = Cond(__U(T), ULL_Type, Cond(Fp(T), double, LL_Type));
|
||||||
};
|
};
|
||||||
template<class T>
|
template<class T>
|
||||||
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
|
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define getT(i, t) std::tuple_element_t<i, std::tuple<t...>>
|
#define getT(i, t) std::tuple_element_t<i, std::tuple<t...>>
|
||||||
template <template<typename ...> class T, typename ...Types>
|
template <template<typename ...> class T, typename ...Types>
|
||||||
struct applyTemplates {
|
struct applyTemplates {
|
||||||
using type = T<Types...>;
|
using type = T<Types...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class lT, template <typename ...> class rT>
|
template <class lT, template <typename ...> class rT>
|
||||||
struct transTypes_s;
|
struct transTypes_s;
|
||||||
template <template<typename ...> class lT, typename ...T, template<typename ...> class rT>
|
template <template<typename ...> class lT, typename ...T, template<typename ...> class rT>
|
||||||
struct transTypes_s<lT<T...>, rT> {
|
struct transTypes_s<lT<T...>, rT> {
|
||||||
using type = rT<T...>;
|
using type = rT<T...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// static_assert(std::is_same<transTypes<std::tuple<int, float>, std::unordered_map>, std::unordered_map<int, float>>::value);
|
// 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>
|
template <class lT, template <typename ...> class rT>
|
||||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||||
|
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
struct record_types {};
|
struct record_types {};
|
||||||
|
|
||||||
template <class ...Types>
|
template <class ...Types>
|
||||||
using record = std::tuple<Types...>;
|
using record = std::tuple<Types...>;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct decayS {
|
struct decayS {
|
||||||
using type = typename std::decay<T>::type;
|
using type = typename std::decay<T>::type;
|
||||||
};
|
};
|
||||||
template<template<typename ...> class T, typename ...Types>
|
template<template<typename ...> class T, typename ...Types>
|
||||||
struct decayS <T<Types...>>{
|
struct decayS <T<Types...>>{
|
||||||
using type = T<typename std::decay<Types>::type ...>;
|
using type = T<typename std::decay<Types>::type ...>;
|
||||||
};
|
};
|
||||||
template <class T>
|
template <class T>
|
||||||
using decays = typename decayS<typename std::decay<T>::type>::type;
|
using decays = typename decayS<typename std::decay<T>::type>::type;
|
||||||
template <class T>
|
template <class T>
|
||||||
using decay_inner = typename decayS<T>::type;
|
using decay_inner = typename decayS<T>::type;
|
||||||
|
|
||||||
template <class, template <class...> class T>
|
template <class, template <class...> class T>
|
||||||
struct instance_of_impl : std::false_type {};
|
struct instance_of_impl : std::false_type {};
|
||||||
template <class ...T1, template <class ...> class T2>
|
template <class ...T1, template <class ...> class T2>
|
||||||
struct instance_of_impl<T2<T1...>, T2> : std::true_type {};
|
struct instance_of_impl<T2<T1...>, T2> : std::true_type {};
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
struct same_class_impl : std::false_type {};
|
struct same_class_impl : std::false_type {};
|
||||||
template <class ...T1s, class ...T2s, template <class...> class T1>
|
template <class ...T1s, class ...T2s, template <class...> class T1>
|
||||||
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
bool same_class = same_class_impl<T1, T2>::value;
|
bool same_class = same_class_impl<T1, T2>::value;
|
||||||
template <class T1, template <class...> class T2>
|
template <class T1, template <class...> class T2>
|
||||||
bool instance_of = instance_of_impl<T1, T2>::value;
|
bool instance_of = instance_of_impl<T1, T2>::value;
|
||||||
|
|
||||||
template <class lT, template <typename ...> class rT>
|
template <class lT, template <typename ...> class rT>
|
||||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||||
|
|
||||||
template <class lT, class vT, template <vT ...> class rT>
|
template <class lT, class vT, template <vT ...> class rT>
|
||||||
struct transValues_s;
|
struct transValues_s;
|
||||||
template <class vT, template<class, vT ...> class lT, vT ...T, template<vT ...> class rT>
|
template <class vT, template<class, vT ...> class lT, vT ...T, template<vT ...> class rT>
|
||||||
struct transValues_s<lT<vT, T...>, vT, rT> {
|
struct transValues_s<lT<vT, T...>, vT, rT> {
|
||||||
using type = rT<T...>;
|
using type = rT<T...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
template <class vT, int i, template <vT ...> class rT>
|
template <class vT, int i, template <vT ...> class rT>
|
||||||
using transValues = typename transValues_s<std::make_integer_sequence<vT, i>, vT, rT>::type;
|
using transValues = typename transValues_s<std::make_integer_sequence<vT, i>, vT, rT>::type;
|
||||||
template <int i, template <int ...> class rT>
|
template <int i, template <int ...> class rT>
|
||||||
using applyIntegerSequence = typename transValues_s<std::make_integer_sequence<int, i>, int, rT>::type;
|
using applyIntegerSequence = typename transValues_s<std::make_integer_sequence<int, i>, int, rT>::type;
|
||||||
template <template <class ...> class T, class ...Types>
|
template <template <class ...> class T, class ...Types>
|
||||||
struct decayed_impl{ typedef T<Types...> type;};
|
struct decayed_impl{ typedef T<Types...> type;};
|
||||||
template <template <typename ...> class VT, class ...Types>
|
template <template <typename ...> class VT, class ...Types>
|
||||||
using decayed_t = typename decayed_impl<VT, Types...>::type;
|
using decayed_t = typename decayed_impl<VT, Types...>::type;
|
||||||
|
|
||||||
template <class First = void, class...Rest>
|
template <class First = void, class...Rest>
|
||||||
struct get_first_impl {
|
struct get_first_impl {
|
||||||
typedef First first;
|
typedef First first;
|
||||||
constexpr static size_t rest_len = sizeof...(Rest);
|
constexpr static size_t rest_len = sizeof...(Rest);
|
||||||
typedef get_first_impl<Rest...> rest;
|
typedef get_first_impl<Rest...> rest;
|
||||||
};
|
};
|
||||||
template <class ...T>
|
template <class ...T>
|
||||||
using get_first = typename get_first_impl<T...>::first;
|
using get_first = typename get_first_impl<T...>::first;
|
||||||
template <class T>
|
template <class T>
|
||||||
struct value_type_impl { typedef T type; };
|
struct value_type_impl { typedef T type; };
|
||||||
template <template <class...> class VT, class ...V>
|
template <template <class...> class VT, class ...V>
|
||||||
struct value_type_impl<VT<V...>> { typedef get_first<V...> type; };
|
struct value_type_impl<VT<V...>> { typedef get_first<V...> type; };
|
||||||
template <class T>
|
template <class T>
|
||||||
using value_type = typename value_type_impl<T>::type;
|
using value_type = typename value_type_impl<T>::type;
|
||||||
template <class ...T>
|
template <class ...T>
|
||||||
using get_first = typename get_first_impl<T...>::first;
|
using get_first = typename get_first_impl<T...>::first;
|
||||||
template <class T>
|
template <class T>
|
||||||
struct value_type_rec_impl { typedef T type; };
|
struct value_type_rec_impl { typedef T type; };
|
||||||
template <template <class...> class VT, class ...V>
|
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; };
|
struct value_type_rec_impl<VT<V...>> { typedef typename value_type_rec_impl<get_first<int>>::type type; };
|
||||||
template <class T>
|
template <class T>
|
||||||
using value_type_r = typename value_type_rec_impl<T>::type;
|
using value_type_r = typename value_type_rec_impl<T>::type;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct nullval_impl { constexpr static T value = 0; };
|
struct nullval_impl { constexpr static T value = 0; };
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr static T nullval = nullval_impl<T>::value;
|
constexpr static T nullval = nullval_impl<T>::value;
|
||||||
#include <limits>
|
#include <limits>
|
||||||
template <>
|
template <>
|
||||||
struct nullval_impl<int> { constexpr static int value = std::numeric_limits<int>::min(); };
|
struct nullval_impl<int> { constexpr static int value = std::numeric_limits<int>::min(); };
|
||||||
template<>
|
template<>
|
||||||
struct nullval_impl<float> { constexpr static float value = -std::numeric_limits<float>::quiet_NaN(); };
|
struct nullval_impl<float> { constexpr static float value = -std::numeric_limits<float>::quiet_NaN(); };
|
||||||
template<>
|
template<>
|
||||||
struct nullval_impl<double> { constexpr static double value = -std::numeric_limits<double>::quiet_NaN(); };
|
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) {
|
constexpr size_t sum_type(size_t a[], size_t sz) {
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
for (int i = 0; i < sz; ++i)
|
for (int i = 0; i < sz; ++i)
|
||||||
ret += a[i];
|
ret += a[i];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
template<class Types, class ...T1>
|
template<class Types, class ...T1>
|
||||||
constexpr size_t sum_type() {
|
constexpr size_t sum_type() {
|
||||||
size_t t[] = {std::is_same_v<Types, T1> ...};
|
size_t t[] = {std::is_same_v<Types, T1> ...};
|
||||||
return sum_type(t, sizeof...(T1));
|
return sum_type(t, sizeof...(T1));
|
||||||
}
|
}
|
||||||
template<class ...T1, class ...Types>
|
template<class ...T1, class ...Types>
|
||||||
constexpr size_t count_type(std::tuple<Types...>* ts) {
|
constexpr size_t count_type(std::tuple<Types...>* ts) {
|
||||||
size_t t[] = {sum_type<Types, T1...>() ...};
|
size_t t[] = {sum_type<Types, T1...>() ...};
|
||||||
return sum_type(t, sizeof...(Types));
|
return sum_type(t, sizeof...(Types));
|
||||||
}
|
}
|
||||||
#endif // !_TYPES_H
|
#endif // !_TYPES_H
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||||
constexpr static bool cpp_17 = true;
|
constexpr static bool cpp_17 = true;
|
||||||
#else
|
#else
|
||||||
constexpr static bool cpp_17 = false;
|
constexpr static bool cpp_17 = false;
|
||||||
#endif
|
#endif
|
||||||
template <class T>
|
template <class T>
|
||||||
inline const char* str(const T& v) {
|
inline const char* str(const T& v) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
inline const char* str(const bool& v) {
|
inline const char* str(const bool& v) {
|
||||||
return v ? "true" : "false";
|
return v ? "true" : "false";
|
||||||
}
|
}
|
@ -1,325 +1,325 @@
|
|||||||
/*
|
/*
|
||||||
* Bill Sun 2022
|
* Bill Sun 2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _VECTOR_TYPE
|
#ifndef _VECTOR_TYPE
|
||||||
#define _VECTOR_TYPE
|
#define _VECTOR_TYPE
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
template <typename _Ty>
|
template <typename _Ty>
|
||||||
class vector_type {
|
class vector_type {
|
||||||
public:
|
public:
|
||||||
typedef vector_type<_Ty> Decayed_t;
|
typedef vector_type<_Ty> Decayed_t;
|
||||||
void inline _copy(const vector_type<_Ty>& vt) {
|
void inline _copy(const vector_type<_Ty>& vt) {
|
||||||
// quick init while using malloc
|
// quick init while using malloc
|
||||||
//if (capacity > 0) free(container);
|
//if (capacity > 0) free(container);
|
||||||
|
|
||||||
this->size = vt.size;
|
this->size = vt.size;
|
||||||
this->capacity = vt.capacity;
|
this->capacity = vt.capacity;
|
||||||
if (capacity) {
|
if (capacity) {
|
||||||
// puts("copy");
|
// puts("copy");
|
||||||
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||||
memcpy(container, vt.container, sizeof(_Ty) * size);
|
memcpy(container, vt.container, sizeof(_Ty) * size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->container = vt.container;
|
this->container = vt.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void inline _move(vector_type<_Ty>&& vt) {
|
void inline _move(vector_type<_Ty>&& vt) {
|
||||||
if (capacity > 0) free(container);
|
if (capacity > 0) free(container);
|
||||||
|
|
||||||
this->size = vt.size;
|
this->size = vt.size;
|
||||||
this->capacity = vt.capacity;
|
this->capacity = vt.capacity;
|
||||||
this->container = vt.container;
|
this->container = vt.container;
|
||||||
// puts("move");
|
// puts("move");
|
||||||
vt.size = vt.capacity = 0;
|
vt.size = vt.capacity = 0;
|
||||||
vt.container = 0;
|
vt.container = 0;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
_Ty* container;
|
_Ty* container;
|
||||||
uint32_t size, capacity;
|
uint32_t size, capacity;
|
||||||
typedef _Ty* iterator_t;
|
typedef _Ty* iterator_t;
|
||||||
typedef _Ty value_t;
|
typedef _Ty value_t;
|
||||||
vector_type(const uint32_t& size) : size(size), capacity(size) {
|
vector_type(const uint32_t& size) : size(size), capacity(size) {
|
||||||
container = (_Ty*)malloc(size * sizeof(_Ty));
|
container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||||
}
|
}
|
||||||
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||||
size = capacity = _l.size();
|
size = capacity = _l.size();
|
||||||
_Ty* _container = this->container = (_Ty*)malloc(sizeof(_Ty) * _l.size());
|
_Ty* _container = this->container = (_Ty*)malloc(sizeof(_Ty) * _l.size());
|
||||||
for (const auto& l : _l) {
|
for (const auto& l : _l) {
|
||||||
*(_container++) = l;
|
*(_container++) = l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
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 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) {
|
constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
||||||
_copy(vt);
|
_copy(vt);
|
||||||
}
|
}
|
||||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
||||||
_move(std::move(vt));
|
_move(std::move(vt));
|
||||||
}
|
}
|
||||||
// size >= capacity ==> readonly vector
|
// size >= capacity ==> readonly vector
|
||||||
constexpr vector_type(const uint32_t size, void* data) :
|
constexpr vector_type(const uint32_t size, void* data) :
|
||||||
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
||||||
|
|
||||||
vector_type<_Ty>& operator =(const _Ty& vt) {
|
vector_type<_Ty>& operator =(const _Ty& vt) {
|
||||||
if (!container) {
|
if (!container) {
|
||||||
container = (_Ty*)malloc(sizeof(_Ty));
|
container = (_Ty*)malloc(sizeof(_Ty));
|
||||||
capacity = 1;
|
capacity = 1;
|
||||||
}
|
}
|
||||||
size = 1;
|
size = 1;
|
||||||
container[0] = vt;
|
container[0] = vt;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
// template<template <typename ...> class VT, class T>
|
// template<template <typename ...> class VT, class T>
|
||||||
// vector_type<_Ty>& operator =(VT<T>&& vt) {
|
// vector_type<_Ty>& operator =(VT<T>&& vt) {
|
||||||
// this->container = (_Ty*)vt.container;
|
// this->container = (_Ty*)vt.container;
|
||||||
// this->size = vt.size;
|
// this->size = vt.size;
|
||||||
// this->capacity = vt.capacity;
|
// this->capacity = vt.capacity;
|
||||||
// vt.capacity = 0; // rvalue's
|
// vt.capacity = 0; // rvalue's
|
||||||
// return *this;
|
// return *this;
|
||||||
// }
|
// }
|
||||||
vector_type<_Ty>& operator =(const vector_type<_Ty>& vt) {
|
vector_type<_Ty>& operator =(const vector_type<_Ty>& vt) {
|
||||||
_copy(vt);
|
_copy(vt);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
vector_type<_Ty>& operator =(vector_type<_Ty>&& vt) {
|
vector_type<_Ty>& operator =(vector_type<_Ty>&& vt) {
|
||||||
_move(std::move(vt));
|
_move(std::move(vt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template <template <class> class VT>
|
template <template <class> class VT>
|
||||||
vector_type<_Ty>& operator =(const VT<_Ty>& vt) {
|
vector_type<_Ty>& operator =(const VT<_Ty>& vt) {
|
||||||
if (capacity > 0) free(container);
|
if (capacity > 0) free(container);
|
||||||
container = static_cast<_Ty*>(malloc(vt.size * sizeof(_Ty)));
|
container = static_cast<_Ty*>(malloc(vt.size * sizeof(_Ty)));
|
||||||
|
|
||||||
size = vt.size;
|
size = vt.size;
|
||||||
capacity = size;
|
capacity = size;
|
||||||
for(uint32_t i = 0; i < size; ++i)
|
for(uint32_t i = 0; i < size; ++i)
|
||||||
container[i] = vt[i];
|
container[i] = vt[i];
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline void grow() {
|
inline void grow() {
|
||||||
if (size >= capacity) { // geometric growth
|
if (size >= capacity) { // geometric growth
|
||||||
uint32_t new_capacity = size + 1 + (size >> 1);
|
uint32_t new_capacity = size + 1 + (size >> 1);
|
||||||
_Ty* n_container = (_Ty*)malloc(new_capacity * sizeof(_Ty));
|
_Ty* n_container = (_Ty*)malloc(new_capacity * sizeof(_Ty));
|
||||||
memcpy(n_container, container, sizeof(_Ty) * size);
|
memcpy(n_container, container, sizeof(_Ty) * size);
|
||||||
memset(n_container + size, 0, sizeof(_Ty) * (new_capacity - size));
|
memset(n_container + size, 0, sizeof(_Ty) * (new_capacity - size));
|
||||||
if (capacity)
|
if (capacity)
|
||||||
free(container);
|
free(container);
|
||||||
container = n_container;
|
container = n_container;
|
||||||
capacity = new_capacity;
|
capacity = new_capacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void emplace_back(const _Ty& _val) {
|
void emplace_back(const _Ty& _val) {
|
||||||
grow();
|
grow();
|
||||||
container[size++] = _val;
|
container[size++] = _val;
|
||||||
}
|
}
|
||||||
void emplace_back(_Ty&& _val) {
|
void emplace_back(_Ty&& _val) {
|
||||||
grow();
|
grow();
|
||||||
container[size++] = std::move(_val);
|
container[size++] = std::move(_val);
|
||||||
}
|
}
|
||||||
iterator_t erase(iterator_t _it) {
|
iterator_t erase(iterator_t _it) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Do bound checks
|
// Do bound checks
|
||||||
if (!(size && capicity && container &&
|
if (!(size && capicity && container &&
|
||||||
_it >= container && (_it - container) < size))
|
_it >= container && (_it - container) < size))
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
iterator_t curr = _it + 1, end = _it + --size;
|
iterator_t curr = _it + 1, end = _it + --size;
|
||||||
while (curr < end)
|
while (curr < end)
|
||||||
*(curr - 1) = *(curr++);
|
*(curr - 1) = *(curr++);
|
||||||
return _it;
|
return _it;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator_t begin() const {
|
iterator_t begin() const {
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
iterator_t end() const {
|
iterator_t end() const {
|
||||||
return container + size;
|
return container + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator_t find(const _Ty item) const {
|
iterator_t find(const _Ty item) const {
|
||||||
iterator_t curr = begin(), _end = end();
|
iterator_t curr = begin(), _end = end();
|
||||||
while (curr != _end && *(curr++) != item);
|
while (curr != _end && *(curr++) != item);
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline _Ty& operator[](const uint32_t _i) const {
|
inline _Ty& operator[](const uint32_t _i) const {
|
||||||
return container[_i];
|
return container[_i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void shrink_to_fit() {
|
void shrink_to_fit() {
|
||||||
if (size && capacity != size) {
|
if (size && capacity != size) {
|
||||||
capacity = size;
|
capacity = size;
|
||||||
_Ty* _container = (_Ty*)malloc(sizeof(_Ty) * size);
|
_Ty* _container = (_Ty*)malloc(sizeof(_Ty) * size);
|
||||||
memcpy(_container, container, sizeof(_Ty) * size);
|
memcpy(_container, container, sizeof(_Ty) * size);
|
||||||
free(container);
|
free(container);
|
||||||
container = _container;
|
container = _container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_Ty& back() {
|
_Ty& back() {
|
||||||
return container[size - 1];
|
return container[size - 1];
|
||||||
}
|
}
|
||||||
void qpop() {
|
void qpop() {
|
||||||
size = size ? size - 1 : size;
|
size = size ? size - 1 : size;
|
||||||
}
|
}
|
||||||
void pop_resize() {
|
void pop_resize() {
|
||||||
if (size) {
|
if (size) {
|
||||||
--size;
|
--size;
|
||||||
if (capacity > (size << 1))
|
if (capacity > (size << 1))
|
||||||
{
|
{
|
||||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * size);
|
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * size);
|
||||||
memcpy(new_container, container, sizeof(_Ty) * size);
|
memcpy(new_container, container, sizeof(_Ty) * size);
|
||||||
free(container);
|
free(container);
|
||||||
container = new_container;
|
container = new_container;
|
||||||
capacity = size;
|
capacity = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_Ty pop() {
|
_Ty pop() {
|
||||||
return container[--size];
|
return container[--size];
|
||||||
}
|
}
|
||||||
void merge(vector_type<_Ty>& _other) {
|
void merge(vector_type<_Ty>& _other) {
|
||||||
if (capacity < this->size + _other.size)
|
if (capacity < this->size + _other.size)
|
||||||
{
|
{
|
||||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (_other.size + this->size));
|
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (_other.size + this->size));
|
||||||
capacity = this->size + _other.size;
|
capacity = this->size + _other.size;
|
||||||
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
||||||
memcpy(new_container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
memcpy(new_container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
||||||
free(container);
|
free(container);
|
||||||
container = new_container;
|
container = new_container;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memcpy(container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
memcpy(container + this->size, _other.container, sizeof(_Ty) * _other.size);
|
||||||
size = this->size + _other.size;
|
size = this->size + _other.size;
|
||||||
}
|
}
|
||||||
template<class _Iter>
|
template<class _Iter>
|
||||||
void merge(_Iter begin, _Iter end) {
|
void merge(_Iter begin, _Iter end) {
|
||||||
unsigned int dist = static_cast<unsigned int>(std::distance(begin, end));
|
unsigned int dist = static_cast<unsigned int>(std::distance(begin, end));
|
||||||
if (capacity < this->size + dist) {
|
if (capacity < this->size + dist) {
|
||||||
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (dist + this->size));
|
_Ty* new_container = (_Ty*)malloc(sizeof(_Ty) * (dist + this->size));
|
||||||
capacity = this->size + dist;
|
capacity = this->size + dist;
|
||||||
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
memcpy(new_container, container, sizeof(_Ty) * this->size);
|
||||||
free(container);
|
free(container);
|
||||||
container = new_container;
|
container = new_container;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < dist; ++i) {
|
for (int i = 0; i < dist; ++i) {
|
||||||
container[i + this->size] = *(begin + i);
|
container[i + this->size] = *(begin + i);
|
||||||
}
|
}
|
||||||
size = this->size + dist;
|
size = this->size + dist;
|
||||||
}
|
}
|
||||||
void out(uint32_t n = 4, const char* sep = " ") const;
|
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_memcpy(uint32_t start, uint32_t end) const {
|
||||||
vector_type<_Ty> subvec(end - start);
|
vector_type<_Ty> subvec(end - start);
|
||||||
memcpy(subvec.container, container + start, sizeof(_Ty) * (end - start));
|
memcpy(subvec.container, container + start, sizeof(_Ty) * (end - start));
|
||||||
return subvec;
|
return subvec;
|
||||||
}
|
}
|
||||||
inline vector_type<_Ty> subvec(uint32_t start, uint32_t end) const {
|
inline vector_type<_Ty> subvec(uint32_t start, uint32_t end) const {
|
||||||
return vector_type<_Ty>(container + start, end - start);
|
return vector_type<_Ty>(container + start, end - start);
|
||||||
}
|
}
|
||||||
vector_type<_Ty> subvec_deep(uint32_t start, uint32_t end) const {
|
vector_type<_Ty> subvec_deep(uint32_t start, uint32_t end) const {
|
||||||
uint32_t len = end - start;
|
uint32_t len = end - start;
|
||||||
vector_type<_Ty> subvec(len);
|
vector_type<_Ty> subvec(len);
|
||||||
for (uint32_t i = 0; i < len; ++i)
|
for (uint32_t i = 0; i < len; ++i)
|
||||||
subvec[i] = container[i];
|
subvec[i] = container[i];
|
||||||
return subvec;
|
return subvec;
|
||||||
}
|
}
|
||||||
inline vector_type<_Ty> subvec(uint32_t start = 0) { return subvec(start, size); }
|
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_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); }
|
inline vector_type<_Ty> subvec_deep(uint32_t start = 0) { return subvec_deep(start, size); }
|
||||||
|
|
||||||
~vector_type() {
|
~vector_type() {
|
||||||
if (capacity > 0) free(container);
|
if (capacity > 0) free(container);
|
||||||
container = 0; size = capacity = 0;
|
container = 0; size = capacity = 0;
|
||||||
}
|
}
|
||||||
#define Op(o, x) \
|
#define Op(o, x) \
|
||||||
template<typename T>\
|
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> inline x(const vector_type<T>& r) const {\
|
||||||
vector_type<typename types::Coercion<_Ty, T>::type> ret(size);\
|
vector_type<typename types::Coercion<_Ty, T>::type> ret(size);\
|
||||||
for (int i = 0; i < size; ++i)\
|
for (int i = 0; i < size; ++i)\
|
||||||
ret[i] = container[i] o r[i];\
|
ret[i] = container[i] o r[i];\
|
||||||
return ret;\
|
return ret;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Opeq(o, x) \
|
#define Opeq(o, x) \
|
||||||
template<typename T>\
|
template<typename T>\
|
||||||
inline vector_type<typename types::Coercion<_Ty, T>::type>& x##eq(const vector_type<T>& r) {\
|
inline vector_type<typename types::Coercion<_Ty, T>::type>& x##eq(const vector_type<T>& r) {\
|
||||||
for (int i = 0; i < size; ++i)\
|
for (int i = 0; i < size; ++i)\
|
||||||
container[i] = container[i] o##= r[i];\
|
container[i] = container[i] o##= r[i];\
|
||||||
return *this;\
|
return *this;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Ops(o, x) \
|
#define Ops(o, x) \
|
||||||
template<typename T>\
|
template<typename T>\
|
||||||
vector_type<typename types::Coercion<_Ty, T>::type> operator o (const vector_type<T>& r) const {\
|
vector_type<typename types::Coercion<_Ty, T>::type> operator o (const vector_type<T>& r) const {\
|
||||||
/*[[likely]] if (r.size == size) {*/\
|
/*[[likely]] if (r.size == size) {*/\
|
||||||
return x(r);\
|
return x(r);\
|
||||||
/*}*/\
|
/*}*/\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Opseq(o, x) \
|
#define Opseq(o, x) \
|
||||||
template<typename T>\
|
template<typename T>\
|
||||||
vector_type<typename types::Coercion<_Ty, T>::type> operator o##= (const vector_type<T>& r) {\
|
vector_type<typename types::Coercion<_Ty, T>::type> operator o##= (const vector_type<T>& r) {\
|
||||||
/*[[likely]] if (r.size == size) {*/\
|
/*[[likely]] if (r.size == size) {*/\
|
||||||
return x##eq(r);\
|
return x##eq(r);\
|
||||||
/*}*/\
|
/*}*/\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _Make_Ops(M) \
|
#define _Make_Ops(M) \
|
||||||
M(+, add) \
|
M(+, add) \
|
||||||
M(-, minus) \
|
M(-, minus) \
|
||||||
M(*, multi) \
|
M(*, multi) \
|
||||||
M(/, div) \
|
M(/, div) \
|
||||||
M(%, mod)
|
M(%, mod)
|
||||||
|
|
||||||
_Make_Ops(Op)
|
_Make_Ops(Op)
|
||||||
_Make_Ops(Opeq)
|
_Make_Ops(Opeq)
|
||||||
_Make_Ops(Ops)
|
_Make_Ops(Ops)
|
||||||
_Make_Ops(Opseq)
|
_Make_Ops(Opseq)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class vector_type<void> {
|
class vector_type<void> {
|
||||||
public:
|
public:
|
||||||
void* container;
|
void* container;
|
||||||
uint32_t size, capacity;
|
uint32_t size, capacity;
|
||||||
typedef void* iterator_t;
|
typedef void* iterator_t;
|
||||||
|
|
||||||
vector_type(uint32_t size) : size(size), capacity(size) {
|
vector_type(uint32_t size) : size(size), capacity(size) {
|
||||||
container = (void*)malloc(size);
|
container = (void*)malloc(size);
|
||||||
}
|
}
|
||||||
template<typename _Ty>
|
template<typename _Ty>
|
||||||
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||||
size = capacity = _l.size();
|
size = capacity = _l.size();
|
||||||
this->container = malloc(sizeof(_Ty) * _l.size());
|
this->container = malloc(sizeof(_Ty) * _l.size());
|
||||||
_Ty* _container = (_Ty*)this->container;
|
_Ty* _container = (_Ty*)this->container;
|
||||||
for (const auto& l : _l) {
|
for (const auto& l : _l) {
|
||||||
*(_container++) = l;
|
*(_container++) = l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
constexpr vector_type() : size(0), capacity(0), container(0) {};
|
constexpr vector_type() : size(0), capacity(0), container(0) {};
|
||||||
void* get(uint32_t i, types::Type_t atype){
|
void* get(uint32_t i, types::Type_t atype){
|
||||||
return static_cast<void*>(static_cast<char*>(container) + (i * types::AType_sizes[atype]));
|
return static_cast<void*>(static_cast<char*>(container) + (i * types::AType_sizes[atype]));
|
||||||
}
|
}
|
||||||
void operator[](const uint32_t& i);
|
void operator[](const uint32_t& i);
|
||||||
vector_type<void> subvec(uint32_t, uint32_t);
|
vector_type<void> subvec(uint32_t, uint32_t);
|
||||||
vector_type<void> subvec_memcpy(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_deep(uint32_t, uint32_t);
|
||||||
vector_type<void> subvec(uint32_t);
|
vector_type<void> subvec(uint32_t);
|
||||||
vector_type<void> subvec_memcpy(uint32_t);
|
vector_type<void> subvec_memcpy(uint32_t);
|
||||||
vector_type<void> subvec_deep(uint32_t);
|
vector_type<void> subvec_deep(uint32_t);
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,40 +1,40 @@
|
|||||||
#include "pch.hpp"
|
#include "pch.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "winhelper.h"
|
#include "winhelper.h"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
|
||||||
void* dlopen(const char* lib, int)
|
void* dlopen(const char* lib, int)
|
||||||
{
|
{
|
||||||
return LoadLibraryA(lib);
|
return LoadLibraryA(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* dlsym(void* handle, const char* proc)
|
void* dlsym(void* handle, const char* proc)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), proc));
|
return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), proc));
|
||||||
}
|
}
|
||||||
|
|
||||||
int dlclose(void* handle)
|
int dlclose(void* handle)
|
||||||
{
|
{
|
||||||
return FreeLibrary(static_cast<HMODULE>(handle));
|
return FreeLibrary(static_cast<HMODULE>(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedMemory::SharedMemory(const char* fname)
|
SharedMemory::SharedMemory(const char* fname)
|
||||||
{
|
{
|
||||||
this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname);
|
this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname);
|
||||||
if (this->hFileMap)
|
if (this->hFileMap)
|
||||||
this->pData = MapViewOfFile(this->hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 2);
|
this->pData = MapViewOfFile(this->hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 2);
|
||||||
else
|
else
|
||||||
this->pData = NULL;
|
this->pData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedMemory::FreeMemoryMap()
|
void SharedMemory::FreeMemoryMap()
|
||||||
{
|
{
|
||||||
if (this->hFileMap)
|
if (this->hFileMap)
|
||||||
if (this->pData)
|
if (this->pData)
|
||||||
UnmapViewOfFile(this->pData);
|
UnmapViewOfFile(this->pData);
|
||||||
if (this->hFileMap)
|
if (this->hFileMap)
|
||||||
CloseHandle(this->hFileMap);
|
CloseHandle(this->hFileMap);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#ifndef _WINHELPER_H
|
#ifndef _WINHELPER_H
|
||||||
#define _WINHELPER_H
|
#define _WINHELPER_H
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static constexpr int RTLD_LAZY = 1;
|
static constexpr int RTLD_LAZY = 1;
|
||||||
void* dlopen(const char*, int);
|
void* dlopen(const char*, int);
|
||||||
void* dlsym(void*, const char*);
|
void* dlsym(void*, const char*);
|
||||||
int dlclose(void*);
|
int dlclose(void*);
|
||||||
struct SharedMemory
|
struct SharedMemory
|
||||||
{
|
{
|
||||||
void* hFileMap;
|
void* hFileMap;
|
||||||
void* pData;
|
void* pData;
|
||||||
SharedMemory(const char*);
|
SharedMemory(const char*);
|
||||||
void FreeMemoryMap();
|
void FreeMemoryMap();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
FUNCTION covariance (x , y ) {
|
FUNCTION covariance (x , y ) {
|
||||||
xmean := avg (x) ;
|
xmean := avg (x) ;
|
||||||
ymean := avg (y) ;
|
ymean := avg (y) ;
|
||||||
avg (( x - xmean ) * (y - ymean ))
|
avg (( x - xmean ) * (y - ymean ))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FUNCTION sd ( x) {
|
FUNCTION sd ( x) {
|
||||||
sqrt ( covariance (x , x) )
|
sqrt ( covariance (x , x) )
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNCTION pairCorr (x , y ) {
|
FUNCTION pairCorr (x , y ) {
|
||||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE TABLE test1(a INT, b INT, c INT, d INT)
|
CREATE TABLE test1(a INT, b INT, c INT, d INT)
|
||||||
|
|
||||||
LOAD DATA INFILE "data/test.csv"
|
LOAD DATA INFILE "data/test.csv"
|
||||||
INTO TABLE test1
|
INTO TABLE test1
|
||||||
FIELDS TERMINATED BY ","
|
FIELDS TERMINATED BY ","
|
||||||
|
|
||||||
SELECT pairCorr(c, b) * d, sum(a), b
|
SELECT pairCorr(c, b) * d, sum(a), b
|
||||||
FROM test1
|
FROM test1
|
||||||
group by c,b,d
|
group by c,b,d
|
||||||
order by b ASC
|
order by b ASC
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
FUNCTION covariance (x , y ) {
|
FUNCTION covariance (x , y ) {
|
||||||
xmean := avg (x) ;
|
xmean := avg (x) ;
|
||||||
ymean := avg (y) ;
|
ymean := avg (y) ;
|
||||||
avg (( x - xmean ) * (y - ymean ))
|
avg (( x - xmean ) * (y - ymean ))
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNCTION sd ( x) {
|
FUNCTION sd ( x) {
|
||||||
sqrt ( covariance (x , x) )
|
sqrt ( covariance (x , x) )
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNCTION pairCorr (x , y ) {
|
FUNCTION pairCorr (x , y ) {
|
||||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||||
}
|
}
|
||||||
|
|
||||||
-- FUNCTION covariances (w, x , y ) {
|
-- FUNCTION covariances (w, x , y ) {
|
||||||
-- xmean := avgs (w, x) ;
|
-- xmean := avgs (w, x) ;
|
||||||
-- ymean := avgs (y) ;
|
-- ymean := avgs (y) ;
|
||||||
-- avg (( x - xmean ) * (y - ymean ))
|
-- avg (( x - xmean ) * (y - ymean ))
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
CREATE TABLE tt(a INT, b INT, c INT, d INT)
|
CREATE TABLE tt(a INT, b INT, c INT, d INT)
|
||||||
|
|
||||||
LOAD DATA INFILE "data/test.csv"
|
LOAD DATA INFILE "data/test.csv"
|
||||||
INTO TABLE tt
|
INTO TABLE tt
|
||||||
FIELDS TERMINATED BY ","
|
FIELDS TERMINATED BY ","
|
||||||
|
|
||||||
CREATE TABLE sale1(Mont INT, sales INT)
|
CREATE TABLE sale1(Mont INT, sales INT)
|
||||||
|
|
||||||
LOAD DATA INFILE "data/moving_avg.csv"
|
LOAD DATA INFILE "data/moving_avg.csv"
|
||||||
INTO TABLE sale1
|
INTO TABLE sale1
|
||||||
FIELDS TERMINATED BY ","
|
FIELDS TERMINATED BY ","
|
||||||
|
|
||||||
select sd(a) + sales from tt, sale1 where tt.a = sale1.Mont
|
select sd(a) + sales from tt, sale1 where tt.a = sale1.Mont
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
LOAD MODULE FROM "./test.so"
|
LOAD MODULE FROM "./test.so"
|
||||||
FUNCTIONS (
|
FUNCTIONS (
|
||||||
mydiv(a:int, b:int) -> double,
|
mydiv(a:int, b:int) -> double,
|
||||||
mulvec(a:int, b:vecfloat) -> vecfloat
|
mulvec(a:int, b:vecfloat) -> vecfloat
|
||||||
);
|
);
|
||||||
|
|
||||||
select mydiv(2,3);
|
select mydiv(2,3);
|
||||||
|
|
||||||
|
@ -1,112 +1,112 @@
|
|||||||
FUNCTION
|
FUNCTION
|
||||||
execStrategy ( alloc , mavgday , mavgmonth , px ) {
|
execStrategy ( alloc , mavgday , mavgmonth , px ) {
|
||||||
buySignal := mavgday > mavgmonth ;
|
buySignal := mavgday > mavgmonth ;
|
||||||
f := a + b ;
|
f := a + b ;
|
||||||
alloc * prd (
|
alloc * prd (
|
||||||
CASE maxs ( buySignal )
|
CASE maxs ( buySignal )
|
||||||
WHEN TRUE THEN
|
WHEN TRUE THEN
|
||||||
CASE buySignal
|
CASE buySignal
|
||||||
WHEN TRUE THEN 1 / px
|
WHEN TRUE THEN 1 / px
|
||||||
ELSE px
|
ELSE px
|
||||||
END
|
END
|
||||||
ELSE 1
|
ELSE 1
|
||||||
END )
|
END )
|
||||||
}
|
}
|
||||||
FUNCTION covariance (x , y ) {
|
FUNCTION covariance (x , y ) {
|
||||||
xmean := avg (x) ;
|
xmean := avg (x) ;
|
||||||
ymean := avg (y) ;
|
ymean := avg (y) ;
|
||||||
avg (( x - xmean ) * (y - ymean ))
|
avg (( x - xmean ) * (y - ymean ))
|
||||||
}
|
}
|
||||||
FUNCTION sd ( x) {
|
FUNCTION sd ( x) {
|
||||||
sqrt ( covariance (x , x) )
|
sqrt ( covariance (x , x) )
|
||||||
}
|
}
|
||||||
FUNCTION pairCorr (x , y ) {
|
FUNCTION pairCorr (x , y ) {
|
||||||
covariance (x , y ) / ( sd (x) * sd (y ))
|
covariance (x , y ) / ( sd (x) * sd (y ))
|
||||||
}
|
}
|
||||||
<k>
|
<k>
|
||||||
`
|
`
|
||||||
p:5
|
p:5
|
||||||
q:2
|
q:2
|
||||||
phi:(p+1)?1.
|
phi:(p+1)?1.
|
||||||
theta:q?1.
|
theta:q?1.
|
||||||
"p q phi theta"
|
"p q phi theta"
|
||||||
p
|
p
|
||||||
q
|
q
|
||||||
phi
|
phi
|
||||||
theta
|
theta
|
||||||
l:()
|
l:()
|
||||||
e:()
|
e:()
|
||||||
|
|
||||||
`
|
`
|
||||||
L1:10?20
|
L1:10?20
|
||||||
Le1:10?2.
|
Le1:10?2.
|
||||||
L2:3?20
|
L2:3?20
|
||||||
Le2:3?2.
|
Le2:3?2.
|
||||||
"L1 Le1 L2 Le2"
|
"L1 Le1 L2 Le2"
|
||||||
L1
|
L1
|
||||||
Le1
|
Le1
|
||||||
L2
|
L2
|
||||||
Le2
|
Le2
|
||||||
|
|
||||||
`
|
`
|
||||||
"Add L1, then predict"
|
"Add L1, then predict"
|
||||||
l:l,L1
|
l:l,L1
|
||||||
e:e,Le1
|
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:(phi(0)) + (sum ({[x](phi(x+1)) * (l(((#l)-1)-x))}[!p])) - (sum ({[x](theta(x)) * (e(((#e)-1)-x))}[!q]))
|
||||||
predict
|
predict
|
||||||
|
|
||||||
`
|
`
|
||||||
"Add L2, then predict"
|
"Add L2, then predict"
|
||||||
l:l,L2
|
l:l,L2
|
||||||
e:e,Le2
|
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:(phi(0)) + (sum ({[x](phi(x+1)) * (l(((#l)-1)-x))}[!p])) - (sum ({[x](theta(x)) * (e(((#e)-1)-x))}[!q]))
|
||||||
predict
|
predict
|
||||||
|
|
||||||
</k>
|
</k>
|
||||||
|
|
||||||
WITH
|
WITH
|
||||||
Target (Id , TradeDate , ClosePrice ) AS
|
Target (Id , TradeDate , ClosePrice ) AS
|
||||||
( SELECT
|
( SELECT
|
||||||
Id , TradeDate , ClosePrice
|
Id , TradeDate , ClosePrice
|
||||||
FROM price
|
FROM price
|
||||||
WHERE Id IN stock10 AND
|
WHERE Id IN stock10 AND
|
||||||
TradeDate >= startYear10 AND
|
TradeDate >= startYear10 AND
|
||||||
TradeDate <= startYear10 + 365 * 10),
|
TradeDate <= startYear10 + 365 * 10),
|
||||||
weekly (Id , bucket , name , low , high , mean ) AS
|
weekly (Id , bucket , name , low , high , mean ) AS
|
||||||
( SELECT
|
( SELECT
|
||||||
Id ,
|
Id ,
|
||||||
timeBucket ,
|
timeBucket ,
|
||||||
" weekly " ,
|
" weekly " ,
|
||||||
min ( ClosePrice ) ,
|
min ( ClosePrice ) ,
|
||||||
max ( ClosePrice ) ,
|
max ( ClosePrice ) ,
|
||||||
avg ( ClosePrice )
|
avg ( ClosePrice )
|
||||||
FROM Target
|
FROM Target
|
||||||
GROUP BY Id , getWeek ( TradeDate ) as
|
GROUP BY Id , getWeek ( TradeDate ) as
|
||||||
timeBucket ),
|
timeBucket ),
|
||||||
monthly ( Id , bucket , name , low , high , mean ) AS
|
monthly ( Id , bucket , name , low , high , mean ) AS
|
||||||
( SELECT
|
( SELECT
|
||||||
Id ,
|
Id ,
|
||||||
timeBucket ,
|
timeBucket ,
|
||||||
" monthly " ,
|
" monthly " ,
|
||||||
min ( ClosePrice ) ,
|
min ( ClosePrice ) ,
|
||||||
max ( ClosePrice ) ,
|
max ( ClosePrice ) ,
|
||||||
avg ( ClosePrice )
|
avg ( ClosePrice )
|
||||||
FROM Target
|
FROM Target
|
||||||
GROUP BY Id , getMonth ( TradeDate ) as
|
GROUP BY Id , getMonth ( TradeDate ) as
|
||||||
timeBucket ),
|
timeBucket ),
|
||||||
yearly (Id , bucket , name , low , high , mean ) AS
|
yearly (Id , bucket , name , low , high , mean ) AS
|
||||||
( SELECT
|
( SELECT
|
||||||
Id ,
|
Id ,
|
||||||
timeBucket ,
|
timeBucket ,
|
||||||
" yearly " ,
|
" yearly " ,
|
||||||
min ( ClosePrice ) ,
|
min ( ClosePrice ) ,
|
||||||
max ( ClosePrice ) ,
|
max ( ClosePrice ) ,
|
||||||
avg ( ClosePrice )
|
avg ( ClosePrice )
|
||||||
FROM Target
|
FROM Target
|
||||||
GROUP BY Id , getYear ( TradeDate ) as
|
GROUP BY Id , getYear ( TradeDate ) as
|
||||||
timeBucket )
|
timeBucket )
|
||||||
SELECT
|
SELECT
|
||||||
Id , bucket , name , low , high , mean
|
Id , bucket , name , low , high , mean
|
||||||
FROM
|
FROM
|
||||||
CONCATENATE ( weekly , monthly , yearly )
|
CONCATENATE ( weekly , monthly , yearly )
|
||||||
ASSUMING ASC Id , ASC name , ASC bucket
|
ASSUMING ASC Id , ASC name , ASC bucket
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
AGGREGATION FUNCTION covariances(x, y, w){
|
AGGREGATION FUNCTION covariances(x, y, w){
|
||||||
static xmeans := 0., ymeans := 0., cnt := 0;
|
static xmeans := 0., ymeans := 0., cnt := 0;
|
||||||
if (cnt < w)
|
if (cnt < w)
|
||||||
{
|
{
|
||||||
xmeans += x;
|
xmeans += x;
|
||||||
ymeans += y;
|
ymeans += y;
|
||||||
cnt+=1;
|
cnt+=1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xmeans += (x - x.vec[cnt - w]) / w;
|
xmeans += (x - x.vec[cnt - w]) / w;
|
||||||
ymeans += (y - y.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 ))
|
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){
|
AGGREGATION FUNCTION covariances2(x, y, win){
|
||||||
xmeans := 0.;
|
xmeans := 0.;
|
||||||
ymeans := 0.;
|
ymeans := 0.;
|
||||||
l := _builtin_len;
|
l := _builtin_len;
|
||||||
|
|
||||||
if (l > 0)
|
if (l > 0)
|
||||||
{
|
{
|
||||||
xmeans := x[0];
|
xmeans := x[0];
|
||||||
ymeans := y[0];
|
ymeans := y[0];
|
||||||
_builtin_ret[0] := 0.;
|
_builtin_ret[0] := 0.;
|
||||||
}
|
}
|
||||||
w := win;
|
w := win;
|
||||||
if (w > l)
|
if (w > l)
|
||||||
w := l;
|
w := l;
|
||||||
for (i := 1, j:= 0; i < w; i := i+1) {
|
for (i := 1, j:= 0; i < w; i := i+1) {
|
||||||
xmeans += x[i];
|
xmeans += x[i];
|
||||||
ymeans += y[i];
|
ymeans += y[i];
|
||||||
_builtin_ret[i] := avg (( x(0, i) - xmeans/i ) * (y(0, i) - ymeans/i ));
|
_builtin_ret[i] := avg (( x(0, i) - xmeans/i ) * (y(0, i) - ymeans/i ));
|
||||||
}
|
}
|
||||||
xmeans /= w;
|
xmeans /= w;
|
||||||
ymeans /= w;
|
ymeans /= w;
|
||||||
for (i := w; i < l; i += 1)
|
for (i := w; i < l; i += 1)
|
||||||
{
|
{
|
||||||
xmeans += (x[i] - x[i - w]) / w;
|
xmeans += (x[i] - x[i - w]) / w;
|
||||||
ymeans += (y[i] - y[i - w]) / w;
|
ymeans += (y[i] - y[i - w]) / w;
|
||||||
_builtin_ret[i] := avg (( x(i-w, i) - xmeans ) * (y(i - w, i) - ymeans ));
|
_builtin_ret[i] := avg (( x(i-w, i) - xmeans ) * (y(i - w, i) - ymeans ));
|
||||||
}
|
}
|
||||||
Null
|
Null
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE TABLE test(a INT, b INT, c INT, d INT)
|
CREATE TABLE test(a INT, b INT, c INT, d INT)
|
||||||
|
|
||||||
LOAD DATA INFILE "data/test2.csv"
|
LOAD DATA INFILE "data/test2.csv"
|
||||||
INTO TABLE test
|
INTO TABLE test
|
||||||
FIELDS TERMINATED BY ","
|
FIELDS TERMINATED BY ","
|
||||||
|
|
||||||
select covariances2(a, b, 4), a+b from test group by c;
|
select covariances2(a, b, 4), a+b from test group by c;
|
||||||
|
|
||||||
|
Loading…
Reference in new issue