Giter Site home page Giter Site logo

leowoerteler / basex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from basexdb/basex

1.0 1.0 0.0 107.06 MB

BaseX Main Repository.

Home Page: http://basex.org

License: BSD 3-Clause "New" or "Revised" License

Shell 0.05% ActionScript 0.13% C# 0.18% Makefile 0.02% C 0.23% Haskell 0.06% Java 95.14% Common Lisp 0.04% Perl 0.11% PHP 0.12% Python 0.20% QMake 0.01% C++ 0.11% Rebol 0.06% XQuery 2.97% Ruby 0.10% Scala 0.16% Visual Basic 0.16% JavaScript 0.11% CSS 0.05%

basex's People

Contributors

adrianber avatar amazingphil avatar andria009 avatar carlosmarcos avatar cfoster avatar charles-dyfis-net avatar christiangruen avatar cportele avatar daveaglick avatar davidmathei avatar dimitarp avatar dirkk avatar ferrarimartin avatar hhv avatar holu avatar jb8748 avatar jenserat avatar jonherrmann avatar kissdanigh avatar klavs avatar kristiank avatar leowoerteler avatar lukask avatar malamut2 avatar masoumeh avatar meersdavy avatar micheee avatar mingarao avatar siahr avatar vincentml avatar

Stargazers

 avatar

Watchers

 avatar

basex's Issues

Inline Function Calls

User-defined functions should be inlined where possible, eliminating the call overhead and enabling more optimizations.

Example:

declare function local:foo($x as xs:integer) as xs:integer {
  if($x lt 100) then $x
  else 100
};

2 * local:foo(21)

After inlining this would be

2 * (
  let $x as xs:integer := 21
  return
    if($x lt 100) then $x
    else 100
)

which BaseX can evaluate at compile-time:

Compiling:

  • binding static variable $x as xs:integer
  • pre-evaluating 21 lt 100
  • pre-evaluating if(true()) then $x else 100
  • removing variable $x as xs:integer
  • simplifying flwor expression
  • pre-evaluating 2 * 21

Result: 42

Preliminaries:

  • argument and result casts have to be explicit (working on it)
  • function body has to be copyable
  • one has to be careful while inlining recursive functions, otherwise the compiler might loop

Precompile Modules

  • related objective: cleaner separation of compiler steps
  • copy module (or called functions/variables/...?) before it is evaluated
  • implement compile() and optimize() in all expressions
  • recompile modules with changed timestamps
  • challenge: import of multiple library modules with identical namespaces

Implement XQuery Sequences as Finger Trees

Currently BaseX implements XQuery sequences as lightweight array lists, which is fast for simple use cases, but breaks down completely when sequences are used as immutable lists because of the copying overhead.

Example:

The standard XQuery function fn:map($f, $xs) applies the function $f so all elements of the sequence $xs, concatenating the results. Implementing it in XQuery is straight-forward:

declare function local:map(
  $f as function(item()) as item()*,
  $xs as item()* 
) as item()* {
  if(empty($xs)) then ()
  else (
    $f(fn:head($xs)),
    local:map($f, fn:tail($xs))
  )
};

Unfortunately the function performs very poorly, as the result sequence has to be copied in every recursive call, which leads to an O(nĀ²) runtime (with n being the length of the list).

Finger Trees

Finger trees are an immutable, purely functional data structure with properties nicely fitting this use case:

  • cons, reverse, tail: amortized O(1)
  • append and split: O(log n)

Even if should not be replaced by finger trees, an option to turn them on would be nice for idiomatic functional XQuery code.

Run-Time Optimizations

Keywords

  • Just-In-Time Compilation: rewriting repeatedly executed code
  • Alternative Evaluation Plans: chosen (or generated?) at runtime. Examples: sequential evaluation vs. index access, positional vs. existential predicate tests
  • Byte Code Generation: complete or partial byte code generation

Publications

This is a largely unreviewed list of papers revolving around XQuery and query optimizations. Some of them include compile-time optimizations:

Byte Code Generation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.