| 1 | /* |
| 2 | Copyright (C) 2022 Sutou Kouhei <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn_progress.h" |
| 20 | |
| 21 | grn_progress_type |
| 22 | grn_progress_get_type(grn_ctx *ctx, grn_progress *progress) |
| 23 | { |
| 24 | return progress->type; |
| 25 | } |
| 26 | |
| 27 | grn_progress_index_phase |
| 28 | grn_progress_index_get_phase(grn_ctx *ctx, grn_progress *progress) |
| 29 | { |
| 30 | if (progress->type != GRN_PROGRESS_INDEX) { |
| 31 | return 0; |
| 32 | } |
| 33 | return progress->value.index.phase; |
| 34 | } |
| 35 | |
| 36 | uint32_t |
| 37 | grn_progress_index_get_n_target_records(grn_ctx *ctx, grn_progress *progress) |
| 38 | { |
| 39 | if (progress->type != GRN_PROGRESS_INDEX) { |
| 40 | return 0; |
| 41 | } |
| 42 | return progress->value.index.n_target_records; |
| 43 | } |
| 44 | |
| 45 | uint32_t |
| 46 | grn_progress_index_get_n_processed_records(grn_ctx *ctx, grn_progress *progress) |
| 47 | { |
| 48 | if (progress->type != GRN_PROGRESS_INDEX) { |
| 49 | return 0; |
| 50 | } |
| 51 | return progress->value.index.n_processed_records; |
| 52 | } |
| 53 | |
| 54 | uint32_t |
| 55 | grn_progress_index_get_n_target_terms(grn_ctx *ctx, grn_progress *progress) |
| 56 | { |
| 57 | if (progress->type != GRN_PROGRESS_INDEX) { |
| 58 | return 0; |
| 59 | } |
| 60 | return progress->value.index.n_target_terms; |
| 61 | } |
| 62 | |
| 63 | uint32_t |
| 64 | grn_progress_index_get_n_processed_terms(grn_ctx *ctx, grn_progress *progress) |
| 65 | { |
| 66 | if (progress->type != GRN_PROGRESS_INDEX) { |
| 67 | return 0; |
| 68 | } |
| 69 | return progress->value.index.n_processed_terms; |
| 70 | } |
| 71 | |
| 72 | uint32_t |
| 73 | grn_progress_language_model_inferencer_get_n_processed_records(grn_ctx *ctx, grn_progress *progress) |
| 74 | { |
| 75 | if (progress->type != GRN_PROGRESS_LANGUAGE_MODEL_INFERENCER) { |
| 76 | return 0; |
| 77 | } |
| 78 | return progress->value.language_model_inferencer.n_processed_records; |
| 79 | } |