Skip to content

Conversation

@dungba88
Copy link
Owner

@dungba88 dungba88 commented Nov 22, 2023

Description

Make FSTCompiler.compile() to only return the FSTMetadata. Depending on whether the DataOutput used implements FSTReader or not, the returned FST might be unreadable. Thus having this method only return the FSTMetadata means we will never return an unusable FST.

The

Now to create the FST there will be 2 ways:

  1. If a FSTReader DataOutput is used, we can create the FST with:
var fstMetadata = fstCompiler.compile();
var fst = FST.fromFSTReader(fstMetadata, fstCompiler.getFSTReader());
  1. If a non-FSTReader DataOutput is used, we need to first create the corresponding DataInput, then call:
var fstMetadata = fstCompiler.compile();
if (fstMetadata == null) {
    return null; // FST is empty
}

// Create the DataInput
var dataInput = ...

var fst = new FST<>(fstMetadata, dataInput);

Note that this PR depends on 2 others to be merged first:

FST.fromFSTReader will also handle the case where fstMetadata is null, in which case it would return null. It is essentially a sugar syntactic utility to make the migration easier. So we will change this code:

var fst = fstCompiler.compile();

to this:

var fst = FST.fromFSTReader(fstCompiler.compile(), fstCompiler.getFSTReader());

instead of:

var fstMetadata = fstCompiler.compile();
if (fstMetadata == null) {
    return;
}
var fst = new FST<>(fstMetadata, fstCompiler.getFSTReader());

@dungba88 dungba88 changed the base branch from main to pr-12543 November 22, 2023 01:11
@dungba88 dungba88 force-pushed the compiler-metadata branch 2 times, most recently from 97f80c1 to 6e9915f Compare November 22, 2023 03:52
@dungba88 dungba88 changed the base branch from pr-12543 to pr-12543-1 November 22, 2023 04:02
@dungba88 dungba88 force-pushed the compiler-metadata branch 2 times, most recently from 4b54ba5 to ed265da Compare November 22, 2023 04:37
@dungba88 dungba88 changed the base branch from pr-12543-1 to main November 23, 2023 13:07
@dungba88 dungba88 changed the base branch from main to pr-12543 November 26, 2023 08:53
@dungba88 dungba88 force-pushed the compiler-metadata branch 3 times, most recently from 8ca0921 to 6418026 Compare December 8, 2023 04:21
@dungba88 dungba88 changed the base branch from pr-12543 to main December 11, 2023 14:16
@github-actions
Copy link

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Jan 11, 2024
@github-actions github-actions bot removed the Stale label Jan 16, 2024
@github-actions
Copy link

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants