Skip to content

Low level API Take 2#2

Merged
kkharji merged 4 commits intomasterfrom
api
Dec 30, 2020
Merged

Low level API Take 2#2
kkharji merged 4 commits intomasterfrom
api

Conversation

@Conni2461
Copy link
Copy Markdown
Collaborator

No description provided.

@Conni2461 Conni2461 force-pushed the api branch 2 times, most recently from 699cf37 to 2da3789 Compare December 29, 2020 21:54
@Conni2461 Conni2461 force-pushed the api branch 2 times, most recently from b8f7a9b to fe773b1 Compare December 29, 2020 23:43
lua/sql/defs.lua Outdated
local M = {}

local clib = ffi.load('/usr/lib/libsqlite3.so')
local clib_path = vim.g.sql.clib_path or (function()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw shoudn't that be vim.g.sql_clib_path

Copy link
Copy Markdown
Owner

@kkharji kkharji Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think we need to have a configurable table so later we have room to add another optional configurations, think db url, auth ..

Thats might be a bad idea when there is multiple plugin in using sql.nvim. @Conni2461

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be good to use while loop here that iterate over a list, say possible_paths

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but how many possible paths are there. Its usually /usr/lib and /usr/lib64 is most just a symlink.
So for some older system it might be /usr/lib32 but then that would be symlinked to /usr/lib

Copy link
Copy Markdown
Owner

@kkharji kkharji Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its a handful but we can only know that with users testing it. Also, we can add a condition that say if no path is found, then just assume that the lib is linked statistically. And this we can do by passing through "sqlite3"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

@Conni2461 Conni2461 Dec 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But statically linked means for us. Statically linked against neovim :o
So what should i do? vim.g.sql. and vim.g.sql.clib_path or function
and we iterate over it later?

@kkharji kkharji merged commit 1990987 into master Dec 30, 2020
@kkharji kkharji deleted the api branch December 30, 2020 00:17
kkharji pushed a commit that referenced this pull request Jan 5, 2021
* origin/master:
  Low level API Take 2 (#2)
  Add ci tests (#3)
kkharji added a commit that referenced this pull request Sep 21, 2021
Before lazy was default and there was no way of changing that. I've
decided to make it optional because it seems that:

1. People expects sqlite {} or sqlite:extend {} to create all the
   defined table in advance.
2. Performance impact of initializing db object is only 1.0 slower in
   microseconds, so it seems to not be as important as I thought it
   would:

   ```lua
   -- test/lazy.lua
    Benchmark #1: 'Logical Component'
      Time(mean ± σ):     23.7 μs ±  18.7 μs
      Range(min … max):   17.4 μs … 102.3 μs  20 runs
    Benchmark #2: 'Full Initialization'
      Time(mean ± σ):     28.7 μs ±  12.9 μs
      Range(min … max):   24.1 μs …  83.1 μs  20 runs
    Summary
      'Logical Component' ran
      1.2 ± 1.1 times faster than 'Full Initialization'
   ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants