forked from blevesearch/bleve
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved byte array converts into the analysis package
- Loading branch information
Showing
8 changed files
with
143 additions
and
37 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
analysis/byte_array_converters/ignore/ignore_byte_array_converter.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2014 Couchbase, Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
// except in compliance with the License. You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed under the | ||
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
// either express or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
package ignore_byte_array_converter | ||
|
||
import ( | ||
"github.com/blevesearch/bleve/analysis" | ||
"github.com/blevesearch/bleve/registry" | ||
) | ||
|
||
type IgnoreByteArrayConverter struct{} | ||
|
||
func NewIgnoreByteArrayConverter() *IgnoreByteArrayConverter { | ||
return &IgnoreByteArrayConverter{} | ||
} | ||
|
||
func (c *IgnoreByteArrayConverter) Convert(in []byte) (interface{}, error) { | ||
return nil, nil | ||
} | ||
|
||
func Constructor(config map[string]interface{}, cache *registry.Cache) (analysis.ByteArrayConverter, error) { | ||
return NewIgnoreByteArrayConverter(), nil | ||
} | ||
|
||
func init() { | ||
registry.RegisterByteArrayConverter("ignore", Constructor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
analysis/byte_array_converters/string/string_byte_array_conveter.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2014 Couchbase, Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
// except in compliance with the License. You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed under the | ||
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
// either express or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
package string_byte_array_converter | ||
|
||
import ( | ||
"github.com/blevesearch/bleve/analysis" | ||
"github.com/blevesearch/bleve/registry" | ||
) | ||
|
||
type StringByteArrayConverter struct{} | ||
|
||
func NewStringByteArrayConverter() *StringByteArrayConverter { | ||
return &StringByteArrayConverter{} | ||
} | ||
|
||
func (c *StringByteArrayConverter) Convert(in []byte) (interface{}, error) { | ||
return string(in), nil | ||
} | ||
|
||
func Constructor(config map[string]interface{}, cache *registry.Cache) (analysis.ByteArrayConverter, error) { | ||
return NewStringByteArrayConverter(), nil | ||
} | ||
|
||
func init() { | ||
registry.RegisterByteArrayConverter("string", Constructor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2014 Couchbase, Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
// except in compliance with the License. You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed under the | ||
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
// either express or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
package registry | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/blevesearch/bleve/analysis" | ||
) | ||
|
||
func RegisterByteArrayConverter(name string, constructor ByteArrayConverterConstructor) { | ||
_, exists := byteArrayConverters[name] | ||
if exists { | ||
panic(fmt.Errorf("attempted to register duplicate byte array converter named '%s'", name)) | ||
} | ||
byteArrayConverters[name] = constructor | ||
} | ||
|
||
type ByteArrayConverterConstructor func(config map[string]interface{}, cache *Cache) (analysis.ByteArrayConverter, error) | ||
type ByteArrayConverterRegistry map[string]ByteArrayConverterConstructor | ||
|
||
func ByteArrayConverterByName(name string) ByteArrayConverterConstructor { | ||
return byteArrayConverters[name] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters