Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Full-text Search support #407

Merged
merged 5 commits into from
Jan 11, 2021
Merged

Add Full-text Search support #407

merged 5 commits into from
Jan 11, 2021

Conversation

jiechic
Copy link
Contributor

@jiechic jiechic commented Oct 15, 2020

Add Fts3 & Fts4 support

@codecov
Copy link

codecov bot commented Oct 15, 2020

Codecov Report

Merging #407 (6f38765) into develop (cfc9e5b) will increase coverage by 0.22%.
The diff coverage is 89.28%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #407      +/-   ##
===========================================
+ Coverage    83.40%   83.63%   +0.22%     
===========================================
  Files           68       69       +1     
  Lines         1687     1741      +54     
===========================================
+ Hits          1407     1456      +49     
- Misses         280      285       +5     
Flag Coverage Δ
floor 83.63% <89.28%> (+0.22%) ⬆️
floor_generator 83.56% <89.28%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
floor_generator/lib/value_object/entity.dart 95.65% <85.71%> (+0.53%) ⬆️
floor_generator/lib/value_object/fts.dart 88.00% <88.00%> (ø)
...loor_generator/lib/processor/entity_processor.dart 82.20% <91.66%> (+1.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfc9e5b...6f38765. Read the comment docs.

@jiechic jiechic force-pushed the develop branch 2 times, most recently from b608074 to d541aad Compare October 15, 2020 06:14
@jiechic
Copy link
Contributor Author

jiechic commented Oct 15, 2020

resolve issue #397

@vitusortner vitusortner linked an issue Oct 15, 2020 that may be closed by this pull request
@vitusortner
Copy link
Collaborator

Thanks for your contribution 🙏 I'll look into reviewing it ASAP.

@vitusortner vitusortner self-requested a review October 15, 2020 19:34
@jiechic jiechic force-pushed the develop branch 3 times, most recently from 4aeea98 to b210d2e Compare October 21, 2020 05:43
} else {
final ftsType = fts.type ?? '';
final ftsTokenizer = fts.tokenizer ?? '';
return 'CREATE VIRTUAL TABLE IF NOT EXISTS `$name` USING $ftsType(${databaseDefinition.join(', ')}, tokenize=$ftsTokenizer)$withoutRowidClause';
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ Does FTS work without a rowid?

Suggested change
return 'CREATE VIRTUAL TABLE IF NOT EXISTS `$name` USING $ftsType(${databaseDefinition.join(', ')}, tokenize=$ftsTokenizer)$withoutRowidClause';
return 'CREATE VIRTUAL TABLE IF NOT EXISTS `$name` USING $ftsType(${databaseDefinition.join(', ')}, tokenize=$ftsTokenizer)';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ths,next commit will change

@@ -0,0 +1,34 @@
class Fts {
Copy link
Collaborator

Choose a reason for hiding this comment

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

💡 FTS4 has some additional features that FTS3 doesn't support. Such as setting an external content table to be used by the FTS table. It might make sense to create two separate types: FTS3 and FTS4 as it's done in Room (see links below). We don't have to support all of these additional features initially but having two classes might allow us to be more flexible in the future.
Having two FTS classes also requires some changes to Entity because it would either need to understand both the FTS3 and FTS4types or we list FTS out of the Entity annotation as done in Room. What are your thoughts about this?

https://developer.android.com/reference/androidx/room/Fts3
https://developer.android.com/reference/androidx/room/Fts4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at last time ,i didn't known how to get a new annotation on classElement
i change to code like room now

Comment on lines 15 to 103
abstract class FtsType {
///FTS3 table in the database
static const fts3 = 'fts3';

///FTS4 table in the database
static const fts4 = 'fts4';
}

abstract class FtsTokenizer {
///The name of the default

///The name of the default tokenizer used on FTS tables
static const simple = 'simple';

///The name of the tokenizer based on the Porter Stemming Algorithm
static const porter = 'porter';

///The name of a tokenizer implemented by the ICU library.
static const icu = 'icu';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes,i will fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After thinking about it, I decided string instead of strings enum,
I don’t know if you will open the bottom-level implementation of database similar to room in the future,like this:
Room.databaseBuilder(...) .openHelperFactory(factory) .build();
in other openHelperFactory may be use custom tokenizer (in android room use wcdb factory can use mmicu tokenizer)

So I decided to use strings to give users better input and provide candidates on ftsTokenizer

example/lib/database.dart Outdated Show resolved Hide resolved
floor_annotation/pubspec.lock Outdated Show resolved Hide resolved
@jiechic
Copy link
Contributor Author

jiechic commented Nov 23, 2020

why ci/floor-generator fail false but my local is success
image

@jiechic jiechic force-pushed the develop branch 6 times, most recently from 42a7aa7 to 9640a8f Compare November 24, 2020 07:35
@jiechic
Copy link
Contributor Author

jiechic commented Nov 24, 2020

i change commit for fix for support some you sugguest,now is ok?

@jiechic jiechic requested a review from vitusortner November 25, 2020 06:37
@jiechic
Copy link
Contributor Author

jiechic commented Dec 31, 2020

any update for review?

Copy link
Collaborator

@vitusortner vitusortner left a comment

Choose a reason for hiding this comment

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

I was only able to partly review the PR for now. I'll review the rest ASAP.

floor_generator/test/value_object/fts_test.dart Outdated Show resolved Hide resolved
floor_generator/lib/misc/fts_action.dart Outdated Show resolved Hide resolved
@jiechic
Copy link
Contributor Author

jiechic commented Dec 31, 2020

alread check and fix,please review again

@jiechic
Copy link
Contributor Author

jiechic commented Jan 5, 2021

any update for review again?

Copy link
Collaborator

@vitusortner vitusortner left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply and thanks for your contribution. This is looking really good. I'll extend the project's documentation so that your contribution is easily discoverable.

@vitusortner vitusortner merged commit 362625d into pinchbv:develop Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Which version is planned to support fts
2 participants