Navigation Menu

Skip to content

Commit

Permalink
schema: support column section/weight/position
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 20, 2015
1 parent 77da933 commit 1a896e3
Show file tree
Hide file tree
Showing 7 changed files with 317 additions and 5 deletions.
11 changes: 10 additions & 1 deletion lib/proc.c
Expand Up @@ -7894,7 +7894,7 @@ proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)

proc_schema_output_column_name(ctx, column);

GRN_OUTPUT_MAP_OPEN("column", 7);
GRN_OUTPUT_MAP_OPEN("column", 10);

GRN_OUTPUT_CSTR("name");
proc_schema_output_column_name(ctx, column);
Expand All @@ -7914,6 +7914,15 @@ proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
GRN_OUTPUT_CSTR("compress");
proc_schema_column_output_compress(ctx, column);

GRN_OUTPUT_CSTR("section");
GRN_OUTPUT_BOOL((column->header.flags & GRN_OBJ_WITH_SECTION) != 0);

GRN_OUTPUT_CSTR("weight");
GRN_OUTPUT_BOOL((column->header.flags & GRN_OBJ_WITH_WEIGHT) != 0);

GRN_OUTPUT_CSTR("position");
GRN_OUTPUT_BOOL((column->header.flags & GRN_OBJ_WITH_POSITION) != 0);

GRN_OUTPUT_MAP_CLOSE();
}

