Skip to content

Commit

Permalink
schema: support vectorOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 14, 2014
1 parent fd63909 commit 2735180
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/droonga/catalog/schema.rb
Expand Up @@ -65,11 +65,12 @@ def flags
end

class Column
attr_reader :table, :name, :data, :index_options
attr_reader :table, :name, :data, :vector_options, :index_options
def initialize(table, name, data)
@table = table
@name = name
@data = data
@vector_options = ColumnVectorOptions.new(vector_options_data)
@index_options = ColumnIndexOptions.new(index_options_data)
end

Expand Down Expand Up @@ -97,7 +98,7 @@ def type_flag
end

def flags
[type_flag] + index_options.flags
[type_flag] + vector_options.flags + index_options.flags
end

def value_type
Expand Down Expand Up @@ -128,6 +129,10 @@ def to_column_create_body
end

private
def vector_options_data
@data["vectorOptions"] || {}
end

def index_options_data
@data["indexOptions"] || {}
end
Expand Down
11 changes: 11 additions & 0 deletions test/unit/catalog/test_schema.rb
Expand Up @@ -241,6 +241,17 @@ def test_type
flags(data))
end

def test_weight_options
data = {
"type" => "Vector",
"vectorOptions" => {
"weight" => true
}
}
assert_equal(["COLUMN_VECTOR", "WITH_WEIGHT"],
flags(data))
end

def test_index_options
data = {
"type" => "Index",
Expand Down

0 comments on commit 2735180

Please sign in to comment.