github.com/dgraph-io/simdjson-go@v0.3.0/simdjson_other.go (about) 1 // +build !amd64 appengine !gc noasm 2 3 /* 4 * MinIO Cloud Storage, (C) 2020 MinIO, Inc. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package simdjson 20 21 import ( 22 "errors" 23 "fmt" 24 "io" 25 ) 26 27 // SupportedCPU will return whether the CPU is supported. 28 func SupportedCPU() bool { 29 return false 30 } 31 32 // Parse a block of data and return the parsed JSON. 33 // An optional block of previously parsed json can be supplied to reduce allocations. 34 func Parse(b []byte, reuse *ParsedJson) (*ParsedJson, error) { 35 return nil, errors.New("Unsupported platform") 36 } 37 38 // ParseND will parse newline delimited JSON. 39 // An optional block of previously parsed json can be supplied to reduce allocations. 40 func ParseND(b []byte, reuse *ParsedJson) (*ParsedJson, error) { 41 return nil, errors.New("Unsupported platform") 42 } 43 44 // A Stream is used to stream back results. 45 // Either Error or Value will be set on returned results. 46 type Stream struct { 47 Value *ParsedJson 48 Error error 49 } 50 51 // ParseNDStream will parse a stream and return parsed JSON to the supplied result channel. 52 // The method will return immediately. 53 // Each element is contained within a root tag. 54 // <root>Element 1</root><root>Element 2</root>... 55 // Each result will contain an unspecified number of full elements, 56 // so it can be assumed that each result starts and ends with a root tag. 57 // The parser will keep parsing until writes to the result stream blocks. 58 // A stream is finished when a non-nil Error is returned. 59 // If the stream was parsed until the end the Error value will be io.EOF 60 // The channel will be closed after an error has been returned. 61 // An optional channel for returning consumed results can be provided. 62 // There is no guarantee that elements will be consumed, so always use 63 // non-blocking writes to the reuse channel. 64 func ParseNDStream(r io.Reader, res chan<- Stream, reuse <-chan *ParsedJson) { 65 go func() { 66 res <- Stream{ 67 Value: nil, 68 Error: fmt.Errorf("Unsupported platform"), 69 } 70 close(res) 71 }() 72 return 73 }