Expand Down
Expand Up @@ -199,7 +199,10 @@ schema
"name": "Text",
"type": "type"
},
"compress": "lz4"
"compress": "lz4",
"section": false,
"weight": false,
"position": false
}
}
}
Expand Down
Expand Up @@ -199,7 +199,10 @@ schema
"name": "Text",
"type": "type"
},
"compress": "zlib"
"compress": "zlib",
"section": false,
"weight": false,
"position": false
}
}
}
Expand Down
280 changes: 280 additions & 0 deletions test/command/suite/schema/tables/columns/type/index.expected
@@ -0,0 +1,280 @@
table_create Posts TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Posts title COLUMN_SCALAR ShortText
[[0,0.0,0.0],true]
column_create Posts text COLUMN_SCALAR Text
[[0,0.0,0.0],true]
table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
[[0,0.0,0.0],true]
column_create Terms index COLUMN_INDEX|WITH_SECTION|WITH_WEIGHT|WITH_POSITION Posts title,text
[[0,0.0,0.0],true]
schema
[
[
0,
0.0,
0.0
],
{
"plugins": {
},
"types": {
"Bool": {
"name": "Bool",
"size": 1,
"can_be_key_type": true,
"can_be_value_type": true
},
"Float": {
"name": "Float",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
},
"Int16": {
"name": "Int16",
"size": 2,
"can_be_key_type": true,
"can_be_value_type": true
},
"Int32": {
"name": "Int32",
"size": 4,
"can_be_key_type": true,
"can_be_value_type": true
},
"Int64": {
"name": "Int64",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
},
"Int8": {
"name": "Int8",
"size": 1,
"can_be_key_type": true,
"can_be_value_type": true
},
"LongText": {
"name": "LongText",
"size": 2147483648,
"can_be_key_type": false,
"can_be_value_type": false
},
"Object": {
"name": "Object",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
},
"ShortText": {
"name": "ShortText",
"size": 4096,
"can_be_key_type": true,
"can_be_value_type": false
},
"Text": {
"name": "Text",
"size": 65536,
"can_be_key_type": false,
"can_be_value_type": false
},
"Time": {
"name": "Time",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
},
"TokyoGeoPoint": {
"name": "TokyoGeoPoint",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
},
"UInt16": {
"name": "UInt16",
"size": 2,
"can_be_key_type": true,
"can_be_value_type": true
},
"UInt32": {
"name": "UInt32",
"size": 4,
"can_be_key_type": true,
"can_be_value_type": true
},
"UInt64": {
"name": "UInt64",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
},
"UInt8": {
"name": "UInt8",
"size": 1,
"can_be_key_type": true,
"can_be_value_type": true
},
"WGS84GeoPoint": {
"name": "WGS84GeoPoint",
"size": 8,
"can_be_key_type": true,
"can_be_value_type": true
}
},
"tokenizers": {
"TokenBigram": {
"name": "TokenBigram"
},
"TokenBigramIgnoreBlank": {
"name": "TokenBigramIgnoreBlank"
},
"TokenBigramIgnoreBlankSplitSymbol": {
"name": "TokenBigramIgnoreBlankSplitSymbol"
},
"TokenBigramIgnoreBlankSplitSymbolAlpha": {
"name": "TokenBigramIgnoreBlankSplitSymbolAlpha"
},
"TokenBigramIgnoreBlankSplitSymbolAlphaDigit": {
"name": "TokenBigramIgnoreBlankSplitSymbolAlphaDigit"
},
"TokenBigramSplitSymbol": {
"name": "TokenBigramSplitSymbol"
},
"TokenBigramSplitSymbolAlpha": {
"name": "TokenBigramSplitSymbolAlpha"
},
"TokenBigramSplitSymbolAlphaDigit": {
"name": "TokenBigramSplitSymbolAlphaDigit"
},
"TokenDelimit": {
"name": "TokenDelimit"
},
"TokenDelimitNull": {
"name": "TokenDelimitNull"
},
"TokenMecab": {
"name": "TokenMecab"
},
"TokenRegexp": {
"name": "TokenRegexp"
},
"TokenTrigram": {
"name": "TokenTrigram"
},
"TokenUnigram": {
"name": "TokenUnigram"
}
},
"normalizers": {
"NormalizerAuto": {
"name": "NormalizerAuto"
},
"NormalizerNFKC51": {
"name": "NormalizerNFKC51"
}
},
"token_filters": {
},
"tables": {
"Posts": {
"name": "Posts",
"type": "hash table",
"key_type": {
"name": "ShortText",
"type": "type"
},
"value_type": null,
"tokenizer": null,
"normalizer": null,
"token_filters": [

],
"command": {
"name": "table_create",
"arguments": {
"name": "Posts",
"flags": "TABLE_HASH_KEY",
"key_type": "ShortText"
},
"command_line": "table_create --name Posts --flags TABLE_HASH_KEY --key_type ShortText"
},
"columns": {
"text": {
"name": "text",
"table": "Posts",
"full_name": "Posts.text",
"type": "scalar",
"value_type": {
"name": "Text",
"type": "type"
},
"compress": null,
"section": false,
"weight": false,
"position": false
},
"title": {
"name": "title",
"table": "Posts",
"full_name": "Posts.title",
"type": "scalar",
"value_type": {
"name": "ShortText",
"type": "type"
},
"compress": null,
"section": false,
"weight": false,
"position": false
}
}
},
"Terms": {
"name": "Terms",
"type": "patricia trie",
"key_type": {
"name": "ShortText",
"type": "type"
},
"value_type": null,
"tokenizer": {
"name": "TokenBigram"
},
"normalizer": {
"name": "NormalizerAuto"
},
"token_filters": [

],
"command": {
"name": "table_create",
"arguments": {
"name": "Terms",
"flags": "TABLE_PAT_KEY",
"key_type": "ShortText",
"default_tokenizer": "TokenBigram",
"normalizer": "NormalizerAuto"
},
"command_line": "table_create --name Terms --flags TABLE_PAT_KEY --key_type ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto"
},
"columns": {
"index": {
"name": "index",
"table": "Terms",
"full_name": "Terms.index",
"type": "index",
"value_type": {
"name": "Posts",
"type": "reference"
},
"compress": null,
"section": true,
"weight": true,
"position": true
}
}
}
}
}
]
11 changes: 11 additions & 0 deletions test/command/suite/schema/tables/columns/type/index.test
@@ -0,0 +1,11 @@
table_create Posts TABLE_HASH_KEY ShortText
column_create Posts title COLUMN_SCALAR ShortText
column_create Posts text COLUMN_SCALAR Text

table_create Terms TABLE_PAT_KEY ShortText \
--default_tokenizer TokenBigram \
--normalizer NormalizerAuto
column_create Terms index COLUMN_INDEX|WITH_SECTION|WITH_WEIGHT|WITH_POSITION \
Posts title,text

schema
Expand Up @@ -199,7 +199,10 @@ schema
"name": "Text",
"type": "type"
},
"compress": null
"compress": null,
"section": false,
"weight": false,
"position": false
}
}
}
Expand Down
Expand Up @@ -205,7 +205,10 @@ schema
"name": "Tags",
"type": "reference"
},
"compress": null
"compress": null,
"section": false,
"weight": false,
"position": false
}
}
},
Expand Down

0 comments on commit 1a896e3

Please sign in to comment.