Cleanup: Removed a lot of deprecated methods
diff --git a/lib/Krawfish/Index.pm b/lib/Krawfish/Index.pm
index 0ac5de3..e2c3c0e 100644
--- a/lib/Krawfish/Index.pm
+++ b/lib/Krawfish/Index.pm
@@ -88,11 +88,12 @@
$self->{file}
);
- $self->{segments} = [];
-
- $self->{dyn_segment} = Krawfish::Index::Segment->new(
- $self->{file}
- );
+ # The first segment in the list of segments is always the dynamic one
+ $self->{segments} = [
+ Krawfish::Index::Segment->new(
+ $self->{file}
+ )
+ ];
return $self;
};
@@ -106,7 +107,7 @@
# Get the dynamic segment
sub segment {
- $_[0]->{dyn_segment};
+ $_[0]->{segments}->[0];
};
diff --git a/lib/Krawfish/Index/Dynamic.pm b/lib/Krawfish/Index/Dynamic.pm
deleted file mode 100644
index 73aeeeb..0000000
--- a/lib/Krawfish/Index/Dynamic.pm
+++ /dev/null
@@ -1,24 +0,0 @@
-package Krawfish::Index::Dynamic;
-use parent 'Krawfish::Index';
-
-warn 'THIS IS DEPRECATED';
-
-# The dynamic index segment can easily
-# add new documents.
-# It will use the global dictionary and for
-# new terms it adds them to a secondary
-# dictionary.
-
-# TODO:
-# This needs to have a different ranking
-# strategy.
-
-sub add;
-
-sub dynamic_dict;
-
-sub is_dynamic { 1 };
-
-sub is_static { 0 };
-
-1;
diff --git a/lib/Krawfish/Index/Fields.pm b/lib/Krawfish/Index/Fields.pm
index b1e5991..8aeac32 100644
--- a/lib/Krawfish/Index/Fields.pm
+++ b/lib/Krawfish/Index/Fields.pm
@@ -50,6 +50,7 @@
}, $class;
};
+
# Get last document identifier aka max_doc_id
sub last_doc_id {
$_[0]->{last_doc_id};
@@ -67,6 +68,7 @@
return $doc_id;
};
+
# Get doc from list (as long as the list provides random access to docs
sub doc {
my ($self, $doc_id) = @_;
@@ -82,10 +84,6 @@
};
-sub store {
- # DEPRECATED!
-};
-
# TODO:
# Unused yet!
@@ -127,7 +125,6 @@
};
-
1;
diff --git a/lib/Krawfish/Index/PostingsList.pm b/lib/Krawfish/Index/PostingsList.pm
index 0e0f0d2..d21b01d 100644
--- a/lib/Krawfish/Index/PostingsList.pm
+++ b/lib/Krawfish/Index/PostingsList.pm
@@ -16,9 +16,9 @@
# TODO: Return K::P::Data for at()
sub new {
- my ($class, $index_file, $term, $term_id) = @_;
+ my ($class, $index_file, $term_id) = @_;
+
bless {
- term => $term, ### Term is irrelevant now!
term_id => $term_id,
index_file => $index_file,
array => [],
@@ -48,9 +48,6 @@
return scalar @{$_[0]->{array}};
};
-sub term {
- return $_[0]->{term} // 'unknown';
-};
sub term_id {
return $_[0]->{term_id};
diff --git a/lib/Krawfish/Index/Segment.pm b/lib/Krawfish/Index/Segment.pm
index b4ce817..d3d431f 100644
--- a/lib/Krawfish/Index/Segment.pm
+++ b/lib/Krawfish/Index/Segment.pm
@@ -43,18 +43,11 @@
print_log('seg', 'Instantiate new segment') if DEBUG;
- # Load offsets
+ # Load subtokens list
$self->{subtokens} = Krawfish::Index::Subtokens->new(
$self->{file}
);
- # Load primary
- # TODO:
- # DEPRECATED!
- $self->{primary} = Krawfish::Index::PrimaryData->new(
- $self->{file}
- );
-
# Load fields
$self->{fields} = Krawfish::Index::Fields->new(
$self->{file}
@@ -76,9 +69,6 @@
# Collect fields to sort
$self->{sortable} = {};
- # Collect values to sum
- $self->{summable} = {};
-
# Add cache
$self->{cache} = Krawfish::Cache->new;
@@ -119,56 +109,49 @@
};
-# Get primary
-sub primary {
- warn 'DEPRECATED';
- $_[0]->{primary};
-};
-
-
-# Get fields
+# Get fields index
sub fields {
$_[0]->{fields};
};
-# Get field values for addition
-sub field_values {
- warn 'DEPRECATED';
- $_[0]->{field_values};
+# Get forward index
+sub forward {
+ $_[0]->{forward};
};
-# Return a postings list
-# based on a term_id
+# Return a postings list based on a term_id
sub postings {
my ($self, $term_id) = @_;
+ # TODO:
+ # There may already be a prepared pool of postingslist
+ # based on the numerically sorted term ids
+
$self->{$term_id} //= Krawfish::Index::PostingsList->new(
- 'unknown', 'unknown', $term_id
+ $self->{file}, $term_id
);
return $self->{$term_id};
};
-sub forward {
- $_[0]->{forward};
-};
-
-
-# This will make add() in Krawfish::Index obsolete
+# Add a prepared document to the index
sub add {
my ($self, $doc) = @_;
# TODO:
+ # This may use a prepared pool of PostingsLists
+ # that are lifted before - for term_ids in numerical order
+
+ # TODO:
# Alternatively get this from the forward index
# Get new doc_id for the segment
my $doc_id = $self->live->incr;
# TODO:
# The document should already have a field with __1:1 and id!
-
my $doc_id_2 = $self->fields->add($doc);
# TODO:
@@ -193,6 +176,7 @@
$self->postings($_->term_id)->append($doc_id);
};
+
# TODO:
# This should probably collect all [term_id => data] in advanced,
# so skiplist info, freq_in_doc etc. can be adjusted in advance
diff --git a/lib/Krawfish/Koral.pm b/lib/Krawfish/Koral.pm
index 4e26f61..8889cef 100644
--- a/lib/Krawfish/Koral.pm
+++ b/lib/Krawfish/Koral.pm
@@ -360,33 +360,7 @@
# Get KoralQuery with results
-sub to_result {
- my ($self, $index) = @_;
-
- warn 'THIS HAS TO BE DONE DIFFERENTLY';
-
- # Get KoralQuery object
- my $koral = $self->to_koral_query;
-
- # Prepare query
- my $query = $self->prepare_for($index);
-
- # TODO:
- # This is only for matches - not for groups
- while ($query->next) {
-
- # Add matches to koral
- $koral->add_match(
-
- # Get current match
- $query->current_match
- )
- };
-
- # Get result hash (e.g. totalResults)
- $koral->{result} = $query->result;
-};
-
+sub to_result;
# TODO:
@@ -409,80 +383,6 @@
};
-# Prepare the query for index
-sub prepare_for {
- my ($self, $index) = @_;
-
- warn 'DEPRECATED';
-
- my $query;
-
- # Corpus and query are given - filter!
- if ($self->query && $self->corpus) {
-
- my $corpus = $self->corpus;
-
- # Meta is defined
- if ($self->meta) {
-
- # Wrap in sort filter if available
- $corpus = $self->meta->sort_filter($corpus);
- };
-
- # Add corpus filter
- $query = $self->query_builder->filter_by($self->query, $self->corpus);
- }
-
- # Only corpus is given
- elsif ($self->corpus) {
- $query = $self->corpus;
-
- # Wrap in sort filter if available
- $query = $self->meta->sort_filter($query, $index) if $self->meta;
- }
-
- # Only query is given
- elsif ($self->query) {
- $query = $self->query;
-
- # TODO:
- # Somehow do sort_filtering here with a corpus based
- # on non-deleted documents or so.
- };
-
- # If meta is defined, prepare results
- $query = $self->meta->search_for($query) if $self->meta;
-
- # TODO:
- # The following operations will invalidate sort filtering:
- # - grouping
- # - aggregate (except result is already cached)
-
- # TODO:
- # if ($self->sorting && $self->sorting->filter) {
- # # Filter matches using a sort filter
- # $query = $self->query->filter_by($self->sorting->filter);
- # };
-
- # TODO:
- # - Find identical subqueries
- # - This is especially useful for VC filtering,
- # - Terms (PostingsList) will automatically avoid
- # lifting posting lists multiple times.
- #
- # That means: create a buffered version of $self->corpus
- #
- # TODO: Make this part of ->plan_for($index, $refs)
- #
- # $query->replace_references;
-
-
- # Prepare query
- $query = $query->prepare_for($index);
- # $query = $query->normalize->finalize->inflate($index->dict)->optimize($index);
-
- return $query;
-};
# Find identical subqueries and replace outer queries with
@@ -524,68 +424,8 @@
return join(',', @list);
};
+
1;
+
__END__
-
-
-
-sub sorting {
- ...
-};
-
-
-# Normalize object
-sub normalize {
- my $self = shift;
-
- my $query;
-
- # Corpus and query are given - filter!
- if ($self->query && $self->corpus) {
-
- my $corpus = $self->corpus;
-
- # Add corpus filter
- $query = $self->query_builder->filter_by($self->query, $self->corpus);
-
- # Meta is defined
- if ($self->meta) {
-
- # TODO: Make this a filter query!
-
- # Wrap in sort filter if available
- $corpus = $self->meta->sort_filter($corpus);
- };
- }
-
- # Only corpus is given
- elsif ($self->corpus) {
- $query = $self->corpus;
-
- # Wrap in sort filter if available
-
- # TODO:
- # $query = $self->meta->sort_filter($query, $index) if $self->meta;
- }
-
- # Only query is given
- elsif ($self->query) {
-
- # Add corpus filter for live documents
- $query = $self->query_builder->filter_by(
- $self->query,
- $self->corpus_builder->any
- );
- };
-
-
- # If meta is defined, prepare results
- if ($self->meta) {
- $query = $self->meta->search_for($query);
- };
-
-
- # Prepare query
- return $query->normalize;
-};
diff --git a/lib/Krawfish/Koral/Corpus.pm b/lib/Krawfish/Koral/Corpus.pm
index 776d62c..22d0ecc 100644
--- a/lib/Krawfish/Koral/Corpus.pm
+++ b/lib/Krawfish/Koral/Corpus.pm
@@ -25,17 +25,6 @@
# Query Planning methods and attributes #
#########################################
-sub plan_for_new {
- my ($self, $index) = @_;
- $self
- ->normalize
- ->finalize
- ->refer
- ->inflate($index)
- ->cache
- ->optimize($index);
-};
-
# Normalize the query
sub normalize {
@@ -126,20 +115,6 @@
};
-# Expand regular expressions
-sub inflate {
- my ($self, $dict) = @_;
-
- warn 'DEPRECATED - use identify';
-
- my $ops = $self->operands;
- return $self unless $ops;
- for (my $i = 0; $i < @$ops; $i++) {
- $ops->[$i] = $ops->[$i]->inflate($dict);
- };
- return $self;
-};
-
# TODO:
# If "nothing" returns, optimize away
diff --git a/lib/Krawfish/Koral/Corpus/Field.pm b/lib/Krawfish/Koral/Corpus/Field.pm
index af3de8b..a027b4f 100644
--- a/lib/Krawfish/Koral/Corpus/Field.pm
+++ b/lib/Krawfish/Koral/Corpus/Field.pm
@@ -111,20 +111,11 @@
sub can_toggle_negativity;
-sub inflate {
- # Inflate for RegEx and existence!
- warn 'Inflation on fields not yet implemented';
- return $_[0];
-};
-
-# This is alternative to inflate
+# Translate all terms to term ids
sub identify {
my ($self, $dict) = @_;
- # Do not inflate
- # TODO:
- # But identify!!!
unless ($self->is_regex) {
my $term = $self->to_term;
diff --git a/lib/Krawfish/Koral/Meta.pm b/lib/Krawfish/Koral/Meta.pm
index 9dbc34b..bbc7cc1 100644
--- a/lib/Krawfish/Koral/Meta.pm
+++ b/lib/Krawfish/Koral/Meta.pm
@@ -16,8 +16,6 @@
our %META_ORDER = (
- # snippet => 1,
- # fields => 2,
limit => 1,
sort => 2,
enrich => 3,
@@ -237,221 +235,8 @@
...
};
-1;
-
-
-__END__
-
-
-sub items_per_page {
- my $self = shift;
- return $self->{items_per_page} unless @_;
- $self->{items_per_page} = shift;
- return $self;
-};
-
-
-sub start_index {
- my $self = shift;
- return $self->{start_index} unless @_;
- $self->{start_index} = shift;
- return $self;
-};
-
-
-sub facets {
- my $self = shift;
- return $self->{facets} unless @_;
- $self->{facets} = [@_];
- return $self;
-};
-
-
-# Count doc_freq and freq
-sub count {
- my $self = shift;
- return $self->{count} unless @_;
- $self->{count} = shift;
- return $self;
-};
-
-
-# Get lengths of results
-sub length {
- my $self = shift;
- return $self->{length} unless @_;
- $self->{length} = shift;
- return $self;
-};
-
-
-sub prepare_for {
- shift->plan_for(@_);
-};
-
-
-# Check if the meta query is filterable
-sub sort_filter {
- my ($self, $query, $index) = @_;
-
- # No sort defined
- return $query unless $self->{field_sort};
-
- # Sort is not restricted
- return $query unless $self->{items_per_page};
-
- # Filtering not applicable because
- # all matches need to be found
- if ($self->{facets} ||
- $self->{field_count} ||
- $self->{count} ||
- $self->{length}) {
- return $query;
- };
-
- # Get first run field
- my ($field, $desc) = @{$self->{field_sort}->[0]};
-
- # Create rank filter
- $query = Krawfish::Result::Sort::Filter->new(
- query => $query,
- max_rank_ref => $self->max_doc_rank_ref,
- field => $field,
- desc => $desc,
- index => $index
- );
-
- print_log('kq_meta', 'Query is qualified for sort filtering') if DEBUG;
-
- return $query;
-};
-
-
-# Return max_doc_rank reference
-sub max_doc_rank_ref {
- my $self = shift;
-
- # Set value to reference
- ${$self->{max_doc_rank_ref}} = shift if @_;
-
- return $self->{max_doc_rank_ref};
-};
-
-
-sub plan_for {
- my ($self, $index) = @_;
-
- # Get the query
- my $query = $self->{query} or return;
-
-
- # TODO:
- # The dictionary should also have a max_rank!
-
-
- # Get the maximum rank for fields, aka the document number
- # and init the shared value for faster filtering
- my $max_doc_rank_ref = $self->max_doc_rank_ref($index->max_rank);
-
- # Prepare the nested query
- $query = $query->prepare_for($index);
-
- my @aggr;
- # Add facets to the result
- if ($self->{facets}) {
-
- # This should have more parameters, like count
- foreach (@{$self->{facets}}) {
- push @aggr, Krawfish::Result::Segment::Aggregate::Facets->new($index, $_);
- };
- };
-
- # Count field values
- if ($self->{field_count}) {
-
- # This should have more parameters, like count
- foreach (@{$self->{field_count}}) {
- push @aggr, Krawfish::Result::Segment::Aggregate::Values->new($index, $_);
- };
- };
-
- # Add frequency and document frequency count to result
- # TODO:
- # This may be obsolete in some cases, because other aggregations already
- # count frequencies.
- if ($self->{count}) {
- push @aggr, Krawfish::Result::Segment::Aggregate::Frequencies->new;
- };
-
- if ($self->{length}) {
- push @aggr, Krawfish::Result::Segment::Aggregate::Length->new;
- };
-
- # Augment the query with aggregations
- # TODO:
- # It may be better to have one aggregation object, that can be filled!
- # like ->query($query)->aggregate_on($aggr)->prepare_for($index);
- # and after the query is through, the aggregation map contains data
- if (@aggr) {
- $query = Krawfish::Result::Segment::Aggregate->new($query, \@aggr);
- };
-
- # Sort the result
- # This is mandatory!
-
- # Precalculate top_k value
- my $top_k = undef;
- if ($self->items_per_page) {
-
- # Top k is defined
- $top_k = $self->items_per_page + ($self->start_index // 0);
- };
-
- # TODO:
- # Check for fields that are either not part
- # of the index or are identified in
- # the corpus query (it makes no sense to
- # sort for author, if author=Fontane is
- # required)
- $query = Krawfish::Result::Sort::PriorityCascade->new(
- query => $query,
- index => $index,
- fields => $self->{field_sort},
- unique => UNIQUE_FIELD,
- top_k => $top_k,
- max_rank_ref => $max_doc_rank_ref
- );
-
- print_log('kq_meta', "Field sort with: " . $query->to_string) if DEBUG;
-
-
- # Limit the result
- if ($self->items_per_page || $self->start_index) {
- $query = Krawfish::Result::Limit->new(
- $query,
- $self->start_index,
- $self->items_per_page
- );
- };
-
- # The order needs to be:
- # snippet(
- # fields(
- # limit( -
- # sorted( -
- # faceted( -
- # count(Q) -
- # )
- # )
- # )
- # )
- # )
-
- # Return the query
- return $query;
-};
-
1;
+
__END__
diff --git a/lib/Krawfish/Koral/Meta/Enrich.pm b/lib/Krawfish/Koral/Meta/Enrich.pm
index d4b54c4..713c222 100644
--- a/lib/Krawfish/Koral/Meta/Enrich.pm
+++ b/lib/Krawfish/Koral/Meta/Enrich.pm
@@ -1,5 +1,4 @@
package Krawfish::Koral::Meta::Enrich;
-use Krawfish::Koral::Meta::Node::Enrich;
use Krawfish::Log;
use strict;
use warnings;
diff --git a/lib/Krawfish/Koral/Meta/Node/Aggregate/Length.pm b/lib/Krawfish/Koral/Meta/Node/Aggregate/Length.pm
deleted file mode 100644
index ca93b06..0000000
--- a/lib/Krawfish/Koral/Meta/Node/Aggregate/Length.pm
+++ /dev/null
@@ -1,53 +0,0 @@
-package Krawfish::Koral::Meta::Node::Aggregate::Length;
-use Krawfish::Result::Segment::Aggregate::Length;
-#use Krawfish::Util::String qw/squote/;
-use Krawfish::Query::Nothing;
-use strict;
-use warnings;
-
-
-warn 'DEPRECATED';
-
-# Create new enrichment object for fields
-sub new {
- my $class = shift;
- my $self = '';
- bless \$self, $class;
-};
-
-
-sub to_string {
- 'length';
-};
-
-
-# This will identify the query and create a list of sorted fields ids
-sub identify {
-
- warn 'DEPRECATED';
-
- my ($self, $dict) = @_;
-
- $self->{query} = $self->{query}->identify($dict);
-
- return $self;
-};
-
-
-# Materialize query for segment search
-sub optimize {
- my ($self, $segment) = @_;
-
- my $query = $self->{query}->optimize($segment);
-
- if ($query->max_freq == 0) {
- return Krawfish::Query::Nothing->new;
- };
-
- return Krawfish::Result::Segment::Aggregate::Length->new(
- $segment,
- $query
- );
-};
-
-1;
diff --git a/lib/Krawfish/Koral/Meta/Node/Enrich.pm b/lib/Krawfish/Koral/Meta/Node/Enrich.pm
deleted file mode 100644
index 6662f4a..0000000
--- a/lib/Krawfish/Koral/Meta/Node/Enrich.pm
+++ /dev/null
@@ -1,60 +0,0 @@
-package Krawfish::Koral::Meta::Node::Enrich;
-use Krawfish::Log;
-use strict;
-use warnings;
-
-use constant DEBUG => 1;
-
-sub new {
- my $class = shift;
-
- warn 'DEPRECATED';
-
- my $self = bless {
- query => shift,
- enrichments => shift
- }, $class;
-};
-
-
-
-# Get identifiers
-sub identify {
- my ($self, $dict) = @_;
-
- warn 'DEPRECATED';
-
-
- my @identifier;
- foreach (@{$self->{enrichments}}) {
- my $enrich = $_->identify($dict);
-
- if ($enrich) {
- push @identifier, $enrich;
- };
- };
-
- $self->{query} = $self->{query}->identify($dict);
-
- return $self->{query} if @identifier == 0;
-
- $self->{enrichments} = \@identifier;
-
- return $self;
-
-};
-
-
-sub to_string {
- my $self = shift;
-
- warn 'DEPRECATED';
-
- return 'enrich(' .
- join(',', map { $_->to_string } @{$self->{enrichments}}) .
- ':' . $self->{query}->to_string . ')';
-};
-
-
-
-1;
diff --git a/lib/Krawfish/Koral/Meta/Sort.pm b/lib/Krawfish/Koral/Meta/Sort.pm
index d626b54..f4da685 100644
--- a/lib/Krawfish/Koral/Meta/Sort.pm
+++ b/lib/Krawfish/Koral/Meta/Sort.pm
@@ -99,15 +99,6 @@
};
-# TODO:
-# REMOVE!
-sub to_nodes {
- my ($self, $query) = @_;
- warn 'DEPRECATED';
- return Krawfish::Result::Node::Sort->new($query, [$self->operations]);
-};
-
-
sub wrap {
my ($self, $query) = @_;
return Krawfish::Koral::Meta::Node::Sort->new(
@@ -118,6 +109,7 @@
);
};
+
sub to_string {
my $self = shift;
my $str = join(',', map { $_->to_string } @{$self->{sort}});
@@ -159,11 +151,6 @@
$self->{top_k} = shift;
};
-# Order sort
-sub plan_for {
- my ($self, $index, $query) = @_;
- ...
-};
sub type { 'sort' };
@@ -189,72 +176,3 @@
__END__
-
-# Sorting can be optimized by an appended filter, in case there is no need
-# for counting all matches and documents.
-#
-# This can be added to the query using
-# ->filter_by($sort->filter)
-sub filter {
- my $self = @_;
-
- # The filter should be disabled, because all matches need to be counted!
- if (defined $_[0]) {
- $self->{filterable} = shift;
- return;
- };
-
- # Filter is disabled
- return unless $self->{filterable};
-
- # return Krawfish::Result::Sort::Filter->new(
- # $self->{corpus}
- # );
- ...
-};
-
-
-sub plan_for {
- my ($self, $index) = @_;
-
- my $field = shift @{$self->{fields}};
-
- # TODO: Sorting should simply use
- # Krawfish::Result::Sort and the passes
- # should be handled there!
-
- # Initially sort using bucket sort
- $query = Krawfish::Result::Sort::FirstPass->new(
- $self->{query},
- ($field->[0] eq 'desc' ? 1 : 0),
- $field->[1]
- );
-
- # Iterate over all fields
- foreach $field (@{$self->{fields}}) {
- $query = Krawfish::Result::Sort::Rank->new(
- $query,
- ($field->[0] eq 'desc' ? 1 : 0),
- $field->[1]
- );
- };
-
- # Final sorting based on UID
- return Krawfish::Result::Sort->new($query, 0, 'uid');
-};
-
-
-sub type { 'sort' };
-
-
-sub to_koral_fragment {
- ...
-};
-
-
-sub to_string {
- ...
-};
-
-
-1;
diff --git a/lib/Krawfish/Koral/Query.pm b/lib/Krawfish/Koral/Query.pm
index 038f91b..9293f6a 100644
--- a/lib/Krawfish/Koral/Query.pm
+++ b/lib/Krawfish/Koral/Query.pm
@@ -50,17 +50,6 @@
# Query Planning methods and attributes #
#########################################
-sub plan_for_new {
- my ($self, $index) = @_;
- $self
- ->normalize
- ->finalize
- ->refer
- ->inflate($index->dict)
- ->cache
- ->optimize($index);
-};
-
# Normalize the query
sub normalize;
@@ -72,20 +61,6 @@
};
-# Expand regular expressions
-sub inflate {
- my ($self, $dict) = @_;
-
- warn 'Inflate is deprecated - use ->identify()';
-
- my $ops = $self->operands;
- return $self unless $ops;
- for (my $i = 0; $i < @$ops; $i++) {
- $ops->[$i] = $ops->[$i]->inflate($dict);
- };
- return $self;
-};
-
# TODO:
# If "nothing" returns, optimize away
diff --git a/lib/Krawfish/Koral/Query/Constraints.pm b/lib/Krawfish/Koral/Query/Constraints.pm
index ba81984..c25ac9a 100644
--- a/lib/Krawfish/Koral/Query/Constraints.pm
+++ b/lib/Krawfish/Koral/Query/Constraints.pm
@@ -304,36 +304,6 @@
# Inflate operands and constraints
-sub inflate {
- my ($self, $dict) = @_;
-
- warn 'DEPRECATED in favor of identify!';
-
- my $ops = $self->operands;
-
- # Inflate on all operands
- my $i = 0;
- for (; $i < @$ops; $i++) {
- $ops->[$i] = $ops->[$i]->inflate($dict);
-
- if ($ops->[$i]->is_nothing) {
- # Return new nothing operand
- return Krawfish::Koral::Query::Nothing->new;
- };
- };
-
- my $cs = $self->constraints;
-
- # Inflate all constraints
- for ($i = 0; $i < @$cs; $i++) {
- $cs->[$i] = $cs->[$i]->inflate($dict);
- };
-
- return $self;
-};
-
-
-# Inflate operands and constraints
sub identify {
my ($self, $dict) = @_;
diff --git a/lib/Krawfish/Koral/Query/Span.pm b/lib/Krawfish/Koral/Query/Span.pm
index 6f1b23a..3e0e679 100644
--- a/lib/Krawfish/Koral/Query/Span.pm
+++ b/lib/Krawfish/Koral/Query/Span.pm
@@ -25,13 +25,16 @@
}, $class;
};
+
sub type { 'span' };
+
# There are no classes allowed in spans
sub remove_classes {
$_[0];
};
+
sub to_koral_fragment {
my $self = shift;
my $span = {
@@ -50,14 +53,6 @@
return $_[0];
};
-#sub inflate {
-# my ($self, $dict) = @_;
-
-# print_log('kq_span', 'Inflate span') if DEBUG;
-
-# $self->{operands}->[0] = $self->operand->inflate($dict);
-# return $self;
-#};
sub identify {
diff --git a/lib/Krawfish/Koral/Query/Term.pm b/lib/Krawfish/Koral/Query/Term.pm
index 74eb863..2643fb1 100644
--- a/lib/Krawfish/Koral/Query/Term.pm
+++ b/lib/Krawfish/Koral/Query/Term.pm
@@ -340,42 +340,10 @@
};
-sub inflate {
- my ($self, $dict) = @_;
-
- # Do not inflate
- return $self unless $self->is_regex;
-
- # Get terms
- my $term = $self->to_term_escaped;
-
- print_log('kq_term', 'Inflate /^' . $term . '$/') if DEBUG;
-
- # Get terms from dictionary
- my @terms = $dict->terms(qr/^$term$/);
-
- if (DEBUG) {
- print_log('kq_term', 'Expand /^' . $term . '$/');
- print_log('kq_term', 'to ' . (@terms > 0 ? substr(join(',', @terms), 0, 50) : '[0]'));
- };
-
- # Build empty term instead of nothing
- return $self->builder->nothing unless @terms;
-
- # TODO:
- # Use refer?
- return $self->builder->bool_or(@terms)->normalize;
-};
-
-
-
-# This is alternative to inflate
+# Translate all terms to term_ids
sub identify {
my ($self, $dict) = @_;
- # Do not inflate
- # TODO:
- # But identify!!!
unless ($self->is_regex) {
my $term = $self->to_term;
diff --git a/lib/Krawfish/Koral/Query/TermGroup.pm b/lib/Krawfish/Koral/Query/TermGroup.pm
index 79b40d8..0cfd419 100644
--- a/lib/Krawfish/Koral/Query/TermGroup.pm
+++ b/lib/Krawfish/Koral/Query/TermGroup.pm
@@ -12,7 +12,7 @@
# TODO:
# Preparation should be:
# -> normalize()
-# -> inflate()
+# -> identify()
# -> finalize()
# -> memoize(cache)
# -> optimize(index)
diff --git a/lib/Krawfish/Koral/Query/Token.pm b/lib/Krawfish/Koral/Query/Token.pm
index 428aa3a..7a8e898 100644
--- a/lib/Krawfish/Koral/Query/Token.pm
+++ b/lib/Krawfish/Koral/Query/Token.pm
@@ -105,13 +105,6 @@
};
-sub inflate {
- my ($self, $dict) = @_;
- print_log('kq_token', 'Inflate wrapper') if DEBUG;
- $self->operands([$self->operand->inflate($dict)]);
- return $self;
-};
-
sub finalize {
my $self = shift;
diff --git a/lib/Krawfish/Koral/Result.pm b/lib/Krawfish/Koral/Result.pm
index 631302e..dba4c2e 100644
--- a/lib/Krawfish/Koral/Result.pm
+++ b/lib/Krawfish/Koral/Result.pm
@@ -41,82 +41,3 @@
1;
__END__
-
-use Krawfish::Koral::Result::Group;
-
-
-sub new {
- my $class = shift;
- bless {
- query => shift,
- group_by => undef
- }, $class;
-};
-
-
-sub group_by {
- my ($self, $type, $param) = @_;
- $type = lc $type;
- if ($type eq 'fields') {
- $self->{group} = Krawfish::Koral::Result::Group->by_fields(@$param);
- };
- return $self;
-};
-
-
-# Prepare for index
-sub prepare_for {
- my ($self, $index) = shift;
-
- my $koral_query;
-
- # TODO: Prepare corpus
- # TODO: Prepare query
-
- # Group was set
- if ($self->{group}) {
-
- my $criterion = $self->{group};
- $koral_query = Krawfish::Result::Group->new(
- $koral_query,
- $criterion,
- $index
- );
- };
-};
-
-sub add_match {
- my ($self, $posting, $index) = @_;
-
- my $match = Krawfish::Koral::Result::Match->new($posting);
-
- my $meta = $self->meta;
- if ($meta->fields) {
- $match->fields(
- $index->get_fields($posting->doc_id, $meta->fields)
- );
- };
-
- # Expand match to, e.g., <base/s=s>
- if ($meta->expansion) {
- my ($start, $end) = $index->get_context(
- $posting,
- $meta->expansion
- );
- };
-
- # Expand context to, e.g., <base/s=p>
- if ($meta->context) {
- my ($start) = $index->get_context();
- };
-
- if ($meta->snippet) {
- $self->get_snippet(
- posting => $posting,
- highlights => $meta->highlights,
- snippet_context => $meta->context,
- match_context => $meta->expansion,
- annotations => $match->annotations
- );
- };
-};