From 34fa1afad097ebbb402df50c613e4ddd51a4b591 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 23 Sep 2015 17:23:38 -0600 Subject: [PATCH] refactor This commit refactors the pilosa codebase. It makes several major changes: * Removes bitmap handles * Removes dispatch/hold/transport * Removes etcd dependency * Adds consistent hash ring for slice placement * Refactors parser/lexer * Adds strong typing to PQL AST * Flattens package hierarchy --- Godeps/Godeps.json | 52 +- NOTES | 26 + README.md | 22 - benchmark_autogen_test.go | 8796 ----------------- bitmap.go | 267 +- blocks.go | 74 - brand.go | 448 - brand_test.go | 44 - cache.go | 262 + cluster.go | 123 + cluster_test.go | 90 + cmd/pilosa/config.go | 111 +- cmd/pilosa/config_test.go | 159 +- cmd/pilosa/main.go | 229 +- cmd/pilosa/seelog.go | 28 - cmd/pilosactl/main.go | 65 + cmd/pilosactl/main_test.go | 1 + core/batch.go | 70 - core/etcd.go | 519 - core/http.go | 854 -- core/load.go | 95 - core/ping.go | 62 - core/remotebits.go | 127 - core/stopper.go | 37 - db/constants.go | 3 - db/db.go | 25 - db/topology.go | 446 - db/topology_test.go | 17 - dispatch/dispatch.go | 123 - etc/default.yaml | 17 - executor.go | 316 + executor/executor.go | 800 -- executor/utils.go | 57 - executor_test.go | 198 + fragment.go | 329 +- fragment_container.go | 340 - fragment_container_test.go | 308 - fragment_test.go | 8 + general.go | 174 - handler.go | 261 + handler_test.go | 373 + hold/hold.go | 88 - hold/hold_test.go | 41 - index.go | 53 + internal/internal.go | 56 + internal/internal.pb.go | 164 + internal/internal.proto | 28 + pilosa.go | 122 +- pilosa_test.go | 51 - popcnt_generic.go | 24 +- pql/ast.go | 228 + pql/ast_test.go | 89 + pql/parser.go | 569 ++ pql/parser_test.go | 239 + pql/scanner.go | 258 + pql/scanner_test.go | 49 + pql/token.go | 81 + query/lexer.go | 348 - query/lexer_test.go | 279 - query/parser.go | 354 - query/parser_test.go | 157 - query/planner.go | 953 -- query/planner_example.go | 67 - query/planner_test.go | 283 - query/query.go | 111 - query/query_test.go | 36 - statsd/statd.go | 65 - storage.go | 49 - storage/cassandra/cassandra.go | 244 - storage/cassandra/cassandra_test.go | 1 - storage/leveldb/leveldb.go | 222 - storage/leveldb/leveldb_test.go | 55 - storage/mem/mem.go | 79 - storage/mem/mem_test.go | 30 - storage/storage.go | 7 - timeframe.go | 5 +- transport/http.go | 56 - transport/tcp.go | 187 - util.go | 27 - .../github.com/BurntSushi/toml/decode_test.go | 950 -- .../github.com/BurntSushi/toml/encode_test.go | 542 - vendor/github.com/bitly/go-notify/.gitignore | 22 - vendor/github.com/bitly/go-notify/README.md | 51 - vendor/github.com/bitly/go-notify/notify.go | 130 - .../cactus/go-statsd-client/statsd/doc.go | 25 - .../cactus/go-statsd-client/statsd/main.go | 151 - .../go-statsd-client/statsd/main_test.go | 152 - .../cactus/go-statsd-client/statsd/noop.go | 74 - .../statsd/test-client/main.go | 90 - vendor/github.com/cihub/seelog/LICENSE.txt | 24 - .../github.com/cihub/seelog/README.markdown | 113 - .../cihub/seelog/behavior_adaptive_test.go | 124 - .../cihub/seelog/behavior_adaptivelogger.go | 129 - .../cihub/seelog/behavior_asynclogger.go | 142 - .../cihub/seelog/behavior_asyncloop_test.go | 133 - .../cihub/seelog/behavior_asynclooplogger.go | 69 - .../cihub/seelog/behavior_asynctimer_test.go | 83 - .../cihub/seelog/behavior_asynctimerlogger.go | 82 - .../cihub/seelog/behavior_synclogger.go | 75 - .../cihub/seelog/behavior_synclogger_test.go | 81 - vendor/github.com/cihub/seelog/cfg_config.go | 188 - vendor/github.com/cihub/seelog/cfg_errors.go | 61 - .../github.com/cihub/seelog/cfg_logconfig.go | 130 - .../cihub/seelog/cfg_logconfig_test.go | 99 - vendor/github.com/cihub/seelog/cfg_parser.go | 1238 --- .../cihub/seelog/cfg_parser_test.go | 1089 -- .../github.com/cihub/seelog/common_closer.go | 25 - .../cihub/seelog/common_constraints.go | 162 - .../cihub/seelog/common_constraints_test.go | 196 - .../github.com/cihub/seelog/common_context.go | 183 - .../cihub/seelog/common_context_test.go | 108 - .../cihub/seelog/common_exception.go | 194 - .../cihub/seelog/common_exception_test.go | 98 - .../github.com/cihub/seelog/common_flusher.go | 31 - .../cihub/seelog/common_loglevel.go | 81 - .../cihub/seelog/dispatch_custom.go | 242 - .../seelog/dispatch_customdispatcher_test.go | 177 - .../cihub/seelog/dispatch_dispatcher.go | 189 - .../cihub/seelog/dispatch_filterdispatcher.go | 66 - .../seelog/dispatch_filterdispatcher_test.go | 67 - .../cihub/seelog/dispatch_splitdispatcher.go | 47 - .../seelog/dispatch_splitdispatcher_test.go | 64 - vendor/github.com/cihub/seelog/doc.go | 141 - vendor/github.com/cihub/seelog/format.go | 461 - vendor/github.com/cihub/seelog/format_test.go | 236 - .../cihub/seelog/internals_baseerror.go | 10 - .../seelog/internals_byteverifiers_test.go | 118 - .../cihub/seelog/internals_fsutils.go | 403 - .../cihub/seelog/internals_xmlnode.go | 175 - .../cihub/seelog/internals_xmlnode_test.go | 196 - vendor/github.com/cihub/seelog/log.go | 307 - vendor/github.com/cihub/seelog/logger.go | 362 - .../cihub/seelog/writers_bufferedwriter.go | 161 - .../seelog/writers_bufferedwriter_test.go | 78 - .../cihub/seelog/writers_connwriter.go | 144 - .../cihub/seelog/writers_consolewriter.go | 47 - .../cihub/seelog/writers_filewriter.go | 92 - .../cihub/seelog/writers_filewriter_test.go | 254 - .../cihub/seelog/writers_formattedwriter.go | 62 - .../seelog/writers_formattedwriter_test.go | 65 - .../cihub/seelog/writers_rollingfilewriter.go | 612 -- .../seelog/writers_rollingfilewriter_test.go | 99 - .../cihub/seelog/writers_smtpwriter.go | 214 - .../coreos/go-etcd/etcd/add_child.go | 23 - .../coreos/go-etcd/etcd/add_child_test.go | 73 - .../github.com/coreos/go-etcd/etcd/client.go | 429 - .../coreos/go-etcd/etcd/client_test.go | 96 - .../github.com/coreos/go-etcd/etcd/cluster.go | 51 - .../coreos/go-etcd/etcd/compare_and_delete.go | 34 - .../go-etcd/etcd/compare_and_delete_test.go | 46 - .../coreos/go-etcd/etcd/compare_and_swap.go | 36 - .../go-etcd/etcd/compare_and_swap_test.go | 57 - .../coreos/go-etcd/etcd/config.json | 1 - .../github.com/coreos/go-etcd/etcd/debug.go | 54 - .../github.com/coreos/go-etcd/etcd/delete.go | 40 - .../coreos/go-etcd/etcd/delete_test.go | 81 - .../github.com/coreos/go-etcd/etcd/error.go | 48 - vendor/github.com/coreos/go-etcd/etcd/get.go | 27 - .../coreos/go-etcd/etcd/get_test.go | 131 - .../github.com/coreos/go-etcd/etcd/options.go | 72 - .../coreos/go-etcd/etcd/requests.go | 361 - .../coreos/go-etcd/etcd/response.go | 89 - .../coreos/go-etcd/etcd/set_curl_chan_test.go | 42 - .../coreos/go-etcd/etcd/set_update_create.go | 137 - .../go-etcd/etcd/set_update_create_test.go | 241 - .../github.com/coreos/go-etcd/etcd/version.go | 3 - .../github.com/coreos/go-etcd/etcd/watch.go | 107 - .../coreos/go-etcd/etcd/watch_test.go | 119 - .../davecgh/go-spew/spew/common_test.go | 178 - .../davecgh/go-spew/spew/dump_test.go | 912 -- .../davecgh/go-spew/spew/dumpcgo_test.go | 82 - .../davecgh/go-spew/spew/dumpnocgo_test.go | 26 - .../davecgh/go-spew/spew/example_test.go | 230 - .../davecgh/go-spew/spew/format_test.go | 1483 --- .../davecgh/go-spew/spew/internal_test.go | 163 - .../davecgh/go-spew/spew/spew_test.go | 308 - vendor/github.com/gocql/gocql/.gitignore | 4 - vendor/github.com/gocql/gocql/.travis.yml | 42 - vendor/github.com/gocql/gocql/AUTHORS | 54 - vendor/github.com/gocql/gocql/CONTRIBUTING.md | 78 - vendor/github.com/gocql/gocql/LICENSE | 27 - vendor/github.com/gocql/gocql/README.md | 197 - .../github.com/gocql/gocql/cass1batch_test.go | 60 - .../github.com/gocql/gocql/cassandra_test.go | 2060 ---- vendor/github.com/gocql/gocql/cluster.go | 112 - vendor/github.com/gocql/gocql/compressor.go | 28 - .../github.com/gocql/gocql/compressor_test.go | 40 - vendor/github.com/gocql/gocql/conn.go | 824 -- vendor/github.com/gocql/gocql/conn_test.go | 817 -- .../github.com/gocql/gocql/connectionpool.go | 895 -- vendor/github.com/gocql/gocql/doc.go | 9 - vendor/github.com/gocql/gocql/errors.go | 88 - vendor/github.com/gocql/gocql/errors_test.go | 29 - vendor/github.com/gocql/gocql/frame.go | 1480 --- vendor/github.com/gocql/gocql/frame_test.go | 98 - vendor/github.com/gocql/gocql/fuzz.go | 33 - vendor/github.com/gocql/gocql/helpers.go | 180 - vendor/github.com/gocql/gocql/host_source.go | 119 - vendor/github.com/gocql/gocql/integration.sh | 83 - vendor/github.com/gocql/gocql/marshal.go | 1624 --- vendor/github.com/gocql/gocql/marshal_test.go | 862 -- vendor/github.com/gocql/gocql/metadata.go | 875 -- .../github.com/gocql/gocql/metadata_test.go | 815 -- vendor/github.com/gocql/gocql/policies.go | 244 - .../github.com/gocql/gocql/policies_test.go | 125 - vendor/github.com/gocql/gocql/session.go | 1019 -- vendor/github.com/gocql/gocql/session_test.go | 255 - vendor/github.com/gocql/gocql/stress_test.go | 40 - vendor/github.com/gocql/gocql/token.go | 348 - vendor/github.com/gocql/gocql/token_test.go | 474 - vendor/github.com/gocql/gocql/topology.go | 74 - .../github.com/gocql/gocql/topology_test.go | 51 - vendor/github.com/gocql/gocql/tuple_test.go | 51 - vendor/github.com/gocql/gocql/udt_test.go | 254 - vendor/github.com/gocql/gocql/uuid.go | 242 - vendor/github.com/gocql/gocql/uuid_test.go | 197 - .../gocql/website/css/bootstrap-theme.css | 384 - .../gocql/website/css/bootstrap-theme.min.css | 1 - .../gocql/gocql/website/css/bootstrap.css | 6805 ------------- .../gocql/gocql/website/css/bootstrap.min.css | 9 - .../gocql/gocql/website/favicon.ico | Bin 13870 -> 0 bytes .../fonts/glyphicons-halflings-regular.eot | Bin 14079 -> 0 bytes .../fonts/glyphicons-halflings-regular.svg | 228 - .../fonts/glyphicons-halflings-regular.ttf | Bin 29512 -> 0 bytes .../fonts/glyphicons-halflings-regular.woff | Bin 16448 -> 0 bytes .../github.com/gocql/gocql/website/gocql.png | Bin 2686 -> 0 bytes .../github.com/gocql/gocql/website/index.html | 133 - .../gocql/gocql/website/js/bootstrap.js | 1999 ---- .../gocql/gocql/website/js/bootstrap.min.js | 6 - vendor/github.com/gocql/gocql/wiki_test.go | 274 - .../github.com/gogo/protobuf/proto/Makefile | 43 + .../github.com/gogo/protobuf/proto/clone.go | 202 + .../github.com/gogo/protobuf/proto/decode.go | 826 ++ .../gogo/protobuf/proto/decode_gogo.go | 175 + .../github.com/gogo/protobuf/proto/encode.go | 1288 +++ .../gogo/protobuf/proto/encode_gogo.go | 354 + .../github.com/gogo/protobuf/proto/equal.go | 256 + .../gogo/protobuf/proto/extensions.go | 481 + .../gogo/protobuf/proto/extensions_gogo.go | 221 + vendor/github.com/gogo/protobuf/proto/lib.go | 790 ++ .../gogo/protobuf/proto/lib_gogo.go | 40 + .../gogo/protobuf/proto/message_set.go | 287 + .../gogo/protobuf/proto/pointer_reflect.go | 479 + .../gogo/protobuf/proto/pointer_unsafe.go | 266 + .../protobuf/proto/pointer_unsafe_gogo.go | 108 + .../gogo/protobuf/proto/properties.go | 815 ++ .../gogo/protobuf/proto/properties_gogo.go | 64 + .../protobuf/proto/proto3_proto/proto3.pb.go | 122 + .../protobuf/proto/proto3_proto/proto3.proto | 68 + .../gogo/protobuf/proto/skip_gogo.go | 117 + vendor/github.com/gogo/protobuf/proto/text.go | 824 ++ .../gogo/protobuf/proto/text_gogo.go | 55 + .../gogo/protobuf/proto/text_parser.go | 800 ++ .../golang/groupcache/lru/lru_test.go | 73 - vendor/github.com/golang/snappy/AUTHORS | 14 - vendor/github.com/golang/snappy/CONTRIBUTORS | 36 - vendor/github.com/golang/snappy/LICENSE | 27 - vendor/github.com/golang/snappy/README | 7 - vendor/github.com/golang/snappy/decode.go | 294 - vendor/github.com/golang/snappy/encode.go | 254 - vendor/github.com/golang/snappy/snappy.go | 68 - .../github.com/golang/snappy/snappy_test.go | 377 - .../github.com/gorilla/websocket/.gitignore | 22 - .../github.com/gorilla/websocket/.travis.yml | 6 - vendor/github.com/gorilla/websocket/LICENSE | 23 - vendor/github.com/gorilla/websocket/README.md | 49 - vendor/github.com/gorilla/websocket/client.go | 237 - .../gorilla/websocket/client_server_test.go | 249 - vendor/github.com/gorilla/websocket/conn.go | 774 -- .../github.com/gorilla/websocket/conn_test.go | 142 - vendor/github.com/gorilla/websocket/doc.go | 103 - .../websocket/examples/autobahn/README.md | 18 - .../examples/autobahn/fuzzingclient.json | 14 - .../websocket/examples/autobahn/server.go | 250 - .../gorilla/websocket/examples/chat/README.md | 19 - .../gorilla/websocket/examples/chat/conn.go | 108 - .../gorilla/websocket/examples/chat/home.html | 92 - .../gorilla/websocket/examples/chat/hub.go | 49 - .../gorilla/websocket/examples/chat/main.go | 39 - vendor/github.com/gorilla/websocket/json.go | 49 - .../github.com/gorilla/websocket/json_test.go | 63 - vendor/github.com/gorilla/websocket/server.go | 135 - .../gorilla/websocket/server_test.go | 33 - vendor/github.com/gorilla/websocket/util.go | 44 - vendor/github.com/kr/s3/License | 19 - vendor/github.com/kr/s3/Readme | 4 - vendor/github.com/kr/s3/example_test.go | 30 - vendor/github.com/kr/s3/s3cp/.gitignore | 1 - vendor/github.com/kr/s3/s3cp/Readme | 4 - vendor/github.com/kr/s3/s3cp/main.go | 82 - vendor/github.com/kr/s3/s3util/Readme | 4 - vendor/github.com/kr/s3/s3util/config.go | 27 - vendor/github.com/kr/s3/s3util/error.go | 29 - .../github.com/kr/s3/s3util/example_test.go | 52 - vendor/github.com/kr/s3/s3util/open.go | 33 - vendor/github.com/kr/s3/s3util/readdir.go | 208 - vendor/github.com/kr/s3/s3util/uploader.go | 267 - .../github.com/kr/s3/s3util/uploader_test.go | 163 - vendor/github.com/kr/s3/sign.go | 200 - vendor/github.com/kr/s3/sign_test.go | 313 - .../github.com/robertkrimen/otto/.gitignore | 3 - .../robertkrimen/otto/DESIGN.markdown | 1 - vendor/github.com/robertkrimen/otto/LICENSE | 7 - vendor/github.com/robertkrimen/otto/Makefile | 60 - .../robertkrimen/otto/README.markdown | 616 -- .../robertkrimen/otto/array_test.go | 495 - .../github.com/robertkrimen/otto/bug_test.go | 249 - .../github.com/robertkrimen/otto/builtin.go | 368 - .../robertkrimen/otto/builtin_array.go | 666 -- .../robertkrimen/otto/builtin_boolean.go | 28 - .../robertkrimen/otto/builtin_date.go | 530 - .../robertkrimen/otto/builtin_error.go | 85 - .../robertkrimen/otto/builtin_function.go | 94 - .../robertkrimen/otto/builtin_math.go | 145 - .../robertkrimen/otto/builtin_number.go | 87 - .../robertkrimen/otto/builtin_object.go | 289 - .../robertkrimen/otto/builtin_regexp.go | 65 - .../robertkrimen/otto/builtin_string.go | 502 - .../robertkrimen/otto/builtin_test.go | 92 - vendor/github.com/robertkrimen/otto/clone.go | 143 - .../github.com/robertkrimen/otto/console.go | 51 - .../github.com/robertkrimen/otto/date_test.go | 210 - vendor/github.com/robertkrimen/otto/dbg.go | 9 - .../github.com/robertkrimen/otto/dbg/dbg.go | 387 - .../robertkrimen/otto/environment.go | 283 - vendor/github.com/robertkrimen/otto/error.go | 146 - .../robertkrimen/otto/error_test.go | 64 - .../github.com/robertkrimen/otto/evaluate.go | 152 - .../robertkrimen/otto/evaluate_expression.go | 573 -- .../robertkrimen/otto/evaluate_statement.go | 316 - .../robertkrimen/otto/execution_context.go | 40 - .../robertkrimen/otto/function_test.go | 116 - vendor/github.com/robertkrimen/otto/global.go | 218 - .../robertkrimen/otto/global_test.go | 320 - vendor/github.com/robertkrimen/otto/inline | 1049 -- vendor/github.com/robertkrimen/otto/inline.go | 6382 ------------ vendor/github.com/robertkrimen/otto/lexer.go | 694 -- .../robertkrimen/otto/lexer_test.go | 299 - .../github.com/robertkrimen/otto/math_test.go | 278 - vendor/github.com/robertkrimen/otto/node.go | 152 - .../robertkrimen/otto/node_expression.go | 424 - .../robertkrimen/otto/node_statement.go | 453 - .../robertkrimen/otto/number_test.go | 108 - vendor/github.com/robertkrimen/otto/object.go | 156 - .../robertkrimen/otto/object_class.go | 384 - .../robertkrimen/otto/object_test.go | 368 - vendor/github.com/robertkrimen/otto/otto.go | 406 - .../robertkrimen/otto/otto/Makefile | 5 - .../github.com/robertkrimen/otto/otto/main.go | 41 - vendor/github.com/robertkrimen/otto/otto_.go | 173 - .../robertkrimen/otto/otto_error_test.go | 49 - .../github.com/robertkrimen/otto/otto_test.go | 665 -- .../robertkrimen/otto/panic_test.go | 37 - .../robertkrimen/otto/parse_expression.go | 474 - .../robertkrimen/otto/parse_statement.go | 557 -- vendor/github.com/robertkrimen/otto/parser.go | 313 - .../robertkrimen/otto/parser_test.go | 1468 --- .../github.com/robertkrimen/otto/property.go | 188 - .../robertkrimen/otto/reflect_test.go | 360 - .../robertkrimen/otto/regexp_test.go | 270 - .../otto/registry/README.markdown | 51 - .../robertkrimen/otto/registry/registry.go | 47 - vendor/github.com/robertkrimen/otto/result.go | 30 - .../github.com/robertkrimen/otto/runtime.go | 360 - .../robertkrimen/otto/runtime_test.go | 1260 --- .../robertkrimen/otto/string_test.go | 314 - .../robertkrimen/otto/terst/terst.go | 1172 --- .../robertkrimen/otto/type_arguments.go | 112 - .../robertkrimen/otto/type_array.go | 88 - .../robertkrimen/otto/type_boolean.go | 13 - .../github.com/robertkrimen/otto/type_date.go | 297 - .../robertkrimen/otto/type_error.go | 9 - .../robertkrimen/otto/type_function.go | 277 - .../robertkrimen/otto/type_go_array.go | 134 - .../robertkrimen/otto/type_go_map.go | 87 - .../robertkrimen/otto/type_go_slice.go | 118 - .../robertkrimen/otto/type_go_struct.go | 91 - .../robertkrimen/otto/type_number.go | 5 - .../robertkrimen/otto/type_reference.go | 155 - .../robertkrimen/otto/type_regexp.go | 248 - .../robertkrimen/otto/type_string.go | 66 - .../robertkrimen/otto/underscore/Makefile | 11 - .../otto/underscore/README.markdown | 53 - .../robertkrimen/otto/underscore/source.go | 3462 ------- .../robertkrimen/otto/underscore/testify | 85 - .../otto/underscore/underscore.go | 49 - .../otto/underscore_arrays_test.go | 345 - .../otto/underscore_chaining_test.go | 96 - .../otto/underscore_collections_test.go | 694 -- .../otto/underscore_functions_test.go | 213 - .../otto/underscore_objects_test.go | 778 -- .../robertkrimen/otto/underscore_test.go | 155 - .../otto/underscore_utility_test.go | 422 - vendor/github.com/robertkrimen/otto/value.go | 922 -- .../robertkrimen/otto/value_boolean.go | 40 - .../robertkrimen/otto/value_number.go | 321 - .../robertkrimen/otto/value_primitive.go | 23 - .../robertkrimen/otto/value_string.go | 101 - .../robertkrimen/otto/value_test.go | 238 - vendor/github.com/stathat/consistent/LICENSE | 19 - .../github.com/stathat/consistent/README.md | 32 - .../stathat/consistent/consistent.go | 203 - .../stathat/consistent/consistent_test.go | 447 - .../stathat/consistent/example_test.go | 111 - .../syndtr/goleveldb/leveldb/batch.go | 252 - .../syndtr/goleveldb/leveldb/batch_test.go | 120 - .../syndtr/goleveldb/leveldb/bench2_test.go | 58 - .../syndtr/goleveldb/leveldb/bench_test.go | 464 - .../goleveldb/leveldb/cache/bench2_test.go | 30 - .../syndtr/goleveldb/leveldb/cache/cache.go | 676 -- .../goleveldb/leveldb/cache/cache_test.go | 554 -- .../syndtr/goleveldb/leveldb/cache/lru.go | 195 - .../syndtr/goleveldb/leveldb/comparer.go | 75 - .../leveldb/comparer/bytes_comparer.go | 51 - .../goleveldb/leveldb/comparer/comparer.go | 57 - .../syndtr/goleveldb/leveldb/corrupt_test.go | 500 - .../github.com/syndtr/goleveldb/leveldb/db.go | 1068 -- .../syndtr/goleveldb/leveldb/db_compaction.go | 791 -- .../syndtr/goleveldb/leveldb/db_iter.go | 350 - .../syndtr/goleveldb/leveldb/db_snapshot.go | 183 - .../syndtr/goleveldb/leveldb/db_state.go | 211 - .../syndtr/goleveldb/leveldb/db_test.go | 2701 ----- .../syndtr/goleveldb/leveldb/db_util.go | 100 - .../syndtr/goleveldb/leveldb/db_write.go | 338 - .../syndtr/goleveldb/leveldb/doc.go | 90 - .../syndtr/goleveldb/leveldb/errors.go | 19 - .../syndtr/goleveldb/leveldb/errors/errors.go | 76 - .../syndtr/goleveldb/leveldb/external_test.go | 58 - .../syndtr/goleveldb/leveldb/filter.go | 31 - .../syndtr/goleveldb/leveldb/filter/bloom.go | 116 - .../goleveldb/leveldb/filter/bloom_test.go | 142 - .../syndtr/goleveldb/leveldb/filter/filter.go | 60 - .../goleveldb/leveldb/iterator/array_iter.go | 184 - .../leveldb/iterator/array_iter_test.go | 30 - .../leveldb/iterator/indexed_iter.go | 242 - .../leveldb/iterator/indexed_iter_test.go | 83 - .../syndtr/goleveldb/leveldb/iterator/iter.go | 131 - .../leveldb/iterator/iter_suite_test.go | 11 - .../goleveldb/leveldb/iterator/merged_iter.go | 304 - .../leveldb/iterator/merged_iter_test.go | 60 - .../goleveldb/leveldb/journal/journal.go | 520 - .../goleveldb/leveldb/journal/journal_test.go | 818 -- .../syndtr/goleveldb/leveldb/key.go | 142 - .../syndtr/goleveldb/leveldb/key_test.go | 133 - .../goleveldb/leveldb/leveldb_suite_test.go | 11 - .../goleveldb/leveldb/memdb/bench_test.go | 75 - .../syndtr/goleveldb/leveldb/memdb/memdb.go | 471 - .../leveldb/memdb/memdb_suite_test.go | 11 - .../goleveldb/leveldb/memdb/memdb_test.go | 135 - .../syndtr/goleveldb/leveldb/opt/options.go | 670 -- .../syndtr/goleveldb/leveldb/options.go | 92 - .../syndtr/goleveldb/leveldb/session.go | 211 - .../goleveldb/leveldb/session_compaction.go | 287 - .../goleveldb/leveldb/session_record.go | 311 - .../goleveldb/leveldb/session_record_test.go | 64 - .../syndtr/goleveldb/leveldb/session_util.go | 249 - .../goleveldb/leveldb/storage/file_storage.go | 534 - .../leveldb/storage/file_storage_plan9.go | 52 - .../leveldb/storage/file_storage_solaris.go | 68 - .../leveldb/storage/file_storage_test.go | 142 - .../leveldb/storage/file_storage_unix.go | 63 - .../leveldb/storage/file_storage_windows.go | 69 - .../goleveldb/leveldb/storage/mem_storage.go | 203 - .../leveldb/storage/mem_storage_test.go | 66 - .../goleveldb/leveldb/storage/storage.go | 157 - .../syndtr/goleveldb/leveldb/storage_test.go | 549 - .../syndtr/goleveldb/leveldb/table.go | 525 - .../goleveldb/leveldb/table/block_test.go | 139 - .../syndtr/goleveldb/leveldb/table/reader.go | 1107 --- .../syndtr/goleveldb/leveldb/table/table.go | 177 - .../leveldb/table/table_suite_test.go | 11 - .../goleveldb/leveldb/table/table_test.go | 122 - .../syndtr/goleveldb/leveldb/table/writer.go | 375 - .../syndtr/goleveldb/leveldb/testutil/db.go | 222 - .../goleveldb/leveldb/testutil/ginkgo.go | 21 - .../syndtr/goleveldb/leveldb/testutil/iter.go | 327 - .../syndtr/goleveldb/leveldb/testutil/kv.go | 352 - .../goleveldb/leveldb/testutil/kvtest.go | 187 - .../goleveldb/leveldb/testutil/storage.go | 586 -- .../syndtr/goleveldb/leveldb/testutil/util.go | 171 - .../syndtr/goleveldb/leveldb/testutil_test.go | 63 - .../syndtr/goleveldb/leveldb/util.go | 91 - .../syndtr/goleveldb/leveldb/util/buffer.go | 293 - .../goleveldb/leveldb/util/buffer_pool.go | 238 - .../goleveldb/leveldb/util/buffer_test.go | 369 - .../syndtr/goleveldb/leveldb/util/crc32.go | 30 - .../syndtr/goleveldb/leveldb/util/hash.go | 48 - .../syndtr/goleveldb/leveldb/util/pool.go | 21 - .../goleveldb/leveldb/util/pool_legacy.go | 33 - .../syndtr/goleveldb/leveldb/util/range.go | 32 - .../syndtr/goleveldb/leveldb/util/util.go | 73 - .../syndtr/goleveldb/leveldb/version.go | 457 - .../yasushi-saito/rbtree/rbtree_test.go | 371 - vendor/gopkg.in/inf.v0/LICENSE | 57 - vendor/gopkg.in/inf.v0/benchmark_test.go | 210 - vendor/gopkg.in/inf.v0/dec.go | 615 -- vendor/gopkg.in/inf.v0/dec_go1_2_test.go | 33 - vendor/gopkg.in/inf.v0/dec_internal_test.go | 40 - vendor/gopkg.in/inf.v0/dec_test.go | 379 - vendor/gopkg.in/inf.v0/example_test.go | 62 - vendor/gopkg.in/inf.v0/rounder.go | 145 - .../gopkg.in/inf.v0/rounder_example_test.go | 72 - vendor/gopkg.in/inf.v0/rounder_test.go | 109 - 503 files changed, 12764 insertions(+), 127466 deletions(-) create mode 100644 NOTES delete mode 100644 benchmark_autogen_test.go delete mode 100644 blocks.go delete mode 100644 brand.go delete mode 100644 brand_test.go create mode 100644 cache.go create mode 100644 cluster.go create mode 100644 cluster_test.go delete mode 100644 cmd/pilosa/seelog.go create mode 100644 cmd/pilosactl/main.go create mode 100644 cmd/pilosactl/main_test.go delete mode 100644 core/batch.go delete mode 100644 core/etcd.go delete mode 100644 core/http.go delete mode 100644 core/load.go delete mode 100644 core/ping.go delete mode 100644 core/remotebits.go delete mode 100644 core/stopper.go delete mode 100644 db/constants.go delete mode 100644 db/db.go delete mode 100644 db/topology.go delete mode 100644 db/topology_test.go delete mode 100644 dispatch/dispatch.go delete mode 100644 etc/default.yaml create mode 100644 executor.go delete mode 100644 executor/executor.go delete mode 100644 executor/utils.go create mode 100644 executor_test.go delete mode 100644 fragment_container.go delete mode 100644 fragment_container_test.go create mode 100644 fragment_test.go delete mode 100644 general.go create mode 100644 handler.go create mode 100644 handler_test.go delete mode 100644 hold/hold.go delete mode 100644 hold/hold_test.go create mode 100644 index.go create mode 100644 internal/internal.go create mode 100644 internal/internal.pb.go create mode 100644 internal/internal.proto delete mode 100644 pilosa_test.go create mode 100644 pql/ast.go create mode 100644 pql/ast_test.go create mode 100644 pql/parser.go create mode 100644 pql/parser_test.go create mode 100644 pql/scanner.go create mode 100644 pql/scanner_test.go create mode 100644 pql/token.go delete mode 100644 query/lexer.go delete mode 100644 query/lexer_test.go delete mode 100644 query/parser.go delete mode 100644 query/parser_test.go delete mode 100644 query/planner.go delete mode 100644 query/planner_example.go delete mode 100644 query/planner_test.go delete mode 100644 query/query.go delete mode 100644 query/query_test.go delete mode 100644 statsd/statd.go delete mode 100644 storage.go delete mode 100644 storage/cassandra/cassandra.go delete mode 100644 storage/cassandra/cassandra_test.go delete mode 100644 storage/leveldb/leveldb.go delete mode 100644 storage/leveldb/leveldb_test.go delete mode 100644 storage/mem/mem.go delete mode 100644 storage/mem/mem_test.go delete mode 100644 storage/storage.go delete mode 100644 transport/http.go delete mode 100644 transport/tcp.go delete mode 100644 util.go delete mode 100644 vendor/github.com/BurntSushi/toml/decode_test.go delete mode 100644 vendor/github.com/BurntSushi/toml/encode_test.go delete mode 100644 vendor/github.com/bitly/go-notify/.gitignore delete mode 100644 vendor/github.com/bitly/go-notify/README.md delete mode 100644 vendor/github.com/bitly/go-notify/notify.go delete mode 100644 vendor/github.com/cactus/go-statsd-client/statsd/doc.go delete mode 100644 vendor/github.com/cactus/go-statsd-client/statsd/main.go delete mode 100644 vendor/github.com/cactus/go-statsd-client/statsd/main_test.go delete mode 100644 vendor/github.com/cactus/go-statsd-client/statsd/noop.go delete mode 100644 vendor/github.com/cactus/go-statsd-client/statsd/test-client/main.go delete mode 100644 vendor/github.com/cihub/seelog/LICENSE.txt delete mode 100644 vendor/github.com/cihub/seelog/README.markdown delete mode 100644 vendor/github.com/cihub/seelog/behavior_adaptive_test.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_adaptivelogger.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_asynclogger.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_asyncloop_test.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_asynclooplogger.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_asynctimer_test.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_asynctimerlogger.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_synclogger.go delete mode 100644 vendor/github.com/cihub/seelog/behavior_synclogger_test.go delete mode 100644 vendor/github.com/cihub/seelog/cfg_config.go delete mode 100644 vendor/github.com/cihub/seelog/cfg_errors.go delete mode 100644 vendor/github.com/cihub/seelog/cfg_logconfig.go delete mode 100644 vendor/github.com/cihub/seelog/cfg_logconfig_test.go delete mode 100644 vendor/github.com/cihub/seelog/cfg_parser.go delete mode 100644 vendor/github.com/cihub/seelog/cfg_parser_test.go delete mode 100644 vendor/github.com/cihub/seelog/common_closer.go delete mode 100644 vendor/github.com/cihub/seelog/common_constraints.go delete mode 100644 vendor/github.com/cihub/seelog/common_constraints_test.go delete mode 100644 vendor/github.com/cihub/seelog/common_context.go delete mode 100644 vendor/github.com/cihub/seelog/common_context_test.go delete mode 100644 vendor/github.com/cihub/seelog/common_exception.go delete mode 100644 vendor/github.com/cihub/seelog/common_exception_test.go delete mode 100644 vendor/github.com/cihub/seelog/common_flusher.go delete mode 100644 vendor/github.com/cihub/seelog/common_loglevel.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_custom.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_customdispatcher_test.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_dispatcher.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_filterdispatcher.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_filterdispatcher_test.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_splitdispatcher.go delete mode 100644 vendor/github.com/cihub/seelog/dispatch_splitdispatcher_test.go delete mode 100644 vendor/github.com/cihub/seelog/doc.go delete mode 100644 vendor/github.com/cihub/seelog/format.go delete mode 100644 vendor/github.com/cihub/seelog/format_test.go delete mode 100644 vendor/github.com/cihub/seelog/internals_baseerror.go delete mode 100644 vendor/github.com/cihub/seelog/internals_byteverifiers_test.go delete mode 100644 vendor/github.com/cihub/seelog/internals_fsutils.go delete mode 100644 vendor/github.com/cihub/seelog/internals_xmlnode.go delete mode 100644 vendor/github.com/cihub/seelog/internals_xmlnode_test.go delete mode 100644 vendor/github.com/cihub/seelog/log.go delete mode 100644 vendor/github.com/cihub/seelog/logger.go delete mode 100644 vendor/github.com/cihub/seelog/writers_bufferedwriter.go delete mode 100644 vendor/github.com/cihub/seelog/writers_bufferedwriter_test.go delete mode 100644 vendor/github.com/cihub/seelog/writers_connwriter.go delete mode 100644 vendor/github.com/cihub/seelog/writers_consolewriter.go delete mode 100644 vendor/github.com/cihub/seelog/writers_filewriter.go delete mode 100644 vendor/github.com/cihub/seelog/writers_filewriter_test.go delete mode 100644 vendor/github.com/cihub/seelog/writers_formattedwriter.go delete mode 100644 vendor/github.com/cihub/seelog/writers_formattedwriter_test.go delete mode 100644 vendor/github.com/cihub/seelog/writers_rollingfilewriter.go delete mode 100644 vendor/github.com/cihub/seelog/writers_rollingfilewriter_test.go delete mode 100644 vendor/github.com/cihub/seelog/writers_smtpwriter.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/add_child.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/add_child_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/client.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/client_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/cluster.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/compare_and_delete_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/compare_and_swap_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/config.json delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/debug.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/delete.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/delete_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/error.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/get.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/get_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/options.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/requests.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/response.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/set_curl_chan_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/set_update_create.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/set_update_create_test.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/version.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/watch.go delete mode 100644 vendor/github.com/coreos/go-etcd/etcd/watch_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/common_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dump_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/example_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/format_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/internal_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/spew_test.go delete mode 100644 vendor/github.com/gocql/gocql/.gitignore delete mode 100644 vendor/github.com/gocql/gocql/.travis.yml delete mode 100644 vendor/github.com/gocql/gocql/AUTHORS delete mode 100644 vendor/github.com/gocql/gocql/CONTRIBUTING.md delete mode 100644 vendor/github.com/gocql/gocql/LICENSE delete mode 100644 vendor/github.com/gocql/gocql/README.md delete mode 100644 vendor/github.com/gocql/gocql/cass1batch_test.go delete mode 100644 vendor/github.com/gocql/gocql/cassandra_test.go delete mode 100644 vendor/github.com/gocql/gocql/cluster.go delete mode 100644 vendor/github.com/gocql/gocql/compressor.go delete mode 100644 vendor/github.com/gocql/gocql/compressor_test.go delete mode 100644 vendor/github.com/gocql/gocql/conn.go delete mode 100644 vendor/github.com/gocql/gocql/conn_test.go delete mode 100644 vendor/github.com/gocql/gocql/connectionpool.go delete mode 100644 vendor/github.com/gocql/gocql/doc.go delete mode 100644 vendor/github.com/gocql/gocql/errors.go delete mode 100644 vendor/github.com/gocql/gocql/errors_test.go delete mode 100644 vendor/github.com/gocql/gocql/frame.go delete mode 100644 vendor/github.com/gocql/gocql/frame_test.go delete mode 100644 vendor/github.com/gocql/gocql/fuzz.go delete mode 100644 vendor/github.com/gocql/gocql/helpers.go delete mode 100644 vendor/github.com/gocql/gocql/host_source.go delete mode 100644 vendor/github.com/gocql/gocql/integration.sh delete mode 100644 vendor/github.com/gocql/gocql/marshal.go delete mode 100644 vendor/github.com/gocql/gocql/marshal_test.go delete mode 100644 vendor/github.com/gocql/gocql/metadata.go delete mode 100644 vendor/github.com/gocql/gocql/metadata_test.go delete mode 100644 vendor/github.com/gocql/gocql/policies.go delete mode 100644 vendor/github.com/gocql/gocql/policies_test.go delete mode 100644 vendor/github.com/gocql/gocql/session.go delete mode 100644 vendor/github.com/gocql/gocql/session_test.go delete mode 100644 vendor/github.com/gocql/gocql/stress_test.go delete mode 100644 vendor/github.com/gocql/gocql/token.go delete mode 100644 vendor/github.com/gocql/gocql/token_test.go delete mode 100644 vendor/github.com/gocql/gocql/topology.go delete mode 100644 vendor/github.com/gocql/gocql/topology_test.go delete mode 100644 vendor/github.com/gocql/gocql/tuple_test.go delete mode 100644 vendor/github.com/gocql/gocql/udt_test.go delete mode 100644 vendor/github.com/gocql/gocql/uuid.go delete mode 100644 vendor/github.com/gocql/gocql/uuid_test.go delete mode 100644 vendor/github.com/gocql/gocql/website/css/bootstrap-theme.css delete mode 100644 vendor/github.com/gocql/gocql/website/css/bootstrap-theme.min.css delete mode 100644 vendor/github.com/gocql/gocql/website/css/bootstrap.css delete mode 100644 vendor/github.com/gocql/gocql/website/css/bootstrap.min.css delete mode 100644 vendor/github.com/gocql/gocql/website/favicon.ico delete mode 100644 vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.eot delete mode 100644 vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.svg delete mode 100644 vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.ttf delete mode 100644 vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.woff delete mode 100644 vendor/github.com/gocql/gocql/website/gocql.png delete mode 100644 vendor/github.com/gocql/gocql/website/index.html delete mode 100644 vendor/github.com/gocql/gocql/website/js/bootstrap.js delete mode 100644 vendor/github.com/gocql/gocql/website/js/bootstrap.min.js delete mode 100644 vendor/github.com/gocql/gocql/wiki_test.go create mode 100644 vendor/github.com/gogo/protobuf/proto/Makefile create mode 100644 vendor/github.com/gogo/protobuf/proto/clone.go create mode 100644 vendor/github.com/gogo/protobuf/proto/decode.go create mode 100644 vendor/github.com/gogo/protobuf/proto/decode_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/encode.go create mode 100644 vendor/github.com/gogo/protobuf/proto/encode_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/equal.go create mode 100644 vendor/github.com/gogo/protobuf/proto/extensions.go create mode 100644 vendor/github.com/gogo/protobuf/proto/extensions_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/lib.go create mode 100644 vendor/github.com/gogo/protobuf/proto/lib_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/message_set.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_reflect.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/properties.go create mode 100644 vendor/github.com/gogo/protobuf/proto/properties_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go create mode 100644 vendor/github.com/gogo/protobuf/proto/proto3_proto/proto3.proto create mode 100644 vendor/github.com/gogo/protobuf/proto/skip_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/text.go create mode 100644 vendor/github.com/gogo/protobuf/proto/text_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/text_parser.go delete mode 100644 vendor/github.com/golang/groupcache/lru/lru_test.go delete mode 100644 vendor/github.com/golang/snappy/AUTHORS delete mode 100644 vendor/github.com/golang/snappy/CONTRIBUTORS delete mode 100644 vendor/github.com/golang/snappy/LICENSE delete mode 100644 vendor/github.com/golang/snappy/README delete mode 100644 vendor/github.com/golang/snappy/decode.go delete mode 100644 vendor/github.com/golang/snappy/encode.go delete mode 100644 vendor/github.com/golang/snappy/snappy.go delete mode 100644 vendor/github.com/golang/snappy/snappy_test.go delete mode 100644 vendor/github.com/gorilla/websocket/.gitignore delete mode 100644 vendor/github.com/gorilla/websocket/.travis.yml delete mode 100644 vendor/github.com/gorilla/websocket/LICENSE delete mode 100644 vendor/github.com/gorilla/websocket/README.md delete mode 100644 vendor/github.com/gorilla/websocket/client.go delete mode 100644 vendor/github.com/gorilla/websocket/client_server_test.go delete mode 100644 vendor/github.com/gorilla/websocket/conn.go delete mode 100644 vendor/github.com/gorilla/websocket/conn_test.go delete mode 100644 vendor/github.com/gorilla/websocket/doc.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/autobahn/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/autobahn/fuzzingclient.json delete mode 100644 vendor/github.com/gorilla/websocket/examples/autobahn/server.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/conn.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/home.html delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/hub.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/main.go delete mode 100644 vendor/github.com/gorilla/websocket/json.go delete mode 100644 vendor/github.com/gorilla/websocket/json_test.go delete mode 100644 vendor/github.com/gorilla/websocket/server.go delete mode 100644 vendor/github.com/gorilla/websocket/server_test.go delete mode 100644 vendor/github.com/gorilla/websocket/util.go delete mode 100644 vendor/github.com/kr/s3/License delete mode 100644 vendor/github.com/kr/s3/Readme delete mode 100644 vendor/github.com/kr/s3/example_test.go delete mode 100644 vendor/github.com/kr/s3/s3cp/.gitignore delete mode 100644 vendor/github.com/kr/s3/s3cp/Readme delete mode 100644 vendor/github.com/kr/s3/s3cp/main.go delete mode 100644 vendor/github.com/kr/s3/s3util/Readme delete mode 100644 vendor/github.com/kr/s3/s3util/config.go delete mode 100644 vendor/github.com/kr/s3/s3util/error.go delete mode 100644 vendor/github.com/kr/s3/s3util/example_test.go delete mode 100644 vendor/github.com/kr/s3/s3util/open.go delete mode 100644 vendor/github.com/kr/s3/s3util/readdir.go delete mode 100644 vendor/github.com/kr/s3/s3util/uploader.go delete mode 100644 vendor/github.com/kr/s3/s3util/uploader_test.go delete mode 100644 vendor/github.com/kr/s3/sign.go delete mode 100644 vendor/github.com/kr/s3/sign_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/.gitignore delete mode 100644 vendor/github.com/robertkrimen/otto/DESIGN.markdown delete mode 100644 vendor/github.com/robertkrimen/otto/LICENSE delete mode 100644 vendor/github.com/robertkrimen/otto/Makefile delete mode 100644 vendor/github.com/robertkrimen/otto/README.markdown delete mode 100644 vendor/github.com/robertkrimen/otto/array_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/bug_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_array.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_boolean.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_date.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_error.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_function.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_math.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_number.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_object.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_regexp.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_string.go delete mode 100644 vendor/github.com/robertkrimen/otto/builtin_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/clone.go delete mode 100644 vendor/github.com/robertkrimen/otto/console.go delete mode 100644 vendor/github.com/robertkrimen/otto/date_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/dbg.go delete mode 100644 vendor/github.com/robertkrimen/otto/dbg/dbg.go delete mode 100644 vendor/github.com/robertkrimen/otto/environment.go delete mode 100644 vendor/github.com/robertkrimen/otto/error.go delete mode 100644 vendor/github.com/robertkrimen/otto/error_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/evaluate.go delete mode 100644 vendor/github.com/robertkrimen/otto/evaluate_expression.go delete mode 100644 vendor/github.com/robertkrimen/otto/evaluate_statement.go delete mode 100644 vendor/github.com/robertkrimen/otto/execution_context.go delete mode 100644 vendor/github.com/robertkrimen/otto/function_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/global.go delete mode 100644 vendor/github.com/robertkrimen/otto/global_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/inline delete mode 100644 vendor/github.com/robertkrimen/otto/inline.go delete mode 100644 vendor/github.com/robertkrimen/otto/lexer.go delete mode 100644 vendor/github.com/robertkrimen/otto/lexer_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/math_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/node.go delete mode 100644 vendor/github.com/robertkrimen/otto/node_expression.go delete mode 100644 vendor/github.com/robertkrimen/otto/node_statement.go delete mode 100644 vendor/github.com/robertkrimen/otto/number_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/object.go delete mode 100644 vendor/github.com/robertkrimen/otto/object_class.go delete mode 100644 vendor/github.com/robertkrimen/otto/object_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/otto.go delete mode 100644 vendor/github.com/robertkrimen/otto/otto/Makefile delete mode 100644 vendor/github.com/robertkrimen/otto/otto/main.go delete mode 100644 vendor/github.com/robertkrimen/otto/otto_.go delete mode 100644 vendor/github.com/robertkrimen/otto/otto_error_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/otto_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/panic_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/parse_expression.go delete mode 100644 vendor/github.com/robertkrimen/otto/parse_statement.go delete mode 100644 vendor/github.com/robertkrimen/otto/parser.go delete mode 100644 vendor/github.com/robertkrimen/otto/parser_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/property.go delete mode 100644 vendor/github.com/robertkrimen/otto/reflect_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/regexp_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/registry/README.markdown delete mode 100644 vendor/github.com/robertkrimen/otto/registry/registry.go delete mode 100644 vendor/github.com/robertkrimen/otto/result.go delete mode 100644 vendor/github.com/robertkrimen/otto/runtime.go delete mode 100644 vendor/github.com/robertkrimen/otto/runtime_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/string_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/terst/terst.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_arguments.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_array.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_boolean.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_date.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_error.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_function.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_go_array.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_go_map.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_go_slice.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_go_struct.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_number.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_reference.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_regexp.go delete mode 100644 vendor/github.com/robertkrimen/otto/type_string.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore/Makefile delete mode 100644 vendor/github.com/robertkrimen/otto/underscore/README.markdown delete mode 100644 vendor/github.com/robertkrimen/otto/underscore/source.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore/testify delete mode 100644 vendor/github.com/robertkrimen/otto/underscore/underscore.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_arrays_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_chaining_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_collections_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_functions_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_objects_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/underscore_utility_test.go delete mode 100644 vendor/github.com/robertkrimen/otto/value.go delete mode 100644 vendor/github.com/robertkrimen/otto/value_boolean.go delete mode 100644 vendor/github.com/robertkrimen/otto/value_number.go delete mode 100644 vendor/github.com/robertkrimen/otto/value_primitive.go delete mode 100644 vendor/github.com/robertkrimen/otto/value_string.go delete mode 100644 vendor/github.com/robertkrimen/otto/value_test.go delete mode 100644 vendor/github.com/stathat/consistent/LICENSE delete mode 100644 vendor/github.com/stathat/consistent/README.md delete mode 100644 vendor/github.com/stathat/consistent/consistent.go delete mode 100644 vendor/github.com/stathat/consistent/consistent_test.go delete mode 100644 vendor/github.com/stathat/consistent/example_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/batch.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/batch_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/bench2_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/bench_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/cache/bench2_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/cache/cache_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/comparer.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/corrupt_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_state.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_util.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/db_write.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/doc.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/errors.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/external_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/filter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter_suite_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/journal/journal_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/key.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/key_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/leveldb_suite_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/memdb/bench_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb_suite_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/options.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/session.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/session_record.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/session_record_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/session_util.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table/block_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table/table.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table/table_suite_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table/table_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/db.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/ginkgo.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/iter.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/kv.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/kvtest.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/storage.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil/util.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/testutil_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/pool.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/pool_legacy.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/range.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/util.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/version.go delete mode 100644 vendor/github.com/yasushi-saito/rbtree/rbtree_test.go delete mode 100644 vendor/gopkg.in/inf.v0/LICENSE delete mode 100644 vendor/gopkg.in/inf.v0/benchmark_test.go delete mode 100644 vendor/gopkg.in/inf.v0/dec.go delete mode 100644 vendor/gopkg.in/inf.v0/dec_go1_2_test.go delete mode 100644 vendor/gopkg.in/inf.v0/dec_internal_test.go delete mode 100644 vendor/gopkg.in/inf.v0/dec_test.go delete mode 100644 vendor/gopkg.in/inf.v0/example_test.go delete mode 100644 vendor/gopkg.in/inf.v0/rounder.go delete mode 100644 vendor/gopkg.in/inf.v0/rounder_example_test.go delete mode 100644 vendor/gopkg.in/inf.v0/rounder_test.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index cfe712f08..5d677bd0b 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,6 +1,6 @@ { "ImportPath": "github.com/umbel/pilosa", - "GoVersion": "go1.5", + "GoVersion": "go1.5.1", "Packages": [ "./..." ], @@ -10,67 +10,21 @@ "Comment": "v0.1.0-21-g056c9bc", "Rev": "056c9bc7be7190eaa7715723883caffa5f8fa3e4" }, - { - "ImportPath": "github.com/bitly/go-notify", - "Rev": "0a148b8111d688ba7550fc7119fe0d5d8e650838" - }, - { - "ImportPath": "github.com/cactus/go-statsd-client/statsd", - "Rev": "3999011ef0451eb805b0fa31f98cfb9261bd71be" - }, - { - "ImportPath": "github.com/cihub/seelog", - "Comment": "go1.1-81-gc510775", - "Rev": "c510775bb50d98213cfafca75a4bc5e3fddc8d8f" - }, - { - "ImportPath": "github.com/coreos/go-etcd/etcd", - "Rev": "1e26d8ee84cf9b1000d2af8acfb45b2521f49be5" - }, { "ImportPath": "github.com/davecgh/go-spew/spew", "Rev": "e762b3d1320b76030bd7f6cc2bfc3d9acce874c0" }, { - "ImportPath": "github.com/gocql/gocql", - "Comment": "1st_gen_framing-221-gf8fb76b", - "Rev": "f8fb76bb772442ea938e4be46ab1666e542411a5" + "ImportPath": "github.com/gogo/protobuf/proto", + "Rev": "499788908625f4d83de42a204d1350fde8588e4f" }, { "ImportPath": "github.com/golang/groupcache/lru", "Rev": "d781998583680cda80cf61e0b37dd0cd8da2eb52" }, - { - "ImportPath": "github.com/golang/snappy", - "Rev": "723cc1e459b8eea2dea4583200fd60757d40097a" - }, - { - "ImportPath": "github.com/gorilla/websocket", - "Rev": "92334662baa9cbebc2e6e68b8d56bc1233f85a4c" - }, - { - "ImportPath": "github.com/kr/s3", - "Rev": "c070c8f9a8f0032d48f0d2a77d4e382788bd8a1d" - }, - { - "ImportPath": "github.com/robertkrimen/otto", - "Rev": "f9e07770bd9b5142de517b05a85ffbb42d1895da" - }, - { - "ImportPath": "github.com/stathat/consistent", - "Rev": "0262985f12333852b6423025aa3ca315af473a4a" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb", - "Rev": "183614d6b32571e867df4cf086f5480ceefbdfac" - }, { "ImportPath": "github.com/yasushi-saito/rbtree", "Rev": "571e2538414bf914c7e2909b61217b4e3e5508f4" - }, - { - "ImportPath": "gopkg.in/inf.v0", - "Rev": "c85f1217d51339c0fa3a498cc8b2075de695dae6" } ] } diff --git a/NOTES b/NOTES new file mode 100644 index 000000000..49d372099 --- /dev/null +++ b/NOTES @@ -0,0 +1,26 @@ + + DB Profile + ┌───────────▼────────────────────────────┐ + │0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ +Bitmap──▶0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ + │────────────────────────────────────────┤ + │0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ + │0000000000000000000000000000000000000000│ + │────────────────────────────────────────┤ + F ▶│0000000000000000000000000000000000000000│ + r ││0000000000000000000000000000000000000000│ + a ││0000000000000000000000000000000000000000│ + m ││0000000000000000000000000000000000000000│ + e ▶│0000000000000000000000000000000000000000│ + └────────────────────────────────────────┘ + ▲───────────▲ + Slice + + +Fragment=intersection of frame & slice diff --git a/README.md b/README.md index 6f46f6a54..4a172735b 100644 --- a/README.md +++ b/README.md @@ -24,28 +24,12 @@ Now you can install the `pilosa` binary: $ go install github.com/umbel/pilosa/... ``` -Pilosa requires that [etcd][] is running locally for coordinating the cluster: - -```sh -# In another terminal window -$ etcd -``` - Now run `pilosa` with the default configuration: ```sh pilosa ``` -This setup assumes that cassandra and etcd are running locally and that -cassandra keyspace pilosa has been setup as describe in the file -`index/storage_cass.go`. - -If you don't want backend storage you can comment out storage_backend in the -config file and it will just operate out of memory. - -[etcd]: https://github.com/coreos/etcd - ## Development @@ -68,9 +52,3 @@ $ godep save ./... [godep]: https://github.com/tools/godep -### Running tests - -Because of a bug in Go 1.5, you'll need to run `make test` to exclude tests -the the `vendor/` directory. - - diff --git a/benchmark_autogen_test.go b/benchmark_autogen_test.go deleted file mode 100644 index b9185ba44..000000000 --- a/benchmark_autogen_test.go +++ /dev/null @@ -1,8796 +0,0 @@ -package pilosa - -import ( - "math/rand" - "testing" -) - -const ( - c1 uint32 = 0xcc9e2d51 - c2 uint32 = 0x1b873593 -) - -func benchmarkDifferentCombinations(b *testing.B, op string, b1, b2 int, s1, s2 int) { - m1 := NewBitmap() - m2 := NewBitmap() - - bit := uint64(0) - rand.Seed(int64(c1)) - for i := 0; i < b1; i++ { - bit += uint64(rand.Intn(s1) + 1) - m1.SetBit(bit) - } - - bit = 0 - rand.Seed(int64(c2)) - for i := 0; i < b2; i++ { - bit += uint64(rand.Intn(s1) + 1) - m2.SetBit(bit) - } - - var f func(b_bm *Bitmap) *Bitmap - switch op { - case "and": - f = m1.Intersection - case "or": - f = m1.Union - case "diff": - f = m1.Difference - default: - return - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if f(m2) == nil { - b.Fatalf("Problem with %s benchmark at i = %d", op, i) - } - } -} -func Benchmark_and_64_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 64) -} - -func Benchmark_and_64_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 128) -} - -func Benchmark_and_64_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 256) -} - -func Benchmark_and_64_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 512) -} - -func Benchmark_and_64_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 1024) -} - -func Benchmark_and_64_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 8192) -} - -func Benchmark_and_64_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 16384) -} - -func Benchmark_and_64_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 32768) -} - -func Benchmark_and_64_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 64, 65536) -} - -func Benchmark_and_64_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 64) -} - -func Benchmark_and_64_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 128) -} - -func Benchmark_and_64_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 256) -} - -func Benchmark_and_64_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 512) -} - -func Benchmark_and_64_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 1024) -} - -func Benchmark_and_64_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 8192) -} - -func Benchmark_and_64_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 16384) -} - -func Benchmark_and_64_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 32768) -} - -func Benchmark_and_64_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 128, 65536) -} - -func Benchmark_and_64_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 64) -} - -func Benchmark_and_64_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 128) -} - -func Benchmark_and_64_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 256) -} - -func Benchmark_and_64_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 512) -} - -func Benchmark_and_64_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 1024) -} - -func Benchmark_and_64_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 8192) -} - -func Benchmark_and_64_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 16384) -} - -func Benchmark_and_64_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 32768) -} - -func Benchmark_and_64_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 256, 65536) -} - -func Benchmark_and_64_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 64) -} - -func Benchmark_and_64_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 128) -} - -func Benchmark_and_64_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 256) -} - -func Benchmark_and_64_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 512) -} - -func Benchmark_and_64_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 1024) -} - -func Benchmark_and_64_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 8192) -} - -func Benchmark_and_64_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 16384) -} - -func Benchmark_and_64_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 32768) -} - -func Benchmark_and_64_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 512, 65536) -} - -func Benchmark_and_64_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 64) -} - -func Benchmark_and_64_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 128) -} - -func Benchmark_and_64_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 256) -} - -func Benchmark_and_64_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 512) -} - -func Benchmark_and_64_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 1024) -} - -func Benchmark_and_64_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 8192) -} - -func Benchmark_and_64_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 16384) -} - -func Benchmark_and_64_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 32768) -} - -func Benchmark_and_64_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 1024, 65536) -} - -func Benchmark_and_64_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 64) -} - -func Benchmark_and_64_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 128) -} - -func Benchmark_and_64_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 256) -} - -func Benchmark_and_64_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 512) -} - -func Benchmark_and_64_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 1024) -} - -func Benchmark_and_64_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 8192) -} - -func Benchmark_and_64_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 16384) -} - -func Benchmark_and_64_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 32768) -} - -func Benchmark_and_64_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 8192, 65536) -} - -func Benchmark_and_64_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 64) -} - -func Benchmark_and_64_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 128) -} - -func Benchmark_and_64_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 256) -} - -func Benchmark_and_64_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 512) -} - -func Benchmark_and_64_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 1024) -} - -func Benchmark_and_64_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 8192) -} - -func Benchmark_and_64_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 16384) -} - -func Benchmark_and_64_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 32768) -} - -func Benchmark_and_64_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 16384, 65536) -} - -func Benchmark_and_64_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 64) -} - -func Benchmark_and_64_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 128) -} - -func Benchmark_and_64_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 256) -} - -func Benchmark_and_64_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 512) -} - -func Benchmark_and_64_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 1024) -} - -func Benchmark_and_64_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 8192) -} - -func Benchmark_and_64_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 16384) -} - -func Benchmark_and_64_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 32768) -} - -func Benchmark_and_64_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 32768, 65536) -} - -func Benchmark_and_64_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 64) -} - -func Benchmark_and_64_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 128) -} - -func Benchmark_and_64_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 256) -} - -func Benchmark_and_64_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 512) -} - -func Benchmark_and_64_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 1024) -} - -func Benchmark_and_64_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 8192) -} - -func Benchmark_and_64_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 16384) -} - -func Benchmark_and_64_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 32768) -} - -func Benchmark_and_64_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 64, 65536, 65536) -} - -func Benchmark_and_64_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 64) -} - -func Benchmark_and_64_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 128) -} - -func Benchmark_and_64_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 256) -} - -func Benchmark_and_64_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 512) -} - -func Benchmark_and_64_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 1024) -} - -func Benchmark_and_64_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 8192) -} - -func Benchmark_and_64_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 16384) -} - -func Benchmark_and_64_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 32768) -} - -func Benchmark_and_64_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 64, 65536) -} - -func Benchmark_and_64_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 64) -} - -func Benchmark_and_64_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 128) -} - -func Benchmark_and_64_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 256) -} - -func Benchmark_and_64_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 512) -} - -func Benchmark_and_64_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 1024) -} - -func Benchmark_and_64_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 8192) -} - -func Benchmark_and_64_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 16384) -} - -func Benchmark_and_64_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 32768) -} - -func Benchmark_and_64_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 128, 65536) -} - -func Benchmark_and_64_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 64) -} - -func Benchmark_and_64_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 128) -} - -func Benchmark_and_64_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 256) -} - -func Benchmark_and_64_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 512) -} - -func Benchmark_and_64_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 1024) -} - -func Benchmark_and_64_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 8192) -} - -func Benchmark_and_64_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 16384) -} - -func Benchmark_and_64_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 32768) -} - -func Benchmark_and_64_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 256, 65536) -} - -func Benchmark_and_64_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 64) -} - -func Benchmark_and_64_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 128) -} - -func Benchmark_and_64_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 256) -} - -func Benchmark_and_64_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 512) -} - -func Benchmark_and_64_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 1024) -} - -func Benchmark_and_64_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 8192) -} - -func Benchmark_and_64_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 16384) -} - -func Benchmark_and_64_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 32768) -} - -func Benchmark_and_64_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 512, 65536) -} - -func Benchmark_and_64_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 64) -} - -func Benchmark_and_64_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 128) -} - -func Benchmark_and_64_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 256) -} - -func Benchmark_and_64_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 512) -} - -func Benchmark_and_64_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 1024) -} - -func Benchmark_and_64_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 8192) -} - -func Benchmark_and_64_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 16384) -} - -func Benchmark_and_64_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 32768) -} - -func Benchmark_and_64_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 1024, 65536) -} - -func Benchmark_and_64_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 64) -} - -func Benchmark_and_64_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 128) -} - -func Benchmark_and_64_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 256) -} - -func Benchmark_and_64_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 512) -} - -func Benchmark_and_64_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 1024) -} - -func Benchmark_and_64_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 8192) -} - -func Benchmark_and_64_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 16384) -} - -func Benchmark_and_64_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 32768) -} - -func Benchmark_and_64_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 8192, 65536) -} - -func Benchmark_and_64_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 64) -} - -func Benchmark_and_64_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 128) -} - -func Benchmark_and_64_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 256) -} - -func Benchmark_and_64_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 512) -} - -func Benchmark_and_64_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 1024) -} - -func Benchmark_and_64_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 8192) -} - -func Benchmark_and_64_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 16384) -} - -func Benchmark_and_64_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 32768) -} - -func Benchmark_and_64_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 16384, 65536) -} - -func Benchmark_and_64_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 64) -} - -func Benchmark_and_64_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 128) -} - -func Benchmark_and_64_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 256) -} - -func Benchmark_and_64_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 512) -} - -func Benchmark_and_64_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 1024) -} - -func Benchmark_and_64_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 8192) -} - -func Benchmark_and_64_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 16384) -} - -func Benchmark_and_64_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 32768) -} - -func Benchmark_and_64_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 32768, 65536) -} - -func Benchmark_and_64_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 64) -} - -func Benchmark_and_64_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 128) -} - -func Benchmark_and_64_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 256) -} - -func Benchmark_and_64_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 512) -} - -func Benchmark_and_64_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 1024) -} - -func Benchmark_and_64_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 8192) -} - -func Benchmark_and_64_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 16384) -} - -func Benchmark_and_64_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 32768) -} - -func Benchmark_and_64_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 1024, 65536, 65536) -} - -func Benchmark_and_64_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 64) -} - -func Benchmark_and_64_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 128) -} - -func Benchmark_and_64_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 256) -} - -func Benchmark_and_64_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 512) -} - -func Benchmark_and_64_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 1024) -} - -func Benchmark_and_64_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 8192) -} - -func Benchmark_and_64_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 16384) -} - -func Benchmark_and_64_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 32768) -} - -func Benchmark_and_64_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 64, 65536) -} - -func Benchmark_and_64_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 64) -} - -func Benchmark_and_64_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 128) -} - -func Benchmark_and_64_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 256) -} - -func Benchmark_and_64_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 512) -} - -func Benchmark_and_64_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 1024) -} - -func Benchmark_and_64_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 8192) -} - -func Benchmark_and_64_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 16384) -} - -func Benchmark_and_64_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 32768) -} - -func Benchmark_and_64_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 128, 65536) -} - -func Benchmark_and_64_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 64) -} - -func Benchmark_and_64_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 128) -} - -func Benchmark_and_64_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 256) -} - -func Benchmark_and_64_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 512) -} - -func Benchmark_and_64_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 1024) -} - -func Benchmark_and_64_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 8192) -} - -func Benchmark_and_64_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 16384) -} - -func Benchmark_and_64_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 32768) -} - -func Benchmark_and_64_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 256, 65536) -} - -func Benchmark_and_64_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 64) -} - -func Benchmark_and_64_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 128) -} - -func Benchmark_and_64_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 256) -} - -func Benchmark_and_64_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 512) -} - -func Benchmark_and_64_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 1024) -} - -func Benchmark_and_64_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 8192) -} - -func Benchmark_and_64_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 16384) -} - -func Benchmark_and_64_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 32768) -} - -func Benchmark_and_64_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 512, 65536) -} - -func Benchmark_and_64_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 64) -} - -func Benchmark_and_64_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 128) -} - -func Benchmark_and_64_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 256) -} - -func Benchmark_and_64_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 512) -} - -func Benchmark_and_64_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 1024) -} - -func Benchmark_and_64_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 8192) -} - -func Benchmark_and_64_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 16384) -} - -func Benchmark_and_64_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 32768) -} - -func Benchmark_and_64_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 1024, 65536) -} - -func Benchmark_and_64_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 64) -} - -func Benchmark_and_64_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 128) -} - -func Benchmark_and_64_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 256) -} - -func Benchmark_and_64_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 512) -} - -func Benchmark_and_64_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 1024) -} - -func Benchmark_and_64_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 8192) -} - -func Benchmark_and_64_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 16384) -} - -func Benchmark_and_64_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 32768) -} - -func Benchmark_and_64_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 8192, 65536) -} - -func Benchmark_and_64_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 64) -} - -func Benchmark_and_64_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 128) -} - -func Benchmark_and_64_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 256) -} - -func Benchmark_and_64_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 512) -} - -func Benchmark_and_64_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 1024) -} - -func Benchmark_and_64_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 8192) -} - -func Benchmark_and_64_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 16384) -} - -func Benchmark_and_64_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 32768) -} - -func Benchmark_and_64_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 16384, 65536) -} - -func Benchmark_and_64_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 64) -} - -func Benchmark_and_64_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 128) -} - -func Benchmark_and_64_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 256) -} - -func Benchmark_and_64_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 512) -} - -func Benchmark_and_64_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 1024) -} - -func Benchmark_and_64_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 8192) -} - -func Benchmark_and_64_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 16384) -} - -func Benchmark_and_64_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 32768) -} - -func Benchmark_and_64_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 32768, 65536) -} - -func Benchmark_and_64_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 64) -} - -func Benchmark_and_64_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 128) -} - -func Benchmark_and_64_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 256) -} - -func Benchmark_and_64_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 512) -} - -func Benchmark_and_64_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 1024) -} - -func Benchmark_and_64_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 8192) -} - -func Benchmark_and_64_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 16384) -} - -func Benchmark_and_64_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 32768) -} - -func Benchmark_and_64_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 64, 65536, 65536, 65536) -} - -func Benchmark_and_1024_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 64) -} - -func Benchmark_and_1024_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 128) -} - -func Benchmark_and_1024_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 256) -} - -func Benchmark_and_1024_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 512) -} - -func Benchmark_and_1024_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 1024) -} - -func Benchmark_and_1024_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 8192) -} - -func Benchmark_and_1024_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 16384) -} - -func Benchmark_and_1024_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 32768) -} - -func Benchmark_and_1024_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 64, 65536) -} - -func Benchmark_and_1024_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 64) -} - -func Benchmark_and_1024_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 128) -} - -func Benchmark_and_1024_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 256) -} - -func Benchmark_and_1024_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 512) -} - -func Benchmark_and_1024_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 1024) -} - -func Benchmark_and_1024_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 8192) -} - -func Benchmark_and_1024_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 16384) -} - -func Benchmark_and_1024_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 32768) -} - -func Benchmark_and_1024_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 128, 65536) -} - -func Benchmark_and_1024_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 64) -} - -func Benchmark_and_1024_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 128) -} - -func Benchmark_and_1024_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 256) -} - -func Benchmark_and_1024_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 512) -} - -func Benchmark_and_1024_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 1024) -} - -func Benchmark_and_1024_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 8192) -} - -func Benchmark_and_1024_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 16384) -} - -func Benchmark_and_1024_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 32768) -} - -func Benchmark_and_1024_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 256, 65536) -} - -func Benchmark_and_1024_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 64) -} - -func Benchmark_and_1024_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 128) -} - -func Benchmark_and_1024_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 256) -} - -func Benchmark_and_1024_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 512) -} - -func Benchmark_and_1024_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 1024) -} - -func Benchmark_and_1024_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 8192) -} - -func Benchmark_and_1024_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 16384) -} - -func Benchmark_and_1024_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 32768) -} - -func Benchmark_and_1024_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 512, 65536) -} - -func Benchmark_and_1024_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 64) -} - -func Benchmark_and_1024_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 128) -} - -func Benchmark_and_1024_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 256) -} - -func Benchmark_and_1024_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 512) -} - -func Benchmark_and_1024_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 1024) -} - -func Benchmark_and_1024_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 8192) -} - -func Benchmark_and_1024_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 16384) -} - -func Benchmark_and_1024_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 32768) -} - -func Benchmark_and_1024_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 1024, 65536) -} - -func Benchmark_and_1024_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 64) -} - -func Benchmark_and_1024_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 128) -} - -func Benchmark_and_1024_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 256) -} - -func Benchmark_and_1024_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 512) -} - -func Benchmark_and_1024_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 1024) -} - -func Benchmark_and_1024_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 8192) -} - -func Benchmark_and_1024_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 16384) -} - -func Benchmark_and_1024_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 32768) -} - -func Benchmark_and_1024_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 8192, 65536) -} - -func Benchmark_and_1024_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 64) -} - -func Benchmark_and_1024_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 128) -} - -func Benchmark_and_1024_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 256) -} - -func Benchmark_and_1024_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 512) -} - -func Benchmark_and_1024_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 1024) -} - -func Benchmark_and_1024_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 8192) -} - -func Benchmark_and_1024_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 16384) -} - -func Benchmark_and_1024_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 32768) -} - -func Benchmark_and_1024_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 16384, 65536) -} - -func Benchmark_and_1024_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 64) -} - -func Benchmark_and_1024_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 128) -} - -func Benchmark_and_1024_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 256) -} - -func Benchmark_and_1024_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 512) -} - -func Benchmark_and_1024_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 1024) -} - -func Benchmark_and_1024_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 8192) -} - -func Benchmark_and_1024_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 16384) -} - -func Benchmark_and_1024_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 32768) -} - -func Benchmark_and_1024_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 32768, 65536) -} - -func Benchmark_and_1024_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 64) -} - -func Benchmark_and_1024_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 128) -} - -func Benchmark_and_1024_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 256) -} - -func Benchmark_and_1024_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 512) -} - -func Benchmark_and_1024_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 1024) -} - -func Benchmark_and_1024_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 8192) -} - -func Benchmark_and_1024_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 16384) -} - -func Benchmark_and_1024_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 32768) -} - -func Benchmark_and_1024_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 64, 65536, 65536) -} - -func Benchmark_and_1024_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 64) -} - -func Benchmark_and_1024_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 128) -} - -func Benchmark_and_1024_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 256) -} - -func Benchmark_and_1024_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 512) -} - -func Benchmark_and_1024_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 1024) -} - -func Benchmark_and_1024_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 8192) -} - -func Benchmark_and_1024_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 16384) -} - -func Benchmark_and_1024_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 32768) -} - -func Benchmark_and_1024_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 64, 65536) -} - -func Benchmark_and_1024_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 64) -} - -func Benchmark_and_1024_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 128) -} - -func Benchmark_and_1024_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 256) -} - -func Benchmark_and_1024_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 512) -} - -func Benchmark_and_1024_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 1024) -} - -func Benchmark_and_1024_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 8192) -} - -func Benchmark_and_1024_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 16384) -} - -func Benchmark_and_1024_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 32768) -} - -func Benchmark_and_1024_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 128, 65536) -} - -func Benchmark_and_1024_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 64) -} - -func Benchmark_and_1024_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 128) -} - -func Benchmark_and_1024_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 256) -} - -func Benchmark_and_1024_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 512) -} - -func Benchmark_and_1024_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 1024) -} - -func Benchmark_and_1024_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 8192) -} - -func Benchmark_and_1024_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 16384) -} - -func Benchmark_and_1024_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 32768) -} - -func Benchmark_and_1024_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 256, 65536) -} - -func Benchmark_and_1024_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 64) -} - -func Benchmark_and_1024_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 128) -} - -func Benchmark_and_1024_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 256) -} - -func Benchmark_and_1024_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 512) -} - -func Benchmark_and_1024_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 1024) -} - -func Benchmark_and_1024_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 8192) -} - -func Benchmark_and_1024_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 16384) -} - -func Benchmark_and_1024_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 32768) -} - -func Benchmark_and_1024_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 512, 65536) -} - -func Benchmark_and_1024_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 64) -} - -func Benchmark_and_1024_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 128) -} - -func Benchmark_and_1024_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 256) -} - -func Benchmark_and_1024_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 512) -} - -func Benchmark_and_1024_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 1024) -} - -func Benchmark_and_1024_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 8192) -} - -func Benchmark_and_1024_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 16384) -} - -func Benchmark_and_1024_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 32768) -} - -func Benchmark_and_1024_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 1024, 65536) -} - -func Benchmark_and_1024_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 64) -} - -func Benchmark_and_1024_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 128) -} - -func Benchmark_and_1024_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 256) -} - -func Benchmark_and_1024_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 512) -} - -func Benchmark_and_1024_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 1024) -} - -func Benchmark_and_1024_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 8192) -} - -func Benchmark_and_1024_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 16384) -} - -func Benchmark_and_1024_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 32768) -} - -func Benchmark_and_1024_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 8192, 65536) -} - -func Benchmark_and_1024_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 64) -} - -func Benchmark_and_1024_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 128) -} - -func Benchmark_and_1024_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 256) -} - -func Benchmark_and_1024_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 512) -} - -func Benchmark_and_1024_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 1024) -} - -func Benchmark_and_1024_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 8192) -} - -func Benchmark_and_1024_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 16384) -} - -func Benchmark_and_1024_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 32768) -} - -func Benchmark_and_1024_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 16384, 65536) -} - -func Benchmark_and_1024_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 64) -} - -func Benchmark_and_1024_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 128) -} - -func Benchmark_and_1024_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 256) -} - -func Benchmark_and_1024_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 512) -} - -func Benchmark_and_1024_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 1024) -} - -func Benchmark_and_1024_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 8192) -} - -func Benchmark_and_1024_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 16384) -} - -func Benchmark_and_1024_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 32768) -} - -func Benchmark_and_1024_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 32768, 65536) -} - -func Benchmark_and_1024_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 64) -} - -func Benchmark_and_1024_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 128) -} - -func Benchmark_and_1024_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 256) -} - -func Benchmark_and_1024_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 512) -} - -func Benchmark_and_1024_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 1024) -} - -func Benchmark_and_1024_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 8192) -} - -func Benchmark_and_1024_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 16384) -} - -func Benchmark_and_1024_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 32768) -} - -func Benchmark_and_1024_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 1024, 65536, 65536) -} - -func Benchmark_and_1024_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 64) -} - -func Benchmark_and_1024_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 128) -} - -func Benchmark_and_1024_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 256) -} - -func Benchmark_and_1024_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 512) -} - -func Benchmark_and_1024_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 1024) -} - -func Benchmark_and_1024_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 8192) -} - -func Benchmark_and_1024_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 16384) -} - -func Benchmark_and_1024_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 32768) -} - -func Benchmark_and_1024_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 64, 65536) -} - -func Benchmark_and_1024_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 64) -} - -func Benchmark_and_1024_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 128) -} - -func Benchmark_and_1024_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 256) -} - -func Benchmark_and_1024_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 512) -} - -func Benchmark_and_1024_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 1024) -} - -func Benchmark_and_1024_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 8192) -} - -func Benchmark_and_1024_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 16384) -} - -func Benchmark_and_1024_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 32768) -} - -func Benchmark_and_1024_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 128, 65536) -} - -func Benchmark_and_1024_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 64) -} - -func Benchmark_and_1024_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 128) -} - -func Benchmark_and_1024_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 256) -} - -func Benchmark_and_1024_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 512) -} - -func Benchmark_and_1024_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 1024) -} - -func Benchmark_and_1024_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 8192) -} - -func Benchmark_and_1024_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 16384) -} - -func Benchmark_and_1024_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 32768) -} - -func Benchmark_and_1024_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 256, 65536) -} - -func Benchmark_and_1024_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 64) -} - -func Benchmark_and_1024_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 128) -} - -func Benchmark_and_1024_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 256) -} - -func Benchmark_and_1024_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 512) -} - -func Benchmark_and_1024_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 1024) -} - -func Benchmark_and_1024_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 8192) -} - -func Benchmark_and_1024_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 16384) -} - -func Benchmark_and_1024_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 32768) -} - -func Benchmark_and_1024_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 512, 65536) -} - -func Benchmark_and_1024_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 64) -} - -func Benchmark_and_1024_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 128) -} - -func Benchmark_and_1024_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 256) -} - -func Benchmark_and_1024_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 512) -} - -func Benchmark_and_1024_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 1024) -} - -func Benchmark_and_1024_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 8192) -} - -func Benchmark_and_1024_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 16384) -} - -func Benchmark_and_1024_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 32768) -} - -func Benchmark_and_1024_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 1024, 65536) -} - -func Benchmark_and_1024_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 64) -} - -func Benchmark_and_1024_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 128) -} - -func Benchmark_and_1024_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 256) -} - -func Benchmark_and_1024_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 512) -} - -func Benchmark_and_1024_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 1024) -} - -func Benchmark_and_1024_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 8192) -} - -func Benchmark_and_1024_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 16384) -} - -func Benchmark_and_1024_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 32768) -} - -func Benchmark_and_1024_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 8192, 65536) -} - -func Benchmark_and_1024_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 64) -} - -func Benchmark_and_1024_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 128) -} - -func Benchmark_and_1024_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 256) -} - -func Benchmark_and_1024_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 512) -} - -func Benchmark_and_1024_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 1024) -} - -func Benchmark_and_1024_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 8192) -} - -func Benchmark_and_1024_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 16384) -} - -func Benchmark_and_1024_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 32768) -} - -func Benchmark_and_1024_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 16384, 65536) -} - -func Benchmark_and_1024_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 64) -} - -func Benchmark_and_1024_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 128) -} - -func Benchmark_and_1024_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 256) -} - -func Benchmark_and_1024_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 512) -} - -func Benchmark_and_1024_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 1024) -} - -func Benchmark_and_1024_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 8192) -} - -func Benchmark_and_1024_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 16384) -} - -func Benchmark_and_1024_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 32768) -} - -func Benchmark_and_1024_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 32768, 65536) -} - -func Benchmark_and_1024_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 64) -} - -func Benchmark_and_1024_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 128) -} - -func Benchmark_and_1024_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 256) -} - -func Benchmark_and_1024_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 512) -} - -func Benchmark_and_1024_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 1024) -} - -func Benchmark_and_1024_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 8192) -} - -func Benchmark_and_1024_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 16384) -} - -func Benchmark_and_1024_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 32768) -} - -func Benchmark_and_1024_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 1024, 65536, 65536, 65536) -} - -func Benchmark_and_65536_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 64) -} - -func Benchmark_and_65536_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 128) -} - -func Benchmark_and_65536_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 256) -} - -func Benchmark_and_65536_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 512) -} - -func Benchmark_and_65536_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 1024) -} - -func Benchmark_and_65536_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 8192) -} - -func Benchmark_and_65536_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 16384) -} - -func Benchmark_and_65536_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 32768) -} - -func Benchmark_and_65536_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 64, 65536) -} - -func Benchmark_and_65536_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 64) -} - -func Benchmark_and_65536_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 128) -} - -func Benchmark_and_65536_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 256) -} - -func Benchmark_and_65536_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 512) -} - -func Benchmark_and_65536_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 1024) -} - -func Benchmark_and_65536_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 8192) -} - -func Benchmark_and_65536_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 16384) -} - -func Benchmark_and_65536_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 32768) -} - -func Benchmark_and_65536_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 128, 65536) -} - -func Benchmark_and_65536_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 64) -} - -func Benchmark_and_65536_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 128) -} - -func Benchmark_and_65536_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 256) -} - -func Benchmark_and_65536_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 512) -} - -func Benchmark_and_65536_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 1024) -} - -func Benchmark_and_65536_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 8192) -} - -func Benchmark_and_65536_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 16384) -} - -func Benchmark_and_65536_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 32768) -} - -func Benchmark_and_65536_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 256, 65536) -} - -func Benchmark_and_65536_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 64) -} - -func Benchmark_and_65536_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 128) -} - -func Benchmark_and_65536_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 256) -} - -func Benchmark_and_65536_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 512) -} - -func Benchmark_and_65536_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 1024) -} - -func Benchmark_and_65536_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 8192) -} - -func Benchmark_and_65536_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 16384) -} - -func Benchmark_and_65536_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 32768) -} - -func Benchmark_and_65536_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 512, 65536) -} - -func Benchmark_and_65536_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 64) -} - -func Benchmark_and_65536_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 128) -} - -func Benchmark_and_65536_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 256) -} - -func Benchmark_and_65536_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 512) -} - -func Benchmark_and_65536_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 1024) -} - -func Benchmark_and_65536_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 8192) -} - -func Benchmark_and_65536_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 16384) -} - -func Benchmark_and_65536_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 32768) -} - -func Benchmark_and_65536_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 1024, 65536) -} - -func Benchmark_and_65536_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 64) -} - -func Benchmark_and_65536_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 128) -} - -func Benchmark_and_65536_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 256) -} - -func Benchmark_and_65536_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 512) -} - -func Benchmark_and_65536_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 1024) -} - -func Benchmark_and_65536_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 8192) -} - -func Benchmark_and_65536_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 16384) -} - -func Benchmark_and_65536_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 32768) -} - -func Benchmark_and_65536_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 8192, 65536) -} - -func Benchmark_and_65536_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 64) -} - -func Benchmark_and_65536_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 128) -} - -func Benchmark_and_65536_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 256) -} - -func Benchmark_and_65536_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 512) -} - -func Benchmark_and_65536_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 1024) -} - -func Benchmark_and_65536_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 8192) -} - -func Benchmark_and_65536_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 16384) -} - -func Benchmark_and_65536_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 32768) -} - -func Benchmark_and_65536_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 16384, 65536) -} - -func Benchmark_and_65536_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 64) -} - -func Benchmark_and_65536_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 128) -} - -func Benchmark_and_65536_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 256) -} - -func Benchmark_and_65536_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 512) -} - -func Benchmark_and_65536_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 1024) -} - -func Benchmark_and_65536_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 8192) -} - -func Benchmark_and_65536_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 16384) -} - -func Benchmark_and_65536_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 32768) -} - -func Benchmark_and_65536_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 32768, 65536) -} - -func Benchmark_and_65536_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 64) -} - -func Benchmark_and_65536_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 128) -} - -func Benchmark_and_65536_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 256) -} - -func Benchmark_and_65536_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 512) -} - -func Benchmark_and_65536_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 1024) -} - -func Benchmark_and_65536_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 8192) -} - -func Benchmark_and_65536_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 16384) -} - -func Benchmark_and_65536_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 32768) -} - -func Benchmark_and_65536_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 64, 65536, 65536) -} - -func Benchmark_and_65536_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 64) -} - -func Benchmark_and_65536_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 128) -} - -func Benchmark_and_65536_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 256) -} - -func Benchmark_and_65536_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 512) -} - -func Benchmark_and_65536_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 1024) -} - -func Benchmark_and_65536_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 8192) -} - -func Benchmark_and_65536_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 16384) -} - -func Benchmark_and_65536_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 32768) -} - -func Benchmark_and_65536_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 64, 65536) -} - -func Benchmark_and_65536_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 64) -} - -func Benchmark_and_65536_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 128) -} - -func Benchmark_and_65536_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 256) -} - -func Benchmark_and_65536_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 512) -} - -func Benchmark_and_65536_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 1024) -} - -func Benchmark_and_65536_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 8192) -} - -func Benchmark_and_65536_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 16384) -} - -func Benchmark_and_65536_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 32768) -} - -func Benchmark_and_65536_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 128, 65536) -} - -func Benchmark_and_65536_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 64) -} - -func Benchmark_and_65536_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 128) -} - -func Benchmark_and_65536_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 256) -} - -func Benchmark_and_65536_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 512) -} - -func Benchmark_and_65536_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 1024) -} - -func Benchmark_and_65536_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 8192) -} - -func Benchmark_and_65536_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 16384) -} - -func Benchmark_and_65536_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 32768) -} - -func Benchmark_and_65536_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 256, 65536) -} - -func Benchmark_and_65536_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 64) -} - -func Benchmark_and_65536_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 128) -} - -func Benchmark_and_65536_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 256) -} - -func Benchmark_and_65536_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 512) -} - -func Benchmark_and_65536_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 1024) -} - -func Benchmark_and_65536_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 8192) -} - -func Benchmark_and_65536_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 16384) -} - -func Benchmark_and_65536_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 32768) -} - -func Benchmark_and_65536_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 512, 65536) -} - -func Benchmark_and_65536_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 64) -} - -func Benchmark_and_65536_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 128) -} - -func Benchmark_and_65536_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 256) -} - -func Benchmark_and_65536_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 512) -} - -func Benchmark_and_65536_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 1024) -} - -func Benchmark_and_65536_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 8192) -} - -func Benchmark_and_65536_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 16384) -} - -func Benchmark_and_65536_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 32768) -} - -func Benchmark_and_65536_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 1024, 65536) -} - -func Benchmark_and_65536_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 64) -} - -func Benchmark_and_65536_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 128) -} - -func Benchmark_and_65536_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 256) -} - -func Benchmark_and_65536_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 512) -} - -func Benchmark_and_65536_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 1024) -} - -func Benchmark_and_65536_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 8192) -} - -func Benchmark_and_65536_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 16384) -} - -func Benchmark_and_65536_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 32768) -} - -func Benchmark_and_65536_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 8192, 65536) -} - -func Benchmark_and_65536_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 64) -} - -func Benchmark_and_65536_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 128) -} - -func Benchmark_and_65536_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 256) -} - -func Benchmark_and_65536_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 512) -} - -func Benchmark_and_65536_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 1024) -} - -func Benchmark_and_65536_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 8192) -} - -func Benchmark_and_65536_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 16384) -} - -func Benchmark_and_65536_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 32768) -} - -func Benchmark_and_65536_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 16384, 65536) -} - -func Benchmark_and_65536_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 64) -} - -func Benchmark_and_65536_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 128) -} - -func Benchmark_and_65536_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 256) -} - -func Benchmark_and_65536_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 512) -} - -func Benchmark_and_65536_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 1024) -} - -func Benchmark_and_65536_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 8192) -} - -func Benchmark_and_65536_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 16384) -} - -func Benchmark_and_65536_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 32768) -} - -func Benchmark_and_65536_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 32768, 65536) -} - -func Benchmark_and_65536_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 64) -} - -func Benchmark_and_65536_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 128) -} - -func Benchmark_and_65536_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 256) -} - -func Benchmark_and_65536_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 512) -} - -func Benchmark_and_65536_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 1024) -} - -func Benchmark_and_65536_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 8192) -} - -func Benchmark_and_65536_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 16384) -} - -func Benchmark_and_65536_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 32768) -} - -func Benchmark_and_65536_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 1024, 65536, 65536) -} - -func Benchmark_and_65536_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 64) -} - -func Benchmark_and_65536_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 128) -} - -func Benchmark_and_65536_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 256) -} - -func Benchmark_and_65536_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 512) -} - -func Benchmark_and_65536_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 1024) -} - -func Benchmark_and_65536_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 8192) -} - -func Benchmark_and_65536_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 16384) -} - -func Benchmark_and_65536_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 32768) -} - -func Benchmark_and_65536_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 64, 65536) -} - -func Benchmark_and_65536_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 64) -} - -func Benchmark_and_65536_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 128) -} - -func Benchmark_and_65536_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 256) -} - -func Benchmark_and_65536_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 512) -} - -func Benchmark_and_65536_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 1024) -} - -func Benchmark_and_65536_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 8192) -} - -func Benchmark_and_65536_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 16384) -} - -func Benchmark_and_65536_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 32768) -} - -func Benchmark_and_65536_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 128, 65536) -} - -func Benchmark_and_65536_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 64) -} - -func Benchmark_and_65536_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 128) -} - -func Benchmark_and_65536_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 256) -} - -func Benchmark_and_65536_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 512) -} - -func Benchmark_and_65536_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 1024) -} - -func Benchmark_and_65536_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 8192) -} - -func Benchmark_and_65536_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 16384) -} - -func Benchmark_and_65536_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 32768) -} - -func Benchmark_and_65536_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 256, 65536) -} - -func Benchmark_and_65536_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 64) -} - -func Benchmark_and_65536_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 128) -} - -func Benchmark_and_65536_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 256) -} - -func Benchmark_and_65536_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 512) -} - -func Benchmark_and_65536_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 1024) -} - -func Benchmark_and_65536_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 8192) -} - -func Benchmark_and_65536_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 16384) -} - -func Benchmark_and_65536_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 32768) -} - -func Benchmark_and_65536_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 512, 65536) -} - -func Benchmark_and_65536_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 64) -} - -func Benchmark_and_65536_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 128) -} - -func Benchmark_and_65536_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 256) -} - -func Benchmark_and_65536_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 512) -} - -func Benchmark_and_65536_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 1024) -} - -func Benchmark_and_65536_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 8192) -} - -func Benchmark_and_65536_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 16384) -} - -func Benchmark_and_65536_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 32768) -} - -func Benchmark_and_65536_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 1024, 65536) -} - -func Benchmark_and_65536_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 64) -} - -func Benchmark_and_65536_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 128) -} - -func Benchmark_and_65536_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 256) -} - -func Benchmark_and_65536_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 512) -} - -func Benchmark_and_65536_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 1024) -} - -func Benchmark_and_65536_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 8192) -} - -func Benchmark_and_65536_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 16384) -} - -func Benchmark_and_65536_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 32768) -} - -func Benchmark_and_65536_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 8192, 65536) -} - -func Benchmark_and_65536_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 64) -} - -func Benchmark_and_65536_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 128) -} - -func Benchmark_and_65536_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 256) -} - -func Benchmark_and_65536_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 512) -} - -func Benchmark_and_65536_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 1024) -} - -func Benchmark_and_65536_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 8192) -} - -func Benchmark_and_65536_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 16384) -} - -func Benchmark_and_65536_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 32768) -} - -func Benchmark_and_65536_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 16384, 65536) -} - -func Benchmark_and_65536_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 64) -} - -func Benchmark_and_65536_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 128) -} - -func Benchmark_and_65536_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 256) -} - -func Benchmark_and_65536_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 512) -} - -func Benchmark_and_65536_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 1024) -} - -func Benchmark_and_65536_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 8192) -} - -func Benchmark_and_65536_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 16384) -} - -func Benchmark_and_65536_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 32768) -} - -func Benchmark_and_65536_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 32768, 65536) -} - -func Benchmark_and_65536_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 64) -} - -func Benchmark_and_65536_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 128) -} - -func Benchmark_and_65536_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 256) -} - -func Benchmark_and_65536_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 512) -} - -func Benchmark_and_65536_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 1024) -} - -func Benchmark_and_65536_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 8192) -} - -func Benchmark_and_65536_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 16384) -} - -func Benchmark_and_65536_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 32768) -} - -func Benchmark_and_65536_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "and", 65536, 65536, 65536, 65536) -} - -func Benchmark_or_64_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 64) -} - -func Benchmark_or_64_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 128) -} - -func Benchmark_or_64_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 256) -} - -func Benchmark_or_64_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 512) -} - -func Benchmark_or_64_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 1024) -} - -func Benchmark_or_64_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 8192) -} - -func Benchmark_or_64_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 16384) -} - -func Benchmark_or_64_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 32768) -} - -func Benchmark_or_64_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 64, 65536) -} - -func Benchmark_or_64_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 64) -} - -func Benchmark_or_64_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 128) -} - -func Benchmark_or_64_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 256) -} - -func Benchmark_or_64_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 512) -} - -func Benchmark_or_64_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 1024) -} - -func Benchmark_or_64_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 8192) -} - -func Benchmark_or_64_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 16384) -} - -func Benchmark_or_64_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 32768) -} - -func Benchmark_or_64_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 128, 65536) -} - -func Benchmark_or_64_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 64) -} - -func Benchmark_or_64_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 128) -} - -func Benchmark_or_64_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 256) -} - -func Benchmark_or_64_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 512) -} - -func Benchmark_or_64_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 1024) -} - -func Benchmark_or_64_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 8192) -} - -func Benchmark_or_64_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 16384) -} - -func Benchmark_or_64_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 32768) -} - -func Benchmark_or_64_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 256, 65536) -} - -func Benchmark_or_64_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 64) -} - -func Benchmark_or_64_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 128) -} - -func Benchmark_or_64_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 256) -} - -func Benchmark_or_64_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 512) -} - -func Benchmark_or_64_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 1024) -} - -func Benchmark_or_64_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 8192) -} - -func Benchmark_or_64_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 16384) -} - -func Benchmark_or_64_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 32768) -} - -func Benchmark_or_64_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 512, 65536) -} - -func Benchmark_or_64_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 64) -} - -func Benchmark_or_64_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 128) -} - -func Benchmark_or_64_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 256) -} - -func Benchmark_or_64_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 512) -} - -func Benchmark_or_64_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 1024) -} - -func Benchmark_or_64_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 8192) -} - -func Benchmark_or_64_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 16384) -} - -func Benchmark_or_64_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 32768) -} - -func Benchmark_or_64_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 1024, 65536) -} - -func Benchmark_or_64_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 64) -} - -func Benchmark_or_64_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 128) -} - -func Benchmark_or_64_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 256) -} - -func Benchmark_or_64_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 512) -} - -func Benchmark_or_64_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 1024) -} - -func Benchmark_or_64_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 8192) -} - -func Benchmark_or_64_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 16384) -} - -func Benchmark_or_64_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 32768) -} - -func Benchmark_or_64_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 8192, 65536) -} - -func Benchmark_or_64_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 64) -} - -func Benchmark_or_64_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 128) -} - -func Benchmark_or_64_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 256) -} - -func Benchmark_or_64_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 512) -} - -func Benchmark_or_64_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 1024) -} - -func Benchmark_or_64_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 8192) -} - -func Benchmark_or_64_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 16384) -} - -func Benchmark_or_64_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 32768) -} - -func Benchmark_or_64_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 16384, 65536) -} - -func Benchmark_or_64_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 64) -} - -func Benchmark_or_64_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 128) -} - -func Benchmark_or_64_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 256) -} - -func Benchmark_or_64_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 512) -} - -func Benchmark_or_64_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 1024) -} - -func Benchmark_or_64_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 8192) -} - -func Benchmark_or_64_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 16384) -} - -func Benchmark_or_64_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 32768) -} - -func Benchmark_or_64_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 32768, 65536) -} - -func Benchmark_or_64_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 64) -} - -func Benchmark_or_64_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 128) -} - -func Benchmark_or_64_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 256) -} - -func Benchmark_or_64_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 512) -} - -func Benchmark_or_64_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 1024) -} - -func Benchmark_or_64_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 8192) -} - -func Benchmark_or_64_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 16384) -} - -func Benchmark_or_64_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 32768) -} - -func Benchmark_or_64_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 64, 65536, 65536) -} - -func Benchmark_or_64_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 64) -} - -func Benchmark_or_64_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 128) -} - -func Benchmark_or_64_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 256) -} - -func Benchmark_or_64_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 512) -} - -func Benchmark_or_64_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 1024) -} - -func Benchmark_or_64_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 8192) -} - -func Benchmark_or_64_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 16384) -} - -func Benchmark_or_64_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 32768) -} - -func Benchmark_or_64_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 64, 65536) -} - -func Benchmark_or_64_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 64) -} - -func Benchmark_or_64_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 128) -} - -func Benchmark_or_64_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 256) -} - -func Benchmark_or_64_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 512) -} - -func Benchmark_or_64_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 1024) -} - -func Benchmark_or_64_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 8192) -} - -func Benchmark_or_64_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 16384) -} - -func Benchmark_or_64_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 32768) -} - -func Benchmark_or_64_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 128, 65536) -} - -func Benchmark_or_64_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 64) -} - -func Benchmark_or_64_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 128) -} - -func Benchmark_or_64_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 256) -} - -func Benchmark_or_64_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 512) -} - -func Benchmark_or_64_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 1024) -} - -func Benchmark_or_64_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 8192) -} - -func Benchmark_or_64_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 16384) -} - -func Benchmark_or_64_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 32768) -} - -func Benchmark_or_64_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 256, 65536) -} - -func Benchmark_or_64_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 64) -} - -func Benchmark_or_64_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 128) -} - -func Benchmark_or_64_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 256) -} - -func Benchmark_or_64_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 512) -} - -func Benchmark_or_64_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 1024) -} - -func Benchmark_or_64_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 8192) -} - -func Benchmark_or_64_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 16384) -} - -func Benchmark_or_64_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 32768) -} - -func Benchmark_or_64_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 512, 65536) -} - -func Benchmark_or_64_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 64) -} - -func Benchmark_or_64_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 128) -} - -func Benchmark_or_64_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 256) -} - -func Benchmark_or_64_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 512) -} - -func Benchmark_or_64_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 1024) -} - -func Benchmark_or_64_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 8192) -} - -func Benchmark_or_64_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 16384) -} - -func Benchmark_or_64_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 32768) -} - -func Benchmark_or_64_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 1024, 65536) -} - -func Benchmark_or_64_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 64) -} - -func Benchmark_or_64_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 128) -} - -func Benchmark_or_64_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 256) -} - -func Benchmark_or_64_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 512) -} - -func Benchmark_or_64_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 1024) -} - -func Benchmark_or_64_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 8192) -} - -func Benchmark_or_64_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 16384) -} - -func Benchmark_or_64_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 32768) -} - -func Benchmark_or_64_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 8192, 65536) -} - -func Benchmark_or_64_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 64) -} - -func Benchmark_or_64_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 128) -} - -func Benchmark_or_64_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 256) -} - -func Benchmark_or_64_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 512) -} - -func Benchmark_or_64_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 1024) -} - -func Benchmark_or_64_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 8192) -} - -func Benchmark_or_64_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 16384) -} - -func Benchmark_or_64_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 32768) -} - -func Benchmark_or_64_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 16384, 65536) -} - -func Benchmark_or_64_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 64) -} - -func Benchmark_or_64_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 128) -} - -func Benchmark_or_64_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 256) -} - -func Benchmark_or_64_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 512) -} - -func Benchmark_or_64_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 1024) -} - -func Benchmark_or_64_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 8192) -} - -func Benchmark_or_64_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 16384) -} - -func Benchmark_or_64_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 32768) -} - -func Benchmark_or_64_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 32768, 65536) -} - -func Benchmark_or_64_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 64) -} - -func Benchmark_or_64_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 128) -} - -func Benchmark_or_64_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 256) -} - -func Benchmark_or_64_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 512) -} - -func Benchmark_or_64_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 1024) -} - -func Benchmark_or_64_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 8192) -} - -func Benchmark_or_64_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 16384) -} - -func Benchmark_or_64_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 32768) -} - -func Benchmark_or_64_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 1024, 65536, 65536) -} - -func Benchmark_or_64_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 64) -} - -func Benchmark_or_64_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 128) -} - -func Benchmark_or_64_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 256) -} - -func Benchmark_or_64_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 512) -} - -func Benchmark_or_64_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 1024) -} - -func Benchmark_or_64_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 8192) -} - -func Benchmark_or_64_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 16384) -} - -func Benchmark_or_64_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 32768) -} - -func Benchmark_or_64_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 64, 65536) -} - -func Benchmark_or_64_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 64) -} - -func Benchmark_or_64_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 128) -} - -func Benchmark_or_64_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 256) -} - -func Benchmark_or_64_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 512) -} - -func Benchmark_or_64_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 1024) -} - -func Benchmark_or_64_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 8192) -} - -func Benchmark_or_64_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 16384) -} - -func Benchmark_or_64_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 32768) -} - -func Benchmark_or_64_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 128, 65536) -} - -func Benchmark_or_64_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 64) -} - -func Benchmark_or_64_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 128) -} - -func Benchmark_or_64_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 256) -} - -func Benchmark_or_64_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 512) -} - -func Benchmark_or_64_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 1024) -} - -func Benchmark_or_64_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 8192) -} - -func Benchmark_or_64_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 16384) -} - -func Benchmark_or_64_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 32768) -} - -func Benchmark_or_64_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 256, 65536) -} - -func Benchmark_or_64_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 64) -} - -func Benchmark_or_64_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 128) -} - -func Benchmark_or_64_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 256) -} - -func Benchmark_or_64_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 512) -} - -func Benchmark_or_64_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 1024) -} - -func Benchmark_or_64_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 8192) -} - -func Benchmark_or_64_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 16384) -} - -func Benchmark_or_64_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 32768) -} - -func Benchmark_or_64_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 512, 65536) -} - -func Benchmark_or_64_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 64) -} - -func Benchmark_or_64_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 128) -} - -func Benchmark_or_64_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 256) -} - -func Benchmark_or_64_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 512) -} - -func Benchmark_or_64_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 1024) -} - -func Benchmark_or_64_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 8192) -} - -func Benchmark_or_64_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 16384) -} - -func Benchmark_or_64_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 32768) -} - -func Benchmark_or_64_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 1024, 65536) -} - -func Benchmark_or_64_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 64) -} - -func Benchmark_or_64_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 128) -} - -func Benchmark_or_64_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 256) -} - -func Benchmark_or_64_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 512) -} - -func Benchmark_or_64_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 1024) -} - -func Benchmark_or_64_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 8192) -} - -func Benchmark_or_64_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 16384) -} - -func Benchmark_or_64_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 32768) -} - -func Benchmark_or_64_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 8192, 65536) -} - -func Benchmark_or_64_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 64) -} - -func Benchmark_or_64_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 128) -} - -func Benchmark_or_64_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 256) -} - -func Benchmark_or_64_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 512) -} - -func Benchmark_or_64_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 1024) -} - -func Benchmark_or_64_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 8192) -} - -func Benchmark_or_64_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 16384) -} - -func Benchmark_or_64_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 32768) -} - -func Benchmark_or_64_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 16384, 65536) -} - -func Benchmark_or_64_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 64) -} - -func Benchmark_or_64_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 128) -} - -func Benchmark_or_64_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 256) -} - -func Benchmark_or_64_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 512) -} - -func Benchmark_or_64_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 1024) -} - -func Benchmark_or_64_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 8192) -} - -func Benchmark_or_64_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 16384) -} - -func Benchmark_or_64_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 32768) -} - -func Benchmark_or_64_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 32768, 65536) -} - -func Benchmark_or_64_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 64) -} - -func Benchmark_or_64_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 128) -} - -func Benchmark_or_64_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 256) -} - -func Benchmark_or_64_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 512) -} - -func Benchmark_or_64_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 1024) -} - -func Benchmark_or_64_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 8192) -} - -func Benchmark_or_64_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 16384) -} - -func Benchmark_or_64_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 32768) -} - -func Benchmark_or_64_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 64, 65536, 65536, 65536) -} - -func Benchmark_or_1024_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 64) -} - -func Benchmark_or_1024_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 128) -} - -func Benchmark_or_1024_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 256) -} - -func Benchmark_or_1024_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 512) -} - -func Benchmark_or_1024_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 1024) -} - -func Benchmark_or_1024_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 8192) -} - -func Benchmark_or_1024_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 16384) -} - -func Benchmark_or_1024_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 32768) -} - -func Benchmark_or_1024_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 64, 65536) -} - -func Benchmark_or_1024_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 64) -} - -func Benchmark_or_1024_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 128) -} - -func Benchmark_or_1024_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 256) -} - -func Benchmark_or_1024_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 512) -} - -func Benchmark_or_1024_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 1024) -} - -func Benchmark_or_1024_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 8192) -} - -func Benchmark_or_1024_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 16384) -} - -func Benchmark_or_1024_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 32768) -} - -func Benchmark_or_1024_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 128, 65536) -} - -func Benchmark_or_1024_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 64) -} - -func Benchmark_or_1024_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 128) -} - -func Benchmark_or_1024_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 256) -} - -func Benchmark_or_1024_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 512) -} - -func Benchmark_or_1024_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 1024) -} - -func Benchmark_or_1024_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 8192) -} - -func Benchmark_or_1024_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 16384) -} - -func Benchmark_or_1024_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 32768) -} - -func Benchmark_or_1024_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 256, 65536) -} - -func Benchmark_or_1024_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 64) -} - -func Benchmark_or_1024_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 128) -} - -func Benchmark_or_1024_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 256) -} - -func Benchmark_or_1024_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 512) -} - -func Benchmark_or_1024_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 1024) -} - -func Benchmark_or_1024_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 8192) -} - -func Benchmark_or_1024_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 16384) -} - -func Benchmark_or_1024_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 32768) -} - -func Benchmark_or_1024_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 512, 65536) -} - -func Benchmark_or_1024_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 64) -} - -func Benchmark_or_1024_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 128) -} - -func Benchmark_or_1024_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 256) -} - -func Benchmark_or_1024_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 512) -} - -func Benchmark_or_1024_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 1024) -} - -func Benchmark_or_1024_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 8192) -} - -func Benchmark_or_1024_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 16384) -} - -func Benchmark_or_1024_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 32768) -} - -func Benchmark_or_1024_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 1024, 65536) -} - -func Benchmark_or_1024_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 64) -} - -func Benchmark_or_1024_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 128) -} - -func Benchmark_or_1024_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 256) -} - -func Benchmark_or_1024_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 512) -} - -func Benchmark_or_1024_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 1024) -} - -func Benchmark_or_1024_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 8192) -} - -func Benchmark_or_1024_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 16384) -} - -func Benchmark_or_1024_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 32768) -} - -func Benchmark_or_1024_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 8192, 65536) -} - -func Benchmark_or_1024_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 64) -} - -func Benchmark_or_1024_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 128) -} - -func Benchmark_or_1024_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 256) -} - -func Benchmark_or_1024_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 512) -} - -func Benchmark_or_1024_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 1024) -} - -func Benchmark_or_1024_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 8192) -} - -func Benchmark_or_1024_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 16384) -} - -func Benchmark_or_1024_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 32768) -} - -func Benchmark_or_1024_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 16384, 65536) -} - -func Benchmark_or_1024_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 64) -} - -func Benchmark_or_1024_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 128) -} - -func Benchmark_or_1024_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 256) -} - -func Benchmark_or_1024_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 512) -} - -func Benchmark_or_1024_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 1024) -} - -func Benchmark_or_1024_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 8192) -} - -func Benchmark_or_1024_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 16384) -} - -func Benchmark_or_1024_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 32768) -} - -func Benchmark_or_1024_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 32768, 65536) -} - -func Benchmark_or_1024_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 64) -} - -func Benchmark_or_1024_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 128) -} - -func Benchmark_or_1024_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 256) -} - -func Benchmark_or_1024_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 512) -} - -func Benchmark_or_1024_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 1024) -} - -func Benchmark_or_1024_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 8192) -} - -func Benchmark_or_1024_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 16384) -} - -func Benchmark_or_1024_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 32768) -} - -func Benchmark_or_1024_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 64, 65536, 65536) -} - -func Benchmark_or_1024_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 64) -} - -func Benchmark_or_1024_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 128) -} - -func Benchmark_or_1024_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 256) -} - -func Benchmark_or_1024_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 512) -} - -func Benchmark_or_1024_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 1024) -} - -func Benchmark_or_1024_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 8192) -} - -func Benchmark_or_1024_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 16384) -} - -func Benchmark_or_1024_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 32768) -} - -func Benchmark_or_1024_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 64, 65536) -} - -func Benchmark_or_1024_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 64) -} - -func Benchmark_or_1024_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 128) -} - -func Benchmark_or_1024_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 256) -} - -func Benchmark_or_1024_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 512) -} - -func Benchmark_or_1024_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 1024) -} - -func Benchmark_or_1024_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 8192) -} - -func Benchmark_or_1024_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 16384) -} - -func Benchmark_or_1024_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 32768) -} - -func Benchmark_or_1024_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 128, 65536) -} - -func Benchmark_or_1024_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 64) -} - -func Benchmark_or_1024_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 128) -} - -func Benchmark_or_1024_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 256) -} - -func Benchmark_or_1024_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 512) -} - -func Benchmark_or_1024_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 1024) -} - -func Benchmark_or_1024_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 8192) -} - -func Benchmark_or_1024_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 16384) -} - -func Benchmark_or_1024_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 32768) -} - -func Benchmark_or_1024_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 256, 65536) -} - -func Benchmark_or_1024_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 64) -} - -func Benchmark_or_1024_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 128) -} - -func Benchmark_or_1024_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 256) -} - -func Benchmark_or_1024_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 512) -} - -func Benchmark_or_1024_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 1024) -} - -func Benchmark_or_1024_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 8192) -} - -func Benchmark_or_1024_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 16384) -} - -func Benchmark_or_1024_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 32768) -} - -func Benchmark_or_1024_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 512, 65536) -} - -func Benchmark_or_1024_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 64) -} - -func Benchmark_or_1024_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 128) -} - -func Benchmark_or_1024_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 256) -} - -func Benchmark_or_1024_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 512) -} - -func Benchmark_or_1024_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 1024) -} - -func Benchmark_or_1024_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 8192) -} - -func Benchmark_or_1024_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 16384) -} - -func Benchmark_or_1024_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 32768) -} - -func Benchmark_or_1024_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 1024, 65536) -} - -func Benchmark_or_1024_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 64) -} - -func Benchmark_or_1024_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 128) -} - -func Benchmark_or_1024_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 256) -} - -func Benchmark_or_1024_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 512) -} - -func Benchmark_or_1024_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 1024) -} - -func Benchmark_or_1024_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 8192) -} - -func Benchmark_or_1024_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 16384) -} - -func Benchmark_or_1024_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 32768) -} - -func Benchmark_or_1024_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 8192, 65536) -} - -func Benchmark_or_1024_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 64) -} - -func Benchmark_or_1024_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 128) -} - -func Benchmark_or_1024_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 256) -} - -func Benchmark_or_1024_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 512) -} - -func Benchmark_or_1024_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 1024) -} - -func Benchmark_or_1024_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 8192) -} - -func Benchmark_or_1024_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 16384) -} - -func Benchmark_or_1024_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 32768) -} - -func Benchmark_or_1024_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 16384, 65536) -} - -func Benchmark_or_1024_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 64) -} - -func Benchmark_or_1024_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 128) -} - -func Benchmark_or_1024_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 256) -} - -func Benchmark_or_1024_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 512) -} - -func Benchmark_or_1024_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 1024) -} - -func Benchmark_or_1024_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 8192) -} - -func Benchmark_or_1024_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 16384) -} - -func Benchmark_or_1024_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 32768) -} - -func Benchmark_or_1024_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 32768, 65536) -} - -func Benchmark_or_1024_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 64) -} - -func Benchmark_or_1024_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 128) -} - -func Benchmark_or_1024_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 256) -} - -func Benchmark_or_1024_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 512) -} - -func Benchmark_or_1024_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 1024) -} - -func Benchmark_or_1024_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 8192) -} - -func Benchmark_or_1024_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 16384) -} - -func Benchmark_or_1024_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 32768) -} - -func Benchmark_or_1024_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 1024, 65536, 65536) -} - -func Benchmark_or_1024_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 64) -} - -func Benchmark_or_1024_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 128) -} - -func Benchmark_or_1024_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 256) -} - -func Benchmark_or_1024_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 512) -} - -func Benchmark_or_1024_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 1024) -} - -func Benchmark_or_1024_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 8192) -} - -func Benchmark_or_1024_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 16384) -} - -func Benchmark_or_1024_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 32768) -} - -func Benchmark_or_1024_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 64, 65536) -} - -func Benchmark_or_1024_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 64) -} - -func Benchmark_or_1024_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 128) -} - -func Benchmark_or_1024_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 256) -} - -func Benchmark_or_1024_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 512) -} - -func Benchmark_or_1024_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 1024) -} - -func Benchmark_or_1024_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 8192) -} - -func Benchmark_or_1024_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 16384) -} - -func Benchmark_or_1024_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 32768) -} - -func Benchmark_or_1024_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 128, 65536) -} - -func Benchmark_or_1024_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 64) -} - -func Benchmark_or_1024_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 128) -} - -func Benchmark_or_1024_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 256) -} - -func Benchmark_or_1024_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 512) -} - -func Benchmark_or_1024_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 1024) -} - -func Benchmark_or_1024_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 8192) -} - -func Benchmark_or_1024_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 16384) -} - -func Benchmark_or_1024_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 32768) -} - -func Benchmark_or_1024_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 256, 65536) -} - -func Benchmark_or_1024_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 64) -} - -func Benchmark_or_1024_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 128) -} - -func Benchmark_or_1024_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 256) -} - -func Benchmark_or_1024_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 512) -} - -func Benchmark_or_1024_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 1024) -} - -func Benchmark_or_1024_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 8192) -} - -func Benchmark_or_1024_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 16384) -} - -func Benchmark_or_1024_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 32768) -} - -func Benchmark_or_1024_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 512, 65536) -} - -func Benchmark_or_1024_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 64) -} - -func Benchmark_or_1024_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 128) -} - -func Benchmark_or_1024_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 256) -} - -func Benchmark_or_1024_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 512) -} - -func Benchmark_or_1024_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 1024) -} - -func Benchmark_or_1024_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 8192) -} - -func Benchmark_or_1024_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 16384) -} - -func Benchmark_or_1024_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 32768) -} - -func Benchmark_or_1024_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 1024, 65536) -} - -func Benchmark_or_1024_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 64) -} - -func Benchmark_or_1024_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 128) -} - -func Benchmark_or_1024_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 256) -} - -func Benchmark_or_1024_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 512) -} - -func Benchmark_or_1024_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 1024) -} - -func Benchmark_or_1024_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 8192) -} - -func Benchmark_or_1024_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 16384) -} - -func Benchmark_or_1024_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 32768) -} - -func Benchmark_or_1024_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 8192, 65536) -} - -func Benchmark_or_1024_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 64) -} - -func Benchmark_or_1024_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 128) -} - -func Benchmark_or_1024_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 256) -} - -func Benchmark_or_1024_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 512) -} - -func Benchmark_or_1024_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 1024) -} - -func Benchmark_or_1024_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 8192) -} - -func Benchmark_or_1024_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 16384) -} - -func Benchmark_or_1024_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 32768) -} - -func Benchmark_or_1024_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 16384, 65536) -} - -func Benchmark_or_1024_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 64) -} - -func Benchmark_or_1024_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 128) -} - -func Benchmark_or_1024_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 256) -} - -func Benchmark_or_1024_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 512) -} - -func Benchmark_or_1024_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 1024) -} - -func Benchmark_or_1024_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 8192) -} - -func Benchmark_or_1024_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 16384) -} - -func Benchmark_or_1024_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 32768) -} - -func Benchmark_or_1024_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 32768, 65536) -} - -func Benchmark_or_1024_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 64) -} - -func Benchmark_or_1024_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 128) -} - -func Benchmark_or_1024_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 256) -} - -func Benchmark_or_1024_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 512) -} - -func Benchmark_or_1024_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 1024) -} - -func Benchmark_or_1024_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 8192) -} - -func Benchmark_or_1024_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 16384) -} - -func Benchmark_or_1024_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 32768) -} - -func Benchmark_or_1024_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 1024, 65536, 65536, 65536) -} - -func Benchmark_or_65536_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 64) -} - -func Benchmark_or_65536_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 128) -} - -func Benchmark_or_65536_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 256) -} - -func Benchmark_or_65536_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 512) -} - -func Benchmark_or_65536_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 1024) -} - -func Benchmark_or_65536_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 8192) -} - -func Benchmark_or_65536_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 16384) -} - -func Benchmark_or_65536_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 32768) -} - -func Benchmark_or_65536_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 64, 65536) -} - -func Benchmark_or_65536_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 64) -} - -func Benchmark_or_65536_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 128) -} - -func Benchmark_or_65536_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 256) -} - -func Benchmark_or_65536_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 512) -} - -func Benchmark_or_65536_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 1024) -} - -func Benchmark_or_65536_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 8192) -} - -func Benchmark_or_65536_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 16384) -} - -func Benchmark_or_65536_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 32768) -} - -func Benchmark_or_65536_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 128, 65536) -} - -func Benchmark_or_65536_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 64) -} - -func Benchmark_or_65536_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 128) -} - -func Benchmark_or_65536_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 256) -} - -func Benchmark_or_65536_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 512) -} - -func Benchmark_or_65536_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 1024) -} - -func Benchmark_or_65536_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 8192) -} - -func Benchmark_or_65536_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 16384) -} - -func Benchmark_or_65536_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 32768) -} - -func Benchmark_or_65536_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 256, 65536) -} - -func Benchmark_or_65536_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 64) -} - -func Benchmark_or_65536_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 128) -} - -func Benchmark_or_65536_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 256) -} - -func Benchmark_or_65536_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 512) -} - -func Benchmark_or_65536_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 1024) -} - -func Benchmark_or_65536_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 8192) -} - -func Benchmark_or_65536_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 16384) -} - -func Benchmark_or_65536_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 32768) -} - -func Benchmark_or_65536_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 512, 65536) -} - -func Benchmark_or_65536_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 64) -} - -func Benchmark_or_65536_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 128) -} - -func Benchmark_or_65536_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 256) -} - -func Benchmark_or_65536_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 512) -} - -func Benchmark_or_65536_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 1024) -} - -func Benchmark_or_65536_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 8192) -} - -func Benchmark_or_65536_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 16384) -} - -func Benchmark_or_65536_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 32768) -} - -func Benchmark_or_65536_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 1024, 65536) -} - -func Benchmark_or_65536_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 64) -} - -func Benchmark_or_65536_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 128) -} - -func Benchmark_or_65536_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 256) -} - -func Benchmark_or_65536_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 512) -} - -func Benchmark_or_65536_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 1024) -} - -func Benchmark_or_65536_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 8192) -} - -func Benchmark_or_65536_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 16384) -} - -func Benchmark_or_65536_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 32768) -} - -func Benchmark_or_65536_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 8192, 65536) -} - -func Benchmark_or_65536_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 64) -} - -func Benchmark_or_65536_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 128) -} - -func Benchmark_or_65536_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 256) -} - -func Benchmark_or_65536_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 512) -} - -func Benchmark_or_65536_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 1024) -} - -func Benchmark_or_65536_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 8192) -} - -func Benchmark_or_65536_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 16384) -} - -func Benchmark_or_65536_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 32768) -} - -func Benchmark_or_65536_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 16384, 65536) -} - -func Benchmark_or_65536_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 64) -} - -func Benchmark_or_65536_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 128) -} - -func Benchmark_or_65536_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 256) -} - -func Benchmark_or_65536_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 512) -} - -func Benchmark_or_65536_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 1024) -} - -func Benchmark_or_65536_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 8192) -} - -func Benchmark_or_65536_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 16384) -} - -func Benchmark_or_65536_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 32768) -} - -func Benchmark_or_65536_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 32768, 65536) -} - -func Benchmark_or_65536_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 64) -} - -func Benchmark_or_65536_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 128) -} - -func Benchmark_or_65536_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 256) -} - -func Benchmark_or_65536_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 512) -} - -func Benchmark_or_65536_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 1024) -} - -func Benchmark_or_65536_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 8192) -} - -func Benchmark_or_65536_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 16384) -} - -func Benchmark_or_65536_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 32768) -} - -func Benchmark_or_65536_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 64, 65536, 65536) -} - -func Benchmark_or_65536_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 64) -} - -func Benchmark_or_65536_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 128) -} - -func Benchmark_or_65536_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 256) -} - -func Benchmark_or_65536_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 512) -} - -func Benchmark_or_65536_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 1024) -} - -func Benchmark_or_65536_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 8192) -} - -func Benchmark_or_65536_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 16384) -} - -func Benchmark_or_65536_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 32768) -} - -func Benchmark_or_65536_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 64, 65536) -} - -func Benchmark_or_65536_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 64) -} - -func Benchmark_or_65536_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 128) -} - -func Benchmark_or_65536_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 256) -} - -func Benchmark_or_65536_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 512) -} - -func Benchmark_or_65536_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 1024) -} - -func Benchmark_or_65536_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 8192) -} - -func Benchmark_or_65536_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 16384) -} - -func Benchmark_or_65536_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 32768) -} - -func Benchmark_or_65536_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 128, 65536) -} - -func Benchmark_or_65536_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 64) -} - -func Benchmark_or_65536_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 128) -} - -func Benchmark_or_65536_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 256) -} - -func Benchmark_or_65536_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 512) -} - -func Benchmark_or_65536_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 1024) -} - -func Benchmark_or_65536_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 8192) -} - -func Benchmark_or_65536_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 16384) -} - -func Benchmark_or_65536_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 32768) -} - -func Benchmark_or_65536_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 256, 65536) -} - -func Benchmark_or_65536_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 64) -} - -func Benchmark_or_65536_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 128) -} - -func Benchmark_or_65536_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 256) -} - -func Benchmark_or_65536_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 512) -} - -func Benchmark_or_65536_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 1024) -} - -func Benchmark_or_65536_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 8192) -} - -func Benchmark_or_65536_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 16384) -} - -func Benchmark_or_65536_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 32768) -} - -func Benchmark_or_65536_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 512, 65536) -} - -func Benchmark_or_65536_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 64) -} - -func Benchmark_or_65536_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 128) -} - -func Benchmark_or_65536_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 256) -} - -func Benchmark_or_65536_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 512) -} - -func Benchmark_or_65536_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 1024) -} - -func Benchmark_or_65536_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 8192) -} - -func Benchmark_or_65536_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 16384) -} - -func Benchmark_or_65536_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 32768) -} - -func Benchmark_or_65536_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 1024, 65536) -} - -func Benchmark_or_65536_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 64) -} - -func Benchmark_or_65536_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 128) -} - -func Benchmark_or_65536_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 256) -} - -func Benchmark_or_65536_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 512) -} - -func Benchmark_or_65536_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 1024) -} - -func Benchmark_or_65536_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 8192) -} - -func Benchmark_or_65536_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 16384) -} - -func Benchmark_or_65536_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 32768) -} - -func Benchmark_or_65536_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 8192, 65536) -} - -func Benchmark_or_65536_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 64) -} - -func Benchmark_or_65536_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 128) -} - -func Benchmark_or_65536_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 256) -} - -func Benchmark_or_65536_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 512) -} - -func Benchmark_or_65536_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 1024) -} - -func Benchmark_or_65536_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 8192) -} - -func Benchmark_or_65536_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 16384) -} - -func Benchmark_or_65536_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 32768) -} - -func Benchmark_or_65536_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 16384, 65536) -} - -func Benchmark_or_65536_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 64) -} - -func Benchmark_or_65536_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 128) -} - -func Benchmark_or_65536_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 256) -} - -func Benchmark_or_65536_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 512) -} - -func Benchmark_or_65536_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 1024) -} - -func Benchmark_or_65536_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 8192) -} - -func Benchmark_or_65536_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 16384) -} - -func Benchmark_or_65536_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 32768) -} - -func Benchmark_or_65536_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 32768, 65536) -} - -func Benchmark_or_65536_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 64) -} - -func Benchmark_or_65536_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 128) -} - -func Benchmark_or_65536_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 256) -} - -func Benchmark_or_65536_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 512) -} - -func Benchmark_or_65536_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 1024) -} - -func Benchmark_or_65536_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 8192) -} - -func Benchmark_or_65536_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 16384) -} - -func Benchmark_or_65536_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 32768) -} - -func Benchmark_or_65536_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 1024, 65536, 65536) -} - -func Benchmark_or_65536_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 64) -} - -func Benchmark_or_65536_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 128) -} - -func Benchmark_or_65536_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 256) -} - -func Benchmark_or_65536_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 512) -} - -func Benchmark_or_65536_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 1024) -} - -func Benchmark_or_65536_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 8192) -} - -func Benchmark_or_65536_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 16384) -} - -func Benchmark_or_65536_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 32768) -} - -func Benchmark_or_65536_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 64, 65536) -} - -func Benchmark_or_65536_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 64) -} - -func Benchmark_or_65536_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 128) -} - -func Benchmark_or_65536_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 256) -} - -func Benchmark_or_65536_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 512) -} - -func Benchmark_or_65536_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 1024) -} - -func Benchmark_or_65536_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 8192) -} - -func Benchmark_or_65536_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 16384) -} - -func Benchmark_or_65536_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 32768) -} - -func Benchmark_or_65536_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 128, 65536) -} - -func Benchmark_or_65536_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 64) -} - -func Benchmark_or_65536_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 128) -} - -func Benchmark_or_65536_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 256) -} - -func Benchmark_or_65536_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 512) -} - -func Benchmark_or_65536_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 1024) -} - -func Benchmark_or_65536_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 8192) -} - -func Benchmark_or_65536_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 16384) -} - -func Benchmark_or_65536_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 32768) -} - -func Benchmark_or_65536_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 256, 65536) -} - -func Benchmark_or_65536_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 64) -} - -func Benchmark_or_65536_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 128) -} - -func Benchmark_or_65536_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 256) -} - -func Benchmark_or_65536_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 512) -} - -func Benchmark_or_65536_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 1024) -} - -func Benchmark_or_65536_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 8192) -} - -func Benchmark_or_65536_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 16384) -} - -func Benchmark_or_65536_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 32768) -} - -func Benchmark_or_65536_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 512, 65536) -} - -func Benchmark_or_65536_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 64) -} - -func Benchmark_or_65536_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 128) -} - -func Benchmark_or_65536_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 256) -} - -func Benchmark_or_65536_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 512) -} - -func Benchmark_or_65536_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 1024) -} - -func Benchmark_or_65536_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 8192) -} - -func Benchmark_or_65536_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 16384) -} - -func Benchmark_or_65536_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 32768) -} - -func Benchmark_or_65536_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 1024, 65536) -} - -func Benchmark_or_65536_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 64) -} - -func Benchmark_or_65536_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 128) -} - -func Benchmark_or_65536_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 256) -} - -func Benchmark_or_65536_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 512) -} - -func Benchmark_or_65536_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 1024) -} - -func Benchmark_or_65536_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 8192) -} - -func Benchmark_or_65536_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 16384) -} - -func Benchmark_or_65536_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 32768) -} - -func Benchmark_or_65536_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 8192, 65536) -} - -func Benchmark_or_65536_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 64) -} - -func Benchmark_or_65536_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 128) -} - -func Benchmark_or_65536_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 256) -} - -func Benchmark_or_65536_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 512) -} - -func Benchmark_or_65536_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 1024) -} - -func Benchmark_or_65536_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 8192) -} - -func Benchmark_or_65536_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 16384) -} - -func Benchmark_or_65536_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 32768) -} - -func Benchmark_or_65536_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 16384, 65536) -} - -func Benchmark_or_65536_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 64) -} - -func Benchmark_or_65536_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 128) -} - -func Benchmark_or_65536_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 256) -} - -func Benchmark_or_65536_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 512) -} - -func Benchmark_or_65536_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 1024) -} - -func Benchmark_or_65536_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 8192) -} - -func Benchmark_or_65536_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 16384) -} - -func Benchmark_or_65536_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 32768) -} - -func Benchmark_or_65536_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 32768, 65536) -} - -func Benchmark_or_65536_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 64) -} - -func Benchmark_or_65536_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 128) -} - -func Benchmark_or_65536_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 256) -} - -func Benchmark_or_65536_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 512) -} - -func Benchmark_or_65536_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 1024) -} - -func Benchmark_or_65536_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 8192) -} - -func Benchmark_or_65536_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 16384) -} - -func Benchmark_or_65536_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 32768) -} - -func Benchmark_or_65536_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "or", 65536, 65536, 65536, 65536) -} - -func Benchmark_diff_64_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 64) -} - -func Benchmark_diff_64_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 128) -} - -func Benchmark_diff_64_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 256) -} - -func Benchmark_diff_64_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 512) -} - -func Benchmark_diff_64_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 1024) -} - -func Benchmark_diff_64_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 8192) -} - -func Benchmark_diff_64_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 16384) -} - -func Benchmark_diff_64_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 32768) -} - -func Benchmark_diff_64_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 64, 65536) -} - -func Benchmark_diff_64_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 64) -} - -func Benchmark_diff_64_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 128) -} - -func Benchmark_diff_64_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 256) -} - -func Benchmark_diff_64_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 512) -} - -func Benchmark_diff_64_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 1024) -} - -func Benchmark_diff_64_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 8192) -} - -func Benchmark_diff_64_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 16384) -} - -func Benchmark_diff_64_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 32768) -} - -func Benchmark_diff_64_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 128, 65536) -} - -func Benchmark_diff_64_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 64) -} - -func Benchmark_diff_64_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 128) -} - -func Benchmark_diff_64_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 256) -} - -func Benchmark_diff_64_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 512) -} - -func Benchmark_diff_64_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 1024) -} - -func Benchmark_diff_64_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 8192) -} - -func Benchmark_diff_64_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 16384) -} - -func Benchmark_diff_64_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 32768) -} - -func Benchmark_diff_64_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 256, 65536) -} - -func Benchmark_diff_64_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 64) -} - -func Benchmark_diff_64_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 128) -} - -func Benchmark_diff_64_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 256) -} - -func Benchmark_diff_64_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 512) -} - -func Benchmark_diff_64_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 1024) -} - -func Benchmark_diff_64_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 8192) -} - -func Benchmark_diff_64_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 16384) -} - -func Benchmark_diff_64_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 32768) -} - -func Benchmark_diff_64_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 512, 65536) -} - -func Benchmark_diff_64_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 64) -} - -func Benchmark_diff_64_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 128) -} - -func Benchmark_diff_64_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 256) -} - -func Benchmark_diff_64_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 512) -} - -func Benchmark_diff_64_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 1024) -} - -func Benchmark_diff_64_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 8192) -} - -func Benchmark_diff_64_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 16384) -} - -func Benchmark_diff_64_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 32768) -} - -func Benchmark_diff_64_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 1024, 65536) -} - -func Benchmark_diff_64_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 64) -} - -func Benchmark_diff_64_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 128) -} - -func Benchmark_diff_64_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 256) -} - -func Benchmark_diff_64_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 512) -} - -func Benchmark_diff_64_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 1024) -} - -func Benchmark_diff_64_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 8192) -} - -func Benchmark_diff_64_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 16384) -} - -func Benchmark_diff_64_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 32768) -} - -func Benchmark_diff_64_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 8192, 65536) -} - -func Benchmark_diff_64_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 64) -} - -func Benchmark_diff_64_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 128) -} - -func Benchmark_diff_64_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 256) -} - -func Benchmark_diff_64_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 512) -} - -func Benchmark_diff_64_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 1024) -} - -func Benchmark_diff_64_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 8192) -} - -func Benchmark_diff_64_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 16384) -} - -func Benchmark_diff_64_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 32768) -} - -func Benchmark_diff_64_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 16384, 65536) -} - -func Benchmark_diff_64_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 64) -} - -func Benchmark_diff_64_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 128) -} - -func Benchmark_diff_64_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 256) -} - -func Benchmark_diff_64_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 512) -} - -func Benchmark_diff_64_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 1024) -} - -func Benchmark_diff_64_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 8192) -} - -func Benchmark_diff_64_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 16384) -} - -func Benchmark_diff_64_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 32768) -} - -func Benchmark_diff_64_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 32768, 65536) -} - -func Benchmark_diff_64_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 64) -} - -func Benchmark_diff_64_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 128) -} - -func Benchmark_diff_64_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 256) -} - -func Benchmark_diff_64_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 512) -} - -func Benchmark_diff_64_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 1024) -} - -func Benchmark_diff_64_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 8192) -} - -func Benchmark_diff_64_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 16384) -} - -func Benchmark_diff_64_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 32768) -} - -func Benchmark_diff_64_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 64, 65536, 65536) -} - -func Benchmark_diff_64_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 64) -} - -func Benchmark_diff_64_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 128) -} - -func Benchmark_diff_64_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 256) -} - -func Benchmark_diff_64_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 512) -} - -func Benchmark_diff_64_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 1024) -} - -func Benchmark_diff_64_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 8192) -} - -func Benchmark_diff_64_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 16384) -} - -func Benchmark_diff_64_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 32768) -} - -func Benchmark_diff_64_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 64, 65536) -} - -func Benchmark_diff_64_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 64) -} - -func Benchmark_diff_64_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 128) -} - -func Benchmark_diff_64_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 256) -} - -func Benchmark_diff_64_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 512) -} - -func Benchmark_diff_64_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 1024) -} - -func Benchmark_diff_64_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 8192) -} - -func Benchmark_diff_64_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 16384) -} - -func Benchmark_diff_64_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 32768) -} - -func Benchmark_diff_64_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 128, 65536) -} - -func Benchmark_diff_64_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 64) -} - -func Benchmark_diff_64_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 128) -} - -func Benchmark_diff_64_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 256) -} - -func Benchmark_diff_64_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 512) -} - -func Benchmark_diff_64_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 1024) -} - -func Benchmark_diff_64_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 8192) -} - -func Benchmark_diff_64_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 16384) -} - -func Benchmark_diff_64_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 32768) -} - -func Benchmark_diff_64_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 256, 65536) -} - -func Benchmark_diff_64_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 64) -} - -func Benchmark_diff_64_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 128) -} - -func Benchmark_diff_64_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 256) -} - -func Benchmark_diff_64_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 512) -} - -func Benchmark_diff_64_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 1024) -} - -func Benchmark_diff_64_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 8192) -} - -func Benchmark_diff_64_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 16384) -} - -func Benchmark_diff_64_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 32768) -} - -func Benchmark_diff_64_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 512, 65536) -} - -func Benchmark_diff_64_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 64) -} - -func Benchmark_diff_64_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 128) -} - -func Benchmark_diff_64_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 256) -} - -func Benchmark_diff_64_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 512) -} - -func Benchmark_diff_64_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 1024) -} - -func Benchmark_diff_64_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 8192) -} - -func Benchmark_diff_64_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 16384) -} - -func Benchmark_diff_64_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 32768) -} - -func Benchmark_diff_64_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 1024, 65536) -} - -func Benchmark_diff_64_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 64) -} - -func Benchmark_diff_64_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 128) -} - -func Benchmark_diff_64_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 256) -} - -func Benchmark_diff_64_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 512) -} - -func Benchmark_diff_64_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 1024) -} - -func Benchmark_diff_64_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 8192) -} - -func Benchmark_diff_64_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 16384) -} - -func Benchmark_diff_64_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 32768) -} - -func Benchmark_diff_64_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 8192, 65536) -} - -func Benchmark_diff_64_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 64) -} - -func Benchmark_diff_64_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 128) -} - -func Benchmark_diff_64_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 256) -} - -func Benchmark_diff_64_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 512) -} - -func Benchmark_diff_64_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 1024) -} - -func Benchmark_diff_64_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 8192) -} - -func Benchmark_diff_64_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 16384) -} - -func Benchmark_diff_64_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 32768) -} - -func Benchmark_diff_64_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 16384, 65536) -} - -func Benchmark_diff_64_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 64) -} - -func Benchmark_diff_64_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 128) -} - -func Benchmark_diff_64_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 256) -} - -func Benchmark_diff_64_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 512) -} - -func Benchmark_diff_64_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 1024) -} - -func Benchmark_diff_64_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 8192) -} - -func Benchmark_diff_64_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 16384) -} - -func Benchmark_diff_64_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 32768) -} - -func Benchmark_diff_64_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 32768, 65536) -} - -func Benchmark_diff_64_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 64) -} - -func Benchmark_diff_64_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 128) -} - -func Benchmark_diff_64_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 256) -} - -func Benchmark_diff_64_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 512) -} - -func Benchmark_diff_64_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 1024) -} - -func Benchmark_diff_64_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 8192) -} - -func Benchmark_diff_64_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 16384) -} - -func Benchmark_diff_64_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 32768) -} - -func Benchmark_diff_64_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 1024, 65536, 65536) -} - -func Benchmark_diff_64_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 64) -} - -func Benchmark_diff_64_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 128) -} - -func Benchmark_diff_64_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 256) -} - -func Benchmark_diff_64_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 512) -} - -func Benchmark_diff_64_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 1024) -} - -func Benchmark_diff_64_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 8192) -} - -func Benchmark_diff_64_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 16384) -} - -func Benchmark_diff_64_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 32768) -} - -func Benchmark_diff_64_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 64, 65536) -} - -func Benchmark_diff_64_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 64) -} - -func Benchmark_diff_64_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 128) -} - -func Benchmark_diff_64_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 256) -} - -func Benchmark_diff_64_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 512) -} - -func Benchmark_diff_64_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 1024) -} - -func Benchmark_diff_64_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 8192) -} - -func Benchmark_diff_64_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 16384) -} - -func Benchmark_diff_64_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 32768) -} - -func Benchmark_diff_64_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 128, 65536) -} - -func Benchmark_diff_64_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 64) -} - -func Benchmark_diff_64_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 128) -} - -func Benchmark_diff_64_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 256) -} - -func Benchmark_diff_64_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 512) -} - -func Benchmark_diff_64_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 1024) -} - -func Benchmark_diff_64_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 8192) -} - -func Benchmark_diff_64_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 16384) -} - -func Benchmark_diff_64_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 32768) -} - -func Benchmark_diff_64_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 256, 65536) -} - -func Benchmark_diff_64_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 64) -} - -func Benchmark_diff_64_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 128) -} - -func Benchmark_diff_64_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 256) -} - -func Benchmark_diff_64_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 512) -} - -func Benchmark_diff_64_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 1024) -} - -func Benchmark_diff_64_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 8192) -} - -func Benchmark_diff_64_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 16384) -} - -func Benchmark_diff_64_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 32768) -} - -func Benchmark_diff_64_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 512, 65536) -} - -func Benchmark_diff_64_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 64) -} - -func Benchmark_diff_64_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 128) -} - -func Benchmark_diff_64_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 256) -} - -func Benchmark_diff_64_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 512) -} - -func Benchmark_diff_64_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 1024) -} - -func Benchmark_diff_64_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 8192) -} - -func Benchmark_diff_64_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 16384) -} - -func Benchmark_diff_64_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 32768) -} - -func Benchmark_diff_64_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 1024, 65536) -} - -func Benchmark_diff_64_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 64) -} - -func Benchmark_diff_64_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 128) -} - -func Benchmark_diff_64_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 256) -} - -func Benchmark_diff_64_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 512) -} - -func Benchmark_diff_64_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 1024) -} - -func Benchmark_diff_64_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 8192) -} - -func Benchmark_diff_64_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 16384) -} - -func Benchmark_diff_64_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 32768) -} - -func Benchmark_diff_64_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 8192, 65536) -} - -func Benchmark_diff_64_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 64) -} - -func Benchmark_diff_64_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 128) -} - -func Benchmark_diff_64_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 256) -} - -func Benchmark_diff_64_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 512) -} - -func Benchmark_diff_64_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 1024) -} - -func Benchmark_diff_64_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 8192) -} - -func Benchmark_diff_64_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 16384) -} - -func Benchmark_diff_64_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 32768) -} - -func Benchmark_diff_64_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 16384, 65536) -} - -func Benchmark_diff_64_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 64) -} - -func Benchmark_diff_64_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 128) -} - -func Benchmark_diff_64_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 256) -} - -func Benchmark_diff_64_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 512) -} - -func Benchmark_diff_64_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 1024) -} - -func Benchmark_diff_64_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 8192) -} - -func Benchmark_diff_64_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 16384) -} - -func Benchmark_diff_64_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 32768) -} - -func Benchmark_diff_64_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 32768, 65536) -} - -func Benchmark_diff_64_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 64) -} - -func Benchmark_diff_64_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 128) -} - -func Benchmark_diff_64_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 256) -} - -func Benchmark_diff_64_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 512) -} - -func Benchmark_diff_64_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 1024) -} - -func Benchmark_diff_64_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 8192) -} - -func Benchmark_diff_64_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 16384) -} - -func Benchmark_diff_64_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 32768) -} - -func Benchmark_diff_64_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 64, 65536, 65536, 65536) -} - -func Benchmark_diff_1024_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 64) -} - -func Benchmark_diff_1024_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 128) -} - -func Benchmark_diff_1024_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 256) -} - -func Benchmark_diff_1024_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 512) -} - -func Benchmark_diff_1024_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 1024) -} - -func Benchmark_diff_1024_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 8192) -} - -func Benchmark_diff_1024_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 16384) -} - -func Benchmark_diff_1024_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 32768) -} - -func Benchmark_diff_1024_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 64, 65536) -} - -func Benchmark_diff_1024_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 64) -} - -func Benchmark_diff_1024_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 128) -} - -func Benchmark_diff_1024_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 256) -} - -func Benchmark_diff_1024_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 512) -} - -func Benchmark_diff_1024_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 1024) -} - -func Benchmark_diff_1024_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 8192) -} - -func Benchmark_diff_1024_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 16384) -} - -func Benchmark_diff_1024_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 32768) -} - -func Benchmark_diff_1024_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 128, 65536) -} - -func Benchmark_diff_1024_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 64) -} - -func Benchmark_diff_1024_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 128) -} - -func Benchmark_diff_1024_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 256) -} - -func Benchmark_diff_1024_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 512) -} - -func Benchmark_diff_1024_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 1024) -} - -func Benchmark_diff_1024_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 8192) -} - -func Benchmark_diff_1024_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 16384) -} - -func Benchmark_diff_1024_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 32768) -} - -func Benchmark_diff_1024_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 256, 65536) -} - -func Benchmark_diff_1024_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 64) -} - -func Benchmark_diff_1024_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 128) -} - -func Benchmark_diff_1024_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 256) -} - -func Benchmark_diff_1024_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 512) -} - -func Benchmark_diff_1024_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 1024) -} - -func Benchmark_diff_1024_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 8192) -} - -func Benchmark_diff_1024_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 16384) -} - -func Benchmark_diff_1024_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 32768) -} - -func Benchmark_diff_1024_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 512, 65536) -} - -func Benchmark_diff_1024_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 64) -} - -func Benchmark_diff_1024_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 128) -} - -func Benchmark_diff_1024_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 256) -} - -func Benchmark_diff_1024_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 512) -} - -func Benchmark_diff_1024_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 1024) -} - -func Benchmark_diff_1024_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 8192) -} - -func Benchmark_diff_1024_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 16384) -} - -func Benchmark_diff_1024_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 32768) -} - -func Benchmark_diff_1024_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 1024, 65536) -} - -func Benchmark_diff_1024_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 64) -} - -func Benchmark_diff_1024_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 128) -} - -func Benchmark_diff_1024_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 256) -} - -func Benchmark_diff_1024_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 512) -} - -func Benchmark_diff_1024_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 1024) -} - -func Benchmark_diff_1024_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 8192) -} - -func Benchmark_diff_1024_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 16384) -} - -func Benchmark_diff_1024_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 32768) -} - -func Benchmark_diff_1024_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 8192, 65536) -} - -func Benchmark_diff_1024_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 64) -} - -func Benchmark_diff_1024_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 128) -} - -func Benchmark_diff_1024_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 256) -} - -func Benchmark_diff_1024_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 512) -} - -func Benchmark_diff_1024_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 1024) -} - -func Benchmark_diff_1024_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 8192) -} - -func Benchmark_diff_1024_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 16384) -} - -func Benchmark_diff_1024_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 32768) -} - -func Benchmark_diff_1024_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 16384, 65536) -} - -func Benchmark_diff_1024_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 64) -} - -func Benchmark_diff_1024_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 128) -} - -func Benchmark_diff_1024_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 256) -} - -func Benchmark_diff_1024_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 512) -} - -func Benchmark_diff_1024_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 1024) -} - -func Benchmark_diff_1024_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 8192) -} - -func Benchmark_diff_1024_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 16384) -} - -func Benchmark_diff_1024_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 32768) -} - -func Benchmark_diff_1024_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 32768, 65536) -} - -func Benchmark_diff_1024_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 64) -} - -func Benchmark_diff_1024_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 128) -} - -func Benchmark_diff_1024_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 256) -} - -func Benchmark_diff_1024_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 512) -} - -func Benchmark_diff_1024_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 1024) -} - -func Benchmark_diff_1024_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 8192) -} - -func Benchmark_diff_1024_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 16384) -} - -func Benchmark_diff_1024_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 32768) -} - -func Benchmark_diff_1024_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 64, 65536, 65536) -} - -func Benchmark_diff_1024_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 64) -} - -func Benchmark_diff_1024_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 128) -} - -func Benchmark_diff_1024_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 256) -} - -func Benchmark_diff_1024_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 512) -} - -func Benchmark_diff_1024_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 1024) -} - -func Benchmark_diff_1024_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 8192) -} - -func Benchmark_diff_1024_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 16384) -} - -func Benchmark_diff_1024_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 32768) -} - -func Benchmark_diff_1024_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 64, 65536) -} - -func Benchmark_diff_1024_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 64) -} - -func Benchmark_diff_1024_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 128) -} - -func Benchmark_diff_1024_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 256) -} - -func Benchmark_diff_1024_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 512) -} - -func Benchmark_diff_1024_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 1024) -} - -func Benchmark_diff_1024_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 8192) -} - -func Benchmark_diff_1024_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 16384) -} - -func Benchmark_diff_1024_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 32768) -} - -func Benchmark_diff_1024_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 128, 65536) -} - -func Benchmark_diff_1024_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 64) -} - -func Benchmark_diff_1024_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 128) -} - -func Benchmark_diff_1024_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 256) -} - -func Benchmark_diff_1024_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 512) -} - -func Benchmark_diff_1024_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 1024) -} - -func Benchmark_diff_1024_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 8192) -} - -func Benchmark_diff_1024_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 16384) -} - -func Benchmark_diff_1024_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 32768) -} - -func Benchmark_diff_1024_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 256, 65536) -} - -func Benchmark_diff_1024_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 64) -} - -func Benchmark_diff_1024_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 128) -} - -func Benchmark_diff_1024_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 256) -} - -func Benchmark_diff_1024_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 512) -} - -func Benchmark_diff_1024_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 1024) -} - -func Benchmark_diff_1024_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 8192) -} - -func Benchmark_diff_1024_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 16384) -} - -func Benchmark_diff_1024_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 32768) -} - -func Benchmark_diff_1024_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 512, 65536) -} - -func Benchmark_diff_1024_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 64) -} - -func Benchmark_diff_1024_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 128) -} - -func Benchmark_diff_1024_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 256) -} - -func Benchmark_diff_1024_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 512) -} - -func Benchmark_diff_1024_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 1024) -} - -func Benchmark_diff_1024_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 8192) -} - -func Benchmark_diff_1024_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 16384) -} - -func Benchmark_diff_1024_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 32768) -} - -func Benchmark_diff_1024_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 1024, 65536) -} - -func Benchmark_diff_1024_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 64) -} - -func Benchmark_diff_1024_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 128) -} - -func Benchmark_diff_1024_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 256) -} - -func Benchmark_diff_1024_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 512) -} - -func Benchmark_diff_1024_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 1024) -} - -func Benchmark_diff_1024_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 8192) -} - -func Benchmark_diff_1024_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 16384) -} - -func Benchmark_diff_1024_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 32768) -} - -func Benchmark_diff_1024_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 8192, 65536) -} - -func Benchmark_diff_1024_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 64) -} - -func Benchmark_diff_1024_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 128) -} - -func Benchmark_diff_1024_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 256) -} - -func Benchmark_diff_1024_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 512) -} - -func Benchmark_diff_1024_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 1024) -} - -func Benchmark_diff_1024_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 8192) -} - -func Benchmark_diff_1024_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 16384) -} - -func Benchmark_diff_1024_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 32768) -} - -func Benchmark_diff_1024_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 16384, 65536) -} - -func Benchmark_diff_1024_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 64) -} - -func Benchmark_diff_1024_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 128) -} - -func Benchmark_diff_1024_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 256) -} - -func Benchmark_diff_1024_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 512) -} - -func Benchmark_diff_1024_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 1024) -} - -func Benchmark_diff_1024_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 8192) -} - -func Benchmark_diff_1024_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 16384) -} - -func Benchmark_diff_1024_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 32768) -} - -func Benchmark_diff_1024_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 32768, 65536) -} - -func Benchmark_diff_1024_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 64) -} - -func Benchmark_diff_1024_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 128) -} - -func Benchmark_diff_1024_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 256) -} - -func Benchmark_diff_1024_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 512) -} - -func Benchmark_diff_1024_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 1024) -} - -func Benchmark_diff_1024_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 8192) -} - -func Benchmark_diff_1024_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 16384) -} - -func Benchmark_diff_1024_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 32768) -} - -func Benchmark_diff_1024_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 1024, 65536, 65536) -} - -func Benchmark_diff_1024_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 64) -} - -func Benchmark_diff_1024_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 128) -} - -func Benchmark_diff_1024_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 256) -} - -func Benchmark_diff_1024_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 512) -} - -func Benchmark_diff_1024_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 1024) -} - -func Benchmark_diff_1024_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 8192) -} - -func Benchmark_diff_1024_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 16384) -} - -func Benchmark_diff_1024_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 32768) -} - -func Benchmark_diff_1024_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 64, 65536) -} - -func Benchmark_diff_1024_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 64) -} - -func Benchmark_diff_1024_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 128) -} - -func Benchmark_diff_1024_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 256) -} - -func Benchmark_diff_1024_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 512) -} - -func Benchmark_diff_1024_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 1024) -} - -func Benchmark_diff_1024_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 8192) -} - -func Benchmark_diff_1024_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 16384) -} - -func Benchmark_diff_1024_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 32768) -} - -func Benchmark_diff_1024_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 128, 65536) -} - -func Benchmark_diff_1024_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 64) -} - -func Benchmark_diff_1024_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 128) -} - -func Benchmark_diff_1024_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 256) -} - -func Benchmark_diff_1024_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 512) -} - -func Benchmark_diff_1024_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 1024) -} - -func Benchmark_diff_1024_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 8192) -} - -func Benchmark_diff_1024_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 16384) -} - -func Benchmark_diff_1024_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 32768) -} - -func Benchmark_diff_1024_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 256, 65536) -} - -func Benchmark_diff_1024_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 64) -} - -func Benchmark_diff_1024_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 128) -} - -func Benchmark_diff_1024_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 256) -} - -func Benchmark_diff_1024_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 512) -} - -func Benchmark_diff_1024_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 1024) -} - -func Benchmark_diff_1024_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 8192) -} - -func Benchmark_diff_1024_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 16384) -} - -func Benchmark_diff_1024_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 32768) -} - -func Benchmark_diff_1024_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 512, 65536) -} - -func Benchmark_diff_1024_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 64) -} - -func Benchmark_diff_1024_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 128) -} - -func Benchmark_diff_1024_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 256) -} - -func Benchmark_diff_1024_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 512) -} - -func Benchmark_diff_1024_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 1024) -} - -func Benchmark_diff_1024_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 8192) -} - -func Benchmark_diff_1024_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 16384) -} - -func Benchmark_diff_1024_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 32768) -} - -func Benchmark_diff_1024_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 1024, 65536) -} - -func Benchmark_diff_1024_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 64) -} - -func Benchmark_diff_1024_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 128) -} - -func Benchmark_diff_1024_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 256) -} - -func Benchmark_diff_1024_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 512) -} - -func Benchmark_diff_1024_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 1024) -} - -func Benchmark_diff_1024_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 8192) -} - -func Benchmark_diff_1024_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 16384) -} - -func Benchmark_diff_1024_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 32768) -} - -func Benchmark_diff_1024_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 8192, 65536) -} - -func Benchmark_diff_1024_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 64) -} - -func Benchmark_diff_1024_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 128) -} - -func Benchmark_diff_1024_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 256) -} - -func Benchmark_diff_1024_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 512) -} - -func Benchmark_diff_1024_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 1024) -} - -func Benchmark_diff_1024_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 8192) -} - -func Benchmark_diff_1024_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 16384) -} - -func Benchmark_diff_1024_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 32768) -} - -func Benchmark_diff_1024_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 16384, 65536) -} - -func Benchmark_diff_1024_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 64) -} - -func Benchmark_diff_1024_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 128) -} - -func Benchmark_diff_1024_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 256) -} - -func Benchmark_diff_1024_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 512) -} - -func Benchmark_diff_1024_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 1024) -} - -func Benchmark_diff_1024_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 8192) -} - -func Benchmark_diff_1024_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 16384) -} - -func Benchmark_diff_1024_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 32768) -} - -func Benchmark_diff_1024_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 32768, 65536) -} - -func Benchmark_diff_1024_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 64) -} - -func Benchmark_diff_1024_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 128) -} - -func Benchmark_diff_1024_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 256) -} - -func Benchmark_diff_1024_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 512) -} - -func Benchmark_diff_1024_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 1024) -} - -func Benchmark_diff_1024_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 8192) -} - -func Benchmark_diff_1024_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 16384) -} - -func Benchmark_diff_1024_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 32768) -} - -func Benchmark_diff_1024_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 1024, 65536, 65536, 65536) -} - -func Benchmark_diff_65536_64_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 64) -} - -func Benchmark_diff_65536_64_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 128) -} - -func Benchmark_diff_65536_64_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 256) -} - -func Benchmark_diff_65536_64_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 512) -} - -func Benchmark_diff_65536_64_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 1024) -} - -func Benchmark_diff_65536_64_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 8192) -} - -func Benchmark_diff_65536_64_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 16384) -} - -func Benchmark_diff_65536_64_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 32768) -} - -func Benchmark_diff_65536_64_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 64, 65536) -} - -func Benchmark_diff_65536_64_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 64) -} - -func Benchmark_diff_65536_64_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 128) -} - -func Benchmark_diff_65536_64_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 256) -} - -func Benchmark_diff_65536_64_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 512) -} - -func Benchmark_diff_65536_64_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 1024) -} - -func Benchmark_diff_65536_64_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 8192) -} - -func Benchmark_diff_65536_64_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 16384) -} - -func Benchmark_diff_65536_64_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 32768) -} - -func Benchmark_diff_65536_64_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 128, 65536) -} - -func Benchmark_diff_65536_64_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 64) -} - -func Benchmark_diff_65536_64_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 128) -} - -func Benchmark_diff_65536_64_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 256) -} - -func Benchmark_diff_65536_64_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 512) -} - -func Benchmark_diff_65536_64_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 1024) -} - -func Benchmark_diff_65536_64_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 8192) -} - -func Benchmark_diff_65536_64_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 16384) -} - -func Benchmark_diff_65536_64_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 32768) -} - -func Benchmark_diff_65536_64_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 256, 65536) -} - -func Benchmark_diff_65536_64_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 64) -} - -func Benchmark_diff_65536_64_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 128) -} - -func Benchmark_diff_65536_64_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 256) -} - -func Benchmark_diff_65536_64_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 512) -} - -func Benchmark_diff_65536_64_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 1024) -} - -func Benchmark_diff_65536_64_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 8192) -} - -func Benchmark_diff_65536_64_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 16384) -} - -func Benchmark_diff_65536_64_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 32768) -} - -func Benchmark_diff_65536_64_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 512, 65536) -} - -func Benchmark_diff_65536_64_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 64) -} - -func Benchmark_diff_65536_64_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 128) -} - -func Benchmark_diff_65536_64_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 256) -} - -func Benchmark_diff_65536_64_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 512) -} - -func Benchmark_diff_65536_64_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 1024) -} - -func Benchmark_diff_65536_64_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 8192) -} - -func Benchmark_diff_65536_64_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 16384) -} - -func Benchmark_diff_65536_64_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 32768) -} - -func Benchmark_diff_65536_64_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 1024, 65536) -} - -func Benchmark_diff_65536_64_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 64) -} - -func Benchmark_diff_65536_64_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 128) -} - -func Benchmark_diff_65536_64_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 256) -} - -func Benchmark_diff_65536_64_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 512) -} - -func Benchmark_diff_65536_64_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 1024) -} - -func Benchmark_diff_65536_64_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 8192) -} - -func Benchmark_diff_65536_64_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 16384) -} - -func Benchmark_diff_65536_64_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 32768) -} - -func Benchmark_diff_65536_64_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 8192, 65536) -} - -func Benchmark_diff_65536_64_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 64) -} - -func Benchmark_diff_65536_64_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 128) -} - -func Benchmark_diff_65536_64_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 256) -} - -func Benchmark_diff_65536_64_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 512) -} - -func Benchmark_diff_65536_64_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 1024) -} - -func Benchmark_diff_65536_64_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 8192) -} - -func Benchmark_diff_65536_64_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 16384) -} - -func Benchmark_diff_65536_64_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 32768) -} - -func Benchmark_diff_65536_64_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 16384, 65536) -} - -func Benchmark_diff_65536_64_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 64) -} - -func Benchmark_diff_65536_64_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 128) -} - -func Benchmark_diff_65536_64_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 256) -} - -func Benchmark_diff_65536_64_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 512) -} - -func Benchmark_diff_65536_64_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 1024) -} - -func Benchmark_diff_65536_64_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 8192) -} - -func Benchmark_diff_65536_64_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 16384) -} - -func Benchmark_diff_65536_64_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 32768) -} - -func Benchmark_diff_65536_64_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 32768, 65536) -} - -func Benchmark_diff_65536_64_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 64) -} - -func Benchmark_diff_65536_64_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 128) -} - -func Benchmark_diff_65536_64_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 256) -} - -func Benchmark_diff_65536_64_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 512) -} - -func Benchmark_diff_65536_64_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 1024) -} - -func Benchmark_diff_65536_64_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 8192) -} - -func Benchmark_diff_65536_64_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 16384) -} - -func Benchmark_diff_65536_64_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 32768) -} - -func Benchmark_diff_65536_64_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 64, 65536, 65536) -} - -func Benchmark_diff_65536_1024_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 64) -} - -func Benchmark_diff_65536_1024_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 128) -} - -func Benchmark_diff_65536_1024_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 256) -} - -func Benchmark_diff_65536_1024_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 512) -} - -func Benchmark_diff_65536_1024_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 1024) -} - -func Benchmark_diff_65536_1024_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 8192) -} - -func Benchmark_diff_65536_1024_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 16384) -} - -func Benchmark_diff_65536_1024_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 32768) -} - -func Benchmark_diff_65536_1024_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 64, 65536) -} - -func Benchmark_diff_65536_1024_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 64) -} - -func Benchmark_diff_65536_1024_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 128) -} - -func Benchmark_diff_65536_1024_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 256) -} - -func Benchmark_diff_65536_1024_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 512) -} - -func Benchmark_diff_65536_1024_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 1024) -} - -func Benchmark_diff_65536_1024_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 8192) -} - -func Benchmark_diff_65536_1024_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 16384) -} - -func Benchmark_diff_65536_1024_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 32768) -} - -func Benchmark_diff_65536_1024_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 128, 65536) -} - -func Benchmark_diff_65536_1024_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 64) -} - -func Benchmark_diff_65536_1024_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 128) -} - -func Benchmark_diff_65536_1024_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 256) -} - -func Benchmark_diff_65536_1024_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 512) -} - -func Benchmark_diff_65536_1024_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 1024) -} - -func Benchmark_diff_65536_1024_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 8192) -} - -func Benchmark_diff_65536_1024_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 16384) -} - -func Benchmark_diff_65536_1024_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 32768) -} - -func Benchmark_diff_65536_1024_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 256, 65536) -} - -func Benchmark_diff_65536_1024_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 64) -} - -func Benchmark_diff_65536_1024_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 128) -} - -func Benchmark_diff_65536_1024_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 256) -} - -func Benchmark_diff_65536_1024_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 512) -} - -func Benchmark_diff_65536_1024_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 1024) -} - -func Benchmark_diff_65536_1024_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 8192) -} - -func Benchmark_diff_65536_1024_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 16384) -} - -func Benchmark_diff_65536_1024_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 32768) -} - -func Benchmark_diff_65536_1024_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 512, 65536) -} - -func Benchmark_diff_65536_1024_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 64) -} - -func Benchmark_diff_65536_1024_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 128) -} - -func Benchmark_diff_65536_1024_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 256) -} - -func Benchmark_diff_65536_1024_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 512) -} - -func Benchmark_diff_65536_1024_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 1024) -} - -func Benchmark_diff_65536_1024_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 8192) -} - -func Benchmark_diff_65536_1024_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 16384) -} - -func Benchmark_diff_65536_1024_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 32768) -} - -func Benchmark_diff_65536_1024_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 1024, 65536) -} - -func Benchmark_diff_65536_1024_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 64) -} - -func Benchmark_diff_65536_1024_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 128) -} - -func Benchmark_diff_65536_1024_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 256) -} - -func Benchmark_diff_65536_1024_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 512) -} - -func Benchmark_diff_65536_1024_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 1024) -} - -func Benchmark_diff_65536_1024_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 8192) -} - -func Benchmark_diff_65536_1024_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 16384) -} - -func Benchmark_diff_65536_1024_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 32768) -} - -func Benchmark_diff_65536_1024_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 8192, 65536) -} - -func Benchmark_diff_65536_1024_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 64) -} - -func Benchmark_diff_65536_1024_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 128) -} - -func Benchmark_diff_65536_1024_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 256) -} - -func Benchmark_diff_65536_1024_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 512) -} - -func Benchmark_diff_65536_1024_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 1024) -} - -func Benchmark_diff_65536_1024_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 8192) -} - -func Benchmark_diff_65536_1024_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 16384) -} - -func Benchmark_diff_65536_1024_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 32768) -} - -func Benchmark_diff_65536_1024_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 16384, 65536) -} - -func Benchmark_diff_65536_1024_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 64) -} - -func Benchmark_diff_65536_1024_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 128) -} - -func Benchmark_diff_65536_1024_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 256) -} - -func Benchmark_diff_65536_1024_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 512) -} - -func Benchmark_diff_65536_1024_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 1024) -} - -func Benchmark_diff_65536_1024_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 8192) -} - -func Benchmark_diff_65536_1024_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 16384) -} - -func Benchmark_diff_65536_1024_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 32768) -} - -func Benchmark_diff_65536_1024_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 32768, 65536) -} - -func Benchmark_diff_65536_1024_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 64) -} - -func Benchmark_diff_65536_1024_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 128) -} - -func Benchmark_diff_65536_1024_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 256) -} - -func Benchmark_diff_65536_1024_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 512) -} - -func Benchmark_diff_65536_1024_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 1024) -} - -func Benchmark_diff_65536_1024_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 8192) -} - -func Benchmark_diff_65536_1024_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 16384) -} - -func Benchmark_diff_65536_1024_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 32768) -} - -func Benchmark_diff_65536_1024_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 1024, 65536, 65536) -} - -func Benchmark_diff_65536_65536_64_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 64) -} - -func Benchmark_diff_65536_65536_64_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 128) -} - -func Benchmark_diff_65536_65536_64_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 256) -} - -func Benchmark_diff_65536_65536_64_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 512) -} - -func Benchmark_diff_65536_65536_64_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 1024) -} - -func Benchmark_diff_65536_65536_64_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 8192) -} - -func Benchmark_diff_65536_65536_64_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 16384) -} - -func Benchmark_diff_65536_65536_64_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 32768) -} - -func Benchmark_diff_65536_65536_64_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 64, 65536) -} - -func Benchmark_diff_65536_65536_128_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 64) -} - -func Benchmark_diff_65536_65536_128_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 128) -} - -func Benchmark_diff_65536_65536_128_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 256) -} - -func Benchmark_diff_65536_65536_128_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 512) -} - -func Benchmark_diff_65536_65536_128_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 1024) -} - -func Benchmark_diff_65536_65536_128_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 8192) -} - -func Benchmark_diff_65536_65536_128_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 16384) -} - -func Benchmark_diff_65536_65536_128_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 32768) -} - -func Benchmark_diff_65536_65536_128_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 128, 65536) -} - -func Benchmark_diff_65536_65536_256_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 64) -} - -func Benchmark_diff_65536_65536_256_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 128) -} - -func Benchmark_diff_65536_65536_256_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 256) -} - -func Benchmark_diff_65536_65536_256_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 512) -} - -func Benchmark_diff_65536_65536_256_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 1024) -} - -func Benchmark_diff_65536_65536_256_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 8192) -} - -func Benchmark_diff_65536_65536_256_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 16384) -} - -func Benchmark_diff_65536_65536_256_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 32768) -} - -func Benchmark_diff_65536_65536_256_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 256, 65536) -} - -func Benchmark_diff_65536_65536_512_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 64) -} - -func Benchmark_diff_65536_65536_512_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 128) -} - -func Benchmark_diff_65536_65536_512_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 256) -} - -func Benchmark_diff_65536_65536_512_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 512) -} - -func Benchmark_diff_65536_65536_512_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 1024) -} - -func Benchmark_diff_65536_65536_512_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 8192) -} - -func Benchmark_diff_65536_65536_512_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 16384) -} - -func Benchmark_diff_65536_65536_512_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 32768) -} - -func Benchmark_diff_65536_65536_512_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 512, 65536) -} - -func Benchmark_diff_65536_65536_1024_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 64) -} - -func Benchmark_diff_65536_65536_1024_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 128) -} - -func Benchmark_diff_65536_65536_1024_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 256) -} - -func Benchmark_diff_65536_65536_1024_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 512) -} - -func Benchmark_diff_65536_65536_1024_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 1024) -} - -func Benchmark_diff_65536_65536_1024_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 8192) -} - -func Benchmark_diff_65536_65536_1024_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 16384) -} - -func Benchmark_diff_65536_65536_1024_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 32768) -} - -func Benchmark_diff_65536_65536_1024_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 1024, 65536) -} - -func Benchmark_diff_65536_65536_8192_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 64) -} - -func Benchmark_diff_65536_65536_8192_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 128) -} - -func Benchmark_diff_65536_65536_8192_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 256) -} - -func Benchmark_diff_65536_65536_8192_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 512) -} - -func Benchmark_diff_65536_65536_8192_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 1024) -} - -func Benchmark_diff_65536_65536_8192_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 8192) -} - -func Benchmark_diff_65536_65536_8192_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 16384) -} - -func Benchmark_diff_65536_65536_8192_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 32768) -} - -func Benchmark_diff_65536_65536_8192_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 8192, 65536) -} - -func Benchmark_diff_65536_65536_16384_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 64) -} - -func Benchmark_diff_65536_65536_16384_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 128) -} - -func Benchmark_diff_65536_65536_16384_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 256) -} - -func Benchmark_diff_65536_65536_16384_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 512) -} - -func Benchmark_diff_65536_65536_16384_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 1024) -} - -func Benchmark_diff_65536_65536_16384_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 8192) -} - -func Benchmark_diff_65536_65536_16384_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 16384) -} - -func Benchmark_diff_65536_65536_16384_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 32768) -} - -func Benchmark_diff_65536_65536_16384_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 16384, 65536) -} - -func Benchmark_diff_65536_65536_32768_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 64) -} - -func Benchmark_diff_65536_65536_32768_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 128) -} - -func Benchmark_diff_65536_65536_32768_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 256) -} - -func Benchmark_diff_65536_65536_32768_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 512) -} - -func Benchmark_diff_65536_65536_32768_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 1024) -} - -func Benchmark_diff_65536_65536_32768_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 8192) -} - -func Benchmark_diff_65536_65536_32768_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 16384) -} - -func Benchmark_diff_65536_65536_32768_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 32768) -} - -func Benchmark_diff_65536_65536_32768_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 32768, 65536) -} - -func Benchmark_diff_65536_65536_65536_64(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 64) -} - -func Benchmark_diff_65536_65536_65536_128(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 128) -} - -func Benchmark_diff_65536_65536_65536_256(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 256) -} - -func Benchmark_diff_65536_65536_65536_512(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 512) -} - -func Benchmark_diff_65536_65536_65536_1024(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 1024) -} - -func Benchmark_diff_65536_65536_65536_8192(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 8192) -} - -func Benchmark_diff_65536_65536_65536_16384(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 16384) -} - -func Benchmark_diff_65536_65536_65536_32768(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 32768) -} - -func Benchmark_diff_65536_65536_65536_65536(b *testing.B) { - benchmarkDifferentCombinations(b, "diff", 65536, 65536, 65536, 65536) -} diff --git a/bitmap.go b/bitmap.go index c457e8e62..9e14195ca 100644 --- a/bitmap.go +++ b/bitmap.go @@ -8,8 +8,11 @@ import ( "encoding/base64" "encoding/binary" "encoding/gob" + "encoding/json" + "io" - log "github.com/cihub/seelog" + "github.com/gogo/protobuf/proto" + "github.com/umbel/pilosa/internal" "github.com/yasushi-saito/rbtree" ) @@ -43,6 +46,15 @@ func (b *Bitmap) Chunk(c *Chunk) *Chunk { // AddChunk adds c to the bitmap. func (b *Bitmap) AddChunk(c *Chunk) { b.tree.Insert(c) } +// Chunks returns a list of all chunks. +func (b *Bitmap) Chunks() []*Chunk { + var a []*Chunk + for itr := b.ChunkIterator(); !itr.Limit(); itr = itr.Next() { + a = append(a, itr.Item().Clone()) + } + return a +} + // ChunkIterator returns an iterator for looping over the bitmap's chunks. func (b *Bitmap) ChunkIterator() *ChunkIterator { return &ChunkIterator{b.tree.Min()} @@ -58,18 +70,21 @@ func (b *Bitmap) Clone() *Bitmap { break } - node := itr.Item() - other.AddChunk(&Chunk{ - Key: node.Key, - Value: node.Value.copy(), - }) - + other.AddChunk(itr.Item().Clone()) itr = itr.Next() } return other } -// IntersectionCount returns the number of itersections between b and other. +// Merge adds chunks from other to b. +// Chunks in b are overwritten if they exist in other. +func (b *Bitmap) Merge(other *Bitmap) { + for itr := other.ChunkIterator(); !itr.Limit(); itr = itr.Next() { + b.AddChunk(itr.Item().Clone()) + } +} + +// IntersectionCount returns the number of intersections between b and other. func (b *Bitmap) IntersectionCount(other *Bitmap) uint64 { itr0 := b.ChunkIterator() itr1 := other.ChunkIterator() @@ -91,8 +106,8 @@ func (b *Bitmap) IntersectionCount(other *Bitmap) uint64 { return results } -// Intersection returns the itersection of b and other. -func (b *Bitmap) Intersection(other *Bitmap) *Bitmap { +// Intersect returns the itersection of b and other. +func (b *Bitmap) Intersect(other *Bitmap) *Bitmap { itr0 := b.ChunkIterator() itr1 := other.ChunkIterator() @@ -107,7 +122,7 @@ func (b *Bitmap) Intersection(other *Bitmap) *Bitmap { } else if itr0.Item().Key == itr1.Item().Key { output.AddChunk(&Chunk{ Key: itr0.Item().Key, - Value: itr0.Item().Value.intersection(itr1.Item().Value), + Value: itr0.Item().Value.intersect(itr1.Item().Value), }) itr0 = itr0.Next() itr1 = itr1.Next() @@ -202,7 +217,7 @@ func (b *Bitmap) Difference(other *Bitmap) *Bitmap { Value: itr0.Item().Value.difference(itr1.Item().Value), } - // Could not add if all zero + // Do not add if all bits are zeroed. if chunk.Value.bitcount() > 0 { output.AddChunk(chunk) } @@ -236,35 +251,87 @@ func (b *Bitmap) ToRawCompressString() (string, int) { return base64.StdEncoding.EncodeToString(bt.Bytes()), max_slice } -// ToBytes returns a gob-encoded byte slice of b. -func (b *Bitmap) ToBytes() []byte { - var buf bytes.Buffer - enc := gob.NewEncoder(&buf) - enc.Encode(b.tree.Len()) +// WriteTo writes the encoded bitmap to w. +func (b *Bitmap) WriteTo(w io.Writer) (n int64, err error) { + // Wrap output in gzip compression. + z := gzip.NewWriter(w) + + // Encode chunk count. + enc := gob.NewEncoder(w) + if err := enc.Encode(b.tree.Len()); err != nil { + return 0, err + } + + // Encode all chunks. for i := b.tree.Min(); !i.Limit(); i = i.Next() { - obj := i.Item().(*Chunk) - err := enc.Encode(obj) - if err != nil { - log.Warn(err) + if err := enc.Encode(i.Item().(*Chunk)); err != nil { + return 0, err } } - return buf.Bytes() + + // Flush and close. + if err := z.Close(); err != nil { + return 0, err + } + + return 0, nil } -// FromBytes decodes a gob-encoded byte slice into b. -func (b *Bitmap) FromBytes(raw []byte) { - buf := bytes.NewBuffer(raw) - dec := gob.NewDecoder(buf) +// ReadFrom reads encoded bitmap data from r into b. +func (b *Bitmap) ReadFrom(r io.Reader) (n int64, err error) { + // Uncompress from gzip format. + z, err := gzip.NewReader(r) + if err != nil { + return 0, err + } + dec := gob.NewDecoder(z) + // Read size from data. var size int - dec.Decode(&size) + if err := dec.Decode(&size); err != nil { + return 0, err + } + + // Read chunks into bitmap. b.tree = rbtree.NewTree(rbtreeItemCompare) for i := 0; i < size; i++ { var chunk Chunk - dec.Decode(&chunk) + if err := dec.Decode(&chunk); err != nil { + return 0, err + } b.AddChunk(&chunk) } b.SetCount(b.BitCount()) + + return 0, nil +} + +// MarshalJSON returns a JSON-encoded byte slice of b. +func (b *Bitmap) MarshalJSON() ([]byte, error) { + o := bitmapJSON{ + Chunks: make([]chunkJSON, 0, b.tree.Len()), + } + + for itr := b.ChunkIterator(); !itr.Limit(); itr = itr.Next() { + o.Chunks = append(o.Chunks, chunkJSON{Key: itr.Item().Key, Value: itr.Item().Value}) + } + + return json.Marshal(&o) +} + +// MarshalBinary returns a gob-encoded byte slice of b. +func (b *Bitmap) MarshalBinary() ([]byte, error) { + var buf bytes.Buffer + if _, err := b.WriteTo(&buf); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalBinary decodes a gob-encoded byte slice into b. +func (b *Bitmap) UnmarshalBinary(data []byte) error { + _, err := b.ReadFrom(bytes.NewReader(data)) + return err } // Bits returns the bits in b as a slice of ints. @@ -291,7 +358,7 @@ func (b *Bitmap) Bits() []uint64 { } // SetBit sets the i-th bit of the bitmap. -func (b *Bitmap) SetBit(i uint64) (bool, *Chunk, Address) { +func (b *Bitmap) SetBit(i uint64) (changed bool) { address := deref(i) chunk := b.Chunk(&Chunk{address.ChunkKey, make(Blocks, 32)}) @@ -300,29 +367,29 @@ func (b *Bitmap) SetBit(i uint64) (bool, *Chunk, Address) { b.AddChunk(chunk) } - changed := chunk.Value.setBit(address.BlockIndex, address.Bit) + changed = chunk.Value.setBit(address.BlockIndex, address.Bit) if changed { b.bcount++ } - return changed, chunk, address + return changed } // ClearBit clears the i-th bit of the bitmap. -func (b *Bitmap) ClearBit(i uint64) (bool, *Chunk, Address) { +func (b *Bitmap) ClearBit(i uint64) (changed bool) { address := deref(i) chunk := b.Chunk(&Chunk{address.ChunkKey, make(Blocks, 32)}) if chunk == nil { - return false, nil, address + return false } - changed := chunk.Value.clearBit(address.BlockIndex, address.Bit) + changed = chunk.Value.clearBit(address.BlockIndex, address.Bit) if changed && b.bcount > 0 { b.bcount-- } - return changed, chunk, address + return changed } // Len returns the number of chunks in b. @@ -343,12 +410,75 @@ func (b *Bitmap) BitCount() uint64 { return n } +// encodeBitmap converts b into its internal representation. +func encodeBitmap(b *Bitmap) *internal.Bitmap { + pb := &internal.Bitmap{} + for i := b.tree.Min(); !i.Limit(); i = i.Next() { + pb.Chunks = append(pb.Chunks, encodeChunk(i.Item().(*Chunk))) + } + return pb +} + +// decodeBitmap converts b from its internal representation. +func decodeBitmap(pb *internal.Bitmap) *Bitmap { + b := NewBitmap() + for _, chunk := range pb.GetChunks() { + b.AddChunk(decodeChunk(chunk)) + } + b.SetCount(b.BitCount()) + return b +} + +// Union performs a union on a slice of bitmaps. +func Union(bitmaps []*Bitmap) *Bitmap { + other := bitmaps[0] + for _, bm := range bitmaps[1:] { + other = other.Union(bm) + } + return other +} + +// bitmapJSON is the JSON representation of Bitmap. +type bitmapJSON struct { + Chunks []chunkJSON `json:"chunks"` +} + // Chunk represents a set of blocks in a Bitmap. type Chunk struct { Key uint64 Value Blocks } +// Clone returns a copy of c. +func (c *Chunk) Clone() *Chunk { + return &Chunk{ + Key: c.Key, + Value: c.Value.copy(), + } +} + +// encodeChunks encodes c into its internal representation. +func encodeChunk(c *Chunk) *internal.Chunk { + return &internal.Chunk{ + Key: proto.Uint64(c.Key), + Value: []uint64(c.Value), + } +} + +// decodeChunk decodes c from its internal representation. +func decodeChunk(pb *internal.Chunk) *Chunk { + return &Chunk{ + Key: pb.GetKey(), + Value: Blocks(pb.GetValue()), + } +} + +// chunkJSON is the JSON representation of Chunk. +type chunkJSON struct { + Key uint64 + Value []uint64 +} + // ChunkIterator represents an object for iterating over chunks in a bitmap. type ChunkIterator struct { itr rbtree.Iterator @@ -383,6 +513,73 @@ func rbtreeItemCompare(a, b rbtree.Item) int { return 0 } +type Blocks []uint64 + +// NewBlocks returns a 32-length Block. +func NewBlocks() Blocks { + return make(Blocks, 32) +} + +func (a Blocks) bitcount() uint64 { + return popcntSlice(a) +} + +func (a Blocks) union(other Blocks) Blocks { + ret := NewBlocks() + for i, _ := range a { + ret[i] = a[i] | other[i] + } + return ret +} + +func (a Blocks) invert() Blocks { + other := NewBlocks() + for i, _ := range a { + other[i] = ^a[i] + } + return other +} + +func (a Blocks) copy() Blocks { + other := NewBlocks() + for i, _ := range a { + other[i] = a[i] + } + return other +} + +func (a Blocks) andcount(other Blocks) uint64 { + return popcntAndSliceAsm(a, other) +} + +func (a Blocks) intersect(other Blocks) Blocks { + ret := NewBlocks() + for i, _ := range a { + ret[i] = a[i] & other[i] + } + return ret +} + +func (a Blocks) difference(other Blocks) Blocks { + ret := NewBlocks() + for i, _ := range a { + ret[i] = a[i] &^ other[i] + } + return ret +} + +func (a Blocks) setBit(i uint8, bit uint8) (changed bool) { + val := a[i] & (1 << bit) + a[i] |= 1 << bit + return val == 0 +} + +func (a Blocks) clearBit(i uint8, bit uint8) (changed bool) { + val := a[i] & (1 << bit) + a[i] &= ^(1 << bit) + return val != 0 +} + // Address represents a location for a given chunk/block/bit. type Address struct { ChunkKey uint64 diff --git a/blocks.go b/blocks.go deleted file mode 100644 index 6803b84aa..000000000 --- a/blocks.go +++ /dev/null @@ -1,74 +0,0 @@ -package pilosa - -import ( - "fmt" -) - -type Blocks []uint64 - -// NewBlocks returns a 32-length Block. -func NewBlocks() Blocks { - return make(Blocks, 32) -} - -func (a Blocks) bitcount() uint64 { - fmt.Println("bitcount:", a) - return popcntSlice(a) -} - -func (a Blocks) union(other Blocks) Blocks { - ret := NewBlocks() - for i, _ := range a { - ret[i] = a[i] | other[i] - } - return ret -} - -func (a Blocks) invert() Blocks { - other := NewBlocks() - for i, _ := range a { - other[i] = ^a[i] - } - return other -} - -func (a Blocks) copy() Blocks { - other := NewBlocks() - for i, _ := range a { - other[i] = a[i] - } - return other -} - -func (a Blocks) andcount(other Blocks) uint64 { - println("andcount") - return popcntAndSliceAsm(a, other) -} - -func (a Blocks) intersection(other Blocks) Blocks { - ret := NewBlocks() - for i, _ := range a { - ret[i] = a[i] & other[i] - } - return ret -} - -func (a Blocks) difference(other Blocks) Blocks { - ret := NewBlocks() - for i, _ := range a { - ret[i] = a[i] &^ other[i] - } - return ret -} - -func (a Blocks) setBit(i uint8, bit uint8) (changed bool) { - val := a[i] & (1 << bit) - a[i] |= 1 << bit - return val == 0 -} - -func (a Blocks) clearBit(i uint8, bit uint8) (changed bool) { - val := a[i] & (1 << bit) - a[i] &= ^(1 << bit) - return val != 0 -} diff --git a/brand.go b/brand.go deleted file mode 100644 index c3c39ebe8..000000000 --- a/brand.go +++ /dev/null @@ -1,448 +0,0 @@ -package pilosa - -import ( - "encoding/json" - "fmt" - "math/rand" - "sort" - "sync" - "time" - - log "github.com/cihub/seelog" - "github.com/umbel/pilosa/statsd" -) - -var FragmentBase string - -var globalLock sync.Mutex - -type Pair struct { - Key, Count uint64 -} -type Rank struct { - *Pair - bitmap *Bitmap - category uint64 -} - -type RankList []*Rank - -func (p RankList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p RankList) Len() int { return len(p) } -func (p RankList) Less(i, j int) bool { return p[i].Count > p[j].Count } - -type Brand struct { - bitmap_cache map[uint64]*Rank - db string - frame string - slice int - storage Storage - rankings RankList - rank_count int - threshold_value uint64 - threshold_length int - threshold_idx int - skip int - rank_time time.Time -} - -func NewBrand(db string, frame string, slice int, s Storage, threshold_len int, threshold int, skipp int) *Brand { - f := new(Brand) - f.storage = s - f.frame = frame - f.slice = slice - f.db = db - f.rank_count = 0 - f.threshold_value = 0 - f.threshold_length = threshold_len - f.threshold_idx = threshold - f.skip = skipp - f.Clear() //alloc the cache - return f - -} - -func (b *Brand) Clear() bool { - b.bitmap_cache = make(map[uint64]*Rank) - return true -} - -func (b *Brand) Exists(bitmap_id uint64) bool { - _, ok := b.bitmap_cache[bitmap_id] - return ok -} - -func (b *Brand) Get(bitmap_id uint64) *Bitmap { - if bm, ok := b.bitmap_cache[bitmap_id]; ok { - return bm.bitmap - } - - // I should fetch the category here..need to come up with a good source - bm, filter := b.storage.Fetch(bitmap_id, b.db, b.frame, b.slice) - b.cache_it(bm, bitmap_id, filter) - return bm -} - -func (b *Brand) Get_nocache(bitmap_id uint64) (*Bitmap, uint64) { - if bm, ok := b.bitmap_cache[bitmap_id]; ok { - return bm.bitmap, bm.category - } - - //I should fetch the category here..need to come up with a good source - return b.storage.Fetch(bitmap_id, b.db, b.frame, b.slice) -} - -func (b *Brand) GetFilter(bitmap_id, filter uint64) *Bitmap { - bm, old_filter := b.storage.Fetch(bitmap_id, b.db, b.frame, b.slice) - if filter == 0 { - filter = old_filter - } - b.cache_it(bm, bitmap_id, filter) - return bm -} - -func (b *Brand) cache_it(bm *Bitmap, bitmap_id uint64, category uint64) { - if bm.Count() >= b.threshold_value { - b.bitmap_cache[bitmap_id] = &Rank{&Pair{bitmap_id, bm.Count()}, bm, category} - if len(b.bitmap_cache) > b.threshold_length { - log.Info("RANK:", len(b.bitmap_cache), b.threshold_length, b.threshold_value) - b.Rank() - b.trim() - } - } -} - -func (b *Brand) trim() { - for k, item := range b.bitmap_cache { - if item.bitmap.Count() <= b.threshold_value { - delete(b.bitmap_cache, k) - } - } - log.Info("TRIM:", len(b.bitmap_cache), b.threshold_length) -} - -func (b *Brand) SetBit(bitmap_id uint64, bit_pos uint64, filter uint64) bool { - bm1, ok := b.bitmap_cache[bitmap_id] - var bm *Bitmap - if ok { - bm = bm1.bitmap - } else { - bm = b.GetFilter(bitmap_id, filter) //aways overwrites what is in cass filter type - } - change, chunk, address := bm.SetBit(bit_pos) - if change { - val := chunk.Value[address.BlockIndex] - b.storage.StoreBit(bitmap_id, b.db, b.frame, b.slice, filter, address.ChunkKey, int32(address.BlockIndex), val, bm.Count()) - b.rank_count++ - } - return change -} - -func (b *Brand) Rank() { - start := time.Now() - var list RankList - for k, item := range b.bitmap_cache { - list = append(list, &Rank{&Pair{k, item.bitmap.Count()}, item.bitmap, item.category}) - } - sort.Sort(list) - b.rankings = list - if len(list) > b.threshold_idx { - item := list[b.threshold_idx] - b.threshold_value = item.bitmap.Count() - } else { - b.threshold_value = 1 - } - - b.rank_count = 0 - delta := time.Since(start) - statsd.SendTimer("brand_Rank", delta.Nanoseconds()) - b.rank_time = start -} - -func packagePairs(r RankList) []Pair { - res := make([]Pair, r.Len()) - for i, v := range r { - res[i] = Pair{v.Key, v.Count} - } - return res -} - -func (b *Brand) Stats() interface{} { - total := uint64(0) - i := uint64(0) - bit_total := uint64(0) - for _, v := range b.bitmap_cache { - total += uint64(v.bitmap.Len()) * uint64(256) - i += 1 - bit_total += v.Count - } - avg_bytes := uint64(0) - avg_bits := uint64(0) - if i > 0 { - avg_bytes = total / i - avg_bits = bit_total / i - } - - stats := map[string]interface{}{ - "total size of cache in bytes": total, - "number of bitmaps": len(b.bitmap_cache), - "avg size of bitmap in space(bytes)": avg_bytes, - "avg size of bitmap in bits": avg_bits, - "rank counter": b.rank_count, - "threshold_value": b.threshold_value, - "threshold_length": b.threshold_length, - "threshold_idx": b.threshold_idx, - "skip": b.skip} - return stats -} - -func (b *Brand) Store(bitmap_id uint64, bm *Bitmap, filter uint64) error { - if err := b.storage.Store(bitmap_id, b.db, b.frame, b.slice, filter, bm); err != nil { - return err - } - b.cache_it(bm, bitmap_id, filter) - return nil -} - -func (b *Brand) checkRank() { - if len(b.rankings) < 50 { - b.Rank() - return - } - - if b.rank_count > 0 { - last := time.Since(b.rank_time) * time.Second - if last > 60*5 { - b.Rank() - } - } -} -func (b *Brand) TopN(src_bitmap *Bitmap, n int, categories []uint64) []Pair { - b.checkRank() - set := make(map[uint64]struct{}) - for _, v := range categories { - set[v] = struct{}{} - } - - return b.TopNCat(src_bitmap, n, set) -} - -func dump(r RankList, n int) { - for i, v := range r { - log.Info(i, v) - if i > n { - return - } - } -} - -func (b *Brand) TopNAll(n int, categories []uint64) []Pair { - log.Trace("TopNAll") - - b.checkRank() - results := make([]Pair, 0, 0) - - set := make(map[uint64]struct{}) - needCat := false - for _, v := range categories { - set[v] = struct{}{} - needCat = true - } - - count := 0 - for _, pair := range b.rankings { - if needCat { - if _, ok := set[pair.category]; !ok { - continue - } - } - - if count >= n { - break - } - if pair.Count > 0 { - results = append(results, Pair{pair.Key, pair.Count}) - } - count++ - } - return results -} - -func (b *Brand) TopNCat(src_bitmap *Bitmap, n int, set map[uint64]struct{}) []Pair { - breakout := 1000 - var ( - o *Rank - results RankList - ) - counter := 0 - x := 0 - - needCat := (len(set) > 0) - for i, pair := range b.rankings { - if needCat { - if _, ok := set[pair.category]; !ok { - continue - } - } - - if counter > n { - break - } - bc := src_bitmap.IntersectionCount(pair.bitmap) - if bc > 0 { - results = append(results, &Rank{&Pair{pair.Key, bc}, nil, pair.category}) - counter = counter + 1 - } - x = i - } - - sort.Sort(results) - if counter < n { - return packagePairs(results) - } - end := len(results) - 1 - o = results[end] - current_threshold := o.Count - - if current_threshold <= 10 { - return packagePairs(results) - } - - results = append(results, o) - - for i := x + 1; i < len(b.rankings); i++ { - o = b.rankings[i] - - if needCat { - if _, ok := set[o.category]; !ok { - continue - } - counter = counter + 1 - } else { - counter = counter + 1 - } - - if counter > breakout { - break - } - - //if o.Count < current_threshold { //done - //need something to do with the size of initianl bitmap - if o.Count < current_threshold { //done - break - - } - - bc := src_bitmap.IntersectionCount(o.bitmap) - - if bc > current_threshold { - if results[end-1].Count > bc { - results[end] = &Rank{&Pair{o.Key, bc}, nil, o.category} - current_threshold = bc - } else { - results[end+1] = &Rank{&Pair{o.Key, bc}, nil, o.category} - sort.Sort(results) - o = results[end] - current_threshold = o.Count - } - } - } - return packagePairs(results[:end]) -} -func (b *Brand) getFileName() string { - base := FragmentBase - if base == "" { - base = "." - } - - return fmt.Sprintf("%s/%s.%s.%d.json", base, b.db, b.frame, b.slice) -} - -func (b *Brand) Persist() error { - log.Info("Brand Persist:", b.getFileName()) - b.storage.Flush() - asize := len(b.bitmap_cache) - - if asize == 0 { - log.Warn("Nothing to save ", b.getFileName()) - return nil - } - w, err := createFile(b.getFileName()) - if err != nil { - log.Warn("Error opening outfile ", b.getFileName()) - log.Warn(err) - return err - } - defer w.Close() - defer b.storage.Close() - - var list RankList - for k, item := range b.bitmap_cache { - list = append(list, &Rank{&Pair{k, item.bitmap.Count()}, item.bitmap, item.category}) - } - - sort.Sort(list) - - results := make([]uint64, asize) - i := 0 - for _, k := range list { // map[uint64]*Rank - results[i] = k.Key - i += 1 - } - - encoder := json.NewEncoder(w) - return encoder.Encode(results) -} - -func (b *Brand) Load(f *Fragment) { - log.Warn("Brand Load") - time.Sleep(time.Duration(rand.Intn(32)) * time.Second) //trying to avoid mass cassandra hit - r, err := openFile(b.getFileName()) - if err != nil { - log.Warn("NO Brand Init File:", b.getFileName()) - return - } - dec := json.NewDecoder(r) - var keys []uint64 - if err := dec.Decode(&keys); err != nil { - return - } - - globalLock.Lock() - defer globalLock.Unlock() - - // probaly need to get a etcd lock too someday - for _, k := range keys { - b.Get(k) - time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) //trying to avoid mass cassandra hit - } -} - -func (b *Brand) ClearBit(bitmap_id uint64, bit_pos uint64) bool { - log.Trace("ClearBit", bitmap_id, bit_pos) - bm1, ok := b.bitmap_cache[bitmap_id] - var bm *Bitmap - filter := uint64(0) - if ok { - bm = bm1.bitmap - filter = bm1.category - } else { - bm, filter = b.Get_nocache(bitmap_id) - if bm.Count() == 0 { - return false //nothing to unset - } - } - - changed, chunk, address := bm.ClearBit(bit_pos) - if changed { - val := chunk.Value[address.BlockIndex] - if val == 0 { - b.storage.RemoveBit(bitmap_id, b.db, b.frame, b.slice, filter, address.ChunkKey, int32(address.BlockIndex), bm.Count()) - } else { - b.storage.StoreBit(bitmap_id, b.db, b.frame, b.slice, filter, address.ChunkKey, int32(address.BlockIndex), val, bm.Count()) - } - b.rank_count++ - } - - return changed -} diff --git a/brand_test.go b/brand_test.go deleted file mode 100644 index 6ff6a2895..000000000 --- a/brand_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package pilosa_test - -import ( - "math/rand" - "testing" - - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/statsd" - "github.com/umbel/pilosa/storage/mem" -) - -var ( - size int - membrand *pilosa.Brand - cassbrand *pilosa.Brand -) - -func init() { - size = 1000 - - statsd.Setup() - // SetupCassandra() - - membrand = pilosa.NewBrand("db", "frame", 0, mem.NewStorage(), size, size, 0) - for i := uint64(0); i < uint64(size); i++ { - membrand.SetBit(i, 0, 1) - } - // cassbrand = NewBrand("db", "frame", 0, NewCassStorage(), size, size, 0) - // for i := uint64(0); i < uint64(size); i++ { - // cassbrand.SetBit(i, 0, 1) - // } -} - -func benchmarkBrand(b *testing.B, size int, fill int, brand *pilosa.Brand) { - println(b.N) - for i := 0; i < b.N; i++ { - bid := rand.Int() % size - profile := uint64(i % fill) - brand.SetBit(uint64(bid), profile, 1) - } -} - -func BenchmarkBrandMemSetBitL2(b *testing.B) { benchmarkBrand(b, size, 1024*64, membrand) } -func BenchmarkBrandCasSetBitL2(b *testing.B) { benchmarkBrand(b, size, 1024*64, cassbrand) } diff --git a/cache.go b/cache.go new file mode 100644 index 000000000..7040b124c --- /dev/null +++ b/cache.go @@ -0,0 +1,262 @@ +package pilosa + +import ( + "encoding/json" + "io" + "sort" + "time" + + "github.com/gogo/protobuf/proto" + "github.com/golang/groupcache/lru" + "github.com/umbel/pilosa/internal" +) + +// Cache represents a cache for bitmaps. +type Cache interface { + io.WriterTo + io.ReaderFrom + + Add(bitmapID, category uint64, bm *Bitmap) + Get(bitmapID uint64) (bm *Bitmap, ok bool) + Len() int + + // Updates the cache, if necessary. + Invalidate() + + // Returns a list of all key/count pairs. + Pairs() []Pair +} + +// LRUCache represents a least recently used Cache implemenation. +type LRUCache struct { + cache *lru.Cache + keys map[uint64]struct{} +} + +// NewLRUCache returns a new instance of LRUCache. +func NewLRUCache(maxEntries int) *LRUCache { + c := &LRUCache{ + cache: lru.New(maxEntries), + keys: make(map[uint64]struct{}), + } + c.cache.OnEvicted = c.onEvicted + return c +} + +// Get returns a bitmap with a given id. +func (c *LRUCache) Add(bitmapID, category uint64, bm *Bitmap) { + c.cache.Add(bitmapID, bm) + c.keys[bitmapID] = struct{}{} +} + +// Get returns a bitmap with a given id. +func (c *LRUCache) Get(bitmapID uint64) (bm *Bitmap, ok bool) { + value, ok := c.cache.Get(bitmapID) + if !ok { + return nil, false + } + return value.(*Bitmap), true +} + +// Len returns the number of items in the cache. +func (c *LRUCache) Len() int { return c.cache.Len() } + +// Invalidate is a no-op. +func (c *LRUCache) Invalidate() {} + +// Pairs returns all key/count pairs in the cache. +func (c *LRUCache) Pairs() []Pair { + a := make([]Pair, 0, len(c.keys)) + for k := range c.keys { + bm, _ := c.Get(k) + + a = append(a, Pair{ + Key: k, + Count: bm.Count(), + }) + } + return a +} + +// WriteTo writes the cache to w. +func (c *LRUCache) WriteTo(w io.Writer) (n int64, err error) { + // Write keys to slice. + a := make([]uint64, 0, len(c.keys)) + for k := range c.keys { + a = append(a, k) + } + + // Encode to file as array of keys. + if err := json.NewEncoder(w).Encode(a); err != nil { + return 0, err + } + return 0, nil +} + +// ReadFrom read from r into the cache. +func (c *LRUCache) ReadFrom(r io.Reader) (n int64, err error) { + var keys []uint64 + if err := json.NewDecoder(r).Decode(&keys); err != nil { + return 0, err + } + panic("FIXME: TODO") +} + +func (c *LRUCache) onEvicted(key lru.Key, _ interface{}) { + delete(c.keys, key.(uint64)) +} + +// Ensure LRUCache implements Cache. +var _ Cache = &LRUCache{} + +// RankCache represents a cache with sorted entries. +type RankCache struct { + entries map[uint64]*Pair + rankings []Pair // cached, ordered list + + updateN int + updateTime time.Time + + ThresholdLength int + ThresholdIndex int + ThresholdValue uint64 +} + +// NewRankCache returns a new instance of RankCache. +func NewRankCache() *RankCache { + return &RankCache{ + entries: make(map[uint64]*Pair), + } +} + +// Get returns a bitmap with a given id. +func (c *RankCache) Add(bitmapID, category uint64, bm *Bitmap) { + // Ignore if the bit count on the bitmap is below the threshold. + if bm.Count() < c.ThresholdValue { + return + } + + // Add to cache. + c.entries[bitmapID] = &Pair{ + Key: bitmapID, + Count: bm.Count(), + bitmap: bm, + category: category, + } + + // If size is larger than the threshold then trim it. + if len(c.entries) > c.ThresholdLength { + c.update() + for k, entry := range c.entries { + if entry.bitmap.Count() <= c.ThresholdValue { + delete(c.entries, k) + } + } + } +} + +// Get returns a bitmap with a given id. +func (c *RankCache) Get(bitmapID uint64) (bm *Bitmap, ok bool) { + entry, ok := c.entries[bitmapID] + if !ok { + return nil, false + } + return entry.bitmap, true +} + +// Len returns the number of items in the cache. +func (c *RankCache) Len() int { return len(c.entries) } + +// Invalidate reorders the entries, if necessary. +func (c *RankCache) Invalidate() { + // Update if there aren't many items or it hasn't been updated recently. + if len(c.rankings) < 50 || (c.updateN > 0 && time.Since(c.updateTime) > 5*time.Minute) { + c.update() + } +} + +// update reorders the entries by rank. +func (c *RankCache) update() { + // Convert cache to a sorted list. + list := make([]Pair, 0, len(c.entries)) + for k, item := range c.entries { + list = append(list, Pair{ + Key: k, + Count: item.bitmap.Count(), + bitmap: item.bitmap, + category: item.category, + }) + } + sort.Sort(Pairs(list)) + + // Store the count of the item at the threshold index. + c.rankings = list + if len(c.rankings) > c.ThresholdIndex { + c.ThresholdValue = list[c.ThresholdIndex].bitmap.Count() + } else { + c.ThresholdValue = 1 + } + + // Reset counters. + c.updateTime, c.updateN = time.Now(), 0 +} + +// Pairs returns an ordered list of key/count pairs. +func (c *RankCache) Pairs() []Pair { return c.rankings } + +// WriteTo writes the cache to w. +func (c *RankCache) WriteTo(w io.Writer) (n int64, err error) { + panic("FIXME: TODO") +} + +// ReadFrom read from r into the cache. +func (c *RankCache) ReadFrom(r io.Reader) (n int64, err error) { + panic("FIXME: TODO") +} + +// Ensure RankCache implements Cache. +var _ Cache = &RankCache{} + +type Pair struct { + Key uint64 `json:"key"` + Count uint64 `json:"count"` + + bitmap *Bitmap + category uint64 +} + +func encodePair(p Pair) *internal.Pair { + return &internal.Pair{ + Key: proto.Uint64(p.Key), + Count: proto.Uint64(p.Count), + } +} + +func decodePair(pb *internal.Pair) Pair { + return Pair{ + Key: pb.GetKey(), + Count: pb.GetCount(), + } +} + +type Pairs []Pair + +func (p Pairs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p Pairs) Len() int { return len(p) } +func (p Pairs) Less(i, j int) bool { return p[i].Count > p[j].Count } + +func encodePairs(a Pairs) []*internal.Pair { + other := make([]*internal.Pair, len(a)) + for i := range a { + other[i] = encodePair(a[i]) + } + return other +} + +func decodePairs(a []*internal.Pair) []Pair { + other := make([]Pair, len(a)) + for i := range a { + other[i] = decodePair(a[i]) + } + return other +} diff --git a/cluster.go b/cluster.go new file mode 100644 index 000000000..efdadef98 --- /dev/null +++ b/cluster.go @@ -0,0 +1,123 @@ +package pilosa + +import ( + "encoding/binary" + "hash/fnv" +) + +const ( + // DefaultPartitionN is the default number of partitions in a cluster. + DefaultPartitionN = 64 + + // DefaultReplicaN is the default number of replicas per partition. + DefaultReplicaN = 1 +) + +// Node represents a node in the cluster. +type Node struct { + Host string +} + +// Nodes represents a list of nodes. +type Nodes []*Node + +// ContainsHost returns true if host matches on of the node's host. +func (a Nodes) ContainsHost(host string) bool { + for _, n := range a { + if n.Host == host { + return true + } + } + return false +} + +// Hosts returns a list of all hostnames. +func (a Nodes) Hosts() []string { + hosts := make([]string, len(a)) + for i, n := range a { + hosts[i] = n.Host + } + return hosts +} + +// Cluster represents a collection of nodes. +type Cluster struct { + Nodes []*Node + + // Hashing algorithm used to assign partitions to nodes. + Hasher Hasher + + // The number of partitions in the cluster. + PartitionN int + + // The number of replicas a partition has. + ReplicaN int +} + +// NewCluster returns a new instance of Cluster with defaults. +func NewCluster() *Cluster { + return &Cluster{ + Hasher: &jmphasher{}, + PartitionN: DefaultPartitionN, + ReplicaN: DefaultReplicaN, + } +} + +// Partition returns the partition that a slice belongs to. +func (c *Cluster) Partition(slice uint64) int { + var buf [8]byte + binary.BigEndian.PutUint64(buf[:], slice) + + // Hash the bytes and mod by partition count. + h := fnv.New64a() + h.Write(buf[:]) + return int(h.Sum64() % uint64(c.PartitionN)) +} + +// SliceNodes returns a list of nodes that own a slice. +func (c *Cluster) SliceNodes(slice uint64) []*Node { + return c.PartitionNodes(c.Partition(slice)) +} + +// PartitionNodes returns a list of nodes that own a partition. +func (c *Cluster) PartitionNodes(partitionID int) []*Node { + // Default replica count to between one and the number of nodes. + // The replica count can be zero if there are no nodes. + replicaN := c.ReplicaN + if replicaN > len(c.Nodes) { + replicaN = len(c.Nodes) + } else if replicaN == 0 { + replicaN = 1 + } + + // Determine primary owner node. + index := c.Hasher.Hash(uint64(partitionID), len(c.Nodes)) + + // Collect nodes around the ring. + nodes := make([]*Node, replicaN) + for i := 0; i < replicaN; i++ { + nodes[i] = c.Nodes[(index+i)%len(c.Nodes)] + } + + return nodes +} + +// Hasher represents an interface to hash integers into buckets. +type Hasher interface { + // Hashes the key into a number between [0,N). + Hash(key uint64, n int) int +} + +// jmphasher represents an implementation of jmphash. Implements Hasher. +type jmphasher struct{} + +// Hash returns the integer hash for the given key. +func (h *jmphasher) Hash(key uint64, n int) int { + b, j := int64(-1), int64(0) + for j < int64(n) { + b = j + key = key*uint64(2862933555777941757) + 1 + j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1))) + } + return int(b) +} diff --git a/cluster_test.go b/cluster_test.go new file mode 100644 index 000000000..13a256fdf --- /dev/null +++ b/cluster_test.go @@ -0,0 +1,90 @@ +package pilosa_test + +import ( + "fmt" + "math/rand" + "reflect" + "testing" + "testing/quick" + + "github.com/davecgh/go-spew/spew" + "github.com/umbel/pilosa" +) + +// Ensure the cluster can fairly distribute partitions across the nodes. +func TestCluster_Owners(t *testing.T) { + c := pilosa.Cluster{ + Nodes: []*pilosa.Node{ + {Host: "serverA:1000"}, + {Host: "serverB:1000"}, + {Host: "serverC:1000"}, + }, + Hasher: NewModHasher(), + ReplicaN: 2, + } + + // Verify nodes are distributed. + if a := c.PartitionNodes(0); !reflect.DeepEqual(a, []*pilosa.Node{c.Nodes[0], c.Nodes[1]}) { + t.Fatalf("unexpected owners: %s", spew.Sdump(a)) + } + + // Verify nodes go around the ring. + if a := c.PartitionNodes(2); !reflect.DeepEqual(a, []*pilosa.Node{c.Nodes[2], c.Nodes[0]}) { + t.Fatalf("unexpected owners: %s", spew.Sdump(a)) + } +} + +// Ensure the partitioner can assign a fragment to a partition. +func TestCluster_Partition(t *testing.T) { + if err := quick.Check(func(slice uint64, partitionN int) bool { + c := pilosa.NewCluster() + c.PartitionN = partitionN + + partitionID := c.Partition(slice) + if partitionID < 0 || partitionID > partitionN { + t.Errorf("partition out of range: slice=%d, p=%d, n=%d", slice, partitionID, partitionN) + } + + return true + }, &quick.Config{ + Values: func(values []reflect.Value, rand *rand.Rand) { + values[0] = reflect.ValueOf(uint64(rand.Uint32())) + values[1] = reflect.ValueOf(rand.Intn(1000) + 1) + }, + }); err != nil { + t.Fatal(err) + } +} + +// NewCluster returns a cluster with n nodes and uses a mod-based hasher. +func NewCluster(n int) *pilosa.Cluster { + c := pilosa.NewCluster() + c.ReplicaN = 1 + c.Hasher = NewModHasher() + + for i := 0; i < n; i++ { + c.Nodes = append(c.Nodes, &pilosa.Node{ + Host: fmt.Sprintf("host%d", i), + }) + } + + return c +} + +// ModHasher represents a simple, mod-based hashing. +type ModHasher struct{} + +// NewModHasher returns a new instance of ModHasher with n buckets. +func NewModHasher() *ModHasher { return &ModHasher{} } + +func (*ModHasher) Hash(key uint64, n int) int { return int(key) % n } + +// ConstHasher represents hash that always returns the same index. +type ConstHasher struct { + i int +} + +// NewConstHasher returns a new instance of ConstHasher that always returns i. +func NewConstHasher(i int) *ConstHasher { return &ConstHasher{i: i} } + +func (h *ConstHasher) Hash(key uint64, n int) int { return h.i } diff --git a/cmd/pilosa/config.go b/cmd/pilosa/config.go index 37bf27534..ba57ef2b2 100644 --- a/cmd/pilosa/config.go +++ b/cmd/pilosa/config.go @@ -4,106 +4,55 @@ import ( "time" "github.com/umbel/pilosa" - "github.com/umbel/pilosa/statsd" - _ "github.com/umbel/pilosa/storage" - "github.com/umbel/pilosa/storage/cassandra" - "github.com/umbel/pilosa/transport" ) const ( - // DefaultLogPath is the default file path where the log will be written. - DefaultLogPath = "/tmps" + // DefaultHost is the default hostname to use. + DefaultHost = "localhost" - // DefaultLogLevel is the default logging level used by seelog. - DefaultLogLevel = "info" - - // DefaultFragmentBase is the default path where fragments are stored. - DefaultFragmentBase = "/tmp/single" -) - -var ( - // DefaultSupportedFrames are the frames supported by default. - DefaultSupportedFrames = [...]string{"b.n", "t.t", "l.n", "d", "p.n"} - - // DefaultETCDHosts are the default hosts to connect to. - DefaultETCDHosts = [...]string{"http://127.0.0.1:4001"} + // DefaultAddr is the default HTTP address to use. + DefaultAddr = ":15000" ) // Config represents the configuration for the command. type Config struct { - ID *pilosa.GUID `toml:"id"` - Host string `toml:"host"` + Host string `toml:"host"` + Addr string `toml:"addr"` - TCP struct { - Port int `toml:"port"` - } `toml:"tcp"` - - HTTP struct { - Port int `toml:"port"` - DefaultDB string `toml:"default-db"` - RequestLogPath string `toml:"request-log-path"` - SetBitLogEnabled bool `toml:"set-bit-log-enabled"` - } `toml:"http"` - - Log struct { - Path string `toml:"path"` - Level string `toml:"level"` - } - - Storage struct { - Backend string `toml:"backend"` - Hosts []string `toml:"hosts"` - Keyspace string `toml:"keyspace"` - - FragmentBase string `toml:"fragment-base"` - SupportedFrames []string `toml:"supported-frames"` - - CassandraTimeWindow Duration `toml:"cassandra-time-window"` - CassandraMaxSizeBatch int `toml:"cassandra-max-size-batch"` - } `toml:"storage"` - - AWS struct { - AccessKeyID string `toml:"access-key-id"` - SecretAccessKey string `toml:"secret-access-key"` - } `toml:"aws"` - - LevelDB struct { - Path string `toml:"path"` - } `toml:"leveldb"` - - Statsd struct { - Host string `toml:"host"` - } `toml:"statsd"` + Cluster struct { + ReplicaN int `toml:"replicas"` + Nodes []struct { + Host string `toml:"host"` + } `toml:"nodes"` + } `toml:"cluster"` Plugins struct { Path string `toml:"path"` } `toml:"plugins"` - - ETCD struct { - Hosts []string `toml:"hosts"` - FragmentAllocLockTTL Duration `toml:"fragment-alloc-lock-ttl"` - } `toml:"etcd"` } // NewConfig returns an instance of Config with default options. -func NewConfig() Config { - var c Config - c.Host = "localhost" - c.TCP.Port = transport.DefaultTCPPort - c.HTTP.Port = transport.DefaultHTTPPort - c.Log.Path = DefaultLogPath - c.Storage.Backend = pilosa.DefaultBackend - c.Storage.Hosts = cassandra.DefaultHosts - c.Storage.Keyspace = cassandra.DefaultKeyspace - c.Storage.FragmentBase = DefaultFragmentBase - c.Storage.SupportedFrames = DefaultSupportedFrames[:] - c.Storage.CassandraTimeWindow = Duration(cassandra.DefaultFlushInterval) - c.Storage.CassandraMaxSizeBatch = cassandra.DefaultFlushThreshold - c.Statsd.Host = statsd.DefaultHost - c.ETCD.Hosts = DefaultETCDHosts[:] +func NewConfig() *Config { + c := &Config{ + Host: DefaultHost, + Addr: DefaultAddr, + } + c.Cluster.ReplicaN = pilosa.DefaultReplicaN return c } +// PilosaCluster returns a new instance of pilosa.Cluster based on the config. +func (c *Config) PilosaCluster() *pilosa.Cluster { + cluster := pilosa.NewCluster() + cluster.ReplicaN = c.Cluster.ReplicaN + + for _, n := range c.Cluster.Nodes { + cluster.Nodes = append(cluster.Nodes, &pilosa.Node{Host: n.Host}) + } + + return cluster +} + // Duration is a TOML wrapper type for time.Duration. type Duration time.Duration diff --git a/cmd/pilosa/config_test.go b/cmd/pilosa/config_test.go index 3ea0fda09..97ca8f605 100644 --- a/cmd/pilosa/config_test.go +++ b/cmd/pilosa/config_test.go @@ -1,157 +1,27 @@ package main_test import ( - "reflect" "testing" - "time" "github.com/BurntSushi/toml" "github.com/umbel/pilosa/cmd/pilosa" ) -// Ensure the ID can be parsed as a GUID. -func TestConfig_Parse_ID(t *testing.T) { - if c, err := ParseConfig(` -id = "00000000-0000-0000-0000-000000000001" -`); err != nil { - t.Fatal(err) - } else if c.ID == nil || c.ID.String() != `00000000-0000-0000-0000-000000000001` { - t.Fatalf("unexpected id: %s", c.ID) - } -} - -// Ensure that parsing an invalid GUID returns an error. -func TestConfig_Parse_ID_ErrInvalid(t *testing.T) { - if _, err := ParseConfig(` -id = "x" -`); err == nil || err.Error() != `Type mismatch for 'main.Config.id': invalid GUID "x"` { - t.Fatal(err) - } -} - // Ensure the host can be parsed. func TestConfig_Parse_Host(t *testing.T) { - if c, err := ParseConfig(`host = "localhost"`); err != nil { + if c, err := ParseConfig(`host = "local"`); err != nil { t.Fatal(err) - } else if c.Host != "localhost" { + } else if c.Host != "local" { t.Fatalf("unexpected host: %s", c.Host) } } -// Ensure the "tcp" config can be parsed. -func TestConfig_Parse_TCP(t *testing.T) { - if c, err := ParseConfig(` -[tcp] -port = 123 -`); err != nil { +// Ensure the addr can be parsed. +func TestConfig_Parse_Addr(t *testing.T) { + if c, err := ParseConfig(`addr = ":80"`); err != nil { t.Fatal(err) - } else if c.TCP.Port != 123 { - t.Fatalf("unexpected port: %s", c.TCP.Port) - } -} - -// Ensure the "http" config can be parsed. -func TestConfig_Parse_HTTP(t *testing.T) { - if c, err := ParseConfig(` -[http] -port = 123 -default-db = "xyz" -request-log-path = "/path/to/log" -set-bit-log-enabled = true -`); err != nil { - t.Fatal(err) - } else if c.HTTP.Port != 123 { - t.Fatalf("unexpected port: %s", c.HTTP.Port) - } else if c.HTTP.DefaultDB != "xyz" { - t.Fatalf("unexpected default db: %s", c.HTTP.DefaultDB) - } else if c.HTTP.RequestLogPath != "/path/to/log" { - t.Fatalf("unexpected request log path: %s", c.HTTP.RequestLogPath) - } else if c.HTTP.SetBitLogEnabled != true { - t.Fatalf("unexpected set bit log enabled: %v", c.HTTP.SetBitLogEnabled) - } -} - -// Ensure the "log" config can be parsed. -func TestConfig_Parse_Log(t *testing.T) { - if c, err := ParseConfig(` -[log] -path = "/path/to/log" -level = "debug" -`); err != nil { - t.Fatal(err) - } else if c.Log.Path != "/path/to/log" { - t.Fatalf("unexpected path: %s", c.Log.Path) - } else if c.Log.Level != "debug" { - t.Fatalf("unexpected level: %s", c.Log.Level) - } -} - -// Ensure the "storage" config can be parsed. -func TestConfig_Parse_Storage(t *testing.T) { - if c, err := ParseConfig(` -[storage] -backend = "cassandra" -hosts = ["server0", "server1"] -keyspace = "pilosa" -fragment-base = "/path/to/base" -supported-frames = ["a", "b", "c"] -cassandra-time-window = "5s" -cassandra-max-size-batch = 50 -`); err != nil { - t.Fatal(err) - } else if c.Storage.Backend != "cassandra" { - t.Fatalf("unexpected backend: %s", c.Storage.Backend) - } else if !reflect.DeepEqual(c.Storage.Hosts, []string{"server0", "server1"}) { - t.Fatalf("unexpected hosts: %+v", c.Storage.Hosts) - } else if c.Storage.Keyspace != "pilosa" { - t.Fatalf("unexpected keyspace: %s", c.Storage.Keyspace) - } else if c.Storage.FragmentBase != "/path/to/base" { - t.Fatalf("unexpected fragment base: %s", c.Storage.FragmentBase) - } else if !reflect.DeepEqual(c.Storage.SupportedFrames, []string{"a", "b", "c"}) { - t.Fatalf("unexpected supported frames: %s", c.Storage.SupportedFrames) - } else if time.Duration(c.Storage.CassandraTimeWindow) != 5*time.Second { - t.Fatalf("unexpected cassandra time window: %s", time.Duration(c.Storage.CassandraTimeWindow)) - } else if c.Storage.CassandraMaxSizeBatch != 50 { - t.Fatalf("unexpected cassandra max size batch: %s", c.Storage.CassandraMaxSizeBatch) - } -} - -// Ensure the "aws" config can be parsed. -func TestConfig_Parse_AWS(t *testing.T) { - if c, err := ParseConfig(` -[aws] -access-key-id = "abc" -secret-access-key = "def" -`); err != nil { - t.Fatal(err) - } else if c.AWS.AccessKeyID != "abc" { - t.Fatalf("unexpected access key id: %s", c.AWS.AccessKeyID) - } else if c.AWS.SecretAccessKey != "def" { - t.Fatalf("unexpected secret access key: %s", c.AWS.SecretAccessKey) - } -} - -// Ensure the "leveldb" config can be parsed. -func TestConfig_Parse_LevelDB(t *testing.T) { - if c, err := ParseConfig(` -[leveldb] -path = "/path/to/db" -`); err != nil { - t.Fatal(err) - } else if c.LevelDB.Path != "/path/to/db" { - t.Fatalf("unexpected path: %s", c.LevelDB.Path) - } -} - -// Ensure the "statsd" config can be parsed. -func TestConfig_Parse_Statsd(t *testing.T) { - if c, err := ParseConfig(` -[statsd] -host = "localhost" -`); err != nil { - t.Fatal(err) - } else if c.Statsd.Host != "localhost" { - t.Fatalf("unexpected host: %s", c.Statsd.Host) + } else if c.Addr != ":80" { + t.Fatalf("unexpected addr: %s", c.Addr) } } @@ -167,21 +37,6 @@ path = "/path/to/plugins" } } -// Ensure the "etcd" config can be parsed. -func TestConfig_Parse_ETCD(t *testing.T) { - if c, err := ParseConfig(` -[etcd] -hosts = ["127.0.0.1"] -fragment-alloc-lock-ttl = "5m" -`); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(c.ETCD.Hosts, []string{"127.0.0.1"}) { - t.Fatalf("unexpected hosts: %+v", c.ETCD.Hosts) - } else if time.Duration(c.ETCD.FragmentAllocLockTTL) != 5*time.Minute { - t.Fatalf("unexpected fragment alloc lock ttl: %v", c.ETCD.FragmentAllocLockTTL) - } -} - // ParseConfig parses s into a config. func ParseConfig(s string) (main.Config, error) { var c main.Config diff --git a/cmd/pilosa/main.go b/cmd/pilosa/main.go index 5addecc66..d67326c64 100644 --- a/cmd/pilosa/main.go +++ b/cmd/pilosa/main.go @@ -4,37 +4,64 @@ import ( "flag" "fmt" "io" + "log" + "math/rand" + "net" + "net/http" "os" "runtime/pprof" "time" "github.com/BurntSushi/toml" - log "github.com/cihub/seelog" - "github.com/coreos/go-etcd/etcd" - "github.com/kr/s3/s3util" "github.com/umbel/pilosa" - "github.com/umbel/pilosa/core" - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/dispatch" - "github.com/umbel/pilosa/executor" - "github.com/umbel/pilosa/hold" - "github.com/umbel/pilosa/statsd" - "github.com/umbel/pilosa/transport" ) // Build holds the build information passed in at compile time. var Build string +func init() { + if Build == "" { + Build = "v0.0.0" + } + + rand.Seed(time.Now().UTC().UnixNano()) +} + func main() { m := NewMain() - if err := m.Run(os.Args[1:]...); err != nil { - fmt.Fprintln(m.Stderr, err.Error()) - os.Exit(-1) + fmt.Fprintf(m.Stderr, "Pilosa %s\n", Build) + + // Parse command line arguments. + if err := m.ParseFlags(os.Args[1:]); err != nil { + fmt.Fprintln(m.Stderr, err) + os.Exit(2) } + + // Execute the program. + if err := m.Run(); err != nil { + fmt.Fprintln(m.Stderr, err) + os.Exit(1) + } + + // Wait indefinitely. + <-(chan struct{})(nil) } // Main represents the main program execution. type Main struct { + ln net.Listener + + // Path to the configuration file. + ConfigPath string + + // Configuration options. + Config *Config + + // Profiling paths + CPUProfile string + + // Standard input/output + Stdin io.Reader Stdout io.Writer Stderr io.Writer } @@ -42,6 +69,9 @@ type Main struct { // NewMain returns a new instance of Main. func NewMain() *Main { return &Main{ + Config: NewConfig(), + + Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, } @@ -49,31 +79,16 @@ func NewMain() *Main { // Run executes the main program execution. func (m *Main) Run(args ...string) error { - defer log.Flush() + logger := log.New(m.Stderr, "", log.LstdFlags) - // Parse command line arguments. - opt, err := m.ParseFlags(args) - if err != nil { - return err - } - - // Parse configuration. - config := NewConfig() - if opt.ConfigPath != "" { - if _, err := toml.DecodeFile(opt.ConfigPath, &config); err != nil { - return err - } - } - - // Generate an ID if one is not specified in the config. - id := config.ID - if id == nil { - *id = pilosa.NewGUID() + // Notify user of config file. + if m.ConfigPath != "" { + fmt.Fprintf(m.Stdout, "Using config: %s\n", m.ConfigPath) } // Set up profiling. - if opt.CPUProfile != "" { - f, err := os.Create(opt.CPUProfile) + if m.CPUProfile != "" { + f, err := os.Create(m.CPUProfile) if err != nil { return err } @@ -82,127 +97,61 @@ func (m *Main) Run(args ...string) error { defer pprof.StopCPUProfile() } - // Pass configuration to packages. - // NOTE: This is temporary. These config options should be encapsulated in the types. - db.SupportedFrames = config.Storage.SupportedFrames - pilosa.FragmentBase = config.Storage.FragmentBase - pilosa.Backend = config.Storage.Backend - pilosa.LevelDBPath = config.LevelDB.Path + // Build cluster from config file. + cluster := m.Config.PilosaCluster() - // Initialize AWS storage. - s3util.DefaultConfig.AccessKey = config.AWS.AccessKeyID - s3util.DefaultConfig.SecretKey = config.AWS.SecretAccessKey + // Create index to store fragments. + index := pilosa.NewIndex() - // Initialize Statsd. - statsd.Host = config.Statsd.Host - statsd.Setup() + // Create executor for executing queries. + e := pilosa.NewExecutor(index) + e.Host = m.Config.Host + e.Cluster = cluster - // Initialize logging. - logger, _ := log.LoggerFromConfigAsBytes([]byte(SeelogProductionConfig(config.Log.Path, *id, config.Log.Level))) - log.ReplaceLogger(logger) + // Initialize HTTP handler. + h := pilosa.NewHandler() + h.Executor = e + h.LogOutput = m.Stderr - // Initialize etcd client. - etcdClient := etcd.NewClient(config.ETCD.Hosts) + // Open HTTP listener. + ln, err := net.Listen("tcp", m.Config.Addr) + if err != nil { + return err + } + m.ln = ln - // Initialize the cluster. - cluster := db.NewCluster() + // Serve HTTP. + go func() { logger.Print(http.Serve(ln, h)) }() - // Create index. - idx := pilosa.NewFragmentContainer() - - // Initialize the holder. - hold := hold.NewHolder() - - // Initialize process map. - processMap := core.NewProcessMap() - - // Start process mapper. - processMapper := core.NewProcessMapper("/pilosa/0") - processMapper.ID = *id - processMapper.TCPPort = config.TCP.Port - processMapper.HTTPPort = config.HTTP.Port - processMapper.Host = config.Host - processMapper.ProcessMap = processMap - processMapper.EtcdClient = etcdClient - - // Start topology mapper. - topologyMapper := core.NewTopologyMapper("/pilosa/0") - topologyMapper.Cluster = cluster - topologyMapper.ProcessMap = processMap - topologyMapper.EtcdClient = etcdClient - topologyMapper.Index = idx - topologyMapper.SupportedFrames = config.Storage.SupportedFrames - topologyMapper.FragmentAllocLockTTL = time.Duration(config.ETCD.FragmentAllocLockTTL) - - // Start the transport. - transport := transport.NewTcpTransport(*id) - transport.Port = config.TCP.Port - transport.ProcessMap = processMap - go transport.Run() - - // Create the pinger. - pinger := core.NewPinger(*id) - pinger.Hold = hold - pinger.Transport = transport - - // Create the batcher. - batcher := core.NewBatcher(*id) - batcher.Cluster = cluster - batcher.Hold = hold - batcher.Transport = transport - - // Start the web service. - core.RequestLogPath = config.HTTP.RequestLogPath - ws := core.NewWebService() - ws.ID = *id - ws.Port = config.HTTP.Port - ws.Version = Build - ws.DefaultDB = config.HTTP.DefaultDB - ws.SetBitLogEnabled = config.HTTP.SetBitLogEnabled - ws.Cluster = cluster - ws.TopologyMapper = topologyMapper - ws.Pinger = pinger - ws.Batcher = batcher - - // Start the executor. - ex := executor.NewExecutor(*id) - ex.ProcessMap = processMap - ex.PluginsPath = config.Plugins.Path - ex.Hold = hold - ex.Index = idx - - // Start the dispatcher. - dispatch := dispatch.NewDispatch() - dispatch.Executor = ex - dispatch.Hold = hold - dispatch.Index = idx - dispatch.Transport = transport - go dispatch.Run() - - fmt.Printf("Pilosa %s\n", Build) - - log.Warn("STOP") + fmt.Fprintf(m.Stderr, "Listening on http://%s\n", ln.Addr().String()) return nil } +// Close shuts down the process. +func (m *Main) Close() error { + if m.ln != nil { + m.ln.Close() + } + return nil +} + // ParseFlags parses command line flags from args. -func (m *Main) ParseFlags(args []string) (Options, error) { - var opt Options +func (m *Main) ParseFlags(args []string) error { fs := flag.NewFlagSet("pilosa", flag.ContinueOnError) fs.SetOutput(m.Stderr) - fs.StringVar(&opt.ConfigPath, "config", "", "config path") - fs.StringVar(&opt.CPUProfile, "cpuprofile", "", "write cpu profile to file") - + fs.StringVar(&m.ConfigPath, "config", "", "config path") + fs.StringVar(&m.CPUProfile, "cpuprofile", "", "write cpu profile to file") if err := fs.Parse(args); err != nil { - return opt, err + return err } - return opt, nil -} + // Load config, if specified. + if m.ConfigPath != "" { + if _, err := toml.DecodeFile(m.ConfigPath, &m.Config); err != nil { + return err + } + } -// Options represents the command line options. -type Options struct { - CPUProfile string - ConfigPath string + return nil } diff --git a/cmd/pilosa/seelog.go b/cmd/pilosa/seelog.go deleted file mode 100644 index b87c1c0cf..000000000 --- a/cmd/pilosa/seelog.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/umbel/pilosa" -) - -func SeelogProductionConfig(path string, id pilosa.GUID, level string) string { - if path == "" { - path = "/tmp" - } - - fname := fmt.Sprintf("%s/pilosa.%s", path, id.String()) - // - - s := fmt.Sprintf(` - - - `, level, fname) - - s += ` - - - ` - - return s -} diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go new file mode 100644 index 000000000..56631a35d --- /dev/null +++ b/cmd/pilosactl/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "errors" + "flag" + "fmt" + "io" + "os" +) + +func main() { + m := NewMain() + + // Parse command line arguments. + if err := m.ParseFlags(os.Args[1:]); err != nil { + fmt.Fprintln(m.Stderr, err) + os.Exit(2) + } + + // Execute the program. + if err := m.Run(); err != nil { + fmt.Fprintln(m.Stderr, err) + os.Exit(1) + } +} + +// Main represents the main program execution. +type Main struct { + Command string + + // Standard input/output + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewMain returns a new instance of Main. +func NewMain() *Main { + return &Main{ + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + } +} + +// Run executes the main program execution. +func (m *Main) Run() error { + panic("FIXME: implement commands") +} + +// ParseFlags parses command line flags from args. +func (m *Main) ParseFlags(args []string) error { + fs := flag.NewFlagSet("pilosactl", flag.ContinueOnError) + fs.SetOutput(m.Stderr) + if err := fs.Parse(args); err != nil { + return err + } + + // Require command. + if fs.NArg() == 0 { + return errors.New("command required") + } + + return nil +} diff --git a/cmd/pilosactl/main_test.go b/cmd/pilosactl/main_test.go new file mode 100644 index 000000000..0fee6f5dc --- /dev/null +++ b/cmd/pilosactl/main_test.go @@ -0,0 +1 @@ +package main_test diff --git a/core/batch.go b/core/batch.go deleted file mode 100644 index 647d0e59a..000000000 --- a/core/batch.go +++ /dev/null @@ -1,70 +0,0 @@ -package core - -import ( - "encoding/gob" - - log "github.com/cihub/seelog" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/hold" -) - -type BatchRequest struct { - Id *pilosa.GUID - Source *pilosa.GUID - Fragment_id pilosa.SUUID - Bitmap_id uint64 - Compressed_bitmap string - Filter uint64 -} - -type BatchResponse struct { - Id *pilosa.GUID -} - -func (self BatchResponse) ResultId() *pilosa.GUID { - return self.Id -} -func (self BatchResponse) ResultData() interface{} { - return self.Id -} - -func init() { - gob.Register(BatchRequest{}) - gob.Register(BatchResponse{}) -} - -type Batcher struct { - ID pilosa.GUID - Cluster *db.Cluster - Hold *hold.Holder - - Transport interface { - Send(message *db.Message, host *pilosa.GUID) - } -} - -func NewBatcher(id pilosa.GUID) *Batcher { - return &Batcher{ID: id} -} - -func (b *Batcher) Batch(database_name, frame, compressed_bitmap string, bitmap_id uint64, slice int, filter uint64) error { - log.Trace("Batch:", "db:", database_name, " frame:", frame, " slice:", slice, " cb:", compressed_bitmap, " bid:", bitmap_id, "f:", filter) - - //determine the fragment_id from database/frame/slice - database := b.Cluster.GetOrCreateDatabase(database_name) - oslice := database.GetOrCreateSlice(slice) - //need to find processid and fragment id for that slice - - fragment, err := database.GetFragmentForBitmap(oslice, &db.Bitmap{Id: bitmap_id, FrameType: frame, Filter: filter}) - if err == nil { - id := pilosa.NewGUID() - batch := db.Message{Data: BatchRequest{Id: &id, Source: &b.ID, Fragment_id: fragment.GetId(), Bitmap_id: bitmap_id, Compressed_bitmap: compressed_bitmap}} - dest_id := fragment.GetProcess().Id() - b.Transport.Send(&batch, &dest_id) - - _, err = b.Hold.Get(&id, 60) - } - - return err -} diff --git a/core/etcd.go b/core/etcd.go deleted file mode 100644 index d2be6c597..000000000 --- a/core/etcd.go +++ /dev/null @@ -1,519 +0,0 @@ -package core - -import ( - "errors" - "fmt" - "os" - "runtime/debug" - "sort" - "strconv" - "strings" - "sync" - "time" - - log "github.com/cihub/seelog" - "github.com/coreos/go-etcd/etcd" - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" -) - -const ( - DefaultFragmentAllocLockTTL = 14400 * time.Second -) - -type TopologyMapper struct { - namespace string - - ID pilosa.GUID - Cluster *db.Cluster - ProcessMap *ProcessMap - - SupportedFrames []string - FragmentAllocLockTTL time.Duration - - EtcdClient interface { - CreateDir(key string, ttl uint64) (*etcd.Response, error) - Get(key string, sort, recursive bool) (*etcd.Response, error) - RawCreate(key string, value string, ttl uint64) (*etcd.RawResponse, error) - Set(key string, value string, ttl uint64) (*etcd.Response, error) - Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error) - } - - Index interface { - AddFragment(db string, frame string, slice int, id pilosa.SUUID) - } -} - -func NewTopologyMapper(namespace string) *TopologyMapper { - return &TopologyMapper{ - namespace: namespace, - FragmentAllocLockTTL: DefaultFragmentAllocLockTTL, - } -} - -func (self *TopologyMapper) Setup() { - log.Warn(self.namespace + "/db") - db_path := self.namespace + "/db" - resp, err := self.EtcdClient.Get(db_path, false, true) - if err != nil { - ee, ok := err.(*etcd.EtcdError) - if ok && ee.ErrorCode == 100 { // node does not exist - resp, err = self.EtcdClient.CreateDir(db_path, 0) - if err != nil { - log.Critical(err) - os.Exit(-1) - } - } else { - log.Critical(err) - os.Exit(-1) - } - } - - //need to lock the world - for _, node := range flatten(resp.Node) { - err := self.handlenode(node) - if err != nil { - log.Warn(err) - } - } - -} -func (self *TopologyMapper) Run() { - - receiver := make(chan *etcd.Response) - go func() { - // TODO: add some terminating measure - // TODO: use modindex to make sure watch catches everything - for { - ns := self.namespace + "/db" - log.Warn(" ETCD watcher:", ns) - stop := make(chan bool) - resp, err := self.EtcdClient.Watch(ns, 0, true, receiver, stop) - log.Warn("TopologyMapper ETCD watcher", resp, err) - } - }() - go func() { - for resp := range receiver { - switch resp.Action { - case "set": - self.handlenode(resp.Node) - case "delete": - self.remove_fragment(resp.Node) - } - // TODO: handle deletes - } - }() -} - -type Pair struct { - Key string - Value int -} - -// A slice of Pairs that implements sort.Interface to sort by Value. -type PairList []Pair - -func (p PairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p PairList) Len() int { return len(p) } -func (p PairList) Less(i, j int) bool { return p[i].Value < p[j].Value } - -func getLightestProcess(m map[string]int) (Pair, error) { - - l := len(m) - if l == 0 { - return Pair{}, errors.New("No Processes") - } - processlist := make(PairList, l) - i := 0 - - for k, v := range m { - processlist[i] = Pair{k, v} - i++ - } - sort.Sort(processlist) - - return processlist[0], nil -} - -func (self *TopologyMapper) GetProcessFragmentCounts() map[string]int { - m := make(map[string]int) - m[self.ID.String()] = 0 //at least have one process if none created - for k, _ := range self.ProcessMap.nodes { - p := k.String() - m[p] = 0 //at least have one process if none created - } - - for _, dbs := range self.Cluster.GetDatabases() { - for _, fsi := range dbs.GetFrameSliceIntersects() { - for _, fragment := range fsi.GetFragments() { - process := fragment.GetProcess().Id().String() - if len(process) > 1 { - i := m[process] - i++ - m[process] = i - } - } - - } - - } - return m -} - -func (self *TopologyMapper) MakeFragments(db string, slice_int int) error { - lock_key := fmt.Sprintf("%s/lock/%s-%d", self.namespace, db, slice_int) - response, err := self.EtcdClient.RawCreate(lock_key, "0", uint64(self.FragmentAllocLockTTL.Seconds())) - - if err == nil { - if response.StatusCode == 201 { //key created - log.Warn("MakeFragments:", db, slice_int) - m := self.GetProcessFragmentCounts() - p, err := getLightestProcess(m) - if err != nil { - log.Warn("MakeFragments: error finding process", db, slice_int, err) - return err - } - - // PUT -d "value=5cb315c3-6e1d-4218-89b7-943d1dba985b" http://etcd0:4001/v2/keys/pilosa/0/db/29/frame/d/slice/5/fragment/a2b632fc4001b817/proces - for _, frame := range self.SupportedFrames { - err := self.AllocateFragment(p.Key, db, frame, slice_int) - if err != nil { - log.Warn(err) - } - } - } - } - return nil -} - -func (self *TopologyMapper) AllocateFragment(process_guid, db, frame string, slice_int int) error { - //get Lock to create the fragment - //figure out least loaded process..possibly check max process - //to create the node, just write off the items to etcd and the watch should spawn - //be nice if something would notify perhaps queue - //so i need db, frame, slice , fragment_id - fuid := pilosa.NewSUUID().String() - fragment_key := fmt.Sprintf("%s/db/%s/frame/%s/slice/%d/fragment/%s/process", self.namespace, db, frame, slice_int, fuid) - // need to check value to see how many we have left - log.Warn("ALLOC:", process_guid, len(process_guid)) - if len(process_guid) > 1 { - _, err := self.EtcdClient.Set(fragment_key, process_guid, 0) - if err != nil { - return err - } - log.Warn("Fragment sent to etcd:", fragment_key, process_guid) - } - - return nil - -} - -func (self *TopologyMapper) handlenode(node *etcd.Node) error { - key := node.Key[len(self.namespace)+1:] - bits := strings.Split(key, "/") - var database *db.Database - var frame *db.Frame - var fragment *db.Fragment - var fragment_id pilosa.SUUID - var slice *db.Slice - var slice_int int - var process_uuid pilosa.GUID - var process *db.Process - var err error - - if len(bits) > 8 { - if bits[8] != "process" { - return errors.New("no process") - } - - process_uuid, err = pilosa.ParseGUID(node.Value) - if err != nil { - log.Warn("Bad Process Guid", key) - return errors.New("No Process Id") - } - } else { - return err - } - - if len(bits) <= 1 || bits[0] != "db" { - return nil - } - if len(bits) > 1 { - database = self.Cluster.GetOrCreateDatabase(bits[1]) - } - if len(bits) > 2 { - if bits[2] != "frame" { - return errors.New("no frame") - } - } - if len(bits) > 3 { - frame = database.GetOrCreateFrame(bits[3]) - } - if len(bits) > 4 { - if bits[4] != "slice" { - return errors.New("no slice") - } - } - if len(bits) > 5 { - slice_int, err = strconv.Atoi(bits[5]) - if err != nil { - return err - } - slice = database.GetOrCreateSlice(slice_int) - } - if len(bits) > 6 { - if bits[6] != "fragment" { - return errors.New("no fragment") - } - } - if len(bits) > 7 { - fragment_id = pilosa.ParseSUUID(bits[7]) - fragment = database.GetOrCreateFragment(frame, slice, fragment_id) - } - - if len(bits) > 8 { - if bits[8] != "process" { - return errors.New("no process") - } - - if err != nil { - log.Warn("Bad UUID:", process_uuid, key) - return err - } - process = db.NewProcess(&process_uuid) - fragment.SetProcess(process) - - if self.ID.Equals(&process_uuid) { - self.Index.AddFragment(bits[1], bits[3], slice_int, fragment_id) - } - - } - return err -} -func (self *TopologyMapper) remove_fragment(node *etcd.Node) error { - log.Warn(" hot remove_fragment (Not Supported yet):", node) - return nil -} - -func flatten(node *etcd.Node) []*etcd.Node { - nodes := []*etcd.Node{node} - for i := 0; i < len(node.Nodes); i++ { - nodes = append(nodes, flatten(&node.Nodes[i])...) - } - return nodes -} - -type Node struct { - id *pilosa.GUID - ip string - port_tcp int - port_http int -} - -type ProcessMap struct { - nodes map[pilosa.GUID]*db.Process - mutex sync.Mutex -} - -func NewProcessMap() *ProcessMap { - p := ProcessMap{} - p.nodes = make(map[pilosa.GUID]*db.Process) - return &p -} - -func (self *ProcessMap) AddProcess(process *db.Process) { - self.mutex.Lock() - defer self.mutex.Unlock() - self.nodes[process.Id()] = process -} - -func (self *ProcessMap) GetProcess(id *pilosa.GUID) (*db.Process, error) { - self.mutex.Lock() - defer self.mutex.Unlock() - if id == nil { - debug.PrintStack() - return nil, errors.New("Nil process") - } - process, ok := self.nodes[*id] - if !ok { - return nil, errors.New("No such process") - } - return process, nil -} - -func (self *ProcessMap) GetOrAddProcess(id *pilosa.GUID) *db.Process { - process, err := self.GetProcess(id) - if err != nil { - process = db.NewProcess(id) - self.AddProcess(process) - } - return process -} - -func (self *ProcessMap) GetHost(id *pilosa.GUID) (string, error) { - self.mutex.Lock() - defer self.mutex.Unlock() - process, ok := self.nodes[*id] - if !ok { - return "", errors.New("Process does not exist") - } - return process.Host(), nil -} - -func (self *ProcessMap) GetPortTcp(id *pilosa.GUID) (int, error) { - self.mutex.Lock() - defer self.mutex.Unlock() - process, ok := self.nodes[*id] - if !ok { - return 0, errors.New("Process does not exist") - } - return process.PortTcp(), nil -} - -func (self *ProcessMap) GetPortHttp(id *pilosa.GUID) (int, error) { - self.mutex.Lock() - defer self.mutex.Unlock() - process, ok := self.nodes[*id] - if !ok { - return 0, errors.New("Process does not exist") - } - return process.PortHttp(), nil -} - -func (self *ProcessMap) GetMetadata() map[string]map[string]interface{} { - self.mutex.Lock() - defer self.mutex.Unlock() - out := make(map[string]map[string]interface{}) - for id, process := range self.nodes { - pdata := make(map[string]interface{}) - pdata["host"] = process.Host() - pdata["port_tcp"] = process.PortTcp() - pdata["port_http"] = process.PortHttp() - out[id.String()] = pdata - } - return out -} - -type ProcessMapper struct { - receiver chan etcd.Response - commands chan ProcessMapperCommand - namespace string - - ID pilosa.GUID - ProcessMap *ProcessMap - - TCPPort int - HTTPPort int - Host string - - EtcdClient interface { - Get(key string, sort, recursive bool) (*etcd.Response, error) - Set(key string, value string, ttl uint64) (*etcd.Response, error) - Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error) - } -} - -func NewProcessMapper(namespace string) *ProcessMapper { - return &ProcessMapper{ - receiver: make(chan etcd.Response), - commands: make(chan ProcessMapperCommand), - namespace: namespace, - } -} - -type ProcessMapperCommand struct { - key string -} - -func getKey(input string) string { - bits := strings.Split(input, "/") - return bits[len(bits)-1] -} - -func (self *ProcessMapper) getnode(u *pilosa.GUID) *Node { - return new(Node) -} - -func crash_on_error(err error) { - if err != nil { - log.Critical(err) - os.Exit(-1) - } -} - -func (self *ProcessMapper) handlenode(node *etcd.Node) error { - var err error - var process *db.Process - key := node.Key[len(self.namespace)+1:] - bits := strings.Split(key, "/") - if len(bits) <= 1 || bits[0] != "process" { - return nil - } - if len(bits) >= 2 { - id_string := bits[1] - id, err := pilosa.ParseGUID(id_string) - if err != nil { - return errors.New("Invalid GUID: " + id_string + " (" + key + ")") - } - process = self.ProcessMap.GetOrAddProcess(&id) - } - if len(bits) >= 3 { - switch bits[2] { - case "port_tcp": - port_tcp, _ := strconv.Atoi(node.Value) - process.SetPortTcp(port_tcp) - case "port_http": - port_http, _ := strconv.Atoi(node.Value) - process.SetPortHttp(port_http) - case "host": - host := node.Value - process.SetHost(host) - } - } - - return err -} - -func (self *ProcessMapper) Run() { - path := self.namespace + "/process" - self_path := path + "/" + self.ID.String() - - log.Warn("Writing configuration to etcd...") - log.Warn(self_path) - - var err error - _, err = self.EtcdClient.Set(self_path+"/port_tcp", strconv.Itoa(self.TCPPort), 0) - crash_on_error(err) - _, err = self.EtcdClient.Set(self_path+"/port_http", strconv.Itoa(self.HTTPPort), 0) - crash_on_error(err) - _, err = self.EtcdClient.Set(self_path+"/host", self.Host, 0) - crash_on_error(err) - - response, err := self.EtcdClient.Get(path, false, true) - for _, node := range flatten(response.Node) { - err := self.handlenode(node) - if err != nil { - out := spew.Sdump(node) - log.Warn(err, out) - } - } - - receiver := make(chan *etcd.Response) - stop := make(chan bool) - go func() { - // TODO: error check and restart watcher - // TODO: use modindex to make sure watch catches everything - _, _ = self.EtcdClient.Watch(path, 0, true, receiver, stop) - }() - - go func() { - for response = range receiver { - switch response.Action { - case "set": - self.handlenode(response.Node) - } - // TODO: handle deletes - } - }() -} diff --git a/core/http.go b/core/http.go deleted file mode 100644 index e8d7d8f2c..000000000 --- a/core/http.go +++ /dev/null @@ -1,854 +0,0 @@ -package core - -import ( - "bytes" - "compress/gzip" - "encoding/base64" - "encoding/gob" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/http/httputil" - "os" - "reflect" - "runtime" - "strconv" - "strings" - "time" - - notify "github.com/bitly/go-notify" - log "github.com/cihub/seelog" - "github.com/davecgh/go-spew/spew" - "github.com/gorilla/websocket" - "github.com/kr/s3/s3util" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/statsd" -) - -const DefaultRequestLogPath = "/tmp/set_bit_log" - -var RequestLogPath = DefaultRequestLogPath - -type WebService struct { - end chan bool - - ID pilosa.GUID - Version string - Port int - DefaultDB string - SetBitLogEnabled bool - - Cluster *db.Cluster - ProcessMap *ProcessMap - - Batcher *Batcher - - Executor interface { - RunPQL(database_name string, pql string) (interface{}, error) - } - - Pinger interface { - Ping(process_id *pilosa.GUID) (*time.Duration, error) - } - - TopologyMapper interface { - MakeFragments(db string, slice_int int) error - } - - Transport interface { - Push(message *db.Message) - } -} - -func NewWebService() *WebService { - return &WebService{ - end: make(chan bool), - } -} - -type Flusher struct { - flusher chan bool -} - -func (self *Flusher) Handle(w http.ResponseWriter, r *http.Request) { - self.flusher <- true -} - -func NewFlusher(flusher chan bool) http.HandlerFunc { - f := Flusher{flusher} - return f.Handle -} - -type RequestLogger struct { - handler http.HandlerFunc - logger chan []byte -} - -func NewRequestLogger(handler http.HandlerFunc, logger chan []byte) http.HandlerFunc { - r := RequestLogger{handler, logger} - return r.Handle -} - -func (self *RequestLogger) Handle(w http.ResponseWriter, r *http.Request) { - - // Grab a dump of the incoming request - dump, err := httputil.DumpRequest(r, true /*dump the body also*/) - if err != nil { - log.Warn("Dump Failure", err) - } - - self.handler(w, r) - self.logger <- dump -} - -type LogRecord struct { - When time.Time - Data_x64 string -} - -func NewLogRecord(t time.Time, data []byte) LogRecord { - var b bytes.Buffer - w := gzip.NewWriter(&b) - w.Write(data) - w.Flush() - w.Close() - e := base64.StdEncoding.EncodeToString(b.Bytes()) - x := LogRecord{t, e} - return x -} - -func genFileName(id string) string { - //bucket/YYYY/MM/DDHHMMSS.id.log - t := time.Now() - //base := "http://pilosa.umbel.com.s3.amazonaws.com/bit_log" - - return fmt.Sprintf("%s%s.%s.log", RequestLogPath, t.Format("/2006/01/02/15/04-05"), id) -} - -func flush(requests []LogRecord, id string, records_to_dump int) { - dest := genFileName(id) - w, err := createFile(dest) - if err != nil { - log.Warn("Error opening outfile ", dest) - log.Warn(err) - return - } - defer w.Close() - - encoder := json.NewEncoder(w) - for i := 0; i < records_to_dump; i++ { - encoder.Encode(requests[i]) - } - -} - -func Logger(in chan []byte, end chan bool, id string, flusher chan bool) { - var buffer = make([]LogRecord, 2048, 2048) - i := 0 - for { - select { - case raw := <-in: - logRecord := NewLogRecord(time.Now(), raw) - buffer[i] = logRecord - i += 1 - if i > 2047 { - flush(buffer, id, i) - i = 0 - } - - case <-flusher: - if i > 0 { - flush(buffer, id, i) - i = 0 - } - case <-end: - flush(buffer, id, i) - log.Info("Shutdown Logger") - return - } - - } - -} - -func (self *WebService) Run() { - port_string := strconv.Itoa(self.Port) - log.Info("Serving HTTP on port:", port_string) - logger_chan := make(chan []byte, 1024) - flusher := make(chan bool) - mux := http.NewServeMux() - mux.HandleFunc("/message", self.HandleMessage) - mux.HandleFunc("/query", self.HandleQuery) - mux.HandleFunc("/stats", self.HandleStats) - mux.HandleFunc("/status", self.HandleStatus) - mux.HandleFunc("/info", self.HandleInfo) - mux.HandleFunc("/processes", self.HandleProcesses) - mux.HandleFunc("/listen/ws", self.HandleListenWS) - mux.HandleFunc("/listen/stream", self.HandleListenStream) - mux.HandleFunc("/listen", self.HandleListen) - mux.HandleFunc("/test", self.HandleTest) - mux.HandleFunc("/version", self.HandleVersion) - mux.HandleFunc("/ping", self.HandlePing) - mux.HandleFunc("/batch", self.HandleBatch) - mux.HandleFunc("/load", self.HandleLoad) - if self.SetBitLogEnabled { - mux.HandleFunc("/set_bits", NewRequestLogger(self.HandleSetBit, logger_chan)) - } else { - mux.HandleFunc("/set_bits", self.HandleSetBit) - } - mux.HandleFunc("/clear_bits", self.HandleClearBit) - //mux.HandleFunc("/set_bits", self.HandleSetBit) - mux.HandleFunc("/flush", NewFlusher(flusher)) - s := &http.Server{ - Addr: ":" + port_string, - Handler: mux, - } - go Logger(logger_chan, self.end, self.ID.String(), flusher) - s.ListenAndServe() -} -func (self *WebService) Shutdown() { - self.end <- true - -} - -func (self *WebService) HandleMessage(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { - http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed) - return - } - var message db.Message - decoder := json.NewDecoder(r.Body) - if decoder.Decode(&message) != nil { - http.Error(w, "Invalid JSON", http.StatusBadRequest) - return - } -} - -func (self *WebService) HandleLoad(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { - http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed) - return - } - - decoder := json.NewDecoder(r.Body) - var obj JsonObject - - err := decoder.Decode(&obj) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - database_name, ok := obj["db"] - if !ok { - http.Error(w, "Provide a database (db)", http.StatusNotFound) - return - } - db := database_name.(string) - - ms_, ok := obj["max_slice"] - if ok { - ms := int(ms_.(float64)) - database := self.Cluster.GetOrCreateDatabase(db) - ns, _ := database.NumSlices() - if ns <= ms { - for i := ns; i <= ms; i++ { - log.Info("Load Create Slice ", i) - self.TopologyMapper.MakeFragments(db, i) - } - http.Error(w, "Needed Slices", http.StatusNotFound) - return - } - - } - - _, ok = obj["id"] - if !ok { - http.Error(w, "Provide a bitmap id (id)", http.StatusNotFound) - return - } - t := float64(obj["id"].(float64)) - bitmap_id := uint64(t) - - frame, ok := obj["frame"] - if !ok { - http.Error(w, "Provide a frame (frame)", http.StatusNotFound) - return - } - api_string, ok := obj["bitmap"] - if !ok { - http.Error(w, "Provide a compressed base64 bitmap (bitmap)", http.StatusNotFound) - return - } - - _, ok = obj["filter"] - if !ok { - http.Error(w, "Provide a filter for categories", http.StatusNotFound) - return - } - t = float64(obj["filter"].(float64)) - filter := uint64(t) - - results := FromApiString(self.Batcher, database_name.(string), frame.(string), api_string.(string), bitmap_id, filter) - - encoder := json.NewEncoder(w) - err = encoder.Encode(results) - if err != nil { - log.Warn("Error Load results") - log.Warn(spew.Sdump(r.Form)) - err = encoder.Encode("Bad Batch Request") - } - -} -func (self *WebService) HandleBatch(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { - http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed) - return - } - - err := r.ParseForm() - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - database_name := r.Form.Get("db") - if database_name == "" { - http.Error(w, "Provide a database (db)", http.StatusNotFound) - return - } - - bitmap_id_string := r.Form.Get("id") - if bitmap_id_string == "" { - http.Error(w, "Provide a bitmap id (id)", http.StatusNotFound) - return - } - bitmap_id, _ := strconv.ParseUint(bitmap_id_string, 10, 64) - - slice_string := r.Form.Get("slice") - if bitmap_id_string == "" { - http.Error(w, "Provide a slice (slice)", http.StatusNotFound) - return - } - slice, _ := strconv.ParseInt(slice_string, 10, 32) - - frame := r.Form.Get("frame") - if bitmap_id_string == "" { - http.Error(w, "Provide a frame (frame)", http.StatusNotFound) - return - } - - compressed_bitmap := r.Form.Get("bitmap") - if bitmap_id_string == "" { - http.Error(w, "Provide a compressed base64 bitmap (bitmap)", http.StatusNotFound) - return - } - - filter_string := r.Form.Get("filter") - filter, _ := strconv.ParseInt(filter_string, 10, 32) - if bitmap_id_string == "" { - http.Error(w, "Provide a filter for categories", http.StatusNotFound) - return - } - - results := self.Batcher.Batch(database_name, frame, compressed_bitmap, bitmap_id, int(slice), uint64(filter)) - - encoder := json.NewEncoder(w) - err = encoder.Encode(results) - if err != nil { - log.Warn("Error Batch results") - log.Warn(spew.Sdump(r.Form)) - err = encoder.Encode("Bad Batch Request") - } - -} - -func (self *WebService) HandleQuery(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { - http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed) - return - } - statsd.SendInc("webservice_Query") - err := r.ParseForm() - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - database_name := r.Form.Get("db") - if database_name == "" { - database_name = self.DefaultDB - } - if database_name == "" { - http.Error(w, "Provide a database (db)", http.StatusNotFound) - return - } - if !self.Cluster.IsValidDatabase(database_name) { - http.Error(w, "Unknown Database:"+database_name, http.StatusNotFound) - return - } - pql := r.Form.Get("pql") - if pql == "" { - http.Error(w, "Provide a valid query string (pql)", http.StatusNotFound) - return - } - _, bits := r.Form["bits"] - - log.Debug("PQL:", database_name, pql) - results, err := self.Executor.RunPQL(database_name, pql) - if err != nil { - log.Warn("PQL Exec Error:", err.Error(), database_name, pql) - http.Error(w, "Error encoding: "+err.Error(), http.StatusInternalServerError) - return - } - switch r := results.(type) { //a hack to handle empty sets - case []pilosa.Pair: - if len(r) == 0 { - results = []int{} - - } - case []byte: //can i figure out the type of the compressed string here? - if bits { - reader, _ := gzip.NewReader(bytes.NewReader(r)) - b, _ := ioutil.ReadAll(reader) - result := pilosa.NewBitmap() - result.FromBytes(b) - results = result.Bits() - } - - } - - if results == nil { - log.Warn("Empty results:", database_name, pql) - http.Error(w, "Error encoding: "+err.Error(), http.StatusInternalServerError) - return - } - if err != nil { - http.Error(w, "Error running query: "+err.Error(), http.StatusInternalServerError) - return - } - - encoder := json.NewEncoder(w) - err = encoder.Encode(results) - if err != nil { - log.Warn("Encode Error :", database_name, pql, err.Error()) - return - } - -} - -type JsonObject map[string]interface{} - -// post this json to the body -//the frame type with extension ".t" are handled a bit differnt -// it generats the timestamp based bitmap_ids -//[{ "db": "3", "frame":"b.n","profile_id": 122,"filter":0, "bitmap_id":123}, -// { "db": "3", "frame":"b.n","profile_id": 122,"filter":2, "bitmap_id":124}, -// { "db": "3", "frame":"t.t","profile_id": 122,"filter":2, "bitmap_id":124, "timestamp":"2014-04-03 13:01:04"}]' -// -func bitmaps(frame string, obj JsonObject) chan uint64 { - c := make(chan uint64) - - go func() { - const shortFormT = "2006-01-02T15:04:05" - const shortFormS = "2006-01-02 15:04:05" - t := float64(obj["bitmap_id"].(float64)) - base_id := uint64(t) - - if strings.HasSuffix(frame, ".t") { - timestamp, present := obj["timestamp"].(string) - - if !present || timestamp == "2014-01-01 00:00:00" { //skip the default timestamp - c <- base_id - } else { - quantum := pilosa.YMDH - if val, ok := obj["time_granularity"]; ok { - switch val { - case "Y": - quantum = pilosa.Y - case "M": - quantum = pilosa.YM - case "D": - quantum = pilosa.YMD - } - } - shortForm := shortFormS - if strings.Contains(timestamp, "T") { - shortForm = shortFormT - } - atime, _ := time.Parse(shortForm, timestamp) - - for i, id := range pilosa.GetTimeIds(base_id, atime, quantum) { - c <- id - if i > 10 { - log.Warn("TO MANY TIMEIDS", base_id, atime, quantum) - break - } - } - } - } else { - c <- base_id - } - - close(c) - }() - - return c -} - -type SBResult struct { - Bitmap_id uint64 - Frame string - Filter uint64 - Profile_id uint64 - Result interface{} -} - -func init() { - gob.Register(SBResult{}) -} - -func (self *WebService) HandleClearBit(w http.ResponseWriter, r *http.Request) { - self.HandleBit(w, r, false) -} -func (self *WebService) HandleSetBit(w http.ResponseWriter, r *http.Request) { - self.HandleBit(w, r, true) -} - -func (self *WebService) HandleBit(w http.ResponseWriter, r *http.Request, ToSet bool) { - if r.Method != "POST" { - http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed) - return - } - - decoder := json.NewDecoder(r.Body) - var args []JsonObject - - err := decoder.Decode(&args) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - //[{ "db": "3", "frame":"brand.","profile_id": 122,"filter":0, "bitmap_id":123}] - var results []SBResult - if len(args) > 4096 { - log.Warn("Request too large:", len(args)) - http.Error(w, "Request To large", http.StatusBadRequest) - return - } - - //remoteSetBit := NewRemoteSetBit() - //remoteSetBit.ID = self.ID - //remoteSetBit.ProcessMap = self.ProcessMap - //remoteSetBit.Hold = self.Hold - //remoteSetBit.Transport = self.Transport - - for _, obj := range args { - if obj["profile_id"] == nil { - http.Error(w, "Missing Profile", http.StatusBadRequest) - return - } - t := float64(obj["profile_id"].(float64)) - profile_id := uint64(t) - - if obj["db"] == nil { - http.Error(w, "Missing db", http.StatusBadRequest) - return - } - dbs := obj["db"].(string) - - if obj["frame"] == nil { - http.Error(w, "Missing Frame", http.StatusBadRequest) - return - - } - frame := obj["frame"].(string) - - if obj["filter"] == nil { - http.Error(w, "Missing Filter", http.StatusBadRequest) - return - } - t = float64(obj["filter"].(float64)) - filter := uint64(t) - for bitmap_id := range bitmaps(frame, obj) { - - var pql string - if ToSet { - pql = fmt.Sprintf("set(%d, %s, %d, %d)", bitmap_id, frame, filter, profile_id) - } else { - pql = fmt.Sprintf("clear(%d, %s, %d, %d)", bitmap_id, frame, filter, profile_id) - } - result, err := self.Executor.RunPQL(dbs, pql) - bundle := SBResult{bitmap_id, frame, filter, profile_id, result} - results = append(results, bundle) - - if err != nil { - log.Warn("Error running set_bit", dbs, frame, profile_id, ToSet) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - } - } - encoder := json.NewEncoder(w) - err = encoder.Encode(results) - if err != nil { - log.Warn("JSON SetBit ERROR:", err, ToSet) - return - } - -} - -func (self *WebService) HandleStats(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed) - return - } - encoder := json.NewEncoder(w) - m := &runtime.MemStats{} - runtime.ReadMemStats(m) - - err := encoder.Encode(m) - if err != nil { - log.Warn("Error encoding stats") - http.Error(w, "Error econding stats", http.StatusMethodNotAllowed) - } -} - -func (self *WebService) HandleInfo(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed) - return - } - spew.Fdump(w, self.Cluster) -} - -func (self *WebService) HandleVersion(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed) - return - } - - fmt.Fprintf(w, "Pilosa v.("+self.Version+")\n") -} - -func (self *WebService) HandleTest(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed) - return - } - spew.Dump("TEST!") - - msg := new(db.Message) - msg.Data = "mystring" - self.Transport.Push(msg) - - msg2 := new(db.Message) - msg2.Data = 789 - self.Transport.Push(msg2) -} - -func (self *WebService) HandleProcesses(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed) - return - } - encoder := json.NewEncoder(w) - processes := self.ProcessMap.GetMetadata() - err := encoder.Encode(processes) - if err != nil { - http.Error(w, "Error Encoding", http.StatusBadRequest) - } -} - -func (self *WebService) HandlePing(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed) - return - } - err := r.ParseForm() - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - process_string := r.Form.Get("process") - process_id, err := pilosa.ParseGUID(process_string) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - _, err = self.ProcessMap.GetProcess(&process_id) - if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) - return - } - duration, err := self.Pinger.Ping(&process_id) - if err != nil { - spew.Fdump(w, err) - return - } - encoder := json.NewEncoder(w) - encoder.Encode(map[string]float64{"duration": duration.Seconds()}) -} - -func (self *WebService) HandleListen(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(` - Pilosa - streaming client - - - - - `)) -} - -func (self *WebService) streamer(writer func(map[string]interface{}) error) { - inbox := make(chan interface{}, 10) - outbox := make(chan interface{}, 10) - notify.Start("inbox", inbox) - notify.Start("outbox", outbox) - var obj interface{} - var data interface{} - var inmessage *db.Message - var outmessage *db.Envelope - var host string - for { - select { - case obj = <-outbox: - outmessage = obj.(*db.Envelope) - data = outmessage.Message.Data - host = outmessage.Host.String() - case obj = <-inbox: - inmessage = obj.(*db.Message) - data = inmessage.Data - host = "" - } - - typ := reflect.TypeOf(data) - - err := writer(map[string]interface{}{ - "type": typ.String(), - "dump": spew.Sdump(data), - "host": host, - }) - if err != nil { - log.Info("stopping") - notify.Stop("inbox", inbox) - notify.Stop("outbox", outbox) - drain(inbox) - drain(outbox) - return - } - } -} - -func (self *WebService) HandleListenWS(w http.ResponseWriter, r *http.Request) { - defer func() { - err := recover() - out := spew.Sdump(err) - log.Info(out) - }() - ws, err := websocket.Upgrade(w, r, nil, 1024, 1024) - if _, ok := err.(websocket.HandshakeError); ok { - http.Error(w, "Not a websocket handshake", 400) - return - } else if err != nil { - log.Warn(err) - return - } - self.streamer(func(data map[string]interface{}) error { - return ws.WriteJSON(data) - }) -} - -func drain(ch chan interface{}) { - for { - switch { - case <-ch: - default: - return - } - } -} - -func (self *WebService) HandleListenStream(w http.ResponseWriter, r *http.Request) { - defer func() { - err := recover() - spew.Dump(err) - }() - writer := json.NewEncoder(w) - flusher := w.(http.Flusher) - self.streamer(func(data map[string]interface{}) error { - err := writer.Encode(data) - flusher.Flush() - return err - }) -} - -func (self *WebService) HandleStatus(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(` - Pilosa - status - - - - - `)) -} - -func createFile(s string) (io.WriteCloser, error) { - if isURL(s) { - return s3util.Create(s, nil, nil) - } - return os.Create(s) -} - -func isURL(s string) bool { - return strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") -} diff --git a/core/load.go b/core/load.go deleted file mode 100644 index a98f871ef..000000000 --- a/core/load.go +++ /dev/null @@ -1,95 +0,0 @@ -package core - -// #cgo CFLAGS:-mpopcnt - -import ( - "bytes" - "compress/gzip" - "encoding/base64" - "encoding/binary" - "errors" - - log "github.com/cihub/seelog" - "github.com/umbel/pilosa" -) - -func copy_raw(src [32]uint64) pilosa.Blocks { - o := make(pilosa.Blocks, 32) - for k, v := range src { - o[k] = v - } - return o -} -func sendBitmap(batcher *Batcher, bitmap *pilosa.Bitmap, db string, frame string, bitmap_id, filter uint64, slice int, finish chan error) { - if slice < 0 { - log.Warn("Bad split", db, frame, slice, bitmap_id) - finish <- errors.New("BadSplit") - return - } - - // Compress bitmap. - var b bytes.Buffer - w := gzip.NewWriter(&b) - w.Write(bitmap.ToBytes()) - w.Flush() - w.Close() - buf := base64.StdEncoding.EncodeToString(b.Bytes()) - - results := batcher.Batch(db, frame, buf, bitmap_id, slice, filter) - finish <- results -} - -func FromApiString(batcher *Batcher, db string, frame string, api_string string, bitmap_id, filter uint64) string { - compressed_data, err := base64.StdEncoding.DecodeString(api_string) - if err != nil { - log.Warn(err) - return "Bad" - } - reader, err := gzip.NewReader(bytes.NewReader(compressed_data)) - if err != nil { - log.Warn(err) - return "Bad" - } - var numChunks uint64 - err = binary.Read(reader, binary.LittleEndian, &numChunks) - if err != nil { - log.Warn(err) - return "Bad" - } - first := true - bitmap := pilosa.NewBitmap() - last_slice := pilosa.CounterMask - sent_count := 0 - finish := make(chan error) - - for i := uint64(0); i < numChunks; i++ { - var raw struct { - Key uint64 - Block [32]uint64 - } - binary.Read(reader, binary.LittleEndian, &raw) - slice := raw.Key >> 5 - if slice != last_slice { - if first { - first = false - } else { - //make async later - sent_count += 1 - go sendBitmap(batcher, bitmap, db, frame, bitmap_id, filter, int(last_slice), finish) - bitmap = pilosa.NewBitmap() - } - last_slice = slice - } - o := copy_raw(raw.Block) - chunk := &pilosa.Chunk{Key: raw.Key, Value: o} - bitmap.AddChunk(chunk) - - } - sent_count += 1 - go sendBitmap(batcher, bitmap, db, frame, bitmap_id, filter, int(last_slice), finish) - for i := 0; i < sent_count; i++ { - <-finish - } - return "OK" - -} diff --git a/core/ping.go b/core/ping.go deleted file mode 100644 index 0d281580f..000000000 --- a/core/ping.go +++ /dev/null @@ -1,62 +0,0 @@ -package core - -import ( - "encoding/gob" - "time" - - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" -) - -type PingRequest struct { - Id *pilosa.GUID - Source *pilosa.GUID -} - -type PongRequest struct { - Id *pilosa.GUID -} - -func (self PongRequest) ResultId() *pilosa.GUID { - return self.Id -} -func (self PongRequest) ResultData() interface{} { - return self.Id -} - -func init() { - gob.Register(PingRequest{}) - gob.Register(PongRequest{}) -} - -type Pinger struct { - ID pilosa.GUID - - Hold interface { - Get(id *pilosa.GUID, timeout time.Duration) (interface{}, error) - } - - Transport interface { - Send(message *db.Message, host *pilosa.GUID) - } -} - -func NewPinger(id pilosa.GUID) *Pinger { - return &Pinger{ - ID: id, - } -} - -func (self *Pinger) Ping(process_id *pilosa.GUID) (*time.Duration, error) { - id := pilosa.NewGUID() - ping := db.Message{Data: PingRequest{Id: &id, Source: &self.ID}} - start := time.Now() - self.Transport.Send(&ping, process_id) - _, err := self.Hold.Get(&id, 60*time.Second) - if err != nil { - return nil, err - } - end := time.Now() - dur := end.Sub(start) - return &dur, nil -} diff --git a/core/remotebits.go b/core/remotebits.go deleted file mode 100644 index 47649b7e6..000000000 --- a/core/remotebits.go +++ /dev/null @@ -1,127 +0,0 @@ -package core - -import ( - "encoding/gob" - - log "github.com/cihub/seelog" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" -) - -type RemoteSetBit struct { - requests []remote_task - cluster map[*pilosa.GUID][]BitmapRequestItem - - ID pilosa.GUID - ProcessMap *ProcessMap - - Hold interface { - Get(id *pilosa.GUID, timeout int) (interface{}, error) - } - - Transport interface { - Send(message *db.Message, host *pilosa.GUID) - } -} - -func init() { - gob.Register(BitmapRequestItem{}) - gob.Register(BitsRequest{}) - gob.Register(BitsResponse{}) -} - -type BitsRequest struct { - Bits []BitmapRequestItem - ReturnProcessId pilosa.GUID - QueryId pilosa.GUID - DestProcessId pilosa.GUID -} -type BitmapRequestItem struct { - Fragment_id pilosa.SUUID - Bitmap_id uint64 - Profile_id uint64 - Filter uint64 - Frame string - SetUnset bool -} - -func NewRemoteSetBit() *RemoteSetBit { - obj := new(RemoteSetBit) - obj.cluster = make(map[*pilosa.GUID][]BitmapRequestItem) - return obj -} - -func (self *RemoteSetBit) Request() { - self.requests = make([]remote_task, 0) - source_process, _ := self.ProcessMap.GetProcess(&self.ID) - for process, request := range self.cluster { - random_id := pilosa.NewGUID() - msg := new(db.Message) - msg.Data = BitsRequest{ - Bits: request, - ReturnProcessId: source_process.Id(), - QueryId: random_id, - DestProcessId: *process, - } - wait := len(request) * 10 - if wait < 10 { - wait = 10 - } - self.requests = append(self.requests, remote_task{random_id, wait}) - self.Transport.Send(msg, process) - } - -} - -type remote_task struct { - id pilosa.GUID - wait_time int -} - -func (self *RemoteSetBit) MergeResults(local_results []SBResult) []SBResult { - answers := make(chan []SBResult) - for _, task := range self.requests { - go func(task remote_task) { - value, err := self.Hold.Get(&task.id, task.wait_time) //eiher need to be the frame process or the handler process? - if value == nil { - log.Warn("Bad RemoteSetBit Result:", err) - empty := make([]SBResult, 0, 0) - answers <- empty - - } else { - answers <- value.([]SBResult) - } - }(task) - } - for i := 0; i < len(self.requests); i++ { - batch := <-answers - for _, item := range batch { - local_results = append(local_results, item) - } - } - close(answers) - return local_results - -} - -func (self *RemoteSetBit) Add(frag *db.Fragment, bitmap_id, profile_id, filter uint64, frame string, SetUnset bool) { - x, found := self.cluster[frag.GetProcessId()] - if !found { - x = make([]BitmapRequestItem, 0) - } - x = append(x, BitmapRequestItem{frag.GetId(), bitmap_id, profile_id, filter, frame, SetUnset}) - self.cluster[frag.GetProcessId()] = x - -} - -type BitsResponse struct { - Id *pilosa.GUID - Items []SBResult -} - -func (self *BitsResponse) ResultId() *pilosa.GUID { - return self.Id -} -func (self *BitsResponse) ResultData() interface{} { - return self.Items -} diff --git a/core/stopper.go b/core/stopper.go deleted file mode 100644 index 5569d2e21..000000000 --- a/core/stopper.go +++ /dev/null @@ -1,37 +0,0 @@ -package core - -import ( - "sync" -) - -type Stopper struct { - TermChans []chan int - DoneChans []chan int - Mutex sync.RWMutex -} - -func (stopper *Stopper) Stop() { - var i chan int - var o chan int - stopper.Mutex.RLock() - for _, i = range stopper.TermChans { - go func(i chan int) { - i <- 1 - }(i) - } - for _, o = range stopper.DoneChans { - <-o - } - stopper.Mutex.RUnlock() - return -} - -func (stopper *Stopper) GetExitChannels() (chan int, chan int) { - termchan := make(chan int, 1) - donechan := make(chan int, 1) - stopper.Mutex.Lock() - stopper.TermChans = append(stopper.TermChans, termchan) - stopper.DoneChans = append(stopper.DoneChans, donechan) - stopper.Mutex.Unlock() - return termchan, donechan -} diff --git a/db/constants.go b/db/constants.go deleted file mode 100644 index d2fbdd0eb..000000000 --- a/db/constants.go +++ /dev/null @@ -1,3 +0,0 @@ -package db - -const SLICE_WIDTH = 65536 diff --git a/db/db.go b/db/db.go deleted file mode 100644 index cb4ee081e..000000000 --- a/db/db.go +++ /dev/null @@ -1,25 +0,0 @@ -package db - -import ( - "encoding/gob" - - "github.com/umbel/pilosa" -) - -type Message struct { - Data interface{} `json:"data"` -} - -type Envelope struct { - Message *Message - Host *pilosa.GUID -} - -type HoldResult interface { - ResultId() *pilosa.GUID - ResultData() interface{} -} - -func init() { - gob.Register(Message{}) -} diff --git a/db/topology.go b/db/topology.go deleted file mode 100644 index 29e8667fd..000000000 --- a/db/topology.go +++ /dev/null @@ -1,446 +0,0 @@ -package db - -import ( - "errors" - "fmt" - "sync" - - log "github.com/cihub/seelog" - "github.com/stathat/consistent" - "github.com/umbel/pilosa" -) - -// SupportedFrames is a list of frame types that are supported. -var SupportedFrames = []string{"default"} - -var FrameDoesNotExistError = errors.New("Frame does not exist.") -var InvalidFrameError = errors.New("Invalid frame.") -var SliceDoesNotExistError = errors.New("Slice does not exist.") -var FragmentDoesNotExistError = errors.New("Fragment does not exist.") -var FrameSliceIntersectDoesNotExistError = errors.New("FrameSliceIntersect does not exist.") - -type Location struct { - ProcessId *pilosa.GUID - FragmentId pilosa.SUUID -} - -type Process struct { - id *pilosa.GUID - host string - port_tcp int - port_http int - mutex sync.Mutex -} - -func NewProcess(id *pilosa.GUID) *Process { - return &Process{id: id} -} - -func (self *Process) Id() pilosa.GUID { - self.mutex.Lock() - defer self.mutex.Unlock() - return *self.id -} - -func (self *Process) Host() string { - self.mutex.Lock() - defer self.mutex.Unlock() - return self.host -} - -func (self *Process) SetHost(host string) { - self.mutex.Lock() - defer self.mutex.Unlock() - self.host = host -} - -func (self *Process) PortTcp() int { - self.mutex.Lock() - defer self.mutex.Unlock() - return self.port_tcp -} - -func (self *Process) SetPortTcp(port int) { - self.mutex.Lock() - defer self.mutex.Unlock() - self.port_tcp = port -} - -func (self *Process) PortHttp() int { - self.mutex.Lock() - defer self.mutex.Unlock() - return self.port_http -} - -func (self *Process) SetPortHttp(port int) { - self.mutex.Lock() - defer self.mutex.Unlock() - self.port_http = port -} - -/////////// CLUSTERS -////////////////////////////////////////////////////////////////////// - -// Represents the entire cluster, and a reference to the Node this instance is -// running on -type Cluster struct { - databases map[string]*Database - mutex sync.Mutex -} - -func NewCluster() *Cluster { - cluster := Cluster{} - cluster.databases = make(map[string]*Database) - return &cluster -} -func (self *Cluster) GetDatabases() map[string]*Database { - return self.databases - -} - -func (self *Cluster) IsValidDatabase(dbname string) bool { - for name, _ := range self.GetDatabases() { - if name == dbname { - return true - } - - } - return false -} - -/////////// DATABASES -////////////////////////////////////////////////////////////////////// - -// A database is a collection of all the frames within a given profile space -type Database struct { - Name string - frames []*Frame - slices []*Slice - frame_slice_intersects []*FrameSliceIntersect - mutex sync.Mutex -} - -func (self *Database) GetFrameSliceIntersects() []*FrameSliceIntersect { - return self.frame_slice_intersects -} - -// Add a database to a cluster -func (c *Cluster) addDatabase(name string) *Database { - database := Database{Name: name} - if c.databases == nil { - c.databases = make(map[string]*Database) - } - c.databases[name] = &database - return &database -} - -func (c *Cluster) getDatabase(name string) (*Database, error) { - value, ok := c.databases[name] - if !ok { - return nil, errors.New("The database does not exist!") - } else { - return value, nil - } -} - -func (c *Cluster) GetOrCreateDatabase(name string) *Database { - c.mutex.Lock() - defer c.mutex.Unlock() - database, err := c.getDatabase(name) - if err == nil { - return database - } - return c.addDatabase(name) -} - -func stringInSlice(a string, list []string) bool { - for _, b := range list { - if b == a { - return true - } - } - return false -} - -func (d *Database) IsValidFrame(name string) bool { - return stringInSlice(name, SupportedFrames) -} - -// Count the number of slices in a database -func (d *Database) NumSlices() (int, error) { - if len(d.slices) < 1 { - return 0, errors.New("Database is empty") - } - return len(d.slices), nil -} - -// return the slice_ids that are in a database -func (d *Database) SliceIds() ([]int, error) { - var rtn []int - for _, slice := range d.slices { - rtn = append(rtn, slice.id) - } - return rtn, nil -} - -///////// FRAMES -////////////////////////////////////////////////////////////////////// - -// A frame is a collection of slices in a given category -// (brands, demographics, etc), specific to a database -type Frame struct { - name string -} - -// Get a frame from a database -func (d *Database) getFrame(name string) (*Frame, error) { - // should we check here for supported frames? - if !d.IsValidFrame(name) { - return nil, InvalidFrameError - } - for _, frame := range d.frames { - if frame.name == name { - return frame, nil - } - } - return nil, FrameDoesNotExistError -} - -// Add a frame to a database -func (d *Database) addFrame(name string) *Frame { - frame := Frame{name: name} - d.frames = append(d.frames, &frame) - // add intersections - for _, slice := range d.slices { - d.AddFrameSliceIntersect(&frame, slice) - } - return &frame -} - -func (d *Database) GetOrCreateFrame(name string) *Frame { - d.mutex.Lock() - defer d.mutex.Unlock() - frame, err := d.getFrame(name) - if err == nil { - return frame - } - return d.addFrame(name) -} - -///////// SLICES -/////////////////////////////////////////////////////////////////////////// - -// A slice is the vertical combination of every fragment. -type Slice struct { - id int -} - -func (self *Slice) Id() int { - return self.id -} - -// Get a slice from a database -func (d *Database) getSlice(slice_id int) (*Slice, error) { - for _, slice := range d.slices { - if slice.id == slice_id { - return slice, nil - } - } - return nil, SliceDoesNotExistError -} - -// Add a slice to a database -func (d *Database) addSlice(slice_id int) *Slice { - slice := Slice{id: slice_id} - d.slices = append(d.slices, &slice) - // add intersections - for _, frame := range d.frames { - d.AddFrameSliceIntersect(frame, &slice) - } - return &slice -} - -func (d *Database) GetOrCreateSlice(slice_id int) *Slice { - d.mutex.Lock() - defer d.mutex.Unlock() - slice, err := d.getSlice(slice_id) - if err == nil { - return slice - } - return d.addSlice(slice_id) -} - -///////// FRAME-SLICE INTERSECT -//////////////////////////////////////////////////////////////// - -type FrameSliceIntersect struct { - frame *Frame - slice *Slice - fragments []*Fragment - hashring *consistent.Consistent -} - -func (d *Database) AddFrameSliceIntersect(frame *Frame, slice *Slice) *FrameSliceIntersect { - frameslice := FrameSliceIntersect{frame: frame, slice: slice} - d.frame_slice_intersects = append(d.frame_slice_intersects, &frameslice) - frameslice.hashring = consistent.New() - frameslice.hashring.NumberOfReplicas = 16 - return &frameslice -} - -func (d *Database) GetFrameSliceIntersect(frame *Frame, slice *Slice) (*FrameSliceIntersect, error) { - for _, frameslice := range d.frame_slice_intersects { - if frameslice.frame == frame && frameslice.slice == slice { - return frameslice, nil - } - } - log.Warn("Missing FrameSliceIntersect:", d.Name, frame, slice) - return nil, FrameSliceIntersectDoesNotExistError -} - -func (self *FrameSliceIntersect) GetFragments() []*Fragment { - return self.fragments -} - -func (d *Database) GetFragment(fragment_id pilosa.SUUID) (*Fragment, error) { - for _, fsi := range d.frame_slice_intersects { - f, err := fsi.GetFragment(fragment_id) - if err == nil { - return f, nil - } - } - return nil, FragmentDoesNotExistError -} -func (self *FrameSliceIntersect) GetFragment(fragment_id pilosa.SUUID) (*Fragment, - error) { - for _, fragment := range self.fragments { - if fragment.id == fragment_id { - return fragment, nil - } - } - return nil, FragmentDoesNotExistError -} - -func (self *FrameSliceIntersect) AddFragment(fragment *Fragment) { - self.fragments = append(self.fragments, fragment) - self.hashring.Add(fragment.id.String()) -} - -///////// FRAGMENTS -////////////////////////////////////////////////////////////////////////// - -// A fragment is a collection of bitmaps within a slice. The fragment contains a -// reference to the responsible node for that fragment. The node is in the form -// ip:port -type Fragment struct { - id pilosa.SUUID - process *Process -} - -func (self *Fragment) GetId() pilosa.SUUID { - return self.id -} - -func (self *Fragment) GetProcess() *Process { - return self.process -} - -func (self *Fragment) GetProcessId() *pilosa.GUID { - return self.process.id -} - -func (self *Fragment) GetLocation() *Location { - return &Location{self.process.id, self.id} -} - -// rename this one -func (d *Database) GetFragmentForBitmap(slice *Slice, bitmap *Bitmap) (*Fragment, error) { - frame, err := d.getFrame(bitmap.FrameType) - if err != nil { - log.Warn("Missing FrameType", bitmap.FrameType, d.Name, slice) - log.Warn(err) - return nil, err - } - fsi, err := d.GetFrameSliceIntersect(frame, slice) - if err != nil { - log.Warn("Missing frame,slice", frame, slice) - log.Warn(err) - return nil, err - } - frag_id_s, err := fsi.hashring.Get(fmt.Sprintf("%d", bitmap.Id)) - if err != nil { - log.Warn("ERROR FSI.GET:", bitmap.Id, bitmap.FrameType, d.Name, frame, slice) - log.Warn(err) - return nil, err - } - frag_id := pilosa.ParseSUUID(frag_id_s) - return fsi.GetFragment(frag_id) -} - -func (d *Database) GetFragmentForFrameSlice(frame *Frame, slice *Slice) (*Fragment, error) { - fsi, err := d.GetFrameSliceIntersect(frame, slice) - if err != nil { - log.Warn("Missing frame,slice", frame, slice) - log.Warn(err) - return nil, err - } - frag_id_s, err := fsi.hashring.Get("0") - // we don't need a specific bitmap in here because we're assuming the hashring only has a single element - if err != nil { - log.Warn("ERROR FSI.GET:", d.Name, frame, slice) - log.Warn(err) - return nil, err - } - frag_id := pilosa.ParseSUUID(frag_id_s) - return fsi.GetFragment(frag_id) -} - -func (d *Database) getFragment(frame *Frame, slice *Slice, fragment_id pilosa.SUUID) (*Fragment, error) { - fsi, err := d.GetFrameSliceIntersect(frame, slice) - if err != nil { - log.Warn(err) - return nil, err - } - return fsi.GetFragment(fragment_id) -} - -func (d *Database) addFragment(frame *Frame, slice *Slice, fragment_id pilosa.SUUID) *Fragment { - fsi, err := d.GetFrameSliceIntersect(frame, slice) - if err != nil { - log.Warn("database.addFragment", err) - return nil - } - fragment := Fragment{id: fragment_id} - fsi.AddFragment(&fragment) - return &fragment -} - -func (d *Database) GetOrCreateFragment(frame *Frame, slice *Slice, fragment_id pilosa.SUUID) *Fragment { - d.mutex.Lock() - defer d.mutex.Unlock() - fragment, err := d.getFragment(frame, slice, fragment_id) - if err == nil { - return fragment - } - return d.addFragment(frame, slice, fragment_id) -} - -func (f *Fragment) SetProcess(process *Process) { - f.process = process -} -func GetSlice(profile_id uint64) int { - return int(profile_id / SLICE_WIDTH) -} - -/////////////////////////////////////////////////////////////////////////////////////////////// -// Get a slice from a database - -func (d *Database) GetSliceForProfile(profile_id uint64) (*Slice, error) { - return d.getSlice(GetSlice(profile_id)) -} - -type Bitmap struct { - Id uint64 - FrameType string - Filter uint64 -} diff --git a/db/topology_test.go b/db/topology_test.go deleted file mode 100644 index 54495ba01..000000000 --- a/db/topology_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package db_test - -import ( - "testing" - - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/util" -) - -func TestCluster(t *testing.T) { - c := db.NewCluster() - d := c.GetOrCreateDatabase("main") - - f := d.GetOrCreateFrame("general") - sl := d.GetOrCreateSlice(0) - d.GetOrCreateFragment(f, sl, util.Id()) -} diff --git a/dispatch/dispatch.go b/dispatch/dispatch.go deleted file mode 100644 index db20fa9ce..000000000 --- a/dispatch/dispatch.go +++ /dev/null @@ -1,123 +0,0 @@ -package dispatch - -import ( - "time" - - log "github.com/cihub/seelog" - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/core" - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/executor" - "github.com/umbel/pilosa/query" -) - -type Dispatch struct { - Executor interface { - NewJob(job *db.Message) - } - - Hold interface { - Set(id *pilosa.GUID, value interface{}, timeout time.Duration) - } - - Index interface { - ClearBit(fragID pilosa.SUUID, bitmapID uint64, pos uint64) (bool, error) - LoadBitmap(fragID pilosa.SUUID, bitmapID uint64, compressedBitmap string, filter uint64) - SetBit(fragID pilosa.SUUID, bitmapID uint64, pos uint64, category uint64) (bool, error) - TopFillBatch(args []pilosa.FillArgs) ([]pilosa.Pair, error) - } - - Transport interface { - Receive() *db.Message - Send(message *db.Message, host *pilosa.GUID) - } -} - -func NewDispatch() *Dispatch { - return &Dispatch{} -} - -func (self *Dispatch) Init() error { - log.Warn("Starting Dispatcher") - return nil -} - -func (self *Dispatch) Close() { - log.Warn("Shutting down Dispatcher") -} - -// The Local Route - -func (d *Dispatch) Run() { - log.Warn("Dispatch Run...") - for { - message := d.Transport.Receive() - - switch data := message.Data.(type) { - case core.BatchRequest: - log.Trace("Dispatch.Run BatchRequest") - response := db.Message{Data: core.BatchResponse{Id: data.Id}} - d.Index.LoadBitmap(data.Fragment_id, data.Bitmap_id, data.Compressed_bitmap, data.Filter) - d.Transport.Send(&response, data.Source) - - case core.BitsRequest: - log.Trace("Dispatch.Run BitsRequest") - var results []core.SBResult - result := false - - for _, v := range data.Bits { - if v.SetUnset { - result, _ = d.Index.SetBit(v.Fragment_id, v.Bitmap_id, v.Profile_id, uint64(v.Filter)) - } else { - result, _ = d.Index.ClearBit(v.Fragment_id, v.Bitmap_id, v.Profile_id) - } - bundle := core.SBResult{Bitmap_id: v.Bitmap_id, Frame: v.Frame, Filter: v.Filter, Profile_id: v.Profile_id, Result: result} - results = append(results, bundle) - } - response := db.Message{Data: core.BitsResponse{Id: &data.QueryId, Items: results}} - d.Transport.Send(&response, &data.ReturnProcessId) - - case core.PingRequest: - log.Trace("Dispatch.Run Ping") - pong := db.Message{Data: core.PongRequest{Id: data.Id}} - d.Transport.Send(&pong, data.Source) - - case db.HoldResult: - log.Trace("Dispatch.Run HoldResult") - d.Hold.Set(data.ResultId(), data.ResultData(), 30*time.Second) - - case query.PortableQueryStep: - log.Trace("Dispatch.Run PortableQueryStep") - go d.Executor.NewJob(message) - - case executor.TopFill: - log.Trace("Dispatch.Run TopFill") - go d.topFillHandler(message) - - case core.BitsResponse: - d.Hold.Set(data.ResultId(), data.ResultData(), 30*time.Second) - - default: - spew.Dump(data) - log.Warn("Unprocessed message", data) - } - } -} - -func (d *Dispatch) topFillHandler(m *db.Message) { - topfill := m.Data.(executor.TopFill) - topn, err := d.Index.TopFillBatch(topfill.Args) - if err != nil { - log.Warn("TopFillHandler:", err) - } - - d.Transport.Send(&db.Message{ - Data: query.FillResult{ - BaseQueryResult: &query.BaseQueryResult{ - Id: &topfill.QueryId, - Data: topn, - }, - }, - }, &topfill.ReturnProcessId) -} diff --git a/etc/default.yaml b/etc/default.yaml deleted file mode 100644 index 2e2c8dc05..000000000 --- a/etc/default.yaml +++ /dev/null @@ -1,17 +0,0 @@ -id: 0d92507d-1646-44f8-be81-79d79c1df623 -host: localhost -port_tcp: 12001 -port_http: 15001 -log_path: /tmp -fragment_base: /tmp/single -storage_backend: cassandra -cassandra_host: localhost -cassandra_keyspace: pilosa -supported_frames: - - b.n - - t.t - - l.n - - d - - p.n -etcd_servers: - - http://127.0.0.1:4001 diff --git a/executor.go b/executor.go new file mode 100644 index 000000000..01eb7da61 --- /dev/null +++ b/executor.go @@ -0,0 +1,316 @@ +package pilosa + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "net/http" + "net/url" + + "github.com/gogo/protobuf/proto" + "github.com/umbel/pilosa/internal" + "github.com/umbel/pilosa/pql" +) + +// DefaultFrame is the frame used if one is not specified. +const DefaultFrame = "general" + +// ErrDatabaseRequired is returned when no database is specified. +var ErrDatabaseRequired = errors.New("database required") + +// Executor recursively executes calls in a PQL query across all slices. +type Executor struct { + index *Index + + // Local hostname. + Host string + + // Cluster configuration + Cluster *Cluster + + // Client used for remote HTTP requests. + HTTPClient *http.Client +} + +// NewExecutor returns a new instance of Executor. +func NewExecutor(index *Index) *Executor { + return &Executor{ + index: index, + HTTPClient: http.DefaultClient, + } +} + +// Index returns the index that the executor runs against. +func (e *Executor) Index() *Index { return e.index } + +// Execute executes a PQL query. +func (e *Executor) Execute(db string, q *pql.Query, slices []uint64) (interface{}, error) { + // Verify that a database is set. + if db == "" { + return nil, ErrDatabaseRequired + } + + // If slices aren't specified, then include all of them. + if len(slices) == 0 { + // Round up the number of slices. + sliceN := (e.index.SliceN() % uint64(len(e.Cluster.Nodes))) + uint64(len(e.Cluster.Nodes)) + + // Generate a slices of all slices. + slices = make([]uint64, sliceN+1) + for i := range slices { + slices[i] = uint64(i) + } + } + + return e.executeCall(db, q.Root, slices) +} + +// executeCall executes a call. +func (e *Executor) executeCall(db string, c pql.Call, slices []uint64) (interface{}, error) { + switch c := c.(type) { + case pql.BitmapCall: + return e.executeBitmapCall(db, c, slices) + case *pql.Count: + return e.executeCount(db, c, slices) + case *pql.TopN: + return e.executeTopN(db, c, slices) + default: + panic("unreachable") + } +} + +// executeBitmapCall executes a call that returns a bitmap. +func (e *Executor) executeBitmapCall(db string, c pql.BitmapCall, slices []uint64) (*Bitmap, error) { + other := NewBitmap() + for node, nodeSlices := range e.slicesByNode(slices) { + // Execute locally if the hostname matches. + if node.Host == e.Host { + for _, slice := range nodeSlices { + bm, err := e.executeBitmapCallSlice(db, c, slice) + if err != nil { + return nil, err + } + other.Merge(bm) + } + continue + } + + // Otherwise execute remotely. + res, err := e.exec(node, db, &pql.Query{Root: c}, nodeSlices) + if err != nil { + return nil, err + } + other.Merge(res.(*Bitmap)) + } + return other, nil +} + +// executeBitmapCallSlice executes a bitmap call for a single slice. +func (e *Executor) executeBitmapCallSlice(db string, c pql.BitmapCall, slice uint64) (*Bitmap, error) { + switch c := c.(type) { + case *pql.Difference: + return e.executeDifferenceSlice(db, c, slice) + case *pql.Get: + return e.executeGetSlice(db, c, slice) + case *pql.Intersect: + return e.executeIntersectSlice(db, c, slice) + case *pql.Range: + return e.executeRangeSlice(db, c, slice) + case *pql.Union: + return e.executeUnionSlice(db, c, slice) + default: + panic("unreachable") + } +} + +// executeTopN executes a top-n() call. +func (e *Executor) executeTopN(db string, c *pql.TopN, slices []uint64) ([]Pair, error) { + panic("FIXME: calculate top n from each slice") +} + +// executeDifferenceSlice executes a difference() call for a local slice. +func (e *Executor) executeDifferenceSlice(db string, c *pql.Difference, slice uint64) (*Bitmap, error) { + var other *Bitmap + for i, input := range c.Inputs { + bm, err := e.executeBitmapCallSlice(db, input, slice) + if err != nil { + return nil, err + } + + if i == 0 { + other = bm + } else { + other = other.Difference(bm) + } + } + return other, nil +} + +func (e *Executor) executeGetSlice(db string, c *pql.Get, slice uint64) (*Bitmap, error) { + frame := c.Frame + if frame == "" { + frame = DefaultFrame + } + + f := e.Index().Fragment(db, frame, slice) + return f.Bitmap(c.ID), nil +} + +// executeIntersectSlice executes a intersect() call for a local slice. +func (e *Executor) executeIntersectSlice(db string, c *pql.Intersect, slice uint64) (*Bitmap, error) { + var other *Bitmap + for i, input := range c.Inputs { + bm, err := e.executeBitmapCallSlice(db, input, slice) + if err != nil { + return nil, err + } + + if i == 0 { + other = bm + } else { + other = other.Intersect(bm) + } + } + return other, nil +} + +// executeRangeSlice executes a range() call for a local slice. +func (e *Executor) executeRangeSlice(db string, c *pql.Range, slice uint64) (*Bitmap, error) { + panic("FIXME") +} + +// executeUnionSlice executes a union() call for a local slice. +func (e *Executor) executeUnionSlice(db string, c *pql.Union, slice uint64) (*Bitmap, error) { + var other *Bitmap + for i, input := range c.Inputs { + bm, err := e.executeBitmapCallSlice(db, input, slice) + if err != nil { + return nil, err + } + + if i == 0 { + other = bm + } else { + other = other.Union(bm) + } + } + return other, nil +} + +// executeCount executes a count() call. +func (e *Executor) executeCount(db string, c *pql.Count, slices []uint64) (uint64, error) { + var n uint64 + for node, nodeSlices := range e.slicesByNode(slices) { + // Execute locally if the hostname matches. + if node.Host == e.Host { + for _, slice := range nodeSlices { + bm, err := e.executeBitmapCallSlice(db, c.Input, slice) + if err != nil { + return 0, err + } + n += bm.Count() + } + continue + } + + // Otherwise execute remotely. + res, err := e.exec(node, db, &pql.Query{Root: c}, nodeSlices) + if err != nil { + return 0, err + } + n += res.(uint64) + } + return n, nil +} + +// exec executes a PQL query remotely for a set of slices on a node. +func (e *Executor) exec(node *Node, db string, q *pql.Query, slices []uint64) (result interface{}, err error) { + // Encode request object. + buf, err := proto.Marshal(&internal.QueryRequest{ + DB: proto.String(db), + Query: proto.String(q.String()), + Slices: slices, + }) + if err != nil { + return nil, err + } + + // Create HTTP request. + req, err := http.NewRequest("POST", (&url.URL{ + Scheme: "http", + Host: node.Host, + Path: "/query", + }).String(), bytes.NewReader(buf)) + if err != nil { + return nil, err + } + + // Require protobuf encoding. + req.Header.Set("Accept", "application/x-protobuf") + req.Header.Set("Content-Type", "application/x-protobuf") + + // Send request to remote node. + resp, err := e.HTTPClient.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + // Read response into buffer. + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + // Check status code. + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("invalid status: code=%d, err=%s", resp.StatusCode, body) + } + + // Decode response object. + var pb internal.QueryResponse + if err := proto.Unmarshal(body, &pb); err != nil { + return nil, err + } + + // Return an error, if specified on response. + if err := decodeError(pb.GetErr()); err != nil { + return nil, err + } + + // Return appropriate data for the query. + switch q.Root.(type) { + case pql.BitmapCall: + return decodeBitmap(pb.GetBitmap()), nil + case *pql.TopN: + return decodePairs(pb.GetPairs()), nil + case *pql.Count: + return pb.GetN(), nil + default: + panic(fmt.Sprintf("invalid node for remote exec: %T", q.Root)) + } +} + +// slicesByNode returns a mapping of nodes to slices. +// +// NOTE: Currently the only primary node is used. +func (e *Executor) slicesByNode(slices []uint64) map[*Node][]uint64 { + m := make(map[*Node][]uint64) + for _, slice := range slices { + nodes := e.Cluster.SliceNodes(slice) + + node := nodes[0] + m[node] = append(m[node], slice) + } + return m +} + +// decodeError returns an error representation of s if s is non-blank. +// Returns nil if s is blank. +func decodeError(s string) error { + if s == "" { + return nil + } + return errors.New(s) +} diff --git a/executor/executor.go b/executor/executor.go deleted file mode 100644 index 4f16d6d10..000000000 --- a/executor/executor.go +++ /dev/null @@ -1,800 +0,0 @@ -package executor - -import ( - "encoding/gob" - "sort" - "time" - - log "github.com/cihub/seelog" - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/core" - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/query" -) - -const DefaultTimeout = 30 * time.Second - -type Executor struct { - inbox chan *db.Message - - ID pilosa.GUID - Cluster *db.Cluster - ProcessMap *core.ProcessMap - PluginsPath string - - Hold interface { - Get(id *pilosa.GUID, timeout time.Duration) (interface{}, error) - Set(id *pilosa.GUID, value interface{}, timeout time.Duration) - } - - Index interface { - ClearBit(frag_id pilosa.SUUID, bitmap_id uint64, pos uint64) (bool, error) - Count(frag_id pilosa.SUUID, bitmap pilosa.BitmapHandle) (uint64, error) - Difference(frag_id pilosa.SUUID, bh []pilosa.BitmapHandle) (pilosa.BitmapHandle, error) - FromBytes(frag_id pilosa.SUUID, bytes []byte) (pilosa.BitmapHandle, error) - Get(frag_id pilosa.SUUID, bitmap_id uint64) (pilosa.BitmapHandle, error) - GetBytes(frag_id pilosa.SUUID, bh pilosa.BitmapHandle) ([]byte, error) - Intersect(frag_id pilosa.SUUID, bh []pilosa.BitmapHandle) (pilosa.BitmapHandle, error) - Range(frag_id pilosa.SUUID, bitmap_id uint64, start, end time.Time) (pilosa.BitmapHandle, error) - SetBit(frag_id pilosa.SUUID, bitmap_id uint64, pos uint64, category uint64) (bool, error) - TopN(frag_id pilosa.SUUID, bh pilosa.BitmapHandle, n int, categories []uint64) ([]pilosa.Pair, error) - TopNAll(frag_id pilosa.SUUID, n int, categories []uint64) ([]pilosa.Pair, error) - Union(frag_id pilosa.SUUID, bh []pilosa.BitmapHandle) (pilosa.BitmapHandle, error) - } - - TopologyMapper interface { - MakeFragments(db string, slice_int int) error - } - - Transport interface { - Send(*db.Message, *pilosa.GUID) - } -} - -func NewExecutor(id pilosa.GUID) *Executor { - log.Trace("NewExector") - return &Executor{inbox: make(chan *db.Message)} -} - -func (self *Executor) Init() error { - log.Trace("Executor.Init()") - return nil -} - -func (self *Executor) Close() { - log.Trace("Executor.Close()") -} - -func (self *Executor) NewJob(job *db.Message) { - log.Trace("NewJob", job) - switch job.Data.(type) { - case query.CountQueryStep: - self.CountQueryStepHandler(job) - case query.TopNQueryStep: - self.TopNQueryStepHandler(job) - case query.UnionQueryStep: - self.UnionQueryStepHandler(job) - case query.IntersectQueryStep: - self.IntersectQueryStepHandler(job) - case query.DifferenceQueryStep: - self.DifferenceQueryStepHandler(job) - case query.CatQueryStep: - self.CatQueryStepHandler(job) - case query.GetQueryStep: - self.GetQueryStepHandler(job) - case query.SetQueryStep: - self.SetQueryStepHandler(job) - case query.ClearQueryStep: - self.ClearQueryStepHandler(job) - case query.RangeQueryStep: - self.RangeQueryStepHandler(job) - case query.StashQueryStep: - self.StashQueryStepHandler(job) - default: - log.Warn("unknown") - log.Warn(spew.Sdump(job.Data)) - } -} - -func (self *Executor) CountQueryStepHandler(msg *db.Message) { - log.Trace("CountQueryStepHandler") - //spew.Dump("COUNT QUERYSTEP") - qs := msg.Data.(query.CountQueryStep) - input := qs.Input - value, _ := self.Hold.Get(input, DefaultTimeout) - var bh pilosa.BitmapHandle - switch val := value.(type) { - case pilosa.BitmapHandle: - bh = val - case []byte: - bh, _ = self.Index.FromBytes(qs.Location.FragmentId, val) - } - count, err := self.Index.Count(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - } - //spew.Dump("SLICE COUNT", count) - result_message := db.Message{ - Data: query.CountQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: count}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) TopNQueryStepHandler(msg *db.Message) { - qs := msg.Data.(query.TopNQueryStep) - var bh pilosa.BitmapHandle - var topnPackage TopNPackage - - // if we have an input, hold for it. if we don't, we assume an all() query - if qs.Input == nil { - topn, err := self.Index.TopNAll(qs.Location.FragmentId, qs.N*2, qs.Filters) - if err != nil { - log.Warn(spew.Sdump(err)) - } - topnPackage = TopNPackage{*qs.Location.ProcessId, qs.Location.FragmentId, topn, bh} - } else { - input := qs.Input - value, _ := self.Hold.Get(input, 10) - //var bh pilosa.BitmapHandle - switch val := value.(type) { - case pilosa.BitmapHandle: - bh = val - case []byte: - bh, _ = self.Index.FromBytes(qs.Location.FragmentId, val) - } - - topn, err := self.Index.TopN(qs.Location.FragmentId, bh, qs.N*2, qs.Filters) - if err != nil { - log.Warn(spew.Sdump(err)) - } - topnPackage = TopNPackage{*qs.Location.ProcessId, qs.Location.FragmentId, topn, bh} - } - - result_message := db.Message{ - Data: query.TopNQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: topnPackage}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) UnionQueryStepHandler(msg *db.Message) { - log.Trace("UnionQueryStepHandler") - //spew.Dump("UNION QUERYSTEP") - - qs := msg.Data.(query.UnionQueryStep) - var handles []pilosa.BitmapHandle - // create a list of bitmap handles - for _, input := range qs.Inputs { - value, _ := self.Hold.Get(input, DefaultTimeout) - switch val := value.(type) { - case pilosa.BitmapHandle: - handles = append(handles, val) - case []byte: - bh, _ := self.Index.FromBytes(qs.Location.FragmentId, val) - handles = append(handles, bh) - } - } - - bh, err := self.Index.Union(qs.Location.FragmentId, handles) - if err != nil { - spew.Dump(err) - } - - var result interface{} - if qs.LocIsDest() { - result = bh - } else { - bm, err := self.Index.GetBytes(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - } - result = bm - } - result_message := db.Message{ - Data: query.UnionQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) IntersectQueryStepHandler(msg *db.Message) { - log.Trace("IntersectQueryStepHandler") - //spew.Dump("INTERSECT QUERYSTEP") - qs := msg.Data.(query.IntersectQueryStep) - var handles []pilosa.BitmapHandle - // create a list of bitmap handles - for _, input := range qs.Inputs { - value, _ := self.Hold.Get(input, DefaultTimeout) - switch val := value.(type) { - case pilosa.BitmapHandle: - handles = append(handles, val) - case []byte: - bh, _ := self.Index.FromBytes(qs.Location.FragmentId, val) - handles = append(handles, bh) - } - } - - bh, err := self.Index.Intersect(qs.Location.FragmentId, handles) - if err != nil { - spew.Dump(err) - } - - var result interface{} - if qs.LocIsDest() { - result = bh - } else { - bm, err := self.Index.GetBytes(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - } - result = bm - } - result_message := db.Message{ - Data: query.IntersectQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) DifferenceQueryStepHandler(msg *db.Message) { - log.Trace("DifferenceQueryStepHandler") - //spew.Dump("DIFFERENCE QUERYSTEP") - qs := msg.Data.(query.DifferenceQueryStep) - var handles []pilosa.BitmapHandle - // create a list of bitmap handles - for _, input := range qs.Inputs { - value, _ := self.Hold.Get(input, DefaultTimeout) - switch val := value.(type) { - case pilosa.BitmapHandle: - handles = append(handles, val) - case []byte: - bh, _ := self.Index.FromBytes(qs.Location.FragmentId, val) - handles = append(handles, bh) - } - } - - bh, err := self.Index.Difference(qs.Location.FragmentId, handles) - if err != nil { - spew.Dump(err) - } - - var result interface{} - if qs.LocIsDest() { - result = bh - } else { - bm, err := self.Index.GetBytes(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - } - result = bm - } - result_message := db.Message{ - Data: query.DifferenceQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) CatQueryStepHandler(msg *db.Message) { - log.Trace("CatQueryStepHandler") - qs := msg.Data.(query.CatQueryStep) - var handles []pilosa.BitmapHandle - return_type := "bitmap-handles" - var sum uint64 - merge_map := make(map[uint64]uint64) - slice_map := make(map[uint64]map[pilosa.SUUID]struct{}) - all_slice := make(map[pilosa.SUUID]struct { - process pilosa.GUID - handle pilosa.BitmapHandle - }) - - // either create a list of bitmap handles to cat (i.e. union), or sum the integer values - part := make(chan interface{}) - num_parts := len(qs.Inputs) - - for _, input := range qs.Inputs { - go func(id *pilosa.GUID, part chan interface{}) { - value, _ := self.Hold.Get(id, DefaultTimeout) - part <- value - }(input, part) - } - - //for _, input := range qs.Inputs { - check_pair := false - for i := 0; i < num_parts; i++ { - value := <-part - - switch val := value.(type) { - case pilosa.BitmapHandle: - handles = append(handles, val) - case []byte: - bh, _ := self.Index.FromBytes(qs.Location.FragmentId, val) - handles = append(handles, bh) - case uint64: - //spew.Dump(val) - return_type = "sum" - sum += val - case TopNPackage: - return_type = "pair-list" - var e struct{} - for _, pair := range val.Pairs { - //merge_map[pair.Key] += pair.Count - if pair.Key == 0 { - continue //skip - } - merge_map[pair.Key] += pair.Count - mm, ok := slice_map[pair.Key] - if !ok { - mm = make(map[pilosa.SUUID]struct{}) - slice_map[pair.Key] = mm - } - mm[val.FragmentId] = e - } - all_slice[val.FragmentId] = struct { - process pilosa.GUID - handle pilosa.BitmapHandle - }{val.ProcessId, val.HBitmap} - check_pair = true - } - } - if check_pair { //no point in doing this for non top-n handling - tasks := BuildTask(merge_map, slice_map, all_slice) - self.FetchMissing(tasks) - for k, v := range self.GatherResults(tasks) { - merge_map[k] += v - } - } - - // either return the sum, or return the compressed bitmap resulting from the cat (union) - var result interface{} - if return_type == "sum" { - result = sum - } else if return_type == "bitmap-handles" { - bh, err := self.Index.Union(qs.Location.FragmentId, handles) - result, err = self.Index.GetBytes(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - } - } else if return_type == "pair-list" { - rank_list := make(pilosa.RankList, 0, len(merge_map)) - for k, v := range merge_map { - if k == 0 || v == 0 { - continue //shouldn't be getting 0 keys or values anyway - } - rank := new(pilosa.Rank) - rank.Pair = &pilosa.Pair{Key: k, Count: v} - rank_list = append(rank_list, rank) - } - sort.Sort(rank_list) // kinda seems like this copy is wasteful..i'll ponder - items_size := min(len(merge_map), qs.N) - pair_list := make([]pilosa.Pair, 0, items_size+1) - for i, r := range rank_list { - if i < items_size { - pair_list = append(pair_list, *r.Pair) - } else { - break - } - } - result = pair_list - } else { - result = "NONE" - } - result_message := db.Message{ - Data: query.CatQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) SendRequest(process_id pilosa.GUID, t *Task) { - args := make([]pilosa.FillArgs, len(t.f), len(t.f)) - for _, v := range t.f { - args = append(args, v) - } - msg := new(db.Message) - p, _ := self.ProcessMap.GetProcess(&self.ID) - msg.Data = TopFill{args, p.Id(), t.hold_id, process_id} - self.Transport.Send(msg, &process_id) -} - -func (self *Executor) FetchMissing(tasks map[pilosa.GUID]*Task) { - for k, v := range tasks { - go self.SendRequest(k, v) - } -} - -func (self *Executor) GatherResults(tasks map[pilosa.GUID]*Task) map[uint64]uint64 { - results := make(map[uint64]uint64) - answers := make(chan []pilosa.Pair) - for _, task := range tasks { - go func(id pilosa.GUID) { - value, err := self.Hold.Get(&id, 10) //eiher need to be the frame process or the handler process? - if value == nil { - log.Warn("Bad TopN Result:", err) - empty := make([]pilosa.Pair, 0, 0) - answers <- empty - - } else { - answers <- value.([]pilosa.Pair) - } - }(task.hold_id) - } - for i := 0; i < len(tasks); i++ { - batch := <-answers - for _, pair := range batch { - results[pair.Key] += pair.Count - } - } - close(answers) - return results -} - -func (self *Executor) GetQueryStepHandler(msg *db.Message) { - qs := msg.Data.(query.GetQueryStep) - //spew.Dump("GET QUERYSTEP") - - bh, err := self.Index.Get(qs.Location.FragmentId, qs.Bitmap.Id) - if err != nil { - spew.Dump(err) - log.Error("GetQueryStepHandler1", qs.Location.FragmentId.String(), qs.Bitmap.Id) - log.Error("GetQueryStepHandler2", err) - } - - var result interface{} - if qs.LocIsDest() { - result = bh - } else { - bm, err := self.Index.GetBytes(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - log.Error("GetQueryStepHandlerr3", qs.Location.FragmentId.String(), qs.Bitmap.Id) - log.Error("GetQueryStepHandler4", err) - } - result = bm - } - result_message := db.Message{ - Data: query.GetQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) SetQueryStepHandler(msg *db.Message) { - //spew.Dump("SET QUERYSTEP") - qs := msg.Data.(query.SetQueryStep) - result, _ := self.Index.SetBit(qs.Location.FragmentId, qs.Bitmap.Id, qs.ProfileId, qs.Bitmap.Filter) - - result_message := db.Message{ - Data: query.SetQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) ClearQueryStepHandler(msg *db.Message) { - //spew.Dump("SET QUERYSTEP") - qs := msg.Data.(query.ClearQueryStep) - result, _ := self.Index.ClearBit(qs.Location.FragmentId, qs.Bitmap.Id, qs.ProfileId) - - result_message := db.Message{ - Data: query.ClearQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) RangeQueryStepHandler(msg *db.Message) { - qs := msg.Data.(query.RangeQueryStep) - //spew.Dump("RANDE QUERYSTEP") - - bh, err := self.Index.Range(qs.Location.FragmentId, qs.Bitmap.Id, qs.Start, qs.End) - if err != nil { - spew.Dump(err) - } - - var result interface{} - if qs.LocIsDest() { - result = bh - } else { - bm, err := self.Index.GetBytes(qs.Location.FragmentId, bh) - if err != nil { - spew.Dump(err) - } - result = bm - } - result_message := db.Message{ - Data: query.RangeQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) -} - -func (self *Executor) StashQueryStepHandler(msg *db.Message) { - log.Trace("StashQueryStepHandler") - qs := msg.Data.(query.StashQueryStep) - - part := make(chan interface{}) - num_parts := len(qs.Inputs) - - for _, input := range qs.Inputs { - go func(id *pilosa.GUID, part chan interface{}) { - value, _ := self.Hold.Get(id, DefaultTimeout) - part <- value - }(input, part) - } - //just collect all the handles and return them - result := query.NewStash() //query.Stash{make([]query.CacheItem, 0), false} - for i := 0; i < num_parts; i++ { - value := <-part - - switch val := value.(type) { - case pilosa.BitmapHandle: - log.Info("STASH ADDING HANDLE", val) - //not sure what to do here.... - //result.Handles = append(result.Handles, val) - case []byte: - bh, _ := self.Index.FromBytes(qs.Location.FragmentId, val) - item := query.CacheItem{FragmentId: qs.Location.FragmentId, Handle: bh} - result.Stash = append(result.Stash, item) - case query.Stash: - result.Stash = append(result.Stash, val.Stash...) - default: - log.Warn("UNEXCPECTED MESSAGE", value) - } - } - result_message := db.Message{ - Data: query.StashQueryResult{ - BaseQueryResult: &query.BaseQueryResult{Id: qs.Id, Data: result}, - }, - } - self.Transport.Send(&result_message, qs.Destination.ProcessId) - -} - -func (self *Executor) RunQueryTest(database_name string, pql string) string { - return pql -} - -func (self *Executor) runQuery(database *db.Database, qry *query.Query) error { - log.Trace("Executor.runQuery", database, qry) - process, err := self.ProcessMap.GetProcess(&self.ID) - if err != nil { - return err - } - process_id := process.Id() - fragment_id := pilosa.SUUID(0) - destination := db.Location{ProcessId: &process_id, FragmentId: fragment_id} - - query_plan, err := query.QueryPlanForQuery(database, qry, &destination) - if err != nil { - switch obj := err.(type) { - case *query.FragmentNotFound: - self.TopologyMapper.MakeFragments(obj.Db, obj.Slice) - } - self.Hold.Set(qry.Id, err, 30) - return err - } - // loop over the query steps and send to Transport - for _, qs := range *query_plan { - msg := new(db.Message) - msg.Data = qs - switch step := qs.(type) { - case query.PortableQueryStep: - loc := step.GetLocation() - if loc != nil { - self.Transport.Send(msg, loc.ProcessId) - } else { - log.Warn("Problem with querystep(nil location)", spew.Sdump(step)) - } - } - } - return nil -} - -func (self *Executor) RunPQL(database_name string, pql string) (interface{}, error) { - log.Trace("Executor.RunPQL", database_name, pql) - database := self.Cluster.GetOrCreateDatabase(database_name) - - // see if the outer query function is a custom query - reserved_functions := stringSlice{"get", "set", "clear", "union", "intersect", "difference", "count", "top-n", "mask", "range", "stash", "recall"} - tokens, err := query.Lex(pql) - if err != nil { - return nil, err - } - outer_token := tokens[0].Text - - if reserved_functions.pos(outer_token) != -1 { - - qry, err := query.QueryForTokens(tokens) - if err != nil { - return nil, err - } - go self.runQuery(database, qry) - - var final interface{} - final, err = self.Hold.Get(qry.Id, 10) - if err != nil { - return nil, err - } - return final, nil - - } else { //want to refactor this down to just RunPlugin(tokens) - plugins_file := self.PluginsPath + "/" + outer_token + ".js" - filter, filters := query.TokensToFilterStrings(tokens) - query_list := GetPlugin(plugins_file, filter, filters).(query.PqlList) - - for i, _ := range query_list { - qry, err := query.QueryForPQL(query_list[i].PQL) - if err != nil { - return nil, err - } - go self.runQuery(database, qry) - query_list[i].Id = qry.Id - } - - final_result := make(map[string]interface{}) - result := make(chan struct { - final interface{} - label string - err error - }) - x := 0 - for i, _ := range query_list { - x++ - go func(q query.PqlListItem, reply chan struct { - final interface{} - label string - err error - }) { - final, err := self.Hold.Get(q.Id, 10) - result <- struct { - final interface{} - label string - err error - }{final, q.Label, err} - }(query_list[i], result) - if err != nil { - out := spew.Sdump(err) - log.Warn(out) - } - } - for z := 0; z < x; z++ { - ans := <-result - final_result[ans.label] = ans.final - } - - return final_result, nil - } - -} - -func init() { - gob.Register(TopNPackage{}) - gob.Register(TopFill{}) -} - -type TopNPackage struct { - ProcessId pilosa.GUID - FragmentId pilosa.SUUID - Pairs []pilosa.Pair - HBitmap pilosa.BitmapHandle -} - -type TopFill struct { - Args []pilosa.FillArgs - ReturnProcessId pilosa.GUID - QueryId pilosa.GUID - DestProcessId pilosa.GUID -} - -type Task struct { - processid pilosa.GUID - f map[pilosa.SUUID]pilosa.FillArgs - hold_id pilosa.GUID -} - -func newtask(p pilosa.GUID) *Task { - result := new(Task) - result.processid = p - result.f = make(map[pilosa.SUUID]pilosa.FillArgs) - result.hold_id = pilosa.NewGUID() - return result -} - -func (t *Task) Add(frag pilosa.SUUID, bitmap_id uint64, handle pilosa.BitmapHandle) { - fa, ok := t.f[frag] - if !ok { - fa = pilosa.FillArgs{Frag_id: frag, Handle: handle, Bitmaps: make([]uint64, 0, 0)} - } - fa.Bitmaps = append(fa.Bitmaps, bitmap_id) - t.f[frag] = fa -} - -func BuildTask(merge_map map[uint64]uint64, - slice_map map[uint64]map[pilosa.SUUID]struct{}, - total_fragments map[pilosa.SUUID]struct { - process pilosa.GUID - handle pilosa.BitmapHandle - }) map[pilosa.GUID]*Task { - - tasks := make(map[pilosa.GUID]*Task) - for bitmap_id, _ := range merge_map { //for all brands - //for fragment_id, reported_fragments := range slice_map[bitmap_id] { //find missing fragments - reporting_fragments := slice_map[bitmap_id] - //id slice ==> SUUID,BitmapHandle - for _, p := range missing(reporting_fragments, total_fragments) { - task, ok := tasks[p.process] - if !ok { - task = newtask(p.process) - tasks[p.process] = task - } - task.Add(p.fragment, bitmap_id, p.handle) - - } - //} - } - - return tasks -} - -type hole struct { - process pilosa.GUID - handle pilosa.BitmapHandle - fragment pilosa.SUUID -} - -func missing(fids map[pilosa.SUUID]struct{}, all map[pilosa.SUUID]struct { - process pilosa.GUID - handle pilosa.BitmapHandle -}) []hole { - results := make([]hole, 0, 0) - - for k, v := range all { - _, ok := fids[k] - if !ok { - results = append(results, hole{v.process, v.handle, k}) - } - } - return results -} - -func (self *TopFill) GetId() *pilosa.GUID { - return &self.QueryId -} -func (self *TopFill) GetLocation() *db.Location { - return &db.Location{ProcessId: &self.DestProcessId, FragmentId: 0} //this message is a broadcast to many fragments so i'm choosing fragmentzero -} - -func (self *Executor) Run() { - log.Warn("Executor Run...") -} - -type stringSlice []string - -func (slice stringSlice) pos(value string) int { - for p, v := range slice { - if v == value { - return p - } - } - return -1 -} - -func min(a, b int) int { - if a < b { - return a - } - return b -} diff --git a/executor/utils.go b/executor/utils.go deleted file mode 100644 index 1acc44530..000000000 --- a/executor/utils.go +++ /dev/null @@ -1,57 +0,0 @@ -package executor - -import ( - "bytes" - "io/ioutil" - "strings" - - "github.com/davecgh/go-spew/spew" - "github.com/robertkrimen/otto" - "github.com/umbel/pilosa/query" -) - -func GetPlugin(file_name string, filter string, filters []string) interface{} { - - file_data, err := ioutil.ReadFile(file_name) - if err != nil { - spew.Dump(err) - } - s := string(file_data[:]) - - // convert the list of filters in to a string array - var buffer bytes.Buffer - if len(filters) > 0 { - buffer.WriteString("['") - buffer.WriteString(strings.Join(filters, "','")) - buffer.WriteString("']") - } else { - buffer.WriteString("[]") - } - - js := "query_list = (" + s + ")('" + filter + "', " + buffer.String() + ");" - - Otto := otto.New() - Otto.Run(js) - query_objects, err := Otto.Get("query_list") - - query_list_interface, err := query_objects.Export() - if err != nil { - spew.Dump(err) - } - - var query_list query.PqlList - - // ql is []interface{} - switch ql := query_list_interface.(type) { - case []interface{}: - // q is map[string]interface{} - for i, _ := range ql { - q := ql[i].(map[string]interface{}) - query_list = append(query_list, query.PqlListItem{Label: q["label"].(string), PQL: q["pql"].(string)}) - } - default: - spew.Dump("DEFAULT") - } - - return query_list -} diff --git a/executor_test.go b/executor_test.go new file mode 100644 index 000000000..f41eb9401 --- /dev/null +++ b/executor_test.go @@ -0,0 +1,198 @@ +package pilosa_test + +import ( + "reflect" + "strings" + "testing" + + "github.com/davecgh/go-spew/spew" + "github.com/umbel/pilosa" + "github.com/umbel/pilosa/pql" +) + +// Ensure a get query can be executed. +func TestExecutor_Execute_Get(t *testing.T) { + e := NewExecutor(NewCluster(1)) + e.Index().Fragment("d", "f", 0).Bitmap(10).SetBit(3) + e.Index().Fragment("d", "f", 1).Bitmap(10).SetBit(SliceWidth + 1) + + if res, err := e.Execute("d", MustParse(`get(id=10, frame=f)`), nil); err != nil { + t.Fatal(err) + } else if chunks := res.(*pilosa.Bitmap).Chunks(); len(chunks) != 2 { + t.Fatalf("unexpected chunk length: %s", spew.Sdump(chunks)) + } else if chunks[0].Value[0] != 8 { + t.Fatalf("unexpected chunk(0): %s", spew.Sdump(chunks[0])) + } else if chunks[1].Value[0] != 2 { + t.Fatalf("unexpected chunk(1): %s", spew.Sdump(chunks[1])) + } +} + +// Ensure a difference query can be executed. +func TestExecutor_Execute_Difference(t *testing.T) { + e := NewExecutor(NewCluster(1)) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(1) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(2) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(3) + + e.Index().Fragment("d", "general", 0).Bitmap(11).SetBit(2) + + if res, err := e.Execute("d", MustParse(`difference(get(id=10), get(id=11))`), nil); err != nil { + t.Fatal(err) + } else if chunks := res.(*pilosa.Bitmap).Chunks(); len(chunks) != 1 { + t.Fatalf("unexpected chunk length: %s", spew.Sdump(chunks)) + } else if chunks[0].Value[0] != 10 { // b1010 + t.Fatalf("unexpected chunk(0): %s", spew.Sdump(chunks[0])) + } +} + +// Ensure an intersect query can be executed. +func TestExecutor_Execute_Intersect(t *testing.T) { + e := NewExecutor(NewCluster(1)) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(1) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(SliceWidth + 1) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(SliceWidth + 2) + + e.Index().Fragment("d", "general", 0).Bitmap(11).SetBit(1) + e.Index().Fragment("d", "general", 0).Bitmap(11).SetBit(2) + e.Index().Fragment("d", "general", 0).Bitmap(11).SetBit(SliceWidth + 2) + + if res, err := e.Execute("d", MustParse(`intersect(get(id=10), get(id=11))`), nil); err != nil { + t.Fatal(err) + } else if chunks := res.(*pilosa.Bitmap).Chunks(); len(chunks) != 2 { + t.Fatalf("unexpected chunk length: %s", spew.Sdump(chunks)) + } else if chunks[0].Value[0] != 2 { + t.Fatalf("unexpected chunk(0): %s", spew.Sdump(chunks[0])) + } else if chunks[1].Value[0] != 4 { + t.Fatalf("unexpected chunk(1): %s", spew.Sdump(chunks[1])) + } +} + +// Ensure a union query can be executed. +func TestExecutor_Execute_Union(t *testing.T) { + e := NewExecutor(NewCluster(1)) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(0) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(SliceWidth + 1) + e.Index().Fragment("d", "general", 0).Bitmap(10).SetBit(SliceWidth + 2) + + e.Index().Fragment("d", "general", 0).Bitmap(11).SetBit(2) + e.Index().Fragment("d", "general", 0).Bitmap(11).SetBit(SliceWidth + 2) + + if res, err := e.Execute("d", MustParse(`union(get(id=10), get(id=11))`), nil); err != nil { + t.Fatal(err) + } else if chunks := res.(*pilosa.Bitmap).Chunks(); len(chunks) != 2 { + t.Fatalf("unexpected chunk length: %s", spew.Sdump(chunks)) + } else if chunks[0].Value[0] != 5 { + t.Fatalf("unexpected chunk(0): %s", spew.Sdump(chunks[0])) + } else if chunks[1].Value[0] != 6 { + t.Fatalf("unexpected chunk(1): %s", spew.Sdump(chunks[1])) + } +} + +// Ensure a count query can be executed. +func TestExecutor_Execute_Count(t *testing.T) { + e := NewExecutor(NewCluster(1)) + e.Index().Fragment("d", "f", 0).Bitmap(10).SetBit(3) + e.Index().Fragment("d", "f", 1).Bitmap(10).SetBit(SliceWidth + 1) + e.Index().Fragment("d", "f", 1).Bitmap(10).SetBit(SliceWidth + 2) + + if n, err := e.Execute("d", MustParse(`count(get(id=10, frame=f))`), nil); err != nil { + t.Fatal(err) + } else if n != uint64(3) { + t.Fatalf("unexpected n: %d", n) + } +} + +// Ensure a remote query can return a bitmap. +func TestExecutor_Execute_Remote_Bitmap(t *testing.T) { + c := NewCluster(2) + + // Create secondary server and update second cluster node. + s := NewServer() + defer s.Close() + c.Nodes[1].Host = s.Host() + + // Mock secondary server's executor to verify arguments and return a bitmap. + s.Handler.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + if db != `d` { + t.Fatalf("unexpected db: %s", db) + } else if query.String() != `get(id=10, frame=f)` { + t.Fatalf("unexpected query: %s", query.String()) + } else if !reflect.DeepEqual(slices, []uint64{0, 2}) { + t.Fatalf("unexpected slices: %+v", slices) + } + + // Set bits in slice 0 & 2. + bm := pilosa.NewBitmap() + bm.SetBit((0 * SliceWidth) + 1) + bm.SetBit((0 * SliceWidth) + 2) + bm.SetBit((2 * SliceWidth) + 4) + return bm, nil + } + + // Create local executor data. + // The local node owns slice 1. + e := NewExecutor(c) + e.Index().Fragment("d", "f", 1).Bitmap(10).SetBit((1 * SliceWidth) + 1) + + if res, err := e.Execute("d", MustParse(`get(id=10, frame=f)`), nil); err != nil { + t.Fatal(err) + } else if chunks := res.(*pilosa.Bitmap).Chunks(); len(chunks) != 3 { + t.Fatalf("unexpected chunk length: %s", spew.Sdump(chunks)) + } else if chunks[0].Value[0] != 6 { + t.Fatalf("unexpected chunk(0): %s", spew.Sdump(chunks[0])) + } else if chunks[1].Value[0] != 2 { + t.Fatalf("unexpected chunk(1): %s", spew.Sdump(chunks[1])) + } +} + +// Ensure a remote query can return a count. +func TestExecutor_Execute_Remote_Count(t *testing.T) { + c := NewCluster(2) + + // Create secondary server and update second cluster node. + s := NewServer() + defer s.Close() + c.Nodes[1].Host = s.Host() + + // Mock secondary server's executor to return a count. + s.Handler.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return uint64(10), nil + } + + // Create local executor data. The local node owns slice 1. + e := NewExecutor(c) + e.Index().Fragment("d", "f", 1).Bitmap(10).SetBit((1 * SliceWidth) + 1) + e.Index().Fragment("d", "f", 1).Bitmap(10).SetBit((1 * SliceWidth) + 2) + + if n, err := e.Execute("d", MustParse(`count(get(id=10, frame=f))`), nil); err != nil { + t.Fatal(err) + } else if n != uint64(12) { + t.Fatalf("unexpected n: %d", n) + } +} + +// Executor represents a test wrapper for pilosa.Executor. +type Executor struct { + *pilosa.Executor +} + +// NewExecutor returns a new instance of Executor. +// The executor always matches the hostname of the first cluster node. +func NewExecutor(cluster *pilosa.Cluster) *Executor { + e := &Executor{ + Executor: pilosa.NewExecutor(pilosa.NewIndex()), + } + e.Cluster = cluster + e.Host = cluster.Nodes[0].Host + + return e +} + +// MustParse parses s into a PQL query. Panic on error. +func MustParse(s string) *pql.Query { + q, err := pql.NewParser(strings.NewReader(s)).Parse() + if err != nil { + panic(err) + } + return q +} diff --git a/fragment.go b/fragment.go index a8c2898a3..7404f8a19 100644 --- a/fragment.go +++ b/fragment.go @@ -1,213 +1,230 @@ package pilosa import ( + "sort" "strings" "sync" "time" - - log "github.com/cihub/seelog" - "github.com/golang/groupcache/lru" ) +// SliceWidth is the number of profile IDs in a slice. +const SliceWidth = 65536 + +// Fragment represents the intersection of a frame and slice in a database. type Fragment struct { - mu sync.Mutex - id SUUID - slice int - impl Pilosa - cache *lru.Cache + mu sync.Mutex - // Provide an autoincrementing index for bitmap handles. - seq uint64 + // Composite identifiers + db string + frame string + slice uint64 - // Stats for how many messages have been processed. - stats FragmentStats + // Bitmap cache. + cache Cache } -func NewFragment(id SUUID, db string, slice int, frame string) *Fragment { - storage := NewStorage(Backend, StorageOptions{ - DB: db, - Slice: slice, - Frame: frame, - FragmentID: id, - LevelDBPath: LevelDBPath, - }) - - var impl Pilosa - if strings.HasSuffix(frame, ".n") { - impl = NewBrand(db, frame, slice, storage, 50000, 45000, 100) - } else { - impl = NewGeneral(db, frame, slice, storage) - } - - return &Fragment{ - id: id, - cache: lru.New(50000), - impl: impl, +// NewFragment returns a new instance of Fragment. +func NewFragment(db, frame string, slice uint64) *Fragment { + f := &Fragment{ + db: db, + frame: frame, slice: slice, } -} -func (f *Fragment) Bitmap(bh BitmapHandle) (*Bitmap, bool) { - f.mu.Lock() - defer f.mu.Unlock() - return f.bitmap(bh) -} - -func (f *Fragment) bitmap(bh BitmapHandle) (*Bitmap, bool) { - bm, ok := f.cache.Get(bh) - if ok && bm != nil { - return bm.(*Bitmap), ok + // Determine cache type from frame name. + if strings.HasSuffix(frame, ".n") { + c := NewRankCache() + c.ThresholdLength = 50000 + c.ThresholdIndex = 45000 + f.cache = c + } else { + f.cache = NewLRUCache(50000) } - return NewBitmap(), false //cache fail + + return f } -func (f *Fragment) exists(bitmapID uint64) bool { +// Bitmap returns a bitmap by ID. +func (f *Fragment) Bitmap(bitmapID uint64) *Bitmap { f.mu.Lock() defer f.mu.Unlock() - return f.impl.Exists(bitmapID) + return f.bitmap(bitmapID) +} + +func (f *Fragment) bitmap(bitmapID uint64) *Bitmap { + // Read from cache. + if bm, ok := f.cache.Get(bitmapID); ok { + return bm + } + + // Read from storage engine. + // bm, filter := f.storage.Fetch(bitmapID, f.db, f.frame, f.slice) + + bm := NewBitmap() + f.cache.Add(bitmapID, 0 /*filter*/, bm) + return bm } func (f *Fragment) TopNAll(n int, categories []uint64) []Pair { f.mu.Lock() defer f.mu.Unlock() - return f.impl.TopNAll(n, categories) -} + f.cache.Invalidate() -func (f *Fragment) TopN(bitmap BitmapHandle, n int, categories []uint64) []Pair { - f.mu.Lock() - defer f.mu.Unlock() - - bm, ok := f.cache.Get(bitmap) - if ok { - return f.impl.TopN(bm.(*Bitmap), n, categories) + // Create a set of categories. + m := make(map[uint64]struct{}) + for _, v := range categories { + m[v] = struct{}{} } - return nil -} -func (f *Fragment) NewHandle(bitmapID uint64) BitmapHandle { - f.mu.Lock() - defer f.mu.Unlock() - return f.allocHandle(f.impl.Get(bitmapID)) -} + // Iterate over rankings and add to results until we have enough. + var results []Pair + for _, pair := range f.cache.Pairs() { + // Skip if categories are specified but category is not found. + if _, ok := m[pair.category]; (len(categories) > 0 && !ok) || pair.Count <= 0 { + continue + } -func (f *Fragment) AllocHandle(bm *Bitmap) BitmapHandle { - f.mu.Lock() - defer f.mu.Unlock() - return f.allocHandle(bm) -} + // Append pair. + results = append(results, pair) -func (f *Fragment) allocHandle(bm *Bitmap) BitmapHandle { - handle := f.nextHandle() - f.cache.Add(handle, bm) - return handle -} - -func (f *Fragment) nextHandle() BitmapHandle { - millis := uint64(time.Now().UTC().UnixNano()) - id := millis << (64 - 41) - id |= uint64(f.slice) << (64 - 41 - 13) - id |= f.seq % 1024 - f.seq += 1 - return BitmapHandle(id) -} - -func (f *Fragment) Union(bitmaps []BitmapHandle) BitmapHandle { - f.mu.Lock() - defer f.mu.Unlock() - - result := NewBitmap() - for i, id := range bitmaps { - bm, _ := f.bitmap(id) - if i == 0 { - result = bm - } else { - result = result.Union(bm) + // Exit when we have enough pairs. + if len(results) >= n { + break } } - return f.allocHandle(result) + return results } -func (f *Fragment) build_time_range_bitmap(bitmapID uint64, start, end time.Time) BitmapHandle { +func (f *Fragment) TopN(src *Bitmap, n int, categories []uint64) []Pair { f.mu.Lock() defer f.mu.Unlock() - result := NewBitmap() - for i, bid := range GetRange(start, end, bitmapID) { - bm := f.impl.Get(bid) - if i == 0 { - result = bm - } else { - result = result.Union(bm) + // Resort rank, if necessary. + f.cache.Invalidate() + + // Create a set of categories. + set := make(map[uint64]struct{}) + for _, v := range categories { + set[v] = struct{}{} + } + + var results []Pair + var x int + breakout := 1000 + + // Iterate over rankings. + rankings := f.cache.Pairs() + for i, pair := range rankings { + // Skip if category not found. + if len(set) > 0 { + if _, ok := set[pair.category]; !ok { + continue + } + } + + // Only append if there are intersecting bits with source bitmap. + bc := src.IntersectionCount(pair.bitmap) + if bc > 0 { + results = append(results, Pair{ + Key: pair.Key, + Count: bc, + category: pair.category, + }) + } + x = i + + // Exit when we have enough. + if len(results) > n { + break } } - return f.AllocHandle(result) -} -func (f *Fragment) Intersect(bitmaps []BitmapHandle) BitmapHandle { - f.mu.Lock() - defer f.mu.Unlock() + // Sort results by ranking. + sort.Sort(Pairs(results)) - var result *Bitmap - for i, id := range bitmaps { - bm, _ := f.bitmap(id) - if i == 0 { - result = bm.Clone() - } else { - result = result.Intersection(bm) + if len(results) < n { + return results + } + + end := len(results) - 1 + o := results[end] + threshold := o.Count + + if threshold <= 10 { + return results + } + + results = append(results, o) + for i := x + 1; i < len(rankings); i++ { + o = rankings[i] + + if len(set) > 0 { + if _, ok := set[o.category]; !ok { + continue + } + } + + // Need something to do with the size of initial bitmap + if len(results) > breakout || o.Count < threshold { + break + } + + bc := src.IntersectionCount(o.bitmap) + if bc > threshold { + if results[end-1].Count > bc { + results[end] = Pair{Key: o.Key, Count: bc, category: o.category} + threshold = bc + } else { + results[end+1] = Pair{Key: o.Key, Count: bc, category: o.category} + sort.Sort(Pairs(results)) + threshold = results[end].Count + } } } - return f.allocHandle(result) + + return results[:end] } -func (f *Fragment) Difference(bitmaps []BitmapHandle) BitmapHandle { - f.mu.Lock() - defer f.mu.Unlock() +/* +func (f *Fragment) TopFill(args FillArgs) ([]Pair, error) { + result := make([]Pair, 0) + for _, id := range args.Bitmaps { + if _, ok := f.cache.Get(id); !ok { + continue + } - result := NewBitmap() - for i, id := range bitmaps { - bm, _ := f.bitmap(id) - if i == 0 { - result = bm - } else { - result = result.Difference(bm) + if args.Handle == 0 { + if bm := f.Bitmap(id); bm != nil && bm.Count() > 0 { + result = append(result, Pair{Key: id, Count: bm.Count()}) + } + continue + } + + res := f.Intersect([]uint64{args.Handle, id}) + if res == nil { + continue + } + + if bc := res.BitCount(); bc > 0 { + result = append(result, Pair{Key: id, Count: bc}) } } - return f.allocHandle(result) + return result, nil } +*/ -func (f *Fragment) Persist() { +func (f *Fragment) Range(bitmapID uint64, start, end time.Time) *Bitmap { f.mu.Lock() defer f.mu.Unlock() - err := f.impl.Persist() - if err != nil { - log.Warn("Error saving:", err) + bitmapIDs := GetRange(start, end, bitmapID) + if len(bitmapIDs) == 0 { + return NewBitmap() } -} -func (f *Fragment) Load() { - f.mu.Lock() - defer f.mu.Unlock() - f.impl.Load(f) -} - -// FragmentStats represents in-memory stats for a single fragment. -type FragmentStats struct { - // Messages processed by the fragment - ProcessN uint64 - ProcessTime time.Duration -} - -type Pilosa interface { - Get(id uint64) *Bitmap - SetBit(id uint64, bit_pos uint64, filter uint64) bool - ClearBit(id uint64, bit_pos uint64) bool - TopN(b *Bitmap, n int, categories []uint64) []Pair - TopNAll(n int, categories []uint64) []Pair - Clear() bool - Store(bitmapID uint64, bm *Bitmap, filter uint64) error - Stats() interface{} - Persist() error - Load(fragment *Fragment) - Exists(id uint64) bool + result := f.bitmap(bitmapIDs[0]) + for _, id := range bitmapIDs[1:] { + result = result.Union(f.bitmap(id)) + } + return result } diff --git a/fragment_container.go b/fragment_container.go deleted file mode 100644 index 6ad4d7f9f..000000000 --- a/fragment_container.go +++ /dev/null @@ -1,340 +0,0 @@ -package pilosa - -import ( - "bytes" - "compress/gzip" - "encoding/base64" - "encoding/gob" - "errors" - "fmt" - "io/ioutil" - "sync" - "syscall" - "time" - - log "github.com/cihub/seelog" - // "github.com/umbel/pilosa/statsd" -) - -// DefaultBackend is the default data storage layer. -const DefaultBackend = "cassandra" - -var Backend = DefaultBackend - -var LevelDBPath string - -var ( - ErrFragmentNotFound = errors.New("fragment not found") -) - -func init() { - gob.Register(BitmapHandle(0)) - gob.Register([]Pair{}) -} - -type FragmentContainer struct { - mu sync.Mutex - fragments map[SUUID]*Fragment -} - -func NewFragmentContainer() *FragmentContainer { - return &FragmentContainer{ - fragments: make(map[SUUID]*Fragment), - } -} - -type BitmapHandle uint64 - -type FillArgs struct { - FragmentID SUUID - Handle BitmapHandle - Bitmaps []uint64 -} - -func (fc *FragmentContainer) Fragment(fragmentID SUUID) (*Fragment, bool) { - fc.mu.Lock() - f, ok := fc.fragments[fragmentID] - fc.mu.Unlock() - return f, ok -} - -func (fc *FragmentContainer) Get(fragmentID SUUID, bitmapID uint64) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - return f.NewHandle(bitmapID), nil -} - -func (fc *FragmentContainer) LoadBitmap(fragmentID SUUID, bitmapID uint64, data string, filter uint64) error { - f, ok := fc.Fragment(fragmentID) - if !ok { - return ErrFragmentNotFound - } - - // Decode from base64 encoding. - buf, err := base64.StdEncoding.DecodeString(data) - if err != nil { - return err - } - - // Decompress data. - reader, err := gzip.NewReader(bytes.NewReader(buf)) - if err != nil { - return err - } - b, err := ioutil.ReadAll(reader) - if err != nil { - return err - } - - // Build bitmap from data. - bm := NewBitmap() - bm.FromBytes(b) - - // Write bitmap to the underlying store. - return f.impl.Store(bitmapID, bm, filter) -} - -func (fc *FragmentContainer) Stats(fragmentID SUUID) interface{} { - f, ok := fc.Fragment(fragmentID) - if !ok { - return nil - } - return f.impl.Stats() -} - -func (fc *FragmentContainer) Empty(fragmentID SUUID) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - return f.AllocHandle(NewBitmap()), nil -} - -func (fc *FragmentContainer) Intersect(fragmentID SUUID, bh []BitmapHandle) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - return f.Intersect(bh), nil -} - -func (fc *FragmentContainer) Union(fragmentID SUUID, bh []BitmapHandle) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - return f.Union(bh), nil -} - -func (fc *FragmentContainer) Difference(fragmentID SUUID, bh []BitmapHandle) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - return f.Difference(bh), nil -} - -func (fc *FragmentContainer) Mask(fragmentID SUUID, start, end uint64) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - - bm := NewBitmap() - for i := start; i < end; i++ { - bm.SetBit(i) - } - return f.AllocHandle(bm), nil -} - -func (fc *FragmentContainer) Range(fragmentID SUUID, bitmapID uint64, start, end time.Time) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - return f.build_time_range_bitmap(bitmapID, start, end), nil -} - -func (fc *FragmentContainer) TopN(fragmentID SUUID, bh BitmapHandle, n int, categories []uint64) ([]Pair, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return nil, ErrFragmentNotFound - } - return f.TopN(bh, n, categories), nil -} - -func (fc *FragmentContainer) TopNAll(fragmentID SUUID, n int, categories []uint64) ([]Pair, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return nil, ErrFragmentNotFound - } - return f.TopNAll(n, categories), nil -} - -func (fc *FragmentContainer) TopFillBatch(args []FillArgs) ([]Pair, error) { - results := make(map[uint64]uint64) - for _, v := range args { - items, _ := fc.TopFillFragment(v) - if len(args) == 1 { - return items, nil - } - for _, pair := range items { - results[pair.Key] += pair.Count - } - } - ret_val := make([]Pair, len(results)) - for k, v := range results { - if v > 0 { //don't include 0 size items - ret_val = append(ret_val, Pair{k, v}) - } - } - return ret_val, nil - -} -func (fc *FragmentContainer) TopFillFragment(args FillArgs) ([]Pair, error) { - f, ok := fc.Fragment(args.FragmentID) - if !ok { - return nil, ErrFragmentNotFound - } - - result := make([]Pair, 0) - for _, v := range args.Bitmaps { - if !f.exists(v) { - continue - } - - a := f.NewHandle(v) - if args.Handle == 0 { - // Return just the count - if bm, ok := f.Bitmap(a); ok && bm.Count() > 0 { - result = append(result, Pair{v, bm.Count()}) - } - continue - } - - res := f.Intersect([]BitmapHandle{args.Handle, a}) - if bm, ok := f.Bitmap(res); ok { - bc := bm.BitCount() - if bc > 0 { - result = append(result, Pair{v, bc}) - } - } - } - return result, nil -} - -func (fc *FragmentContainer) GetList(fragmentID SUUID, bitmapIDs []uint64) ([]BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return nil, ErrFragmentNotFound - } - - a := make([]BitmapHandle, len(bitmapIDs)) - for i, v := range bitmapIDs { - a[i] = f.NewHandle(v) - } - return a, nil -} - -func (fc *FragmentContainer) Count(fragmentID SUUID, bh BitmapHandle) (uint64, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - - bm, ok := f.Bitmap(bh) - if ok == false { - return 0, nil - } - return bm.BitCount(), nil -} - -func (fc *FragmentContainer) GetBytes(fragmentID SUUID, bh BitmapHandle) ([]byte, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return nil, ErrFragmentNotFound - } - - bm, ok := f.Bitmap(bh) - if !ok { - bm = NewBitmap() - log.Warn("cache miss") - } - - var b bytes.Buffer - w := gzip.NewWriter(&b) - if _, err := w.Write(bm.ToBytes()); err != nil { - return nil, err - } - if err := w.Flush(); err != nil { - return nil, err - } - if err := w.Close(); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -func (fc *FragmentContainer) FromBytes(fragmentID SUUID, data []byte) (BitmapHandle, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return 0, ErrFragmentNotFound - } - - r, _ := gzip.NewReader(bytes.NewReader(data)) - b, _ := ioutil.ReadAll(r) - - bm := NewBitmap() - bm.FromBytes(b) - return f.AllocHandle(bm), nil -} - -func (fc *FragmentContainer) SetBit(fragmentID SUUID, bitmapID uint64, pos uint64, category uint64) (bool, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return false, ErrFragmentNotFound - } - return f.impl.SetBit(bitmapID, pos, category), nil -} - -func (fc *FragmentContainer) ClearBit(fragmentID SUUID, bitmapID uint64, pos uint64) (bool, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return false, ErrFragmentNotFound - } - return f.impl.ClearBit(bitmapID, pos), nil -} - -func (fc *FragmentContainer) Clear(fragmentID SUUID) (bool, error) { - f, ok := fc.Fragment(fragmentID) - if !ok { - return false, ErrFragmentNotFound - } - return f.impl.Clear(), nil -} - -func (fc *FragmentContainer) AddFragment(db string, frame string, slice int, id SUUID) { - fc.mu.Lock() - defer fc.mu.Unlock() - - _, ok := fc.fragments[id] - if ok { - return - } - - log.Warn("ADD FRAGMENT", frame, db, slice, id.String()) - f := NewFragment(id, db, slice, frame) - fc.fragments[id] = f - // go f.Load(loader) -} - -func dumpHandlesToLog() { - var limit syscall.Rlimit - if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { - log.Warn("Getrlimit:" + err.Error()) - } - mesg := fmt.Sprintf("%v file descriptors out of a maximum of %v available\n", limit.Cur, limit.Max) - log.Warn(mesg) -} diff --git a/fragment_container_test.go b/fragment_container_test.go deleted file mode 100644 index 20d0331d3..000000000 --- a/fragment_container_test.go +++ /dev/null @@ -1,308 +0,0 @@ -package pilosa_test - -import ( - "testing" - - "github.com/umbel/pilosa" - _ "github.com/umbel/pilosa/storage" -) - -func init() { - pilosa.Backend = "memory" -} - -// Ensure a fragment can be retrieved from the container. -func TestFragmentContainer_Get(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustClear(1) - - if bh, err := fc.Get(pilosa.SUUID(1), 1234); err != nil { - t.Fatal(err) - } else if bh == 0 { - t.Fatal("expected non-zero bitmap handle") - } -} - -// Ensure a bit can be set on a bitmap. -func TestFragmentContainer_SetBit(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustClear(1) - - // Set a bit on the bitmap. - if changed, err := fc.SetBit(1, uint64(1234), 1, 0); err != nil { - t.Fatal(err) - } else if changed == false { - t.Fatal("expected change") - } - - // Set the same bit on the bitmap. No change should be indicated. - if changed, err := fc.SetBit(1, uint64(1234), 1, 0); err != nil { - t.Fatal(err) - } else if changed == true { - t.Fatal("expected no change") - } -} - -// Ensure the number of bits on a bitmap can be counted. -func TestFragmentContainer_Count(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, pilosa.SUUID(1)) - - // Set a bit on the bitmap. - bi1 := uint64(1234) - if changed, err := fc.SetBit(pilosa.SUUID(1), bi1, 1, 0); err != nil { - t.Fatal(err) - } else if changed == false { - t.Fatal("expected change") - } - - // Verify that one bit is set. - if bh, err := fc.Get(pilosa.SUUID(1), bi1); err != nil { - t.Fatal(err) - } else if n, err := fc.Count(pilosa.SUUID(1), bh); err != nil { - t.Fatal(err) - } else if n != 1 { - t.Fatalf("unexpected count: %d", n) - } -} - -// Ensure the bits in two bitmaps can be unioned. -func TestFragmentContainer_Union(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustSetBit(1, 1234, 1, 0) - fc.MustSetBit(1, 4321, 65537, 0) - - // Union the handles together. - if result, err := fc.Union(1, []pilosa.BitmapHandle{fc.MustGet(1, 1234), fc.MustGet(1, 4321)}); err != nil { - t.Fatal(err) - } else if n := fc.MustCount(1, result); n != 2 { - t.Fatalf("unexpected union bit count: %d", n) - } -} - -// Ensure unioning a bitmap with an empty bitmap returns a single bit count. -func TestFragmentContainer_Union_Empty(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustSetBit(1, 1234, 1, 0) - - // Union the handles together. - if result, err := fc.Union(1, []pilosa.BitmapHandle{fc.MustGet(1, 1234), fc.MustGet(1, 4321)}); err != nil { - t.Fatal(err) - } else if n := fc.MustCount(1, result); n != 1 { - t.Fatalf("unexpected empty union bit count: %d", n) - } -} - -// Ensure the bits in two bitmaps can be intersected. -func TestFragmentContainer_Intersect(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustSetBit(1, 1234, 1, 0) - fc.MustSetBit(1, 4321, 65537, 0) - - // Intersect the handles together. - if result, err := fc.Intersect(1, []pilosa.BitmapHandle{fc.MustGet(1, 1234), fc.MustGet(1, 4321)}); err != nil { - t.Fatal(err) - } else if n := fc.MustCount(1, result); n != 0 { - t.Fatalf("unexpected intersect bit count: %d", n) - } -} - -// Ensure the bits in two bitmaps can be diffed. -func TestFragmentContainer_Difference(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustSetBit(1, 1234, 1, 0) - fc.MustSetBit(1, 4321, 65537, 0) - - // Compute the difference between the handles. - if result, err := fc.Difference(1, []pilosa.BitmapHandle{fc.MustGet(1, 1234), fc.MustGet(1, 4321)}); err != nil { - t.Fatal(err) - } else if n := fc.MustCount(1, result); n != 1 { - t.Fatalf("unexpected difference bit count: %s", err) - } -} - -// Ensure bitmaps can be marshaled and unmarshaled to bytes. -func TestFragmentContainer_Bytes(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustSetBit(1, 1234, 1, 0) - - // Count bits and marshal to bytes. - beforeN := fc.MustCount(1, 1234) - buf, err := fc.GetBytes(1, 1234) - if err != nil { - t.Fatal(err) - } - - // Marshal bytes back to a bitmap and re-count. - bh2, err := fc.FromBytes(1, buf) - if err != nil { - t.Fatal(err) - } - afterN := fc.MustCount(1, bh2) - - // Ensure the original bit count matches the new bitmap's bit count. - if beforeN != afterN { - t.Fatalf("unexpected bit count: before=%d, after=%d", beforeN, afterN) - } -} - -// Ensure an empty bitmap can be returned. -func TestFragmentContainer_Empty(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - bh, err := fc.Empty(1) - if err != nil { - t.Fatal(err) - } else if n := fc.MustCount(1, bh); n != 0 { - t.Fatalf("unexpected bit count: %d", n) - } -} - -// Ensure a list of bitmap handles can be returned. -func TestFragmentContainer_GetList(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - fc.MustSetBit(1, 1234, 1, 0) - fc.MustSetBit(1, 4321, 65537, 0) - - a, err := fc.GetList(1, []uint64{1234, 4321, 789}) - if err != nil { - t.Fatal(err) - } - - // Compute the union to ensure they're the correct bitmaps. - if res, err := fc.Union(1, a); err != nil { - t.Fatal(err) - } else if n := fc.MustCount(1, res); n != 2 { - t.Fatalf("unexpected bit count: %d", n) - } -} - -// Ensure brand bitmaps can perform a small number of set bits. -func TestFragmentContainer_SetBit_Brand_Small(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "b.n", 0, 2) - for i := uint64(0); i < 1000; i++ { - fc.SetBit(2, 1029, i, 0) - } -} - -// Ensure the top n can be computed for a brand. -func TestFragmentContainer_TopN_Brand(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "b.n", 0, 2) - - // Set bits on the bitmap. - fc.MustSetBit(2, uint64(1), 1, 2) - fc.MustSetBit(2, uint64(1), 2, 2) - fc.MustSetBit(2, uint64(1), 3, 2) - fc.MustSetBit(2, uint64(2), 1, 2) - fc.MustSetBit(2, uint64(2), 2, 2) - fc.MustSetBit(2, uint64(3), 1, 2) - - // Retrieve the bitmap handle for bitmap 1. - bh := fc.MustGet(2, uint64(1)) - - // Compute the top-n. - if results, err := fc.TopN(2, bh, 4, []uint64{2}); err != nil { - t.Fatal(err) - } else if results[0].Key != 1 { - t.Fatalf("unexpected key: %d", results[0].Key) - } else if results[0].Count != 3 { - t.Fatalf("unexpected value: %d", results[0].Count) - } -} - -// Ensure a fragment can be cleared. -func TestFragmentContainer_Clear(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "general", 0, 1) - - // Compute the top-n. - if res, err := fc.Clear(1); err != nil { - t.Fatal(err) - } else if res != true { - t.Fatalf("unexpected result: %v", res) - } -} - -// Ensure a fragment can be marshaled and unmarshaled to and from bytes. -func TestFragmentContainer_FromBytes(t *testing.T) { - fc := NewFragmentContainer() - fc.AddFragment("25", "b.n", 0, 2) - - // Set bits for a bitmap. - for i := 0; i < 4096; i++ { - fc.MustSetBit(2, 1, uint64(i), 0) - } - - // Marshal to bytes. - buf, err := fc.GetBytes(2, fc.MustGet(2, 1)) - if err != nil { - t.Fatal(err) - } - - // Load a bitmap from compressed data. - bh, err := fc.FromBytes(2, buf) - if err != nil { - t.Fatal(err) - } - - // Load and count bits. - if n := fc.MustCount(2, bh); n != 4096 { - t.Fatalf("unexpected bit count: %d", n) - } -} - -// FragementContainer is a test wrapper for pilosa.FragmentContainer. -type FragmentContainer struct { - *pilosa.FragmentContainer -} - -// NewFragmentContainer returns a new instance of FragmentContainer. -func NewFragmentContainer() *FragmentContainer { - return &FragmentContainer{pilosa.NewFragmentContainer()} -} - -// MustGet retrieves a bitmap by id. Panic on error. -func (fc *FragmentContainer) MustGet(frag_id pilosa.SUUID, bitmap_id uint64) pilosa.BitmapHandle { - bh, err := fc.Get(frag_id, bitmap_id) - if err != nil { - panic(err) - } - return bh -} - -// MustSetBit sets a bit in a bitmap. Panic on error. -func (fc *FragmentContainer) MustSetBit(frag_id pilosa.SUUID, bitmap_id uint64, pos uint64, category uint64) bool { - changed, err := fc.SetBit(frag_id, bitmap_id, pos, category) - if err != nil { - panic(err) - } - return changed -} - -// MustClear clears a fragment. Panic on error. -func (fc *FragmentContainer) MustClear(fragmentID pilosa.SUUID) bool { - v, err := fc.Clear(fragmentID) - if err != nil { - panic(err) - } - return v -} - -// MustCount returns the number of set bits in a bitmap. Panic on error. -func (fc *FragmentContainer) MustCount(frag_id pilosa.SUUID, bitmap pilosa.BitmapHandle) uint64 { - v, err := fc.Count(frag_id, bitmap) - if err != nil { - panic(err) - } - return v -} diff --git a/fragment_test.go b/fragment_test.go new file mode 100644 index 000000000..e7d3e593d --- /dev/null +++ b/fragment_test.go @@ -0,0 +1,8 @@ +package pilosa_test + +import ( + "github.com/umbel/pilosa" +) + +// SliceWidth is a helper reference to use when testing. +const SliceWidth = pilosa.SliceWidth diff --git a/general.go b/general.go deleted file mode 100644 index 5c96d9672..000000000 --- a/general.go +++ /dev/null @@ -1,174 +0,0 @@ -package pilosa - -import ( - "encoding/json" - "fmt" - - log "github.com/cihub/seelog" - "github.com/golang/groupcache/lru" -) - -type General struct { - bitmap_cache *lru.Cache - keys map[uint64]interface{} - db string - frame string - slice int - storage Storage -} - -func NewGeneral(db string, frame string, slice int, s Storage) *General { - f := new(General) - f.storage = s - f.frame = frame - f.slice = slice - f.db = db - f.Clear() - f.keys = make(map[uint64]interface{}) - return f - -} -func (self *General) Clear() bool { - self.bitmap_cache = lru.New(50000) - self.bitmap_cache.OnEvicted = self.OnEvicted - return true -} - -func (self *General) Exists(bitmap_id uint64) bool { - _, ok := self.bitmap_cache.Get(bitmap_id) - return ok - -} -func (self *General) Get(bitmap_id uint64) *Bitmap { - bm, ok := self.bitmap_cache.Get(bitmap_id) - if ok && bm != nil { - return bm.(*Bitmap) - } - bm, _ = self.storage.Fetch(bitmap_id, self.db, self.frame, self.slice) - self.bitmap_cache.Add(bitmap_id, bm) - self.keys[bitmap_id] = 0 - return bm.(*Bitmap) -} -func (self *General) SetBit(bitmap_id uint64, bit_pos uint64, filter uint64) bool { - bm := self.Get(bitmap_id) - change, chunk, address := bm.SetBit(bit_pos) - if change { - val := chunk.Value[address.BlockIndex] - self.storage.StoreBit(bitmap_id, self.db, self.frame, self.slice, filter, address.ChunkKey, int32(address.BlockIndex), val, bm.Count()) - } - return change -} -func (self *General) TopN(b *Bitmap, n int, categories []uint64) []Pair { - var empty []Pair - - return empty -} -func (self *General) Store(bitmap_id uint64, bm *Bitmap, filter uint64) error { - if err := self.storage.Store(bitmap_id, self.db, self.frame, self.slice, filter, bm); err != nil { - return err - } - self.bitmap_cache.Add(bitmap_id, bm) - self.keys[bitmap_id] = 0 - return nil -} - -func (self *General) OnEvicted(key lru.Key, value interface{}) { - delete(self.keys, key.(uint64)) -} - -func (self *General) Stats() interface{} { - - stats := map[string]interface{}{ - "total size of cache in items": self.bitmap_cache.Len()} - return stats -} - -func (self *General) getFileName() string { - base := FragmentBase - if base == "" { - base = "." - } - return fmt.Sprintf("%s/%s.%s.%d", base, self.db, self.frame, self.slice) -} - -func (self *General) Persist() error { - log.Warn("General Persist") - w, err := createFile(self.getFileName()) - if err != nil { - log.Warn("Error saving:", err) - return err - } - defer w.Close() - defer self.storage.Close() - - results := make([]uint64, len(self.keys)) - i := 0 - for k, _ := range self.keys { // map[uint64]*Rank - results[i] = k - i += 1 - } - - encoder := json.NewEncoder(w) - return encoder.Encode(results) -} - -func (self *General) Load(f *Fragment) { - log.Warn("General Load") - r, err := openFile(self.getFileName()) - if err != nil { - log.Warn("NO General Init File:", self.getFileName()) - return - } - - dec := json.NewDecoder(r) - var keys []uint64 - - if err := dec.Decode(&keys); err != nil { - return - } - for _, k := range keys { - self.Get(k) - } -} - -func (self *General) TopNAll(n int, categories []uint64) []Pair { - results := make([]Pair, 0, 0) - - count := 0 - for k, _ := range self.keys { - - if count >= n { - break - } - bm := self.Get(k) - results = append(results, Pair{k, bm.Count()}) - count++ - } - return results -} - -func (self *General) ClearBit(bitmap_id uint64, bit_pos uint64) bool { - bm := self.Get_nocache(bitmap_id) - if bm.Count() == 0 { - return false - } - change, chunk, address := bm.ClearBit(bit_pos) - if change { - val := chunk.Value[address.BlockIndex] - if val == 0 { - self.storage.RemoveBit(bitmap_id, self.db, self.frame, self.slice, uint64(0), address.ChunkKey, int32(address.BlockIndex), bm.Count()) - } else { - self.storage.StoreBit(bitmap_id, self.db, self.frame, self.slice, uint64(0), address.ChunkKey, int32(address.BlockIndex), val, bm.Count()) - } - } - return change -} - -func (self *General) Get_nocache(bitmap_id uint64) *Bitmap { - bm, ok := self.bitmap_cache.Get(bitmap_id) - if ok && bm != nil { - return bm.(*Bitmap) - } - bm, _ = self.storage.Fetch(bitmap_id, self.db, self.frame, self.slice) - return bm.(*Bitmap) -} diff --git a/handler.go b/handler.go new file mode 100644 index 000000000..2d141f754 --- /dev/null +++ b/handler.go @@ -0,0 +1,261 @@ +package pilosa + +import ( + "encoding/json" + "errors" + "expvar" + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "os" + "strconv" + "strings" + + "github.com/gogo/protobuf/proto" + "github.com/umbel/pilosa/internal" + "github.com/umbel/pilosa/pql" +) + +// Handler represents an HTTP handler. +type Handler struct { + // The execution engine for running queries. + Executor interface { + Execute(db string, query *pql.Query, slices []uint64) (interface{}, error) + } + + // The version to report on the /version endpoint. + Version string + + // The writer for any logging. + LogOutput io.Writer +} + +// NewHandler returns a new instance of Handler with a default logger. +func NewHandler() *Handler { + return &Handler{ + Version: Version, + LogOutput: os.Stderr, + } +} + +// ServeHTTP handles an HTTP request. +func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/query": + h.handleQuery(w, r) + case "/version": + h.handleVersion(w, r) + + case "/debug/vars": + h.handleExpvar(w, r) + default: + http.NotFound(w, r) + } +} + +// handleQuery handles /query requests. +func (h *Handler) handleQuery(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case "POST": + h.handlePostQuery(w, r) + default: + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + } +} + +// handlePostQuery handles /query requests. +func (h *Handler) handlePostQuery(w http.ResponseWriter, r *http.Request) { + // Parse incoming request. + db, query, slices, err := h.readQueryRequest(r) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + h.writeQueryResponse(w, r, nil, err) + return + } + + // Parse query string. + q, err := pql.NewParser(strings.NewReader(query)).Parse() + if err != nil { + w.WriteHeader(http.StatusBadRequest) + h.writeQueryResponse(w, r, nil, err) + return + } + + // Execute the query. + res, e := h.Executor.Execute(db, q, slices) + + // Set appropriate status code, if there is an error. + if e != nil { + w.WriteHeader(http.StatusInternalServerError) + } + + // Write response back to client. + if err := h.writeQueryResponse(w, r, res, e); err != nil { + h.logger().Printf("write query response error: %s", err) + } +} + +// readQueryRequest parses an query parameters from r. +func (h *Handler) readQueryRequest(r *http.Request) (db, query string, slices []uint64, err error) { + switch r.Header.Get("Content-Type") { + case "application/x-protobuf": + return h.readProtobufQueryRequest(r) + default: + return h.readURLQueryRequest(r) + } +} + +// readProtobufQueryRequest parses query parameters in protobuf from r. +func (h *Handler) readProtobufQueryRequest(r *http.Request) (db, query string, slices []uint64, err error) { + // Slurp the body. + body, err := ioutil.ReadAll(r.Body) + if err != nil { + return + } + + // Unmarshal into object. + var req internal.QueryRequest + if err = proto.Unmarshal(body, &req); err != nil { + return + } + + return req.GetDB(), req.GetQuery(), req.GetSlices(), nil +} + +// readURLQueryRequest parses query parameters from URL parameters from r. +func (h *Handler) readURLQueryRequest(r *http.Request) (db, query string, slices []uint64, err error) { + q := r.URL.Query() + + // Read DB argument. + db = q.Get("db") + + // Parse query string. + buf, err := ioutil.ReadAll(r.Body) + if err != nil { + return + } + query = string(buf) + + // Parse list of slices. + slices, err = parseUint64Slice(q.Get("slices")) + if err != nil { + err = errors.New("invalid slice argument") + return + } + + return +} + +// writeQueryResponse writes the response from the executor to w. +func (h *Handler) writeQueryResponse(w http.ResponseWriter, r *http.Request, res interface{}, err error) error { + if strings.Contains(r.Header.Get("Accept"), "application/x-protobuf") { + return h.writeProtobufQueryResponse(w, res, err) + } + return h.writeJSONQueryResponse(w, res, err) +} + +// writeProtobufQueryResponse writes the response from the executor to w as protobuf. +func (h *Handler) writeProtobufQueryResponse(w http.ResponseWriter, res interface{}, e error) error { + var resp internal.QueryResponse + + // Set the result on the appropriate field. + if res != nil { + switch res := res.(type) { + case *Bitmap: + resp.Bitmap = encodeBitmap(res) + case Pairs: + resp.Pairs = encodePairs(res) + case uint64: + resp.N = proto.Uint64(res) + default: + panic(fmt.Sprintf("invalid query response type: %T", res)) + } + } + + // Set the error if there is one. + if e != nil { + resp.Err = proto.String(e.Error()) + } + + // Encode response. + buf, err := proto.Marshal(&resp) + if err != nil { + return err + } + + // Write response back to client. + if _, err := w.Write(buf); err != nil { + return err + } + + return nil +} + +// writeJSONQueryResponse writes the response from the executor to w as JSON. +func (h *Handler) writeJSONQueryResponse(w http.ResponseWriter, res interface{}, e error) error { + var o struct { + Result interface{} `json:"result,omitempty"` + Error string `json:"error,omitempty"` + } + o.Result = res + + if e != nil { + o.Error = e.Error() + } + + // Otherwise marshal the result as JSON. + return json.NewEncoder(w).Encode(o) +} + +// handleGetVersion handles /version requests. +func (h *Handler) handleVersion(w http.ResponseWriter, r *http.Request) { + if err := json.NewEncoder(w).Encode(struct { + Version string `json:"version"` + }{ + Version: h.Version, + }); err != nil { + h.logger().Printf("write version response error: %s", err) + } +} + +// handleExpvar handles /debug/vars requests. +func (h *Handler) handleExpvar(w http.ResponseWriter, r *http.Request) { + // Copied from $GOROOT/src/expvar/expvar.go + w.Header().Set("Content-Type", "application/json; charset=utf-8") + fmt.Fprintf(w, "{\n") + first := true + expvar.Do(func(kv expvar.KeyValue) { + if !first { + fmt.Fprintf(w, ",\n") + } + first = false + fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) + }) + fmt.Fprintf(w, "\n}\n") +} + +// logger returns a logger for the handler. +func (h *Handler) logger() *log.Logger { + return log.New(h.LogOutput, "", log.LstdFlags) +} + +// parseUint64Slice returns a slice of uint64s from a comma-delimited string. +func parseUint64Slice(s string) ([]uint64, error) { + var a []uint64 + for _, str := range strings.Split(s, ",") { + // Ignore blanks. + if str == "" { + continue + } + + // Parse number. + num, err := strconv.ParseUint(str, 10, 64) + if err != nil { + return nil, err + } + a = append(a, num) + } + return a, nil +} diff --git a/handler_test.go b/handler_test.go new file mode 100644 index 000000000..22e784f6d --- /dev/null +++ b/handler_test.go @@ -0,0 +1,373 @@ +package pilosa_test + +import ( + "bytes" + "errors" + "io" + "net/http" + "net/http/httptest" + "net/url" + "reflect" + "strings" + "testing" + + "github.com/gogo/protobuf/proto" + "github.com/umbel/pilosa" + "github.com/umbel/pilosa/internal" + "github.com/umbel/pilosa/pql" +) + +// Ensure the handler returns "not found" for invalid paths. +func TestHandler_NotFound(t *testing.T) { + w := httptest.NewRecorder() + NewHandler().ServeHTTP(w, MustNewHTTPRequest("GET", "/no_such_path", nil)) + if w.Code != http.StatusNotFound { + t.Fatalf("invalid status: %d", w.Code) + } +} + +// Ensure the handler can accept URL arguments. +func TestHandler_Query_Args_URL(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + if db != "db0" { + t.Fatalf("unexpected db: %s", db) + } else if query.String() != `count(get(id=100))` { + t.Fatalf("unexpected query: %s", query.String()) + } else if !reflect.DeepEqual(slices, []uint64{0, 1}) { + t.Fatalf("unexpected slices: %+v", slices) + } + return uint64(100), nil + } + + w := httptest.NewRecorder() + h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query?db=db0&slices=0,1", strings.NewReader("count( get( 100))"))) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"result":100}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can accept arguments via protobufs. +func TestHandler_Query_Args_Protobuf(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + if db != "db0" { + t.Fatalf("unexpected db: %s", db) + } else if query.String() != `count(get(id=100))` { + t.Fatalf("unexpected query: %s", query.String()) + } else if !reflect.DeepEqual(slices, []uint64{0, 1}) { + t.Fatalf("unexpected slices: %+v", slices) + } + return uint64(100), nil + } + + // Generate request body. + reqBody, err := proto.Marshal(&internal.QueryRequest{ + DB: proto.String("db0"), + Query: proto.String("count(get(100))"), + Slices: []uint64{0, 1}, + }) + if err != nil { + t.Fatal(err) + } + + // Generate protobuf request. + req := MustNewHTTPRequest("POST", "/query", bytes.NewReader(reqBody)) + req.Header.Set("Content-Type", "application/x-protobuf") + + w := httptest.NewRecorder() + h.ServeHTTP(w, req) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } +} + +// Ensure the handler returns an error when parsing bad arguments. +func TestHandler_Query_Args_Err(t *testing.T) { + w := httptest.NewRecorder() + NewHandler().ServeHTTP(w, MustNewHTTPRequest("POST", "/query?db=db0&slices=a,b", strings.NewReader("get(100)"))) + if w.Code != http.StatusBadRequest { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"error":"invalid slice argument"}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can execute a query with a uint64 response as JSON. +func TestHandler_Query_Uint64_JSON(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return uint64(100), nil + } + + w := httptest.NewRecorder() + h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query?db=db0&slices=0,1", strings.NewReader("count( get( 100))"))) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"result":100}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can execute a query with a uint64 response as protobufs. +func TestHandler_Query_Uint64_Protobuf(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return uint64(100), nil + } + + w := httptest.NewRecorder() + r := MustNewHTTPRequest("POST", "/query", strings.NewReader("count(get(100))")) + r.Header.Set("Accept", "application/x-protobuf") + h.ServeHTTP(w, r) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } + + var resp internal.QueryResponse + if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { + t.Fatal(err) + } else if resp.GetN() != 100 { + t.Fatalf("unexpected n: %d", resp.GetN()) + } +} + +// Ensure the handler can execute a query that returns a bitmap as JSON. +func TestHandler_Query_Bitmap_JSON(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + bm := pilosa.NewBitmap() + bm.SetBit(1) + bm.SetBit(3) + bm.SetBit(66) + bm.SetBit(pilosa.SliceWidth + 1) + return bm, nil + } + + w := httptest.NewRecorder() + h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query", strings.NewReader("get(100)"))) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"result":{"chunks":[{"Key":0,"Value":[10,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},{"Key":32,"Value":[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}]}}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can execute a query that returns a bitmap as protobuf. +func TestHandler_Query_Bitmap_Protobuf(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + bm := pilosa.NewBitmap() + bm.SetBit(1) + bm.SetBit(pilosa.SliceWidth + 1) + return bm, nil + } + + w := httptest.NewRecorder() + r := MustNewHTTPRequest("POST", "/query", strings.NewReader("get(100)")) + r.Header.Set("Accept", "application/x-protobuf") + h.ServeHTTP(w, r) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } + + var resp internal.QueryResponse + if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { + t.Fatal(err) + } else if a := resp.GetBitmap().GetChunks(); len(a) != 2 { + t.Fatalf("unexpected bitmap chunk length: %d", len(a)) + } +} + +// Ensure the handler can execute a query that returns pairs as JSON. +func TestHandler_Query_Pairs_JSON(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return pilosa.Pairs{ + {Key: 1, Count: 2}, + {Key: 3, Count: 4}, + }, nil + } + + w := httptest.NewRecorder() + h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query", strings.NewReader(`top-n(frame=x, n=2)`))) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"result":[{"key":1,"count":2},{"key":3,"count":4}]}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can execute a query that returns pairs as protobuf. +func TestHandler_Query_Pairs_Protobuf(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return pilosa.Pairs{ + {Key: 1, Count: 2}, + {Key: 3, Count: 4}, + }, nil + } + + w := httptest.NewRecorder() + r := MustNewHTTPRequest("POST", "/query", strings.NewReader(`top-n(frame=x, n=2)`)) + r.Header.Set("Accept", "application/x-protobuf") + h.ServeHTTP(w, r) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } + + var resp internal.QueryResponse + if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { + t.Fatal(err) + } else if a := resp.GetPairs(); len(a) != 2 { + t.Fatalf("unexpected pair length: %d", len(a)) + } +} + +// Ensure the handler can return an error as JSON. +func TestHandler_Query_Err_JSON(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return nil, errors.New("marker") + } + + w := httptest.NewRecorder() + h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query", strings.NewReader(`get(100)`))) + if w.Code != http.StatusInternalServerError { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"error":"marker"}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can return an error as protobuf. +func TestHandler_Query_Err_Protobuf(t *testing.T) { + h := NewHandler() + h.Executor.ExecuteFn = func(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return nil, errors.New("marker") + } + + w := httptest.NewRecorder() + r := MustNewHTTPRequest("POST", "/query", strings.NewReader(`top-n(frame=x, n=2)`)) + r.Header.Set("Accept", "application/x-protobuf") + h.ServeHTTP(w, r) + if w.Code != http.StatusInternalServerError { + t.Fatalf("unexpected status code: %d", w.Code) + } + + var resp internal.QueryResponse + if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil { + t.Fatal(err) + } else if s := resp.GetErr(); s != `marker` { + t.Fatalf("unexpected error: %s", s) + } +} + +// Ensure the handler returns "method not allowed" for non-POST queries. +func TestHandler_Query_MethodNotAllowed(t *testing.T) { + w := httptest.NewRecorder() + NewHandler().ServeHTTP(w, MustNewHTTPRequest("GET", "/query", nil)) + if w.Code != http.StatusMethodNotAllowed { + t.Fatalf("invalid status: %d", w.Code) + } +} + +// Ensure the handler returns an error if there is a parsing error.. +func TestHandler_Query_ErrParse(t *testing.T) { + h := NewHandler() + w := httptest.NewRecorder() + h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query?db=db0&slices=0,1", strings.NewReader("bad_fn("))) + if w.Code != http.StatusBadRequest { + t.Fatalf("unexpected status code: %d", w.Code) + } else if body := w.Body.String(); body != `{"error":"function not found: bad_fn occurred at line 1, char 1"}`+"\n" { + t.Fatalf("unexpected body: %q", body) + } +} + +// Ensure the handler can retrieve the version. +func TestHandler_Version(t *testing.T) { + h := NewHandler() + h.Version = "1.0.0" + + w := httptest.NewRecorder() + r := MustNewHTTPRequest("GET", "/version", nil) + h.ServeHTTP(w, r) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } else if w.Body.String() != `{"version":"1.0.0"}`+"\n" { + t.Fatalf("unexpected body: %q", w.Body.String()) + } +} + +// Ensure the handler can return expvars without panicking. +func TestHandler_Expvars(t *testing.T) { + h := NewHandler() + w := httptest.NewRecorder() + r := MustNewHTTPRequest("GET", "/debug/vars", nil) + h.ServeHTTP(w, r) + if w.Code != http.StatusOK { + t.Fatalf("unexpected status code: %d", w.Code) + } +} + +// Handler represents a test wrapper for pilosa.Handler. +type Handler struct { + *pilosa.Handler + Executor HandlerExecutor +} + +// NewHandler returns a new instance of Handler. +func NewHandler() *Handler { + h := &Handler{ + Handler: pilosa.NewHandler(), + } + h.Handler.Executor = &h.Executor + return h +} + +// HandlerExecutor is a mock implementing pilosa.Handler.Executor. +type HandlerExecutor struct { + cluster *pilosa.Cluster + ExecuteFn func(db string, query *pql.Query, slices []uint64) (interface{}, error) +} + +func (c *HandlerExecutor) Cluster() *pilosa.Cluster { return c.cluster } + +func (c *HandlerExecutor) Execute(db string, query *pql.Query, slices []uint64) (interface{}, error) { + return c.ExecuteFn(db, query, slices) +} + +// Server represents a test wrapper for httptest.Server. +type Server struct { + *httptest.Server + Handler *Handler +} + +// NewServer returns a test server running on a random port. +func NewServer() *Server { + s := &Server{ + Handler: NewHandler(), + } + s.Server = httptest.NewServer(s.Handler.Handler) + return s +} + +// Host returns the hostname of the running server. +func (s *Server) Host() string { + u, err := url.Parse(s.URL) + if err != nil { + panic(err) + } + return u.Host +} + +// MustNewHTTPRequest creates a new HTTP request. Panic on error. +func MustNewHTTPRequest(method, urlStr string, body io.Reader) *http.Request { + req, err := http.NewRequest(method, urlStr, body) + if err != nil { + panic(err) + } + return req +} diff --git a/hold/hold.go b/hold/hold.go deleted file mode 100644 index d05d81ac9..000000000 --- a/hold/hold.go +++ /dev/null @@ -1,88 +0,0 @@ -package hold - -import ( - "errors" - "time" - - log "github.com/cihub/seelog" - "github.com/umbel/pilosa" -) - -type holdchan chan interface{} -type gethold struct { - id *pilosa.GUID - reply chan holdchan -} -type delhold struct { - id *pilosa.GUID -} - -type Holder struct { - data map[pilosa.GUID]holdchan - getchan chan gethold - delchan chan delhold -} - -func NewHolder() *Holder { - return &Holder{ - data: make(map[pilosa.GUID]holdchan), - getchan: make(chan gethold), - delchan: make(chan delhold), - } -} - -func (self *Holder) DelChan(id *pilosa.GUID) { - log.Trace("Holder.DelChan", id) - req := delhold{id} - self.delchan <- req -} - -func (self *Holder) GetChan(id *pilosa.GUID) holdchan { - log.Trace("Holder.GetChan", id) - reply := make(chan holdchan) - req := gethold{id, reply} - self.getchan <- req - return <-reply -} - -func (self *Holder) Get(id *pilosa.GUID, timeout time.Duration) (interface{}, error) { - log.Trace("Holder.Get", id, timeout.String()) - ch := self.GetChan(id) - select { - case val := <-ch: - return val, nil - case <-time.After(timeout): - self.DelChan(id) - return nil, errors.New("Timeout getting from holder") - } -} - -func (self *Holder) Set(id *pilosa.GUID, value interface{}, timeout time.Duration) { - log.Trace("Holder.Set", id, value, timeout.String()) - ch := self.GetChan(id) - go func() { - select { - case ch <- value: - case <-time.After(timeout): - } - self.DelChan(id) - }() -} - -func (self *Holder) Run() { - var greq gethold - var dreq delhold - for { - select { - case greq = <-self.getchan: - item, ok := self.data[*greq.id] - if !ok { - item = make(holdchan) - self.data[*greq.id] = item - } - greq.reply <- item - case dreq = <-self.delchan: - delete(self.data, *dreq.id) - } - } -} diff --git a/hold/hold_test.go b/hold/hold_test.go deleted file mode 100644 index 8ef3a1bd5..000000000 --- a/hold/hold_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package hold_test - -import ( - "testing" - "time" - - "github.com/umbel/pilosa/hold" - "github.com/umbel/pilosa/util" -) - -// Ensure hold can get a value that has been set. -func TestHold_Get(t *testing.T) { - h := hold.NewHolder() - go h.Run() - - id := util.RandomUUID() - h.Set(&id, "derp", 10) - if v, err := h.Get(&id, 10); err != nil { - t.Fatal(err) - } else if v != "derp" { - t.Fatalf("unexpected value: %v", v) - } -} - -// Ensure hold can wait for a value that has not been set yet. -func TestHold_Get_Delay(t *testing.T) { - h := hold.NewHolder() - go h.Run() - - id := util.RandomUUID() - go func() { - time.Sleep(500 * time.Millisecond) - h.Set(&id, "derpsy", 10) - }() - - if v, err := h.Get(&id, 10); err != nil { - t.Fatal(err) - } else if v != "derpsy" { - t.Fatalf("unexpected value: %v", v) - } -} diff --git a/index.go b/index.go new file mode 100644 index 000000000..8ee0906f4 --- /dev/null +++ b/index.go @@ -0,0 +1,53 @@ +package pilosa + +import ( + "sync" +) + +// Index represents a container for fragments. +type Index struct { + mu sync.Mutex + sliceN uint64 + fragments map[fragmentKey]*Fragment +} + +// NewIndex returns a new instance of Index. +func NewIndex() *Index { + return &Index{ + fragments: make(map[fragmentKey]*Fragment), + } +} + +// SliceN returs the total number of slices managed by the index. +func (i *Index) SliceN() uint64 { + i.mu.Lock() + defer i.mu.Unlock() + return i.sliceN +} + +// Fragment returns the fragment for a database, frame & slice. +// The fragment is created if it doesn't already exist. +func (i *Index) Fragment(db, frame string, slice uint64) *Fragment { + i.mu.Lock() + defer i.mu.Unlock() + + // Track the highest slice. + if slice > i.sliceN { + i.sliceN = slice + } + + // Create fragment, if not exists. + key := fragmentKey{db, frame, slice} + if i.fragments[key] == nil { + i.fragments[key] = NewFragment(db, frame, slice) + } + + return i.fragments[key] +} + +// fragmentKey is the map key for fragment look ups. +type fragmentKey struct { + db string + frame string + slice uint64 +} diff --git a/internal/internal.go b/internal/internal.go new file mode 100644 index 000000000..574c0ee5c --- /dev/null +++ b/internal/internal.go @@ -0,0 +1,56 @@ +package internal + +import ( + "io" + "io/ioutil" + + "github.com/gogo/protobuf/proto" +) + +type Request proto.Message + +type Response proto.Message + +// Encoder encodes messages to a writer. +type Encoder struct { + w io.Writer +} + +// NewEncoder returns a new instance of Encoder. +func NewEncoder(w io.Writer) *Encoder { + return &Encoder{w: w} +} + +// Encode marshals m into bytes and writes them to r. +func (enc *Encoder) Encode(pb proto.Message) error { + buf, err := proto.Marshal(pb) + if err != nil { + return err + } + + if _, err := enc.w.Write(buf); err != nil { + return err + } + + return nil +} + +// Decoder decodes messages from a reader. +type Decoder struct { + r io.Reader +} + +// NewDecoder returns a new instance of Decoder. +func NewDecoder(r io.Reader) *Decoder { + return &Decoder{r: r} +} + +// Decode reads all bytes from the reader and unmarshals them into pb. +func (dec *Decoder) Decode(pb proto.Message) error { + buf, err := ioutil.ReadAll(dec.r) + if err != nil { + return err + } + + return proto.Unmarshal(buf, pb) +} diff --git a/internal/internal.pb.go b/internal/internal.pb.go new file mode 100644 index 000000000..bdb18ac33 --- /dev/null +++ b/internal/internal.pb.go @@ -0,0 +1,164 @@ +// Code generated by protoc-gen-gogo. +// source: internal/internal.proto +// DO NOT EDIT! + +/* +Package internal is a generated protocol buffer package. + +It is generated from these files: + internal/internal.proto + +It has these top-level messages: + Bitmap + Chunk + Pair + QueryRequest + QueryResponse +*/ +package internal + +import proto "github.com/gogo/protobuf/proto" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = math.Inf + +type Bitmap struct { + Chunks []*Chunk `protobuf:"bytes,1,rep" json:"Chunks,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Bitmap) Reset() { *m = Bitmap{} } +func (m *Bitmap) String() string { return proto.CompactTextString(m) } +func (*Bitmap) ProtoMessage() {} + +func (m *Bitmap) GetChunks() []*Chunk { + if m != nil { + return m.Chunks + } + return nil +} + +type Chunk struct { + Key *uint64 `protobuf:"varint,1,req" json:"Key,omitempty"` + Value []uint64 `protobuf:"varint,2,rep" json:"Value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Chunk) Reset() { *m = Chunk{} } +func (m *Chunk) String() string { return proto.CompactTextString(m) } +func (*Chunk) ProtoMessage() {} + +func (m *Chunk) GetKey() uint64 { + if m != nil && m.Key != nil { + return *m.Key + } + return 0 +} + +func (m *Chunk) GetValue() []uint64 { + if m != nil { + return m.Value + } + return nil +} + +type Pair struct { + Key *uint64 `protobuf:"varint,1,req" json:"Key,omitempty"` + Count *uint64 `protobuf:"varint,2,req" json:"Count,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Pair) Reset() { *m = Pair{} } +func (m *Pair) String() string { return proto.CompactTextString(m) } +func (*Pair) ProtoMessage() {} + +func (m *Pair) GetKey() uint64 { + if m != nil && m.Key != nil { + return *m.Key + } + return 0 +} + +func (m *Pair) GetCount() uint64 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +type QueryRequest struct { + DB *string `protobuf:"bytes,1,req" json:"DB,omitempty"` + Query *string `protobuf:"bytes,2,req" json:"Query,omitempty"` + Slices []uint64 `protobuf:"varint,3,rep" json:"Slices,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} + +func (m *QueryRequest) GetDB() string { + if m != nil && m.DB != nil { + return *m.DB + } + return "" +} + +func (m *QueryRequest) GetQuery() string { + if m != nil && m.Query != nil { + return *m.Query + } + return "" +} + +func (m *QueryRequest) GetSlices() []uint64 { + if m != nil { + return m.Slices + } + return nil +} + +type QueryResponse struct { + Err *string `protobuf:"bytes,1,opt" json:"Err,omitempty"` + Bitmap *Bitmap `protobuf:"bytes,2,opt" json:"Bitmap,omitempty"` + N *uint64 `protobuf:"varint,3,opt" json:"N,omitempty"` + Pairs []*Pair `protobuf:"bytes,4,rep" json:"Pairs,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} + +func (m *QueryResponse) GetErr() string { + if m != nil && m.Err != nil { + return *m.Err + } + return "" +} + +func (m *QueryResponse) GetBitmap() *Bitmap { + if m != nil { + return m.Bitmap + } + return nil +} + +func (m *QueryResponse) GetN() uint64 { + if m != nil && m.N != nil { + return *m.N + } + return 0 +} + +func (m *QueryResponse) GetPairs() []*Pair { + if m != nil { + return m.Pairs + } + return nil +} + +func init() { +} diff --git a/internal/internal.proto b/internal/internal.proto new file mode 100644 index 000000000..9630bc798 --- /dev/null +++ b/internal/internal.proto @@ -0,0 +1,28 @@ +package internal; + +message Bitmap { + repeated Chunk Chunks = 1; +} + +message Chunk { + required uint64 Key = 1; + repeated uint64 Value = 2; +} + +message Pair { + required uint64 Key = 1; + required uint64 Count = 2; +} + +message QueryRequest { + required string DB = 1; + required string Query = 2; + repeated uint64 Slices = 3; +} + +message QueryResponse { + optional string Err = 1; + optional Bitmap Bitmap = 2; + optional uint64 N = 3; + repeated Pair Pairs = 4; +} diff --git a/pilosa.go b/pilosa.go index a480b3946..19c291ffd 100644 --- a/pilosa.go +++ b/pilosa.go @@ -1,122 +1,6 @@ package pilosa -import ( - "encoding/binary" - "encoding/hex" - "fmt" - "math/rand" - "strings" - "time" +//go:generate protoc --gogo_out=. internal/internal.proto - "github.com/gocql/gocql" -) - -var counter = uint64(0) - -func init() { - rand.Seed(time.Now().UTC().UnixNano()) -} - -// SUUID represents a sequential UUID. -type SUUID uint64 - -// SUUID returns a new SUUID. -func NewSUUID() SUUID { - millis := uint64(time.Now().UTC().UnixNano()) - id := millis << (64 - 41) - id |= uint64(rand.Intn(128)) << (64 - 41 - 13) - id |= counter % 1024 - counter += 1 - return SUUID(id) -} - -// String returns a string representation of id. -func (id SUUID) String() string { - var buf [8]byte - binary.BigEndian.PutUint64(buf[:], uint64(id)) - return hex.EncodeToString(buf[:]) -} - -// ParseSUUID parses s into an SUUID. -func ParseSUUID(s string) SUUID { - if n := len(s); n < 16 { - s = strings.Repeat("0", 16-n) + s - } - - b, _ := hex.DecodeString(s) - return SUUID(binary.BigEndian.Uint64(b)) -} - -// GUID represents a globally unique identifier. -type GUID [16]byte - -// UnmarshalText parses a text value into a GUID. -// This is used by the TOML parser. -func (id *GUID) UnmarshalText(text []byte) error { - v, err := ParseGUID(string(text)) - if err != nil { - return err - } - - *id = v - return nil -} - -func (id GUID) String() string { - var offsets = [...]int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34} - const hexString = "0123456789abcdef" - r := make([]byte, 36) - for i, b := range id { - r[offsets[i]] = hexString[b>>4] - r[offsets[i]+1] = hexString[b&0xF] - } - r[8] = '-' - r[13] = '-' - r[18] = '-' - r[23] = '-' - return string(r) - -} - -// Equals returns true if id equals other. -func (id *GUID) Equals(other *GUID) bool { - for i, v := range id { - if v != other[i] { - return false - } - } - return true -} - -// NewGUID returns a random GUID. -func NewGUID() GUID { - uid, _ := gocql.RandomUUID() - var id GUID - copy(id[:], uid[:]) - return id -} - -// ParseGUID parses s into a GUID. -func ParseGUID(s string) (GUID, error) { - var u GUID - j := 0 - for _, r := range s { - switch { - case r == '-' && j&1 == 0: - continue - case r >= '0' && r <= '9' && j < 32: - u[j/2] |= byte(r-'0') << uint(4-j&1*4) - case r >= 'a' && r <= 'f' && j < 32: - u[j/2] |= byte(r-'a'+10) << uint(4-j&1*4) - case r >= 'A' && r <= 'F' && j < 32: - u[j/2] |= byte(r-'A'+10) << uint(4-j&1*4) - default: - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - j += 1 - } - if j != 32 { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - return u, nil -} +// Version represents the current running version of Pilosa. +var Version string diff --git a/pilosa_test.go b/pilosa_test.go deleted file mode 100644 index f1cb30bde..000000000 --- a/pilosa_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package pilosa_test - -import ( - "fmt" - "testing" - - "github.com/umbel/pilosa" -) - -// Ensure id can be parsed from string. -func TestSUUID_Small(t *testing.T) { - if v := pilosa.ParseSUUID("1"); v != 1 { - t.Fatalf("unexpected SUUID: %v", v) - } -} - -// Ensure generated IDs are unique. -func TestSUUID_Unique(t *testing.T) { - a, b := pilosa.NewSUUID(), pilosa.NewSUUID() - if a == b { - t.Fatalf("ids should be unique: %v != %v", a, b) - } -} - -// Ensure ids can be converted to and from hex. -func TestSUUID_Hex(t *testing.T) { - a := pilosa.NewSUUID() - b := pilosa.ParseSUUID(a.String()) - if a != b { - t.Fatalf("ids not equal: %v != %v", a, b) - } -} - -// Ensure ids can be generated in sequence. -func TestSUUID_Multiple(t *testing.T) { - for i := 0; i < 10; i++ { - println(pilosa.NewSUUID().String()) - } -} - -// Ensure a random GUID can be converted to a string. -func TestGUID_String(t *testing.T) { - fmt.Println(pilosa.NewGUID().String()) -} - -func BenchmarkSUUID(b *testing.B) { - // run the Fib function b.N times - for n := 0; n < b.N; n++ { - pilosa.NewSUUID() - } -} diff --git a/popcnt_generic.go b/popcnt_generic.go index 72cdbb46a..b9665ac0a 100644 --- a/popcnt_generic.go +++ b/popcnt_generic.go @@ -2,22 +2,8 @@ package pilosa -func popcntSlice(s []uint64) uint64 { - return popcntSliceGo(s) -} - -func popcntMaskSlice(s, m []uint64) uint64 { - return popcntMaskSliceGo(s, m) -} - -func popcntAndSlice(s, m []uint64) uint64 { - return popcntAndSliceGo(s, m) -} - -func popcntOrSlice(s, m []uint64) uint64 { - return popcntOrSliceGo(s, m) -} - -func popcntXorSlice(s, m []uint64) uint64 { - return popcntXorSliceGo(s, m) -} +func popcntSlice(s []uint64) uint64 { return popcntSliceGo(s) } +func popcntMaskSlice(s, m []uint64) uint64 { return popcntMaskSliceGo(s, m) } +func popcntAndSlice(s, m []uint64) uint64 { return popcntAndSliceGo(s, m) } +func popcntOrSlice(s, m []uint64) uint64 { return popcntOrSliceGo(s, m) } +func popcntXorSlice(s, m []uint64) uint64 { return popcntXorSliceGo(s, m) } diff --git a/pql/ast.go b/pql/ast.go new file mode 100644 index 000000000..11a53aae8 --- /dev/null +++ b/pql/ast.go @@ -0,0 +1,228 @@ +package pql + +import ( + "fmt" + "strings" + "time" +) + +// Query represents a PQL query. +type Query struct { + Root Call +} + +// String returns a string representation of the query. +func (q *Query) String() string { return q.Root.String() } + +// Node represents any node in the AST. +type Node interface { + node() + String() string +} + +func (*Clear) node() {} +func (*Count) node() {} +func (*Difference) node() {} +func (*Get) node() {} +func (*Intersect) node() {} +func (*Range) node() {} +func (*Set) node() {} +func (*TopN) node() {} +func (*Union) node() {} + +// Call represents a function call in the AST. +type Call interface { + Node + call() +} + +func (*Clear) call() {} +func (*Count) call() {} +func (*Difference) call() {} +func (*Get) call() {} +func (*Intersect) call() {} +func (*Range) call() {} +func (*Set) call() {} +func (*TopN) call() {} +func (*Union) call() {} + +// Calls represents a list of calls. +type Calls []Call + +// String returns a string representation of the calls as a comma-delimited list. +func (a Calls) String() string { + args := make([]string, len(a)) + for i, c := range a { + args[i] = c.String() + } + return strings.Join(args, ", ") +} + +// BitmapCall represents a function call that returns a bitmap. +type BitmapCall interface { + Call + bitmapCall() +} + +// BitmapCalls represents a list of bitmap calls. +type BitmapCalls []BitmapCall + +// String returns a string representation of the calls as a comma-delimited list. +func (a BitmapCalls) String() string { + args := make([]string, len(a)) + for i, c := range a { + args[i] = c.String() + } + return strings.Join(args, ", ") +} + +func (*Difference) bitmapCall() {} +func (*Get) bitmapCall() {} +func (*Intersect) bitmapCall() {} +func (*Range) bitmapCall() {} +func (*Union) bitmapCall() {} + +// Clear represents a clear() function call. +type Clear struct { + ID uint64 + Frame string + Filter uint64 + ProfileID uint64 +} + +// String returns the string representation of the call. +func (c *Clear) String() string { + args := make([]string, 0, 4) + if c.ID != 0 { + args = append(args, fmt.Sprintf("id=%d", c.ID)) + } + if c.Frame != "" { + args = append(args, fmt.Sprintf("frame=%s", c.Frame)) + } + if c.Filter != 0 { + args = append(args, fmt.Sprintf("filter=%d", c.Filter)) + } + if c.ProfileID != 0 { + args = append(args, fmt.Sprintf("profile_id=%d", c.ProfileID)) + } + return fmt.Sprintf("clear(%s)", strings.Join(args, ", ")) +} + +// Count represents a count() function call. +type Count struct { + Input BitmapCall +} + +// String returns the string representation of the call. +func (c *Count) String() string { + return fmt.Sprintf("count(%s)", c.Input.String()) +} + +// Difference represents an difference() function call. +type Difference struct { + Inputs BitmapCalls +} + +// String returns the string representation of the call. +func (c *Difference) String() string { + return fmt.Sprintf("difference(%s)", c.Inputs.String()) +} + +// Get represents a get() function call. +type Get struct { + ID uint64 + Frame string +} + +// String returns the string representation of the call. +func (c *Get) String() string { + args := make([]string, 0, 2) + if c.ID != 0 { + args = append(args, fmt.Sprintf("id=%d", c.ID)) + } + if c.Frame != "" { + args = append(args, fmt.Sprintf("frame=%s", c.Frame)) + } + return fmt.Sprintf("get(%s)", strings.Join(args, ", ")) +} + +// Intersect represents an intersect() function call. +type Intersect struct { + Inputs BitmapCalls +} + +// String returns the string representation of the call. +func (c *Intersect) String() string { + return fmt.Sprintf("intersect(%s)", c.Inputs.String()) +} + +// Range represents a range() function call. +type Range struct { + ID uint64 + Frame string + StartTime time.Time + EndTime time.Time +} + +// String returns the string representation of the call. +func (c *Range) String() string { + args := make([]string, 0, 2) + if c.ID != 0 { + args = append(args, fmt.Sprintf("id=%d", c.ID)) + } + if c.Frame != "" { + args = append(args, fmt.Sprintf("frame=%s", c.Frame)) + } + if !c.StartTime.IsZero() { + args = append(args, fmt.Sprintf("start=%s", c.StartTime.Format(TimeFormat))) + } + if !c.EndTime.IsZero() { + args = append(args, fmt.Sprintf("end=%s", c.EndTime.Format(TimeFormat))) + } + return fmt.Sprintf("range(%s)", strings.Join(args, ", ")) +} + +// Set represents a set() function call. +type Set struct { + ID uint64 + Frame string + Filter uint64 + ProfileID uint64 +} + +// String returns the string representation of the call. +func (c *Set) String() string { + args := make([]string, 0, 2) + if c.ID != 0 { + args = append(args, fmt.Sprintf("id=%d", c.ID)) + } + if c.Frame != "" { + args = append(args, fmt.Sprintf("frame=%s", c.Frame)) + } + if c.Filter != 0 { + args = append(args, fmt.Sprintf("filter=%d", c.Filter)) + } + if c.ProfileID != 0 { + args = append(args, fmt.Sprintf("profile_id=%d", c.ProfileID)) + } + return fmt.Sprintf("set(%s)", strings.Join(args, ", ")) +} + +// TopN represents a top-n() function call. +type TopN struct { + Frame string + N int +} + +// String returns the string representation of the call. +func (c *TopN) String() string { panic("FIXME") } + +// Union represents a union() function call. +type Union struct { + Inputs BitmapCalls +} + +// String returns the string representation of the call. +func (c *Union) String() string { + return fmt.Sprintf("union(%s)", c.Inputs.String()) +} diff --git a/pql/ast_test.go b/pql/ast_test.go new file mode 100644 index 000000000..a390f5263 --- /dev/null +++ b/pql/ast_test.go @@ -0,0 +1,89 @@ +package pql_test + +import ( + "testing" + "time" + + "github.com/umbel/pilosa/pql" +) + +// Ensure the Clear call can be converted into a string. +func TestClear_String(t *testing.T) { + s := (&pql.Clear{ID: 1, Frame: "x.n", Filter: 2, ProfileID: 3}).String() + if s != `clear(id=1, frame=x.n, filter=2, profile_id=3)` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Count call can be converted into a string. +func TestCount_String(t *testing.T) { + s := (&pql.Count{Input: &pql.Get{ID: 1, Frame: "x.n"}}).String() + if s != `count(get(id=1, frame=x.n))` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Difference call can be converted into a string. +func TestDifference_String(t *testing.T) { + s := (&pql.Difference{Inputs: pql.BitmapCalls{ + &pql.Get{ID: 1, Frame: "x.n"}, + &pql.Get{ID: 2}, + }, + }).String() + if s != `difference(get(id=1, frame=x.n), get(id=2))` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Get call can be converted into a string. +func TestGet_String(t *testing.T) { + s := (&pql.Get{ID: 1, Frame: "x.n"}).String() + if s != `get(id=1, frame=x.n)` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Intersect call can be converted into a string. +func TestIntersect_String(t *testing.T) { + s := (&pql.Intersect{Inputs: pql.BitmapCalls{ + &pql.Get{ID: 1, Frame: "x.n"}, + &pql.Get{ID: 2}, + }, + }).String() + if s != `intersect(get(id=1, frame=x.n), get(id=2))` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Range call can be converted into a string. +func TestRange_String(t *testing.T) { + s := (&pql.Range{ + ID: 1, + Frame: "x.n", + StartTime: time.Unix(0, 0).UTC(), + EndTime: time.Date(2000, 1, 2, 3, 4, 0, 0, time.UTC), + }).String() + if s != `range(id=1, frame=x.n, start=1970-01-01T00:00, end=2000-01-02T03:04)` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Set call can be converted into a string. +func TestSet_String(t *testing.T) { + s := (&pql.Set{ID: 1, Frame: "x.n", Filter: 2, ProfileID: 3}).String() + if s != `set(id=1, frame=x.n, filter=2, profile_id=3)` { + t.Fatalf("unexpected string: %s", s) + } +} + +// Ensure the Union call can be converted into a string. +func TestUnion_String(t *testing.T) { + s := (&pql.Union{Inputs: pql.BitmapCalls{ + &pql.Get{ID: 1, Frame: "x.n"}, + &pql.Get{ID: 2}, + }, + }).String() + if s != `union(get(id=1, frame=x.n), get(id=2))` { + t.Fatalf("unexpected string: %s", s) + } +} diff --git a/pql/parser.go b/pql/parser.go new file mode 100644 index 000000000..1fb41a5c3 --- /dev/null +++ b/pql/parser.go @@ -0,0 +1,569 @@ +package pql + +import ( + "fmt" + "io" + "strconv" + "strings" + "time" +) + +// TimeFormat is the go-style time format used to parse string dates. +const TimeFormat = "2006-01-02T15:04" + +// Parser represents a parser for the PQL language. +type Parser struct { + scanner *bufScanner +} + +// NewParser returns a new instance of Parser. +func NewParser(r io.Reader) *Parser { + return &Parser{ + scanner: newBufScanner(r), + } +} + +// ParseString parses s into a query. +func ParseString(s string) (*Query, error) { + return NewParser(strings.NewReader(s)).Parse() +} + +// Parse parses the next node in the query. +func (p *Parser) Parse() (*Query, error) { + fn, err := p.parseCall() + if err != nil { + return nil, err + } + return &Query{Root: fn}, nil +} + +// parseCall parses the next function call. +func (p *Parser) parseCall() (Call, error) { + tok, pos, lit := p.scanIgnoreWhitespace() + if tok != IDENT { + return nil, &ParseError{Message: fmt.Sprintf("expected identifier, found: %s", lit), Pos: pos} + } + + switch lit { + case "count": + return p.parseCountCall() + case "clear": + return p.parseClearCall() + case "difference": + return p.parseDifferenceCall() + case "get": + return p.parseGetCall() + case "intersect": + return p.parseIntersectCall() + case "range": + return p.parseRangeCall() + case "set": + return p.parseSetCall() + case "top-n": + return p.parseTopNCall() + case "union": + return p.parseUnionCall() + default: + return nil, &ParseError{Message: fmt.Sprintf("function not found: %s", lit), Pos: pos} + } +} + +// parseClearCall parses a clear() function call. +func (p *Parser) parseClearCall() (*Clear, error) { + c := &Clear{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + switch arg.key { + case 0, "id": + if err := decodeUint64(arg.value, &c.ID); err != nil { + return nil, parseErrorf(pos, "id: %s", err) + } + case 1, "frame": + if err := decodeString(arg.value, &c.Frame); err != nil { + return nil, parseErrorf(pos, "frame: %s", err) + } + case 2, "filter": + if err := decodeUint64(arg.value, &c.Filter); err != nil { + return nil, parseErrorf(pos, "filter: %s", err) + } + case 3, "profile_id": + if err := decodeUint64(arg.value, &c.ProfileID); err != nil { + return nil, parseErrorf(pos, "profile_id: %s", err) + } + default: + return nil, parseErrorf(pos, "invalid arg: %v", arg.key) + } + } + + return c, nil +} + +// parseCount parses a count() function call. +func (p *Parser) parseCountCall() (*Count, error) { + c := &Count{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } else if len(args) != 1 { + return nil, parseErrorf(pos, "count requires one argument") + } + + // Copy argument to AST. + input, ok := args[0].value.(BitmapCall) + if !ok { + return nil, parseErrorf(pos, "invalid count arg: %s", args[0].value) + } + c.Input = input + + return c, nil +} + +// parseDifference parses a difference() function call. +func (p *Parser) parseDifferenceCall() (*Difference, error) { + c := &Difference{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + if v, ok := arg.value.(BitmapCall); ok { + c.Inputs = append(c.Inputs, v) + } else { + return nil, parseErrorf(pos, "invalid arg: %v", arg.value) + } + } + + return c, nil +} + +// parseGetCall parses a get() function call. +func (p *Parser) parseGetCall() (*Get, error) { + c := &Get{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + switch arg.key { + case 0, "id": + if err := decodeUint64(arg.value, &c.ID); err != nil { + return nil, parseErrorf(pos, "id: %s", err) + } + case 1, "frame": + if err := decodeString(arg.value, &c.Frame); err != nil { + return nil, parseErrorf(pos, "frame: %s", err) + } + default: + return nil, parseErrorf(pos, "invalid arg: %v", arg.key) + } + } + + return c, nil +} + +// parseIntersect parses a intersect() function call. +func (p *Parser) parseIntersectCall() (*Intersect, error) { + c := &Intersect{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + if v, ok := arg.value.(BitmapCall); ok { + c.Inputs = append(c.Inputs, v) + } else { + return nil, parseErrorf(pos, "invalid arg: %v", arg.value) + } + } + + return c, nil +} + +// parseRangeCall parses a range() function call. +func (p *Parser) parseRangeCall() (*Range, error) { + c := &Range{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + switch arg.key { + case 0, "id": + if err := decodeUint64(arg.value, &c.ID); err != nil { + return nil, parseErrorf(pos, "start: %s", err) + } + case 1, "frame": + if err := decodeString(arg.value, &c.Frame); err != nil { + return nil, parseErrorf(pos, "frame: %s", err) + } + case 2, "start": + if err := decodeDate(arg.value, &c.StartTime); err != nil { + return nil, parseErrorf(pos, "start: %s", err) + } + case 3, "end": + if err := decodeDate(arg.value, &c.EndTime); err != nil { + return nil, parseErrorf(pos, "end: %s", err) + } + default: + return nil, parseErrorf(pos, "invalid arg: %v", arg.key) + } + } + + return c, nil +} + +// parseSetCall parses a set() function call. +func (p *Parser) parseSetCall() (*Set, error) { + c := &Set{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + switch arg.key { + case 0, "id": + if err := decodeUint64(arg.value, &c.ID); err != nil { + return nil, parseErrorf(pos, "id: %s", err) + } + case 1, "frame": + if err := decodeString(arg.value, &c.Frame); err != nil { + return nil, parseErrorf(pos, "frame: %s", err) + } + case 2, "filter": + if err := decodeUint64(arg.value, &c.Filter); err != nil { + return nil, parseErrorf(pos, "filter: %s", err) + } + case 3, "profile_id": + if err := decodeUint64(arg.value, &c.ProfileID); err != nil { + return nil, parseErrorf(pos, "profile_id: %s", err) + } + default: + return nil, parseErrorf(pos, "invalid arg: %v", arg.key) + } + } + + return c, nil +} + +// parseTopNCall parses a top-n() function call. +func (p *Parser) parseTopNCall() (*TopN, error) { + c := &TopN{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + switch arg.key { + case 0, "frame": + if err := decodeString(arg.value, &c.Frame); err != nil { + return nil, parseErrorf(pos, "frame: %s", err) + } + case 1, "n": + if err := decodeInt(arg.value, &c.N); err != nil { + return nil, parseErrorf(pos, "n: %s", err) + } + default: + return nil, parseErrorf(pos, "invalid arg: %v", arg.key) + } + } + + return c, nil +} + +// parseUnion parses a union() function call. +func (p *Parser) parseUnionCall() (*Union, error) { + c := &Union{} + pos := p.pos() + + // Scan opening parenthesis. + if err := p.expect(LPAREN); err != nil { + return nil, err + } + + // Parse arguments. + args, err := p.parseArgs() + if err != nil { + return nil, err + } + + // Copy arguments to AST. + for _, arg := range args { + if v, ok := arg.value.(BitmapCall); ok { + c.Inputs = append(c.Inputs, v) + } else { + return nil, parseErrorf(pos, "invalid arg: %v", arg.value) + } + } + + return c, nil +} + +// parseArgs arguments to a function call. +func (p *Parser) parseArgs() ([]arg, error) { + var i int + var args []arg + for { + // Parse next argument. + arg, err := p.parseArg() + if err != nil { + return nil, err + } + + // If it's a primitive type without a key then index it. + if arg.key == nil { + switch arg.value.(type) { + case uint64, string: + arg.key = i + i++ + } + } + + // Append argument to list. + args = append(args, arg) + + // If next token is a closing parenthesis, then exit. + // Otherwise expect a comma. + if tok, pos, lit := p.scanIgnoreWhitespace(); tok == RPAREN { + break + } else if tok != COMMA { + return nil, parseErrorf(pos, "expected COMMA, found %q", lit) + } + } + + return args, nil +} + +// parseArg parses a single argument to a function call. +func (p *Parser) parseArg() (arg, error) { + var key, value interface{} + + // Read identifier and check if there's a following "=" or "(". + tok, pos, lit := p.scanIgnoreWhitespace() + switch tok { + case IDENT: + // If a left paren immediately follows then it's a function call. + if tok, _, _ := p.scan(); tok == LPAREN { + p.unscan(2) + c, err := p.parseCall() + if err != nil { + return arg{}, err + } + return arg{value: c}, nil + } + + // If it's not a left paren, rescan ignoring whitespace and look for "=", + p.unscan(1) + if tok, _, _ := p.scanIgnoreWhitespace(); tok == EQ { + key = lit // keyed arg + } else { + p.unscan(1) + } + default: + p.unscan(1) + } + + // Read value token. + tok, pos, lit = p.scanIgnoreWhitespace() + switch tok { + case IDENT, STRING: + value = lit + case NUMBER: + v, err := strconv.ParseUint(lit, 10, 64) + if err != nil { + return arg{}, err + } + value = v + case LBRACK: + panic("FIXME: parse list of integers") + default: + return arg{}, parseErrorf(pos, "invalid value: %q", lit) + } + + return arg{key: key, value: value}, nil +} + +// scan returns the next token from the scanner. +func (p *Parser) scan() (tok Token, pos Pos, lit string) { return p.scanner.Scan() } + +// scanIgnoreWhitespace returns the next non-whitespace token from the scanner. +func (p *Parser) scanIgnoreWhitespace() (tok Token, pos Pos, lit string) { + tok, pos, lit = p.scan() + if tok == WS { + tok, pos, lit = p.scan() + } + return +} + +// unscan returns the last n tokens back to the scanner. +func (p *Parser) unscan(n int) { + for i := 0; i < n; i++ { + p.scanner.unscan() + } +} + +// expect returns an error if the next token is not exp. +func (p *Parser) expect(exp Token) error { + if tok, pos, lit := p.scan(); tok != exp { + return parseErrorf(pos, "expected %s, found %q", exp.String(), lit) + } + return nil +} + +// expectIgnoreWhitespace returns an error if the next non-whitespace token is not exp. +func (p *Parser) expectIgnoreWhitespace(exp Token) error { + if tok, pos, lit := p.scanIgnoreWhitespace(); tok != exp { + return parseErrorf(pos, "expected %s, found %q", exp.String(), lit) + } + return nil +} + +// pos returns the current position. +func (p *Parser) pos() Pos { return p.scanner.pos() } + +// arg represents an call argument. +// The key can be the index or the string key. +// The value can be a uint64, []uint64, string, Call, or Calls. +type arg struct { + key interface{} + value interface{} +} + +// ParseError represents an error that occurred while parsing a PQL query. +type ParseError struct { + Message string + Pos Pos +} + +// Error returns a string representation of e. +func (e *ParseError) Error() string { + return fmt.Sprintf("%s occurred at line %d, char %d", e.Message, e.Pos.Line+1, e.Pos.Char+1) +} + +// parseErrorf returns a formatted parse error. +func parseErrorf(pos Pos, format string, args ...interface{}) *ParseError { + return &ParseError{ + Message: fmt.Sprintf(format, args...), + Pos: pos, + } +} + +// decodeInt type converts v to target. +func decodeInt(v interface{}, target *int) error { + if v, ok := v.(uint64); ok { + *target = int(v) + return nil + } + return fmt.Errorf("invalid int value: %v", v) +} + +// decodeUint64 type converts v to target. +func decodeUint64(v interface{}, target *uint64) error { + if v, ok := v.(uint64); ok { + *target = v + return nil + } + return fmt.Errorf("invalid int value: %v", v) +} + +// decodeString type converts v to target. +func decodeString(v interface{}, target *string) error { + if v, ok := v.(string); ok { + *target = v + return nil + } + return fmt.Errorf("invalid string value: %v", v) +} + +// decodeDate type converts v to target. +func decodeDate(v interface{}, target *time.Time) error { + if v, ok := v.(string); ok { + t, err := time.Parse(TimeFormat, v) + if err != nil { + return fmt.Errorf("invalid date format: %s", v) + } + *target = t + return nil + } + return fmt.Errorf("invalid date value: %v", v) +} diff --git a/pql/parser_test.go b/pql/parser_test.go new file mode 100644 index 000000000..9e7333dfb --- /dev/null +++ b/pql/parser_test.go @@ -0,0 +1,239 @@ +package pql_test + +import ( + "reflect" + "testing" + "time" + + "github.com/davecgh/go-spew/spew" + "github.com/umbel/pilosa/pql" +) + +// Ensure the parser can parse a "clear()" function with keyed args. +func TestParser_Parse_Clear_Key(t *testing.T) { + q, err := pql.ParseString(`clear(id=1, frame="b.n", filter=2, profile_id = 3)`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Clear{ + ID: 1, + Frame: "b.n", + Filter: 2, + ProfileID: 3, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "clear()" function with array args. +func TestParser_Parse_Clear_Array(t *testing.T) { + q, err := pql.ParseString(`clear(1, "b.n", 2, 3)`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Clear{ + ID: 1, + Frame: "b.n", + Filter: 2, + ProfileID: 3, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "count()" function. +func TestParser_Parse_Count(t *testing.T) { + q, err := pql.ParseString(`count(get(1))`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Count{ + Input: &pql.Get{ + ID: 1, + }, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "difference()" function. +func TestParser_Parse_Difference(t *testing.T) { + q, err := pql.ParseString(`difference(get(1), get(2))`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Difference{ + Inputs: pql.BitmapCalls{ + &pql.Get{ID: 1}, + &pql.Get{ID: 2}, + }, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "get()" function with keyed args. +func TestParser_Parse_Get_Key(t *testing.T) { + q, err := pql.ParseString(`get(id=1, frame="b.n")`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Get{ + ID: 1, + Frame: "b.n", + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "get()" function with array args. +func TestParser_Parse_Get_Array(t *testing.T) { + q, err := pql.ParseString(`get(1, "b.n")`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Get{ + ID: 1, + Frame: "b.n", + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "intersect()" function. +func TestParser_Parse_Intersect(t *testing.T) { + q, err := pql.ParseString(`intersect(get(1), get(2))`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Intersect{ + Inputs: pql.BitmapCalls{ + &pql.Get{ID: 1}, + &pql.Get{ID: 2}, + }, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "range()" function with keyed args. +func TestParser_Parse_Range_Key(t *testing.T) { + q, err := pql.ParseString(`range(start="2000-01-02T03:04", id=20, frame="b.n", end="2001-01-02T03:04")`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Range{ + ID: 20, + Frame: "b.n", + StartTime: time.Date(2000, 1, 2, 3, 4, 0, 0, time.UTC), + EndTime: time.Date(2001, 1, 2, 3, 4, 0, 0, time.UTC), + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "range()" function with array args. +func TestParser_Parse_Range_Array(t *testing.T) { + q, err := pql.ParseString(`range(20, "b.n", "2000-01-02T03:04", "2001-01-02T03:04")`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Range{ + ID: 20, + Frame: "b.n", + StartTime: time.Date(2000, 1, 2, 3, 4, 0, 0, time.UTC), + EndTime: time.Date(2001, 1, 2, 3, 4, 0, 0, time.UTC), + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "set()" function with keyed args. +func TestParser_Parse_Set_Key(t *testing.T) { + q, err := pql.ParseString(`set(id=1, frame="b.n", filter=2, profile_id = 3)`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Set{ + ID: 1, + Frame: "b.n", + Filter: 2, + ProfileID: 3, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "set()" function with array args. +func TestParser_Parse_Set_Array(t *testing.T) { + q, err := pql.ParseString(`set(1, "b.n", 2, 3)`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Set{ + ID: 1, + Frame: "b.n", + Filter: 2, + ProfileID: 3, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "top-n()" function with keyed args. +func TestParser_Parse_TopN_Key(t *testing.T) { + q, err := pql.ParseString(`top-n(frame="b.n", n=2)`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.TopN{ + Frame: "b.n", + N: 2, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "top-n()" function with array args. +func TestParser_Parse_TopN_Array(t *testing.T) { + q, err := pql.ParseString(`top-n("b.n", 2)`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.TopN{ + Frame: "b.n", + N: 2, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} + +// Ensure the parser can parse a "union()" function. +func TestParser_Parse_Union(t *testing.T) { + q, err := pql.ParseString(`union(get(1), get(2))`) + if err != nil { + t.Fatal(err) + } else if !reflect.DeepEqual(q, &pql.Query{ + Root: &pql.Union{ + Inputs: pql.BitmapCalls{ + &pql.Get{ID: 1}, + &pql.Get{ID: 2}, + }, + }, + }) { + t.Fatalf("unexpected query: %s", spew.Sdump(q)) + } +} diff --git a/pql/scanner.go b/pql/scanner.go new file mode 100644 index 000000000..3df4cc3f2 --- /dev/null +++ b/pql/scanner.go @@ -0,0 +1,258 @@ +package pql + +import ( + "bufio" + "bytes" + "io" + "unicode" +) + +// Scanner represents a PQL lexical scanner. +type Scanner struct { + r io.RuneScanner + pos Pos +} + +// NewScanner returns a new instance of Scanner. +func NewScanner(r io.Reader) *Scanner { + return &Scanner{r: bufio.NewReader(r)} +} + +// Scan returns the next token and position from the underlying reader. +func (s *Scanner) Scan() (tok Token, pos Pos, lit string) { + pos = s.pos + + // Read next code point. + ch := s.read() + + // If we see whitespace then consume all contiguous whitespace. + // If we see a letter, or certain acceptable special characters, then consume + // as an ident or reserved word. If we see quotes, then scan as string. + if isWhitespace(ch) { + s.unread() + return s.scanWhitespace() + } else if isIdentFirstChar(ch) { + s.unread() + return s.scanIdent() + } else if isDigit(ch) { + s.unread() + return s.scanNumber() + } else if ch == '"' || ch == '\'' { + s.unread() + return s.scanString() + } + + // Otherwise parse individual characters. + switch ch { + case eof: + tok = EOF + return + case '=': + tok = EQ + case ',': + tok = COMMA + case '(': + tok = LPAREN + case ')': + tok = RPAREN + case '[': + tok = LBRACK + case ']': + tok = RBRACK + default: + tok = ILLEGAL + } + + lit = string(ch) + return +} + +// read returns the next code point from the underlying reader and updates the pos. +func (s *Scanner) read() rune { + // Read next rune from underlying reader. + ch, _, err := s.r.ReadRune() + if err != nil { + return eof + } + + // Update position information. + if ch == '\n' { + s.pos.Line++ + s.pos.Char = 0 + } else { + s.pos.Char++ + } + + return ch +} + +// unread pushes the previously read rune back onto the reader. +func (s *Scanner) unread() { + if s.pos.Char == 0 { + s.pos.Line-- + } else { + s.pos.Char-- + } + + s.r.UnreadRune() +} + +// scanWhitespace consumes the current rune and all contiguous whitespace. +func (s *Scanner) scanWhitespace() (tok Token, pos Pos, lit string) { + pos = s.pos + + var buf bytes.Buffer + for { + ch := s.read() + if ch == eof { + break + } else if !isWhitespace(ch) { + s.unread() + break + } + buf.WriteRune(ch) + } + + return WS, pos, buf.String() +} + +func (s *Scanner) scanIdent() (tok Token, pos Pos, lit string) { + pos = s.pos + + var buf bytes.Buffer + for { + ch := s.read() + if ch == eof { + break + } else if !isIdentChar(ch) { + s.unread() + break + } + buf.WriteRune(ch) + } + lit = buf.String() + + // If the literal matches a keyword then return that keyword. + if tok = Lookup(lit); tok != IDENT { + return tok, pos, lit + } + + return IDENT, pos, lit +} + +// scanNumber consumes consecutive integer digits. +func (s *Scanner) scanNumber() (tok Token, pos Pos, lit string) { + pos = s.pos + + var buf bytes.Buffer + for { + ch := s.read() + if !isDigit(ch) { + s.unread() + break + } + buf.WriteRune(ch) + } + return NUMBER, pos, buf.String() +} + +// scanString consumes a single-quoted or double-quoted string. +func (s *Scanner) scanString() (tok Token, pos Pos, lit string) { + pos = s.pos + + // This must be either a single- or double-quote. + ending := s.read() + + var buf bytes.Buffer + for { + ch := s.read() + if ch == ending { + break + } else if ch == '\n' || ch == eof { + return BADSTRING, pos, buf.String() + } else if ch == '\\' { + next := s.read() + if next == 'n' { + buf.WriteRune('\n') + } else if next == '\\' { + buf.WriteRune('\\') + } else if next == '"' { + buf.WriteRune('"') + } else if next == '\'' { + buf.WriteRune('\'') + } else { + return BADSTRING, pos, buf.String() + } + } else { + buf.WriteRune(ch) + } + } + + return STRING, pos, buf.String() +} + +// bufScanner represents a wrapper for scanner to add a buffer. +// It provides a fixed-length circular buffer that can be unread. +type bufScanner struct { + s *Scanner + i int // buffer index + n int // buffer size + buf [3]struct { + tok Token + pos Pos + lit string + } +} + +// newBufScanner returns a new buffered scanner for a reader. +func newBufScanner(r io.Reader) *bufScanner { + return &bufScanner{s: NewScanner(r)} +} + +// Scan reads the next token from the scanner. +func (s *bufScanner) Scan() (tok Token, pos Pos, lit string) { + // If we have unread tokens then read them off the buffer first. + if s.n > 0 { + s.n-- + return s.curr() + } + + // Move buffer position forward and save the token. + s.i = (s.i + 1) % len(s.buf) + buf := &s.buf[s.i] + buf.tok, buf.pos, buf.lit = s.s.Scan() + + return s.curr() +} + +// unscan pushes the previously token back onto the buffer. +func (s *bufScanner) unscan() { s.n++ } + +// curr returns the last read token. +func (s *bufScanner) curr() (tok Token, pos Pos, lit string) { + buf := &s.buf[(s.i-s.n+len(s.buf))%len(s.buf)] + return buf.tok, buf.pos, buf.lit +} + +// pos returns the current position. +func (s *bufScanner) pos() Pos { + _, pos, _ := s.curr() + return pos +} + +// isWhitespace returns true if the rune a Unicode space character. +func isWhitespace(ch rune) bool { return unicode.IsSpace(ch) } + +// isLetter returns true if the rune is a letter. +func isLetter(ch rune) bool { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') } + +// isDigit returns true if the rune is a digit. +func isDigit(ch rune) bool { return (ch >= '0' && ch <= '9') } + +// isIdentChar returns true if the rune can be used in an unquoted identifier. +func isIdentChar(ch rune) bool { return isLetter(ch) || isDigit(ch) || ch == '_' || ch == '-' } + +// isIdentFirstChar returns true if the rune can be used as the first char in an identifier. +func isIdentFirstChar(ch rune) bool { return isLetter(ch) } + +const eof = rune(0) diff --git a/pql/scanner_test.go b/pql/scanner_test.go new file mode 100644 index 000000000..7432598d5 --- /dev/null +++ b/pql/scanner_test.go @@ -0,0 +1,49 @@ +package pql_test + +import ( + "strings" + "testing" + + "github.com/umbel/pilosa/pql" +) + +func TestScanner_Scan(t *testing.T) { + var tests = []struct { + s string + tok pql.Token + lit string + pos pql.Pos + }{ + // Special tokens (EOF, ILLEGAL, WS) + {s: ``, tok: pql.EOF}, + {s: `#`, tok: pql.ILLEGAL, lit: `#`}, + {s: ` `, tok: pql.WS, lit: " "}, + {s: "\t", tok: pql.WS, lit: "\t"}, + {s: "\n", tok: pql.WS, lit: "\n"}, + + {s: `=`, tok: pql.EQ, lit: `=`}, + {s: `,`, tok: pql.COMMA, lit: `,`}, + {s: `(`, tok: pql.LPAREN, lit: `(`}, + {s: `)`, tok: pql.RPAREN, lit: `)`}, + {s: `[`, tok: pql.LBRACK, lit: `[`}, + {s: `]`, tok: pql.RBRACK, lit: `]`}, + + {s: `foo`, tok: pql.IDENT, lit: `foo`}, + {s: `100`, tok: pql.NUMBER, lit: `100`}, + + {s: `all`, tok: pql.ALL, lit: `all`}, + {s: `ALL`, tok: pql.ALL, lit: `ALL`}, // case insensitive + } + + for i, tt := range tests { + s := pql.NewScanner(strings.NewReader(tt.s)) + tok, pos, lit := s.Scan() + if tt.tok != tok { + t.Errorf("%d. %q token mismatch: exp=%q got=%q <%q>", i, tt.s, tt.tok, tok, lit) + } else if tt.pos.Line != pos.Line || tt.pos.Char != pos.Char { + t.Errorf("%d. %q pos mismatch: exp=%#v got=%#v", i, tt.s, tt.pos, pos) + } else if tt.lit != lit { + t.Errorf("%d. %q literal mismatch: exp=%q got=%q", i, tt.s, tt.lit, lit) + } + } +} diff --git a/pql/token.go b/pql/token.go new file mode 100644 index 000000000..f794a684a --- /dev/null +++ b/pql/token.go @@ -0,0 +1,81 @@ +package pql + +import "strings" + +// Token is a lexical token of the PQL language. +type Token int + +const ( + // Special tokens + ILLEGAL Token = iota + EOF + WS + + literal_beg + IDENT // main + STRING // "foo" + BADSTRING // bad escape or unclosed string + NUMBER // 12345 + literal_end + + keyword_beg + ALL + keyword_end + + EQ // = + COMMA // , + LPAREN // ( + RPAREN // ) + LBRACK // ( + RBRACK // ) +) + +var tokens = [...]string{ + ILLEGAL: "ILLEGAL", + EOF: "EOF", + WS: "WS", + + IDENT: "IDENT", + NUMBER: "NUMBER", + + ALL: "ALL", + + EQ: "=", + COMMA: ",", + LPAREN: "(", + RPAREN: ")", + LBRACK: "(", + RBRACK: ")", +} + +var keywords map[string]Token + +func init() { + keywords = make(map[string]Token) + for tok := keyword_beg + 1; tok < keyword_end; tok++ { + keywords[strings.ToLower(tokens[tok])] = tok + } +} + +// String returns the string representation of the token. +func (tok Token) String() string { + if tok >= 0 && tok < Token(len(tokens)) { + return tokens[tok] + } + return "" +} + +// Lookup returns the token associated with a given string. +func Lookup(ident string) Token { + if tok, ok := keywords[strings.ToLower(ident)]; ok { + return tok + } + return IDENT +} + +// Pos specifies the line and character position of a token. +// The Char and Line are both zero-based indexes. +type Pos struct { + Line int + Char int +} diff --git a/query/lexer.go b/query/lexer.go deleted file mode 100644 index 1c7ce0ea4..000000000 --- a/query/lexer.go +++ /dev/null @@ -1,348 +0,0 @@ -package query - -import ( - "errors" - "fmt" - "strings" - "unicode" - "unicode/utf8" - - log "github.com/cihub/seelog" -) - -const ( - TYPE_FUNC = iota - TYPE_LP = iota - TYPE_RP = iota - TYPE_LB = iota - TYPE_RB = iota - TYPE_VALUE = iota - TYPE_KEYWORD = iota - TYPE_EQUALS = iota - TYPE_COMMA = iota - TYPE_ERROR = iota - - // Below types deprecated - TYPE_ID = iota - TYPE_FRAME = iota - TYPE_PROFILE = iota - TYPE_LIMIT = iota -) - -type Token struct { - Text string - Type int -} - -type statefn func(lexer *Lexer) statefn - -type Lexer struct { - text string // the string being scanned. - pos int // current position in the input. - width int // width of last rune read from input. - start int // start position of this item. - state int // current state of lexer NEEDED??? - ch chan Token // channel of scanned items (Tokens). -} - -func (lexer *Lexer) emit(typ int) { - log.Trace("Lexer.emit", typ) - if lexer.start < lexer.pos { - lexer.ch <- Token{lexer.text[lexer.start:lexer.pos], typ} - } - lexer.start = lexer.pos -} - -func (lexer *Lexer) acceptUntil(chars string, consume bool) (rune, error) { - log.Trace("Lexer.acceptUntil", chars, consume) - start_pos := lexer.pos - - for { - next := lexer.next() - - if next == rune(' ') { - lexer.ignore() - } - - if next == 0 { - lexer.pos = start_pos - return 0, errors.New("Not found") - } - ch := strings.IndexRune(chars, next) - if ch >= 0 { - if consume { - lexer.backup() - } else { - lexer.pos = start_pos - } - return []rune(chars)[ch], nil - } - } -} - -func (lexer *Lexer) acceptRun(valid string) { - log.Trace("Lexer.acceptRun", valid) - for strings.IndexRune(valid, lexer.next()) >= 0 { - } - lexer.backup() -} - -// next returns the next rune in the input. -func (lexer *Lexer) next() (runey rune) { - log.Trace("Lexer.next", runey) - if lexer.pos >= len(lexer.text) { - lexer.width = 0 - return 0 - } - runey, lexer.width = utf8.DecodeRuneInString(lexer.text[lexer.pos:]) - lexer.pos += lexer.width - return runey -} - -// ignore skips over the pending input before this point. -func (lexer *Lexer) ignore() { - log.Trace("Lexer.ignore") - lexer.start = lexer.pos -} - -// backup steps back one rune. -// Can be called only once per call of next. -func (lexer *Lexer) backup() { - log.Trace("Lexer.backup") - lexer.pos -= lexer.width -} - -// peek returns but does not consume -// the next rune in the input. -func (lexer *Lexer) peek() rune { - log.Trace("Lexer.peek") - for { - next_rune := lexer.next() - // ignore spaces - if next_rune != rune(' ') { - lexer.backup() - return next_rune - } - lexer.ignore() - } -} - -func stateError(err error) func(lexer *Lexer) statefn { - log.Trace("stateError", err) - return func(lexer *Lexer) statefn { - lexer.ch <- Token{err.Error(), TYPE_ERROR} - close(lexer.ch) - return nil - } -} - -func stateFunc(lexer *Lexer) statefn { - log.Trace("stateFunc", lexer) - _, err := lexer.acceptUntil("(", true) - if err != nil { - return stateError(err) - } - lexer.emit(TYPE_FUNC) - return stateLP -} - -func stateLP(lexer *Lexer) statefn { - log.Trace("stateLP", lexer) - lexer.pos += 1 - lexer.emit(TYPE_LP) - // handle multiple LPs - if lexer.peek() == rune('(') { - return stateLP - } - return stateArgs -} - -func stateLB(lexer *Lexer) statefn { - log.Trace("stateLB", lexer) - lexer.acceptUntil("[", true) - lexer.next() - lexer.emit(TYPE_LB) - - peeked := lexer.peek() - if peeked == rune(']') { - lexer.next() - lexer.emit(TYPE_RB) - return stateArgs - } else if unicode.IsDigit(peeked) { - for { - r, err := lexer.acceptUntil(",]", true) - if err != nil { - return stateError(errors.New("Unclosed bracket!")) - } - lexer.emit(TYPE_VALUE) - if r == ',' { - lexer.next() - lexer.emit(TYPE_COMMA) - } else { - lexer.next() - lexer.emit(TYPE_RB) - return stateArgs - } - } - } else { - return stateArgs - } -} - -func stateRB(lexer *Lexer) statefn { - log.Trace("stateRB", lexer) - lexer.pos += 1 - lexer.emit(TYPE_RB) - - peeked := lexer.peek() - if peeked == rune(',') { - return stateRPComma - } else if peeked == rune(')') { - return stateRP - } else { - return stateEOF - } -} - -func stateArgs(lexer *Lexer) statefn { - log.Trace("stateArgs", lexer) - r, err := lexer.acceptUntil("(),=[]", false) - if err != nil { - return stateError(err) - } - switch r { - case '(': - return stateFunc - case ')': - return stateValue - case ',': - return stateValue - case '=': - return stateKeyword - case '[': - return stateLB - case ']': - return stateRB - default: - return stateError(errors.New("Expecting arguments!")) - } -} - -func stateKeyword(lexer *Lexer) statefn { - log.Trace("stateKeyword", lexer) - _, err := lexer.acceptUntil("=", true) - if err != nil { - return stateError(err) - } - lexer.emit(TYPE_KEYWORD) - return stateEquals -} - -func stateEquals(lexer *Lexer) statefn { - log.Trace("stateEquals", lexer) - e := lexer.next() - if e != '=' { - return stateError(errors.New("Expecting '='!")) - } - lexer.emit(TYPE_EQUALS) - return stateValue -} - -func stateValue(lexer *Lexer) statefn { - log.Trace("stateValue", lexer) - r, err := lexer.acceptUntil("(),[", false) - if err != nil { - return stateError(err) - } - switch r { - case '(': - return stateFunc - case ')': - lexer.acceptUntil(")", true) - if lexer.pos > lexer.start { - lexer.emit(TYPE_VALUE) - } - return stateRP - case ',': - lexer.acceptUntil(",", true) - lexer.emit(TYPE_VALUE) - return stateComma - case '[': - return stateLB - default: - return stateError(errors.New("Unexpected character!")) - } -} - -func stateRP(lexer *Lexer) statefn { - log.Trace("stateRP", lexer) - lexer.pos += 1 - lexer.emit(TYPE_RP) - - peeked := lexer.peek() - if peeked == rune(',') { - return stateRPComma - } else if peeked == rune(')') { - return stateRP - } else if peeked == rune(']') { - return stateRB - } else { - return stateEOF - } -} - -func stateRPComma(lexer *Lexer) statefn { - log.Trace("stateRPComma", lexer) - lexer.pos += 1 - lexer.emit(TYPE_COMMA) - return stateValue -} - -func stateComma(lexer *Lexer) statefn { - log.Trace("stateComma", lexer) - lexer.pos += 1 - lexer.emit(TYPE_COMMA) - return stateArgs -} - -func stateEOF(lexer *Lexer) statefn { - log.Trace("stateEOF", lexer) - close(lexer.ch) - return nil -} - -func (lexer *Lexer) Lex() (tokens []Token, err error) { - log.Trace("Lexer.Lex", tokens, err) - defer func() { - if r := recover(); r != nil { - var ok bool - err, ok = r.(error) - if !ok { - err = fmt.Errorf("query: %v", r) - } - } - }() - tokens = make([]Token, 0) - state := stateFunc - go func() { - for { - state = state(lexer) - if state == nil { - return - } - } - }() - for t := range lexer.ch { - if t.Type == TYPE_ERROR { - err = errors.New(t.Text) - } - tokens = append(tokens, t) - } - return tokens, err -} - -func Lex(input string) ([]Token, error) { - log.Trace("Lex", input) - lexer := Lexer{input, 0, 0, 0, TYPE_FUNC, make(chan Token)} - return lexer.Lex() -} diff --git a/query/lexer_test.go b/query/lexer_test.go deleted file mode 100644 index 4e5f0578a..000000000 --- a/query/lexer_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package query_test - -import ( - "reflect" - "testing" - - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa/query" -) - -// Ensure a simple function and value can be lexed. -func TestLexer_Lex_FuncValue(t *testing.T) { - if tokens, err := query.Lex("get(10)"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure a simple function, keyword, & value can be lexed. -func TestLexer_Lex_FuncKeywordValue(t *testing.T) { - if tokens, err := query.Lex("get(id=10)"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"id", query.TYPE_KEYWORD}, - {"=", query.TYPE_EQUALS}, - {"10", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure a more complex function can be lexed. -func TestLexer_Lex_FuncComplex(t *testing.T) { - if tokens, err := query.Lex("get(id=10, frame=brand)"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"id", query.TYPE_KEYWORD}, - {"=", query.TYPE_EQUALS}, - {"10", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"frame", query.TYPE_KEYWORD}, - {"=", query.TYPE_EQUALS}, - {"brand", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that nested functions can be lexed. -func TestLexer_Lex_FuncNested(t *testing.T) { - if tokens, err := query.Lex("union(get(10))"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"union", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that a list of nested functions can be lexed. -func TestLexer_Lex_FuncNestedList(t *testing.T) { - if tokens, err := query.Lex("intersect(get(10), get(11), get(12))"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"intersect", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"11", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"12", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that complex nested functions can be lexed. -func TestLexer_Lex_FuncNestedComplex(t *testing.T) { - if tokens, err := query.Lex("intersect(get(10), get(11), concat(get(12),get(14)))"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"intersect", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"11", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"concat", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"12", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"14", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {")", query.TYPE_RP}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that complex nested functions can be lexed. -func TestLexer_Lex_FuncNestedComplex2(t *testing.T) { - if tokens, err := query.Lex("concat(get(1, brand),get(2))"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"concat", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"1", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"brand", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"2", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that a set function can be lexed. -func TestLexer_Lex_Set1(t *testing.T) { - if tokens, err := query.Lex("set(1, 987)"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"set", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"1", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"987", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that a set function can be lexed. -func TestLexer_Lex_Set2(t *testing.T) { - if tokens, err := query.Lex("set(1, general, 987)"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"set", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"1", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"general", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"987", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that a TopN function can be lexed. -func TestLexer_Lex_TopN1(t *testing.T) { - if tokens, err := query.Lex("top-n(get(10), 8)"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"top-n", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"8", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that a TopN function can be lexed. -func TestLexer_Lex_TopN2(t *testing.T) { - if tokens, err := query.Lex("top-n(get(10, general), [1,2,3])"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"top-n", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"general", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"[", query.TYPE_LB}, - {"1", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"2", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"3", query.TYPE_VALUE}, - {"]", query.TYPE_RB}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// Ensure that a plugin function can be lexed. -func TestLexer_Lex_Plugin(t *testing.T) { - if tokens, err := query.Lex("plugin(get(10, general), [get(11, general)])"); err != nil { - t.Fatal(err) - } else if !reflect.DeepEqual(tokens, []query.Token{ - {"plugin", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"10", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"general", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {",", query.TYPE_COMMA}, - {"[", query.TYPE_LB}, - {"get", query.TYPE_FUNC}, - {"(", query.TYPE_LP}, - {"11", query.TYPE_VALUE}, - {",", query.TYPE_COMMA}, - {"general", query.TYPE_VALUE}, - {")", query.TYPE_RP}, - {"]", query.TYPE_RB}, - {")", query.TYPE_RP}, - }) { - t.Fatalf("unexpected tokens:\n\n%s", spew.Sprint(tokens)) - } -} - -// MustLex lexes s and returns a set of tokens. Panic on error. -func MustLex(s string) []query.Token { - a, err := query.Lex(s) - if err != nil { - panic(err) - } - return a -} diff --git a/query/parser.go b/query/parser.go deleted file mode 100644 index d15fec54a..000000000 --- a/query/parser.go +++ /dev/null @@ -1,354 +0,0 @@ -package query - -import ( - "errors" - "fmt" - "strconv" - "time" - - log "github.com/cihub/seelog" - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa" -) - -var InvalidQueryError = errors.New("Invalid query format.") - -type QueryParser struct { - tokens []Token - pos int -} - -func (self *QueryParser) next() *Token { - log.Trace("QueryParser.next") - self.pos += 1 - if self.pos > len(self.tokens) { - return nil - } - return &self.tokens[self.pos-1] -} - -func (self *QueryParser) peek() *Token { - log.Trace("QueryParser.peek") - token := self.next() - self.backup() - return token -} - -func (self *QueryParser) backup() { - log.Trace("QueryParser.backup") - self.pos -= 1 -} - -func (self *QueryParser) Parse() (query *Query, err error) { - log.Trace("QueryParser.Parse", query, err) - defer func() { - if r := recover(); r != nil { - var ok bool - err, ok = r.(error) - if !ok { - err = fmt.Errorf("query: %v", r) - } - } - }() - var token *Token - - id := pilosa.NewGUID() - query = &Query{Id: &id, Subqueries: make([]Query, 0), Args: make(map[string]interface{})} - - token = self.next() - if token.Type != TYPE_FUNC { - return nil, fmt.Errorf("Expected function, found token %v.", token) - } - - query.Operation = token.Text - - token = self.next() - if token.Type != TYPE_LP { - return nil, fmt.Errorf("Expected '(', found token %v.", token) - } - const shortForm = "2006-01-02T15:04" - -ArgLoop: - for { - token = self.next() - if token == nil { - return nil, fmt.Errorf("Unclosed parentheses!") - } - - switch token.Type { - case TYPE_FUNC: - self.backup() - subquery, err := self.Parse() - if err != nil { - return nil, err - } - query.Subqueries = append(query.Subqueries, *subquery) - case TYPE_VALUE: - switch query.Operation { - case "range": - switch len(query.Args) { - case 0: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["id"] = i - case 1: - query.Args["frame"] = token.Text - case 2: - t, err := time.Parse(shortForm, token.Text) - if err != nil { - return nil, fmt.Errorf("Expecting integer DateTime (%v)", err) - } - query.Args["start"] = t - case 3: - t, err := time.Parse(shortForm, token.Text) - if err != nil { - return nil, fmt.Errorf("Expecting integer DateTime (%v)", err) - } - query.Args["end"] = t - } - case "mask": - switch len(query.Args) { - case 0: - query.Args["frame"] = token.Text - case 1: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["start"] = i - case 2: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["end"] = i - } - case "get": - switch len(query.Args) { - case 0: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["id"] = i - case 1: - query.Args["frame"] = token.Text - default: - return nil, fmt.Errorf("Unexpected argument! (%v)", token) - } - case "clear": - switch len(query.Args) { - case 0: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["id"] = i - case 1: - query.Args["frame"] = token.Text - case 2: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["filter"] = i - case 3: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["profile_id"] = i - default: - return nil, fmt.Errorf("Unexpected argument! (%v)", token) - } - case "set": - switch len(query.Args) { - case 0: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["id"] = i - case 1: - query.Args["frame"] = token.Text - case 2: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["filter"] = i - case 3: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["profile_id"] = i - default: - return nil, fmt.Errorf("Unexpected argument! (%v)", token) - } - case "top-n": - switch len(query.Args) { - case 0: - query.Args["frame"] = token.Text - case 1: - i, err := strconv.Atoi(token.Text) - if err != nil { - return nil, fmt.Errorf("Expecting integer! (%v)", err) - } - query.Args["n"] = i - } - case "all": - // do nothing - case "recall": //need pair based list of frag_id,handle - arg, ok := query.Args["stash"] - if !ok { - arg = &Stash{make([]CacheItem, 0), false} - query.Args["stash"] = arg - } - - recallArgs := arg.(*Stash) - if !recallArgs.incomplete { - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting fragment id! (%v)", err) - } - recallArgs.Add(pilosa.SUUID(i)) //constructs a new arg - } else { - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting handle! (%v)", err) - } - recallArgs.Assign(pilosa.BitmapHandle(i)) //sets the value of the last created arg - } - default: - spew.Dump("UNPROCESSED VALUE", token) - } - continue - case TYPE_COMMA: - continue - case TYPE_RP: - break ArgLoop - case TYPE_KEYWORD: - var value interface{} - keyword := token.Text - token = self.next() - if token == nil || token.Type != TYPE_EQUALS { - return nil, fmt.Errorf("Expecting equals sign!") - } - token = self.next() - if token == nil || token.Type != TYPE_VALUE { - return nil, fmt.Errorf("Expecting value!") - } - if keyword == "id" { - value, err = strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - } else if keyword == "n" { - value, err = strconv.Atoi(token.Text) - if err != nil { - return nil, fmt.Errorf("Expecting integer! (%v)", err) - } - } else { - value = token.Text - } - query.Args[keyword] = value - case TYPE_LB: - peeked := self.peek() - // we currently support 2 types of values in square brackets: - // ids <- list of integers (TYPE_VALUE) - // filters <- list of queries (TYPE_FUNC) - switch peeked.Type { - case TYPE_VALUE: - query.Args["ids"] = make([]uint64, 0) - for { - token = self.next() - if token == nil { - return nil, fmt.Errorf("Unclosed list!") - } - switch token.Type { - case TYPE_COMMA: - break - case TYPE_VALUE: - i, err := strconv.ParseUint(token.Text, 10, 64) - if err != nil { - return nil, fmt.Errorf("Expecting integer id! (%v)", err) - } - query.Args["ids"] = append(query.Args["ids"].([]uint64), i) - case TYPE_RB: - continue ArgLoop - default: - return nil, fmt.Errorf("Unexpected token! (%v)", token) - } - } - case TYPE_FUNC: - query.Args["filters"] = make([]Query, 0) - for { - token = self.next() - if token == nil { - return nil, fmt.Errorf("Unclosed list!") - } - switch token.Type { - case TYPE_COMMA: - break - case TYPE_FUNC: - self.backup() - filterquery, err := self.Parse() - if err != nil { - return nil, err - } - query.Args["filters"] = append(query.Args["filters"].([]Query), *filterquery) - case TYPE_RB: - continue ArgLoop - default: - return nil, fmt.Errorf("Unexpected token! (%v)", token) - } - } - } - case TYPE_RB: - // - default: - log.Warn(spew.Sdump("unexpected", token)) - return nil, errors.New("BAD TOKEN") - } - } - - if query.Operation == "get" && query.Args["frame"] == nil { - query.Args["frame"] = "general" - } - if len(query.Args) == 0 && len(query.Subqueries) == 0 { - if query.Operation == "count" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "intersect" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "union" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "difference" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "range" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "mask" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "stash" { - return nil, fmt.Errorf("No Args Given") - } - if query.Operation == "recall" { - return nil, fmt.Errorf("No Args Given") - } - } - return query, nil -} - -func Parse(tokens []Token) (*Query, error) { - log.Trace("Parse", tokens) - parser := QueryParser{tokens, 0} - return parser.Parse() -} diff --git a/query/parser_test.go b/query/parser_test.go deleted file mode 100644 index 6c3a4976e..000000000 --- a/query/parser_test.go +++ /dev/null @@ -1,157 +0,0 @@ -package query_test - -import ( - "reflect" - "testing" - - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa/query" -) - -// Ensure the parser can parse a get() query. -func TestParser_Parse_Get(t *testing.T) { - if q, err := query.Parse(MustLex("get(10)")); err != nil { - t.Fatal(err) - } else if q.Operation != "get" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if !reflect.DeepEqual(q.Args, map[string]interface{}{ - "id": uint64(10), - "frame": "general", - }) { - t.Fatalf("unexpected args:\n\n%s", spew.Sprint(q.Args)) - } -} - -// Ensure the parser can parse a get() query with a keyword. -func TestParser_Parse_Get_Keyword(t *testing.T) { - if q, err := query.Parse(MustLex("get(id=10)")); err != nil { - t.Fatal(err) - } else if q.Operation != "get" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if !reflect.DeepEqual(q.Args, map[string]interface{}{"id": uint64(10), "frame": "general"}) { - t.Fatalf("unexpected args:\n\n%s", spew.Sprint(q.Args)) - } -} - -// Ensure the parser can parse a get() query with a keyword. -func TestParser_Parse_Get_MultiKeyword(t *testing.T) { - if q, err := query.Parse(MustLex("get(id=10, frame=brands)")); err != nil { - t.Fatal(err) - } else if q.Operation != "get" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if !reflect.DeepEqual(q.Args, map[string]interface{}{"id": uint64(10), "frame": "brands"}) { - t.Fatalf("unexpected args:\n\n%s", spew.Sprint(q.Args)) - } -} - -// Ensure the parser can parse a clear() query. -func TestParser_Parse_Clear(t *testing.T) { - if q, err := query.Parse(MustLex("clear(10, general, 0, 20)")); err != nil { - t.Fatal(err) - } else if q.Operation != "clear" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if !reflect.DeepEqual(q.Args, map[string]interface{}{ - "id": uint64(10), - "frame": "general", - "filter": uint64(0), - "profile_id": uint64(20), - }) { - t.Fatalf("unexpected args:\n\n%s", spew.Sprint(q.Args)) - } -} - -// Ensure the parser can parse a set() query. -func TestParser_Parse_Set(t *testing.T) { - if q, err := query.Parse(MustLex("set(10, general, 0, 20)")); err != nil { - t.Fatal(err) - } else if q.Operation != "set" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if !reflect.DeepEqual(q.Args, map[string]interface{}{ - "id": uint64(10), - "frame": "general", - "filter": uint64(0), - "profile_id": uint64(20), - }) { - t.Fatalf("unexpected args:\n\n%s", spew.Sprint(q.Args)) - } -} - -// Ensure the parser can parse a nested query. -func TestParser_Parse_Nested(t *testing.T) { - q, err := query.Parse(MustLex("union(get(10,general), get(11,brand), get(12))")) - if err != nil { - t.Fatal(err) - } else if q.Operation != "union" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if len(q.Subqueries) != 3 { - t.Fatalf("unexpected subquery count: %d", len(q.Subqueries)) - } - - if sq := q.Subqueries[0]; sq.Operation != "get" { - t.Fatalf("unexpected subquery(0) operation: %q", sq.Operation) - } else if !reflect.DeepEqual(sq.Args, map[string]interface{}{"id": uint64(10), "frame": "general"}) { - t.Fatalf("unexpected subquery(0) args:\n\n%s", spew.Sprint(q.Args)) - } - - if sq := q.Subqueries[1]; sq.Operation != "get" { - t.Fatalf("unexpected subquery(1) operation: %q", sq.Operation) - } else if !reflect.DeepEqual(sq.Args, map[string]interface{}{"id": uint64(11), "frame": "brand"}) { - t.Fatalf("unexpected subquery(1) args:\n\n%s", spew.Sprint(sq.Args)) - } - - if sq := q.Subqueries[2]; sq.Operation != "get" { - t.Fatalf("unexpected subquery(2) operation: %q", sq.Operation) - } else if !reflect.DeepEqual(sq.Args, map[string]interface{}{"id": uint64(12), "frame": "general"}) { - t.Fatalf("unexpected subquery(2) args:\n\n%s", spew.Sprint(sq.Args)) - } -} - -// Ensure the parser can parse a query with lists. -func TestParser_Parse_Lists(t *testing.T) { - q, err := query.Parse(MustLex("top-n(get(10, general), [1,2,3], 50)")) - if err != nil { - t.Fatal(err) - } else if q.Operation != "top-n" { - t.Fatalf("unexpected operation: %q", q.Operation) - } else if !reflect.DeepEqual(q.Args, map[string]interface{}{"ids": []uint64{1, 2, 3}, "n": 50}) { - t.Fatalf("unexpected args:\n\n%s", spew.Sprint(q.Args)) - } - - if sq := q.Subqueries[0]; sq.Operation != "get" { - t.Fatalf("unexpected subquery(0) operation: %q", sq.Operation) - } else if !reflect.DeepEqual(sq.Args, map[string]interface{}{"id": uint64(10), "frame": "general"}) { - t.Fatalf("unexpected subquery(0) args:\n\n%s", spew.Sprint(q.Args)) - } -} - -// Ensure the parser can parse "all()". -func TestParser_Parse_All(t *testing.T) { - q, err := query.Parse(MustLex("top-n(all(), general, 30)")) - if err != nil { - t.Fatal(err) - } else if q.Operation != "top-n" { - t.Fatalf("unexpected operation: %q", q.Operation) - } - - if sq := q.Subqueries[0]; sq.Operation != "all" { - t.Fatalf("unexpected subquery(0) operation: %q", sq.Operation) - } -} - -// Ensure the parser can parse bracketed lists. -func TestParser_Parse_Lists_Bracketed(t *testing.T) { - q, err := query.Parse(MustLex("plugin(get(99), [get(10), get(11)])")) - if err != nil { - t.Fatalf("expected error") - } - spew.Dump(q) -} - -// Ensure the parser can parse a recall query. -func TestParser_Parse_Recall(t *testing.T) { - q, err := query.Parse(MustLex("recall(12345,1,12345,2,12345,3)")) - if err != nil { - t.Fatal(err) - } - spew.Dump(q) -} diff --git a/query/planner.go b/query/planner.go deleted file mode 100644 index bc7de4391..000000000 --- a/query/planner.go +++ /dev/null @@ -1,953 +0,0 @@ -package query - -import ( - "encoding/gob" - "errors" - "fmt" - "math/rand" - "time" - - log "github.com/cihub/seelog" - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" -) - -type PortableQueryStep interface { - GetId() *pilosa.GUID - GetLocation() *db.Location -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ERRORS -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// Invalid Frame -type InvalidFrame struct { - Db string - Frame string - Retry bool -} - -func NewInvalidFrame(db string, frame string) *InvalidFrame { - return &InvalidFrame{db, frame, false} -} - -func (self *InvalidFrame) Error() string { - return fmt.Sprintf("Invalid Frame: %s:%s", self.Db, self.Frame) -} - -// Fragment Not Found -type FragmentNotFound struct { - Db string - Frame string - Slice int - Retry bool -} - -func NewFragmentNotFound(db string, frame string, slice int) *FragmentNotFound { - return &FragmentNotFound{db, frame, slice, true} -} - -func (self *FragmentNotFound) Error() string { - return fmt.Sprintf("Fragment Not Found: %s:%s:%d", self.Db, self.Frame, self.Slice) -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// BASE -/////////////////////////////////////////////////////////////////////////////////////////////////// - -type BaseQueryStep struct { - Id *pilosa.GUID - Operation string - Location *db.Location - Destination *db.Location -} - -func (self *BaseQueryStep) GetId() *pilosa.GUID { - log.Trace("BaseQueryStep", *self.Id) - return self.Id -} -func (self *BaseQueryStep) GetLocation() *db.Location { - log.Trace("BaseQueryStep.GetLocation", *self.Location) - return self.Location -} - -func (self *BaseQueryStep) LocIsDest() bool { - log.Trace("BaseQueryStep.LocIsDest") - if self.Location.ProcessId.Equals(self.Destination.ProcessId) && - self.Location.FragmentId == self.Destination.FragmentId { - log.Trace("BaseQueryStep.LocIsDest Return true") - return true - } - log.Trace("BaseQueryStep.LocIsDest Return false") - return false -} - -type BaseQueryResult struct { - Id *pilosa.GUID - Data interface{} -} - -func (self *BaseQueryResult) ResultId() *pilosa.GUID { - log.Trace("BaseQueryStep.ResultId", self) - - return self.Id -} - -func (self *BaseQueryResult) ResultData() interface{} { - log.Trace("BaseQueryStep.ResultData", self) - return self.Data -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// COUNT -/////////////////////////////////////////////////////////////////////////////////////////////////// -type CountQueryStep struct { - *BaseQueryStep - Input *pilosa.GUID -} - -type CountQueryResult struct { - *BaseQueryResult -} - -// QueryTree for COUNT queries -type CountQueryTree struct { - subquery QueryTree - location *db.Location -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *CountQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("CountQueryTree.getLocation", d, qt) - return qt.subquery.getLocation(d) -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// TOP-N -/////////////////////////////////////////////////////////////////////////////////////////////////// -type TopNQueryStep struct { - *BaseQueryStep - Input *pilosa.GUID - Filters []uint64 - N int - Frame string -} - -type TopNQueryResult struct { - *BaseQueryResult -} - -// QueryTree for TOP-N queries -type TopNQueryTree struct { - subquery QueryTree - location *db.Location - Filters []uint64 - N int - Frame string - Slice int -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *TopNQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("TopNQueryTree.getLocation", d, qt) - var err error - if qt.location == nil { - frame := d.GetOrCreateFrame(qt.Frame) - slice := d.GetOrCreateSlice(qt.Slice) - fragment, err := d.GetFragmentForFrameSlice(frame, slice) - if err != nil { - log.Warn("GetFragmentForFrameSliceFailed TopNQueryTree", frame, slice) - return nil, err - } - qt.location = fragment.GetLocation() - return qt.location, nil - } - return qt.location, err -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// UNION -/////////////////////////////////////////////////////////////////////////////////////////////////// -type UnionQueryStep struct { - *BaseQueryStep - Inputs []*pilosa.GUID -} - -type UnionQueryResult struct { - *BaseQueryResult -} - -// QueryTree for UNION queries -type UnionQueryTree struct { - subqueries []QueryTree - location *db.Location -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *UnionQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("UnionQueryTree.getLocation", d, qt) - var err error - if qt.location == nil { - subqueryLength := len(qt.subqueries) - if subqueryLength > 0 { - locationIndex := rand.Intn(subqueryLength) - subquery := qt.subqueries[locationIndex] - qt.location, err = subquery.getLocation(d) - } - } - return qt.location, err -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// INTERSECT -/////////////////////////////////////////////////////////////////////////////////////////////////// -type IntersectQueryStep struct { - *BaseQueryStep - Inputs []*pilosa.GUID -} - -type IntersectQueryResult struct { - *BaseQueryResult -} - -// QueryTree for UNION queries -type IntersectQueryTree struct { - subqueries []QueryTree - location *db.Location -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *IntersectQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("IntersectQueryTree.getLocation", d, qt) - var err error - if qt.location == nil { - subqueryLength := len(qt.subqueries) - if subqueryLength > 0 { - locationIndex := rand.Intn(subqueryLength) - subquery := qt.subqueries[locationIndex] - qt.location, err = subquery.getLocation(d) - } - } - return qt.location, err -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// DIFFERENCE -/////////////////////////////////////////////////////////////////////////////////////////////////// -type DifferenceQueryStep struct { - *BaseQueryStep - Inputs []*pilosa.GUID -} - -type DifferenceQueryResult struct { - *BaseQueryResult -} - -// QueryTree for UNION queries -type DifferenceQueryTree struct { - subqueries []QueryTree - location *db.Location -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *DifferenceQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("DifferenceQueryTree.getLocation", d, qt) - var err error - if qt.location == nil { - subqueryLength := len(qt.subqueries) - if subqueryLength > 0 { - locationIndex := rand.Intn(subqueryLength) - subquery := qt.subqueries[locationIndex] - qt.location, err = subquery.getLocation(d) - } - } - return qt.location, err -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// CAT -/////////////////////////////////////////////////////////////////////////////////////////////////// -type CatQueryStep struct { - *BaseQueryStep - Inputs []*pilosa.GUID - N int -} -type Appendable interface { - Append(subq QueryTree) -} - -type CatQueryResult struct { - *BaseQueryResult -} - -// QueryTree for CAT queries -type CatQueryTree struct { - subqueries []QueryTree - location *db.Location - N int -} - -func (qt *CatQueryTree) Append(subtree QueryTree) { - log.Trace("CatQueryTree.Append", qt, subtree) - qt.subqueries = append(qt.subqueries, subtree) -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *CatQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("CatQueryTree.getLocation", d) - var err error - if qt.location == nil { - subqueryLength := len(qt.subqueries) - if subqueryLength > 0 { - locationIndex := rand.Intn(subqueryLength) - subquery := qt.subqueries[locationIndex] - qt.location, err = subquery.getLocation(d) - } - } - return qt.location, err -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ALL -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// QueryTree for GET queries -type AllQueryTree struct { -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *AllQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("AllQueryTree.getLocation", d) - return nil, nil -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// GET -/////////////////////////////////////////////////////////////////////////////////////////////////// -type GetQueryStep struct { - *BaseQueryStep - Bitmap *db.Bitmap - Slice int -} - -type GetQueryResult struct { - *BaseQueryResult -} - -// QueryTree for GET queries -type GetQueryTree struct { - bitmap *db.Bitmap - slice int -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *GetQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("GetQueryTree.getLocation", d) - slice := d.GetOrCreateSlice(qt.slice) // TODO: this should probably be just GetSlice (no create) - fragment, err := d.GetFragmentForBitmap(slice, qt.bitmap) - if err != nil { - log.Warn("GetFragmenForBitmapFailed GetQueryTree", slice) - return nil, err - } - return fragment.GetLocation(), nil -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// SET -/////////////////////////////////////////////////////////////////////////////////////////////////// -type SetQueryStep struct { - *BaseQueryStep - Bitmap *db.Bitmap - ProfileId uint64 -} - -type SetQueryResult struct { - *BaseQueryResult -} - -// QueryTree for SET queries -type SetQueryTree struct { - bitmap *db.Bitmap - profile_id uint64 -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *SetQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("SetQueryTree.getLocation", d) - // check here for supported frames - if !d.IsValidFrame(qt.bitmap.FrameType) { - return nil, NewInvalidFrame(d.Name, qt.bitmap.FrameType) - } - slice, err := d.GetSliceForProfile(qt.profile_id) - if err != nil { - return nil, NewFragmentNotFound(d.Name, qt.bitmap.FrameType, db.GetSlice(qt.profile_id)) - } - fragment, err := d.GetFragmentForBitmap(slice, qt.bitmap) - if err != nil { - log.Warn("NOT FOUND:", slice, qt.bitmap) - return nil, NewFragmentNotFound(d.Name, qt.bitmap.FrameType, db.GetSlice(qt.profile_id)) - } - return fragment.GetLocation(), nil -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -func init() { - gob.Register(BaseQueryResult{}) - gob.Register(SetQueryResult{}) - gob.Register(ClearQueryResult{}) - gob.Register(GetQueryResult{}) - gob.Register(RangeQueryResult{}) - gob.Register(CatQueryResult{}) - gob.Register(UnionQueryResult{}) - gob.Register(IntersectQueryResult{}) - gob.Register(DifferenceQueryResult{}) - gob.Register(CountQueryResult{}) - gob.Register(TopNQueryResult{}) - gob.Register(FillResult{}) - gob.Register(StashQueryResult{}) - gob.Register(CacheItem{}) - gob.Register(Stash{}) - - gob.Register(SetQueryStep{}) - gob.Register(ClearQueryStep{}) - gob.Register(GetQueryStep{}) - gob.Register(RangeQueryStep{}) - gob.Register(CatQueryStep{}) - gob.Register(UnionQueryStep{}) - gob.Register(IntersectQueryStep{}) - gob.Register(DifferenceQueryStep{}) - gob.Register(CountQueryStep{}) - gob.Register(TopNQueryStep{}) - gob.Register(StashQueryStep{}) -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// This is the output of the query planner. Contains a list of steps which can be performed in parallel -//type QueryPlan []QueryStep -type QueryPlan []interface{} - -type QueryPlanner struct { - Database *db.Database - Query *Query -} -type QueryTree interface { - getLocation(d *db.Database) (*db.Location, error) -} - -func validateRange(Args map[string]interface{}) error { - log.Trace("validateRange", Args) - _, ok := Args["id"] - if !ok { - return errors.New("missing bitmap id") - } - _, ok = Args["frame"] - if !ok { - return errors.New("missing frame ") - } - _, ok = Args["start"] - if !ok { - return errors.New("missing start time") - } - _, ok = Args["end"] - if !ok { - return errors.New("missing end time") - } - return nil -} - -// Builds QueryTree object from Query. Pass slice=-1 to perform operation on all slices -func (self *QueryPlanner) buildTree(query *Query, slice int) (QueryTree, error) { - log.Trace("QueryPlanner.buildTree", query, slice) - var tree QueryTree - // handle SET operation regardless of the slice - if query.Operation == "set" { - tree = &SetQueryTree{&db.Bitmap{Id: query.Args["id"].(uint64), FrameType: query.Args["frame"].(string), Filter: query.Args["filter"].(uint64)}, query.Args["profile_id"].(uint64)} - return tree, nil - } - - if query.Operation == "clear" { - tree = &ClearQueryTree{&db.Bitmap{Id: query.Args["id"].(uint64), FrameType: query.Args["frame"].(string), Filter: query.Args["filter"].(uint64)}, query.Args["profile_id"].(uint64)} - return tree, nil - } - - if query.Operation == "recall" { - tree = &RecallQueryTree{query.Args["stash"].(Stash)} - return tree, nil - } - - // handle the remaining operations, taking slice into consideration - //I'm kinda thinking for stash it needs a differnt handler..i guess for now I'll see if i can use the cathandler - if slice == -1 { - var n int - n_, ok := query.Args["n"] - if ok { - n = n_.(int) - } - var p Appendable - - if query.Operation == "stash" { - tree = &StashQueryTree{N: n} - } else { - tree = &CatQueryTree{N: n} - } - p = tree.(Appendable) - slice_ids, err := self.Database.SliceIds() - if err != nil { - return nil, err - } - for i := range slice_ids { - subtree, err := self.buildTree(query, slice_ids[i]) - if err != nil { - return nil, err - } - p.Append(subtree) - } - } else { - if query.Operation == "get" { - tree = &GetQueryTree{&db.Bitmap{Id: query.Args["id"].(uint64), FrameType: query.Args["frame"].(string), Filter: 0}, slice} - return tree, nil - } else if query.Operation == "range" { - err := validateRange(query.Args) - if err != nil { - return nil, err - } - tree = &RangeQueryTree{ - &db.Bitmap{ - Id: query.Args["id"].(uint64), - FrameType: query.Args["frame"].(string), - Filter: 0}, - slice, - query.Args["start"].(time.Time), - query.Args["end"].(time.Time)} - return tree, nil - } else if query.Operation == "count" { - subquery, err := self.buildTree(&query.Subqueries[0], slice) - if err != nil { - return nil, err - } - tree = &CountQueryTree{subquery: subquery} - } else if query.Operation == "all" { - tree = &AllQueryTree{} - } else if query.Operation == "top-n" { - var frame string - var n int - var filters []uint64 - frame_, ok := query.Args["frame"] - if ok { - frame = frame_.(string) - } - n_, ok := query.Args["n"] - if ok { - n = n_.(int) - } - filters_, ok := query.Args["ids"] - if ok { - filters = filters_.([]uint64) - } - - subquery, err := self.buildTree(&query.Subqueries[0], slice) - if err != nil { - return nil, err - } - tree = &TopNQueryTree{subquery: subquery, Filters: filters, N: n, Frame: frame, Slice: slice} - } else if query.Operation == "union" { - subqueries := make([]QueryTree, len(query.Subqueries)) - var err error - for i, query := range query.Subqueries { - subqueries[i], err = self.buildTree(&query, slice) - if err != nil { - return nil, err - } - } - tree = &UnionQueryTree{subqueries: subqueries} - } else if query.Operation == "intersect" { - subqueries := make([]QueryTree, len(query.Subqueries)) - var err error - for i, query := range query.Subqueries { - subqueries[i], err = self.buildTree(&query, slice) - if err != nil { - return nil, err - } - } - tree = &IntersectQueryTree{subqueries: subqueries} - } else if query.Operation == "difference" { - subqueries := make([]QueryTree, len(query.Subqueries)) - var err error - for i, query := range query.Subqueries { - subqueries[i], err = self.buildTree(&query, slice) - if err != nil { - return nil, err - } - } - tree = &DifferenceQueryTree{subqueries: subqueries} - } else if query.Operation == "stash" { - - subqueries := make([]QueryTree, len(query.Subqueries)) - var err error - for i, query := range query.Subqueries { - subqueries[i], err = self.buildTree(&query, slice) - if err != nil { - return nil, err - } - } - tree = &StashQueryTree{subqueries: subqueries} - } else { - //TODO return error gracefully - log.Warn(spew.Sdump(query)) - return nil, errors.New("BuildTree Issues") - } - } - return tree, nil -} - -// Produces flattened QueryPlan from QueryTree input -func (self *QueryPlanner) flatten(qt QueryTree, id *pilosa.GUID, location *db.Location) (*QueryPlan, error) { - log.Trace("QueryPlanner.flatten", self, qt, id, location) - plan := QueryPlan{} - if cat, ok := qt.(*CatQueryTree); ok { - inputs := make([]*pilosa.GUID, len(cat.subqueries)) - loc, err := cat.getLocation(self.Database) - if err != nil { - return nil, err - } - step := CatQueryStep{&BaseQueryStep{id, "cat", loc, location}, inputs, cat.N} - for index, subq := range cat.subqueries { - sub_id := pilosa.NewGUID() - step.Inputs[index] = &sub_id - subq_steps, err := self.flatten(subq, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - } - plan = append(plan, step) - - } else if stash, ok := qt.(*StashQueryTree); ok { - inputs := make([]*pilosa.GUID, len(stash.subqueries)) - loc, err := stash.getLocation(self.Database) - if err != nil { - return nil, err - } - step := StashQueryStep{&BaseQueryStep{id, "stash", loc, location}, inputs, stash.N} - for index, subq := range stash.subqueries { - sub_id := pilosa.NewGUID() - step.Inputs[index] = &sub_id - subq_steps, err := self.flatten(subq, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - } - plan = append(plan, step) - } else if union, ok := qt.(*UnionQueryTree); ok { - inputs := make([]*pilosa.GUID, len(union.subqueries)) - loc, err := union.getLocation(self.Database) - if err != nil { - return nil, err - } - step := UnionQueryStep{&BaseQueryStep{id, "union", loc, location}, inputs} - for index, subq := range union.subqueries { - sub_id := pilosa.NewGUID() - step.Inputs[index] = &sub_id - subq_steps, err := self.flatten(subq, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - } - plan = append(plan, step) - } else if intersect, ok := qt.(*IntersectQueryTree); ok { - inputs := make([]*pilosa.GUID, len(intersect.subqueries)) - loc, err := intersect.getLocation(self.Database) - if err != nil { - return nil, err - } - step := IntersectQueryStep{&BaseQueryStep{id, "intersect", loc, location}, inputs} - for index, subq := range intersect.subqueries { - sub_id := pilosa.NewGUID() - step.Inputs[index] = &sub_id - subq_steps, err := self.flatten(subq, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - } - plan = append(plan, step) - } else if difference, ok := qt.(*DifferenceQueryTree); ok { - inputs := make([]*pilosa.GUID, len(difference.subqueries)) - loc, err := difference.getLocation(self.Database) - if err != nil { - return nil, err - } - step := DifferenceQueryStep{&BaseQueryStep{id, "difference", loc, location}, inputs} - for index, subq := range difference.subqueries { - sub_id := pilosa.NewGUID() - step.Inputs[index] = &sub_id - subq_steps, err := self.flatten(subq, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - } - plan = append(plan, step) - } else if get, ok := qt.(*GetQueryTree); ok { - loc, err := get.getLocation(self.Database) - if err != nil { - return nil, err - } - step := GetQueryStep{&BaseQueryStep{id, "get", loc, location}, get.bitmap, get.slice} - plan := QueryPlan{step} - return &plan, nil - } else if rang, ok := qt.(*RangeQueryTree); ok { - loc, err := rang.getLocation(self.Database) - if err != nil { - return nil, err - } - step := RangeQueryStep{&BaseQueryStep{id, "range", loc, location}, rang.bitmap, rang.start, rang.end} - plan := QueryPlan{step} - return &plan, nil - } else if set, ok := qt.(*SetQueryTree); ok { - loc, err := set.getLocation(self.Database) - if err != nil { - return nil, err - } - step := SetQueryStep{&BaseQueryStep{id, "set", loc, location}, set.bitmap, set.profile_id} - plan := QueryPlan{step} - return &plan, nil - } else if clear, ok := qt.(*ClearQueryTree); ok { - loc, err := clear.getLocation(self.Database) - if err != nil { - return nil, err - } - step := ClearQueryStep{&BaseQueryStep{id, "clear", loc, location}, clear.bitmap, clear.profile_id} - plan := QueryPlan{step} - return &plan, nil - } else if cnt, ok := qt.(*CountQueryTree); ok { - sub_id := pilosa.NewGUID() - loc, err := cnt.getLocation(self.Database) - if err != nil { - return nil, err - } - step := &CountQueryStep{&BaseQueryStep{id, "count", loc, location}, &sub_id} - subq_steps, err := self.flatten(cnt.subquery, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - plan = append(plan, step) - } else if topn, ok := qt.(*TopNQueryTree); ok { - sub_id := pilosa.NewGUID() - loc, err := topn.getLocation(self.Database) - if err != nil { - return nil, err - } - step := &TopNQueryStep{&BaseQueryStep{id, "top-n", loc, location}, nil, topn.Filters, topn.N, topn.Frame} - switch topn.subquery.(type) { - case *AllQueryTree: - // do nothing - default: - step.Input = &sub_id - subq_steps, err := self.flatten(topn.subquery, &sub_id, loc) - if err != nil { - return nil, err - } - plan = append(plan, *subq_steps...) - } - plan = append(plan, step) - } - return &plan, nil -} - -// Transforms Query into QueryTree and flattens to QueryPlan object -func (self *QueryPlanner) Plan(query *Query, id *pilosa.GUID, destination *db.Location) (*QueryPlan, error) { - log.Trace("QueryPlanner.Plan", self, query, id, destination) - queryTree, err := self.buildTree(query, -1) - if err != nil { - return nil, err - } - return self.flatten(queryTree, query.Id, destination) -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -//MASK -/////////////////////////////////////////////////////////////////////////////////////////////////// -type MaskQueryStep struct { - *BaseQueryStep - start, end uint64 -} - -type MaskQueryResult struct { - *BaseQueryResult -} - -// QueryTree for Mask queries -type MaskQueryTree struct { - start, end uint64 - bitmap *db.Bitmap -} - -// Uses consistent hashing function to select node containing data for GET operation -/* -func (qt *MaskQueryTree) getLocation(d *db.Database) (*db.Location, error) { - slice := d.GetOrCreateSlice(qt.slice) // TODO: this should probably be just GetSlice (no create) - fragment, err := d.GetFragmentForBitmap(slice, qt.bitmap) - if err != nil { - log.Warn("GetFragmenForBitmapFailed GetQueryTree", slice) - return nil, err - } - return fragment.GetLocation(), nil -} -*/ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -//Range -/////////////////////////////////////////////////////////////////////////////////////////////////// -type RangeQueryStep struct { - *BaseQueryStep - Bitmap *db.Bitmap - Start, End time.Time -} - -type RangeQueryResult struct { - *BaseQueryResult -} - -// QueryTree for Mask queries -type RangeQueryTree struct { - bitmap *db.Bitmap - slice int - start, end time.Time -} - -func (qt *RangeQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("RangeQueryTree", qt, d) - slice := d.GetOrCreateSlice(qt.slice) // TODO: this should probably be just GetSlice (no create) - fragment, err := d.GetFragmentForBitmap(slice, qt.bitmap) - if err != nil { - log.Warn("GetFragmenForBitmapFailed GetQueryTree", slice) - return nil, err - } - return fragment.GetLocation(), nil -} - -type FillResult struct { - *BaseQueryResult -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -//Stash -/////////////////////////////////////////////////////////////////////////////////////////////////// - -type CacheItem struct { - FragmentId pilosa.SUUID - Handle pilosa.BitmapHandle -} - -type Stash struct { - Stash []CacheItem //pilosa.BitmapHandle //probably need to make the a struct with fragment_id and handle - incomplete bool -} - -func NewStash() Stash { - return Stash{make([]CacheItem, 0), false} -} - -func (st *Stash) Add(i pilosa.SUUID) { - item := CacheItem{i, 0} - st.Stash = append(st.Stash, item) - st.incomplete = true -} - -func (st *Stash) Assign(i pilosa.BitmapHandle) { - st.Stash[len(st.Stash)-1].Handle = i //big assumption that item already exists - st.incomplete = false -} - -type StashQueryStep struct { - *BaseQueryStep - Inputs []*pilosa.GUID - N int -} - -type StashQueryResult struct { - *BaseQueryResult -} - -// QueryTree for UNION queries -type StashQueryTree struct { - subqueries []QueryTree - location *db.Location - N int -} - -func (qt *StashQueryTree) Append(subtree QueryTree) { - qt.subqueries = append(qt.subqueries, subtree) -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *StashQueryTree) getLocation(d *db.Database) (*db.Location, error) { - var err error - if qt.location == nil { - subqueryLength := len(qt.subqueries) - if subqueryLength > 0 { - locationIndex := rand.Intn(subqueryLength) - subquery := qt.subqueries[locationIndex] - qt.location, err = subquery.getLocation(d) - } - } - return qt.location, err -} - -type RecallQueryStep struct { - *BaseQueryStep - Stash Stash -} -type RecallQueryTree struct { - Stash Stash -} - -func (rqt *RecallQueryTree) getLocation(d *db.Database) (*db.Location, error) { - return nil, nil -} - -type RecallQueryResult struct { - *BaseQueryResult -} - -type ClearQueryStep struct { - *BaseQueryStep - Bitmap *db.Bitmap - ProfileId uint64 -} - -type ClearQueryResult struct { - *BaseQueryResult -} - -type ClearQueryTree struct { - bitmap *db.Bitmap - profile_id uint64 -} - -// Uses consistent hashing function to select node containing data for GET operation -func (qt *ClearQueryTree) getLocation(d *db.Database) (*db.Location, error) { - log.Trace("ClearQueryTree.getLocation", d) - // check here for supported frames - if !d.IsValidFrame(qt.bitmap.FrameType) { - return nil, NewInvalidFrame(d.Name, qt.bitmap.FrameType) - } - slice, err := d.GetSliceForProfile(qt.profile_id) - if err != nil { - return nil, NewFragmentNotFound(d.Name, qt.bitmap.FrameType, db.GetSlice(qt.profile_id)) - } - fragment, err := d.GetFragmentForBitmap(slice, qt.bitmap) - if err != nil { - log.Warn("NOT FOUND:", slice, qt.bitmap) - return nil, NewFragmentNotFound(d.Name, qt.bitmap.FrameType, db.GetSlice(qt.profile_id)) - } - return fragment.GetLocation(), nil -} diff --git a/query/planner_example.go b/query/planner_example.go deleted file mode 100644 index 02affe0a5..000000000 --- a/query/planner_example.go +++ /dev/null @@ -1,67 +0,0 @@ -package query - -//package main -// -//import ( -// "pilosa/query" -// "pilosa/core" -// "math/rand" -// "time" -// "log" -//) -// -//func main() { -// rand.Seed(time.Now().UnixNano()) -// cluster := core.Cluster{Self:"192.168.1.100:1201"} -// database := cluster.AddDatabase("property49") -// frame := database.AddFrame("general") -// frame.AddSlice("192.168.1.100:1201", "192.168.1.100:1202", "192.168.1.100:1203") -// frame.AddSlice("192.168.1.101:1201", "192.168.1.101:1202", "192.168.1.101:1203") -// frame.AddSlice("192.168.1.102:1201", "192.168.1.102:1202", "192.168.1.102:1203") -// frame2 := database.AddFrame("brands") -// frame2.AddSlice("192.168.1.200:1201", "192.168.1.200:1202", "192.168.1.200:1203") -// frame2.AddSlice("192.168.1.201:1201", "192.168.1.201:1202", "192.168.1.201:1203") -// frame2.AddSlice("192.168.1.202:1201", "192.168.1.202:1202", "192.168.1.202:1203") -// -// //cluster.describe() -// -// //query := Query{"get", []QueryInput{Bitmap{"general", 10}}} -// -// //query := Query{"union", []QueryInput{ -// // &Query{"get", []QueryInput{Bitmap{"general", 20}}}, -// // &Query{"get", []QueryInput{Bitmap{"brands", 30}}}, -// //}} -// -// //queryString = "union(bitmap(general, 33), bitmap(brands, 44))" -// //queryString := `["union", ["intersect", ["bitmap", "general", 33], ["bitmap", "brands", 44]], ["bitmap", "general", 55]]` -// //query := `count(union(bitmap(""), bitmap(brands, 55)))` -// //query := `setbit(bitmap(cats, 33), 75000)` -// queryString := `["union", ["intersect", ["bitmap", "general", 33], ["bitmap", "brands", 44]], ["bitmap", "general", 55]]` -// queryParser := query.QueryParser{queryString} -// queryParsed, err := queryParser.Parse() -// log.Println(queryParsed) -// if err != nil { -// log.Println("ERROR!", err) -// } -// -//// query := qp.Query{"inter", []qp.QueryInput{ -//// &qp.Query{"union", []qp.QueryInput{ -//// &qp.Query{"get", []qp.QueryInput{core.Bitmap{"general", 20}}}, -//// &qp.Query{"get", []qp.QueryInput{core.Bitmap{"brands", 30}}}, -//// }}, -//// &qp.Query{"get", []qp.QueryInput{core.Bitmap{"general", 10}}}, -//// }} -//// -// planner := query.QueryPlanner{&cluster, database} -// -// id, _ := uuid.NewV4() -// dest := "1.2.3.4:1234" -// log.Println("Query id", id, "Dest", dest) -// -// queryplan := planner.Plan(queryParsed, id, dest, -1) -// -// for _, i := range *queryplan { -// log.Println(i) -// } -// //fmt.Println(queryplan) -//} diff --git a/query/planner_test.go b/query/planner_test.go deleted file mode 100644 index bc71fc4eb..000000000 --- a/query/planner_test.go +++ /dev/null @@ -1,283 +0,0 @@ -package query_test - -import ( - "reflect" - "testing" - - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa/db" - "github.com/umbel/pilosa/query" - "github.com/umbel/pilosa/util" -) - -// Ensure the query planner can plan a "get" query. -func TestQueryPlanner_Plan_Get(t *testing.T) { - q, err := query.QueryForPQL("get(10,default)") - if err != nil { - t.Fatal(err) - } - - d, frag1 := NewDefaultDB() - planner := query.QueryPlanner{Database: d, Query: q} - - id := util.RandomUUID() - plan, err := planner.Plan(q, &id, frag1.GetLocation()) - if err != nil { - t.Fatal(err) - } - - if n := len(*plan); n != 3 { - t.Fatalf("unexpected plan length: %d", n) - } - - if step := (*plan)[0].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(0) operation: %s", step.Operation) - } else if step.Slice != 0 { - t.Fatalf("unexpected step(0) slice: %d", step.Slice) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(0) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - if step := (*plan)[1].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(1) operation: %s", step.Operation) - } else if step.Slice != 1 { - t.Fatalf("unexpected step(1) slice: %d", step.Slice) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(1) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - if step := (*plan)[2].(query.CatQueryStep); step.Operation != "cat" { - t.Fatalf("unexpected step(2) operation: %s", step.Operation) - } else if !reflect.DeepEqual(step.Inputs, []*pilosa.GUID{ - (*plan)[0].(query.GetQueryStep).Id, - (*plan)[1].(query.GetQueryStep).Id, - }) { - t.Fatalf("unexpected step(2) inputs: %s", spew.Sprint(step.Inputs)) - } -} - -// Ensure the query planner can plan a "set" query. -func TestQueryPlanner_Plan_Set(t *testing.T) { - q, err := query.QueryForPQL("set(10, default, 0, 100)") - if err != nil { - t.Fatal(err) - } - - d, frag1 := NewDefaultDB() - planner := query.QueryPlanner{Database: d, Query: q} - - id := util.RandomUUID() - plan, err := planner.Plan(q, &id, frag1.GetLocation()) - if err != nil { - t.Fatal(err) - } - - if n := len(*plan); n != 1 { - t.Fatalf("unexpected plan length: %d", n) - } - - if step := (*plan)[0].(query.SetQueryStep); step.Operation != "set" { - t.Fatalf("unexpected step(0) operation: %s", step.Operation) - } else if step.ProfileId != 100 { - t.Fatalf("unexpected step(0) profile id: %d", step.ProfileId) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(0) bitmap: %s", spew.Sprint(step.Bitmap)) - } -} - -// Ensure the query planner can plan a "top-n" query. -func TestQueryPlanner_Plan_TopN(t *testing.T) { - q, err := query.QueryForPQL("top-n(get(10, default), default, 50,[1,2,3])") - if err != nil { - t.Fatal(err) - } - - d, frag1 := NewDefaultDB() - planner := query.QueryPlanner{Database: d, Query: q} - - id := util.RandomUUID() - plan, err := planner.Plan(q, &id, frag1.GetLocation()) - if err != nil { - t.Fatal(err) - } - - if n := len(*plan); n != 5 { - t.Fatalf("unexpected plan length: %d", n) - } - - if step := (*plan)[0].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(0) operation: %s", step.Operation) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(0) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - if step := (*plan)[1].(*query.TopNQueryStep); step.Operation != "top-n" { - t.Fatalf("unexpected step(1) operation: %s", step.Operation) - } else if step.Input != (*plan)[0].(query.GetQueryStep).Id { - t.Fatalf("unexpected step(1) input: %d", step.Input) - } else if step.N != 50 { - t.Fatalf("unexpected step(1) n: %d", step.N) - } else if !reflect.DeepEqual(step.Filters, []uint64{1, 2, 3}) { - t.Fatalf("unexpected step(1) filters: %s", spew.Sprint(step.Filters)) - } - - if step := (*plan)[2].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(2) operation: %s", step.Operation) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(2) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - if step := (*plan)[3].(*query.TopNQueryStep); step.Operation != "top-n" { - t.Fatalf("unexpected step(3) operation: %s", step.Operation) - } else if step.Input != (*plan)[2].(query.GetQueryStep).Id { - t.Fatalf("unexpected step(3) input: %d", step.Input) - } else if step.N != 50 { - t.Fatalf("unexpected step(3) n: %d", step.N) - } -} - -// Ensure the query planner can plan a "top-n" all() query. -func TestQueryPlanner_Plan_TopN_All(t *testing.T) { - q, err := query.QueryForPQL("top-n(all(), default, 50, [1,2,3])") - if err != nil { - t.Fatal(err) - } - - d, frag1 := NewDefaultDB() - planner := query.QueryPlanner{Database: d, Query: q} - - id := util.RandomUUID() - plan, err := planner.Plan(q, &id, frag1.GetLocation()) - if err != nil { - t.Fatal(err) - } - - if n := len(*plan); n != 3 { - t.Fatalf("unexpected plan length: %d", n) - } - - if step := (*plan)[0].(*query.TopNQueryStep); step.Operation != "top-n" { - t.Fatalf("unexpected step(0) operation: %s", step.Operation) - } else if step.Input != nil { - t.Fatalf("unexpected step(0) input: %v", step.Input) - } else if step.N != 50 { - t.Fatalf("unexpected step(0) n: %d", step.N) - } else if !reflect.DeepEqual(step.Filters, []uint64{1, 2, 3}) { - t.Fatalf("unexpected step(0) filters: %s", spew.Sprint(step.Filters)) - } -} - -// Ensure the query planner can plan a "union" query. -func TestQueryPlanner_Plan_Union(t *testing.T) { - id1 := util.RandomUUID() - q1 := query.Query{Id: &id1, Operation: "get", Args: map[string]interface{}{"id": uint64(10), "frame": "default"}} - - id2 := util.RandomUUID() - q2 := query.Query{Id: &id2, Operation: "get", Args: map[string]interface{}{"id": uint64(20), "frame": "default"}} - - id3 := util.RandomUUID() - q := query.Query{Id: &id3, Operation: "union", Subqueries: []query.Query{q1, q2}} - - d, frag1 := NewDefaultDB() - planner := query.QueryPlanner{Database: d, Query: &q} - - id := util.RandomUUID() - plan, err := planner.Plan(&q, &id, frag1.GetLocation()) - if err != nil { - t.Fatal(err) - } - - if n := len(*plan); n != 7 { - t.Fatalf("unexpected plan size: %d", n) - } - - // First step should be a "get" step. - if step := (*plan)[0].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(0) operation: %s", step.Operation) - } else if step.Slice != 0 { - t.Fatalf("unexpected step(0) slice: %d", step.Slice) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(0) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - // Second step should also be a "get" step. - if step := (*plan)[1].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(1) operation: %s", step.Operation) - } else if step.Slice != 0 { - t.Fatalf("unexpected step(1) slice: %d", step.Slice) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 20, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(1) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - // Third step should union the first two steps. - if step := (*plan)[2].(query.UnionQueryStep); step.Operation != "union" { - t.Fatalf("unexpected step(2) operation: %s", step.Operation) - } else if !reflect.DeepEqual(step.Inputs, []*pilosa.GUID{ - (*plan)[0].(query.GetQueryStep).Id, - (*plan)[1].(query.GetQueryStep).Id, - }) { - t.Fatalf("unexpected step(2) inputs: %s", spew.Sprint(step.Inputs)) - } - - // Fourth step should be a "get" step. - if step := (*plan)[3].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(3) operation: %s", step.Operation) - } else if step.Slice != 1 { - t.Fatalf("unexpected step(3) slice: %d", step.Slice) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 10, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(3) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - // Fifth step should also be a "get" step. - if step := (*plan)[4].(query.GetQueryStep); step.Operation != "get" { - t.Fatalf("unexpected step(4) operation: %s", step.Operation) - } else if step.Slice != 1 { - t.Fatalf("unexpected step(4) slice: %d", step.Slice) - } else if !reflect.DeepEqual(step.Bitmap, &db.Bitmap{Id: 20, FrameType: "default", Filter: 0}) { - t.Fatalf("unexpected step(4) bitmap: %s", spew.Sprint(step.Bitmap)) - } - - // Sixth step should union the previous two steps. - if step := (*plan)[5].(query.UnionQueryStep); step.Operation != "union" { - t.Fatalf("unexpected step(5) operation: %s", step.Operation) - } else if !reflect.DeepEqual(step.Inputs, []*pilosa.GUID{ - (*plan)[3].(query.GetQueryStep).Id, - (*plan)[4].(query.GetQueryStep).Id, - }) { - t.Fatalf("unexpected step(5) inputs: %s", spew.Sprint(step.Inputs)) - } - - // Final step should concatenate the two union steps. - if step := (*plan)[6].(query.CatQueryStep); step.Operation != "cat" { - t.Fatalf("unexpected step(6) operation: %s", step.Operation) - } else if !reflect.DeepEqual(step.Inputs, []*pilosa.GUID{ - (*plan)[2].(query.UnionQueryStep).Id, - (*plan)[5].(query.UnionQueryStep).Id, - }) { - t.Fatalf("unexpected step(6) inputs: %s", spew.Sprint(step.Inputs)) - } -} - -// NewDefaultDB returns a simple, initialized database and fragment. -func NewDefaultDB() (*db.Database, *db.Fragment) { - // Create an empty database - c := db.NewCluster() - d := c.GetOrCreateDatabase("main") - f := d.GetOrCreateFrame("default") - - s1 := d.GetOrCreateSlice(0) - frag1 := d.GetOrCreateFragment(f, s1, util.Id()) - pid := util.RandomUUID() - p1 := db.NewProcess(&pid) - p1.SetHost("----192.1.1.0----") - frag1.SetProcess(p1) - - s2 := d.GetOrCreateSlice(1) - frag2 := d.GetOrCreateFragment(f, s2, util.Id()) - pid = util.RandomUUID() - p2 := db.NewProcess(&pid) - p2.SetHost("----192.1.1.1----") - frag2.SetProcess(p2) - - return d, frag1 -} diff --git a/query/query.go b/query/query.go deleted file mode 100644 index b50c904e8..000000000 --- a/query/query.go +++ /dev/null @@ -1,111 +0,0 @@ -package query - -import ( - "strings" - - log "github.com/cihub/seelog" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/db" -) - -type QueryInput interface{} - -type QueryResults struct { - Data interface{} -} - -type PqlList []PqlListItem - -type PqlListItem struct { - Id *pilosa.GUID - Label string - PQL string -} - -type Query struct { - Id *pilosa.GUID - Operation string - Args map[string]interface{} - Subqueries []Query -} - -func QueryPlanForPQL(database *db.Database, pql string, destination *db.Location) (*QueryPlan, error) { - log.Trace("QueryPlanFOrPQL", database, pql, destination) - tokens, err := Lex(pql) - if err != nil { - return nil, err - } - return QueryPlanForTokens(database, tokens, destination) -} - -func QueryForPQL(pql string) (*Query, error) { - log.Trace("QueryForPQL", pql) - tokens, err := Lex(pql) - if err != nil { - return nil, err - } - return QueryForTokens(tokens) -} - -func QueryForTokens(tokens []Token) (*Query, error) { - log.Trace("QueryForTokens", tokens) - query, err := Parse(tokens) - if err != nil { - return nil, err - } - return query, nil -} - -func QueryPlanForTokens(database *db.Database, tokens []Token, destination *db.Location) (*QueryPlan, error) { - log.Trace("QueryPlanForTokens", database, tokens, destination) - query, err := QueryForTokens(tokens) - if err != nil { - return nil, err - } - return QueryPlanForQuery(database, query, destination) -} - -func QueryPlanForQuery(database *db.Database, query *Query, destination *db.Location) (*QueryPlan, error) { - log.Trace("QueryPlanForQuery", database, query, destination) - query_planner := QueryPlanner{Database: database, Query: query} - id := pilosa.NewGUID() - query_plan, err := query_planner.Plan(query, &id, destination) - if err != nil { - return nil, err - } - return query_plan, nil -} - -func TokensToFilterStrings(tokens []Token) (string, []string) { - log.Trace("TokensToFilterStrings", tokens) - var whole []string - var filter string - var filters []string - var open_parens int - var in_square_brackets bool - var last_slice = 0 - - open_parens = -1 - in_square_brackets = false - for i, _ := range tokens { - whole = append(whole, tokens[i].Text) - if tokens[i].Type == TYPE_FUNC { - last_slice = i - } else if tokens[i].Type == TYPE_LP { - open_parens += 1 - } else if tokens[i].Type == TYPE_RP { - open_parens -= 1 - if open_parens == 0 { - if !in_square_brackets { - filter = strings.Join(whole[2:], "") - } else { - filters = append(filters, strings.Join(whole[last_slice:], "")) - } - last_slice = i - } - } else if open_parens == 0 && tokens[i].Type == TYPE_LB { - in_square_brackets = true - } - } - return filter, filters -} diff --git a/query/query_test.go b/query/query_test.go deleted file mode 100644 index 5850295b6..000000000 --- a/query/query_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package query_test - -import ( - "reflect" - "testing" - - "github.com/davecgh/go-spew/spew" - "github.com/umbel/pilosa/query" -) - -func TestTokensToFilterStrings1(t *testing.T) { - filter, filters := query.TokensToFilterStrings(MustLex("plugin(get(88, general), [get(12, general), get(13, general)])")) - if filter != "get(88,general)" { - t.Fatalf("unexpected filter: %s", filter) - } else if !reflect.DeepEqual(filters, []string{"get(12,general)", "get(13,general)"}) { - t.Fatalf("unexpected filters: %s", spew.Sprint(filters)) - } -} - -func TestTokensToFilterStrings2(t *testing.T) { - filter, filters := query.TokensToFilterStrings(MustLex("plugin(intersect(get(88, general, [0]), get(77, b.n)), [get(12, general), get(13, general)])")) - if filter != "intersect(get(88,general,[0]),get(77,b.n))" { - t.Fatalf("unexpected filter: %s", filter) - } else if !reflect.DeepEqual(filters, []string{"get(12,general)", "get(13,general)"}) { - t.Fatalf("unexpected filters: %s", spew.Sprint(filters)) - } -} - -func TestTokensToFilterStrings3(t *testing.T) { - filter, filters := query.TokensToFilterStrings(MustLex("plugin(intersect(get(88, general, [0]), get(77, b.n)))")) - if filter != "intersect(get(88,general,[0]),get(77,b.n))" { - t.Fatalf("unexpected filter: %s", filter) - } else if !reflect.DeepEqual(filters, []string(nil)) { - t.Fatalf("unexpected filters: %s", spew.Sprint(filters)) - } -} diff --git a/statsd/statd.go b/statsd/statd.go deleted file mode 100644 index 4ca32bed6..000000000 --- a/statsd/statd.go +++ /dev/null @@ -1,65 +0,0 @@ -package statsd - -import ( - "time" - - "github.com/cactus/go-statsd-client/statsd" - log "github.com/cihub/seelog" -) - -// DefaultHost is the default host to send statsd data to. -const DefaultHost = "127.0.0.1:8125" - -// Host is the host to send statsd data to. -var Host = DefaultHost - -type args struct { - stat string - delta int64 - rate float32 -} - -var timer chan args -var count chan string -var end chan bool - -func Setup() { - timer = make(chan args, 32768) - count = make(chan string, 32768) - end = make(chan bool) - - log.Warn("New Stats", Host) - stats, _ := statsd.New(Host, "") - - go func() { - for { - select { - case ci := <-timer: - stats.Gauge(ci.stat, ci.delta, ci.rate) - stats.Timing(ci.stat, ci.delta, ci.rate) - case stat := <-count: - stats.Inc(stat, 1, 1.0) - case <-end: - log.Warn("DONE Stats") - return - - } - } - }() -} - -func SendTimer(stat string, delta int64) { - pstat := "pilosa." + stat - milli := time.Duration(delta) / time.Millisecond - timer <- args{pstat, int64(milli), 1.0} -} - -func SendInc(stat string) { - pstat := "pilosa." + stat - count <- pstat -} - -func ShutdownStats() { - log.Warn("Shutdown Stats") - end <- true -} diff --git a/storage.go b/storage.go deleted file mode 100644 index 679daab67..000000000 --- a/storage.go +++ /dev/null @@ -1,49 +0,0 @@ -package pilosa - -// Storage represents -type Storage interface { - Open() error - Close() error - Flush() - - Fetch(bitmap_id uint64, db, frame string, slice int) (*Bitmap, uint64) - Store(id uint64, db, frame string, slice int, filter uint64, bitmap *Bitmap) error - - StoreBlock(id uint64, db, frame string, slice int, filter uint64, chunk uint64, block_index int32, block uint64) error - RemoveBlock(id uint64, db, frame string, slice int, chunk uint64, block_index int32) - - StoreBit(bid uint64, db, frame string, slice int, filter uint64, chunk uint64, block_index int32, block, count uint64) - RemoveBit(id uint64, db, frame string, slice int, filter uint64, chunk uint64, block_index int32, count uint64) -} - -var storageFns = make(map[string]NewStorageFunc) - -// NewStorageFunc represents a function that instantiates a new storage engine. -type NewStorageFunc func(opt StorageOptions) Storage - -// RegisterStorage registers a storage engine. -func RegisterStorage(name string, fn NewStorageFunc) { - if storageFns[name] != nil { - panic("storage engine already registered: " + name) - } - storageFns[name] = fn -} - -// NewStorage returns a new Storage instance by name. -func NewStorage(name string, opt StorageOptions) Storage { - fn := storageFns[name] - if fn == nil { - panic("storage type not registered: " + name) - } - return fn(opt) -} - -// StorageOptions represents the options passed to the storage engine. -type StorageOptions struct { - DB string - Slice int - Frame string - FragmentID SUUID - - LevelDBPath string -} diff --git a/storage/cassandra/cassandra.go b/storage/cassandra/cassandra.go deleted file mode 100644 index 9ec0adcba..000000000 --- a/storage/cassandra/cassandra.go +++ /dev/null @@ -1,244 +0,0 @@ -package cassandra - -import ( - "time" - - log "github.com/cihub/seelog" - "github.com/gocql/gocql" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/statsd" -) - -func init() { - pilosa.RegisterStorage("cassandra", - func(opt pilosa.StorageOptions) pilosa.Storage { - return NewStorage(opt) - }, - ) -} - -// CREATE KEYSPACE IF NOT EXISTS pilosa WITH strategy_class = SimpleStrategy AND strategy_options:replication_factor = 1" -// create keyspace if not exists pilosa with replication = {'class': 'SimpleStrategy', 'replication_factor' : 1} and durable_writes = true; -// CREATE KEYSPACE pilosa WITH replication = {'class': 'NetworkTopologyStrategy', 'pilpang': '2'} AND durable_writes = true; -// CREATE TABLE IF NOT EXISTS bitmap (bitmap_id bigint, db varchar, frame varchar, slice int, filter int, chunkkey bigint, blockindex int, block bigint, PRIMARY KEY ((bitmap_id, db, frame, slice), chunkkey, blockindex) ) - -// DefaultHosts are the default hosts in the cassandra cluster. -var DefaultHosts = []string{"localhost"} - -const ( - // DefaultKeyspace is the default keyspace used in cassandra. - DefaultKeyspace = "pilosa" - - // DefaultFlushInterval is the default maximum time between flushes. - DefaultFlushInterval = 5 * time.Second - - // DefaultFlushThreshold is the default maximum number of items to batch. - DefaultFlushThreshold = 15 -) - -// Storage represents Cassandra-backed storage for bitmaps. -type Storage struct { - session *gocql.Session - - batch *gocql.Batch - batchTime time.Time - batchN int - - FlushInterval time.Duration - FlushThreshold int - - Hosts []string - Keyspace string -} - -// NewStorage returns a new, uninitialized instance of Storage. -func NewStorage(opt pilosa.StorageOptions) *Storage { - return &Storage{ - batchTime: time.Now(), - - FlushInterval: DefaultFlushInterval, - FlushThreshold: DefaultFlushThreshold, - - Hosts: DefaultHosts, - Keyspace: DefaultKeyspace, - } -} - -// Open opens the connection to the cassandra cluster. -func (s *Storage) Open() error { - // Create cluster configuration. - config := gocql.NewCluster(s.Hosts...) - config.Keyspace = s.Keyspace - config.Consistency = gocql.One - config.Timeout = 5 * time.Second - config.RetryPolicy = &gocql.SimpleRetryPolicy{NumRetries: 10} - - // Connect to cassandra. - session, err := config.CreateSession() - if err != nil { - return err - } - s.session = session - - return nil -} - -// Close closes the connection to the cassandra cluster. -func (s *Storage) Close() error { - if s.session != nil { - s.Flush() - s.session.Close() - } - - return nil -} - -// Fetch returns a bitmap by ID. -func (s *Storage) Fetch(bitmapID uint64, db string, frame string, slice int) (*pilosa.Bitmap, uint64) { - bm := pilosa.NewBitmap() - - // Start benchmark. - start := time.Now() - - // Create iterator over bitmap. - itr := s.session.Query("SELECT filter, Chunkkey, BlockIndex, block FROM bitmap WHERE bitmap_id=? AND db=? AND frame=? AND slice=? ", - u64toi64(bitmapID), db, frame, slice).Iter() - - // Iterate over chunks and materialize bitmap object. - var chunk *pilosa.Chunk - var chunkKey, block, count int64 - var blockIndex uint32 - var filter int - lastKey := int64(-1) - - for itr.Scan(&filter, &chunkKey, &blockIndex, &block) { - if chunkKey != int64(-1) { - if chunkKey != lastKey { - chunk = &pilosa.Chunk{uint64(chunkKey), pilosa.NewBlocks()} - bm.AddChunk(chunk) - } - chunk.Value[uint8(blockIndex)] = uint64(block) - } else { - count = block - } - lastKey = chunkKey - } - - statsd.SendTimer("cassandra_storage_Fetch", time.Since(start).Nanoseconds()) - statsd.SendInc("cassandra_storage_Read") - - // Set total bits set. - bm.SetCount(uint64(count)) - return bm, uint64(filter) -} - -// beginBatch starts a batch if one is not already in progress. -func (s *Storage) beginBatch() { - if s.batch == nil { - s.batch = gocql.NewBatch(gocql.UnloggedBatch) - } - s.batchN++ -} - -// endBatch flushes a batch if one is in progress. -func (s *Storage) endBatch() { - if s.batch == nil { - return - } - - start := time.Now() - s.Flush() - statsd.SendTimer("cassandra_storage_EndBatch", time.Since(start).Nanoseconds()) - statsd.SendInc("cassandra_storage_Write") -} - -// Flush flushes the current batch to storage. -func (s *Storage) Flush() { - start := time.Now() - - // If batch exists then flush it. - if s.batch != nil { - if err := s.session.ExecuteBatch(s.batch); err != nil { - log.Warn("Batch ERROR: ", err) - } - } - - // Clear batch and threshold time and count. - s.batch = nil - s.batchTime = time.Now() - s.batchN = 0 - - statsd.SendTimer("cassandra_storage_FlushBatch", time.Since(start).Nanoseconds()) -} - -// Store saves a bitmap to storage. -func (s *Storage) Store(id uint64, db string, frame string, slice int, filter uint64, bm *pilosa.Bitmap) error { - s.beginBatch() - - for i := bm.ChunkIterator(); !i.Limit(); i = i.Next() { - var chunk = i.Item() - for idx, block := range chunk.Value { - if block != 0 { - s.StoreBlock(id, db, frame, slice, filter, chunk.Key, int32(idx), block) - } - } - } - - s.StoreBlock(id, db, frame, slice, filter, pilosa.CounterMask, 0, bm.BitCount()) - s.endBatch() - return nil -} - -// StoreBlock saves a block to storage. -func (s *Storage) StoreBlock(bid uint64, db string, frame string, slice int, filter uint64, bchunk uint64, blockIndex int32, bblock uint64) error { - id := u64toi64(bid) // these functions ignore overflow - block := u64toi64(bblock) - chunk := u64toi64(bchunk) - - if s.batch == nil { - s.beginBatch() - } - - start := time.Now() - s.batch.Query(`INSERT INTO bitmap ( bitmap_id, db, frame, slice , filter, ChunkKey, BlockIndex, block) VALUES (?,?,?,?,?,?,?,?) USING timestamp ?;`, - id, db, frame, slice, int(filter), chunk, blockIndex, block, start.UnixNano()) - statsd.SendTimer("cassandra_storage_StoreBlock", time.Since(start).Nanoseconds()) - - return nil -} - -// RemoveBlock deletes a block from storage. -func (s *Storage) RemoveBlock(bid uint64, db string, frame string, slice int, bchunk uint64, blockIndex int32) { - log.Trace("RemoveBlock", bid, db, frame, slice, bchunk, blockIndex) - - id := u64toi64(bid) //these fucntions ignore overflow - chunk := u64toi64(bchunk) - - if s.batch == nil { - s.beginBatch() - } - - startTime := time.Now() - - s.batch.Query(`DELETE FROM bitmap USING TIMESTAMP ? WHERE bitmap_id=? AND db=? AND frame=? AND slice=? AND chunkkey=? AND blockindex=?`, - startTime.UnixNano(), id, db, frame, slice, chunk, blockIndex) - - statsd.SendTimer("cassandra_storage_DeleteBlock", time.Since(startTime).Nanoseconds()) -} - -func (s *Storage) StoreBit(bid uint64, db string, frame string, slice int, filter uint64, chunk uint64, blockIndex int32, val, count uint64) { - s.beginBatch() - s.StoreBlock(bid, db, frame, slice, filter, chunk, blockIndex, val) - s.StoreBlock(bid, db, frame, slice, filter, pilosa.CounterMask, 0, count) - s.endBatch() -} - -func (s *Storage) RemoveBit(id uint64, db string, frame string, slice int, filter uint64, chunk uint64, blockIndex int32, count uint64) { - log.Trace("RemoveBit", id, db, frame, slice, chunk, blockIndex) - s.beginBatch() - s.RemoveBlock(id, db, frame, slice, chunk, blockIndex) - s.StoreBlock(id, db, frame, slice, filter, pilosa.CounterMask, 0, count) - s.endBatch() -} - -func u64toi64(v uint64) int64 { return int64(v) } diff --git a/storage/cassandra/cassandra_test.go b/storage/cassandra/cassandra_test.go deleted file mode 100644 index 702552410..000000000 --- a/storage/cassandra/cassandra_test.go +++ /dev/null @@ -1 +0,0 @@ -package cassandra_test diff --git a/storage/leveldb/leveldb.go b/storage/leveldb/leveldb.go deleted file mode 100644 index 5a78afca6..000000000 --- a/storage/leveldb/leveldb.go +++ /dev/null @@ -1,222 +0,0 @@ -package leveldb - -import ( - "bytes" - "encoding/binary" - "path/filepath" - "strconv" - "time" - - "github.com/syndtr/goleveldb/leveldb" - . "github.com/syndtr/goleveldb/leveldb/util" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/statsd" -) - -func init() { - pilosa.RegisterStorage("leveldb", - func(opt pilosa.StorageOptions) pilosa.Storage { - return NewStorage(opt) - }, - ) -} - -//go get github.com/syndtr/goleveldb/leveldb - -// Storage represents a LevelDB-backed storage engine. -type Storage struct { - path string - db *leveldb.DB - - batch *leveldb.Batch - batchTime time.Time - batchN int -} - -// NewStorage returns a new instance of Storage. -func NewStorage(opt pilosa.StorageOptions) *Storage { - path := filepath.Join( - opt.LevelDBPath, - opt.DB, - strconv.Itoa(opt.Slice), - opt.Frame, - opt.FragmentID.String(), - ) - - return &Storage{path: path} -} - -// Path returns the path the storage was initialized with. -func (s *Storage) Path() string { return s.path } - -// Open opens and initializes the storage. -func (s *Storage) Open() error { - db, err := leveldb.OpenFile(s.path, nil) - if err != nil { - return err - } - s.db = db - s.batchTime = time.Now().Add(-time.Hour) - - return nil -} - -// Close flushes and closes the storage. -func (s *Storage) Close() error { - s.Flush() - return s.db.Close() -} - -func (s *Storage) Fetch(bitmapID uint64, db string, frame string, slice int) (*pilosa.Bitmap, uint64) { - bm := pilosa.NewBitmap() - - // Begin benchmark. - start := time.Now() - - // Create an iterator on the database. - iter := s.db.NewIterator(&Range{ - Start: marshalKey(bitmapID, 0, 0), - Limit: marshalKey(bitmapID+1, 0, 0), - }, nil) - defer iter.Release() - - // Iterate over blocks in database and create bitmap. - var chunk *pilosa.Chunk - var filter, block, count uint64 - lastKey := uint64(pilosa.CounterMask) - - for iter.Next() { - _, key, idx := unmarshalKey(iter.Key()) - block, filter = unmarshalValue(iter.Value()) - if key != pilosa.CounterMask { - if key != lastKey { - chunk = &pilosa.Chunk{key, pilosa.NewBlocks()} - bm.AddChunk(chunk) - } - chunk.Value[idx] = block - } else { - count = block - } - - lastKey = key - } - - statsd.SendTimer("leveldb_storage_Fetch", time.Since(start).Nanoseconds()) - - // Set bit count on bitmap. - bm.SetCount(uint64(count)) - - return bm, uint64(filter) -} - -// beginBatch starts a new batch if one is not already started. -func (s *Storage) beginBatch() { - if s.batch == nil { - s.batch = &leveldb.Batch{} - } - s.batchN++ -} - -func (s *Storage) endBatch() { - if s.batch == nil { - return - } - - start := time.Now() - if time.Since(s.batchTime) > 15*time.Second || s.batchN > 300 { - s.Flush() - } - statsd.SendTimer("leveldb_storage_EndBatch", time.Since(start).Nanoseconds()) -} - -func (s *Storage) Flush() { - start := time.Now() - - // Flush the batch if one exists. - if s.batch != nil { - s.db.Write(s.batch, nil) - } - - // Clear batch and reset timer and count. - s.batch = nil - s.batchTime = time.Now() - s.batchN = 0 - - statsd.SendTimer("leveldb_storage_FlushBatch", time.Since(start).Nanoseconds()) -} - -// Store saves a bitmap to storage. -func (s *Storage) Store(bitmapID uint64, db string, frame string, slice int, filter uint64, bm *pilosa.Bitmap) error { - s.beginBatch() - - for itr := bm.ChunkIterator(); !itr.Limit(); itr = itr.Next() { - for idx, block := range itr.Item().Value { - if block != 0 { - s.StoreBlock(bitmapID, db, frame, slice, filter, itr.Item().Key, int32(idx), block) - } - } - } - - s.StoreBlock(bitmapID, db, frame, slice, filter, pilosa.CounterMask, 0, bm.BitCount()) - - s.endBatch() - return nil -} - -// StoreBlock saves a block to storage. -func (s *Storage) StoreBlock(bitmapID uint64, db string, frame string, slice int, filter uint64, chunk uint64, index int32, block uint64) error { - start := time.Now() - s.batch.Put(marshalKey(bitmapID, chunk, uint8(index)), marshalValue(block, filter)) - statsd.SendTimer("leveldb_storage_StoreBlock", time.Since(start).Nanoseconds()) - return nil -} - -// RemoveBlock deletes a block from storage. This is a no-op in the LevelDB store. -func (s *Storage) RemoveBlock(bitmapID uint64, db string, frame string, slice int, chunk uint64, blockIndex int32) { -} - -// StoreBit sets a bit in storage. -func (s *Storage) StoreBit(bitmapID uint64, db string, frame string, slice int, filter uint64, bchunk uint64, blockIndex int32, bblock, count uint64) { - s.beginBatch() - s.StoreBlock(bitmapID, db, frame, slice, filter, bchunk, blockIndex, bblock) - s.StoreBlock(bitmapID, db, frame, slice, filter, pilosa.CounterMask, 0, count) - s.endBatch() -} - -// RemoveBlock unsets a bit in storage. This is a no-op in the LevelDB store. -func (s *Storage) RemoveBit(bitmapID uint64, db string, frame string, slice int, filter uint64, bchunk uint64, blockIndex int32, count uint64) { -} - -// marshalKey encodes the id, chunk key, & block index to a byte slice. -func marshalKey(id, key uint64, index uint8) []byte { - buf := new(bytes.Buffer) - binary.Write(buf, binary.LittleEndian, id) - binary.Write(buf, binary.LittleEndian, key) - binary.Write(buf, binary.LittleEndian, index) - return buf.Bytes() -} - -// marshalValue encodes the block number and filter to a byte slice. -func marshalValue(block, filter uint64) []byte { - buf := new(bytes.Buffer) - binary.Write(buf, binary.LittleEndian, block) - binary.Write(buf, binary.LittleEndian, filter) - return buf.Bytes() -} - -// unmarshalKey decodes the id, chunk key, & block index from a byte slice. -func unmarshalKey(v []byte) (id, key uint64, index uint8) { - buf := bytes.NewReader(v) - binary.Read(buf, binary.LittleEndian, &id) - binary.Read(buf, binary.LittleEndian, &key) - binary.Read(buf, binary.LittleEndian, &index) - return -} - -// unmarshalValue decodes the block number and filter from a byte slice. -func unmarshalValue(v []byte) (block, filter uint64) { - buf := bytes.NewReader(v) - binary.Read(buf, binary.LittleEndian, &block) - binary.Read(buf, binary.LittleEndian, &filter) - return -} diff --git a/storage/leveldb/leveldb_test.go b/storage/leveldb/leveldb_test.go deleted file mode 100644 index e956078c8..000000000 --- a/storage/leveldb/leveldb_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package leveldb_test - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/storage/leveldb" - "github.com/umbel/pilosa/util" -) - -func init() { - util.SetupStatsd() -} - -func TestStorage_Fetch(t *testing.T) { - s := MustOpenStorage() - defer s.Close() -} - -// Storage represents a test wrapper for leveldb.Storage. -type Storage struct { - *leveldb.Storage -} - -// NewStorage returns a new instance of Storage with a temporary path. -func NewStorage() *Storage { - // Create temporary path. - f, err := ioutil.TempFile("", "pilosa-leveldb-") - if err != nil { - panic(err) - } - f.Close() - os.Remove(f.Name()) - - return &Storage{leveldb.NewStorage(pilosa.StorageOptions{ - LevelDBPath: f.Name(), - })} -} - -// MustOpenStorage returns a new, opened instance of Storage. -func MustOpenStorage() *Storage { - s := NewStorage() - if err := s.Open(); err != nil { - panic(err) - } - return s -} - -// Close closes the storage and removes the underlying data file. -func (s *Storage) Close() error { - defer os.Remove(s.Path()) - return s.Storage.Close() -} diff --git a/storage/mem/mem.go b/storage/mem/mem.go deleted file mode 100644 index bf5bdbc82..000000000 --- a/storage/mem/mem.go +++ /dev/null @@ -1,79 +0,0 @@ -package mem - -import ( - "fmt" - - "github.com/umbel/pilosa" -) - -func init() { - pilosa.RegisterStorage("memory", - func(opt pilosa.StorageOptions) pilosa.Storage { - return NewStorage() - }, - ) -} - -// Storage represents in-memory bitmap storage. -type Storage struct { - db map[string]*pilosa.Bitmap -} - -// NewStorage returns a new instance of Storage. -func NewStorage() *Storage { - return &Storage{ - db: make(map[string]*pilosa.Bitmap), - } -} - -// Open initializes the storage. -func (c *Storage) Open() error { return nil } - -// Close shuts down the storage. -func (c *Storage) Close() error { return nil } - -// FlushBatch flushes the batch to disk. This is a no-op for in-memory storage. -func (c *Storage) Flush() {} - -// Fetch retrieves a bitmap by id. -func (c *Storage) Fetch(id uint64, db, frame string, slice int) (*pilosa.Bitmap, uint64) { - key := fmt.Sprintf("%d:%s:%s:%d", id, db, frame, slice) - - // Find bitmap by key. - b, ok := c.db[key] - if ok { - return b, 0 - } - - // If the bitmap doesn't exist then create a new one. - b = pilosa.NewBitmap() - c.db[key] = b - return b, 0 -} - -// Store saves a bitmap to storage. -// This is a no-op for in-memory storage because changes are stored in the cache. -func (c *Storage) Store(id uint64, db, frame string, slice int, filter uint64, b *pilosa.Bitmap) error { - return nil -} - -// StoreBlock saves a block to storage. -// This is a no-op for in-memory storage because changes are stored in the cache. -func (c *Storage) StoreBlock(id uint64, db, frame string, slice int, filter uint64, chunk_key uint64, block_index int32, block uint64) error { - return nil -} - -// RemoveBlock deletes a block from bitmap. -// This is a no-op for in-memory storage because changes are stored in the cache. -func (self *Storage) RemoveBlock(id uint64, db string, frame string, slice int, chunk uint64, block_index int32) { -} - -// StoreBit sets a bit in a bitmap. -// This is a no-op for in-memory storage because changes are stored in the cache. -func (self *Storage) StoreBit(id uint64, db string, frame string, slice int, filter uint64, bchunk uint64, block_index int32, bblock, count uint64) { -} - -// RemoveBit unsets a bit in a bitmap. -// This is a no-op for in-memory storage because changes are stored in the cache. -func (self *Storage) RemoveBit(id uint64, db string, frame string, slice int, filter uint64, chunk uint64, block_index int32, count uint64) { -} diff --git a/storage/mem/mem_test.go b/storage/mem/mem_test.go deleted file mode 100644 index 1c88e0577..000000000 --- a/storage/mem/mem_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package mem_test - -import ( - "testing" - - "github.com/umbel/pilosa/storage/mem" -) - -// Ensure a bitmap can be retrieved from storage. -func TestStorage_Fetch(t *testing.T) { - s := mem.NewStorage() - - // Retrieving a non-existent bitmap should create a new one. - b, _ := s.Fetch(1, "d", "f", 0) - if b == nil { - t.Fatal("expected bitmap") - } - - // Retrieve the bitmap again. - other, _ := s.Fetch(1, "d", "f", 0) - if b != other { - t.Fatal("expected same bitmap") - } - - // Retrieving a different bitmap should return a different reference. - b2, _ := s.Fetch(2, "d", "f", 0) - if b == b2 { - t.Fatal("expected new bitmap") - } -} diff --git a/storage/storage.go b/storage/storage.go deleted file mode 100644 index 8efbe5c3c..000000000 --- a/storage/storage.go +++ /dev/null @@ -1,7 +0,0 @@ -package storage - -import ( - _ "github.com/umbel/pilosa/storage/cassandra" - _ "github.com/umbel/pilosa/storage/leveldb" - _ "github.com/umbel/pilosa/storage/mem" -) diff --git a/timeframe.go b/timeframe.go index 182adc272..22c75cc11 100644 --- a/timeframe.go +++ b/timeframe.go @@ -86,15 +86,18 @@ func NextMonth(start time.Time, end time.Time) bool { nextMonth := start.AddDate(0, 1, 0) return sameMonth(nextMonth, end) || end.After(nextMonth) } + func sameDay(t1, t2 time.Time) bool { y1, m1, d1 := t1.Date() y2, m2, d2 := t2.Date() return (y1 == y2) && (m1 == m2) && (d1 == d2) } + func NextDay(start time.Time, end time.Time) bool { nextDay := start.AddDate(0, 0, 1) return sameDay(nextDay, end) || end.After(nextDay) } + func GetRange(start_time time.Time, end_time time.Time, tile_id uint64) []uint64 { results, marker := upHill(start_time, end_time, tile_id) r2 := downHill(marker, end_time, tile_id) @@ -142,8 +145,8 @@ func upHill(start_time time.Time, end_time time.Time, tile_id uint64) ([]uint64, return results, time_iterator } -func downHill(start_time time.Time, end_time time.Time, tile_id uint64) []uint64 { +func downHill(start_time time.Time, end_time time.Time, tile_id uint64) []uint64 { var results []uint64 time_iterator := start_time for time_iterator.Before(end_time) { diff --git a/transport/http.go b/transport/http.go deleted file mode 100644 index eacbe1a74..000000000 --- a/transport/http.go +++ /dev/null @@ -1,56 +0,0 @@ -package transport - -import ( - "log" - - "github.com/umbel/pilosa/db" -) - -const DefaultHTTPPort = 15001 - -type HttpTransport struct { - port int - outbox chan *db.Message - done chan int -} - -func (trans *HttpTransport) Init() error { - log.Println("Bind to port", trans.port) - trans.done = make(chan int) - go trans.Loop() - return nil -} - -func (trans *HttpTransport) Loop() { - var message *db.Message - for { - select { - case message = <-trans.outbox: - log.Println(message) - case <-trans.done: - return - } - } -} - -func (trans *HttpTransport) Close() { - log.Println("Closing HTTP transport.") - trans.done <- 1 -} - -func (trans *HttpTransport) Send(node string, message *db.Message) error { - log.Println("Send", message, "to", node) - trans.outbox <- message - return nil -} - -func (trans *HttpTransport) Receive() (*db.Message, error) { - return &db.Message{}, nil -} - -func NewHttpTransport(port int) *HttpTransport { - trans := new(HttpTransport) - trans.port = port - trans.outbox = make(chan *db.Message, 10) - return trans -} diff --git a/transport/tcp.go b/transport/tcp.go deleted file mode 100644 index 1afe6dcb5..000000000 --- a/transport/tcp.go +++ /dev/null @@ -1,187 +0,0 @@ -package transport - -import ( - "encoding/gob" - "fmt" - "net" - "os" - "time" - - notify "github.com/bitly/go-notify" - log "github.com/cihub/seelog" - "github.com/umbel/pilosa" - "github.com/umbel/pilosa/core" - "github.com/umbel/pilosa/db" -) - -const DefaultTCPPort = 12001 - -type connection struct { - transport *TcpTransport - inbox chan *db.Message - outbox chan *db.Message - conn *net.Conn - process *pilosa.GUID -} - -type newconnection struct { - id *pilosa.GUID - connection *connection -} - -func init() { - gob.Register(pilosa.GUID{}) -} - -func (self *connection) manage() { -BeginManageConnection: - for { - if self.conn == nil { - process, err := self.transport.ProcessMap.GetProcess(self.process) - if err != nil { - log.Warn("transport/tcp: error getting process, retrying in 2 seconds... ", self.process, err) - time.Sleep(2 * time.Second) - continue - } - host_string := fmt.Sprintf("%s:%d", process.Host(), process.PortTcp()) - conn, err := net.Dial("tcp", host_string) - if err != nil { - log.Warn("transport/tcp: error dialing: ", host_string, " Retrying in 2 seconds...") - time.Sleep(2 * time.Second) - continue - } - self.conn = &conn - go func() { - self.outbox <- &db.Message{Data: self.transport.ID.String()} - }() - } - encoder := gob.NewEncoder(*self.conn) - decoder := gob.NewDecoder(*self.conn) - var exit = make(chan int) - go func() { - for { - var mess *db.Message - err := decoder.Decode(&mess) - if err != nil { - log.Warn("transport/tcp: error decoding message: ", err.Error()) - exit <- 1 - return - } - self.inbox <- mess - } - }() - for { - select { - case message := <-self.outbox: - err := encoder.Encode(message) - if err != nil { - log.Warn(err.Error()) - return - } - case message := <-self.inbox: - identifier, ok := message.Data.(pilosa.GUID) - if ok { - // message is connection registration; bypass inbox and register - self.process = &identifier - self.transport.reg <- &newconnection{&identifier, self} - } else { - self.transport.inbox <- message - } - case <-exit: - if self.process != nil { - self.conn = nil - continue BeginManageConnection - } else { - return - } - } - } - } -} - -type TcpTransport struct { - inbox chan *db.Message - outbox chan db.Envelope - connections map[pilosa.GUID]*connection - reg chan *newconnection - - ID pilosa.GUID - Port int - ProcessMap *core.ProcessMap -} - -func NewTcpTransport(id pilosa.GUID) *TcpTransport { - return &TcpTransport{ - inbox: make(chan *db.Message, 100), - outbox: make(chan db.Envelope, 100), - connections: make(map[pilosa.GUID]*connection), - reg: make(chan *newconnection), - - ID: id, - Port: DefaultTCPPort, - } -} - -func (self *TcpTransport) Run() { - log.Warn("Initializing TCP transport") - go self.listen() - for { - select { - case env := <-self.outbox: - con, ok := self.connections[*(env.Host)] - if !ok { - con = &connection{self, make(chan *db.Message, 100), make(chan *db.Message, 100), nil, env.Host} - go con.manage() - self.connections[*env.Host] = con - } - con.outbox <- env.Message - case nc := <-self.reg: - self.connections[*nc.id] = nc.connection - } - } -} - -func (self *TcpTransport) listen() { - port_string := fmt.Sprintf(":%d", self.Port) - l, e := net.Listen("tcp", port_string) - if e != nil { - log.Critical("Cannot bind to port! ", self.Port) - os.Exit(-1) - } - for { - conn, err := l.Accept() - if err != nil { - log.Warn("Error accepting, trying again in 2 sec... ", err) - time.Sleep(2 * time.Second) - continue - } - go self.manage(&conn) - } -} - -func (self *TcpTransport) manage(conn *net.Conn) { - con := &connection{self, make(chan *db.Message, 1024), make(chan *db.Message, 1024), conn, nil} - con.manage() -} - -func (self *TcpTransport) Close() { - log.Warn("Shutting down TCP transport") -} - -func (self *TcpTransport) Send(message *db.Message, host *pilosa.GUID) { - log.Trace("TcpTransport.Send", message, host) - envelope := db.Envelope{Message: message, Host: host} - notify.Post("outbox", &envelope) - self.outbox <- envelope -} - -func (self *TcpTransport) Receive() *db.Message { - log.Trace("TcpTransport.Receive") - message := <-self.inbox - notify.Post("inbox", message) - return message -} - -func (self *TcpTransport) Push(message *db.Message) { - self.inbox <- message -} diff --git a/util.go b/util.go deleted file mode 100644 index 8becf9a5f..000000000 --- a/util.go +++ /dev/null @@ -1,27 +0,0 @@ -package pilosa - -import ( - "io" - "os" - "strings" - - "github.com/kr/s3/s3util" -) - -func openFile(s string) (io.ReadCloser, error) { - if isURL(s) { - return s3util.Open(s, nil) - } - return os.Open(s) -} - -func createFile(s string) (io.WriteCloser, error) { - if isURL(s) { - return s3util.Create(s, nil, nil) - } - return os.Create(s) -} - -func isURL(s string) bool { - return strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") -} diff --git a/vendor/github.com/BurntSushi/toml/decode_test.go b/vendor/github.com/BurntSushi/toml/decode_test.go deleted file mode 100644 index 3805931f2..000000000 --- a/vendor/github.com/BurntSushi/toml/decode_test.go +++ /dev/null @@ -1,950 +0,0 @@ -package toml - -import ( - "fmt" - "log" - "reflect" - "testing" - "time" -) - -func init() { - log.SetFlags(0) -} - -func TestDecodeSimple(t *testing.T) { - var testSimple = ` -age = 250 -andrew = "gallant" -kait = "brady" -now = 1987-07-05T05:45:00Z -yesOrNo = true -pi = 3.14 -colors = [ - ["red", "green", "blue"], - ["cyan", "magenta", "yellow", "black"], -] - -[My.Cats] -plato = "cat 1" -cauchy = "cat 2" -` - - type cats struct { - Plato string - Cauchy string - } - type simple struct { - Age int - Colors [][]string - Pi float64 - YesOrNo bool - Now time.Time - Andrew string - Kait string - My map[string]cats - } - - var val simple - _, err := Decode(testSimple, &val) - if err != nil { - t.Fatal(err) - } - - now, err := time.Parse("2006-01-02T15:04:05", "1987-07-05T05:45:00") - if err != nil { - panic(err) - } - var answer = simple{ - Age: 250, - Andrew: "gallant", - Kait: "brady", - Now: now, - YesOrNo: true, - Pi: 3.14, - Colors: [][]string{ - {"red", "green", "blue"}, - {"cyan", "magenta", "yellow", "black"}, - }, - My: map[string]cats{ - "Cats": cats{Plato: "cat 1", Cauchy: "cat 2"}, - }, - } - if !reflect.DeepEqual(val, answer) { - t.Fatalf("Expected\n-----\n%#v\n-----\nbut got\n-----\n%#v\n", - answer, val) - } -} - -func TestDecodeEmbedded(t *testing.T) { - type Dog struct{ Name string } - type Age int - - tests := map[string]struct { - input string - decodeInto interface{} - wantDecoded interface{} - }{ - "embedded struct": { - input: `Name = "milton"`, - decodeInto: &struct{ Dog }{}, - wantDecoded: &struct{ Dog }{Dog{"milton"}}, - }, - "embedded non-nil pointer to struct": { - input: `Name = "milton"`, - decodeInto: &struct{ *Dog }{}, - wantDecoded: &struct{ *Dog }{&Dog{"milton"}}, - }, - "embedded nil pointer to struct": { - input: ``, - decodeInto: &struct{ *Dog }{}, - wantDecoded: &struct{ *Dog }{nil}, - }, - "embedded int": { - input: `Age = -5`, - decodeInto: &struct{ Age }{}, - wantDecoded: &struct{ Age }{-5}, - }, - } - - for label, test := range tests { - _, err := Decode(test.input, test.decodeInto) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(test.wantDecoded, test.decodeInto) { - t.Errorf("%s: want decoded == %+v, got %+v", - label, test.wantDecoded, test.decodeInto) - } - } -} - -func TestTableArrays(t *testing.T) { - var tomlTableArrays = ` -[[albums]] -name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] -name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" -` - - type Song struct { - Name string - } - - type Album struct { - Name string - Songs []Song - } - - type Music struct { - Albums []Album - } - - expected := Music{[]Album{ - {"Born to Run", []Song{{"Jungleland"}, {"Meeting Across the River"}}}, - {"Born in the USA", []Song{{"Glory Days"}, {"Dancing in the Dark"}}}, - }} - var got Music - if _, err := Decode(tomlTableArrays, &got); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, got) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, got) - } -} - -// Case insensitive matching tests. -// A bit more comprehensive than needed given the current implementation, -// but implementations change. -// Probably still missing demonstrations of some ugly corner cases regarding -// case insensitive matching and multiple fields. -func TestCase(t *testing.T) { - var caseToml = ` -tOpString = "string" -tOpInt = 1 -tOpFloat = 1.1 -tOpBool = true -tOpdate = 2006-01-02T15:04:05Z -tOparray = [ "array" ] -Match = "i should be in Match only" -MatcH = "i should be in MatcH only" -once = "just once" -[nEst.eD] -nEstedString = "another string" -` - - type InsensitiveEd struct { - NestedString string - } - - type InsensitiveNest struct { - Ed InsensitiveEd - } - - type Insensitive struct { - TopString string - TopInt int - TopFloat float64 - TopBool bool - TopDate time.Time - TopArray []string - Match string - MatcH string - Once string - OncE string - Nest InsensitiveNest - } - - tme, err := time.Parse(time.RFC3339, time.RFC3339[:len(time.RFC3339)-5]) - if err != nil { - panic(err) - } - expected := Insensitive{ - TopString: "string", - TopInt: 1, - TopFloat: 1.1, - TopBool: true, - TopDate: tme, - TopArray: []string{"array"}, - MatcH: "i should be in MatcH only", - Match: "i should be in Match only", - Once: "just once", - OncE: "", - Nest: InsensitiveNest{ - Ed: InsensitiveEd{NestedString: "another string"}, - }, - } - var got Insensitive - if _, err := Decode(caseToml, &got); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, got) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, got) - } -} - -func TestPointers(t *testing.T) { - type Object struct { - Type string - Description string - } - - type Dict struct { - NamedObject map[string]*Object - BaseObject *Object - Strptr *string - Strptrs []*string - } - s1, s2, s3 := "blah", "abc", "def" - expected := &Dict{ - Strptr: &s1, - Strptrs: []*string{&s2, &s3}, - NamedObject: map[string]*Object{ - "foo": {"FOO", "fooooo!!!"}, - "bar": {"BAR", "ba-ba-ba-ba-barrrr!!!"}, - }, - BaseObject: &Object{"BASE", "da base"}, - } - - ex1 := ` -Strptr = "blah" -Strptrs = ["abc", "def"] - -[NamedObject.foo] -Type = "FOO" -Description = "fooooo!!!" - -[NamedObject.bar] -Type = "BAR" -Description = "ba-ba-ba-ba-barrrr!!!" - -[BaseObject] -Type = "BASE" -Description = "da base" -` - dict := new(Dict) - _, err := Decode(ex1, dict) - if err != nil { - t.Errorf("Decode error: %v", err) - } - if !reflect.DeepEqual(expected, dict) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, dict) - } -} - -type sphere struct { - Center [3]float64 - Radius float64 -} - -func TestDecodeSimpleArray(t *testing.T) { - var s1 sphere - if _, err := Decode(`center = [0.0, 1.5, 0.0]`, &s1); err != nil { - t.Fatal(err) - } -} - -func TestDecodeArrayWrongSize(t *testing.T) { - var s1 sphere - if _, err := Decode(`center = [0.1, 2.3]`, &s1); err == nil { - t.Fatal("Expected array type mismatch error") - } -} - -func TestDecodeLargeIntoSmallInt(t *testing.T) { - type table struct { - Value int8 - } - var tab table - if _, err := Decode(`value = 500`, &tab); err == nil { - t.Fatal("Expected integer out-of-bounds error.") - } -} - -func TestDecodeSizedInts(t *testing.T) { - type table struct { - U8 uint8 - U16 uint16 - U32 uint32 - U64 uint64 - U uint - I8 int8 - I16 int16 - I32 int32 - I64 int64 - I int - } - answer := table{1, 1, 1, 1, 1, -1, -1, -1, -1, -1} - toml := ` - u8 = 1 - u16 = 1 - u32 = 1 - u64 = 1 - u = 1 - i8 = -1 - i16 = -1 - i32 = -1 - i64 = -1 - i = -1 - ` - var tab table - if _, err := Decode(toml, &tab); err != nil { - t.Fatal(err.Error()) - } - if answer != tab { - t.Fatalf("Expected %#v but got %#v", answer, tab) - } -} - -func TestUnmarshaler(t *testing.T) { - - var tomlBlob = ` -[dishes.hamboogie] -name = "Hamboogie with fries" -price = 10.99 - -[[dishes.hamboogie.ingredients]] -name = "Bread Bun" - -[[dishes.hamboogie.ingredients]] -name = "Lettuce" - -[[dishes.hamboogie.ingredients]] -name = "Real Beef Patty" - -[[dishes.hamboogie.ingredients]] -name = "Tomato" - -[dishes.eggsalad] -name = "Egg Salad with rice" -price = 3.99 - -[[dishes.eggsalad.ingredients]] -name = "Egg" - -[[dishes.eggsalad.ingredients]] -name = "Mayo" - -[[dishes.eggsalad.ingredients]] -name = "Rice" -` - m := &menu{} - if _, err := Decode(tomlBlob, m); err != nil { - log.Fatal(err) - } - - if len(m.Dishes) != 2 { - t.Log("two dishes should be loaded with UnmarshalTOML()") - t.Errorf("expected %d but got %d", 2, len(m.Dishes)) - } - - eggSalad := m.Dishes["eggsalad"] - if _, ok := interface{}(eggSalad).(dish); !ok { - t.Errorf("expected a dish") - } - - if eggSalad.Name != "Egg Salad with rice" { - t.Errorf("expected the dish to be named 'Egg Salad with rice'") - } - - if len(eggSalad.Ingredients) != 3 { - t.Log("dish should be loaded with UnmarshalTOML()") - t.Errorf("expected %d but got %d", 3, len(eggSalad.Ingredients)) - } - - found := false - for _, i := range eggSalad.Ingredients { - if i.Name == "Rice" { - found = true - break - } - } - if !found { - t.Error("Rice was not loaded in UnmarshalTOML()") - } - - // test on a value - must be passed as * - o := menu{} - if _, err := Decode(tomlBlob, &o); err != nil { - log.Fatal(err) - } - -} - -type menu struct { - Dishes map[string]dish -} - -func (m *menu) UnmarshalTOML(p interface{}) error { - m.Dishes = make(map[string]dish) - data, _ := p.(map[string]interface{}) - dishes := data["dishes"].(map[string]interface{}) - for n, v := range dishes { - if d, ok := v.(map[string]interface{}); ok { - nd := dish{} - nd.UnmarshalTOML(d) - m.Dishes[n] = nd - } else { - return fmt.Errorf("not a dish") - } - } - return nil -} - -type dish struct { - Name string - Price float32 - Ingredients []ingredient -} - -func (d *dish) UnmarshalTOML(p interface{}) error { - data, _ := p.(map[string]interface{}) - d.Name, _ = data["name"].(string) - d.Price, _ = data["price"].(float32) - ingredients, _ := data["ingredients"].([]map[string]interface{}) - for _, e := range ingredients { - n, _ := interface{}(e).(map[string]interface{}) - name, _ := n["name"].(string) - i := ingredient{name} - d.Ingredients = append(d.Ingredients, i) - } - return nil -} - -type ingredient struct { - Name string -} - -func ExampleMetaData_PrimitiveDecode() { - var md MetaData - var err error - - var tomlBlob = ` -ranking = ["Springsteen", "J Geils"] - -[bands.Springsteen] -started = 1973 -albums = ["Greetings", "WIESS", "Born to Run", "Darkness"] - -[bands."J Geils"] -started = 1970 -albums = ["The J. Geils Band", "Full House", "Blow Your Face Out"] -` - - type band struct { - Started int - Albums []string - } - type classics struct { - Ranking []string - Bands map[string]Primitive - } - - // Do the initial decode. Reflection is delayed on Primitive values. - var music classics - if md, err = Decode(tomlBlob, &music); err != nil { - log.Fatal(err) - } - - // MetaData still includes information on Primitive values. - fmt.Printf("Is `bands.Springsteen` defined? %v\n", - md.IsDefined("bands", "Springsteen")) - - // Decode primitive data into Go values. - for _, artist := range music.Ranking { - // A band is a primitive value, so we need to decode it to get a - // real `band` value. - primValue := music.Bands[artist] - - var aBand band - if err = md.PrimitiveDecode(primValue, &aBand); err != nil { - log.Fatal(err) - } - fmt.Printf("%s started in %d.\n", artist, aBand.Started) - } - // Check to see if there were any fields left undecoded. - // Note that this won't be empty before decoding the Primitive value! - fmt.Printf("Undecoded: %q\n", md.Undecoded()) - - // Output: - // Is `bands.Springsteen` defined? true - // Springsteen started in 1973. - // J Geils started in 1970. - // Undecoded: [] -} - -func ExampleDecode() { - var tomlBlob = ` -# Some comments. -[alpha] -ip = "10.0.0.1" - - [alpha.config] - Ports = [ 8001, 8002 ] - Location = "Toronto" - Created = 1987-07-05T05:45:00Z - -[beta] -ip = "10.0.0.2" - - [beta.config] - Ports = [ 9001, 9002 ] - Location = "New Jersey" - Created = 1887-01-05T05:55:00Z -` - - type serverConfig struct { - Ports []int - Location string - Created time.Time - } - - type server struct { - IP string `toml:"ip"` - Config serverConfig `toml:"config"` - } - - type servers map[string]server - - var config servers - if _, err := Decode(tomlBlob, &config); err != nil { - log.Fatal(err) - } - - for _, name := range []string{"alpha", "beta"} { - s := config[name] - fmt.Printf("Server: %s (ip: %s) in %s created on %s\n", - name, s.IP, s.Config.Location, - s.Config.Created.Format("2006-01-02")) - fmt.Printf("Ports: %v\n", s.Config.Ports) - } - - // Output: - // Server: alpha (ip: 10.0.0.1) in Toronto created on 1987-07-05 - // Ports: [8001 8002] - // Server: beta (ip: 10.0.0.2) in New Jersey created on 1887-01-05 - // Ports: [9001 9002] -} - -type duration struct { - time.Duration -} - -func (d *duration) UnmarshalText(text []byte) error { - var err error - d.Duration, err = time.ParseDuration(string(text)) - return err -} - -// Example Unmarshaler shows how to decode TOML strings into your own -// custom data type. -func Example_unmarshaler() { - blob := ` -[[song]] -name = "Thunder Road" -duration = "4m49s" - -[[song]] -name = "Stairway to Heaven" -duration = "8m03s" -` - type song struct { - Name string - Duration duration - } - type songs struct { - Song []song - } - var favorites songs - if _, err := Decode(blob, &favorites); err != nil { - log.Fatal(err) - } - - // Code to implement the TextUnmarshaler interface for `duration`: - // - // type duration struct { - // time.Duration - // } - // - // func (d *duration) UnmarshalText(text []byte) error { - // var err error - // d.Duration, err = time.ParseDuration(string(text)) - // return err - // } - - for _, s := range favorites.Song { - fmt.Printf("%s (%s)\n", s.Name, s.Duration) - } - // Output: - // Thunder Road (4m49s) - // Stairway to Heaven (8m3s) -} - -// Example StrictDecoding shows how to detect whether there are keys in the -// TOML document that weren't decoded into the value given. This is useful -// for returning an error to the user if they've included extraneous fields -// in their configuration. -func Example_strictDecoding() { - var blob = ` -key1 = "value1" -key2 = "value2" -key3 = "value3" -` - type config struct { - Key1 string - Key3 string - } - - var conf config - md, err := Decode(blob, &conf) - if err != nil { - log.Fatal(err) - } - fmt.Printf("Undecoded keys: %q\n", md.Undecoded()) - // Output: - // Undecoded keys: ["key2"] -} - -// Example UnmarshalTOML shows how to implement a struct type that knows how to -// unmarshal itself. The struct must take full responsibility for mapping the -// values passed into the struct. The method may be used with interfaces in a -// struct in cases where the actual type is not known until the data is -// examined. -func Example_unmarshalTOML() { - - var blob = ` -[[parts]] -type = "valve" -id = "valve-1" -size = 1.2 -rating = 4 - -[[parts]] -type = "valve" -id = "valve-2" -size = 2.1 -rating = 5 - -[[parts]] -type = "pipe" -id = "pipe-1" -length = 2.1 -diameter = 12 - -[[parts]] -type = "cable" -id = "cable-1" -length = 12 -rating = 3.1 -` - o := &order{} - err := Unmarshal([]byte(blob), o) - if err != nil { - log.Fatal(err) - } - - fmt.Println(len(o.parts)) - - for _, part := range o.parts { - fmt.Println(part.Name()) - } - - // Code to implement UmarshalJSON. - - // type order struct { - // // NOTE `order.parts` is a private slice of type `part` which is an - // // interface and may only be loaded from toml using the - // // UnmarshalTOML() method of the Umarshaler interface. - // parts parts - // } - - // func (o *order) UnmarshalTOML(data interface{}) error { - - // // NOTE the example below contains detailed type casting to show how - // // the 'data' is retrieved. In operational use, a type cast wrapper - // // may be prefered e.g. - // // - // // func AsMap(v interface{}) (map[string]interface{}, error) { - // // return v.(map[string]interface{}) - // // } - // // - // // resulting in: - // // d, _ := AsMap(data) - // // - - // d, _ := data.(map[string]interface{}) - // parts, _ := d["parts"].([]map[string]interface{}) - - // for _, p := range parts { - - // typ, _ := p["type"].(string) - // id, _ := p["id"].(string) - - // // detect the type of part and handle each case - // switch p["type"] { - // case "valve": - - // size := float32(p["size"].(float64)) - // rating := int(p["rating"].(int64)) - - // valve := &valve{ - // Type: typ, - // ID: id, - // Size: size, - // Rating: rating, - // } - - // o.parts = append(o.parts, valve) - - // case "pipe": - - // length := float32(p["length"].(float64)) - // diameter := int(p["diameter"].(int64)) - - // pipe := &pipe{ - // Type: typ, - // ID: id, - // Length: length, - // Diameter: diameter, - // } - - // o.parts = append(o.parts, pipe) - - // case "cable": - - // length := int(p["length"].(int64)) - // rating := float32(p["rating"].(float64)) - - // cable := &cable{ - // Type: typ, - // ID: id, - // Length: length, - // Rating: rating, - // } - - // o.parts = append(o.parts, cable) - - // } - // } - - // return nil - // } - - // type parts []part - - // type part interface { - // Name() string - // } - - // type valve struct { - // Type string - // ID string - // Size float32 - // Rating int - // } - - // func (v *valve) Name() string { - // return fmt.Sprintf("VALVE: %s", v.ID) - // } - - // type pipe struct { - // Type string - // ID string - // Length float32 - // Diameter int - // } - - // func (p *pipe) Name() string { - // return fmt.Sprintf("PIPE: %s", p.ID) - // } - - // type cable struct { - // Type string - // ID string - // Length int - // Rating float32 - // } - - // func (c *cable) Name() string { - // return fmt.Sprintf("CABLE: %s", c.ID) - // } - - // Output: - // 4 - // VALVE: valve-1 - // VALVE: valve-2 - // PIPE: pipe-1 - // CABLE: cable-1 - -} - -type order struct { - // NOTE `order.parts` is a private slice of type `part` which is an - // interface and may only be loaded from toml using the UnmarshalTOML() - // method of the Umarshaler interface. - parts parts -} - -func (o *order) UnmarshalTOML(data interface{}) error { - - // NOTE the example below contains detailed type casting to show how - // the 'data' is retrieved. In operational use, a type cast wrapper - // may be prefered e.g. - // - // func AsMap(v interface{}) (map[string]interface{}, error) { - // return v.(map[string]interface{}) - // } - // - // resulting in: - // d, _ := AsMap(data) - // - - d, _ := data.(map[string]interface{}) - parts, _ := d["parts"].([]map[string]interface{}) - - for _, p := range parts { - - typ, _ := p["type"].(string) - id, _ := p["id"].(string) - - // detect the type of part and handle each case - switch p["type"] { - case "valve": - - size := float32(p["size"].(float64)) - rating := int(p["rating"].(int64)) - - valve := &valve{ - Type: typ, - ID: id, - Size: size, - Rating: rating, - } - - o.parts = append(o.parts, valve) - - case "pipe": - - length := float32(p["length"].(float64)) - diameter := int(p["diameter"].(int64)) - - pipe := &pipe{ - Type: typ, - ID: id, - Length: length, - Diameter: diameter, - } - - o.parts = append(o.parts, pipe) - - case "cable": - - length := int(p["length"].(int64)) - rating := float32(p["rating"].(float64)) - - cable := &cable{ - Type: typ, - ID: id, - Length: length, - Rating: rating, - } - - o.parts = append(o.parts, cable) - - } - } - - return nil -} - -type parts []part - -type part interface { - Name() string -} - -type valve struct { - Type string - ID string - Size float32 - Rating int -} - -func (v *valve) Name() string { - return fmt.Sprintf("VALVE: %s", v.ID) -} - -type pipe struct { - Type string - ID string - Length float32 - Diameter int -} - -func (p *pipe) Name() string { - return fmt.Sprintf("PIPE: %s", p.ID) -} - -type cable struct { - Type string - ID string - Length int - Rating float32 -} - -func (c *cable) Name() string { - return fmt.Sprintf("CABLE: %s", c.ID) -} diff --git a/vendor/github.com/BurntSushi/toml/encode_test.go b/vendor/github.com/BurntSushi/toml/encode_test.go deleted file mode 100644 index 445ca8e21..000000000 --- a/vendor/github.com/BurntSushi/toml/encode_test.go +++ /dev/null @@ -1,542 +0,0 @@ -package toml - -import ( - "bytes" - "fmt" - "log" - "net" - "testing" - "time" -) - -func TestEncodeRoundTrip(t *testing.T) { - type Config struct { - Age int - Cats []string - Pi float64 - Perfection []int - DOB time.Time - Ipaddress net.IP - } - - var inputs = Config{ - 13, - []string{"one", "two", "three"}, - 3.145, - []int{11, 2, 3, 4}, - time.Now(), - net.ParseIP("192.168.59.254"), - } - - var firstBuffer bytes.Buffer - e := NewEncoder(&firstBuffer) - err := e.Encode(inputs) - if err != nil { - t.Fatal(err) - } - var outputs Config - if _, err := Decode(firstBuffer.String(), &outputs); err != nil { - log.Printf("Could not decode:\n-----\n%s\n-----\n", - firstBuffer.String()) - t.Fatal(err) - } - - // could test each value individually, but I'm lazy - var secondBuffer bytes.Buffer - e2 := NewEncoder(&secondBuffer) - err = e2.Encode(outputs) - if err != nil { - t.Fatal(err) - } - if firstBuffer.String() != secondBuffer.String() { - t.Error( - firstBuffer.String(), - "\n\n is not identical to\n\n", - secondBuffer.String()) - } -} - -// XXX(burntsushi) -// I think these tests probably should be removed. They are good, but they -// ought to be obsolete by toml-test. -func TestEncode(t *testing.T) { - type Embedded struct { - Int int `toml:"_int"` - } - type NonStruct int - - date := time.Date(2014, 5, 11, 20, 30, 40, 0, time.FixedZone("IST", 3600)) - dateStr := "2014-05-11T19:30:40Z" - - tests := map[string]struct { - input interface{} - wantOutput string - wantError error - }{ - "bool field": { - input: struct { - BoolTrue bool - BoolFalse bool - }{true, false}, - wantOutput: "BoolTrue = true\nBoolFalse = false\n", - }, - "int fields": { - input: struct { - Int int - Int8 int8 - Int16 int16 - Int32 int32 - Int64 int64 - }{1, 2, 3, 4, 5}, - wantOutput: "Int = 1\nInt8 = 2\nInt16 = 3\nInt32 = 4\nInt64 = 5\n", - }, - "uint fields": { - input: struct { - Uint uint - Uint8 uint8 - Uint16 uint16 - Uint32 uint32 - Uint64 uint64 - }{1, 2, 3, 4, 5}, - wantOutput: "Uint = 1\nUint8 = 2\nUint16 = 3\nUint32 = 4" + - "\nUint64 = 5\n", - }, - "float fields": { - input: struct { - Float32 float32 - Float64 float64 - }{1.5, 2.5}, - wantOutput: "Float32 = 1.5\nFloat64 = 2.5\n", - }, - "string field": { - input: struct{ String string }{"foo"}, - wantOutput: "String = \"foo\"\n", - }, - "string field and unexported field": { - input: struct { - String string - unexported int - }{"foo", 0}, - wantOutput: "String = \"foo\"\n", - }, - "datetime field in UTC": { - input: struct{ Date time.Time }{date}, - wantOutput: fmt.Sprintf("Date = %s\n", dateStr), - }, - "datetime field as primitive": { - // Using a map here to fail if isStructOrMap() returns true for - // time.Time. - input: map[string]interface{}{ - "Date": date, - "Int": 1, - }, - wantOutput: fmt.Sprintf("Date = %s\nInt = 1\n", dateStr), - }, - "array fields": { - input: struct { - IntArray0 [0]int - IntArray3 [3]int - }{[0]int{}, [3]int{1, 2, 3}}, - wantOutput: "IntArray0 = []\nIntArray3 = [1, 2, 3]\n", - }, - "slice fields": { - input: struct{ IntSliceNil, IntSlice0, IntSlice3 []int }{ - nil, []int{}, []int{1, 2, 3}, - }, - wantOutput: "IntSlice0 = []\nIntSlice3 = [1, 2, 3]\n", - }, - "datetime slices": { - input: struct{ DatetimeSlice []time.Time }{ - []time.Time{date, date}, - }, - wantOutput: fmt.Sprintf("DatetimeSlice = [%s, %s]\n", - dateStr, dateStr), - }, - "nested arrays and slices": { - input: struct { - SliceOfArrays [][2]int - ArrayOfSlices [2][]int - SliceOfArraysOfSlices [][2][]int - ArrayOfSlicesOfArrays [2][][2]int - SliceOfMixedArrays [][2]interface{} - ArrayOfMixedSlices [2][]interface{} - }{ - [][2]int{{1, 2}, {3, 4}}, - [2][]int{{1, 2}, {3, 4}}, - [][2][]int{ - { - {1, 2}, {3, 4}, - }, - { - {5, 6}, {7, 8}, - }, - }, - [2][][2]int{ - { - {1, 2}, {3, 4}, - }, - { - {5, 6}, {7, 8}, - }, - }, - [][2]interface{}{ - {1, 2}, {"a", "b"}, - }, - [2][]interface{}{ - {1, 2}, {"a", "b"}, - }, - }, - wantOutput: `SliceOfArrays = [[1, 2], [3, 4]] -ArrayOfSlices = [[1, 2], [3, 4]] -SliceOfArraysOfSlices = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -ArrayOfSlicesOfArrays = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -SliceOfMixedArrays = [[1, 2], ["a", "b"]] -ArrayOfMixedSlices = [[1, 2], ["a", "b"]] -`, - }, - "empty slice": { - input: struct{ Empty []interface{} }{[]interface{}{}}, - wantOutput: "Empty = []\n", - }, - "(error) slice with element type mismatch (string and integer)": { - input: struct{ Mixed []interface{} }{[]interface{}{1, "a"}}, - wantError: errArrayMixedElementTypes, - }, - "(error) slice with element type mismatch (integer and float)": { - input: struct{ Mixed []interface{} }{[]interface{}{1, 2.5}}, - wantError: errArrayMixedElementTypes, - }, - "slice with elems of differing Go types, same TOML types": { - input: struct { - MixedInts []interface{} - MixedFloats []interface{} - }{ - []interface{}{ - int(1), int8(2), int16(3), int32(4), int64(5), - uint(1), uint8(2), uint16(3), uint32(4), uint64(5), - }, - []interface{}{float32(1.5), float64(2.5)}, - }, - wantOutput: "MixedInts = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n" + - "MixedFloats = [1.5, 2.5]\n", - }, - "(error) slice w/ element type mismatch (one is nested array)": { - input: struct{ Mixed []interface{} }{ - []interface{}{1, []interface{}{2}}, - }, - wantError: errArrayMixedElementTypes, - }, - "(error) slice with 1 nil element": { - input: struct{ NilElement1 []interface{} }{[]interface{}{nil}}, - wantError: errArrayNilElement, - }, - "(error) slice with 1 nil element (and other non-nil elements)": { - input: struct{ NilElement []interface{} }{ - []interface{}{1, nil}, - }, - wantError: errArrayNilElement, - }, - "simple map": { - input: map[string]int{"a": 1, "b": 2}, - wantOutput: "a = 1\nb = 2\n", - }, - "map with interface{} value type": { - input: map[string]interface{}{"a": 1, "b": "c"}, - wantOutput: "a = 1\nb = \"c\"\n", - }, - "map with interface{} value type, some of which are structs": { - input: map[string]interface{}{ - "a": struct{ Int int }{2}, - "b": 1, - }, - wantOutput: "b = 1\n\n[a]\n Int = 2\n", - }, - "nested map": { - input: map[string]map[string]int{ - "a": {"b": 1}, - "c": {"d": 2}, - }, - wantOutput: "[a]\n b = 1\n\n[c]\n d = 2\n", - }, - "nested struct": { - input: struct{ Struct struct{ Int int } }{ - struct{ Int int }{1}, - }, - wantOutput: "[Struct]\n Int = 1\n", - }, - "nested struct and non-struct field": { - input: struct { - Struct struct{ Int int } - Bool bool - }{struct{ Int int }{1}, true}, - wantOutput: "Bool = true\n\n[Struct]\n Int = 1\n", - }, - "2 nested structs": { - input: struct{ Struct1, Struct2 struct{ Int int } }{ - struct{ Int int }{1}, struct{ Int int }{2}, - }, - wantOutput: "[Struct1]\n Int = 1\n\n[Struct2]\n Int = 2\n", - }, - "deeply nested structs": { - input: struct { - Struct1, Struct2 struct{ Struct3 *struct{ Int int } } - }{ - struct{ Struct3 *struct{ Int int } }{&struct{ Int int }{1}}, - struct{ Struct3 *struct{ Int int } }{nil}, - }, - wantOutput: "[Struct1]\n [Struct1.Struct3]\n Int = 1" + - "\n\n[Struct2]\n", - }, - "nested struct with nil struct elem": { - input: struct { - Struct struct{ Inner *struct{ Int int } } - }{ - struct{ Inner *struct{ Int int } }{nil}, - }, - wantOutput: "[Struct]\n", - }, - "nested struct with no fields": { - input: struct { - Struct struct{ Inner struct{} } - }{ - struct{ Inner struct{} }{struct{}{}}, - }, - wantOutput: "[Struct]\n [Struct.Inner]\n", - }, - "struct with tags": { - input: struct { - Struct struct { - Int int `toml:"_int"` - } `toml:"_struct"` - Bool bool `toml:"_bool"` - }{ - struct { - Int int `toml:"_int"` - }{1}, true, - }, - wantOutput: "_bool = true\n\n[_struct]\n _int = 1\n", - }, - "embedded struct": { - input: struct{ Embedded }{Embedded{1}}, - wantOutput: "_int = 1\n", - }, - "embedded *struct": { - input: struct{ *Embedded }{&Embedded{1}}, - wantOutput: "_int = 1\n", - }, - "nested embedded struct": { - input: struct { - Struct struct{ Embedded } `toml:"_struct"` - }{struct{ Embedded }{Embedded{1}}}, - wantOutput: "[_struct]\n _int = 1\n", - }, - "nested embedded *struct": { - input: struct { - Struct struct{ *Embedded } `toml:"_struct"` - }{struct{ *Embedded }{&Embedded{1}}}, - wantOutput: "[_struct]\n _int = 1\n", - }, - "array of tables": { - input: struct { - Structs []*struct{ Int int } `toml:"struct"` - }{ - []*struct{ Int int }{{1}, {3}}, - }, - wantOutput: "[[struct]]\n Int = 1\n\n[[struct]]\n Int = 3\n", - }, - "array of tables order": { - input: map[string]interface{}{ - "map": map[string]interface{}{ - "zero": 5, - "arr": []map[string]int{ - map[string]int{ - "friend": 5, - }, - }, - }, - }, - wantOutput: "[map]\n zero = 5\n\n [[map.arr]]\n friend = 5\n", - }, - "(error) top-level slice": { - input: []struct{ Int int }{{1}, {2}, {3}}, - wantError: errNoKey, - }, - "(error) slice of slice": { - input: struct { - Slices [][]struct{ Int int } - }{ - [][]struct{ Int int }{{{1}}, {{2}}, {{3}}}, - }, - wantError: errArrayNoTable, - }, - "(error) map no string key": { - input: map[int]string{1: ""}, - wantError: errNonString, - }, - "(error) anonymous non-struct": { - input: struct{ NonStruct }{5}, - wantError: errAnonNonStruct, - }, - "(error) empty key name": { - input: map[string]int{"": 1}, - wantError: errAnything, - }, - "(error) empty map name": { - input: map[string]interface{}{ - "": map[string]int{"v": 1}, - }, - wantError: errAnything, - }, - } - for label, test := range tests { - encodeExpected(t, label, test.input, test.wantOutput, test.wantError) - } -} - -func TestEncodeNestedTableArrays(t *testing.T) { - type song struct { - Name string `toml:"name"` - } - type album struct { - Name string `toml:"name"` - Songs []song `toml:"songs"` - } - type springsteen struct { - Albums []album `toml:"albums"` - } - value := springsteen{ - []album{ - {"Born to Run", - []song{{"Jungleland"}, {"Meeting Across the River"}}}, - {"Born in the USA", - []song{{"Glory Days"}, {"Dancing in the Dark"}}}, - }, - } - expected := `[[albums]] - name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] - name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" -` - encodeExpected(t, "nested table arrays", value, expected, nil) -} - -func TestEncodeArrayHashWithNormalHashOrder(t *testing.T) { - type Alpha struct { - V int - } - type Beta struct { - V int - } - type Conf struct { - V int - A Alpha - B []Beta - } - - val := Conf{ - V: 1, - A: Alpha{2}, - B: []Beta{{3}}, - } - expected := "V = 1\n\n[A]\n V = 2\n\n[[B]]\n V = 3\n" - encodeExpected(t, "array hash with normal hash order", val, expected, nil) -} - -func TestEncodeWithOmitEmpty(t *testing.T) { - type simple struct { - User string `toml:"user"` - Pass string `toml:"password,omitempty"` - } - - value := simple{"Testing", ""} - expected := fmt.Sprintf("user = %q\n", value.User) - encodeExpected(t, "simple with omitempty, is empty", value, expected, nil) - value.Pass = "some password" - expected = fmt.Sprintf("user = %q\npassword = %q\n", value.User, value.Pass) - encodeExpected(t, "simple with omitempty, not empty", value, expected, nil) -} - -func TestEncodeWithOmitZero(t *testing.T) { - type simple struct { - Number int `toml:"number,omitzero"` - Real float64 `toml:"real,omitzero"` - Unsigned uint `toml:"unsigned,omitzero"` - } - - value := simple{0, 0.0, uint(0)} - expected := "" - - encodeExpected(t, "simple with omitzero, all zero", value, expected, nil) - - value.Number = 10 - value.Real = 20 - value.Unsigned = 5 - expected = `number = 10 -real = 20.0 -unsigned = 5 -` - encodeExpected(t, "simple with omitzero, non-zero", value, expected, nil) -} - -func encodeExpected( - t *testing.T, label string, val interface{}, wantStr string, wantErr error, -) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - err := enc.Encode(val) - if err != wantErr { - if wantErr != nil { - if wantErr == errAnything && err != nil { - return - } - t.Errorf("%s: want Encode error %v, got %v", label, wantErr, err) - } else { - t.Errorf("%s: Encode failed: %s", label, err) - } - } - if err != nil { - return - } - if got := buf.String(); wantStr != got { - t.Errorf("%s: want\n-----\n%q\n-----\nbut got\n-----\n%q\n-----\n", - label, wantStr, got) - } -} - -func ExampleEncoder_Encode() { - date, _ := time.Parse(time.RFC822, "14 Mar 10 18:00 UTC") - var config = map[string]interface{}{ - "date": date, - "counts": []int{1, 1, 2, 3, 5, 8}, - "hash": map[string]string{ - "key1": "val1", - "key2": "val2", - }, - } - buf := new(bytes.Buffer) - if err := NewEncoder(buf).Encode(config); err != nil { - log.Fatal(err) - } - fmt.Println(buf.String()) - - // Output: - // counts = [1, 1, 2, 3, 5, 8] - // date = 2010-03-14T18:00:00Z - // - // [hash] - // key1 = "val1" - // key2 = "val2" -} diff --git a/vendor/github.com/bitly/go-notify/.gitignore b/vendor/github.com/bitly/go-notify/.gitignore deleted file mode 100644 index 00268614f..000000000 --- a/vendor/github.com/bitly/go-notify/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe diff --git a/vendor/github.com/bitly/go-notify/README.md b/vendor/github.com/bitly/go-notify/README.md deleted file mode 100644 index 5d578bcc6..000000000 --- a/vendor/github.com/bitly/go-notify/README.md +++ /dev/null @@ -1,51 +0,0 @@ -## go-notify - -Package notify enables independent components of an application to -observe notable events in a decoupled fashion. - -It generalizes the pattern of *multiple* consumers of an event (ie: the -same message delivered to multiple channels) and obviates the need for -components to have intimate knowledge of each other (only `import -notify` and the name of the event are shared). - -Example: - - // producer of "my_event" - go func() { - for { - time.Sleep(time.Duration(1) * time.Second): - notify.Post("my_event", time.Now().Unix()) - } - }() - - // observer of "my_event" (normally some independent component that - // needs to be notified when "my_event" occurs) - myEventChan := make(chan interface{}) - notify.Start("my_event", myEventChan) - go func() { - for { - data := <-myEventChan - log.Printf("MY_EVENT: %#v", data) - } - }() - -### Functions - - func Post(event string, data interface{}) error - Post a notification (arbitrary data) to the specified event - - func PostTimeout(event string, data interface{}, timeout time.Duration) error - Post a notification to the specified event using the provided timeout for - any output channels that are blocking - - func Start(event string, outputChan chan interface{}) - Start observing the specified event via provided output channel - - func Stop(event string, outputChan chan interface{}) error - Stop observing the specified event on the provided output channel - - func StopAll(event string) error - Stop observing the specified event on all channels - - func Version() string - returns the current version diff --git a/vendor/github.com/bitly/go-notify/notify.go b/vendor/github.com/bitly/go-notify/notify.go deleted file mode 100644 index 7b40d5dca..000000000 --- a/vendor/github.com/bitly/go-notify/notify.go +++ /dev/null @@ -1,130 +0,0 @@ -// Package notify enables independent components of an application to -// observe notable events in a decoupled fashion. -// -// It generalizes the pattern of *multiple* consumers of an event (ie: -// the same message delivered to multiple channels) and obviates the need -// for components to have intimate knowledge of each other (only `import notify` -// and the name of the event are shared). -// -// Example: -// // producer of "my_event" -// go func() { -// for { -// time.Sleep(time.Duration(1) * time.Second): -// notify.Post("my_event", time.Now().Unix()) -// } -// }() -// -// // observer of "my_event" (normally some independent component that -// // needs to be notified when "my_event" occurs) -// myEventChan := make(chan interface{}) -// notify.Start("my_event", myEventChan) -// go func() { -// for { -// data := <-myEventChan -// log.Printf("MY_EVENT: %#v", data) -// } -// }() -package notify - -import ( - "errors" - "sync" - "time" -) - -const E_NOT_FOUND = "E_NOT_FOUND" - -// returns the current version -func Version() string { - return "0.2" -} - -// internal mapping of event names to observing channels -var events = make(map[string][]chan interface{}) - -// mutex for touching the event map -var rwMutex sync.RWMutex - -// Start observing the specified event via provided output channel -func Start(event string, outputChan chan interface{}) { - rwMutex.Lock() - defer rwMutex.Unlock() - - events[event] = append(events[event], outputChan) -} - -// Stop observing the specified event on the provided output channel -func Stop(event string, outputChan chan interface{}) error { - rwMutex.Lock() - defer rwMutex.Unlock() - - newArray := make([]chan interface{}, 0) - outChans, ok := events[event] - if !ok { - return errors.New(E_NOT_FOUND) - } - for _, ch := range outChans { - if ch != outputChan { - newArray = append(newArray, ch) - } else { - close(ch) - } - } - events[event] = newArray - - return nil -} - -// Stop observing the specified event on all channels -func StopAll(event string) error { - rwMutex.Lock() - defer rwMutex.Unlock() - - outChans, ok := events[event] - if !ok { - return errors.New(E_NOT_FOUND) - } - for _, ch := range outChans { - close(ch) - } - delete(events, event) - - return nil -} - -// Post a notification (arbitrary data) to the specified event -func Post(event string, data interface{}) error { - rwMutex.RLock() - defer rwMutex.RUnlock() - - outChans, ok := events[event] - if !ok { - return errors.New(E_NOT_FOUND) - } - for _, outputChan := range outChans { - outputChan <- data - } - - return nil -} - -// Post a notification to the specified event using the provided timeout for -// any output channels that are blocking -func PostTimeout(event string, data interface{}, timeout time.Duration) error { - rwMutex.RLock() - defer rwMutex.RUnlock() - - outChans, ok := events[event] - if !ok { - return errors.New(E_NOT_FOUND) - } - for _, outputChan := range outChans { - select { - case outputChan <- data: - case <-time.After(timeout): - } - } - - return nil -} diff --git a/vendor/github.com/cactus/go-statsd-client/statsd/doc.go b/vendor/github.com/cactus/go-statsd-client/statsd/doc.go deleted file mode 100644 index 722e98046..000000000 --- a/vendor/github.com/cactus/go-statsd-client/statsd/doc.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -Package statsd provides a StatsD client implementation that is safe for -concurrent use by multiple goroutines and for efficiency can be created and -reused. - -Example usage: - - // first create a client - client, err := statsd.New("127.0.0.1:8125", "test-client") - // handle any errors - if err != nil { - log.Fatal(err) - } - // make sure to clean up - defer client.Close() - - // Send a stat - err = client.Inc("stat1", 42, 1.0) - // handle any errors - if err != nil { - log.Printf("Error sending metric: %+v", err) - } - -*/ -package statsd diff --git a/vendor/github.com/cactus/go-statsd-client/statsd/main.go b/vendor/github.com/cactus/go-statsd-client/statsd/main.go deleted file mode 100644 index f5717f25c..000000000 --- a/vendor/github.com/cactus/go-statsd-client/statsd/main.go +++ /dev/null @@ -1,151 +0,0 @@ -package statsd - -import ( - "errors" - "fmt" - "math/rand" - "net" -) - -type Statter interface { - Inc(stat string, value int64, rate float32) error - Dec(stat string, value int64, rate float32) error - Gauge(stat string, value int64, rate float32) error - GaugeDelta(stat string, value int64, rate float32) error - Timing(stat string, delta int64, rate float32) error - Raw(stat string, value string, rate float32) error - SetPrefix(prefix string) - Close() error -} - - -type Client struct { - // underlying connection - c net.PacketConn - // resolved udp address - ra *net.UDPAddr - // prefix for statsd name - prefix string -} - -// Close closes the connection and cleans up. -func (s *Client) Close() error { - err := s.c.Close() - return err -} - -// Increments a statsd count type. -// stat is a string name for the metric. -// value is the integer value -// rate is the sample rate (0.0 to 1.0) -func (s *Client) Inc(stat string, value int64, rate float32) error { - dap := fmt.Sprintf("%d|c", value) - return s.Raw(stat, dap, rate) -} - -// Decrements a statsd count type. -// stat is a string name for the metric. -// value is the integer value. -// rate is the sample rate (0.0 to 1.0). -func (s *Client) Dec(stat string, value int64, rate float32) error { - return s.Inc(stat, -value, rate) -} - -// Submits/Updates a statsd gauge type. -// stat is a string name for the metric. -// value is the integer value. -// rate is the sample rate (0.0 to 1.0). -func (s *Client) Gauge(stat string, value int64, rate float32) error { - dap := fmt.Sprintf("%d|g", value) - return s.Raw(stat, dap, rate) -} - -// Submits a delta to a statsd gauge. -// stat is the string name for the metric. -// value is the (positive or negative) change. -// rate is the sample rate (0.0 to 1.0). -func (s *Client) GaugeDelta(stat string, value int64, rate float32) error { - dap := fmt.Sprintf("%+d|g", value) - return s.Raw(stat, dap, rate) -} - -// Submits a statsd timing type. -// stat is a string name for the metric. -// value is the integer value. -// rate is the sample rate (0.0 to 1.0). -func (s *Client) Timing(stat string, delta int64, rate float32) error { - dap := fmt.Sprintf("%d|ms", delta) - return s.Raw(stat, dap, rate) -} - -// Raw formats the statsd event data, handles sampling, prepares it, -// and sends it to the server. -// stat is the string name for the metric. -// value is a preformatted "raw" value string. -// rate is the sample rate (0.0 to 1.0). -func (s *Client) Raw(stat string, value string, rate float32) error { - if rate < 1 { - if rand.Float32() < rate { - value = fmt.Sprintf("%s|@%f", value, rate) - } else { - return nil - } - } - - if s.prefix != "" { - stat = fmt.Sprintf("%s.%s", s.prefix, stat) - } - - data := fmt.Sprintf("%s:%s", stat, value) - - _, err := s.send([]byte(data)) - if err != nil { - return err - } - return nil -} - -// Sets/Updates the statsd client prefix -func (s *Client) SetPrefix(prefix string) { - s.prefix = prefix -} - -// sends the data to the server endpoint -func (s *Client) send(data []byte) (int, error) { - // no need for locking here, as the underlying fdNet - // already serialized writes - n, err := s.c.(*net.UDPConn).WriteToUDP([]byte(data), s.ra) - if err != nil { - return 0, err - } - if n == 0 { - return n, errors.New("Wrote no bytes") - } - return n, nil -} - -// Returns a pointer to a new Client, and an error. -// addr is a string of the format "hostname:port", and must be parsable by -// net.ResolveUDPAddr. -// prefix is the statsd client prefix. Can be "" if no prefix is desired. -func New(addr, prefix string) (*Client, error) { - c, err := net.ListenPacket("udp", ":0") - if err != nil { - return nil, err - } - - ra, err := net.ResolveUDPAddr("udp", addr) - if err != nil { - return nil, err - } - - client := &Client{ - c: c, - ra: ra, - prefix: prefix} - - return client, nil -} - -// Compatibility alias -var Dial = New diff --git a/vendor/github.com/cactus/go-statsd-client/statsd/main_test.go b/vendor/github.com/cactus/go-statsd-client/statsd/main_test.go deleted file mode 100644 index 8d304a293..000000000 --- a/vendor/github.com/cactus/go-statsd-client/statsd/main_test.go +++ /dev/null @@ -1,152 +0,0 @@ -package statsd - -import ( - "bytes" - "log" - "net" - "reflect" - "testing" - "time" -) - -var statsdPacketTests = []struct { - Prefix string - Method string - Stat string - Value int64 - Rate float32 - Expected string -}{ - {"test", "Gauge", "gauge", 1, 1.0, "test.gauge:1|g"}, - {"test", "Inc", "count", 1, 0.999999, "test.count:1|c|@0.999999"}, - {"test", "Inc", "count", 1, 1.0, "test.count:1|c"}, - {"test", "Dec", "count", 1, 1.0, "test.count:-1|c"}, - {"test", "Timing", "timing", 1, 1.0, "test.timing:1|ms"}, - {"", "Inc", "count", 1, 1.0, "count:1|c"}, - {"", "GaugeDelta", "gauge", 1, 1.0, "gauge:+1|g"}, - {"", "GaugeDelta", "gauge", -1, 1.0, "gauge:-1|g"}, -} - -func TestClient(t *testing.T) { - l, err := newUDPListener("127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - for _, tt := range statsdPacketTests { - c, err := New(l.LocalAddr().String(), tt.Prefix) - if err != nil { - t.Fatal(err) - } - method := reflect.ValueOf(c).MethodByName(tt.Method) - e := method.Call([]reflect.Value{ - reflect.ValueOf(tt.Stat), - reflect.ValueOf(tt.Value), - reflect.ValueOf(tt.Rate)})[0] - errInter := e.Interface() - if errInter != nil { - t.Fatal(errInter.(error)) - } - - data := make([]byte, 128) - _, _, err = l.ReadFrom(data) - if err != nil { - c.Close() - t.Fatal(err) - } - - data = bytes.TrimRight(data, "\x00") - if bytes.Equal(data, []byte(tt.Expected)) != true { - c.Close() - t.Fatalf("%s got '%s' expected '%s'", tt.Method, data, tt.Expected) - } - c.Close() - } -} - -func TestNoopClient(t *testing.T) { - l, err := newUDPListener("127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - for _, tt := range statsdPacketTests { - c, err := NewNoop(l.LocalAddr().String(), tt.Prefix) - if err != nil { - t.Fatal(err) - } - method := reflect.ValueOf(c).MethodByName(tt.Method) - e := method.Call([]reflect.Value{ - reflect.ValueOf(tt.Stat), - reflect.ValueOf(tt.Value), - reflect.ValueOf(tt.Rate)})[0] - errInter := e.Interface() - if errInter != nil { - t.Fatal(errInter.(error)) - } - - data := make([]byte, 128) - n, _, err := l.ReadFrom(data) - // this is expected to error, since there should - // be no udp data sent, so the read will time out - if err == nil || n != 0 { - c.Close() - t.Fatal(err) - } - c.Close() - } -} - -func newUDPListener(addr string) (*net.UDPConn, error) { - l, err := net.ListenPacket("udp", addr) - if err != nil { - return nil, err - } - l.SetDeadline(time.Now().Add(100 * time.Millisecond)) - l.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) - l.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)) - return l.(*net.UDPConn), nil -} - -func ExampleClient() { - // first create a client - client, err := Dial("127.0.0.1:8125", "test-client") - // handle any errors - if err != nil { - log.Fatal(err) - } - // make sure to clean up - defer client.Close() - - // Send a stat - err = client.Inc("stat1", 42, 1.0) - // handle any errors - if err != nil { - log.Printf("Error sending metric: %+v", err) - } -} - -func ExampleNoopClient() { - // use interface so we can sub noop client if needed - var client Statter - var err error - - // first try to create a real client - client, err = Dial("not-resolvable:8125", "test-client") - // Lets say real client creation fails, but you don't care enough about - // stats that you don't want your program to run. Just log an error and - // make a NoopClient instead - if err != nil { - log.Println("Remote endpoint did not resolve. Disabling stats", err) - client, err = NewNoop() - } - // make sure to clean up - defer client.Close() - - // Send a stat - err = client.Inc("stat1", 42, 1.0) - // handle any errors - if err != nil { - log.Printf("Error sending metric: %+v", err) - } -} diff --git a/vendor/github.com/cactus/go-statsd-client/statsd/noop.go b/vendor/github.com/cactus/go-statsd-client/statsd/noop.go deleted file mode 100644 index ee11e74a9..000000000 --- a/vendor/github.com/cactus/go-statsd-client/statsd/noop.go +++ /dev/null @@ -1,74 +0,0 @@ -package statsd - -type NoopClient struct { - // prefix for statsd name - prefix string -} - -// Close closes the connection and cleans up. -func (s *NoopClient) Close() error { - return nil -} - -// Increments a statsd count type. -// stat is a string name for the metric. -// value is the integer value -// rate is the sample rate (0.0 to 1.0) -func (s *NoopClient) Inc(stat string, value int64, rate float32) error { - return nil -} - -// Decrements a statsd count type. -// stat is a string name for the metric. -// value is the integer value. -// rate is the sample rate (0.0 to 1.0). -func (s *NoopClient) Dec(stat string, value int64, rate float32) error { - return nil -} - -// Submits/Updates a statsd gauge type. -// stat is a string name for the metric. -// value is the integer value. -// rate is the sample rate (0.0 to 1.0). -func (s *NoopClient) Gauge(stat string, value int64, rate float32) error { - return nil -} - -// Submits a delta to a statsd gauge. -// stat is the string name for the metric. -// value is the (positive or negative) change. -// rate is the sample rate (0.0 to 1.0). -func (s *NoopClient) GaugeDelta(stat string, value int64, rate float32) error { - return nil -} - -// Submits a statsd timing type. -// stat is a string name for the metric. -// value is the integer value. -// rate is the sample rate (0.0 to 1.0). -func (s *NoopClient) Timing(stat string, delta int64, rate float32) error { - return nil -} - -// Raw formats the statsd event data, handles sampling, prepares it, -// and sends it to the server. -// stat is the string name for the metric. -// value is the preformatted "raw" value string. -// rate is the sample rate (0.0 to 1.0). -func (s *NoopClient) Raw(stat string, value string, rate float32) error { - return nil -} - -// Sets/Updates the statsd client prefix -func (s *NoopClient) SetPrefix(prefix string) { - s.prefix = prefix -} - -// Returns a pointer to a new NoopClient, and an error (always nil, just -// supplied to support api convention). -// Use variadic arguments to support identical format as New, or a more -// conventional no argument form. -func NewNoop(a ...interface{}) (*NoopClient, error) { - noopClient := &NoopClient{} - return noopClient, nil -} diff --git a/vendor/github.com/cactus/go-statsd-client/statsd/test-client/main.go b/vendor/github.com/cactus/go-statsd-client/statsd/test-client/main.go deleted file mode 100644 index 484c60381..000000000 --- a/vendor/github.com/cactus/go-statsd-client/statsd/test-client/main.go +++ /dev/null @@ -1,90 +0,0 @@ -package main - -import ( - "github.com/cactus/go-statsd-client/statsd" - flags "github.com/jessevdk/go-flags" - "fmt" - "log" - "os" - "time" -) - -func main() { - - // command line flags - var opts struct { - HostPort string `long:"host" default:"127.0.0.1:8125" description:"host:port of statsd server"` - Prefix string `long:"prefix" default:"test-client" description:"Statsd prefix"` - StatType string `long:"type" default:"count" description:"stat type to send. Can be timing, count, guage"` - StatValue int64 `long:"value" default:"1" description:"Value to send"` - Name string `short:"n" long:"name" default:"counter" description:"stat name"` - Rate float32 `short:"r" long:"rate" default:"1.0" description:"sample rate"` - Volume int `short:"c" long:"count" default:"1000" description:"Number of stats to send. Volume."` - Noop bool `long:"noop" default:"false" description:"Use noop client"` - Duration time.Duration `short:"d" long:"duration" default:"10s" description:"How long to spread the volume across. Each second of duration volume/seconds events will be sent."` - } - - // parse said flags - _, err := flags.Parse(&opts) - if err != nil { - if e, ok := err.(*flags.Error); ok { - if e.Type == flags.ErrHelp { - os.Exit(0) - } - } - fmt.Printf("Error: %+v\n", err) - os.Exit(1) - } - - var client statsd.Statter - if !opts.Noop { - client, err = statsd.New(opts.HostPort, opts.Prefix) - if err != nil { - log.Fatal(err) - } - defer client.Close() - } else { - client, err = statsd.NewNoop(opts.HostPort, opts.Prefix) - } - - var stat func(stat string, value int64, rate float32) error - switch opts.StatType { - case "count": - stat = func(stat string, value int64, rate float32) error { - return client.Inc(stat, value, rate) - } - case "gauge": - stat = func(stat string, value int64, rate float32) error { - return client.Gauge(stat, value, rate) - } - case "timing": - stat = func(stat string, value int64, rate float32) error { - return client.Timing(stat, value, rate) - } - default: - log.Fatal("Unsupported state type") - } - - pertick := opts.Volume / int(opts.Duration.Seconds()) / 10 - // add some extra tiem, because the first tick takes a while - ender := time.After(opts.Duration + 100*time.Millisecond) - c := time.Tick(time.Second / 10) - count := 0 - for { - select { - case <-c: - for x := 0; x < pertick; x++ { - err := stat(opts.Name, opts.StatValue, opts.Rate) - if err != nil { - log.Printf("Got Error: %+v", err) - break - } - count += 1 - } - case <-ender: - log.Printf("%d events called", count) - os.Exit(0) - return - } - } -} diff --git a/vendor/github.com/cihub/seelog/LICENSE.txt b/vendor/github.com/cihub/seelog/LICENSE.txt deleted file mode 100644 index 8c7068141..000000000 --- a/vendor/github.com/cihub/seelog/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2012, Cloud Instruments Co., Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Cloud Instruments Co., Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/cihub/seelog/README.markdown b/vendor/github.com/cihub/seelog/README.markdown deleted file mode 100644 index b9acd2d1d..000000000 --- a/vendor/github.com/cihub/seelog/README.markdown +++ /dev/null @@ -1,113 +0,0 @@ -Seelog -======= - -Seelog is a powerful and easy-to-learn logging framework that provides functionality for flexible dispatching, filtering, and formatting log messages. -It is natively written in the [Go](http://golang.org/) programming language. - -[![Build Status](https://drone.io/github.com/cihub/seelog/status.png)](https://drone.io/github.com/cihub/seelog/latest) - -Features ------------------- - -* Xml configuring to be able to change logger parameters without recompilation -* Changing configurations on the fly without app restart -* Possibility to set different log configurations for different project files and functions -* Adjustable message formatting -* Simultaneous log output to multiple streams -* Choosing logger priority strategy to minimize performance hit -* Different output writers - * Console writer - * File writer - * Buffered writer (Chunk writer) - * Rolling log writer (Logging with rotation) - * SMTP writer - * Others... (See [Wiki](https://github.com/cihub/seelog/wiki)) -* Log message wrappers (JSON, XML, etc.) -* Global variables and functions for easy usage in standalone apps -* Functions for flexible usage in libraries - -Quick-start ------------ - -```go -package main - -import log "github.com/cihub/seelog" - -func main() { - defer log.Flush() - log.Info("Hello from Seelog!") -} -``` - -Installation ------------- - -If you don't have the Go development environment installed, visit the -[Getting Started](http://golang.org/doc/install.html) document and follow the instructions. Once you're ready, execute the following command: - -``` -go get -u github.com/cihub/seelog -``` - -*IMPORTANT*: If you are not using the latest release version of Go, check out this [wiki page](https://github.com/cihub/seelog/wiki/Notes-on-'go-get') - -Documentation ---------------- - -Seelog has github wiki pages, which contain detailed how-tos references: https://github.com/cihub/seelog/wiki - -Examples ---------------- - -Seelog examples can be found here: [seelog-examples](https://github.com/cihub/seelog-examples) - -Issues ---------------- - -Feel free to push issues that could make Seelog better: https://github.com/cihub/seelog/issues - -Changelog ---------------- - -* **v2.5** : Interaction with other systems. Part 2: custom receivers - * Finished custom receivers feature. Check [wiki](https://github.com/cihub/seelog/wiki/custom-receivers) - * Added 'LoggerFromCustomReceiver' - * Added 'LoggerFromWriterWithMinLevelAndFormat' - * Added 'LoggerFromCustomReceiver' - * Added 'LoggerFromParamConfigAs...' -* **v2.4** : Interaction with other systems. Part 1: wrapping seelog - * Added configurable caller stack skip logic - * Added 'SetAdditionalStackDepth' to 'LoggerInterface' -* **v2.3** : Rethinking 'rolling' receiver - * Reimplemented 'rolling' receiver - * Added 'Max rolls' feature for 'rolling' receiver with type='date' - * Fixed 'rolling' receiver issue: renaming on Windows -* **v2.2** : go1.0 compatibility point [go1.0 tag] - * Fixed internal bugs - * Added 'ANSI n [;k]' format identifier: %EscN - * Made current release go1 compatible -* **v2.1** : Some new features - * Rolling receiver archiving option. - * Added format identifier: %Line - * Smtp: added paths to PEM files directories - * Added format identifier: %FuncShort - * Warn, Error and Critical methods now return an error -* **v2.0** : Second major release. BREAKING CHANGES. - * Support of binaries with stripped symbols - * Added log strategy: adaptive - * Critical message now forces Flush() - * Added predefined formats: xml-debug, xml-debug-short, xml, xml-short, json-debug, json-debug-short, json, json-short, debug, debug-short, fast - * Added receiver: conn (network connection writer) - * BREAKING CHANGE: added Tracef, Debugf, Infof, etc. to satisfy the print/printf principle - * Bug fixes -* **v1.0** : Initial release. Features: - * Xml config - * Changing configurations on the fly without app restart - * Contraints and exceptions - * Formatting - * Log strategies: sync, async loop, async timer - * Receivers: buffered, console, file, rolling, smtp - - - diff --git a/vendor/github.com/cihub/seelog/behavior_adaptive_test.go b/vendor/github.com/cihub/seelog/behavior_adaptive_test.go deleted file mode 100644 index e99194930..000000000 --- a/vendor/github.com/cihub/seelog/behavior_adaptive_test.go +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "strconv" - "testing" -) - -func countSequencedRowsInFile(filePath string) (int64, error) { - bts, err := ioutil.ReadFile(filePath) - if err != nil { - return 0, err - } - - bufReader := bufio.NewReader(bytes.NewBuffer(bts)) - - var gotCounter int64 - for { - line, _, bufErr := bufReader.ReadLine() - if bufErr != nil && bufErr != io.EOF { - return 0, bufErr - } - - lineString := string(line) - if lineString == "" { - break - } - - intVal, atoiErr := strconv.ParseInt(lineString, 10, 64) - if atoiErr != nil { - return 0, atoiErr - } - - if intVal != gotCounter { - return 0, fmt.Errorf("wrong order: %d Expected: %d\n", intVal, gotCounter) - } - - gotCounter++ - } - - return gotCounter, nil -} - -func Test_Adaptive(t *testing.T) { - fileName := "beh_test_adaptive.log" - count := 100 - - Current.Close() - - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - return - } - defer func() { - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - } - }() - - testConfig := ` - - - - - - - -` - - logger, _ := LoggerFromConfigAsString(testConfig) - - err := ReplaceLogger(logger) - if err != nil { - t.Error(err) - return - } - - for i := 0; i < count; i++ { - Trace(strconv.Itoa(i)) - } - - Flush() - - gotCount, err := countSequencedRowsInFile(fileName) - if err != nil { - t.Error(err) - return - } - - if int64(count) != gotCount { - t.Errorf("wrong count of log messages. Expected: %v, got: %v.", count, gotCount) - return - } - - Current.Close() -} diff --git a/vendor/github.com/cihub/seelog/behavior_adaptivelogger.go b/vendor/github.com/cihub/seelog/behavior_adaptivelogger.go deleted file mode 100644 index 11f10c210..000000000 --- a/vendor/github.com/cihub/seelog/behavior_adaptivelogger.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "math" - "time" -) - -var ( - adaptiveLoggerMaxInterval = time.Minute - adaptiveLoggerMaxCriticalMsgCount = uint32(1000) -) - -// asyncAdaptiveLogger represents asynchronous adaptive logger which acts like -// an async timer logger, but its interval depends on the current message count -// in the queue. -// -// Interval = I, minInterval = m, maxInterval = M, criticalMsgCount = C, msgCount = c: -// I = m + (C - Min(c, C)) / C * (M - m) -type asyncAdaptiveLogger struct { - asyncLogger - minInterval time.Duration - criticalMsgCount uint32 - maxInterval time.Duration -} - -// newAsyncLoopLogger creates a new asynchronous adaptive logger -func newAsyncAdaptiveLogger( - config *logConfig, - minInterval time.Duration, - maxInterval time.Duration, - criticalMsgCount uint32) (*asyncAdaptiveLogger, error) { - - if minInterval <= 0 { - return nil, errors.New("async adaptive logger min interval should be > 0") - } - - if maxInterval > adaptiveLoggerMaxInterval { - return nil, fmt.Errorf("async adaptive logger max interval should be <= %s", - adaptiveLoggerMaxInterval) - } - - if criticalMsgCount <= 0 { - return nil, errors.New("async adaptive logger critical msg count should be > 0") - } - - if criticalMsgCount > adaptiveLoggerMaxCriticalMsgCount { - return nil, fmt.Errorf("async adaptive logger critical msg count should be <= %s", - adaptiveLoggerMaxInterval) - } - - asnAdaptiveLogger := new(asyncAdaptiveLogger) - - asnAdaptiveLogger.asyncLogger = *newAsyncLogger(config) - asnAdaptiveLogger.minInterval = minInterval - asnAdaptiveLogger.maxInterval = maxInterval - asnAdaptiveLogger.criticalMsgCount = criticalMsgCount - - go asnAdaptiveLogger.processQueue() - - return asnAdaptiveLogger, nil -} - -func (asnAdaptiveLogger *asyncAdaptiveLogger) processItem() (closed bool, itemCount int) { - asnAdaptiveLogger.queueHasElements.L.Lock() - defer asnAdaptiveLogger.queueHasElements.L.Unlock() - - for asnAdaptiveLogger.msgQueue.Len() == 0 && !asnAdaptiveLogger.Closed() { - asnAdaptiveLogger.queueHasElements.Wait() - } - - if asnAdaptiveLogger.Closed() { - return true, asnAdaptiveLogger.msgQueue.Len() - } - - asnAdaptiveLogger.processQueueElement() - return false, asnAdaptiveLogger.msgQueue.Len() - 1 -} - -// I = m + (C - Min(c, C)) / C * (M - m) => -// I = m + cDiff * mDiff, -// cDiff = (C - Min(c, C)) / C) -// mDiff = (M - m) -func (asnAdaptiveLogger *asyncAdaptiveLogger) calcAdaptiveInterval(msgCount int) time.Duration { - critCountF := float64(asnAdaptiveLogger.criticalMsgCount) - cDiff := (critCountF - math.Min(float64(msgCount), critCountF)) / critCountF - mDiff := float64(asnAdaptiveLogger.maxInterval - asnAdaptiveLogger.minInterval) - - return asnAdaptiveLogger.minInterval + time.Duration(cDiff*mDiff) -} - -func (asnAdaptiveLogger *asyncAdaptiveLogger) processQueue() { - for !asnAdaptiveLogger.Closed() { - closed, itemCount := asnAdaptiveLogger.processItem() - - if closed { - break - } - - interval := asnAdaptiveLogger.calcAdaptiveInterval(itemCount) - - <-time.After(interval) - } -} diff --git a/vendor/github.com/cihub/seelog/behavior_asynclogger.go b/vendor/github.com/cihub/seelog/behavior_asynclogger.go deleted file mode 100644 index 75231067b..000000000 --- a/vendor/github.com/cihub/seelog/behavior_asynclogger.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "container/list" - "fmt" - "sync" -) - -// MaxQueueSize is the critical number of messages in the queue that result in an immediate flush. -const ( - MaxQueueSize = 10000 -) - -type msgQueueItem struct { - level LogLevel - context LogContextInterface - message fmt.Stringer -} - -// asyncLogger represents common data for all asynchronous loggers -type asyncLogger struct { - commonLogger - msgQueue *list.List - queueHasElements *sync.Cond -} - -// newAsyncLogger creates a new asynchronous logger -func newAsyncLogger(config *logConfig) *asyncLogger { - asnLogger := new(asyncLogger) - - asnLogger.msgQueue = list.New() - asnLogger.queueHasElements = sync.NewCond(new(sync.Mutex)) - - asnLogger.commonLogger = *newCommonLogger(config, asnLogger) - - return asnLogger -} - -func (asnLogger *asyncLogger) innerLog( - level LogLevel, - context LogContextInterface, - message fmt.Stringer) { - - asnLogger.addMsgToQueue(level, context, message) -} - -func (asnLogger *asyncLogger) Close() { - asnLogger.m.Lock() - defer asnLogger.m.Unlock() - - if !asnLogger.Closed() { - asnLogger.flushQueue(true) - asnLogger.config.RootDispatcher.Flush() - - if err := asnLogger.config.RootDispatcher.Close(); err != nil { - reportInternalError(err) - } - - asnLogger.closedM.Lock() - asnLogger.closed = true - asnLogger.closedM.Unlock() - asnLogger.queueHasElements.Broadcast() - } -} - -func (asnLogger *asyncLogger) Flush() { - asnLogger.m.Lock() - defer asnLogger.m.Unlock() - - if !asnLogger.Closed() { - asnLogger.flushQueue(true) - asnLogger.config.RootDispatcher.Flush() - } -} - -func (asnLogger *asyncLogger) flushQueue(lockNeeded bool) { - if lockNeeded { - asnLogger.queueHasElements.L.Lock() - defer asnLogger.queueHasElements.L.Unlock() - } - - for asnLogger.msgQueue.Len() > 0 { - asnLogger.processQueueElement() - } -} - -func (asnLogger *asyncLogger) processQueueElement() { - if asnLogger.msgQueue.Len() > 0 { - backElement := asnLogger.msgQueue.Front() - msg, _ := backElement.Value.(msgQueueItem) - asnLogger.processLogMsg(msg.level, msg.message, msg.context) - asnLogger.msgQueue.Remove(backElement) - } -} - -func (asnLogger *asyncLogger) addMsgToQueue( - level LogLevel, - context LogContextInterface, - message fmt.Stringer) { - - if !asnLogger.Closed() { - asnLogger.queueHasElements.L.Lock() - defer asnLogger.queueHasElements.L.Unlock() - - if asnLogger.msgQueue.Len() >= MaxQueueSize { - fmt.Printf("Seelog queue overflow: more than %v messages in the queue. Flushing.\n", MaxQueueSize) - asnLogger.flushQueue(false) - } - - queueItem := msgQueueItem{level, context, message} - - asnLogger.msgQueue.PushBack(queueItem) - asnLogger.queueHasElements.Broadcast() - } else { - err := fmt.Errorf("queue closed! Cannot process element: %d %#v", level, message) - reportInternalError(err) - } -} diff --git a/vendor/github.com/cihub/seelog/behavior_asyncloop_test.go b/vendor/github.com/cihub/seelog/behavior_asyncloop_test.go deleted file mode 100644 index 142c4fcff..000000000 --- a/vendor/github.com/cihub/seelog/behavior_asyncloop_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "strconv" - "testing" -) - -func Test_Asyncloop(t *testing.T) { - fileName := "beh_test_asyncloop.log" - count := 100 - - Current.Close() - - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - return - } - defer func() { - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - } - }() - - testConfig := ` - - - - - - - -` - - logger, _ := LoggerFromConfigAsString(testConfig) - err := ReplaceLogger(logger) - if err != nil { - t.Error(err) - return - } - - for i := 0; i < count; i++ { - Trace(strconv.Itoa(i)) - } - - Flush() - - gotCount, err := countSequencedRowsInFile(fileName) - if err != nil { - t.Error(err) - return - } - - if int64(count) != gotCount { - t.Errorf("wrong count of log messages. Expected: %v, got: %v.", count, gotCount) - return - } - - Current.Close() -} - -func Test_AsyncloopOff(t *testing.T) { - fileName := "beh_test_asyncloopoff.log" - count := 100 - - Current.Close() - - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - return - } - - testConfig := ` - - - - - - - -` - - logger, _ := LoggerFromConfigAsString(testConfig) - err := ReplaceLogger(logger) - if err != nil { - t.Error(err) - return - } - - for i := 0; i < count; i++ { - Trace(strconv.Itoa(i)) - } - - Flush() - - ex, err := fileExists(fileName) - if err != nil { - t.Error(err) - } - if ex { - t.Errorf("logger at level OFF is not expected to create log file at all.") - defer func() { - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - } - }() - } - - Current.Close() -} diff --git a/vendor/github.com/cihub/seelog/behavior_asynclooplogger.go b/vendor/github.com/cihub/seelog/behavior_asynclooplogger.go deleted file mode 100644 index fdb354230..000000000 --- a/vendor/github.com/cihub/seelog/behavior_asynclooplogger.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -// asyncLoopLogger represents asynchronous logger which processes the log queue in -// a 'for' loop -type asyncLoopLogger struct { - asyncLogger -} - -// newAsyncLoopLogger creates a new asynchronous loop logger -func newAsyncLoopLogger(config *logConfig) *asyncLoopLogger { - - asnLoopLogger := new(asyncLoopLogger) - - asnLoopLogger.asyncLogger = *newAsyncLogger(config) - - go asnLoopLogger.processQueue() - - return asnLoopLogger -} - -func (asnLoopLogger *asyncLoopLogger) processItem() (closed bool) { - asnLoopLogger.queueHasElements.L.Lock() - defer asnLoopLogger.queueHasElements.L.Unlock() - - for asnLoopLogger.msgQueue.Len() == 0 && !asnLoopLogger.Closed() { - asnLoopLogger.queueHasElements.Wait() - } - - if asnLoopLogger.Closed() { - return true - } - - asnLoopLogger.processQueueElement() - return false -} - -func (asnLoopLogger *asyncLoopLogger) processQueue() { - for !asnLoopLogger.Closed() { - closed := asnLoopLogger.processItem() - - if closed { - break - } - } -} diff --git a/vendor/github.com/cihub/seelog/behavior_asynctimer_test.go b/vendor/github.com/cihub/seelog/behavior_asynctimer_test.go deleted file mode 100644 index 37bfa6a90..000000000 --- a/vendor/github.com/cihub/seelog/behavior_asynctimer_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "strconv" - "testing" -) - -func Test_Asynctimer(t *testing.T) { - fileName := "beh_test_asynctimer.log" - count := 100 - - Current.Close() - - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - return - } - defer func() { - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - } - }() - - testConfig := ` - - - - - - - -` - - logger, _ := LoggerFromConfigAsString(testConfig) - err := ReplaceLogger(logger) - if err != nil { - t.Error(err) - return - } - - for i := 0; i < count; i++ { - Trace(strconv.Itoa(i)) - } - - Flush() - - gotCount, err := countSequencedRowsInFile(fileName) - if err != nil { - t.Error(err) - return - } - - if int64(count) != gotCount { - t.Errorf("wrong count of log messages. Expected: %v, got: %v.", count, gotCount) - return - } - - Current.Close() -} diff --git a/vendor/github.com/cihub/seelog/behavior_asynctimerlogger.go b/vendor/github.com/cihub/seelog/behavior_asynctimerlogger.go deleted file mode 100644 index 581e984df..000000000 --- a/vendor/github.com/cihub/seelog/behavior_asynctimerlogger.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "time" -) - -// asyncTimerLogger represents asynchronous logger which processes the log queue each -// 'duration' nanoseconds -type asyncTimerLogger struct { - asyncLogger - interval time.Duration -} - -// newAsyncLoopLogger creates a new asynchronous loop logger -func newAsyncTimerLogger(config *logConfig, interval time.Duration) (*asyncTimerLogger, error) { - - if interval <= 0 { - return nil, errors.New("async logger interval should be > 0") - } - - asnTimerLogger := new(asyncTimerLogger) - - asnTimerLogger.asyncLogger = *newAsyncLogger(config) - asnTimerLogger.interval = interval - - go asnTimerLogger.processQueue() - - return asnTimerLogger, nil -} - -func (asnTimerLogger *asyncTimerLogger) processItem() (closed bool) { - asnTimerLogger.queueHasElements.L.Lock() - defer asnTimerLogger.queueHasElements.L.Unlock() - - for asnTimerLogger.msgQueue.Len() == 0 && !asnTimerLogger.Closed() { - asnTimerLogger.queueHasElements.Wait() - } - - if asnTimerLogger.Closed() { - return true - } - - asnTimerLogger.processQueueElement() - return false -} - -func (asnTimerLogger *asyncTimerLogger) processQueue() { - for !asnTimerLogger.Closed() { - closed := asnTimerLogger.processItem() - - if closed { - break - } - - <-time.After(asnTimerLogger.interval) - } -} diff --git a/vendor/github.com/cihub/seelog/behavior_synclogger.go b/vendor/github.com/cihub/seelog/behavior_synclogger.go deleted file mode 100644 index 1a6932ae3..000000000 --- a/vendor/github.com/cihub/seelog/behavior_synclogger.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" -) - -// syncLogger performs logging in the same goroutine where 'Trace/Debug/...' -// func was called -type syncLogger struct { - commonLogger -} - -// newSyncLogger creates a new synchronous logger -func newSyncLogger(config *logConfig) *syncLogger { - syncLogger := new(syncLogger) - - syncLogger.commonLogger = *newCommonLogger(config, syncLogger) - - return syncLogger -} - -func (syncLogger *syncLogger) innerLog( - level LogLevel, - context LogContextInterface, - message fmt.Stringer) { - - syncLogger.processLogMsg(level, message, context) -} - -func (syncLogger *syncLogger) Close() { - syncLogger.m.Lock() - defer syncLogger.m.Unlock() - - if !syncLogger.Closed() { - if err := syncLogger.config.RootDispatcher.Close(); err != nil { - reportInternalError(err) - } - syncLogger.closedM.Lock() - syncLogger.closed = true - syncLogger.closedM.Unlock() - } -} - -func (syncLogger *syncLogger) Flush() { - syncLogger.m.Lock() - defer syncLogger.m.Unlock() - - if !syncLogger.Closed() { - syncLogger.config.RootDispatcher.Flush() - } -} diff --git a/vendor/github.com/cihub/seelog/behavior_synclogger_test.go b/vendor/github.com/cihub/seelog/behavior_synclogger_test.go deleted file mode 100644 index ddcbbb60b..000000000 --- a/vendor/github.com/cihub/seelog/behavior_synclogger_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "strconv" - "testing" -) - -func Test_Sync(t *testing.T) { - fileName := "beh_test_sync.log" - count := 100 - - Current.Close() - - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - return - } - defer func() { - if e := tryRemoveFile(fileName); e != nil { - t.Error(e) - } - }() - - testConfig := ` - - - - - - - -` - - logger, _ := LoggerFromConfigAsString(testConfig) - err := ReplaceLogger(logger) - if err != nil { - t.Error(err) - return - } - - for i := 0; i < count; i++ { - Trace(strconv.Itoa(i)) - } - - gotCount, err := countSequencedRowsInFile(fileName) - if err != nil { - t.Error(err) - return - } - - if int64(count) != gotCount { - t.Errorf("wrong count of log messages. Expected: %v, got: %v.", count, gotCount) - return - } - - Current.Close() -} diff --git a/vendor/github.com/cihub/seelog/cfg_config.go b/vendor/github.com/cihub/seelog/cfg_config.go deleted file mode 100644 index e06dc2751..000000000 --- a/vendor/github.com/cihub/seelog/cfg_config.go +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "bytes" - "encoding/xml" - "io" - "os" -) - -// LoggerFromConfigAsFile creates logger with config from file. File should contain valid seelog xml. -func LoggerFromConfigAsFile(fileName string) (LoggerInterface, error) { - file, err := os.Open(fileName) - if err != nil { - return nil, err - } - defer file.Close() - - conf, err := configFromReader(file) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} - -// LoggerFromConfigAsBytes creates a logger with config from bytes stream. Bytes should contain valid seelog xml. -func LoggerFromConfigAsBytes(data []byte) (LoggerInterface, error) { - conf, err := configFromReader(bytes.NewBuffer(data)) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} - -// LoggerFromConfigAsString creates a logger with config from a string. String should contain valid seelog xml. -func LoggerFromConfigAsString(data string) (LoggerInterface, error) { - return LoggerFromConfigAsBytes([]byte(data)) -} - -// LoggerFromParamConfigAsFile does the same as LoggerFromConfigAsFile, but includes special parser options. -// See 'CfgParseParams' comments. -func LoggerFromParamConfigAsFile(fileName string, parserParams *CfgParseParams) (LoggerInterface, error) { - file, err := os.Open(fileName) - if err != nil { - return nil, err - } - defer file.Close() - - conf, err := configFromReaderWithConfig(file, parserParams) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} - -// LoggerFromParamConfigAsBytes does the same as LoggerFromConfigAsBytes, but includes special parser options. -// See 'CfgParseParams' comments. -func LoggerFromParamConfigAsBytes(data []byte, parserParams *CfgParseParams) (LoggerInterface, error) { - conf, err := configFromReaderWithConfig(bytes.NewBuffer(data), parserParams) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} - -// LoggerFromParamConfigAsString does the same as LoggerFromConfigAsString, but includes special parser options. -// See 'CfgParseParams' comments. -func LoggerFromParamConfigAsString(data string, parserParams *CfgParseParams) (LoggerInterface, error) { - return LoggerFromParamConfigAsBytes([]byte(data), parserParams) -} - -// LoggerFromWriterWithMinLevel is shortcut for LoggerFromWriterWithMinLevelAndFormat(output, minLevel, DefaultMsgFormat) -func LoggerFromWriterWithMinLevel(output io.Writer, minLevel LogLevel) (LoggerInterface, error) { - return LoggerFromWriterWithMinLevelAndFormat(output, minLevel, DefaultMsgFormat) -} - -// LoggerFromWriterWithMinLevelAndFormat creates a proxy logger that uses io.Writer as the -// receiver with minimal level = minLevel and with specified format. -// -// All messages with level more or equal to minLevel will be written to output and -// formatted using the default seelog format. -// -// Can be called for usage with non-Seelog systems -func LoggerFromWriterWithMinLevelAndFormat(output io.Writer, minLevel LogLevel, format string) (LoggerInterface, error) { - constraints, err := newMinMaxConstraints(minLevel, CriticalLvl) - if err != nil { - return nil, err - } - formatter, err := newFormatter(format) - if err != nil { - return nil, err - } - dispatcher, err := newSplitDispatcher(formatter, []interface{}{output}) - if err != nil { - return nil, err - } - - conf, err := newConfig(constraints, make([]*logLevelException, 0), dispatcher, syncloggerTypeFromString, nil, nil) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} - -// LoggerFromXMLDecoder creates logger with config from a XML decoder starting from a specific node. -// It should contain valid seelog xml, except for root node name. -func LoggerFromXMLDecoder(xmlParser *xml.Decoder, rootNode xml.Token) (LoggerInterface, error) { - conf, err := configFromXMLDecoder(xmlParser, rootNode) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} - -// LoggerFromCustomReceiver creates a proxy logger that uses a CustomReceiver as the -// receiver. -// -// All messages will be sent to the specified custom receiver without additional -// formatting ('%Msg' format is used). -// -// Check CustomReceiver, RegisterReceiver for additional info. -// -// NOTE 1: CustomReceiver.AfterParse is only called when a receiver is instantiated -// by the config parser while parsing config. So, if you are not planning to use the -// same CustomReceiver for both proxying (via LoggerFromCustomReceiver call) and -// loading from config, just leave AfterParse implementation empty. -// -// NOTE 2: Unlike RegisterReceiver, LoggerFromCustomReceiver takes an already initialized -// instance that implements CustomReceiver. So, fill it with data and perform any initialization -// logic before calling this func and it won't be lost. -// -// So: -// * RegisterReceiver takes value just to get the reflect.Type from it and then -// instantiate it as many times as config is reloaded. -// -// * LoggerFromCustomReceiver takes value and uses it without modification and -// reinstantiation, directy passing it to the dispatcher tree. -func LoggerFromCustomReceiver(receiver CustomReceiver) (LoggerInterface, error) { - constraints, err := newMinMaxConstraints(TraceLvl, CriticalLvl) - if err != nil { - return nil, err - } - - output, err := newCustomReceiverDispatcherByValue(msgonlyformatter, receiver, "user-proxy", CustomReceiverInitArgs{}) - if err != nil { - return nil, err - } - dispatcher, err := newSplitDispatcher(msgonlyformatter, []interface{}{output}) - if err != nil { - return nil, err - } - - conf, err := newConfig(constraints, make([]*logLevelException, 0), dispatcher, syncloggerTypeFromString, nil, nil) - if err != nil { - return nil, err - } - - return createLoggerFromConfig(conf) -} diff --git a/vendor/github.com/cihub/seelog/cfg_errors.go b/vendor/github.com/cihub/seelog/cfg_errors.go deleted file mode 100644 index c1fb4d101..000000000 --- a/vendor/github.com/cihub/seelog/cfg_errors.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" -) - -var ( - errNodeMustHaveChildren = errors.New("node must have children") - errNodeCannotHaveChildren = errors.New("node cannot have children") -) - -type unexpectedChildElementError struct { - baseError -} - -func newUnexpectedChildElementError(msg string) *unexpectedChildElementError { - custmsg := "Unexpected child element: " + msg - return &unexpectedChildElementError{baseError{message: custmsg}} -} - -type missingArgumentError struct { - baseError -} - -func newMissingArgumentError(nodeName, attrName string) *missingArgumentError { - custmsg := "Output '" + nodeName + "' has no '" + attrName + "' attribute" - return &missingArgumentError{baseError{message: custmsg}} -} - -type unexpectedAttributeError struct { - baseError -} - -func newUnexpectedAttributeError(nodeName, attr string) *unexpectedAttributeError { - custmsg := nodeName + " has unexpected attribute: " + attr - return &unexpectedAttributeError{baseError{message: custmsg}} -} diff --git a/vendor/github.com/cihub/seelog/cfg_logconfig.go b/vendor/github.com/cihub/seelog/cfg_logconfig.go deleted file mode 100644 index 0898c51c8..000000000 --- a/vendor/github.com/cihub/seelog/cfg_logconfig.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" -) - -type loggerTypeFromString uint8 - -const ( - syncloggerTypeFromString = iota - asyncLooploggerTypeFromString - asyncTimerloggerTypeFromString - adaptiveLoggerTypeFromString - defaultloggerTypeFromString = asyncLooploggerTypeFromString -) - -const ( - syncloggerTypeFromStringStr = "sync" - asyncloggerTypeFromStringStr = "asyncloop" - asyncTimerloggerTypeFromStringStr = "asynctimer" - adaptiveLoggerTypeFromStringStr = "adaptive" -) - -// asyncTimerLoggerData represents specific data for async timer logger -type asyncTimerLoggerData struct { - AsyncInterval uint32 -} - -// adaptiveLoggerData represents specific data for adaptive timer logger -type adaptiveLoggerData struct { - MinInterval uint32 - MaxInterval uint32 - CriticalMsgCount uint32 -} - -var loggerTypeToStringRepresentations = map[loggerTypeFromString]string{ - syncloggerTypeFromString: syncloggerTypeFromStringStr, - asyncLooploggerTypeFromString: asyncloggerTypeFromStringStr, - asyncTimerloggerTypeFromString: asyncTimerloggerTypeFromStringStr, - adaptiveLoggerTypeFromString: adaptiveLoggerTypeFromStringStr, -} - -// getLoggerTypeFromString parses a string and returns a corresponding logger type, if successful. -func getLoggerTypeFromString(logTypeString string) (level loggerTypeFromString, found bool) { - for logType, logTypeStr := range loggerTypeToStringRepresentations { - if logTypeStr == logTypeString { - return logType, true - } - } - - return 0, false -} - -// logConfig stores logging configuration. Contains messages dispatcher, allowed log level rules -// (general constraints and exceptions), and messages formats (used by nodes of dispatcher tree) -type logConfig struct { - Constraints logLevelConstraints // General log level rules (>min and - - - - - -` - - conf, err := configFromReader(strings.NewReader(testConfig)) - if err != nil { - t.Errorf("parse error: %s\n", err.Error()) - return - } - - context, err := currentContext() - if err != nil { - t.Errorf("cannot get current context:" + err.Error()) - return - } - firstContext, err := getFirstContext() - if err != nil { - t.Errorf("cannot get current context:" + err.Error()) - return - } - secondContext, err := getSecondContext() - if err != nil { - t.Errorf("cannot get current context:" + err.Error()) - return - } - - if !conf.IsAllowed(TraceLvl, context) { - t.Errorf("error: deny trace in current context") - } - if conf.IsAllowed(TraceLvl, firstContext) { - t.Errorf("error: allow trace in first context") - } - if conf.IsAllowed(ErrorLvl, context) { - t.Errorf("error: allow error in current context") - } - if !conf.IsAllowed(ErrorLvl, secondContext) { - t.Errorf("error: deny error in second context") - } - - // cache test - if !conf.IsAllowed(TraceLvl, context) { - t.Errorf("error: deny trace in current context") - } - if conf.IsAllowed(TraceLvl, firstContext) { - t.Errorf("error: allow trace in first context") - } - if conf.IsAllowed(ErrorLvl, context) { - t.Errorf("error: allow error in current context") - } - if !conf.IsAllowed(ErrorLvl, secondContext) { - t.Errorf("error: deny error in second context") - } -} - -func getFirstContext() (LogContextInterface, error) { - return currentContext() -} - -func getSecondContext() (LogContextInterface, error) { - return currentContext() -} diff --git a/vendor/github.com/cihub/seelog/cfg_parser.go b/vendor/github.com/cihub/seelog/cfg_parser.go deleted file mode 100644 index c5fbf46c0..000000000 --- a/vendor/github.com/cihub/seelog/cfg_parser.go +++ /dev/null @@ -1,1238 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "crypto/tls" - "encoding/xml" - "errors" - "fmt" - "io" - "strconv" - "strings" - "time" -) - -// Names of elements of seelog config. -const ( - seelogConfigID = "seelog" - outputsID = "outputs" - formatsID = "formats" - minLevelID = "minlevel" - maxLevelID = "maxlevel" - levelsID = "levels" - exceptionsID = "exceptions" - exceptionID = "exception" - funcPatternID = "funcpattern" - filePatternID = "filepattern" - formatID = "format" - formatAttrID = "format" - formatKeyAttrID = "id" - outputFormatID = "formatid" - pathID = "path" - fileWriterID = "file" - smtpWriterID = "smtp" - senderaddressID = "senderaddress" - senderNameID = "sendername" - recipientID = "recipient" - mailHeaderID = "header" - mailHeaderNameID = "name" - mailHeaderValueID = "value" - addressID = "address" - hostNameID = "hostname" - hostPortID = "hostport" - userNameID = "username" - userPassID = "password" - cACertDirpathID = "cacertdirpath" - subjectID = "subject" - splitterDispatcherID = "splitter" - consoleWriterID = "console" - customReceiverID = "custom" - customNameAttrID = "name" - customNameDataAttrPrefix = "data-" - filterDispatcherID = "filter" - filterLevelsAttrID = "levels" - rollingfileWriterID = "rollingfile" - rollingFileTypeAttr = "type" - rollingFilePathAttr = "filename" - rollingFileMaxSizeAttr = "maxsize" - rollingFileMaxRollsAttr = "maxrolls" - rollingFileNameModeAttr = "namemode" - rollingFileDataPatternAttr = "datepattern" - rollingFileArchiveAttr = "archivetype" - rollingFileArchivePathAttr = "archivepath" - bufferedWriterID = "buffered" - bufferedSizeAttr = "size" - bufferedFlushPeriodAttr = "flushperiod" - loggerTypeFromStringAttr = "type" - asyncLoggerIntervalAttr = "asyncinterval" - adaptLoggerMinIntervalAttr = "mininterval" - adaptLoggerMaxIntervalAttr = "maxinterval" - adaptLoggerCriticalMsgCountAttr = "critmsgcount" - predefinedPrefix = "std:" - connWriterID = "conn" - connWriterAddrAttr = "addr" - connWriterNetAttr = "net" - connWriterReconnectOnMsgAttr = "reconnectonmsg" - connWriterUseTLSAttr = "tls" - connWriterInsecureSkipVerifyAttr = "insecureskipverify" -) - -// CustomReceiverProducer is the signature of the function CfgParseParams needs to create -// custom receivers. -type CustomReceiverProducer func(CustomReceiverInitArgs) (CustomReceiver, error) - -// CfgParseParams represent specific parse options or flags used by parser. It is used if seelog parser needs -// some special directives or additional info to correctly parse a config. -type CfgParseParams struct { - // CustomReceiverProducers expose the same functionality as RegisterReceiver func - // but only in the scope (context) of the config parse func instead of a global package scope. - // - // It means that if you use custom receivers in your code, you may either register them globally once with - // RegisterReceiver or you may call funcs like LoggerFromParamConfigAsFile (with 'ParamConfig') - // and use CustomReceiverProducers to provide custom producer funcs. - // - // A producer func is called when config parser processes a '' element. It takes the 'name' attribute - // of the element and tries to find a match in two places: - // 1) CfgParseParams.CustomReceiverProducers map - // 2) Global type map, filled by RegisterReceiver - // - // If a match is found in the CustomReceiverProducers map, parser calls the corresponding producer func - // passing the init args to it. The func takes exactly the same args as CustomReceiver.AfterParse. - // The producer func must return a correct receiver or an error. If case of error, seelog will behave - // in the same way as with any other config error. - // - // You may use this param to set custom producers in case you need to pass some context when instantiating - // a custom receiver or if you frequently change custom receivers with different parameters or in any other - // situation where package-level registering (RegisterReceiver) is not an option for you. - CustomReceiverProducers map[string]CustomReceiverProducer -} - -func (cfg *CfgParseParams) String() string { - return fmt.Sprintf("CfgParams: {custom_recs=%d}", len(cfg.CustomReceiverProducers)) -} - -type elementMapEntry struct { - constructor func(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) -} - -var elementMap map[string]elementMapEntry -var predefinedFormats map[string]*formatter - -func init() { - elementMap = map[string]elementMapEntry{ - fileWriterID: {createfileWriter}, - splitterDispatcherID: {createSplitter}, - customReceiverID: {createCustomReceiver}, - filterDispatcherID: {createFilter}, - consoleWriterID: {createConsoleWriter}, - rollingfileWriterID: {createRollingFileWriter}, - bufferedWriterID: {createbufferedWriter}, - smtpWriterID: {createSMTPWriter}, - connWriterID: {createconnWriter}, - } - - err := fillPredefinedFormats() - if err != nil { - panic(fmt.Sprintf("Seelog couldn't start: predefined formats creation failed. Error: %s", err.Error())) - } -} - -func fillPredefinedFormats() error { - predefinedFormatsWithoutPrefix := map[string]string{ - "xml-debug": `%Lev%Msg%RelFile%Func%Line`, - "xml-debug-short": `%Ns%l%Msg

%RelFile

%Func`, - "xml": `%Lev%Msg`, - "xml-short": `%Ns%l%Msg`, - - "json-debug": `{"time":%Ns,"lev":"%Lev","msg":"%Msg","path":"%RelFile","func":"%Func","line":"%Line"}`, - "json-debug-short": `{"t":%Ns,"l":"%Lev","m":"%Msg","p":"%RelFile","f":"%Func"}`, - "json": `{"time":%Ns,"lev":"%Lev","msg":"%Msg"}`, - "json-short": `{"t":%Ns,"l":"%Lev","m":"%Msg"}`, - - "debug": `[%LEVEL] %RelFile:%Func.%Line %Date %Time %Msg%n`, - "debug-short": `[%LEVEL] %Date %Time %Msg%n`, - "fast": `%Ns %l %Msg%n`, - } - - predefinedFormats = make(map[string]*formatter) - - for formatKey, format := range predefinedFormatsWithoutPrefix { - formatter, err := newFormatter(format) - if err != nil { - return err - } - - predefinedFormats[predefinedPrefix+formatKey] = formatter - } - - return nil -} - -// configFromXMLDecoder parses data from a given XML decoder. -// Returns parsed config which can be used to create logger in case no errors occured. -// Returns error if format is incorrect or anything happened. -func configFromXMLDecoder(xmlParser *xml.Decoder, rootNode xml.Token) (*logConfig, error) { - return configFromXMLDecoderWithConfig(xmlParser, rootNode, nil) -} - -// configFromXMLDecoderWithConfig parses data from a given XML decoder. -// Returns parsed config which can be used to create logger in case no errors occured. -// Returns error if format is incorrect or anything happened. -func configFromXMLDecoderWithConfig(xmlParser *xml.Decoder, rootNode xml.Token, cfg *CfgParseParams) (*logConfig, error) { - _, ok := rootNode.(xml.StartElement) - if !ok { - return nil, errors.New("rootNode must be XML startElement") - } - - config, err := unmarshalNode(xmlParser, rootNode) - if err != nil { - return nil, err - } - if config == nil { - return nil, errors.New("xml has no content") - } - - return configFromXMLNodeWithConfig(config, cfg) -} - -// configFromReader parses data from a given reader. -// Returns parsed config which can be used to create logger in case no errors occured. -// Returns error if format is incorrect or anything happened. -func configFromReader(reader io.Reader) (*logConfig, error) { - return configFromReaderWithConfig(reader, nil) -} - -// configFromReaderWithConfig parses data from a given reader. -// Returns parsed config which can be used to create logger in case no errors occured. -// Returns error if format is incorrect or anything happened. -func configFromReaderWithConfig(reader io.Reader, cfg *CfgParseParams) (*logConfig, error) { - config, err := unmarshalConfig(reader) - if err != nil { - return nil, err - } - - if config.name != seelogConfigID { - return nil, errors.New("root xml tag must be '" + seelogConfigID + "'") - } - - return configFromXMLNodeWithConfig(config, cfg) -} - -func configFromXMLNodeWithConfig(config *xmlNode, cfg *CfgParseParams) (*logConfig, error) { - err := checkUnexpectedAttribute( - config, - minLevelID, - maxLevelID, - levelsID, - loggerTypeFromStringAttr, - asyncLoggerIntervalAttr, - adaptLoggerMinIntervalAttr, - adaptLoggerMaxIntervalAttr, - adaptLoggerCriticalMsgCountAttr, - ) - if err != nil { - return nil, err - } - - err = checkExpectedElements(config, optionalElement(outputsID), optionalElement(formatsID), optionalElement(exceptionsID)) - if err != nil { - return nil, err - } - - constraints, err := getConstraints(config) - if err != nil { - return nil, err - } - - exceptions, err := getExceptions(config) - if err != nil { - return nil, err - } - err = checkDistinctExceptions(exceptions) - if err != nil { - return nil, err - } - - formats, err := getFormats(config) - if err != nil { - return nil, err - } - - dispatcher, err := getOutputsTree(config, formats, cfg) - if err != nil { - // If we open several files, but then fail to parse the config, we should close - // those files before reporting that config is invalid. - if dispatcher != nil { - dispatcher.Close() - } - - return nil, err - } - - loggerType, logData, err := getloggerTypeFromStringData(config) - if err != nil { - return nil, err - } - - return newConfig(constraints, exceptions, dispatcher, loggerType, logData, cfg) -} - -func getConstraints(node *xmlNode) (logLevelConstraints, error) { - minLevelStr, isMinLevel := node.attributes[minLevelID] - maxLevelStr, isMaxLevel := node.attributes[maxLevelID] - levelsStr, isLevels := node.attributes[levelsID] - - if isLevels && (isMinLevel && isMaxLevel) { - return nil, errors.New("for level declaration use '" + levelsID + "'' OR '" + minLevelID + - "', '" + maxLevelID + "'") - } - - offString := LogLevel(Off).String() - - if (isLevels && strings.TrimSpace(levelsStr) == offString) || - (isMinLevel && !isMaxLevel && minLevelStr == offString) { - - return newOffConstraints() - } - - if isLevels { - levels, err := parseLevels(levelsStr) - if err != nil { - return nil, err - } - return newListConstraints(levels) - } - - var minLevel = LogLevel(TraceLvl) - if isMinLevel { - found := true - minLevel, found = LogLevelFromString(minLevelStr) - if !found { - return nil, errors.New("declared " + minLevelID + " not found: " + minLevelStr) - } - } - - var maxLevel = LogLevel(CriticalLvl) - if isMaxLevel { - found := true - maxLevel, found = LogLevelFromString(maxLevelStr) - if !found { - return nil, errors.New("declared " + maxLevelID + " not found: " + maxLevelStr) - } - } - - return newMinMaxConstraints(minLevel, maxLevel) -} - -func parseLevels(str string) ([]LogLevel, error) { - levelsStrArr := strings.Split(strings.Replace(str, " ", "", -1), ",") - var levels []LogLevel - for _, levelStr := range levelsStrArr { - level, found := LogLevelFromString(levelStr) - if !found { - return nil, errors.New("declared level not found: " + levelStr) - } - - levels = append(levels, level) - } - - return levels, nil -} - -func getExceptions(config *xmlNode) ([]*logLevelException, error) { - var exceptions []*logLevelException - - var exceptionsNode *xmlNode - for _, child := range config.children { - if child.name == exceptionsID { - exceptionsNode = child - break - } - } - - if exceptionsNode == nil { - return exceptions, nil - } - - err := checkUnexpectedAttribute(exceptionsNode) - if err != nil { - return nil, err - } - - err = checkExpectedElements(exceptionsNode, multipleMandatoryElements("exception")) - if err != nil { - return nil, err - } - - for _, exceptionNode := range exceptionsNode.children { - if exceptionNode.name != exceptionID { - return nil, errors.New("incorrect nested element in exceptions section: " + exceptionNode.name) - } - - err := checkUnexpectedAttribute(exceptionNode, minLevelID, maxLevelID, levelsID, funcPatternID, filePatternID) - if err != nil { - return nil, err - } - - constraints, err := getConstraints(exceptionNode) - if err != nil { - return nil, errors.New("incorrect " + exceptionsID + " node: " + err.Error()) - } - - funcPattern, isFuncPattern := exceptionNode.attributes[funcPatternID] - filePattern, isFilePattern := exceptionNode.attributes[filePatternID] - if !isFuncPattern { - funcPattern = "*" - } - if !isFilePattern { - filePattern = "*" - } - - exception, err := newLogLevelException(funcPattern, filePattern, constraints) - if err != nil { - return nil, errors.New("incorrect exception node: " + err.Error()) - } - - exceptions = append(exceptions, exception) - } - - return exceptions, nil -} - -func checkDistinctExceptions(exceptions []*logLevelException) error { - for i, exception := range exceptions { - for j, exception1 := range exceptions { - if i == j { - continue - } - - if exception.FuncPattern() == exception1.FuncPattern() && - exception.FilePattern() == exception1.FilePattern() { - - return fmt.Errorf("there are two or more duplicate exceptions. Func: %v, file %v", - exception.FuncPattern(), exception.FilePattern()) - } - } - } - - return nil -} - -func getFormats(config *xmlNode) (map[string]*formatter, error) { - formats := make(map[string]*formatter, 0) - - var formatsNode *xmlNode - for _, child := range config.children { - if child.name == formatsID { - formatsNode = child - break - } - } - - if formatsNode == nil { - return formats, nil - } - - err := checkUnexpectedAttribute(formatsNode) - if err != nil { - return nil, err - } - - err = checkExpectedElements(formatsNode, multipleMandatoryElements("format")) - if err != nil { - return nil, err - } - - for _, formatNode := range formatsNode.children { - if formatNode.name != formatID { - return nil, errors.New("incorrect nested element in " + formatsID + " section: " + formatNode.name) - } - - err := checkUnexpectedAttribute(formatNode, formatKeyAttrID, formatID) - if err != nil { - return nil, err - } - - id, isID := formatNode.attributes[formatKeyAttrID] - formatStr, isFormat := formatNode.attributes[formatAttrID] - if !isID { - return nil, errors.New("format has no '" + formatKeyAttrID + "' attribute") - } - if !isFormat { - return nil, errors.New("format[" + id + "] has no '" + formatAttrID + "' attribute") - } - - formatter, err := newFormatter(formatStr) - if err != nil { - return nil, err - } - - formats[id] = formatter - } - - return formats, nil -} - -func getloggerTypeFromStringData(config *xmlNode) (logType loggerTypeFromString, logData interface{}, err error) { - logTypeStr, loggerTypeExists := config.attributes[loggerTypeFromStringAttr] - - if !loggerTypeExists { - return defaultloggerTypeFromString, nil, nil - } - - logType, found := getLoggerTypeFromString(logTypeStr) - - if !found { - return 0, nil, fmt.Errorf("unknown logger type: %s", logTypeStr) - } - - if logType == asyncTimerloggerTypeFromString { - intervalStr, intervalExists := config.attributes[asyncLoggerIntervalAttr] - if !intervalExists { - return 0, nil, newMissingArgumentError(config.name, asyncLoggerIntervalAttr) - } - - interval, err := strconv.ParseUint(intervalStr, 10, 32) - if err != nil { - return 0, nil, err - } - - logData = asyncTimerLoggerData{uint32(interval)} - } else if logType == adaptiveLoggerTypeFromString { - - // Min interval - minIntStr, minIntExists := config.attributes[adaptLoggerMinIntervalAttr] - if !minIntExists { - return 0, nil, newMissingArgumentError(config.name, adaptLoggerMinIntervalAttr) - } - minInterval, err := strconv.ParseUint(minIntStr, 10, 32) - if err != nil { - return 0, nil, err - } - - // Max interval - maxIntStr, maxIntExists := config.attributes[adaptLoggerMaxIntervalAttr] - if !maxIntExists { - return 0, nil, newMissingArgumentError(config.name, adaptLoggerMaxIntervalAttr) - } - maxInterval, err := strconv.ParseUint(maxIntStr, 10, 32) - if err != nil { - return 0, nil, err - } - - // Critical msg count - criticalMsgCountStr, criticalMsgCountExists := config.attributes[adaptLoggerCriticalMsgCountAttr] - if !criticalMsgCountExists { - return 0, nil, newMissingArgumentError(config.name, adaptLoggerCriticalMsgCountAttr) - } - criticalMsgCount, err := strconv.ParseUint(criticalMsgCountStr, 10, 32) - if err != nil { - return 0, nil, err - } - - logData = adaptiveLoggerData{uint32(minInterval), uint32(maxInterval), uint32(criticalMsgCount)} - } - - return logType, logData, nil -} - -func getOutputsTree(config *xmlNode, formats map[string]*formatter, cfg *CfgParseParams) (dispatcherInterface, error) { - var outputsNode *xmlNode - for _, child := range config.children { - if child.name == outputsID { - outputsNode = child - break - } - } - - if outputsNode != nil { - err := checkUnexpectedAttribute(outputsNode, outputFormatID) - if err != nil { - return nil, err - } - - formatter, err := getCurrentFormat(outputsNode, defaultformatter, formats) - if err != nil { - return nil, err - } - - output, err := createSplitter(outputsNode, formatter, formats, cfg) - if err != nil { - return nil, err - } - - dispatcher, ok := output.(dispatcherInterface) - if ok { - return dispatcher, nil - } - } - - console, err := newConsoleWriter() - if err != nil { - return nil, err - } - return newSplitDispatcher(defaultformatter, []interface{}{console}) -} - -func getCurrentFormat(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter) (*formatter, error) { - formatID, isFormatID := node.attributes[outputFormatID] - if !isFormatID { - return formatFromParent, nil - } - - format, ok := formats[formatID] - if ok { - return format, nil - } - - // Test for predefined format match - pdFormat, pdOk := predefinedFormats[formatID] - - if !pdOk { - return nil, errors.New("formatid = '" + formatID + "' doesn't exist") - } - - return pdFormat, nil -} - -func createInnerReceivers(node *xmlNode, format *formatter, formats map[string]*formatter, cfg *CfgParseParams) ([]interface{}, error) { - var outputs []interface{} - for _, childNode := range node.children { - entry, ok := elementMap[childNode.name] - if !ok { - return nil, errors.New("unnknown tag '" + childNode.name + "' in outputs section") - } - - output, err := entry.constructor(childNode, format, formats, cfg) - if err != nil { - return nil, err - } - - outputs = append(outputs, output) - } - - return outputs, nil -} - -func createSplitter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - err := checkUnexpectedAttribute(node, outputFormatID) - if err != nil { - return nil, err - } - - if !node.hasChildren() { - return nil, errNodeMustHaveChildren - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - receivers, err := createInnerReceivers(node, currentFormat, formats, cfg) - if err != nil { - return nil, err - } - - return newSplitDispatcher(currentFormat, receivers) -} - -func createCustomReceiver(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - dataCustomPrefixes := make(map[string]string) - // Expecting only 'formatid', 'name' and 'data-' attrs - for attr, attrval := range node.attributes { - isExpected := false - if attr == outputFormatID || - attr == customNameAttrID { - isExpected = true - } - if strings.HasPrefix(attr, customNameDataAttrPrefix) { - dataCustomPrefixes[attr[len(customNameDataAttrPrefix):]] = attrval - isExpected = true - } - if !isExpected { - return nil, newUnexpectedAttributeError(node.name, attr) - } - } - - if node.hasChildren() { - return nil, errNodeCannotHaveChildren - } - customName, hasCustomName := node.attributes[customNameAttrID] - if !hasCustomName { - return nil, newMissingArgumentError(node.name, customNameAttrID) - } - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - args := CustomReceiverInitArgs{ - XmlCustomAttrs: dataCustomPrefixes, - } - - if cfg != nil && cfg.CustomReceiverProducers != nil { - if prod, ok := cfg.CustomReceiverProducers[customName]; ok { - rec, err := prod(args) - if err != nil { - return nil, err - } - creceiver, err := newCustomReceiverDispatcherByValue(currentFormat, rec, customName, args) - if err != nil { - return nil, err - } - err = rec.AfterParse(args) - if err != nil { - return nil, err - } - return creceiver, nil - } - } - - return newCustomReceiverDispatcher(currentFormat, customName, args) -} - -func createFilter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - err := checkUnexpectedAttribute(node, outputFormatID, filterLevelsAttrID) - if err != nil { - return nil, err - } - - if !node.hasChildren() { - return nil, errNodeMustHaveChildren - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - levelsStr, isLevels := node.attributes[filterLevelsAttrID] - if !isLevels { - return nil, newMissingArgumentError(node.name, filterLevelsAttrID) - } - - levels, err := parseLevels(levelsStr) - if err != nil { - return nil, err - } - - receivers, err := createInnerReceivers(node, currentFormat, formats, cfg) - if err != nil { - return nil, err - } - - return newFilterDispatcher(currentFormat, receivers, levels...) -} - -func createfileWriter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - err := checkUnexpectedAttribute(node, outputFormatID, pathID) - if err != nil { - return nil, err - } - - if node.hasChildren() { - return nil, errNodeCannotHaveChildren - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - path, isPath := node.attributes[pathID] - if !isPath { - return nil, newMissingArgumentError(node.name, pathID) - } - - fileWriter, err := newFileWriter(path) - if err != nil { - return nil, err - } - - return newFormattedWriter(fileWriter, currentFormat) -} - -// Creates new SMTP writer if encountered in the config file. -func createSMTPWriter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - err := checkUnexpectedAttribute(node, outputFormatID, senderaddressID, senderNameID, hostNameID, hostPortID, userNameID, userPassID, subjectID) - if err != nil { - return nil, err - } - // Node must have children. - if !node.hasChildren() { - return nil, errNodeMustHaveChildren - } - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - senderAddress, ok := node.attributes[senderaddressID] - if !ok { - return nil, newMissingArgumentError(node.name, senderaddressID) - } - senderName, ok := node.attributes[senderNameID] - if !ok { - return nil, newMissingArgumentError(node.name, senderNameID) - } - // Process child nodes scanning for recipient email addresses and/or CA certificate paths. - var recipientAddresses []string - var caCertDirPaths []string - var mailHeaders []string - for _, childNode := range node.children { - switch childNode.name { - // Extract recipient address from child nodes. - case recipientID: - address, ok := childNode.attributes[addressID] - if !ok { - return nil, newMissingArgumentError(childNode.name, addressID) - } - recipientAddresses = append(recipientAddresses, address) - // Extract CA certificate file path from child nodes. - case cACertDirpathID: - path, ok := childNode.attributes[pathID] - if !ok { - return nil, newMissingArgumentError(childNode.name, pathID) - } - caCertDirPaths = append(caCertDirPaths, path) - - // Extract email headers from child nodes. - case mailHeaderID: - headerName, ok := childNode.attributes[mailHeaderNameID] - if !ok { - return nil, newMissingArgumentError(childNode.name, mailHeaderNameID) - } - - headerValue, ok := childNode.attributes[mailHeaderValueID] - if !ok { - return nil, newMissingArgumentError(childNode.name, mailHeaderValueID) - } - - // Build header line - mailHeaders = append(mailHeaders, fmt.Sprintf("%s: %s", headerName, headerValue)) - default: - return nil, newUnexpectedChildElementError(childNode.name) - } - } - hostName, ok := node.attributes[hostNameID] - if !ok { - return nil, newMissingArgumentError(node.name, hostNameID) - } - - hostPort, ok := node.attributes[hostPortID] - if !ok { - return nil, newMissingArgumentError(node.name, hostPortID) - } - - // Check if the string can really be converted into int. - if _, err := strconv.Atoi(hostPort); err != nil { - return nil, errors.New("invalid host port number") - } - - userName, ok := node.attributes[userNameID] - if !ok { - return nil, newMissingArgumentError(node.name, userNameID) - } - - userPass, ok := node.attributes[userPassID] - if !ok { - return nil, newMissingArgumentError(node.name, userPassID) - } - - // subject is optionally set by configuration. - // default value is defined by DefaultSubjectPhrase constant in the writers_smtpwriter.go - var subjectPhrase = DefaultSubjectPhrase - - subject, ok := node.attributes[subjectID] - if ok { - subjectPhrase = subject - } - - smtpWriter := newSMTPWriter( - senderAddress, - senderName, - recipientAddresses, - hostName, - hostPort, - userName, - userPass, - caCertDirPaths, - subjectPhrase, - mailHeaders, - ) - - return newFormattedWriter(smtpWriter, currentFormat) -} - -func createConsoleWriter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - err := checkUnexpectedAttribute(node, outputFormatID) - if err != nil { - return nil, err - } - - if node.hasChildren() { - return nil, errNodeCannotHaveChildren - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - consoleWriter, err := newConsoleWriter() - if err != nil { - return nil, err - } - - return newFormattedWriter(consoleWriter, currentFormat) -} - -func createconnWriter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - if node.hasChildren() { - return nil, errNodeCannotHaveChildren - } - - err := checkUnexpectedAttribute(node, outputFormatID, connWriterAddrAttr, connWriterNetAttr, connWriterReconnectOnMsgAttr, connWriterUseTLSAttr, connWriterInsecureSkipVerifyAttr) - if err != nil { - return nil, err - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - addr, isAddr := node.attributes[connWriterAddrAttr] - if !isAddr { - return nil, newMissingArgumentError(node.name, connWriterAddrAttr) - } - - net, isNet := node.attributes[connWriterNetAttr] - if !isNet { - return nil, newMissingArgumentError(node.name, connWriterNetAttr) - } - - reconnectOnMsg := false - reconnectOnMsgStr, isReconnectOnMsgStr := node.attributes[connWriterReconnectOnMsgAttr] - if isReconnectOnMsgStr { - if reconnectOnMsgStr == "true" { - reconnectOnMsg = true - } else if reconnectOnMsgStr == "false" { - reconnectOnMsg = false - } else { - return nil, errors.New("node '" + node.name + "' has incorrect '" + connWriterReconnectOnMsgAttr + "' attribute value") - } - } - - useTLS := false - useTLSStr, isUseTLSStr := node.attributes[connWriterUseTLSAttr] - if isUseTLSStr { - if useTLSStr == "true" { - useTLS = true - } else if useTLSStr == "false" { - useTLS = false - } else { - return nil, errors.New("node '" + node.name + "' has incorrect '" + connWriterUseTLSAttr + "' attribute value") - } - if useTLS { - insecureSkipVerify := false - insecureSkipVerifyStr, isInsecureSkipVerify := node.attributes[connWriterInsecureSkipVerifyAttr] - if isInsecureSkipVerify { - if insecureSkipVerifyStr == "true" { - insecureSkipVerify = true - } else if insecureSkipVerifyStr == "false" { - insecureSkipVerify = false - } else { - return nil, errors.New("node '" + node.name + "' has incorrect '" + connWriterInsecureSkipVerifyAttr + "' attribute value") - } - } - config := tls.Config{InsecureSkipVerify: insecureSkipVerify} - connWriter := newTLSWriter(net, addr, reconnectOnMsg, &config) - return newFormattedWriter(connWriter, currentFormat) - } - } - - connWriter := newConnWriter(net, addr, reconnectOnMsg) - - return newFormattedWriter(connWriter, currentFormat) -} - -func createRollingFileWriter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - if node.hasChildren() { - return nil, errNodeCannotHaveChildren - } - - rollingTypeStr, isRollingType := node.attributes[rollingFileTypeAttr] - if !isRollingType { - return nil, newMissingArgumentError(node.name, rollingFileTypeAttr) - } - - rollingType, ok := rollingTypeFromString(rollingTypeStr) - if !ok { - return nil, errors.New("unknown rolling file type: " + rollingTypeStr) - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - path, isPath := node.attributes[rollingFilePathAttr] - if !isPath { - return nil, newMissingArgumentError(node.name, rollingFilePathAttr) - } - - rollingArchiveStr, archiveAttrExists := node.attributes[rollingFileArchiveAttr] - - var rArchiveType rollingArchiveType - var rArchivePath string - if !archiveAttrExists { - rArchiveType = rollingArchiveNone - rArchivePath = "" - } else { - rArchiveType, ok = rollingArchiveTypeFromString(rollingArchiveStr) - if !ok { - return nil, errors.New("unknown rolling archive type: " + rollingArchiveStr) - } - - if rArchiveType == rollingArchiveNone { - rArchivePath = "" - } else { - rArchivePath, ok = node.attributes[rollingFileArchivePathAttr] - if !ok { - rArchivePath, ok = rollingArchiveTypesDefaultNames[rArchiveType] - if !ok { - return nil, fmt.Errorf("cannot get default filename for archive type = %v", - rArchiveType) - } - } - } - } - - nameMode := rollingNameMode(rollingNameModePostfix) - nameModeStr, ok := node.attributes[rollingFileNameModeAttr] - if ok { - mode, found := rollingNameModeFromString(nameModeStr) - if !found { - return nil, errors.New("unknown rolling filename mode: " + nameModeStr) - } else { - nameMode = mode - } - } - - if rollingType == rollingTypeSize { - err := checkUnexpectedAttribute(node, outputFormatID, rollingFileTypeAttr, rollingFilePathAttr, - rollingFileMaxSizeAttr, rollingFileMaxRollsAttr, rollingFileArchiveAttr, - rollingFileArchivePathAttr, rollingFileNameModeAttr) - if err != nil { - return nil, err - } - - maxSizeStr, ok := node.attributes[rollingFileMaxSizeAttr] - if !ok { - return nil, newMissingArgumentError(node.name, rollingFileMaxSizeAttr) - } - - maxSize, err := strconv.ParseInt(maxSizeStr, 10, 64) - if err != nil { - return nil, err - } - - maxRolls := 0 - maxRollsStr, ok := node.attributes[rollingFileMaxRollsAttr] - if ok { - maxRolls, err = strconv.Atoi(maxRollsStr) - if err != nil { - return nil, err - } - } - - rollingWriter, err := newRollingFileWriterSize(path, rArchiveType, rArchivePath, maxSize, maxRolls, nameMode) - if err != nil { - return nil, err - } - - return newFormattedWriter(rollingWriter, currentFormat) - - } else if rollingType == rollingTypeTime { - err := checkUnexpectedAttribute(node, outputFormatID, rollingFileTypeAttr, rollingFilePathAttr, - rollingFileDataPatternAttr, rollingFileArchiveAttr, rollingFileMaxRollsAttr, - rollingFileArchivePathAttr, rollingFileNameModeAttr) - if err != nil { - return nil, err - } - - maxRolls := 0 - maxRollsStr, ok := node.attributes[rollingFileMaxRollsAttr] - if ok { - maxRolls, err = strconv.Atoi(maxRollsStr) - if err != nil { - return nil, err - } - } - - dataPattern, ok := node.attributes[rollingFileDataPatternAttr] - if !ok { - return nil, newMissingArgumentError(node.name, rollingFileDataPatternAttr) - } - - rollingWriter, err := newRollingFileWriterTime(path, rArchiveType, rArchivePath, maxRolls, dataPattern, rollingIntervalAny, nameMode) - if err != nil { - return nil, err - } - - return newFormattedWriter(rollingWriter, currentFormat) - } - - return nil, errors.New("incorrect rolling writer type " + rollingTypeStr) -} - -func createbufferedWriter(node *xmlNode, formatFromParent *formatter, formats map[string]*formatter, cfg *CfgParseParams) (interface{}, error) { - err := checkUnexpectedAttribute(node, outputFormatID, bufferedSizeAttr, bufferedFlushPeriodAttr) - if err != nil { - return nil, err - } - - if !node.hasChildren() { - return nil, errNodeMustHaveChildren - } - - currentFormat, err := getCurrentFormat(node, formatFromParent, formats) - if err != nil { - return nil, err - } - - sizeStr, isSize := node.attributes[bufferedSizeAttr] - if !isSize { - return nil, newMissingArgumentError(node.name, bufferedSizeAttr) - } - - size, err := strconv.Atoi(sizeStr) - if err != nil { - return nil, err - } - - flushPeriod := 0 - flushPeriodStr, isFlushPeriod := node.attributes[bufferedFlushPeriodAttr] - if isFlushPeriod { - flushPeriod, err = strconv.Atoi(flushPeriodStr) - if err != nil { - return nil, err - } - } - - // Inner writer couldn't have its own format, so we pass 'currentFormat' as its parent format - receivers, err := createInnerReceivers(node, currentFormat, formats, cfg) - if err != nil { - return nil, err - } - - formattedWriter, ok := receivers[0].(*formattedWriter) - if !ok { - return nil, errors.New("buffered writer's child is not writer") - } - - // ... and then we check that it hasn't changed - if formattedWriter.Format() != currentFormat { - return nil, errors.New("inner writer cannot have his own format") - } - - bufferedWriter, err := newBufferedWriter(formattedWriter.Writer(), size, time.Duration(flushPeriod)) - if err != nil { - return nil, err - } - - return newFormattedWriter(bufferedWriter, currentFormat) -} - -// Returns an error if node has any attributes not listed in expectedAttrs. -func checkUnexpectedAttribute(node *xmlNode, expectedAttrs ...string) error { - for attr := range node.attributes { - isExpected := false - for _, expected := range expectedAttrs { - if attr == expected { - isExpected = true - break - } - } - if !isExpected { - return newUnexpectedAttributeError(node.name, attr) - } - } - - return nil -} - -type expectedElementInfo struct { - name string - mandatory bool - multiple bool -} - -func optionalElement(name string) expectedElementInfo { - return expectedElementInfo{name, false, false} -} -func mandatoryElement(name string) expectedElementInfo { - return expectedElementInfo{name, true, false} -} -func multipleElements(name string) expectedElementInfo { - return expectedElementInfo{name, false, true} -} -func multipleMandatoryElements(name string) expectedElementInfo { - return expectedElementInfo{name, true, true} -} - -func checkExpectedElements(node *xmlNode, elements ...expectedElementInfo) error { - for _, element := range elements { - count := 0 - for _, child := range node.children { - if child.name == element.name { - count++ - } - } - - if count == 0 && element.mandatory { - return errors.New(node.name + " does not have mandatory subnode - " + element.name) - } - if count > 1 && !element.multiple { - return errors.New(node.name + " has more then one subnode - " + element.name) - } - } - - for _, child := range node.children { - isExpected := false - for _, element := range elements { - if child.name == element.name { - isExpected = true - } - } - - if !isExpected { - return errors.New(node.name + " has unexpected child: " + child.name) - } - } - - return nil -} diff --git a/vendor/github.com/cihub/seelog/cfg_parser_test.go b/vendor/github.com/cihub/seelog/cfg_parser_test.go deleted file mode 100644 index 107d53231..000000000 --- a/vendor/github.com/cihub/seelog/cfg_parser_test.go +++ /dev/null @@ -1,1089 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "path/filepath" - "regexp" - "strings" - "testing" -) - -type customTestReceiverOutput struct { - initCalled bool - dataPassed string - messageOutput string - levelOutput LogLevel - closed bool - flushed bool -} -type customTestReceiver struct{ co *customTestReceiverOutput } - -func (cr *customTestReceiver) ReceiveMessage(message string, level LogLevel, context LogContextInterface) error { - cr.co.messageOutput = message - cr.co.levelOutput = level - return nil -} - -func (cr *customTestReceiver) String() string { - return fmt.Sprintf("custom data='%s'", cr.co.dataPassed) -} - -func (cr *customTestReceiver) AfterParse(initArgs CustomReceiverInitArgs) error { - cr.co = new(customTestReceiverOutput) - cr.co.initCalled = true - cr.co.dataPassed = initArgs.XmlCustomAttrs["test"] - return nil -} - -func (cr *customTestReceiver) Flush() { - cr.co.flushed = true -} - -func (cr *customTestReceiver) Close() error { - cr.co.closed = true - return nil -} - -var re = regexp.MustCompile(`[^a-zA-Z0-9]+`) - -func getTestFileName(testName, postfix string) string { - if len(postfix) != 0 { - return strings.ToLower(re.ReplaceAllString(testName, "_")) + "_" + postfix + "_test.log" - } - return strings.ToLower(re.ReplaceAllString(testName, "_")) + "_test.log" -} - -var parserTests []parserTest - -type parserTest struct { - testName string - config string - expected *logConfig //interface{} - errorExpected bool - parserConfig *CfgParseParams -} - -func getParserTests() []parserTest { - if parserTests == nil { - parserTests = make([]parserTest, 0) - - testName := "Simple file output" - testLogFileName := getTestFileName(testName, "") - testConfig := ` - - - - - - ` - testExpected := new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testfileWriter, _ := newFileWriter(testLogFileName) - testHeadSplitter, _ := newSplitDispatcher(defaultformatter, []interface{}{testfileWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Filter dispatcher" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testfileWriter, _ = newFileWriter(testLogFileName) - testFilter, _ := newFilterDispatcher(defaultformatter, []interface{}{testfileWriter}, DebugLvl, InfoLvl, CriticalLvl) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testFilter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Console writer" - testConfig = ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ := newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "SMTP writer" - testConfig = ` - - - - - - - - - - - - ` - - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testSMTPWriter := newSMTPWriter( - "sa", - "sn", - []string{"ra1", "ra2", "ra3"}, - "hn", - "123", - "un", - "up", - []string{"cacdp1", "cacdp2"}, - DefaultSubjectPhrase, - nil, - ) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testSMTPWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "SMTP writer custom header and subject configuration" - testConfig = ` - - - - - -
-
-
-
- - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testSMTPWriter = newSMTPWriter( - "sa", - "sn", - []string{"ra1"}, - "hn", - "123", - "un", - "up", - []string{"cacdp1"}, - "ohlala", - []string{"Priority: Urgent", "Importance: high", "Sensitivity: Company-Confidential", "Auto-Submitted: auto-generated"}, - ) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testSMTPWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Default output" - testConfig = ` - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Asyncloop behavior" - testConfig = ` - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Asynctimer behavior" - testConfig = ` - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncTimerloggerTypeFromString - testExpected.LoggerData = asyncTimerLoggerData{101} - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Rolling file writer size" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriter, _ := newRollingFileWriterSize(testLogFileName, rollingArchiveNone, "", 100, 5, rollingNameModePostfix) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testrollingFileWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Rolling file writer archive zip" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriter, _ = newRollingFileWriterSize(testLogFileName, rollingArchiveZip, "log.zip", 100, 5, rollingNameModePostfix) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testrollingFileWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Rolling file writer archive zip with specified path" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriter, _ = newRollingFileWriterSize(testLogFileName, rollingArchiveZip, "test.zip", 100, 5, rollingNameModePrefix) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testrollingFileWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Rolling file writer archive none" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriter, _ = newRollingFileWriterSize(testLogFileName, rollingArchiveNone, "", 100, 5, rollingNameModePostfix) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testrollingFileWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Rolling file writer date" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriterTime, _ := newRollingFileWriterTime(testLogFileName, rollingArchiveNone, "", 0, "2006-01-02T15:04:05Z07:00", rollingIntervalAny, rollingNameModePostfix) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testrollingFileWriterTime}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Buffered writer" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriterTime, _ = newRollingFileWriterTime(testLogFileName, rollingArchiveNone, "", 0, "2006-01-02T15:04:05Z07:00", rollingIntervalDaily, rollingNameModePostfix) - testbufferedWriter, _ := newBufferedWriter(testrollingFileWriterTime, 100500, 100) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testbufferedWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Inner splitter output" - testLogFileName1 := getTestFileName(testName, "1") - testLogFileName2 := getTestFileName(testName, "2") - testLogFileName3 := getTestFileName(testName, "3") - testConfig = ` - - - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testfileWriter1, _ := newFileWriter(testLogFileName2) - testfileWriter2, _ := newFileWriter(testLogFileName3) - testInnerSplitter, _ := newSplitDispatcher(defaultformatter, []interface{}{testfileWriter1, testfileWriter2}) - testfileWriter, _ = newFileWriter(testLogFileName1) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testfileWriter, testInnerSplitter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - RegisterReceiver("custom-name-1", &customTestReceiver{}) - - testName = "Custom receiver 1" - testConfig = ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testCustomReceiver, _ := newCustomReceiverDispatcher(defaultformatter, "custom-name-1", CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": "set", - }, - }) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testCustomReceiver}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Custom receiver 2" - testConfig = ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - crec := &customTestReceiver{} - cargs := CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": "set2", - }, - } - crec.AfterParse(cargs) - testCustomReceiver2, _ := newCustomReceiverDispatcherByValue(defaultformatter, crec, "custom-name-2", cargs) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testCustomReceiver2}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - fnc := func(initArgs CustomReceiverInitArgs) (CustomReceiver, error) { - return &customTestReceiver{}, nil - } - cfg := CfgParseParams{ - CustomReceiverProducers: map[string]CustomReceiverProducer{ - "custom-name-2": CustomReceiverProducer(fnc), - }, - } - testExpected.Params = &cfg - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, &cfg}) - - RegisterReceiver("-", &customTestReceiver{}) - testName = "Custom receiver 3" - testConfig = ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - creccustom := &customTestReceiver{} - cargs3 := CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": "set3", - }, - } - creccustom.AfterParse(cargs3) - testCustomReceiver, _ = newCustomReceiverDispatcherByValue(defaultformatter, creccustom, "-", cargs3) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testCustomReceiver}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Custom receivers with formats" - testConfig = ` - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testCustomReceivers := make([]*customReceiverDispatcher, 3) - for i := 0; i < 3; i++ { - testCustomReceivers[i], _ = newCustomReceiverDispatcher(defaultformatter, "custom-name-1", CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": fmt.Sprintf("set%d", i+1), - }, - }) - } - - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testCustomReceivers[0], testCustomReceivers[1], testCustomReceivers[2]}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Format" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testfileWriter, _ = newFileWriter(testLogFileName) - testFormat, _ := newFormatter("%Level %Msg %File") - testHeadSplitter, _ = newSplitDispatcher(testFormat, []interface{}{testfileWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Format2" - testLogFileName = getTestFileName(testName, "") - testLogFileName1 = getTestFileName(testName, "1") - testConfig = ` - - - - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testfileWriter, _ = newFileWriter(testLogFileName) - testfileWriter1, _ = newFileWriter(testLogFileName1) - testFormat1, _ := newFormatter("%Level %Msg %File") - testFormat2, _ := newFormatter("%l %Msg") - formattedWriter, _ := newFormattedWriter(testfileWriter1, testFormat2) - testHeadSplitter, _ = newSplitDispatcher(testFormat1, []interface{}{testfileWriter, formattedWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Minlevel = warn" - testConfig = `` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(WarnLvl, CriticalLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Maxlevel = trace" - testConfig = `` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, TraceLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Level between info and error" - testConfig = `` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(InfoLvl, ErrorLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Off with minlevel" - testConfig = `` - testExpected = new(logConfig) - testExpected.Constraints, _ = newOffConstraints() - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Off with levels" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Levels list" - testConfig = `` - testExpected = new(logConfig) - testExpected.Constraints, _ = newListConstraints([]LogLevel{ - DebugLvl, InfoLvl, CriticalLvl}) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = asyncLooploggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Errors #1" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #2" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #3" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #4" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #5" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #6" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #7" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #8" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #9" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #10" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #11" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #12" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #13" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #14" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #15" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #16" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #17" - testLogFileName = getTestFileName(testName, "") - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #18" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #19" - testConfig = `` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Exceptions: restricting" - testConfig = - ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - listConstraint, _ := newOffConstraints() - exception, _ := newLogLevelException("Test*", "someFile.go", listConstraint) - testExpected.Exceptions = []*logLevelException{exception} - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Exceptions: allowing #1" - testConfig = - ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newListConstraints([]LogLevel{ErrorLvl}) - minMaxConstraint, _ := newMinMaxConstraints(TraceLvl, CriticalLvl) - exception, _ = newLogLevelException("*", "testfile.go", minMaxConstraint) - testExpected.Exceptions = []*logLevelException{exception} - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Exceptions: allowing #2" - testConfig = ` - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newOffConstraints() - minMaxConstraint, _ = newMinMaxConstraints(WarnLvl, CriticalLvl) - exception, _ = newLogLevelException("*", "testfile.go", minMaxConstraint) - testExpected.Exceptions = []*logLevelException{exception} - testconsoleWriter, _ = newConsoleWriter() - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testconsoleWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Predefined formats" - formatID := predefinedPrefix + "xml-debug-short" - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testconsoleWriter, _ = newConsoleWriter() - testFormat, _ = predefinedFormats[formatID] - testHeadSplitter, _ = newSplitDispatcher(testFormat, []interface{}{testconsoleWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Predefined formats redefine" - testLogFileName = getTestFileName(testName, "") - formatID = predefinedPrefix + "xml-debug-short" - testConfig = ` - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testfileWriter, _ = newFileWriter(testLogFileName) - testFormat, _ = newFormatter("%Level %Msg %File") - testHeadSplitter, _ = newSplitDispatcher(testFormat, []interface{}{testfileWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Conn writer 1" - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testConnWriter := newConnWriter("tcp", ":8888", false) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testConnWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Conn writer 2" - testConfig = ` - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testConnWriter = newConnWriter("tcp", ":8888", true) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{testConnWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - testName = "Errors #11" - testConfig = ` - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #12" - testConfig = ` - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #13" - testConfig = ` - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #14" - testConfig = ` - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #15" - testConfig = ` - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #16" - testConfig = ` - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #17" - testConfig = ` - - - - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #18" - testConfig = ` - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #19" - testConfig = ` - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #20" - testConfig = ` - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #21" - testConfig = ` - - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #22" - testConfig = ` - - - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #23" - testConfig = ` - - - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #24" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #25" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Errors #26" - testConfig = ` - - - - - ` - parserTests = append(parserTests, parserTest{testName, testConfig, nil, true, nil}) - - testName = "Buffered writer same formatid override" - testLogFileName = getTestFileName(testName, "") - testConfig = ` - - - - - - - - - - ` - testExpected = new(logConfig) - testExpected.Constraints, _ = newMinMaxConstraints(TraceLvl, CriticalLvl) - testExpected.Exceptions = nil - testrollingFileWriterTime, _ = newRollingFileWriterTime(testLogFileName, rollingArchiveNone, "", 0, "2006-01-02T15:04:05Z07:00", rollingIntervalDaily, rollingNameModePrefix) - testbufferedWriter, _ = newBufferedWriter(testrollingFileWriterTime, 100500, 100) - testFormat, _ = newFormatter("%Level %Msg %File 123") - formattedWriter, _ = newFormattedWriter(testbufferedWriter, testFormat) - testHeadSplitter, _ = newSplitDispatcher(defaultformatter, []interface{}{formattedWriter}) - testExpected.LogType = syncloggerTypeFromString - testExpected.RootDispatcher = testHeadSplitter - parserTests = append(parserTests, parserTest{testName, testConfig, testExpected, false, nil}) - - } - - return parserTests -} - -// Temporary solution: compare by string identity. Not the best solution in -// terms of performance, but a valid one in terms of comparison, because -// every seelog dispatcher/receiver must have a valid String() func -// that fully represents its internal parameters. -func configsAreEqual(conf1 *logConfig, conf2 interface{}) bool { - if conf1 == nil { - return conf2 == nil - } - if conf2 == nil { - return conf1 == nil - } - - // logConfig, ok := conf2 //.(*logConfig) - // if !ok { - // return false - // } - - return fmt.Sprintf("%v", conf1) == fmt.Sprintf("%v", conf2) //logConfig) -} - -func testLogFileFilter(fn string) bool { - return ".log" == filepath.Ext(fn) -} - -func cleanupAfterCfgTest(t *testing.T) { - toDel, err := getDirFilePaths(".", testLogFileFilter, true) - if nil != err { - t.Fatal("Cannot list files in test directory!") - } - - for _, p := range toDel { - err = tryRemoveFile(p) - if nil != err { - t.Errorf("cannot remove file %s in test directory: %s", p, err.Error()) - } - } -} - -func parseTest(test parserTest, t *testing.T) { - conf, err := configFromReaderWithConfig(strings.NewReader(test.config), test.parserConfig) - if /*err != nil &&*/ conf != nil && conf.RootDispatcher != nil { - defer func() { - if err = conf.RootDispatcher.Close(); err != nil { - t.Errorf("\n----ERROR while closing root dispatcher in %s test: %s", test.testName, err) - } - }() - } - - if (err != nil) != test.errorExpected { - t.Errorf("\n----ERROR in %s:\nConfig: %s\n* Expected error:%t. Got error: %t\n", - test.testName, test.config, test.errorExpected, (err != nil)) - if err != nil { - t.Logf("%s\n", err.Error()) - } - return - } - - if err == nil && !configsAreEqual(conf, test.expected) { - t.Errorf("\n----ERROR in %s:\nConfig: %s\n* Expected: %v. \n* Got: %v\n", - test.testName, test.config, test.expected, conf) - } -} - -func TestParser(t *testing.T) { - defer cleanupAfterCfgTest(t) - - for _, test := range getParserTests() { - parseTest(test, t) - } -} diff --git a/vendor/github.com/cihub/seelog/common_closer.go b/vendor/github.com/cihub/seelog/common_closer.go deleted file mode 100644 index 1319c2217..000000000 --- a/vendor/github.com/cihub/seelog/common_closer.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog diff --git a/vendor/github.com/cihub/seelog/common_constraints.go b/vendor/github.com/cihub/seelog/common_constraints.go deleted file mode 100644 index 23b3dd215..000000000 --- a/vendor/github.com/cihub/seelog/common_constraints.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "strings" -) - -// Represents constraints which form a general rule for log levels selection -type logLevelConstraints interface { - IsAllowed(level LogLevel) bool -} - -// A minMaxConstraints represents constraints which use minimal and maximal allowed log levels. -type minMaxConstraints struct { - min LogLevel - max LogLevel -} - -// newMinMaxConstraints creates a new minMaxConstraints struct with the specified min and max levels. -func newMinMaxConstraints(min LogLevel, max LogLevel) (*minMaxConstraints, error) { - if min > max { - return nil, fmt.Errorf("min level can't be greater than max. Got min: %d, max: %d", min, max) - } - if min < TraceLvl || min > CriticalLvl { - return nil, fmt.Errorf("min level can't be less than Trace or greater than Critical. Got min: %d", min) - } - if max < TraceLvl || max > CriticalLvl { - return nil, fmt.Errorf("max level can't be less than Trace or greater than Critical. Got max: %d", max) - } - - return &minMaxConstraints{min, max}, nil -} - -// IsAllowed returns true, if log level is in [min, max] range (inclusive). -func (minMaxConstr *minMaxConstraints) IsAllowed(level LogLevel) bool { - return level >= minMaxConstr.min && level <= minMaxConstr.max -} - -func (minMaxConstr *minMaxConstraints) String() string { - return fmt.Sprintf("Min: %s. Max: %s", minMaxConstr.min, minMaxConstr.max) -} - -//======================================================= - -// A listConstraints represents constraints which use allowed log levels list. -type listConstraints struct { - allowedLevels map[LogLevel]bool -} - -// newListConstraints creates a new listConstraints struct with the specified allowed levels. -func newListConstraints(allowList []LogLevel) (*listConstraints, error) { - if allowList == nil { - return nil, errors.New("list can't be nil") - } - - allowLevels, err := createMapFromList(allowList) - if err != nil { - return nil, err - } - err = validateOffLevel(allowLevels) - if err != nil { - return nil, err - } - - return &listConstraints{allowLevels}, nil -} - -func (listConstr *listConstraints) String() string { - allowedList := "List: " - - listLevel := make([]string, len(listConstr.allowedLevels)) - - var logLevel LogLevel - i := 0 - for logLevel = TraceLvl; logLevel <= Off; logLevel++ { - if listConstr.allowedLevels[logLevel] { - listLevel[i] = logLevel.String() - i++ - } - } - - allowedList += strings.Join(listLevel, ",") - - return allowedList -} - -func createMapFromList(allowedList []LogLevel) (map[LogLevel]bool, error) { - allowedLevels := make(map[LogLevel]bool, 0) - for _, level := range allowedList { - if level < TraceLvl || level > Off { - return nil, fmt.Errorf("level can't be less than Trace or greater than Critical. Got level: %d", level) - } - allowedLevels[level] = true - } - return allowedLevels, nil -} -func validateOffLevel(allowedLevels map[LogLevel]bool) error { - if _, ok := allowedLevels[Off]; ok && len(allowedLevels) > 1 { - return errors.New("logLevel Off cant be mixed with other levels") - } - - return nil -} - -// IsAllowed returns true, if log level is in allowed log levels list. -// If the list contains the only item 'common.Off' then IsAllowed will always return false for any input values. -func (listConstr *listConstraints) IsAllowed(level LogLevel) bool { - for l := range listConstr.allowedLevels { - if l == level && level != Off { - return true - } - } - - return false -} - -// AllowedLevels returns allowed levels configuration as a map. -func (listConstr *listConstraints) AllowedLevels() map[LogLevel]bool { - return listConstr.allowedLevels -} - -//======================================================= - -type offConstraints struct { -} - -func newOffConstraints() (*offConstraints, error) { - return &offConstraints{}, nil -} - -func (offConstr *offConstraints) IsAllowed(level LogLevel) bool { - return false -} - -func (offConstr *offConstraints) String() string { - return "Off constraint" -} diff --git a/vendor/github.com/cihub/seelog/common_constraints_test.go b/vendor/github.com/cihub/seelog/common_constraints_test.go deleted file mode 100644 index 0f05b9df0..000000000 --- a/vendor/github.com/cihub/seelog/common_constraints_test.go +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "testing" -) - -func TestInvalidminMaxConstraints(t *testing.T) { - constr, err := newMinMaxConstraints(CriticalLvl, WarnLvl) - - if err == nil || constr != nil { - t.Errorf("expected an error and a nil value for minmax constraints: min = %d, max = %d. Got: %v, %v", - CriticalLvl, WarnLvl, err, constr) - return - } -} - -func TestInvalidLogLevels(t *testing.T) { - var invalidMin uint8 = 123 - var invalidMax uint8 = 124 - minMaxConstr, errMinMax := newMinMaxConstraints(LogLevel(invalidMin), LogLevel(invalidMax)) - - if errMinMax == nil || minMaxConstr != nil { - t.Errorf("expected an error and a nil value for minmax constraints: min = %d, max = %d. Got: %v, %v", - invalidMin, invalidMax, errMinMax, minMaxConstr) - return - } - - invalidList := []LogLevel{145} - - listConstr, errList := newListConstraints(invalidList) - - if errList == nil || listConstr != nil { - t.Errorf("expected an error and a nil value for constraints list: %v. Got: %v, %v", - invalidList, errList, listConstr) - return - } -} - -func TestlistConstraintsWithDuplicates(t *testing.T) { - duplicateList := []LogLevel{TraceLvl, DebugLvl, InfoLvl, - WarnLvl, ErrorLvl, CriticalLvl, CriticalLvl, CriticalLvl} - - listConstr, errList := newListConstraints(duplicateList) - - if errList != nil || listConstr == nil { - t.Errorf("expected a valid constraints list struct for: %v, got error: %v, value: %v", - duplicateList, errList, listConstr) - return - } - - listLevels := listConstr.AllowedLevels() - - if listLevels == nil { - t.Fatalf("listConstr.AllowedLevels() == nil") - return - } - - if len(listLevels) != 6 { - t.Errorf("expected: listConstr.AllowedLevels() length == 6. Got: %d", len(listLevels)) - return - } -} - -func TestlistConstraintsWithOffInList(t *testing.T) { - offList := []LogLevel{TraceLvl, DebugLvl, Off} - - listConstr, errList := newListConstraints(offList) - - if errList == nil || listConstr != nil { - t.Errorf("expected an error and a nil value for constraints list with 'Off': %v. Got: %v, %v", - offList, errList, listConstr) - return - } -} - -type logLevelTestCase struct { - level LogLevel - allowed bool -} - -var minMaxTests = []logLevelTestCase{ - {TraceLvl, false}, - {DebugLvl, false}, - {InfoLvl, true}, - {WarnLvl, true}, - {ErrorLvl, false}, - {CriticalLvl, false}, - {123, false}, - {6, false}, -} - -func TestValidminMaxConstraints(t *testing.T) { - - constr, err := newMinMaxConstraints(InfoLvl, WarnLvl) - - if err != nil || constr == nil { - t.Errorf("expected a valid constraints struct for minmax constraints: min = %d, max = %d. Got: %v, %v", - InfoLvl, WarnLvl, err, constr) - return - } - - for _, minMaxTest := range minMaxTests { - allowed := constr.IsAllowed(minMaxTest.level) - if allowed != minMaxTest.allowed { - t.Errorf("expected IsAllowed() = %t for level = %d. Got: %t", - minMaxTest.allowed, minMaxTest.level, allowed) - return - } - } -} - -var listTests = []logLevelTestCase{ - {TraceLvl, true}, - {DebugLvl, false}, - {InfoLvl, true}, - {WarnLvl, true}, - {ErrorLvl, false}, - {CriticalLvl, true}, - {123, false}, - {6, false}, -} - -func TestValidlistConstraints(t *testing.T) { - validList := []LogLevel{TraceLvl, InfoLvl, WarnLvl, CriticalLvl} - constr, err := newListConstraints(validList) - - if err != nil || constr == nil { - t.Errorf("expected a valid constraints list struct for: %v. Got error: %v, value: %v", - validList, err, constr) - return - } - - for _, minMaxTest := range listTests { - allowed := constr.IsAllowed(minMaxTest.level) - if allowed != minMaxTest.allowed { - t.Errorf("expected IsAllowed() = %t for level = %d. Got: %t", - minMaxTest.allowed, minMaxTest.level, allowed) - return - } - } -} - -var offTests = []logLevelTestCase{ - {TraceLvl, false}, - {DebugLvl, false}, - {InfoLvl, false}, - {WarnLvl, false}, - {ErrorLvl, false}, - {CriticalLvl, false}, - {123, false}, - {6, false}, -} - -func TestValidListoffConstraints(t *testing.T) { - validList := []LogLevel{Off} - constr, err := newListConstraints(validList) - - if err != nil || constr == nil { - t.Errorf("expected a valid constraints list struct for: %v. Got error: %v, value: %v", - validList, err, constr) - return - } - - for _, minMaxTest := range offTests { - allowed := constr.IsAllowed(minMaxTest.level) - if allowed != minMaxTest.allowed { - t.Errorf("expected IsAllowed() = %t for level = %d. Got: %t", - minMaxTest.allowed, minMaxTest.level, allowed) - return - } - } -} diff --git a/vendor/github.com/cihub/seelog/common_context.go b/vendor/github.com/cihub/seelog/common_context.go deleted file mode 100644 index 01d948369..000000000 --- a/vendor/github.com/cihub/seelog/common_context.go +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "os" - "path/filepath" - "runtime" - "strings" - "time" -) - -var workingDir = "/" - -func init() { - wd, err := os.Getwd() - if err == nil { - workingDir = filepath.ToSlash(wd) + "/" - } -} - -// Represents runtime caller context. -type LogContextInterface interface { - // Caller's function name. - Func() string - // Caller's line number. - Line() int - // Caller's file short path (in slashed form). - ShortPath() string - // Caller's file full path (in slashed form). - FullPath() string - // Caller's file name (without path). - FileName() string - // True if the context is correct and may be used. - // If false, then an error in context evaluation occurred and - // all its other data may be corrupted. - IsValid() bool - // Time when log function was called. - CallTime() time.Time -} - -// Returns context of the caller -func currentContext() (LogContextInterface, error) { - return specifyContext(1) -} - -func extractCallerInfo(skip int) (fullPath string, shortPath string, funcName string, line int, err error) { - pc, fp, ln, ok := runtime.Caller(skip) - if !ok { - err = fmt.Errorf("error during runtime.Caller") - return - } - line = ln - fullPath = fp - if strings.HasPrefix(fp, workingDir) { - shortPath = fp[len(workingDir):] - } else { - shortPath = fp - } - funcName = runtime.FuncForPC(pc).Name() - if strings.HasPrefix(funcName, workingDir) { - funcName = funcName[len(workingDir):] - } - return -} - -// Returns context of the function with placed "skip" stack frames of the caller -// If skip == 0 then behaves like currentContext -// Context is returned in any situation, even if error occurs. But, if an error -// occurs, the returned context is an error context, which contains no paths -// or names, but states that they can't be extracted. -func specifyContext(skip int) (LogContextInterface, error) { - callTime := time.Now() - if skip < 0 { - err := fmt.Errorf("can not skip negative stack frames") - return &errorContext{callTime, err}, err - } - fullPath, shortPath, funcName, line, err := extractCallerInfo(skip + 2) - if err != nil { - return &errorContext{callTime, err}, err - } - _, fileName := filepath.Split(fullPath) - return &logContext{funcName, line, shortPath, fullPath, fileName, callTime}, nil -} - -// Represents a normal runtime caller context. -type logContext struct { - funcName string - line int - shortPath string - fullPath string - fileName string - callTime time.Time -} - -func (context *logContext) IsValid() bool { - return true -} - -func (context *logContext) Func() string { - return context.funcName -} - -func (context *logContext) Line() int { - return context.line -} - -func (context *logContext) ShortPath() string { - return context.shortPath -} - -func (context *logContext) FullPath() string { - return context.fullPath -} - -func (context *logContext) FileName() string { - return context.fileName -} - -func (context *logContext) CallTime() time.Time { - return context.callTime -} - -// Represents an error context -type errorContext struct { - errorTime time.Time - err error -} - -func (errContext *errorContext) getErrorText(prefix string) string { - return fmt.Sprintf("%s() error: %s", prefix, errContext.err) -} - -func (errContext *errorContext) IsValid() bool { - return false -} - -func (errContext *errorContext) Line() int { - return -1 -} - -func (errContext *errorContext) Func() string { - return errContext.getErrorText("Func") -} - -func (errContext *errorContext) ShortPath() string { - return errContext.getErrorText("ShortPath") -} - -func (errContext *errorContext) FullPath() string { - return errContext.getErrorText("FullPath") -} - -func (errContext *errorContext) FileName() string { - return errContext.getErrorText("FileName") -} - -func (errContext *errorContext) CallTime() time.Time { - return errContext.errorTime -} diff --git a/vendor/github.com/cihub/seelog/common_context_test.go b/vendor/github.com/cihub/seelog/common_context_test.go deleted file mode 100644 index 02c79c4fc..000000000 --- a/vendor/github.com/cihub/seelog/common_context_test.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "os" - "path/filepath" - "strings" - "testing" -) - -const ( - testShortPath = "common_context_test.go" -) - -var ( - commonPrefix string - testFullPath string -) - -func init() { - // Here we remove the hardcoding of the package name which - // may break forks and some CI environments such as jenkins. - _, _, funcName, _, _ := extractCallerInfo(1) - commonPrefix = funcName[:strings.Index(funcName, "init·")] - wd, err := os.Getwd() - if err == nil { - // Transform the file path into a slashed form: - // This is the proper platform-neutral way. - testFullPath = filepath.ToSlash(filepath.Join(wd, testShortPath)) - } -} - -func TestContext(t *testing.T) { - context, err := currentContext() - if err != nil { - t.Fatalf("unexpected error: %s", err) - } - if context == nil { - t.Fatalf("unexpected error: context is nil") - } - if fn, funcName := context.Func(), commonPrefix+"TestContext"; fn != funcName { - // Account for a case when the func full path is longer than commonPrefix but includes it. - if !strings.HasSuffix(fn, funcName) { - t.Errorf("expected context.Func == %s ; got %s", funcName, context.Func()) - } - } - if context.ShortPath() != testShortPath { - t.Errorf("expected context.ShortPath == %s ; got %s", testShortPath, context.ShortPath()) - } - if len(testFullPath) == 0 { - t.Fatal("working directory seems invalid") - } - if context.FullPath() != testFullPath { - t.Errorf("expected context.FullPath == %s ; got %s", testFullPath, context.FullPath()) - } -} - -func innerContext() (context LogContextInterface, err error) { - return currentContext() -} - -func TestInnerContext(t *testing.T) { - context, err := innerContext() - if err != nil { - t.Fatalf("unexpected error: %s", err) - } - if context == nil { - t.Fatalf("unexpected error: context is nil") - } - if fn, funcName := context.Func(), commonPrefix+"innerContext"; fn != funcName { - // Account for a case when the func full path is longer than commonPrefix but includes it. - if !strings.HasSuffix(fn, funcName) { - t.Errorf("expected context.Func == %s ; got %s", funcName, context.Func()) - } - } - if context.ShortPath() != testShortPath { - t.Errorf("expected context.ShortPath == %s ; got %s", testShortPath, context.ShortPath()) - } - if len(testFullPath) == 0 { - t.Fatal("working directory seems invalid") - } - if context.FullPath() != testFullPath { - t.Errorf("expected context.FullPath == %s ; got %s", testFullPath, context.FullPath()) - } -} diff --git a/vendor/github.com/cihub/seelog/common_exception.go b/vendor/github.com/cihub/seelog/common_exception.go deleted file mode 100644 index 9b5ebe0fc..000000000 --- a/vendor/github.com/cihub/seelog/common_exception.go +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "regexp" - "strings" -) - -// Used in rules creation to validate input file and func filters -var ( - fileFormatValidator = regexp.MustCompile(`[a-zA-Z0-9\\/ _\*\.]*`) - funcFormatValidator = regexp.MustCompile(`[a-zA-Z0-9_\*\.]*`) -) - -// logLevelException represents an exceptional case used when you need some specific files or funcs to -// override general constraints and to use their own. -type logLevelException struct { - funcPatternParts []string - filePatternParts []string - - funcPattern string - filePattern string - - constraints logLevelConstraints -} - -// newLogLevelException creates a new exception. -func newLogLevelException(funcPattern string, filePattern string, constraints logLevelConstraints) (*logLevelException, error) { - if constraints == nil { - return nil, errors.New("constraints can not be nil") - } - - exception := new(logLevelException) - - err := exception.initFuncPatternParts(funcPattern) - if err != nil { - return nil, err - } - exception.funcPattern = strings.Join(exception.funcPatternParts, "") - - err = exception.initFilePatternParts(filePattern) - if err != nil { - return nil, err - } - exception.filePattern = strings.Join(exception.filePatternParts, "") - - exception.constraints = constraints - - return exception, nil -} - -// MatchesContext returns true if context matches the patterns of this logLevelException -func (logLevelEx *logLevelException) MatchesContext(context LogContextInterface) bool { - return logLevelEx.match(context.Func(), context.FullPath()) -} - -// IsAllowed returns true if log level is allowed according to the constraints of this logLevelException -func (logLevelEx *logLevelException) IsAllowed(level LogLevel) bool { - return logLevelEx.constraints.IsAllowed(level) -} - -// FuncPattern returns the function pattern of a exception -func (logLevelEx *logLevelException) FuncPattern() string { - return logLevelEx.funcPattern -} - -// FuncPattern returns the file pattern of a exception -func (logLevelEx *logLevelException) FilePattern() string { - return logLevelEx.filePattern -} - -// initFuncPatternParts checks whether the func filter has a correct format and splits funcPattern on parts -func (logLevelEx *logLevelException) initFuncPatternParts(funcPattern string) (err error) { - - if funcFormatValidator.FindString(funcPattern) != funcPattern { - return errors.New("func path \"" + funcPattern + "\" contains incorrect symbols. Only a-z A-Z 0-9 _ * . allowed)") - } - - logLevelEx.funcPatternParts = splitPattern(funcPattern) - return nil -} - -// Checks whether the file filter has a correct format and splits file patterns using splitPattern. -func (logLevelEx *logLevelException) initFilePatternParts(filePattern string) (err error) { - - if fileFormatValidator.FindString(filePattern) != filePattern { - return errors.New("file path \"" + filePattern + "\" contains incorrect symbols. Only a-z A-Z 0-9 \\ / _ * . allowed)") - } - - logLevelEx.filePatternParts = splitPattern(filePattern) - return err -} - -func (logLevelEx *logLevelException) match(funcPath string, filePath string) bool { - if !stringMatchesPattern(logLevelEx.funcPatternParts, funcPath) { - return false - } - return stringMatchesPattern(logLevelEx.filePatternParts, filePath) -} - -func (logLevelEx *logLevelException) String() string { - str := fmt.Sprintf("Func: %s File: %s ", logLevelEx.funcPattern, logLevelEx.filePattern) - - if logLevelEx.constraints != nil { - str += fmt.Sprintf("Constr: %s", logLevelEx.constraints) - } else { - str += "nil" - } - - return str -} - -// splitPattern splits pattern into strings and asterisks. Example: "ab*cde**f" -> ["ab", "*", "cde", "*", "f"] -func splitPattern(pattern string) []string { - var patternParts []string - var lastChar rune - for _, char := range pattern { - if char == '*' { - if lastChar != '*' { - patternParts = append(patternParts, "*") - } - } else { - if len(patternParts) != 0 && lastChar != '*' { - patternParts[len(patternParts)-1] += string(char) - } else { - patternParts = append(patternParts, string(char)) - } - } - lastChar = char - } - - return patternParts -} - -// stringMatchesPattern check whether testString matches pattern with asterisks. -// Standard regexp functionality is not used here because of performance issues. -func stringMatchesPattern(patternparts []string, testString string) bool { - if len(patternparts) == 0 { - return len(testString) == 0 - } - - part := patternparts[0] - if part != "*" { - index := strings.Index(testString, part) - if index == 0 { - return stringMatchesPattern(patternparts[1:], testString[len(part):]) - } - } else { - if len(patternparts) == 1 { - return true - } - - newTestString := testString - part = patternparts[1] - for { - index := strings.Index(newTestString, part) - if index == -1 { - break - } - - newTestString = newTestString[index+len(part):] - result := stringMatchesPattern(patternparts[2:], newTestString) - if result { - return true - } - } - } - return false -} diff --git a/vendor/github.com/cihub/seelog/common_exception_test.go b/vendor/github.com/cihub/seelog/common_exception_test.go deleted file mode 100644 index 4bff96113..000000000 --- a/vendor/github.com/cihub/seelog/common_exception_test.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "testing" -) - -type exceptionTestCase struct { - funcPattern string - filePattern string - funcName string - fileName string - match bool -} - -var exceptionTestCases = []exceptionTestCase{ - {"*", "*", "func", "file", true}, - {"func*", "*", "func", "file", true}, - {"*func", "*", "func", "file", true}, - {"*func", "*", "1func", "file", true}, - {"func*", "*", "func1", "file", true}, - {"fu*nc", "*", "func", "file", true}, - {"fu*nc", "*", "fu1nc", "file", true}, - {"fu*nc", "*", "func1nc", "file", true}, - {"*fu*nc*", "*", "somefuntonc", "file", true}, - {"fu*nc", "*", "f1nc", "file", false}, - {"func*", "*", "fun", "file", false}, - {"fu*nc", "*", "func1n", "file", false}, - {"**f**u**n**c**", "*", "func1n", "file", true}, -} - -func TestMatchingCorrectness(t *testing.T) { - constraints, err := newListConstraints([]LogLevel{TraceLvl}) - if err != nil { - t.Error(err) - return - } - - for _, testCase := range exceptionTestCases { - rule, ruleError := newLogLevelException(testCase.funcPattern, testCase.filePattern, constraints) - if ruleError != nil { - t.Fatalf("Unexpected error on rule creation: [ %v, %v ]. %v", - testCase.funcPattern, testCase.filePattern, ruleError) - } - - match := rule.match(testCase.funcName, testCase.fileName) - if match != testCase.match { - t.Errorf("incorrect matching for [ %v, %v ] [ %v, %v ] Expected: %t. Got: %t", - testCase.funcPattern, testCase.filePattern, testCase.funcName, testCase.fileName, testCase.match, match) - } - } -} - -func TestAsterisksReducing(t *testing.T) { - constraints, err := newListConstraints([]LogLevel{TraceLvl}) - if err != nil { - t.Error(err) - return - } - - rule, err := newLogLevelException("***func**", "fi*****le", constraints) - if err != nil { - t.Error(err) - return - } - expectFunc := "*func*" - if rule.FuncPattern() != expectFunc { - t.Errorf("asterisks must be reduced. Expect:%v, Got:%v", expectFunc, rule.FuncPattern()) - } - - expectFile := "fi*le" - if rule.FilePattern() != expectFile { - t.Errorf("asterisks must be reduced. Expect:%v, Got:%v", expectFile, rule.FilePattern()) - } -} diff --git a/vendor/github.com/cihub/seelog/common_flusher.go b/vendor/github.com/cihub/seelog/common_flusher.go deleted file mode 100644 index 0ef077c8d..000000000 --- a/vendor/github.com/cihub/seelog/common_flusher.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -// flusherInterface represents all objects that have to do cleanup -// at certain moments of time (e.g. before app shutdown to avoid data loss) -type flusherInterface interface { - Flush() -} diff --git a/vendor/github.com/cihub/seelog/common_loglevel.go b/vendor/github.com/cihub/seelog/common_loglevel.go deleted file mode 100644 index d54ecf270..000000000 --- a/vendor/github.com/cihub/seelog/common_loglevel.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -// Log level type -type LogLevel uint8 - -// Log levels -const ( - TraceLvl = iota - DebugLvl - InfoLvl - WarnLvl - ErrorLvl - CriticalLvl - Off -) - -// Log level string representations (used in configuration files) -const ( - TraceStr = "trace" - DebugStr = "debug" - InfoStr = "info" - WarnStr = "warn" - ErrorStr = "error" - CriticalStr = "critical" - OffStr = "off" -) - -var levelToStringRepresentations = map[LogLevel]string{ - TraceLvl: TraceStr, - DebugLvl: DebugStr, - InfoLvl: InfoStr, - WarnLvl: WarnStr, - ErrorLvl: ErrorStr, - CriticalLvl: CriticalStr, - Off: OffStr, -} - -// LogLevelFromString parses a string and returns a corresponding log level, if sucessfull. -func LogLevelFromString(levelStr string) (level LogLevel, found bool) { - for lvl, lvlStr := range levelToStringRepresentations { - if lvlStr == levelStr { - return lvl, true - } - } - - return 0, false -} - -// LogLevelToString returns seelog string representation for a specified level. Returns "" for invalid log levels. -func (level LogLevel) String() string { - levelStr, ok := levelToStringRepresentations[level] - if ok { - return levelStr - } - - return "" -} diff --git a/vendor/github.com/cihub/seelog/dispatch_custom.go b/vendor/github.com/cihub/seelog/dispatch_custom.go deleted file mode 100644 index 7c13b6701..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_custom.go +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (c) 2013 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "reflect" - "sort" -) - -var registeredReceivers = make(map[string]reflect.Type) - -// RegisterReceiver records a custom receiver type, identified by a value -// of that type (second argument), under the specified name. Registered -// names can be used in the "name" attribute of config items. -// -// RegisterReceiver takes the type of the receiver argument, without taking -// the value into the account. So do NOT enter any data to the second argument -// and only call it like: -// RegisterReceiver("somename", &MyReceiverType{}) -// -// After that, when a '' config tag with this name is used, -// a receiver of the specified type would be instantiated. Check -// CustomReceiver comments for interface details. -// -// NOTE 1: RegisterReceiver fails if you attempt to register different types -// with the same name. -// -// NOTE 2: RegisterReceiver registers those receivers that must be used in -// the configuration files ( items). Basically it is just the way -// you tell seelog config parser what should it do when it meets a -// tag with a specific name and data attributes. -// -// But If you are only using seelog as a proxy to an already instantiated -// CustomReceiver (via LoggerFromCustomReceiver func), you should not call RegisterReceiver. -func RegisterReceiver(name string, receiver CustomReceiver) { - newType := reflect.TypeOf(reflect.ValueOf(receiver).Elem().Interface()) - if t, ok := registeredReceivers[name]; ok && t != newType { - panic(fmt.Sprintf("duplicate types for %s: %s != %s", name, t, newType)) - } - registeredReceivers[name] = newType -} - -func customReceiverByName(name string) (creceiver CustomReceiver, err error) { - rt, ok := registeredReceivers[name] - if !ok { - return nil, fmt.Errorf("custom receiver name not registered: '%s'", name) - } - v, ok := reflect.New(rt).Interface().(CustomReceiver) - if !ok { - return nil, fmt.Errorf("cannot instantiate receiver with name='%s'", name) - } - return v, nil -} - -// CustomReceiverInitArgs represent arguments passed to the CustomReceiver.Init -// func when custom receiver is being initialized. -type CustomReceiverInitArgs struct { - // XmlCustomAttrs represent '' xml config item attributes that - // start with "data-". Map keys will be the attribute names without the "data-". - // Map values will the those attribute values. - // - // E.g. if you have a '' - // you will get map with 2 key-value pairs: "attr1"->"a1", "attr2"->"a2" - // - // Note that in custom items you can only use allowed attributes, like "name" and - // your custom attributes, starting with "data-". Any other will lead to a - // parsing error. - XmlCustomAttrs map[string]string -} - -// CustomReceiver is the interface that external custom seelog message receivers -// must implement in order to be able to process seelog messages. Those receivers -// are set in the xml config file using the tag. Check receivers reference -// wiki section on that. -// -// Use seelog.RegisterReceiver on the receiver type before using it. -type CustomReceiver interface { - // ReceiveMessage is called when the custom receiver gets seelog message from - // a parent dispatcher. - // - // Message, level and context args represent all data that was included in the seelog - // message at the time it was logged. - // - // The formatting is already applied to the message and depends on the config - // like with any other receiver. - // - // If you would like to inform seelog of an error that happened during the handling of - // the message, return a non-nil error. This way you'll end up seeing your error like - // any other internal seelog error. - ReceiveMessage(message string, level LogLevel, context LogContextInterface) error - - // AfterParse is called immediately after your custom receiver is instantiated by - // the xml config parser. So, if you need to do any startup logic after config parsing, - // like opening file or allocating any resources after the receiver is instantiated, do it here. - // - // If this func returns a non-nil error, then the loading procedure will fail. E.g. - // if you are loading a seelog xml config, the parser would not finish the loading - // procedure and inform about an error like with any other config error. - // - // If your custom logger needs some configuration, you can use custom attributes in - // your config. Check CustomReceiverInitArgs.XmlCustomAttrs comments. - // - // IMPORTANT: This func is NOT called when the LoggerFromCustomReceiver func is used - // to create seelog proxy logger using the custom receiver. This func is only called when - // receiver is instantiated from a config. - AfterParse(initArgs CustomReceiverInitArgs) error - - // Flush is called when the custom receiver gets a 'flush' directive from a - // parent receiver. If custom receiver implements some kind of buffering or - // queing, then the appropriate reaction on a flush message is synchronous - // flushing of all those queues/buffers. If custom receiver doesn't have - // such mechanisms, then flush implementation may be left empty. - Flush() - - // Close is called when the custom receiver gets a 'close' directive from a - // parent receiver. This happens when a top-level seelog dispatcher is sending - // 'close' to all child nodes and it means that current seelog logger is being closed. - // If you need to do any cleanup after your custom receiver is done, you should do - // it here. - Close() error -} - -type customReceiverDispatcher struct { - formatter *formatter - innerReceiver CustomReceiver - customReceiverName string - usedArgs CustomReceiverInitArgs -} - -// newCustomReceiverDispatcher creates a customReceiverDispatcher which dispatches data to a specific receiver created -// using a tag in the config file. -func newCustomReceiverDispatcher(formatter *formatter, customReceiverName string, cArgs CustomReceiverInitArgs) (*customReceiverDispatcher, error) { - if formatter == nil { - return nil, errors.New("formatter cannot be nil") - } - if len(customReceiverName) == 0 { - return nil, errors.New("custom receiver name cannot be empty") - } - - creceiver, err := customReceiverByName(customReceiverName) - if err != nil { - return nil, err - } - err = creceiver.AfterParse(cArgs) - if err != nil { - return nil, err - } - disp := &customReceiverDispatcher{formatter, creceiver, customReceiverName, cArgs} - - return disp, nil -} - -// newCustomReceiverDispatcherByValue is basically the same as newCustomReceiverDispatcher, but using -// a specific CustomReceiver value instead of instantiating a new one by type. -func newCustomReceiverDispatcherByValue(formatter *formatter, customReceiver CustomReceiver, name string, cArgs CustomReceiverInitArgs) (*customReceiverDispatcher, error) { - if formatter == nil { - return nil, errors.New("formatter cannot be nil") - } - if customReceiver == nil { - return nil, errors.New("customReceiver cannot be nil") - } - disp := &customReceiverDispatcher{formatter, customReceiver, name, cArgs} - - return disp, nil -} - -// CustomReceiver implementation. Check CustomReceiver comments. -func (disp *customReceiverDispatcher) Dispatch( - message string, - level LogLevel, - context LogContextInterface, - errorFunc func(err error)) { - - defer func() { - if err := recover(); err != nil { - errorFunc(fmt.Errorf("panic in custom receiver '%s'.Dispatch: %s", reflect.TypeOf(disp.innerReceiver), err)) - } - }() - - err := disp.innerReceiver.ReceiveMessage(disp.formatter.Format(message, level, context), level, context) - if err != nil { - errorFunc(err) - } -} - -// CustomReceiver implementation. Check CustomReceiver comments. -func (disp *customReceiverDispatcher) Flush() { - disp.innerReceiver.Flush() -} - -// CustomReceiver implementation. Check CustomReceiver comments. -func (disp *customReceiverDispatcher) Close() error { - disp.innerReceiver.Flush() - - err := disp.innerReceiver.Close() - if err != nil { - return err - } - - return nil -} - -func (disp *customReceiverDispatcher) String() string { - datas := "" - skeys := make([]string, 0, len(disp.usedArgs.XmlCustomAttrs)) - for i := range disp.usedArgs.XmlCustomAttrs { - skeys = append(skeys, i) - } - sort.Strings(skeys) - for _, key := range skeys { - datas += fmt.Sprintf("<%s, %s> ", key, disp.usedArgs.XmlCustomAttrs[key]) - } - - str := fmt.Sprintf("Custom receiver %s [fmt='%s'],[data='%s'],[inner='%s']\n", - disp.customReceiverName, disp.formatter.String(), datas, disp.innerReceiver) - - return str -} diff --git a/vendor/github.com/cihub/seelog/dispatch_customdispatcher_test.go b/vendor/github.com/cihub/seelog/dispatch_customdispatcher_test.go deleted file mode 100644 index 6510b2b6e..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_customdispatcher_test.go +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2013 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "testing" -) - -type testCustomDispatcherMessageReceiver struct { - customTestReceiver -} - -func TestCustomDispatcher_Message(t *testing.T) { - recName := "TestCustomDispatcher_Message" - RegisterReceiver(recName, &testCustomDispatcherMessageReceiver{}) - - customDispatcher, err := newCustomReceiverDispatcher(onlyMessageFormatForTest, recName, CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": "testdata", - }, - }) - if err != nil { - t.Error(err) - return - } - - context, err := currentContext() - if err != nil { - t.Error(err) - return - } - - bytes := []byte("Hello") - customDispatcher.Dispatch(string(bytes), TraceLvl, context, func(err error) {}) - - cout := customDispatcher.innerReceiver.(*testCustomDispatcherMessageReceiver).customTestReceiver.co - if cout.initCalled != true { - t.Error("Init not called") - return - } - if cout.dataPassed != "testdata" { - t.Errorf("wrong data passed: '%s'", cout.dataPassed) - return - } - if cout.messageOutput != string(bytes) { - t.Errorf("wrong message output: '%s'", cout.messageOutput) - return - } - if cout.levelOutput != TraceLvl { - t.Errorf("wrong log level: '%s'", cout.levelOutput) - return - } - if cout.flushed { - t.Error("Flush was not expected") - return - } - if cout.closed { - t.Error("Closing was not expected") - return - } -} - -type testCustomDispatcherFlushReceiver struct { - customTestReceiver -} - -func TestCustomDispatcher_Flush(t *testing.T) { - recName := "TestCustomDispatcher_Flush" - RegisterReceiver(recName, &testCustomDispatcherFlushReceiver{}) - - customDispatcher, err := newCustomReceiverDispatcher(onlyMessageFormatForTest, recName, CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": "testdata", - }, - }) - if err != nil { - t.Error(err) - return - } - - customDispatcher.Flush() - - cout := customDispatcher.innerReceiver.(*testCustomDispatcherFlushReceiver).customTestReceiver.co - if cout.initCalled != true { - t.Error("Init not called") - return - } - if cout.dataPassed != "testdata" { - t.Errorf("wrong data passed: '%s'", cout.dataPassed) - return - } - if cout.messageOutput != "" { - t.Errorf("wrong message output: '%s'", cout.messageOutput) - return - } - if cout.levelOutput != TraceLvl { - t.Errorf("wrong log level: '%s'", cout.levelOutput) - return - } - if !cout.flushed { - t.Error("Flush was expected") - return - } - if cout.closed { - t.Error("Closing was not expected") - return - } -} - -type testCustomDispatcherCloseReceiver struct { - customTestReceiver -} - -func TestCustomDispatcher_Close(t *testing.T) { - recName := "TestCustomDispatcher_Close" - RegisterReceiver(recName, &testCustomDispatcherCloseReceiver{}) - - customDispatcher, err := newCustomReceiverDispatcher(onlyMessageFormatForTest, recName, CustomReceiverInitArgs{ - XmlCustomAttrs: map[string]string{ - "test": "testdata", - }, - }) - if err != nil { - t.Error(err) - return - } - - customDispatcher.Close() - - cout := customDispatcher.innerReceiver.(*testCustomDispatcherCloseReceiver).customTestReceiver.co - if cout.initCalled != true { - t.Error("Init not called") - return - } - if cout.dataPassed != "testdata" { - t.Errorf("wrong data passed: '%s'", cout.dataPassed) - return - } - if cout.messageOutput != "" { - t.Errorf("wrong message output: '%s'", cout.messageOutput) - return - } - if cout.levelOutput != TraceLvl { - t.Errorf("wrong log level: '%s'", cout.levelOutput) - return - } - if !cout.flushed { - t.Error("Flush was expected") - return - } - if !cout.closed { - t.Error("Closing was expected") - return - } -} diff --git a/vendor/github.com/cihub/seelog/dispatch_dispatcher.go b/vendor/github.com/cihub/seelog/dispatch_dispatcher.go deleted file mode 100644 index e3c695586..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_dispatcher.go +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "io" -) - -// A dispatcherInterface is used to dispatch message to all underlying receivers. -// Dispatch logic depends on given context and log level. Any errors are reported using errorFunc. -// Also, as underlying receivers may have a state, dispatcher has a ShuttingDown method which performs -// an immediate cleanup of all data that is stored in the receivers -type dispatcherInterface interface { - flusherInterface - io.Closer - Dispatch(message string, level LogLevel, context LogContextInterface, errorFunc func(err error)) -} - -type dispatcher struct { - formatter *formatter - writers []*formattedWriter - dispatchers []dispatcherInterface -} - -// Creates a dispatcher which dispatches data to a list of receivers. -// Each receiver should be either a Dispatcher or io.Writer, otherwise an error will be returned -func createDispatcher(formatter *formatter, receivers []interface{}) (*dispatcher, error) { - if formatter == nil { - return nil, errors.New("formatter cannot be nil") - } - if receivers == nil || len(receivers) == 0 { - return nil, errors.New("receivers cannot be nil or empty") - } - - disp := &dispatcher{formatter, make([]*formattedWriter, 0), make([]dispatcherInterface, 0)} - for _, receiver := range receivers { - writer, ok := receiver.(*formattedWriter) - if ok { - disp.writers = append(disp.writers, writer) - continue - } - - ioWriter, ok := receiver.(io.Writer) - if ok { - writer, err := newFormattedWriter(ioWriter, disp.formatter) - if err != nil { - return nil, err - } - disp.writers = append(disp.writers, writer) - continue - } - - dispInterface, ok := receiver.(dispatcherInterface) - if ok { - disp.dispatchers = append(disp.dispatchers, dispInterface) - continue - } - - return nil, errors.New("method can receive either io.Writer or dispatcherInterface") - } - - return disp, nil -} - -func (disp *dispatcher) Dispatch( - message string, - level LogLevel, - context LogContextInterface, - errorFunc func(err error)) { - - for _, writer := range disp.writers { - err := writer.Write(message, level, context) - if err != nil { - errorFunc(err) - } - } - - for _, dispInterface := range disp.dispatchers { - dispInterface.Dispatch(message, level, context, errorFunc) - } -} - -// Flush goes through all underlying writers which implement flusherInterface interface -// and closes them. Recursively performs the same action for underlying dispatchers -func (disp *dispatcher) Flush() { - for _, disp := range disp.Dispatchers() { - disp.Flush() - } - - for _, formatWriter := range disp.Writers() { - flusher, ok := formatWriter.Writer().(flusherInterface) - if ok { - flusher.Flush() - } - } -} - -// Close goes through all underlying writers which implement io.Closer interface -// and closes them. Recursively performs the same action for underlying dispatchers -// Before closing, writers are flushed to prevent loss of any buffered data, so -// a call to Flush() func before Close() is not necessary -func (disp *dispatcher) Close() error { - for _, disp := range disp.Dispatchers() { - disp.Flush() - err := disp.Close() - if err != nil { - return err - } - } - - for _, formatWriter := range disp.Writers() { - flusher, ok := formatWriter.Writer().(flusherInterface) - if ok { - flusher.Flush() - } - - closer, ok := formatWriter.Writer().(io.Closer) - if ok { - err := closer.Close() - if err != nil { - return err - } - } - } - - return nil -} - -func (disp *dispatcher) Writers() []*formattedWriter { - return disp.writers -} - -func (disp *dispatcher) Dispatchers() []dispatcherInterface { - return disp.dispatchers -} - -func (disp *dispatcher) String() string { - str := "formatter: " + disp.formatter.String() + "\n" - - str += " ->Dispatchers:" - - if len(disp.dispatchers) == 0 { - str += "none\n" - } else { - str += "\n" - - for _, disp := range disp.dispatchers { - str += fmt.Sprintf(" ->%s", disp) - } - } - - str += " ->Writers:" - - if len(disp.writers) == 0 { - str += "none\n" - } else { - str += "\n" - - for _, writer := range disp.writers { - str += fmt.Sprintf(" ->%s\n", writer) - } - } - - return str -} diff --git a/vendor/github.com/cihub/seelog/dispatch_filterdispatcher.go b/vendor/github.com/cihub/seelog/dispatch_filterdispatcher.go deleted file mode 100644 index 60da31fe5..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_filterdispatcher.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" -) - -// A filterDispatcher writes the given message to underlying receivers only if message log level -// is in the allowed list. -type filterDispatcher struct { - *dispatcher - allowList map[LogLevel]bool -} - -// newFilterDispatcher creates a new filterDispatcher using a list of allowed levels. -func newFilterDispatcher(formatter *formatter, receivers []interface{}, allowList ...LogLevel) (*filterDispatcher, error) { - disp, err := createDispatcher(formatter, receivers) - if err != nil { - return nil, err - } - - allows := make(map[LogLevel]bool) - for _, allowLevel := range allowList { - allows[allowLevel] = true - } - - return &filterDispatcher{disp, allows}, nil -} - -func (filter *filterDispatcher) Dispatch( - message string, - level LogLevel, - context LogContextInterface, - errorFunc func(err error)) { - isAllowed, ok := filter.allowList[level] - if ok && isAllowed { - filter.dispatcher.Dispatch(message, level, context, errorFunc) - } -} - -func (filter *filterDispatcher) String() string { - return fmt.Sprintf("filterDispatcher ->\n%s", filter.dispatcher) -} diff --git a/vendor/github.com/cihub/seelog/dispatch_filterdispatcher_test.go b/vendor/github.com/cihub/seelog/dispatch_filterdispatcher_test.go deleted file mode 100644 index 70138b988..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_filterdispatcher_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "testing" -) - -func TestfilterDispatcher_Pass(t *testing.T) { - writer, _ := newBytesVerifier(t) - filter, err := newFilterDispatcher(onlyMessageFormatForTest, []interface{}{writer}, TraceLvl) - if err != nil { - t.Error(err) - return - } - - context, err := currentContext() - if err != nil { - t.Error(err) - return - } - - bytes := []byte("Hello") - writer.ExpectBytes(bytes) - filter.Dispatch(string(bytes), TraceLvl, context, func(err error) {}) - writer.MustNotExpect() -} - -func TestfilterDispatcher_Deny(t *testing.T) { - writer, _ := newBytesVerifier(t) - filter, err := newFilterDispatcher(defaultformatter, []interface{}{writer}) - if err != nil { - t.Error(err) - return - } - - context, err := currentContext() - if err != nil { - t.Error(err) - return - } - - bytes := []byte("Hello") - filter.Dispatch(string(bytes), TraceLvl, context, func(err error) {}) -} diff --git a/vendor/github.com/cihub/seelog/dispatch_splitdispatcher.go b/vendor/github.com/cihub/seelog/dispatch_splitdispatcher.go deleted file mode 100644 index 218729ca4..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_splitdispatcher.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" -) - -// A splitDispatcher just writes the given message to underlying receivers. (Splits the message stream.) -type splitDispatcher struct { - *dispatcher -} - -func newSplitDispatcher(formatter *formatter, receivers []interface{}) (*splitDispatcher, error) { - disp, err := createDispatcher(formatter, receivers) - if err != nil { - return nil, err - } - - return &splitDispatcher{disp}, nil -} - -func (splitter *splitDispatcher) String() string { - return fmt.Sprintf("splitDispatcher ->\n%s", splitter.dispatcher.String()) -} diff --git a/vendor/github.com/cihub/seelog/dispatch_splitdispatcher_test.go b/vendor/github.com/cihub/seelog/dispatch_splitdispatcher_test.go deleted file mode 100644 index 08499a80c..000000000 --- a/vendor/github.com/cihub/seelog/dispatch_splitdispatcher_test.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "testing" -) - -var onlyMessageFormatForTest *formatter - -func init() { - var err error - onlyMessageFormatForTest, err = newFormatter("%Msg") - if err != nil { - fmt.Println("Can not create only message format: " + err.Error()) - } -} - -func TestsplitDispatcher(t *testing.T) { - writer1, _ := newBytesVerifier(t) - writer2, _ := newBytesVerifier(t) - spliter, err := newSplitDispatcher(onlyMessageFormatForTest, []interface{}{writer1, writer2}) - if err != nil { - t.Error(err) - return - } - - context, err := currentContext() - if err != nil { - t.Error(err) - return - } - - bytes := []byte("Hello") - - writer1.ExpectBytes(bytes) - writer2.ExpectBytes(bytes) - spliter.Dispatch(string(bytes), TraceLvl, context, func(err error) {}) - writer1.MustNotExpect() - writer2.MustNotExpect() -} diff --git a/vendor/github.com/cihub/seelog/doc.go b/vendor/github.com/cihub/seelog/doc.go deleted file mode 100644 index 95c15ae99..000000000 --- a/vendor/github.com/cihub/seelog/doc.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2014 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Package seelog implements logging functionality with flexible dispatching, filtering, and formatting. - -Creation - -To create a logger, use one of the following constructors: - func LoggerFromConfigAsBytes - func LoggerFromConfigAsFile - func LoggerFromConfigAsString - func LoggerFromWriterWithMinLevel - func LoggerFromWriterWithMinLevelAndFormat - func LoggerFromCustomReceiver (check https://github.com/cihub/seelog/wiki/Custom-receivers) -Example: - import log "github.com/cihub/seelog" - - func main() { - logger, err := log.LoggerFromConfigAsFile("seelog.xml") - if err != nil { - panic(err) - } - defer logger.Flush() - ... use logger ... - } -The "defer" line is important because if you are using asynchronous logger behavior, without this line you may end up losing some -messages when you close your application because they are processed in another non-blocking goroutine. To avoid that you -explicitly defer flushing all messages before closing. - -Usage - -Logger created using one of the LoggerFrom* funcs can be used directly by calling one of the main log funcs. -Example: - import log "github.com/cihub/seelog" - - func main() { - logger, err := log.LoggerFromConfigAsFile("seelog.xml") - if err != nil { - panic(err) - } - defer logger.Flush() - logger.Trace("test") - logger.Debugf("var = %s", "abc") - } - -Having loggers as variables is convenient if you are writing your own package with internal logging or if you have -several loggers with different options. -But for most standalone apps it is more convenient to use package level funcs and vars. There is a package level -var 'Current' made for it. You can replace it with another logger using 'ReplaceLogger' and then use package level funcs: - import log "github.com/cihub/seelog" - - func main() { - logger, err := log.LoggerFromConfigAsFile("seelog.xml") - if err != nil { - panic(err) - } - log.ReplaceLogger(logger) - defer log.Flush() - log.Trace("test") - log.Debugf("var = %s", "abc") - } -Last lines - log.Trace("test") - log.Debugf("var = %s", "abc") -do the same as - log.Current.Trace("test") - log.Current.Debugf("var = %s", "abc") -In this example the 'Current' logger was replaced using a 'ReplaceLogger' call and became equal to 'logger' variable created from config. -This way you are able to use package level funcs instead of passing the logger variable. - -Configuration - -Main seelog point is to configure logger via config files and not the code. So you can only specify -formats and log rules by changing the configuration. -The configuration is read by LoggerFrom* funcs. These funcs read xml configuration from different sources and try -to create a logger using it. - -All the configuration features are covered in detail in the official wiki: https://github.com/cihub/seelog/wiki. -There are many sections covering different aspects of seelog, but the most important for understanding configs are: - https://github.com/cihub/seelog/wiki/Constraints-and-exceptions - https://github.com/cihub/seelog/wiki/Dispatchers-and-receivers - https://github.com/cihub/seelog/wiki/Formatting - https://github.com/cihub/seelog/wiki/Logger-types -After you understand these concepts, check the 'Reference' section on the main wiki page to get the up-to-date -list of dispatchers, receivers, formats, and logger types. - -Here is an example config with all these features: - - - - - - - - - - - - - - - - - - - - - -This config represents a logger with adaptive timeout between log messages (check logger types reference) which -logs to console, all.log, and errors.log depending on the log level. Its output formats also depend on log level. This logger will only -use log level 'debug' and higher (minlevel is set) for all files with names that don't start with 'test'. For files starting with 'test' -this logger prohibits all levels below 'error'. - -Examples - -To learn seelog features faster you should check the examples package: https://github.com/cihub/seelog-examples -It contains many example configs and usecases. -*/ -package seelog diff --git a/vendor/github.com/cihub/seelog/format.go b/vendor/github.com/cihub/seelog/format.go deleted file mode 100644 index b71994efd..000000000 --- a/vendor/github.com/cihub/seelog/format.go +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "bytes" - "errors" - "fmt" - "strconv" - "strings" - "unicode" - "unicode/utf8" -) - -// FormatterSymbol is a special symbol used in config files to mark special format aliases. -const ( - FormatterSymbol = '%' -) - -const ( - formatterParameterStart = '(' - formatterParameterEnd = ')' -) - -// Time and date formats used for %Date and %Time aliases. -const ( - DateDefaultFormat = "2006-01-02" - TimeFormat = "15:04:05" -) - -var DefaultMsgFormat = "%Ns [%Level] %Msg%n" - -var ( - defaultformatter *formatter - msgonlyformatter *formatter -) - -func init() { - var err error - if defaultformatter, err = newFormatter(DefaultMsgFormat); err != nil { - reportInternalError(fmt.Errorf("error during creating defaultformatter: %s", err)) - } - if msgonlyformatter, err = newFormatter("%Msg"); err != nil { - reportInternalError(fmt.Errorf("error during creating msgonlyformatter: %s", err)) - } -} - -// FormatterFunc represents one formatter object that starts with '%' sign in the 'format' attribute -// of the 'format' config item. These special symbols are replaced with context values or special -// strings when message is written to byte receiver. -// -// Check https://github.com/cihub/seelog/wiki/Formatting for details. -// Full list (with descriptions) of formatters: https://github.com/cihub/seelog/wiki/Format-reference -// -// FormatterFunc takes raw log message, level, log context and returns a string, number (of any type) or any object -// that can be evaluated as string. -type FormatterFunc func(message string, level LogLevel, context LogContextInterface) interface{} - -// FormatterFuncCreator is a factory of FormatterFunc objects. It is used to generate parameterized -// formatters (such as %Date or %EscM) and custom user formatters. -type FormatterFuncCreator func(param string) FormatterFunc - -var formatterFuncs = map[string]FormatterFunc{ - "Level": formatterLevel, - "Lev": formatterLev, - "LEVEL": formatterLEVEL, - "LEV": formatterLEV, - "l": formatterl, - "Msg": formatterMsg, - "FullPath": formatterFullPath, - "File": formatterFile, - "RelFile": formatterRelFile, - "Func": FormatterFunction, - "FuncShort": FormatterFunctionShort, - "Line": formatterLine, - "Time": formatterTime, - "UTCTime": formatterUTCTime, - "Ns": formatterNs, - "UTCNs": formatterUTCNs, - "n": formattern, - "t": formattert, -} - -var formatterFuncsParameterized = map[string]FormatterFuncCreator{ - "Date": createDateTimeFormatterFunc, - "UTCDate": createUTCDateTimeFormatterFunc, - "EscM": createANSIEscapeFunc, -} - -func errorAliasReserved(name string) error { - return fmt.Errorf("cannot use '%s' as custom formatter name. Name is reserved", name) -} - -// RegisterCustomFormatter registers a new custom formatter factory with a given name. If returned error is nil, -// then this name (prepended by '%' symbol) can be used in 'format' attributes in configuration and -// it will be treated like the standard parameterized formatter identifiers. -// -// RegisterCustomFormatter needs to be called before creating a logger for it to take effect. The general recommendation -// is to call it once in 'init' func of your application or any initializer func. -// -// For usage examples, check https://github.com/cihub/seelog/wiki/Custom-formatters. -// -// Name must only consist of letters (unicode.IsLetter). -// -// Name must not be one of the already registered standard formatter names -// (https://github.com/cihub/seelog/wiki/Format-reference) and previously registered -// custom format names. To avoid any potential name conflicts (in future releases), it is recommended -// to start your custom formatter name with a namespace (e.g. 'MyCompanySomething') or a 'Custom' keyword. -func RegisterCustomFormatter(name string, creator FormatterFuncCreator) error { - if _, ok := formatterFuncs[name]; ok { - return errorAliasReserved(name) - } - if _, ok := formatterFuncsParameterized[name]; ok { - return errorAliasReserved(name) - } - formatterFuncsParameterized[name] = creator - return nil -} - -// formatter is used to write messages in a specific format, inserting such additional data -// as log level, date/time, etc. -type formatter struct { - fmtStringOriginal string - fmtString string - formatterFuncs []FormatterFunc -} - -// newFormatter creates a new formatter using a format string -func newFormatter(formatString string) (*formatter, error) { - fmtr := new(formatter) - fmtr.fmtStringOriginal = formatString - if err := buildFormatterFuncs(fmtr); err != nil { - return nil, err - } - return fmtr, nil -} - -func buildFormatterFuncs(formatter *formatter) error { - var ( - fsbuf = new(bytes.Buffer) - fsolm1 = len(formatter.fmtStringOriginal) - 1 - ) - for i := 0; i <= fsolm1; i++ { - if char := formatter.fmtStringOriginal[i]; char != FormatterSymbol { - fsbuf.WriteByte(char) - continue - } - // Check if the index is at the end of the string. - if i == fsolm1 { - return fmt.Errorf("format error: %c cannot be last symbol", FormatterSymbol) - } - // Check if the formatter symbol is doubled and skip it as nonmatching. - if formatter.fmtStringOriginal[i+1] == FormatterSymbol { - fsbuf.WriteRune(FormatterSymbol) - i++ - continue - } - function, ni, err := formatter.extractFormatterFunc(i + 1) - if err != nil { - return err - } - // Append formatting string "%v". - fsbuf.Write([]byte{37, 118}) - i = ni - formatter.formatterFuncs = append(formatter.formatterFuncs, function) - } - formatter.fmtString = fsbuf.String() - return nil -} - -func (formatter *formatter) extractFormatterFunc(index int) (FormatterFunc, int, error) { - letterSequence := formatter.extractLetterSequence(index) - if len(letterSequence) == 0 { - return nil, 0, fmt.Errorf("format error: lack of formatter after %c at %d", FormatterSymbol, index) - } - - function, formatterLength, ok := formatter.findFormatterFunc(letterSequence) - if ok { - return function, index + formatterLength - 1, nil - } - - function, formatterLength, ok, err := formatter.findFormatterFuncParametrized(letterSequence, index) - if err != nil { - return nil, 0, err - } - if ok { - return function, index + formatterLength - 1, nil - } - - return nil, 0, errors.New("format error: unrecognized formatter at " + strconv.Itoa(index) + ": " + letterSequence) -} - -func (formatter *formatter) extractLetterSequence(index int) string { - letters := "" - - bytesToParse := []byte(formatter.fmtStringOriginal[index:]) - runeCount := utf8.RuneCount(bytesToParse) - for i := 0; i < runeCount; i++ { - rune, runeSize := utf8.DecodeRune(bytesToParse) - bytesToParse = bytesToParse[runeSize:] - - if unicode.IsLetter(rune) { - letters += string(rune) - } else { - break - } - } - return letters -} - -func (formatter *formatter) findFormatterFunc(letters string) (FormatterFunc, int, bool) { - currentVerb := letters - for i := 0; i < len(letters); i++ { - function, ok := formatterFuncs[currentVerb] - if ok { - return function, len(currentVerb), ok - } - currentVerb = currentVerb[:len(currentVerb)-1] - } - - return nil, 0, false -} - -func (formatter *formatter) findFormatterFuncParametrized(letters string, lettersStartIndex int) (FormatterFunc, int, bool, error) { - currentVerb := letters - for i := 0; i < len(letters); i++ { - functionCreator, ok := formatterFuncsParameterized[currentVerb] - if ok { - parameter := "" - parameterLen := 0 - isVerbEqualsLetters := i == 0 // if not, then letter goes after formatter, and formatter is parameterless - if isVerbEqualsLetters { - userParameter := "" - var err error - userParameter, parameterLen, ok, err = formatter.findparameter(lettersStartIndex + len(currentVerb)) - if ok { - parameter = userParameter - } else if err != nil { - return nil, 0, false, err - } - } - - return functionCreator(parameter), len(currentVerb) + parameterLen, true, nil - } - - currentVerb = currentVerb[:len(currentVerb)-1] - } - - return nil, 0, false, nil -} - -func (formatter *formatter) findparameter(startIndex int) (string, int, bool, error) { - if len(formatter.fmtStringOriginal) == startIndex || formatter.fmtStringOriginal[startIndex] != formatterParameterStart { - return "", 0, false, nil - } - - endIndex := strings.Index(formatter.fmtStringOriginal[startIndex:], string(formatterParameterEnd)) - if endIndex == -1 { - return "", 0, false, fmt.Errorf("Unmatched parenthesis or invalid parameter at %d: %s", - startIndex, formatter.fmtStringOriginal[startIndex:]) - } - endIndex += startIndex - - length := endIndex - startIndex + 1 - - return formatter.fmtStringOriginal[startIndex+1 : endIndex], length, true, nil -} - -// Format processes a message with special formatters, log level, and context. Returns formatted string -// with all formatter identifiers changed to appropriate values. -func (formatter *formatter) Format(message string, level LogLevel, context LogContextInterface) string { - if len(formatter.formatterFuncs) == 0 { - return formatter.fmtString - } - - params := make([]interface{}, len(formatter.formatterFuncs)) - for i, function := range formatter.formatterFuncs { - params[i] = function(message, level, context) - } - - return fmt.Sprintf(formatter.fmtString, params...) -} - -func (formatter *formatter) String() string { - return formatter.fmtStringOriginal -} - -//===================================================== - -const ( - wrongLogLevel = "WRONG_LOGLEVEL" - wrongEscapeCode = "WRONG_ESCAPE" -) - -var levelToString = map[LogLevel]string{ - TraceLvl: "Trace", - DebugLvl: "Debug", - InfoLvl: "Info", - WarnLvl: "Warn", - ErrorLvl: "Error", - CriticalLvl: "Critical", - Off: "Off", -} - -var levelToShortString = map[LogLevel]string{ - TraceLvl: "Trc", - DebugLvl: "Dbg", - InfoLvl: "Inf", - WarnLvl: "Wrn", - ErrorLvl: "Err", - CriticalLvl: "Crt", - Off: "Off", -} - -var levelToShortestString = map[LogLevel]string{ - TraceLvl: "t", - DebugLvl: "d", - InfoLvl: "i", - WarnLvl: "w", - ErrorLvl: "e", - CriticalLvl: "c", - Off: "o", -} - -func formatterLevel(message string, level LogLevel, context LogContextInterface) interface{} { - levelStr, ok := levelToString[level] - if !ok { - return wrongLogLevel - } - return levelStr -} - -func formatterLev(message string, level LogLevel, context LogContextInterface) interface{} { - levelStr, ok := levelToShortString[level] - if !ok { - return wrongLogLevel - } - return levelStr -} - -func formatterLEVEL(message string, level LogLevel, context LogContextInterface) interface{} { - return strings.ToTitle(formatterLevel(message, level, context).(string)) -} - -func formatterLEV(message string, level LogLevel, context LogContextInterface) interface{} { - return strings.ToTitle(formatterLev(message, level, context).(string)) -} - -func formatterl(message string, level LogLevel, context LogContextInterface) interface{} { - levelStr, ok := levelToShortestString[level] - if !ok { - return wrongLogLevel - } - return levelStr -} - -func formatterMsg(message string, level LogLevel, context LogContextInterface) interface{} { - return message -} - -func formatterFullPath(message string, level LogLevel, context LogContextInterface) interface{} { - return context.FullPath() -} - -func formatterFile(message string, level LogLevel, context LogContextInterface) interface{} { - return context.FileName() -} - -func formatterRelFile(message string, level LogLevel, context LogContextInterface) interface{} { - return context.ShortPath() -} - -func FormatterFunction(message string, level LogLevel, context LogContextInterface) interface{} { - return context.Func() -} - -func FormatterFunctionShort(message string, level LogLevel, context LogContextInterface) interface{} { - f := context.Func() - spl := strings.Split(f, ".") - return spl[len(spl)-1] -} - -func formatterLine(message string, level LogLevel, context LogContextInterface) interface{} { - return context.Line() -} - -func formatterTime(message string, level LogLevel, context LogContextInterface) interface{} { - return context.CallTime().Format(TimeFormat) -} - -func formatterUTCTime(message string, level LogLevel, context LogContextInterface) interface{} { - return context.CallTime().UTC().Format(TimeFormat) -} - -func formatterNs(message string, level LogLevel, context LogContextInterface) interface{} { - return context.CallTime().UnixNano() -} - -func formatterUTCNs(message string, level LogLevel, context LogContextInterface) interface{} { - return context.CallTime().UTC().UnixNano() -} - -func formattern(message string, level LogLevel, context LogContextInterface) interface{} { - return "\n" -} - -func formattert(message string, level LogLevel, context LogContextInterface) interface{} { - return "\t" -} - -func createDateTimeFormatterFunc(dateTimeFormat string) FormatterFunc { - format := dateTimeFormat - if format == "" { - format = DateDefaultFormat - } - return func(message string, level LogLevel, context LogContextInterface) interface{} { - return context.CallTime().Format(format) - } -} - -func createUTCDateTimeFormatterFunc(dateTimeFormat string) FormatterFunc { - format := dateTimeFormat - if format == "" { - format = DateDefaultFormat - } - return func(message string, level LogLevel, context LogContextInterface) interface{} { - return context.CallTime().UTC().Format(format) - } -} - -func createANSIEscapeFunc(escapeCodeString string) FormatterFunc { - return func(message string, level LogLevel, context LogContextInterface) interface{} { - if len(escapeCodeString) == 0 { - return wrongEscapeCode - } - - return fmt.Sprintf("%c[%sm", 0x1B, escapeCodeString) - } -} diff --git a/vendor/github.com/cihub/seelog/format_test.go b/vendor/github.com/cihub/seelog/format_test.go deleted file mode 100644 index 4402b60ef..000000000 --- a/vendor/github.com/cihub/seelog/format_test.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "strings" - "testing" - "time" -) - -const ( - TestFuncName = "TestFormats" -) - -type formatTest struct { - formatString string - input string - inputLogLevel LogLevel - expectedOutput string - errorExpected bool -} - -var formatTests = []formatTest{ - {"test", "abcdef", TraceLvl, "test", false}, - {"", "abcdef", TraceLvl, "", false}, - {"%Level", "", TraceLvl, "Trace", false}, - {"%Level", "", DebugLvl, "Debug", false}, - {"%Level", "", InfoLvl, "Info", false}, - {"%Level", "", WarnLvl, "Warn", false}, - {"%Level", "", ErrorLvl, "Error", false}, - {"%Level", "", CriticalLvl, "Critical", false}, - {"[%Level]", "", TraceLvl, "[Trace]", false}, - {"[%Level]", "abc", DebugLvl, "[Debug]", false}, - {"%LevelLevel", "", InfoLvl, "InfoLevel", false}, - {"[%Level][%Level]", "", WarnLvl, "[Warn][Warn]", false}, - {"[%Level]X[%Level]", "", ErrorLvl, "[Error]X[Error]", false}, - {"%Levelll", "", CriticalLvl, "Criticalll", false}, - {"%Lvl", "", TraceLvl, "", true}, - {"%%Level", "", DebugLvl, "%Level", false}, - {"%Level%", "", InfoLvl, "", true}, - {"%sevel", "", WarnLvl, "", true}, - {"Level", "", ErrorLvl, "Level", false}, - {"%LevelLevel", "", CriticalLvl, "CriticalLevel", false}, - {"%Lev", "", TraceLvl, "Trc", false}, - {"%Lev", "", DebugLvl, "Dbg", false}, - {"%Lev", "", InfoLvl, "Inf", false}, - {"%Lev", "", WarnLvl, "Wrn", false}, - {"%Lev", "", ErrorLvl, "Err", false}, - {"%Lev", "", CriticalLvl, "Crt", false}, - {"[%Lev]", "", TraceLvl, "[Trc]", false}, - {"[%Lev]", "abc", DebugLvl, "[Dbg]", false}, - {"%LevLevel", "", InfoLvl, "InfLevel", false}, - {"[%Level][%Lev]", "", WarnLvl, "[Warn][Wrn]", false}, - {"[%Lev]X[%Lev]", "", ErrorLvl, "[Err]X[Err]", false}, - {"%Levll", "", CriticalLvl, "Crtll", false}, - {"%LEVEL", "", TraceLvl, "TRACE", false}, - {"%LEVEL", "", DebugLvl, "DEBUG", false}, - {"%LEVEL", "", InfoLvl, "INFO", false}, - {"%LEVEL", "", WarnLvl, "WARN", false}, - {"%LEVEL", "", ErrorLvl, "ERROR", false}, - {"%LEVEL", "", CriticalLvl, "CRITICAL", false}, - {"[%LEVEL]", "", TraceLvl, "[TRACE]", false}, - {"[%LEVEL]", "abc", DebugLvl, "[DEBUG]", false}, - {"%LEVELLEVEL", "", InfoLvl, "INFOLEVEL", false}, - {"[%LEVEL][%LEVEL]", "", WarnLvl, "[WARN][WARN]", false}, - {"[%LEVEL]X[%Level]", "", ErrorLvl, "[ERROR]X[Error]", false}, - {"%LEVELLL", "", CriticalLvl, "CRITICALLL", false}, - {"%LEV", "", TraceLvl, "TRC", false}, - {"%LEV", "", DebugLvl, "DBG", false}, - {"%LEV", "", InfoLvl, "INF", false}, - {"%LEV", "", WarnLvl, "WRN", false}, - {"%LEV", "", ErrorLvl, "ERR", false}, - {"%LEV", "", CriticalLvl, "CRT", false}, - {"[%LEV]", "", TraceLvl, "[TRC]", false}, - {"[%LEV]", "abc", DebugLvl, "[DBG]", false}, - {"%LEVLEVEL", "", InfoLvl, "INFLEVEL", false}, - {"[%LEVEL][%LEV]", "", WarnLvl, "[WARN][WRN]", false}, - {"[%LEV]X[%LEV]", "", ErrorLvl, "[ERR]X[ERR]", false}, - {"%LEVLL", "", CriticalLvl, "CRTLL", false}, - {"%l", "", TraceLvl, "t", false}, - {"%l", "", DebugLvl, "d", false}, - {"%l", "", InfoLvl, "i", false}, - {"%l", "", WarnLvl, "w", false}, - {"%l", "", ErrorLvl, "e", false}, - {"%l", "", CriticalLvl, "c", false}, - {"[%l]", "", TraceLvl, "[t]", false}, - {"[%l]", "abc", DebugLvl, "[d]", false}, - {"%Level%Msg", "", TraceLvl, "Trace", false}, - {"%Level%Msg", "A", DebugLvl, "DebugA", false}, - {"%Level%Msg", "", InfoLvl, "Info", false}, - {"%Level%Msg", "test", WarnLvl, "Warntest", false}, - {"%Level%Msg", " ", ErrorLvl, "Error ", false}, - {"%Level%Msg", "", CriticalLvl, "Critical", false}, - {"[%Level]", "", TraceLvl, "[Trace]", false}, - {"[%Level]", "abc", DebugLvl, "[Debug]", false}, - {"%Level%MsgLevel", "A", InfoLvl, "InfoALevel", false}, - {"[%Level]%Msg[%Level]", "test", WarnLvl, "[Warn]test[Warn]", false}, - {"[%Level]%MsgX[%Level]", "test", ErrorLvl, "[Error]testX[Error]", false}, - {"%Levell%Msgl", "Test", CriticalLvl, "CriticallTestl", false}, - {"%Lev%Msg%LEVEL%LEV%l%Msg", "Test", InfoLvl, "InfTestINFOINFiTest", false}, - {"%n", "", CriticalLvl, "\n", false}, - {"%t", "", CriticalLvl, "\t", false}, -} - -func TestFormats(t *testing.T) { - - context, conErr := currentContext() - if conErr != nil { - t.Fatal("Cannot get current context:" + conErr.Error()) - return - } - - for _, test := range formatTests { - - form, err := newFormatter(test.formatString) - - if (err != nil) != test.errorExpected { - t.Errorf("input: %s \nInput LL: %s\n* Expected error:%t Got error: %t\n", - test.input, test.inputLogLevel, test.errorExpected, (err != nil)) - if err != nil { - t.Logf("%s\n", err.Error()) - } - continue - } else if err != nil { - continue - } - - msg := form.Format(test.input, test.inputLogLevel, context) - - if err == nil && msg != test.expectedOutput { - t.Errorf("format: %s \nInput: %s \nInput LL: %s\n* Expected: %s \n* Got: %s\n", - test.formatString, test.input, test.inputLogLevel, test.expectedOutput, msg) - } - } -} - -func TestDateFormat(t *testing.T) { - _, err := newFormatter("%Date") - if err != nil { - t.Error("Unexpected error: " + err.Error()) - } -} - -func TestDateParameterizedFormat(t *testing.T) { - testFormat := "Mon Jan 02 2006 15:04:05" - preciseForamt := "Mon Jan 02 2006 15:04:05.000" - - context, conErr := currentContext() - if conErr != nil { - t.Fatal("Cannot get current context:" + conErr.Error()) - return - } - - form, err := newFormatter("%Date(" + preciseForamt + ")") - if err != nil { - t.Error("Unexpected error: " + err.Error()) - } - - dateBefore := time.Now().Format(testFormat) - msg := form.Format("", TraceLvl, context) - dateAfter := time.Now().Format(testFormat) - - if !strings.HasPrefix(msg, dateBefore) && !strings.HasPrefix(msg, dateAfter) { - t.Errorf("incorrect message: %v. Expected %v or %v", msg, dateBefore, dateAfter) - } - - _, err = newFormatter("%Date(" + preciseForamt) - if err == nil { - t.Error("Expected error for invalid format") - } -} - -func createTestFormatter(format string) FormatterFunc { - return func(message string, level LogLevel, context LogContextInterface) interface{} { - return "TEST " + context.Func() + " TEST" - } -} - -func TestCustomFormatterRegistration(t *testing.T) { - err := RegisterCustomFormatter("Level", createTestFormatter) - if err == nil { - t.Errorf("expected an error when trying to register a custom formatter with a reserved alias") - } - err = RegisterCustomFormatter("EscM", createTestFormatter) - if err == nil { - t.Errorf("expected an error when trying to register a custom formatter with a reserved parameterized alias") - } - err = RegisterCustomFormatter("TEST", createTestFormatter) - if err != nil { - t.Fatalf("Registering custom formatter: unexpected error: %s", err) - } - err = RegisterCustomFormatter("TEST", createTestFormatter) - if err == nil { - t.Errorf("expected an error when trying to register a custom formatter with duplicate name") - } - - context, conErr := currentContext() - if conErr != nil { - t.Fatal("Cannot get current context:" + conErr.Error()) - return - } - - form, err := newFormatter("%Msg %TEST 123") - if err != nil { - t.Fatalf("%s\n", err.Error()) - } - - expected := fmt.Sprintf("test TEST %sTestCustomFormatterRegistration TEST 123", commonPrefix) - msg := form.Format("test", DebugLvl, context) - if msg != expected { - t.Fatalf("Custom formatter: invalid output. Expected: '%s'. Got: '%s'", expected, msg) - } -} diff --git a/vendor/github.com/cihub/seelog/internals_baseerror.go b/vendor/github.com/cihub/seelog/internals_baseerror.go deleted file mode 100644 index c0b271d7d..000000000 --- a/vendor/github.com/cihub/seelog/internals_baseerror.go +++ /dev/null @@ -1,10 +0,0 @@ -package seelog - -// Base struct for custom errors. -type baseError struct { - message string -} - -func (be baseError) Error() string { - return be.message -} diff --git a/vendor/github.com/cihub/seelog/internals_byteverifiers_test.go b/vendor/github.com/cihub/seelog/internals_byteverifiers_test.go deleted file mode 100644 index 0ab6ebc68..000000000 --- a/vendor/github.com/cihub/seelog/internals_byteverifiers_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "strconv" - "testing" -) - -// bytesVerifier is a byte receiver which is used for correct input testing. -// It allows to compare expected result and actual result in context of received bytes. -type bytesVerifier struct { - expectedBytes []byte // bytes that are expected to be written in next Write call - waitingForInput bool // true if verifier is waiting for a Write call - writtenData []byte // real bytes that actually were received during the last Write call - testEnv *testing.T -} - -func newBytesVerifier(t *testing.T) (*bytesVerifier, error) { - if t == nil { - return nil, errors.New("testing environment param is nil") - } - - verifier := new(bytesVerifier) - verifier.testEnv = t - - return verifier, nil -} - -// Write is used to check whether verifier was waiting for input and whether bytes are the same as expectedBytes. -// After Write call, waitingForInput is set to false. -func (verifier *bytesVerifier) Write(bytes []byte) (n int, err error) { - if !verifier.waitingForInput { - verifier.testEnv.Errorf("unexpected input: %v", string(bytes)) - return - } - - verifier.waitingForInput = false - verifier.writtenData = bytes - - if verifier.expectedBytes != nil { - if bytes == nil { - verifier.testEnv.Errorf("incoming 'bytes' is nil") - } else { - if len(bytes) != len(verifier.expectedBytes) { - verifier.testEnv.Errorf("'Bytes' has unexpected len. Expected: %d. Got: %d. . Expected string: %q. Got: %q", - len(verifier.expectedBytes), len(bytes), string(verifier.expectedBytes), string(bytes)) - } else { - for i := 0; i < len(bytes); i++ { - if verifier.expectedBytes[i] != bytes[i] { - verifier.testEnv.Errorf("incorrect data on position %d. Expected: %d. Got: %d. Expected string: %q. Got: %q", - i, verifier.expectedBytes[i], bytes[i], string(verifier.expectedBytes), string(bytes)) - break - } - } - } - } - } - - return len(bytes), nil -} - -func (verifier *bytesVerifier) ExpectBytes(bytes []byte) { - verifier.waitingForInput = true - verifier.expectedBytes = bytes -} - -func (verifier *bytesVerifier) MustNotExpect() { - if verifier.waitingForInput { - errorText := "Unexpected input: " - - if verifier.expectedBytes != nil { - errorText += "len = " + strconv.Itoa(len(verifier.expectedBytes)) - errorText += ". text = " + string(verifier.expectedBytes) - } - - verifier.testEnv.Errorf(errorText) - } -} - -func (verifier *bytesVerifier) Close() error { - return nil -} - -// nullWriter implements io.Writer inteface and does nothing, always returning a successful write result -type nullWriter struct { -} - -func (writer *nullWriter) Write(bytes []byte) (n int, err error) { - return len(bytes), nil -} - -func (writer *nullWriter) Close() error { - return nil -} diff --git a/vendor/github.com/cihub/seelog/internals_fsutils.go b/vendor/github.com/cihub/seelog/internals_fsutils.go deleted file mode 100644 index 5baa6ba61..000000000 --- a/vendor/github.com/cihub/seelog/internals_fsutils.go +++ /dev/null @@ -1,403 +0,0 @@ -package seelog - -import ( - "archive/zip" - "bytes" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "sync" -) - -// File and directory permitions. -const ( - defaultFilePermissions = 0666 - defaultDirectoryPermissions = 0767 -) - -const ( - // Max number of directories can be read asynchronously. - maxDirNumberReadAsync = 1000 -) - -type cannotOpenFileError struct { - baseError -} - -func newCannotOpenFileError(fname string) *cannotOpenFileError { - return &cannotOpenFileError{baseError{message: "Cannot open file: " + fname}} -} - -type notDirectoryError struct { - baseError -} - -func newNotDirectoryError(dname string) *notDirectoryError { - return ¬DirectoryError{baseError{message: dname + " is not directory"}} -} - -// fileFilter is a filtering criteria function for '*os.File'. -// Must return 'false' to set aside the given file. -type fileFilter func(os.FileInfo, *os.File) bool - -// filePathFilter is a filtering creteria function for file path. -// Must return 'false' to set aside the given file. -type filePathFilter func(filePath string) bool - -// GetSubdirNames returns a list of directories found in -// the given one with dirPath. -func getSubdirNames(dirPath string) ([]string, error) { - fi, err := os.Stat(dirPath) - if err != nil { - return nil, err - } - if !fi.IsDir() { - return nil, newNotDirectoryError(dirPath) - } - dd, err := os.Open(dirPath) - // Cannot open file. - if err != nil { - if dd != nil { - dd.Close() - } - return nil, err - } - defer dd.Close() - // TODO: Improve performance by buffering reading. - allEntities, err := dd.Readdir(-1) - if err != nil { - return nil, err - } - subDirs := []string{} - for _, entity := range allEntities { - if entity.IsDir() { - subDirs = append(subDirs, entity.Name()) - } - } - return subDirs, nil -} - -// getSubdirAbsPaths recursively visit all the subdirectories -// starting from the given directory and returns absolute paths for them. -func getAllSubdirAbsPaths(dirPath string) (res []string, err error) { - dps, err := getSubdirAbsPaths(dirPath) - if err != nil { - res = []string{} - return - } - res = append(res, dps...) - for _, dp := range dps { - sdps, err := getAllSubdirAbsPaths(dp) - if err != nil { - return []string{}, err - } - res = append(res, sdps...) - } - return -} - -// getSubdirAbsPaths supplies absolute paths for all subdirectiries in a given directory. -// Input: (I1) dirPath - absolute path of a directory in question. -// Out: (O1) - slice of subdir asbolute paths; (O2) - error of the operation. -// Remark: If error (O2) is non-nil then (O1) is nil and vice versa. -func getSubdirAbsPaths(dirPath string) ([]string, error) { - sdns, err := getSubdirNames(dirPath) - if err != nil { - return nil, err - } - rsdns := []string{} - for _, sdn := range sdns { - rsdns = append(rsdns, filepath.Join(dirPath, sdn)) - } - return rsdns, nil -} - -// getOpenFilesInDir supplies a slice of os.File pointers to files located in the directory. -// Remark: Ignores files for which fileFilter returns false -func getOpenFilesInDir(dirPath string, fFilter fileFilter) ([]*os.File, error) { - dfi, err := os.Open(dirPath) - if err != nil { - return nil, newCannotOpenFileError("Cannot open directory " + dirPath) - } - defer dfi.Close() - // Size of read buffer (i.e. chunk of items read at a time). - rbs := 64 - resFiles := []*os.File{} -L: - for { - // Read directory entities by reasonable chuncks - // to prevent overflows on big number of files. - fis, e := dfi.Readdir(rbs) - switch e { - // It's OK. - case nil: - // Do nothing, just continue cycle. - case io.EOF: - break L - // Something went wrong. - default: - return nil, e - } - // THINK: Maybe, use async running. - for _, fi := range fis { - // NB: On Linux this could be a problem as - // there are lots of file types available. - if !fi.IsDir() { - f, e := os.Open(filepath.Join(dirPath, fi.Name())) - if e != nil { - if f != nil { - f.Close() - } - // THINK: Add nil as indicator that a problem occurred. - resFiles = append(resFiles, nil) - continue - } - // Check filter condition. - if fFilter != nil && !fFilter(fi, f) { - continue - } - resFiles = append(resFiles, f) - } - } - } - return resFiles, nil -} - -func isRegular(m os.FileMode) bool { - return m&os.ModeType == 0 -} - -// getDirFilePaths return full paths of the files located in the directory. -// Remark: Ignores files for which fileFilter returns false. -func getDirFilePaths(dirPath string, fpFilter filePathFilter, pathIsName bool) ([]string, error) { - dfi, err := os.Open(dirPath) - if err != nil { - return nil, newCannotOpenFileError("Cannot open directory " + dirPath) - } - defer dfi.Close() - - var absDirPath string - if !filepath.IsAbs(dirPath) { - absDirPath, err = filepath.Abs(dirPath) - if err != nil { - return nil, fmt.Errorf("cannot get absolute path of directory: %s", err.Error()) - } - } else { - absDirPath = dirPath - } - - // TODO: check if dirPath is really directory. - // Size of read buffer (i.e. chunk of items read at a time). - rbs := 2 << 5 - filePaths := []string{} - - var fp string -L: - for { - // Read directory entities by reasonable chuncks - // to prevent overflows on big number of files. - fis, e := dfi.Readdir(rbs) - switch e { - // It's OK. - case nil: - // Do nothing, just continue cycle. - case io.EOF: - break L - // Indicate that something went wrong. - default: - return nil, e - } - // THINK: Maybe, use async running. - for _, fi := range fis { - // NB: Should work on every Windows and non-Windows OS. - if isRegular(fi.Mode()) { - if pathIsName { - fp = fi.Name() - } else { - // Build full path of a file. - fp = filepath.Join(absDirPath, fi.Name()) - } - // Check filter condition. - if fpFilter != nil && !fpFilter(fp) { - continue - } - filePaths = append(filePaths, fp) - } - } - } - return filePaths, nil -} - -// getOpenFilesByDirectoryAsync runs async reading directories 'dirPaths' and inserts pairs -// in map 'filesInDirMap': Key - directory name, value - *os.File slice. -func getOpenFilesByDirectoryAsync( - dirPaths []string, - fFilter fileFilter, - filesInDirMap map[string][]*os.File, -) error { - n := len(dirPaths) - if n > maxDirNumberReadAsync { - return fmt.Errorf("number of input directories to be read exceeded max value %d", maxDirNumberReadAsync) - } - type filesInDirResult struct { - DirName string - Files []*os.File - Error error - } - dirFilesChan := make(chan *filesInDirResult, n) - var wg sync.WaitGroup - // Register n goroutines which are going to do work. - wg.Add(n) - for i := 0; i < n; i++ { - // Launch asynchronously the piece of work. - go func(dirPath string) { - fs, e := getOpenFilesInDir(dirPath, fFilter) - dirFilesChan <- &filesInDirResult{filepath.Base(dirPath), fs, e} - // Mark the current goroutine as finished (work is done). - wg.Done() - }(dirPaths[i]) - } - // Wait for all goroutines to finish their work. - wg.Wait() - // Close the error channel to let for-range clause - // get all the buffered values without blocking and quit in the end. - close(dirFilesChan) - for fidr := range dirFilesChan { - if fidr.Error == nil { - // THINK: What will happen if the key is already present? - filesInDirMap[fidr.DirName] = fidr.Files - } else { - return fidr.Error - } - } - return nil -} - -func copyFile(sf *os.File, dst string) (int64, error) { - df, err := os.Create(dst) - if err != nil { - return 0, err - } - defer df.Close() - return io.Copy(df, sf) -} - -// fileExists return flag whether a given file exists -// and operation error if an unclassified failure occurs. -func fileExists(path string) (bool, error) { - _, err := os.Stat(path) - if err != nil { - if os.IsNotExist(err) { - return false, nil - } - return false, err - } - return true, nil -} - -// createDirectory makes directory with a given name -// making all parent directories if necessary. -func createDirectory(dirPath string) error { - var dPath string - var err error - if !filepath.IsAbs(dirPath) { - dPath, err = filepath.Abs(dirPath) - if err != nil { - return err - } - } else { - dPath = dirPath - } - exists, err := fileExists(dPath) - if err != nil { - return err - } - if exists { - return nil - } - return os.MkdirAll(dPath, os.ModeDir) -} - -// tryRemoveFile gives a try removing the file -// only ignoring an error when the file does not exist. -func tryRemoveFile(filePath string) (err error) { - err = os.Remove(filePath) - if os.IsNotExist(err) { - err = nil - return - } - return -} - -// Unzips a specified zip file. Returns filename->filebytes map. -func unzip(archiveName string) (map[string][]byte, error) { - // Open a zip archive for reading. - r, err := zip.OpenReader(archiveName) - if err != nil { - return nil, err - } - defer r.Close() - - // Files to be added to archive - // map file name to contents - files := make(map[string][]byte) - - // Iterate through the files in the archive, - // printing some of their contents. - for _, f := range r.File { - rc, err := f.Open() - if err != nil { - return nil, err - } - - bts, err := ioutil.ReadAll(rc) - rcErr := rc.Close() - - if err != nil { - return nil, err - } - if rcErr != nil { - return nil, rcErr - } - - files[f.Name] = bts - } - - return files, nil -} - -// Creates a zip file with the specified file names and byte contents. -func createZip(archiveName string, files map[string][]byte) error { - // Create a buffer to write our archive to. - buf := new(bytes.Buffer) - - // Create a new zip archive. - w := zip.NewWriter(buf) - - // Write files - for fpath, fcont := range files { - f, err := w.Create(fpath) - if err != nil { - return err - } - _, err = f.Write([]byte(fcont)) - if err != nil { - return err - } - } - - // Make sure to check the error on Close. - err := w.Close() - if err != nil { - return err - } - - err = ioutil.WriteFile(archiveName, buf.Bytes(), defaultFilePermissions) - if err != nil { - return err - } - - return nil -} diff --git a/vendor/github.com/cihub/seelog/internals_xmlnode.go b/vendor/github.com/cihub/seelog/internals_xmlnode.go deleted file mode 100644 index 985884933..000000000 --- a/vendor/github.com/cihub/seelog/internals_xmlnode.go +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "encoding/xml" - "errors" - "fmt" - "io" - "strings" -) - -type xmlNode struct { - name string - attributes map[string]string - children []*xmlNode - value string -} - -func newNode() *xmlNode { - node := new(xmlNode) - node.children = make([]*xmlNode, 0) - node.attributes = make(map[string]string) - return node -} - -func (node *xmlNode) String() string { - str := fmt.Sprintf("<%s", node.name) - - for attrName, attrVal := range node.attributes { - str += fmt.Sprintf(" %s=\"%s\"", attrName, attrVal) - } - - str += ">" - str += node.value - - if len(node.children) != 0 { - for _, child := range node.children { - str += fmt.Sprintf("%s", child) - } - } - - str += fmt.Sprintf("", node.name) - - return str -} - -func (node *xmlNode) unmarshal(startEl xml.StartElement) error { - node.name = startEl.Name.Local - - for _, v := range startEl.Attr { - _, alreadyExists := node.attributes[v.Name.Local] - if alreadyExists { - return errors.New("tag '" + node.name + "' has duplicated attribute: '" + v.Name.Local + "'") - } - node.attributes[v.Name.Local] = v.Value - } - - return nil -} - -func (node *xmlNode) add(child *xmlNode) { - if node.children == nil { - node.children = make([]*xmlNode, 0) - } - - node.children = append(node.children, child) -} - -func (node *xmlNode) hasChildren() bool { - return node.children != nil && len(node.children) > 0 -} - -//============================================= - -func unmarshalConfig(reader io.Reader) (*xmlNode, error) { - xmlParser := xml.NewDecoder(reader) - - config, err := unmarshalNode(xmlParser, nil) - if err != nil { - return nil, err - } - if config == nil { - return nil, errors.New("xml has no content") - } - - nextConfigEntry, err := unmarshalNode(xmlParser, nil) - if nextConfigEntry != nil { - return nil, errors.New("xml contains more than one root element") - } - - return config, nil -} - -func unmarshalNode(xmlParser *xml.Decoder, curToken xml.Token) (node *xmlNode, err error) { - firstLoop := true - for { - var tok xml.Token - if firstLoop && curToken != nil { - tok = curToken - firstLoop = false - } else { - tok, err = getNextToken(xmlParser) - if err != nil || tok == nil { - return - } - } - - switch tt := tok.(type) { - case xml.SyntaxError: - err = errors.New(tt.Error()) - return - case xml.CharData: - value := strings.TrimSpace(string([]byte(tt))) - if node != nil { - node.value += value - } - case xml.StartElement: - if node == nil { - node = newNode() - err := node.unmarshal(tt) - if err != nil { - return nil, err - } - } else { - childNode, childErr := unmarshalNode(xmlParser, tok) - if childErr != nil { - return nil, childErr - } - - if childNode != nil { - node.add(childNode) - } else { - return - } - } - case xml.EndElement: - return - } - } -} - -func getNextToken(xmlParser *xml.Decoder) (tok xml.Token, err error) { - if tok, err = xmlParser.Token(); err != nil { - if err == io.EOF { - err = nil - return - } - return - } - - return -} diff --git a/vendor/github.com/cihub/seelog/internals_xmlnode_test.go b/vendor/github.com/cihub/seelog/internals_xmlnode_test.go deleted file mode 100644 index 3a4487ce7..000000000 --- a/vendor/github.com/cihub/seelog/internals_xmlnode_test.go +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "strings" - "testing" - //"fmt" - "reflect" -) - -var testEnv *testing.T - -/*func TestWrapper(t *testing.T) { - testEnv = t - - s := "" - reader := strings.NewReader(s) - config, err := unmarshalConfig(reader) - if err != nil { - testEnv.Error(err) - return - } - - printXML(config, 0) -} - -func printXML(node *xmlNode, level int) { - indent := strings.Repeat("\t", level) - fmt.Print(indent + node.name) - for key, value := range node.attributes { - fmt.Print(" " + key + "/" + value) - } - fmt.Println() - - for _, child := range node.children { - printXML(child, level+1) - } -}*/ - -var xmlNodeTests []xmlNodeTest - -type xmlNodeTest struct { - testName string - inputXML string - expected interface{} - errorExpected bool -} - -func getXMLTests() []xmlNodeTest { - if xmlNodeTests == nil { - xmlNodeTests = make([]xmlNodeTest, 0) - - testName := "Simple test" - testXML := `` - testExpected := newNode() - testExpected.name = "a" - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Multiline test" - testXML = - ` - - -` - testExpected = newNode() - testExpected.name = "a" - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Multiline test #2" - testXML = - ` - - - - - - -` - testExpected = newNode() - testExpected.name = "a" - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Incorrect names" - testXML = `< a >< /a >` - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, nil, true}) - - testName = "Comments" - testXML = - ` - - -` - testExpected = newNode() - testExpected.name = "a" - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Multiple roots" - testXML = `` - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, nil, true}) - - testName = "Multiple roots + incorrect xml" - testXML = `` - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, nil, true}) - - testName = "Some unicode and data" - testXML = `<俄语>данные` - testExpected = newNode() - testExpected.name = "俄语" - testExpected.value = "данные" - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Values and children" - testXML = `<俄语>данные` - testExpected = newNode() - testExpected.name = "俄语" - testExpected.value = "данные" - child := newNode() - child.name = "and_a_child" - testExpected.children = append(testExpected.children, child) - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Just children" - testXML = `<俄语>` - testExpected = newNode() - testExpected.name = "俄语" - child = newNode() - child.name = "and_a_child" - testExpected.children = append(testExpected.children, child) - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - - testName = "Mixed test" - testXML = `<俄语 a="1" b="2.13" c="abc">` - testExpected = newNode() - testExpected.name = "俄语" - testExpected.attributes["a"] = "1" - testExpected.attributes["b"] = "2.13" - testExpected.attributes["c"] = "abc" - child = newNode() - child.name = "child" - child.attributes["abc"] = "bca" - testExpected.children = append(testExpected.children, child) - child = newNode() - child.name = "child" - child.attributes["abc"] = "def" - testExpected.children = append(testExpected.children, child) - xmlNodeTests = append(xmlNodeTests, xmlNodeTest{testName, testXML, testExpected, false}) - } - - return xmlNodeTests -} - -func TestXmlNode(t *testing.T) { - - for _, test := range getXMLTests() { - - reader := strings.NewReader(test.inputXML) - parsedXML, err := unmarshalConfig(reader) - - if (err != nil) != test.errorExpected { - t.Errorf("\n%s:\nXML input: %s\nExpected error:%t. Got error: %t\n", test.testName, - test.inputXML, test.errorExpected, (err != nil)) - if err != nil { - t.Logf("%s\n", err.Error()) - } - continue - } - - if err == nil && !reflect.DeepEqual(parsedXML, test.expected) { - t.Errorf("\n%s:\nXML input: %s\nExpected: %s. \nGot: %s\n", test.testName, - test.inputXML, test.expected, parsedXML) - } - } -} diff --git a/vendor/github.com/cihub/seelog/log.go b/vendor/github.com/cihub/seelog/log.go deleted file mode 100644 index 1ec688062..000000000 --- a/vendor/github.com/cihub/seelog/log.go +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "sync" - "time" -) - -const ( - staticFuncCallDepth = 3 // See 'commonLogger.log' method comments - loggerFuncCallDepth = 3 -) - -// Current is the logger used in all package level convenience funcs like 'Trace', 'Debug', 'Flush', etc. -var Current LoggerInterface - -// Default logger that is created from an empty config: "". It is not closed by a ReplaceLogger call. -var Default LoggerInterface - -// Disabled logger that doesn't produce any output in any circumstances. It is neither closed nor flushed by a ReplaceLogger call. -var Disabled LoggerInterface - -var pkgOperationsMutex *sync.Mutex - -func init() { - pkgOperationsMutex = new(sync.Mutex) - var err error - - if Default == nil { - Default, err = LoggerFromConfigAsBytes([]byte("")) - } - - if Disabled == nil { - Disabled, err = LoggerFromConfigAsBytes([]byte("")) - } - - if err != nil { - panic(fmt.Sprintf("Seelog couldn't start. Error: %s", err.Error())) - } - - Current = Default -} - -func createLoggerFromConfig(config *logConfig) (LoggerInterface, error) { - if config.LogType == syncloggerTypeFromString { - return newSyncLogger(config), nil - } else if config.LogType == asyncLooploggerTypeFromString { - return newAsyncLoopLogger(config), nil - } else if config.LogType == asyncTimerloggerTypeFromString { - logData := config.LoggerData - if logData == nil { - return nil, errors.New("async timer data not set") - } - - asyncInt, ok := logData.(asyncTimerLoggerData) - if !ok { - return nil, errors.New("invalid async timer data") - } - - logger, err := newAsyncTimerLogger(config, time.Duration(asyncInt.AsyncInterval)) - if !ok { - return nil, err - } - - return logger, nil - } else if config.LogType == adaptiveLoggerTypeFromString { - logData := config.LoggerData - if logData == nil { - return nil, errors.New("adaptive logger parameters not set") - } - - adaptData, ok := logData.(adaptiveLoggerData) - if !ok { - return nil, errors.New("invalid adaptive logger parameters") - } - - logger, err := newAsyncAdaptiveLogger( - config, - time.Duration(adaptData.MinInterval), - time.Duration(adaptData.MaxInterval), - adaptData.CriticalMsgCount, - ) - if err != nil { - return nil, err - } - - return logger, nil - } - return nil, errors.New("invalid config log type/data") -} - -// UseLogger sets the 'Current' package level logger variable to the specified value. -// This variable is used in all Trace/Debug/... package level convenience funcs. -// -// Example: -// -// after calling -// seelog.UseLogger(somelogger) -// the following: -// seelog.Debug("abc") -// will be equal to -// somelogger.Debug("abc") -// -// IMPORTANT: UseLogger do NOT close the previous logger (only flushes it). So if -// you constantly use it to replace loggers and don't close them in other code, you'll -// end up having memory leaks. -// -// To safely replace loggers, use ReplaceLogger. -func UseLogger(logger LoggerInterface) error { - if logger == nil { - return errors.New("logger can not be nil") - } - - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - - oldLogger := Current - Current = logger - - if oldLogger != nil { - oldLogger.Flush() - } - - return nil -} - -// ReplaceLogger acts as UseLogger but the logger that was previously -// used is disposed (except Default and Disabled loggers). -// -// Example: -// import log "github.com/cihub/seelog" -// -// func main() { -// logger, err := log.LoggerFromConfigAsFile("seelog.xml") -// -// if err != nil { -// panic(err) -// } -// -// log.ReplaceLogger(logger) -// defer log.Flush() -// -// log.Trace("test") -// log.Debugf("var = %s", "abc") -// } -func ReplaceLogger(logger LoggerInterface) error { - if logger == nil { - return errors.New("logger can not be nil") - } - - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - - defer func() { - if err := recover(); err != nil { - reportInternalError(fmt.Errorf("recovered from panic during ReplaceLogger: %s", err)) - } - }() - - if Current == Default { - Current.Flush() - } else if Current != nil && !Current.Closed() && Current != Disabled { - Current.Flush() - Current.Close() - } - - Current = logger - - return nil -} - -// Tracef formats message according to format specifier -// and writes to default logger with log level = Trace. -func Tracef(format string, params ...interface{}) { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.traceWithCallDepth(staticFuncCallDepth, newLogFormattedMessage(format, params)) -} - -// Debugf formats message according to format specifier -// and writes to default logger with log level = Debug. -func Debugf(format string, params ...interface{}) { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.debugWithCallDepth(staticFuncCallDepth, newLogFormattedMessage(format, params)) -} - -// Infof formats message according to format specifier -// and writes to default logger with log level = Info. -func Infof(format string, params ...interface{}) { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.infoWithCallDepth(staticFuncCallDepth, newLogFormattedMessage(format, params)) -} - -// Warnf formats message according to format specifier and writes to default logger with log level = Warn -func Warnf(format string, params ...interface{}) error { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - message := newLogFormattedMessage(format, params) - Current.warnWithCallDepth(staticFuncCallDepth, message) - return errors.New(message.String()) -} - -// Errorf formats message according to format specifier and writes to default logger with log level = Error -func Errorf(format string, params ...interface{}) error { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - message := newLogFormattedMessage(format, params) - Current.errorWithCallDepth(staticFuncCallDepth, message) - return errors.New(message.String()) -} - -// Criticalf formats message according to format specifier and writes to default logger with log level = Critical -func Criticalf(format string, params ...interface{}) error { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - message := newLogFormattedMessage(format, params) - Current.criticalWithCallDepth(staticFuncCallDepth, message) - return errors.New(message.String()) -} - -// Trace formats message using the default formats for its operands and writes to default logger with log level = Trace -func Trace(v ...interface{}) { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.traceWithCallDepth(staticFuncCallDepth, newLogMessage(v)) -} - -// Debug formats message using the default formats for its operands and writes to default logger with log level = Debug -func Debug(v ...interface{}) { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.debugWithCallDepth(staticFuncCallDepth, newLogMessage(v)) -} - -// Info formats message using the default formats for its operands and writes to default logger with log level = Info -func Info(v ...interface{}) { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.infoWithCallDepth(staticFuncCallDepth, newLogMessage(v)) -} - -// Warn formats message using the default formats for its operands and writes to default logger with log level = Warn -func Warn(v ...interface{}) error { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - message := newLogMessage(v) - Current.warnWithCallDepth(staticFuncCallDepth, message) - return errors.New(message.String()) -} - -// Error formats message using the default formats for its operands and writes to default logger with log level = Error -func Error(v ...interface{}) error { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - message := newLogMessage(v) - Current.errorWithCallDepth(staticFuncCallDepth, message) - return errors.New(message.String()) -} - -// Critical formats message using the default formats for its operands and writes to default logger with log level = Critical -func Critical(v ...interface{}) error { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - message := newLogMessage(v) - Current.criticalWithCallDepth(staticFuncCallDepth, message) - return errors.New(message.String()) -} - -// Flush immediately processes all currently queued messages and all currently buffered messages. -// It is a blocking call which returns only after the queue is empty and all the buffers are empty. -// -// If Flush is called for a synchronous logger (type='sync'), it only flushes buffers (e.g. '' receivers) -// , because there is no queue. -// -// Call this method when your app is going to shut down not to lose any log messages. -func Flush() { - pkgOperationsMutex.Lock() - defer pkgOperationsMutex.Unlock() - Current.Flush() -} diff --git a/vendor/github.com/cihub/seelog/logger.go b/vendor/github.com/cihub/seelog/logger.go deleted file mode 100644 index 480eae80f..000000000 --- a/vendor/github.com/cihub/seelog/logger.go +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "os" - "sync" -) - -func reportInternalError(err error) { - fmt.Fprintf(os.Stderr, "seelog internal error: %s\n", err) -} - -// LoggerInterface represents structs capable of logging Seelog messages -type LoggerInterface interface { - - // Tracef formats message according to format specifier - // and writes to log with level = Trace. - Tracef(format string, params ...interface{}) - - // Debugf formats message according to format specifier - // and writes to log with level = Debug. - Debugf(format string, params ...interface{}) - - // Infof formats message according to format specifier - // and writes to log with level = Info. - Infof(format string, params ...interface{}) - - // Warnf formats message according to format specifier - // and writes to log with level = Warn. - Warnf(format string, params ...interface{}) error - - // Errorf formats message according to format specifier - // and writes to log with level = Error. - Errorf(format string, params ...interface{}) error - - // Criticalf formats message according to format specifier - // and writes to log with level = Critical. - Criticalf(format string, params ...interface{}) error - - // Trace formats message using the default formats for its operands - // and writes to log with level = Trace - Trace(v ...interface{}) - - // Debug formats message using the default formats for its operands - // and writes to log with level = Debug - Debug(v ...interface{}) - - // Info formats message using the default formats for its operands - // and writes to log with level = Info - Info(v ...interface{}) - - // Warn formats message using the default formats for its operands - // and writes to log with level = Warn - Warn(v ...interface{}) error - - // Error formats message using the default formats for its operands - // and writes to log with level = Error - Error(v ...interface{}) error - - // Critical formats message using the default formats for its operands - // and writes to log with level = Critical - Critical(v ...interface{}) error - - traceWithCallDepth(callDepth int, message fmt.Stringer) - debugWithCallDepth(callDepth int, message fmt.Stringer) - infoWithCallDepth(callDepth int, message fmt.Stringer) - warnWithCallDepth(callDepth int, message fmt.Stringer) - errorWithCallDepth(callDepth int, message fmt.Stringer) - criticalWithCallDepth(callDepth int, message fmt.Stringer) - - // Close flushes all the messages in the logger and closes it. It cannot be used after this operation. - Close() - - // Flush flushes all the messages in the logger. - Flush() - - // Closed returns true if the logger was previously closed. - Closed() bool - - // SetAdditionalStackDepth sets the additional number of frames to skip by runtime.Caller - // when getting function information needed to print seelog format identifiers such as %Func or %File. - // - // This func may be used when you wrap seelog funcs and want to print caller info of you own - // wrappers instead of seelog func callers. In this case you should set depth = 1. If you then - // wrap your wrapper, you should set depth = 2, etc. - // - // NOTE: Incorrect depth value may lead to errors in runtime.Caller evaluation or incorrect - // function/file names in log files. Do not use it if you are not going to wrap seelog funcs. - // You may reset the value to default using a SetAdditionalStackDepth(0) call. - SetAdditionalStackDepth(depth int) error -} - -// innerLoggerInterface is an internal logging interface -type innerLoggerInterface interface { - innerLog(level LogLevel, context LogContextInterface, message fmt.Stringer) - Flush() -} - -// [file path][func name][level] -> [allowed] -type allowedContextCache map[string]map[string]map[LogLevel]bool - -// commonLogger contains all common data needed for logging and contains methods used to log messages. -type commonLogger struct { - config *logConfig // Config used for logging - contextCache allowedContextCache // Caches whether log is enabled for specific "full path-func name-level" sets - closed bool // 'true' when all writers are closed, all data is flushed, logger is unusable. Must be accessed while holding closedM - closedM sync.RWMutex - m sync.Mutex // Mutex for main operations - unusedLevels []bool - innerLogger innerLoggerInterface - addStackDepth int // Additional stack depth needed for correct seelog caller context detection -} - -func newCommonLogger(config *logConfig, internalLogger innerLoggerInterface) *commonLogger { - cLogger := new(commonLogger) - - cLogger.config = config - cLogger.contextCache = make(allowedContextCache) - cLogger.unusedLevels = make([]bool, Off) - cLogger.fillUnusedLevels() - cLogger.innerLogger = internalLogger - - return cLogger -} - -func (cLogger *commonLogger) SetAdditionalStackDepth(depth int) error { - if depth < 0 { - return fmt.Errorf("negative depth: %d", depth) - } - cLogger.m.Lock() - cLogger.addStackDepth = depth - cLogger.m.Unlock() - return nil -} - -func (cLogger *commonLogger) Tracef(format string, params ...interface{}) { - cLogger.traceWithCallDepth(loggerFuncCallDepth, newLogFormattedMessage(format, params)) -} - -func (cLogger *commonLogger) Debugf(format string, params ...interface{}) { - cLogger.debugWithCallDepth(loggerFuncCallDepth, newLogFormattedMessage(format, params)) -} - -func (cLogger *commonLogger) Infof(format string, params ...interface{}) { - cLogger.infoWithCallDepth(loggerFuncCallDepth, newLogFormattedMessage(format, params)) -} - -func (cLogger *commonLogger) Warnf(format string, params ...interface{}) error { - message := newLogFormattedMessage(format, params) - cLogger.warnWithCallDepth(loggerFuncCallDepth, message) - return errors.New(message.String()) -} - -func (cLogger *commonLogger) Errorf(format string, params ...interface{}) error { - message := newLogFormattedMessage(format, params) - cLogger.errorWithCallDepth(loggerFuncCallDepth, message) - return errors.New(message.String()) -} - -func (cLogger *commonLogger) Criticalf(format string, params ...interface{}) error { - message := newLogFormattedMessage(format, params) - cLogger.criticalWithCallDepth(loggerFuncCallDepth, message) - return errors.New(message.String()) -} - -func (cLogger *commonLogger) Trace(v ...interface{}) { - cLogger.traceWithCallDepth(loggerFuncCallDepth, newLogMessage(v)) -} - -func (cLogger *commonLogger) Debug(v ...interface{}) { - cLogger.debugWithCallDepth(loggerFuncCallDepth, newLogMessage(v)) -} - -func (cLogger *commonLogger) Info(v ...interface{}) { - cLogger.infoWithCallDepth(loggerFuncCallDepth, newLogMessage(v)) -} - -func (cLogger *commonLogger) Warn(v ...interface{}) error { - message := newLogMessage(v) - cLogger.warnWithCallDepth(loggerFuncCallDepth, message) - return errors.New(message.String()) -} - -func (cLogger *commonLogger) Error(v ...interface{}) error { - message := newLogMessage(v) - cLogger.errorWithCallDepth(loggerFuncCallDepth, message) - return errors.New(message.String()) -} - -func (cLogger *commonLogger) Critical(v ...interface{}) error { - message := newLogMessage(v) - cLogger.criticalWithCallDepth(loggerFuncCallDepth, message) - return errors.New(message.String()) -} - -func (cLogger *commonLogger) traceWithCallDepth(callDepth int, message fmt.Stringer) { - cLogger.log(TraceLvl, message, callDepth) -} - -func (cLogger *commonLogger) debugWithCallDepth(callDepth int, message fmt.Stringer) { - cLogger.log(DebugLvl, message, callDepth) -} - -func (cLogger *commonLogger) infoWithCallDepth(callDepth int, message fmt.Stringer) { - cLogger.log(InfoLvl, message, callDepth) -} - -func (cLogger *commonLogger) warnWithCallDepth(callDepth int, message fmt.Stringer) { - cLogger.log(WarnLvl, message, callDepth) -} - -func (cLogger *commonLogger) errorWithCallDepth(callDepth int, message fmt.Stringer) { - cLogger.log(ErrorLvl, message, callDepth) -} - -func (cLogger *commonLogger) criticalWithCallDepth(callDepth int, message fmt.Stringer) { - cLogger.log(CriticalLvl, message, callDepth) - cLogger.innerLogger.Flush() -} - -func (cLogger *commonLogger) Closed() bool { - cLogger.closedM.RLock() - defer cLogger.closedM.RUnlock() - return cLogger.closed -} - -func (cLogger *commonLogger) fillUnusedLevels() { - for i := 0; i < len(cLogger.unusedLevels); i++ { - cLogger.unusedLevels[i] = true - } - - cLogger.fillUnusedLevelsByContraint(cLogger.config.Constraints) - - for _, exception := range cLogger.config.Exceptions { - cLogger.fillUnusedLevelsByContraint(exception) - } -} - -func (cLogger *commonLogger) fillUnusedLevelsByContraint(constraint logLevelConstraints) { - for i := 0; i < len(cLogger.unusedLevels); i++ { - if constraint.IsAllowed(LogLevel(i)) { - cLogger.unusedLevels[i] = false - } - } -} - -// stackCallDepth is used to indicate the call depth of 'log' func. -// This depth level is used in the runtime.Caller(...) call. See -// common_context.go -> specifyContext, extractCallerInfo for details. -func (cLogger *commonLogger) log(level LogLevel, message fmt.Stringer, stackCallDepth int) { - if cLogger.unusedLevels[level] { - return - } - cLogger.m.Lock() - defer cLogger.m.Unlock() - - if cLogger.Closed() { - return - } - context, _ := specifyContext(stackCallDepth + cLogger.addStackDepth) - // Context errors are not reported because there are situations - // in which context errors are normal Seelog usage cases. For - // example in executables with stripped symbols. - // Error contexts are returned instead. See common_context.go. - /*if err != nil { - reportInternalError(err) - return - }*/ - cLogger.innerLogger.innerLog(level, context, message) -} - -func (cLogger *commonLogger) processLogMsg(level LogLevel, message fmt.Stringer, context LogContextInterface) { - defer func() { - if err := recover(); err != nil { - reportInternalError(fmt.Errorf("recovered from panic during message processing: %s", err)) - } - }() - if cLogger.config.IsAllowed(level, context) { - cLogger.config.RootDispatcher.Dispatch(message.String(), level, context, reportInternalError) - } -} - -func (cLogger *commonLogger) isAllowed(level LogLevel, context LogContextInterface) bool { - funcMap, ok := cLogger.contextCache[context.FullPath()] - if !ok { - funcMap = make(map[string]map[LogLevel]bool, 0) - cLogger.contextCache[context.FullPath()] = funcMap - } - - levelMap, ok := funcMap[context.Func()] - if !ok { - levelMap = make(map[LogLevel]bool, 0) - funcMap[context.Func()] = levelMap - } - - isAllowValue, ok := levelMap[level] - if !ok { - isAllowValue = cLogger.config.IsAllowed(level, context) - levelMap[level] = isAllowValue - } - - return isAllowValue -} - -type logMessage struct { - params []interface{} -} - -type logFormattedMessage struct { - format string - params []interface{} -} - -func newLogMessage(params []interface{}) fmt.Stringer { - message := new(logMessage) - - message.params = params - - return message -} - -func newLogFormattedMessage(format string, params []interface{}) *logFormattedMessage { - message := new(logFormattedMessage) - - message.params = params - message.format = format - - return message -} - -func (message *logMessage) String() string { - return fmt.Sprint(message.params...) -} - -func (message *logFormattedMessage) String() string { - return fmt.Sprintf(message.format, message.params...) -} diff --git a/vendor/github.com/cihub/seelog/writers_bufferedwriter.go b/vendor/github.com/cihub/seelog/writers_bufferedwriter.go deleted file mode 100644 index e35e34098..000000000 --- a/vendor/github.com/cihub/seelog/writers_bufferedwriter.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "bufio" - "errors" - "fmt" - "io" - "sync" - "time" -) - -// bufferedWriter stores data in memory and flushes it every flushPeriod or when buffer is full -type bufferedWriter struct { - flushPeriod time.Duration // data flushes interval (in microseconds) - bufferMutex *sync.Mutex // mutex for buffer operations syncronization - innerWriter io.Writer // inner writer - buffer *bufio.Writer // buffered wrapper for inner writer - bufferSize int // max size of data chunk in bytes -} - -// newBufferedWriter creates a new buffered writer struct. -// bufferSize -- size of memory buffer in bytes -// flushPeriod -- period in which data flushes from memory buffer in milliseconds. 0 - turn off this functionality -func newBufferedWriter(innerWriter io.Writer, bufferSize int, flushPeriod time.Duration) (*bufferedWriter, error) { - - if innerWriter == nil { - return nil, errors.New("argument is nil: innerWriter") - } - if flushPeriod < 0 { - return nil, fmt.Errorf("flushPeriod can not be less than 0. Got: %d", flushPeriod) - } - - if bufferSize <= 0 { - return nil, fmt.Errorf("bufferSize can not be less or equal to 0. Got: %d", bufferSize) - } - - buffer := bufio.NewWriterSize(innerWriter, bufferSize) - - /*if err != nil { - return nil, err - }*/ - - newWriter := new(bufferedWriter) - - newWriter.innerWriter = innerWriter - newWriter.buffer = buffer - newWriter.bufferSize = bufferSize - newWriter.flushPeriod = flushPeriod * 1e6 - newWriter.bufferMutex = new(sync.Mutex) - - if flushPeriod != 0 { - go newWriter.flushPeriodically() - } - - return newWriter, nil -} - -func (bufWriter *bufferedWriter) writeBigChunk(bytes []byte) (n int, err error) { - bufferedLen := bufWriter.buffer.Buffered() - - n, err = bufWriter.flushInner() - if err != nil { - return - } - - written, writeErr := bufWriter.innerWriter.Write(bytes) - return bufferedLen + written, writeErr -} - -// Sends data to buffer manager. Waits until all buffers are full. -func (bufWriter *bufferedWriter) Write(bytes []byte) (n int, err error) { - - bufWriter.bufferMutex.Lock() - defer bufWriter.bufferMutex.Unlock() - - bytesLen := len(bytes) - - if bytesLen > bufWriter.bufferSize { - return bufWriter.writeBigChunk(bytes) - } - - if bytesLen > bufWriter.buffer.Available() { - n, err = bufWriter.flushInner() - if err != nil { - return - } - } - - bufWriter.buffer.Write(bytes) - - return len(bytes), nil -} - -func (bufWriter *bufferedWriter) Close() error { - closer, ok := bufWriter.innerWriter.(io.Closer) - if ok { - return closer.Close() - } - - return nil -} - -func (bufWriter *bufferedWriter) Flush() { - - bufWriter.bufferMutex.Lock() - defer bufWriter.bufferMutex.Unlock() - - bufWriter.flushInner() -} - -func (bufWriter *bufferedWriter) flushInner() (n int, err error) { - bufferedLen := bufWriter.buffer.Buffered() - flushErr := bufWriter.buffer.Flush() - - return bufWriter.buffer.Buffered() - bufferedLen, flushErr -} - -func (bufWriter *bufferedWriter) flushBuffer() { - bufWriter.bufferMutex.Lock() - defer bufWriter.bufferMutex.Unlock() - - bufWriter.buffer.Flush() -} - -func (bufWriter *bufferedWriter) flushPeriodically() { - if bufWriter.flushPeriod > 0 { - ticker := time.NewTicker(bufWriter.flushPeriod) - for { - <-ticker.C - bufWriter.flushBuffer() - } - } -} - -func (bufWriter *bufferedWriter) String() string { - return fmt.Sprintf("bufferedWriter size: %d, flushPeriod: %d", bufWriter.bufferSize, bufWriter.flushPeriod) -} diff --git a/vendor/github.com/cihub/seelog/writers_bufferedwriter_test.go b/vendor/github.com/cihub/seelog/writers_bufferedwriter_test.go deleted file mode 100644 index 42d7f288f..000000000 --- a/vendor/github.com/cihub/seelog/writers_bufferedwriter_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "testing" -) - -func TestChunkWriteOnFilling(t *testing.T) { - writer, _ := newBytesVerifier(t) - bufferedWriter, err := newBufferedWriter(writer, 1024, 0) - - if err != nil { - t.Fatalf("Unexpected buffered writer creation error: %s", err.Error()) - } - - bytes := make([]byte, 1000) - - bufferedWriter.Write(bytes) - writer.ExpectBytes(bytes) - bufferedWriter.Write(bytes) -} - -func TestFlushByTimePeriod(t *testing.T) { - writer, _ := newBytesVerifier(t) - bufferedWriter, err := newBufferedWriter(writer, 1024, 10) - - if err != nil { - t.Fatalf("Unexpected buffered writer creation error: %s", err.Error()) - } - - bytes := []byte("Hello") - - for i := 0; i < 2; i++ { - writer.ExpectBytes(bytes) - bufferedWriter.Write(bytes) - } -} - -func TestBigMessageMustPassMemoryBuffer(t *testing.T) { - writer, _ := newBytesVerifier(t) - bufferedWriter, err := newBufferedWriter(writer, 1024, 0) - - if err != nil { - t.Fatalf("Unexpected buffered writer creation error: %s", err.Error()) - } - - bytes := make([]byte, 5000) - - for i := 0; i < len(bytes); i++ { - bytes[i] = uint8(i % 255) - } - - writer.ExpectBytes(bytes) - bufferedWriter.Write(bytes) -} diff --git a/vendor/github.com/cihub/seelog/writers_connwriter.go b/vendor/github.com/cihub/seelog/writers_connwriter.go deleted file mode 100644 index b7b360b7e..000000000 --- a/vendor/github.com/cihub/seelog/writers_connwriter.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "crypto/tls" - "fmt" - "io" - "net" -) - -// connWriter is used to write to a stream-oriented network connection. -type connWriter struct { - innerWriter io.WriteCloser - reconnectOnMsg bool - reconnect bool - net string - addr string - useTLS bool - configTLS *tls.Config -} - -// Creates writer to the address addr on the network netName. -// Connection will be opened on each write if reconnectOnMsg = true -func newConnWriter(netName string, addr string, reconnectOnMsg bool) *connWriter { - newWriter := new(connWriter) - - newWriter.net = netName - newWriter.addr = addr - newWriter.reconnectOnMsg = reconnectOnMsg - - return newWriter -} - -// Creates a writer that uses SSL/TLS -func newTLSWriter(netName string, addr string, reconnectOnMsg bool, config *tls.Config) *connWriter { - newWriter := new(connWriter) - - newWriter.net = netName - newWriter.addr = addr - newWriter.reconnectOnMsg = reconnectOnMsg - newWriter.useTLS = true - newWriter.configTLS = config - - return newWriter -} - -func (connWriter *connWriter) Close() error { - if connWriter.innerWriter == nil { - return nil - } - - return connWriter.innerWriter.Close() -} - -func (connWriter *connWriter) Write(bytes []byte) (n int, err error) { - if connWriter.neededConnectOnMsg() { - err = connWriter.connect() - if err != nil { - return 0, err - } - } - - if connWriter.reconnectOnMsg { - defer connWriter.innerWriter.Close() - } - - n, err = connWriter.innerWriter.Write(bytes) - if err != nil { - connWriter.reconnect = true - } - - return -} - -func (connWriter *connWriter) String() string { - return fmt.Sprintf("Conn writer: [%s, %s, %v]", connWriter.net, connWriter.addr, connWriter.reconnectOnMsg) -} - -func (connWriter *connWriter) connect() error { - if connWriter.innerWriter != nil { - connWriter.innerWriter.Close() - connWriter.innerWriter = nil - } - - if connWriter.useTLS { - conn, err := tls.Dial(connWriter.net, connWriter.addr, connWriter.configTLS) - if err != nil { - return err - } - connWriter.innerWriter = conn - - return nil - } - - conn, err := net.Dial(connWriter.net, connWriter.addr) - if err != nil { - return err - } - - tcpConn, ok := conn.(*net.TCPConn) - if ok { - tcpConn.SetKeepAlive(true) - } - - connWriter.innerWriter = conn - - return nil -} - -func (connWriter *connWriter) neededConnectOnMsg() bool { - if connWriter.reconnect { - connWriter.reconnect = false - return true - } - - if connWriter.innerWriter == nil { - return true - } - - return connWriter.reconnectOnMsg -} diff --git a/vendor/github.com/cihub/seelog/writers_consolewriter.go b/vendor/github.com/cihub/seelog/writers_consolewriter.go deleted file mode 100644 index f0d3b4100..000000000 --- a/vendor/github.com/cihub/seelog/writers_consolewriter.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import "fmt" - -// consoleWriter is used to write to console -type consoleWriter struct { -} - -// Creates a new console writer. Returns error, if the console writer couldn't be created. -func newConsoleWriter() (writer *consoleWriter, err error) { - newWriter := new(consoleWriter) - - return newWriter, nil -} - -// Create folder and file on WriteLog/Write first call -func (console *consoleWriter) Write(bytes []byte) (int, error) { - return fmt.Print(string(bytes)) -} - -func (console *consoleWriter) String() string { - return "Console writer" -} diff --git a/vendor/github.com/cihub/seelog/writers_filewriter.go b/vendor/github.com/cihub/seelog/writers_filewriter.go deleted file mode 100644 index be5ec34be..000000000 --- a/vendor/github.com/cihub/seelog/writers_filewriter.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "io" - "os" - "path/filepath" -) - -// fileWriter is used to write to a file. -type fileWriter struct { - innerWriter io.WriteCloser - fileName string -} - -// Creates a new file and a corresponding writer. Returns error, if the file couldn't be created. -func newFileWriter(fileName string) (writer *fileWriter, err error) { - newWriter := new(fileWriter) - newWriter.fileName = fileName - - return newWriter, nil -} - -func (fw *fileWriter) Close() error { - if fw.innerWriter != nil { - err := fw.innerWriter.Close() - if err != nil { - return err - } - fw.innerWriter = nil - } - return nil -} - -// Create folder and file on WriteLog/Write first call -func (fw *fileWriter) Write(bytes []byte) (n int, err error) { - if fw.innerWriter == nil { - if err := fw.createFile(); err != nil { - return 0, err - } - } - return fw.innerWriter.Write(bytes) -} - -func (fw *fileWriter) createFile() error { - folder, _ := filepath.Split(fw.fileName) - var err error - - if 0 != len(folder) { - err = os.MkdirAll(folder, defaultDirectoryPermissions) - if err != nil { - return err - } - } - - // If exists - fw.innerWriter, err = os.OpenFile(fw.fileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, defaultFilePermissions) - - if err != nil { - return err - } - - return nil -} - -func (fw *fileWriter) String() string { - return fmt.Sprintf("File writer: %s", fw.fileName) -} diff --git a/vendor/github.com/cihub/seelog/writers_filewriter_test.go b/vendor/github.com/cihub/seelog/writers_filewriter_test.go deleted file mode 100644 index 5f73a2885..000000000 --- a/vendor/github.com/cihub/seelog/writers_filewriter_test.go +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "io" - "os" - "path/filepath" - "strings" - "testing" -) - -const ( - messageLen = 10 -) - -var bytesFileTest = []byte(strings.Repeat("A", messageLen)) - -func TestSimpleFileWriter(t *testing.T) { - t.Logf("Starting file writer tests") - newFileWriterTester(simplefileWriterTests, simplefileWriterGetter, t).test() -} - -//=============================================================== - -func simplefileWriterGetter(testCase *fileWriterTestCase) (io.WriteCloser, error) { - return newFileWriter(testCase.fileName) -} - -//=============================================================== -type fileWriterTestCase struct { - files []string - fileName string - rollingType rollingType - fileSize int64 - maxRolls int - datePattern string - writeCount int - resFiles []string - nameMode rollingNameMode -} - -func createSimplefileWriterTestCase(fileName string, writeCount int) *fileWriterTestCase { - return &fileWriterTestCase{[]string{}, fileName, rollingTypeSize, 0, 0, "", writeCount, []string{fileName}, 0} -} - -var simplefileWriterTests = []*fileWriterTestCase{ - createSimplefileWriterTestCase("log.testlog", 1), - createSimplefileWriterTestCase("log.testlog", 50), - createSimplefileWriterTestCase(filepath.Join("dir", "log.testlog"), 50), -} - -//=============================================================== - -type fileWriterTester struct { - testCases []*fileWriterTestCase - writerGetter func(*fileWriterTestCase) (io.WriteCloser, error) - t *testing.T -} - -func newFileWriterTester( - testCases []*fileWriterTestCase, - writerGetter func(*fileWriterTestCase) (io.WriteCloser, error), - t *testing.T) *fileWriterTester { - - return &fileWriterTester{testCases, writerGetter, t} -} - -func isWriterTestFile(fn string) bool { - return strings.Contains(fn, ".testlog") -} - -func cleanupWriterTest(t *testing.T) { - toDel, err := getDirFilePaths(".", isWriterTestFile, true) - if nil != err { - t.Fatal("Cannot list files in test directory!") - } - - for _, p := range toDel { - if err = tryRemoveFile(p); nil != err { - t.Errorf("cannot remove file %s in test directory: %s", p, err.Error()) - } - } - - if err = os.RemoveAll("dir"); nil != err { - t.Errorf("cannot remove temp test directory: %s", err.Error()) - } -} - -func getWriterTestResultFiles() ([]string, error) { - var p []string - - visit := func(path string, f os.FileInfo, err error) error { - if !f.IsDir() && isWriterTestFile(path) { - abs, err := filepath.Abs(path) - if err != nil { - return fmt.Errorf("filepath.Abs failed for %s", path) - } - - p = append(p, abs) - } - - return nil - } - - err := filepath.Walk(".", visit) - if nil != err { - return nil, err - } - - return p, nil -} - -func (tester *fileWriterTester) testCase(testCase *fileWriterTestCase, testNum int) { - defer cleanupWriterTest(tester.t) - - tester.t.Logf("Start test [%v]\n", testNum) - - for _, filePath := range testCase.files { - dir, _ := filepath.Split(filePath) - - var err error - - if 0 != len(dir) { - err = os.MkdirAll(dir, defaultDirectoryPermissions) - if err != nil { - tester.t.Error(err) - return - } - } - - fi, err := os.Create(filePath) - if err != nil { - tester.t.Error(err) - return - } - - err = fi.Close() - if err != nil { - tester.t.Error(err) - return - } - } - - fwc, err := tester.writerGetter(testCase) - if err != nil { - tester.t.Error(err) - return - } - defer fwc.Close() - - tester.performWrite(fwc, testCase.writeCount) - - files, err := getWriterTestResultFiles() - if err != nil { - tester.t.Error(err) - return - } - - tester.checkRequiredFilesExist(testCase, files) - tester.checkJustRequiredFilesExist(testCase, files) - -} - -func (tester *fileWriterTester) test() { - for i, tc := range tester.testCases { - cleanupWriterTest(tester.t) - tester.testCase(tc, i) - } -} - -func (tester *fileWriterTester) performWrite(fileWriter io.Writer, count int) { - for i := 0; i < count; i++ { - _, err := fileWriter.Write(bytesFileTest) - - if err != nil { - tester.t.Error(err) - return - } - } -} - -func (tester *fileWriterTester) checkRequiredFilesExist(testCase *fileWriterTestCase, files []string) { - var found bool - for _, expected := range testCase.resFiles { - found = false - exAbs, err := filepath.Abs(expected) - if err != nil { - tester.t.Errorf("filepath.Abs failed for %s", expected) - continue - } - - for _, f := range files { - if af, e := filepath.Abs(f); e == nil { - tester.t.Log(af) - if exAbs == af { - found = true - break - } - } else { - tester.t.Errorf("filepath.Abs failed for %s", f) - } - } - - if !found { - tester.t.Errorf("expected file: %s doesn't exist. Got %v\n", exAbs, files) - } - } -} - -func (tester *fileWriterTester) checkJustRequiredFilesExist(testCase *fileWriterTestCase, files []string) { - for _, f := range files { - found := false - for _, expected := range testCase.resFiles { - - exAbs, err := filepath.Abs(expected) - if err != nil { - tester.t.Errorf("filepath.Abs failed for %s", expected) - } else { - if exAbs == f { - found = true - break - } - } - } - - if !found { - tester.t.Errorf("unexpected file: %v", f) - } - } -} diff --git a/vendor/github.com/cihub/seelog/writers_formattedwriter.go b/vendor/github.com/cihub/seelog/writers_formattedwriter.go deleted file mode 100644 index d28f2b8dc..000000000 --- a/vendor/github.com/cihub/seelog/writers_formattedwriter.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "errors" - "fmt" - "io" -) - -type formattedWriter struct { - writer io.Writer - formatter *formatter -} - -func newFormattedWriter(writer io.Writer, formatter *formatter) (*formattedWriter, error) { - if formatter == nil { - return nil, errors.New("formatter can not be nil") - } - - return &formattedWriter{writer, formatter}, nil -} - -func (formattedWriter *formattedWriter) Write(message string, level LogLevel, context LogContextInterface) error { - str := formattedWriter.formatter.Format(message, level, context) - _, err := formattedWriter.writer.Write([]byte(str)) - return err -} - -func (formattedWriter *formattedWriter) String() string { - return fmt.Sprintf("writer: %s, format: %s", formattedWriter.writer, formattedWriter.formatter) -} - -func (formattedWriter *formattedWriter) Writer() io.Writer { - return formattedWriter.writer -} - -func (formattedWriter *formattedWriter) Format() *formatter { - return formattedWriter.formatter -} diff --git a/vendor/github.com/cihub/seelog/writers_formattedwriter_test.go b/vendor/github.com/cihub/seelog/writers_formattedwriter_test.go deleted file mode 100644 index 07519cc60..000000000 --- a/vendor/github.com/cihub/seelog/writers_formattedwriter_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "testing" -) - -func TestformattedWriter(t *testing.T) { - formatStr := "%Level %LEVEL %Msg" - message := "message" - var logLevel = LogLevel(TraceLvl) - - bytesVerifier, err := newBytesVerifier(t) - if err != nil { - t.Error(err) - return - } - - formatter, err := newFormatter(formatStr) - if err != nil { - t.Error(err) - return - } - - writer, err := newFormattedWriter(bytesVerifier, formatter) - if err != nil { - t.Error(err) - return - } - - context, err := currentContext() - if err != nil { - t.Error(err) - return - } - - logMessage := formatter.Format(message, logLevel, context) - - bytesVerifier.ExpectBytes([]byte(logMessage)) - writer.Write(message, logLevel, context) - bytesVerifier.MustNotExpect() -} diff --git a/vendor/github.com/cihub/seelog/writers_rollingfilewriter.go b/vendor/github.com/cihub/seelog/writers_rollingfilewriter.go deleted file mode 100644 index 5b321d5b0..000000000 --- a/vendor/github.com/cihub/seelog/writers_rollingfilewriter.go +++ /dev/null @@ -1,612 +0,0 @@ -// Copyright (c) 2013 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "sort" - "strconv" - "strings" - "time" -) - -// Common constants -const ( - rollingLogHistoryDelimiter = "." -) - -// Types of the rolling writer: roll by date, by time, etc. -type rollingType uint8 - -const ( - rollingTypeSize = iota - rollingTypeTime -) - -// Types of the rolled file naming mode: prefix, postfix, etc. -type rollingNameMode uint8 - -const ( - rollingNameModePostfix = iota - rollingNameModePrefix -) - -var rollingNameModesStringRepresentation = map[rollingNameMode]string{ - rollingNameModePostfix: "postfix", - rollingNameModePrefix: "prefix", -} - -func rollingNameModeFromString(rollingNameStr string) (rollingNameMode, bool) { - for tp, tpStr := range rollingNameModesStringRepresentation { - if tpStr == rollingNameStr { - return tp, true - } - } - - return 0, false -} - -type rollingIntervalType uint8 - -const ( - rollingIntervalAny = iota - rollingIntervalDaily -) - -var rollingInvervalTypesStringRepresentation = map[rollingIntervalType]string{ - rollingIntervalDaily: "daily", -} - -func rollingIntervalTypeFromString(rollingTypeStr string) (rollingIntervalType, bool) { - for tp, tpStr := range rollingInvervalTypesStringRepresentation { - if tpStr == rollingTypeStr { - return tp, true - } - } - - return 0, false -} - -var rollingTypesStringRepresentation = map[rollingType]string{ - rollingTypeSize: "size", - rollingTypeTime: "date", -} - -func rollingTypeFromString(rollingTypeStr string) (rollingType, bool) { - for tp, tpStr := range rollingTypesStringRepresentation { - if tpStr == rollingTypeStr { - return tp, true - } - } - - return 0, false -} - -// Old logs archivation type. -type rollingArchiveType uint8 - -const ( - rollingArchiveNone = iota - rollingArchiveZip -) - -var rollingArchiveTypesStringRepresentation = map[rollingArchiveType]string{ - rollingArchiveNone: "none", - rollingArchiveZip: "zip", -} - -func rollingArchiveTypeFromString(rollingArchiveTypeStr string) (rollingArchiveType, bool) { - for tp, tpStr := range rollingArchiveTypesStringRepresentation { - if tpStr == rollingArchiveTypeStr { - return tp, true - } - } - - return 0, false -} - -// Default names for different archivation types -var rollingArchiveTypesDefaultNames = map[rollingArchiveType]string{ - rollingArchiveZip: "log.zip", -} - -// rollerVirtual is an interface that represents all virtual funcs that are -// called in different rolling writer subtypes. -type rollerVirtual interface { - needsToRoll() (bool, error) // Returns true if needs to switch to another file. - isFileRollNameValid(rname string) bool // Returns true if logger roll file name (postfix/prefix/etc.) is ok. - sortFileRollNamesAsc(fs []string) ([]string, error) // Sorts logger roll file names in ascending order of their creation by logger. - - // Creates a new froll history file using the contents of current file and special filename of the latest roll (prefix/ postfix). - // If lastRollName is empty (""), then it means that there is no latest roll (current is the first one) - getNewHistoryRollFileName(lastRollName string) string - getCurrentModifiedFileName(originalFileName string) string // Returns filename modified according to specific logger rules -} - -// rollingFileWriter writes received messages to a file, until time interval passes -// or file exceeds a specified limit. After that the current log file is renamed -// and writer starts to log into a new file. You can set a limit for such renamed -// files count, if you want, and then the rolling writer would delete older ones when -// the files count exceed the specified limit. -type rollingFileWriter struct { - fileName string // current file name. May differ from original in date rolling loggers - originalFileName string // original one - currentDirPath string - currentFile *os.File - currentFileSize int64 - rollingType rollingType // Rolling mode (Files roll by size/date/...) - archiveType rollingArchiveType - archivePath string - maxRolls int - nameMode rollingNameMode - self rollerVirtual // Used for virtual calls -} - -func newRollingFileWriter(fpath string, rtype rollingType, atype rollingArchiveType, apath string, maxr int, namemode rollingNameMode) (*rollingFileWriter, error) { - rw := new(rollingFileWriter) - rw.currentDirPath, rw.fileName = filepath.Split(fpath) - if len(rw.currentDirPath) == 0 { - rw.currentDirPath = "." - } - rw.originalFileName = rw.fileName - - rw.rollingType = rtype - rw.archiveType = atype - rw.archivePath = apath - rw.nameMode = namemode - rw.maxRolls = maxr - return rw, nil -} - -func (rw *rollingFileWriter) hasRollName(file string) bool { - switch rw.nameMode { - case rollingNameModePostfix: - rname := rw.originalFileName + rollingLogHistoryDelimiter - return strings.HasPrefix(file, rname) - case rollingNameModePrefix: - rname := rollingLogHistoryDelimiter + rw.originalFileName - return strings.HasSuffix(file, rname) - } - return false -} - -func (rw *rollingFileWriter) createFullFileName(originalName, rollname string) string { - switch rw.nameMode { - case rollingNameModePostfix: - return originalName + rollingLogHistoryDelimiter + rollname - case rollingNameModePrefix: - return rollname + rollingLogHistoryDelimiter + originalName - } - return "" -} - -func (rw *rollingFileWriter) getSortedLogHistory() ([]string, error) { - files, err := getDirFilePaths(rw.currentDirPath, nil, true) - if err != nil { - return nil, err - } - var validRollNames []string - for _, file := range files { - if file != rw.fileName && rw.hasRollName(file) { - rname := rw.getFileRollName(file) - if rw.self.isFileRollNameValid(rname) { - validRollNames = append(validRollNames, rname) - } - } - } - sortedTails, err := rw.self.sortFileRollNamesAsc(validRollNames) - if err != nil { - return nil, err - } - validSortedFiles := make([]string, len(sortedTails)) - for i, v := range sortedTails { - validSortedFiles[i] = rw.createFullFileName(rw.originalFileName, v) - } - return validSortedFiles, nil -} - -func (rw *rollingFileWriter) createFileAndFolderIfNeeded() error { - var err error - - if len(rw.currentDirPath) != 0 { - err = os.MkdirAll(rw.currentDirPath, defaultDirectoryPermissions) - - if err != nil { - return err - } - } - - rw.fileName = rw.self.getCurrentModifiedFileName(rw.originalFileName) - filePath := filepath.Join(rw.currentDirPath, rw.fileName) - - // If exists - stat, err := os.Lstat(filePath) - if err == nil { - rw.currentFile, err = os.OpenFile(filePath, os.O_WRONLY|os.O_APPEND, defaultFilePermissions) - - stat, err = os.Lstat(filePath) - if err != nil { - return err - } - - rw.currentFileSize = stat.Size() - } else { - rw.currentFile, err = os.Create(filePath) - rw.currentFileSize = 0 - } - if err != nil { - return err - } - - return nil -} - -func (rw *rollingFileWriter) deleteOldRolls(history []string) error { - if rw.maxRolls <= 0 { - return nil - } - - rollsToDelete := len(history) - rw.maxRolls - if rollsToDelete <= 0 { - return nil - } - - switch rw.archiveType { - case rollingArchiveZip: - var files map[string][]byte - - // If archive exists - _, err := os.Lstat(rw.archivePath) - if nil == err { - // Extract files and content from it - files, err = unzip(rw.archivePath) - if err != nil { - return err - } - - // Remove the original file - err = tryRemoveFile(rw.archivePath) - if err != nil { - return err - } - } else { - files = make(map[string][]byte) - } - - // Add files to the existing files map, filled above - for i := 0; i < rollsToDelete; i++ { - rollPath := filepath.Join(rw.currentDirPath, history[i]) - bts, err := ioutil.ReadFile(rollPath) - if err != nil { - return err - } - - files[rollPath] = bts - } - - // Put the final file set to zip file. - if err = createZip(rw.archivePath, files); err != nil { - return err - } - } - var err error - // In all cases (archive files or not) the files should be deleted. - for i := 0; i < rollsToDelete; i++ { - // Try best to delete files without breaking the loop. - if err = tryRemoveFile(filepath.Join(rw.currentDirPath, history[i])); err != nil { - reportInternalError(err) - } - } - - return nil -} - -func (rw *rollingFileWriter) getFileRollName(fileName string) string { - switch rw.nameMode { - case rollingNameModePostfix: - return fileName[len(rw.originalFileName+rollingLogHistoryDelimiter):] - case rollingNameModePrefix: - return fileName[:len(fileName)-len(rw.originalFileName+rollingLogHistoryDelimiter)] - } - return "" -} - -func (rw *rollingFileWriter) Write(bytes []byte) (n int, err error) { - if rw.currentFile == nil { - err := rw.createFileAndFolderIfNeeded() - if err != nil { - return 0, err - } - } - // needs to roll if: - // * file roller max file size exceeded OR - // * time roller interval passed - nr, err := rw.self.needsToRoll() - if err != nil { - return 0, err - } - if nr { - // First, close current file. - err = rw.currentFile.Close() - if err != nil { - return 0, err - } - // Current history of all previous log files. - // For file roller it may be like this: - // * ... - // * file.log.4 - // * file.log.5 - // * file.log.6 - // - // For date roller it may look like this: - // * ... - // * file.log.11.Aug.13 - // * file.log.15.Aug.13 - // * file.log.16.Aug.13 - // Sorted log history does NOT include current file. - history, err := rw.getSortedLogHistory() - if err != nil { - return 0, err - } - // Renames current file to create a new roll history entry - // For file roller it may be like this: - // * ... - // * file.log.4 - // * file.log.5 - // * file.log.6 - // n file.log.7 <---- RENAMED (from file.log) - // Time rollers that doesn't modify file names (e.g. 'date' roller) skip this logic. - var newHistoryName string - var newRollMarkerName string - if len(history) > 0 { - // Create new rname name using last history file name - newRollMarkerName = rw.self.getNewHistoryRollFileName(rw.getFileRollName(history[len(history)-1])) - } else { - // Create first rname name - newRollMarkerName = rw.self.getNewHistoryRollFileName("") - } - if len(newRollMarkerName) != 0 { - newHistoryName = rw.createFullFileName(rw.fileName, newRollMarkerName) - } else { - newHistoryName = rw.fileName - } - if newHistoryName != rw.fileName { - err = os.Rename(filepath.Join(rw.currentDirPath, rw.fileName), filepath.Join(rw.currentDirPath, newHistoryName)) - if err != nil { - return 0, err - } - } - // Finally, add the newly added history file to the history archive - // and, if after that the archive exceeds the allowed max limit, older rolls - // must the removed/archived. - history = append(history, newHistoryName) - if len(history) > rw.maxRolls { - err = rw.deleteOldRolls(history) - if err != nil { - return 0, err - } - } - - err = rw.createFileAndFolderIfNeeded() - if err != nil { - return 0, err - } - } - - rw.currentFileSize += int64(len(bytes)) - return rw.currentFile.Write(bytes) -} - -func (rw *rollingFileWriter) Close() error { - if rw.currentFile != nil { - e := rw.currentFile.Close() - if e != nil { - return e - } - rw.currentFile = nil - } - return nil -} - -// ============================================================================================= -// Different types of rolling writers -// ============================================================================================= - -// -------------------------------------------------- -// Rolling writer by SIZE -// -------------------------------------------------- - -// rollingFileWriterSize performs roll when file exceeds a specified limit. -type rollingFileWriterSize struct { - *rollingFileWriter - maxFileSize int64 -} - -func newRollingFileWriterSize(fpath string, atype rollingArchiveType, apath string, maxSize int64, maxRolls int, namemode rollingNameMode) (*rollingFileWriterSize, error) { - rw, err := newRollingFileWriter(fpath, rollingTypeSize, atype, apath, maxRolls, namemode) - if err != nil { - return nil, err - } - rws := &rollingFileWriterSize{rw, maxSize} - rws.self = rws - return rws, nil -} - -func (rws *rollingFileWriterSize) needsToRoll() (bool, error) { - return rws.currentFileSize >= rws.maxFileSize, nil -} - -func (rws *rollingFileWriterSize) isFileRollNameValid(rname string) bool { - if len(rname) == 0 { - return false - } - _, err := strconv.Atoi(rname) - return err == nil -} - -type rollSizeFileTailsSlice []string - -func (p rollSizeFileTailsSlice) Len() int { return len(p) } -func (p rollSizeFileTailsSlice) Less(i, j int) bool { - v1, _ := strconv.Atoi(p[i]) - v2, _ := strconv.Atoi(p[j]) - return v1 < v2 -} -func (p rollSizeFileTailsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } - -func (rws *rollingFileWriterSize) sortFileRollNamesAsc(fs []string) ([]string, error) { - ss := rollSizeFileTailsSlice(fs) - sort.Sort(ss) - return ss, nil -} - -func (rws *rollingFileWriterSize) getNewHistoryRollFileName(lastRollName string) string { - v := 0 - if len(lastRollName) != 0 { - v, _ = strconv.Atoi(lastRollName) - } - return fmt.Sprintf("%d", v+1) -} - -func (rws *rollingFileWriterSize) getCurrentModifiedFileName(originalFileName string) string { - return originalFileName -} - -func (rws *rollingFileWriterSize) String() string { - return fmt.Sprintf("Rolling file writer (By SIZE): filename: %s, archive: %s, archivefile: %s, maxFileSize: %v, maxRolls: %v", - rws.fileName, - rollingArchiveTypesStringRepresentation[rws.archiveType], - rws.archivePath, - rws.maxFileSize, - rws.maxRolls) -} - -// -------------------------------------------------- -// Rolling writer by TIME -// -------------------------------------------------- - -// rollingFileWriterTime performs roll when a specified time interval has passed. -type rollingFileWriterTime struct { - *rollingFileWriter - timePattern string - interval rollingIntervalType - currentTimeFileName string -} - -func newRollingFileWriterTime(fpath string, atype rollingArchiveType, apath string, maxr int, - timePattern string, interval rollingIntervalType, namemode rollingNameMode) (*rollingFileWriterTime, error) { - - rw, err := newRollingFileWriter(fpath, rollingTypeTime, atype, apath, maxr, namemode) - if err != nil { - return nil, err - } - rws := &rollingFileWriterTime{rw, timePattern, interval, ""} - rws.self = rws - return rws, nil -} - -func (rwt *rollingFileWriterTime) needsToRoll() (bool, error) { - switch rwt.nameMode { - case rollingNameModePostfix: - if rwt.originalFileName+rollingLogHistoryDelimiter+time.Now().Format(rwt.timePattern) == rwt.fileName { - return false, nil - } - case rollingNameModePrefix: - if time.Now().Format(rwt.timePattern)+rollingLogHistoryDelimiter+rwt.originalFileName == rwt.fileName { - return false, nil - } - } - if rwt.interval == rollingIntervalAny { - return true, nil - } - - tprev, err := time.ParseInLocation(rwt.timePattern, rwt.getFileRollName(rwt.fileName), time.Local) - if err != nil { - return false, err - } - - diff := time.Now().Sub(tprev) - switch rwt.interval { - case rollingIntervalDaily: - return diff >= 24*time.Hour, nil - } - return false, fmt.Errorf("unknown interval type: %d", rwt.interval) -} - -func (rwt *rollingFileWriterTime) isFileRollNameValid(rname string) bool { - if len(rname) == 0 { - return false - } - _, err := time.ParseInLocation(rwt.timePattern, rname, time.Local) - return err == nil -} - -type rollTimeFileTailsSlice struct { - data []string - pattern string -} - -func (p rollTimeFileTailsSlice) Len() int { return len(p.data) } - -func (p rollTimeFileTailsSlice) Less(i, j int) bool { - t1, _ := time.ParseInLocation(p.pattern, p.data[i], time.Local) - t2, _ := time.ParseInLocation(p.pattern, p.data[j], time.Local) - return t1.Before(t2) -} - -func (p rollTimeFileTailsSlice) Swap(i, j int) { p.data[i], p.data[j] = p.data[j], p.data[i] } - -func (rwt *rollingFileWriterTime) sortFileRollNamesAsc(fs []string) ([]string, error) { - ss := rollTimeFileTailsSlice{data: fs, pattern: rwt.timePattern} - sort.Sort(ss) - return ss.data, nil -} - -func (rwt *rollingFileWriterTime) getNewHistoryRollFileName(lastRollName string) string { - return "" -} - -func (rwt *rollingFileWriterTime) getCurrentModifiedFileName(originalFileName string) string { - switch rwt.nameMode { - case rollingNameModePostfix: - return originalFileName + rollingLogHistoryDelimiter + time.Now().Format(rwt.timePattern) - case rollingNameModePrefix: - return time.Now().Format(rwt.timePattern) + rollingLogHistoryDelimiter + originalFileName - } - return "" -} - -func (rwt *rollingFileWriterTime) String() string { - return fmt.Sprintf("Rolling file writer (By TIME): filename: %s, archive: %s, archivefile: %s, maxInterval: %v, pattern: %s, maxRolls: %v", - rwt.fileName, - rollingArchiveTypesStringRepresentation[rwt.archiveType], - rwt.archivePath, - rwt.interval, - rwt.timePattern, - rwt.maxRolls) -} diff --git a/vendor/github.com/cihub/seelog/writers_rollingfilewriter_test.go b/vendor/github.com/cihub/seelog/writers_rollingfilewriter_test.go deleted file mode 100644 index 338c3a410..000000000 --- a/vendor/github.com/cihub/seelog/writers_rollingfilewriter_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "fmt" - "io" - "testing" -) - -// fileWriterTestCase is declared in writers_filewriter_test.go - -func createRollingSizeFileWriterTestCase( - files []string, - fileName string, - fileSize int64, - maxRolls int, - writeCount int, - resFiles []string, - nameMode rollingNameMode) *fileWriterTestCase { - - return &fileWriterTestCase{files, fileName, rollingTypeSize, fileSize, maxRolls, "", writeCount, resFiles, nameMode} -} - -func createRollingDatefileWriterTestCase( - files []string, - fileName string, - datePattern string, - writeCount int, - resFiles []string, - nameMode rollingNameMode) *fileWriterTestCase { - - return &fileWriterTestCase{files, fileName, rollingTypeTime, 0, 0, datePattern, writeCount, resFiles, nameMode} -} - -func TestRollingFileWriter(t *testing.T) { - t.Logf("Starting rolling file writer tests") - newFileWriterTester(rollingfileWriterTests, rollingFileWriterGetter, t).test() -} - -//=============================================================== - -func rollingFileWriterGetter(testCase *fileWriterTestCase) (io.WriteCloser, error) { - if testCase.rollingType == rollingTypeSize { - return newRollingFileWriterSize(testCase.fileName, rollingArchiveNone, "", testCase.fileSize, testCase.maxRolls, testCase.nameMode) - } else if testCase.rollingType == rollingTypeTime { - return newRollingFileWriterTime(testCase.fileName, rollingArchiveNone, "", -1, testCase.datePattern, rollingIntervalDaily, testCase.nameMode) - } - - return nil, fmt.Errorf("incorrect rollingType") -} - -//=============================================================== -var rollingfileWriterTests = []*fileWriterTestCase{ - createRollingSizeFileWriterTestCase([]string{}, "log.testlog", 10, 10, 1, []string{"log.testlog"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, "log.testlog", 10, 10, 2, []string{"log.testlog", "log.testlog.1"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{"1.log.testlog"}, "log.testlog", 10, 10, 2, []string{"log.testlog", "1.log.testlog", "2.log.testlog"}, rollingNameModePrefix), - createRollingSizeFileWriterTestCase([]string{"log.testlog.1"}, "log.testlog", 10, 1, 2, []string{"log.testlog", "log.testlog.2"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, "log.testlog", 10, 1, 2, []string{"log.testlog", "log.testlog.1"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{"log.testlog.9"}, "log.testlog", 10, 1, 2, []string{"log.testlog", "log.testlog.10"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{"log.testlog.a", "log.testlog.1b"}, "log.testlog", 10, 1, 2, []string{"log.testlog", "log.testlog.1", "log.testlog.a", "log.testlog.1b"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, `dir/log.testlog`, 10, 10, 1, []string{`dir/log.testlog`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, `dir/log.testlog`, 10, 10, 2, []string{`dir/log.testlog`, `dir/1.log.testlog`}, rollingNameModePrefix), - createRollingSizeFileWriterTestCase([]string{`dir/dir/log.testlog.1`}, `dir/dir/log.testlog`, 10, 10, 2, []string{`dir/dir/log.testlog`, `dir/dir/log.testlog.1`, `dir/dir/log.testlog.2`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{`dir/dir/dir/log.testlog.1`}, `dir/dir/dir/log.testlog`, 10, 1, 2, []string{`dir/dir/dir/log.testlog`, `dir/dir/dir/log.testlog.2`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, `./log.testlog`, 10, 1, 2, []string{`log.testlog`, `log.testlog.1`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{`././././log.testlog.9`}, `log.testlog`, 10, 1, 2, []string{`log.testlog`, `log.testlog.10`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{"dir/dir/log.testlog.a", "dir/dir/log.testlog.1b"}, "dir/dir/log.testlog", 10, 1, 2, []string{"dir/dir/log.testlog", "dir/dir/log.testlog.1", "dir/dir/log.testlog.a", "dir/dir/log.testlog.1b"}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, `././dir/log.testlog`, 10, 10, 1, []string{`dir/log.testlog`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, `././dir/log.testlog`, 10, 10, 2, []string{`dir/log.testlog`, `dir/log.testlog.1`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{`././dir/dir/log.testlog.1`}, `dir/dir/log.testlog`, 10, 10, 2, []string{`dir/dir/log.testlog`, `dir/dir/log.testlog.1`, `dir/dir/log.testlog.2`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{`././dir/dir/dir/log.testlog.1`}, `dir/dir/dir/log.testlog`, 10, 1, 2, []string{`dir/dir/dir/log.testlog`, `dir/dir/dir/log.testlog.2`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{}, `././log.testlog`, 10, 1, 2, []string{`log.testlog`, `log.testlog.1`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{`././././log.testlog.9`}, `log.testlog`, 10, 1, 2, []string{`log.testlog`, `log.testlog.10`}, rollingNameModePostfix), - createRollingSizeFileWriterTestCase([]string{"././dir/dir/log.testlog.a", "././dir/dir/log.testlog.1b"}, "dir/dir/log.testlog", 10, 1, 2, []string{"dir/dir/log.testlog", "dir/dir/log.testlog.1", "dir/dir/log.testlog.a", "dir/dir/log.testlog.1b"}, rollingNameModePostfix), - // ==================== -} diff --git a/vendor/github.com/cihub/seelog/writers_smtpwriter.go b/vendor/github.com/cihub/seelog/writers_smtpwriter.go deleted file mode 100644 index d9de60795..000000000 --- a/vendor/github.com/cihub/seelog/writers_smtpwriter.go +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2012 - Cloud Instruments Co., Ltd. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package seelog - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "fmt" - "io/ioutil" - "net/smtp" - "path/filepath" - "strings" -) - -const ( - // Default subject phrase for sending emails. - DefaultSubjectPhrase = "Diagnostic message from server: " - - // Message subject pattern composed according to RFC 5321. - rfc5321SubjectPattern = "From: %s <%s>\nSubject: %s\n\n" -) - -// smtpWriter is used to send emails via given SMTP-server. -type smtpWriter struct { - auth smtp.Auth - hostName string - hostPort string - hostNameWithPort string - senderAddress string - senderName string - recipientAddresses []string - caCertDirPaths []string - mailHeaders []string - subject string -} - -// newSMTPWriter returns a new SMTP-writer. -func newSMTPWriter(sa, sn string, ras []string, hn, hp, un, pwd string, cacdps []string, subj string, headers []string) *smtpWriter { - return &smtpWriter{ - auth: smtp.PlainAuth("", un, pwd, hn), - hostName: hn, - hostPort: hp, - hostNameWithPort: fmt.Sprintf("%s:%s", hn, hp), - senderAddress: sa, - senderName: sn, - recipientAddresses: ras, - caCertDirPaths: cacdps, - subject: subj, - mailHeaders: headers, - } -} - -func prepareMessage(senderAddr, senderName, subject string, body []byte, headers []string) []byte { - headerLines := fmt.Sprintf(rfc5321SubjectPattern, senderName, senderAddr, subject) - // Build header lines if configured. - if headers != nil && len(headers) > 0 { - headerLines += strings.Join(headers, "\n") - headerLines += "\n" - } - return append([]byte(headerLines), body...) -} - -// getTLSConfig gets paths of PEM files with certificates, -// host server name and tries to create an appropriate TLS.Config. -func getTLSConfig(pemFileDirPaths []string, hostName string) (config *tls.Config, err error) { - if pemFileDirPaths == nil || len(pemFileDirPaths) == 0 { - err = errors.New("invalid PEM file paths") - return - } - pemEncodedContent := []byte{} - var ( - e error - bytes []byte - ) - // Create a file-filter-by-extension, set aside non-pem files. - pemFilePathFilter := func(fp string) bool { - if filepath.Ext(fp) == ".pem" { - return true - } - return false - } - for _, pemFileDirPath := range pemFileDirPaths { - pemFilePaths, err := getDirFilePaths(pemFileDirPath, pemFilePathFilter, false) - if err != nil { - return nil, err - } - - // Put together all the PEM files to decode them as a whole byte slice. - for _, pfp := range pemFilePaths { - if bytes, e = ioutil.ReadFile(pfp); e == nil { - pemEncodedContent = append(pemEncodedContent, bytes...) - } else { - return nil, fmt.Errorf("cannot read file: %s: %s", pfp, e.Error()) - } - } - } - config = &tls.Config{RootCAs: x509.NewCertPool(), ServerName: hostName} - isAppended := config.RootCAs.AppendCertsFromPEM(pemEncodedContent) - if !isAppended { - // Extract this into a separate error. - err = errors.New("invalid PEM content") - return - } - return -} - -// SendMail accepts TLS configuration, connects to the server at addr, -// switches to TLS if possible, authenticates with mechanism a if possible, -// and then sends an email from address from, to addresses to, with message msg. -func sendMailWithTLSConfig(config *tls.Config, addr string, a smtp.Auth, from string, to []string, msg []byte) error { - c, err := smtp.Dial(addr) - if err != nil { - return err - } - // Check if the server supports STARTTLS extension. - if ok, _ := c.Extension("STARTTLS"); ok { - if err = c.StartTLS(config); err != nil { - return err - } - } - // Check if the server supports AUTH extension and use given smtp.Auth. - if a != nil { - if isSupported, _ := c.Extension("AUTH"); isSupported { - if err = c.Auth(a); err != nil { - return err - } - } - } - // Portion of code from the official smtp.SendMail function, - // see http://golang.org/src/pkg/net/smtp/smtp.go. - if err = c.Mail(from); err != nil { - return err - } - for _, addr := range to { - if err = c.Rcpt(addr); err != nil { - return err - } - } - w, err := c.Data() - if err != nil { - return err - } - _, err = w.Write(msg) - if err != nil { - return err - } - err = w.Close() - if err != nil { - return err - } - return c.Quit() -} - -// Write pushes a text message properly composed according to RFC 5321 -// to a post server, which sends it to the recipients. -func (smtpw *smtpWriter) Write(data []byte) (int, error) { - var err error - - if smtpw.caCertDirPaths == nil { - err = smtp.SendMail( - smtpw.hostNameWithPort, - smtpw.auth, - smtpw.senderAddress, - smtpw.recipientAddresses, - prepareMessage(smtpw.senderAddress, smtpw.senderName, smtpw.subject, data, smtpw.mailHeaders), - ) - } else { - config, e := getTLSConfig(smtpw.caCertDirPaths, smtpw.hostName) - if e != nil { - return 0, e - } - err = sendMailWithTLSConfig( - config, - smtpw.hostNameWithPort, - smtpw.auth, - smtpw.senderAddress, - smtpw.recipientAddresses, - prepareMessage(smtpw.senderAddress, smtpw.senderName, smtpw.subject, data, smtpw.mailHeaders), - ) - } - if err != nil { - return 0, err - } - return len(data), nil -} - -// Close closes down SMTP-connection. -func (smtpw *smtpWriter) Close() error { - // Do nothing as Write method opens and closes connection automatically. - return nil -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/add_child.go b/vendor/github.com/coreos/go-etcd/etcd/add_child.go deleted file mode 100644 index 7122be049..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/add_child.go +++ /dev/null @@ -1,23 +0,0 @@ -package etcd - -// Add a new directory with a random etcd-generated key under the given path. -func (c *Client) AddChildDir(key string, ttl uint64) (*Response, error) { - raw, err := c.post(key, "", ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// Add a new file with a random etcd-generated key under the given path. -func (c *Client) AddChild(key string, value string, ttl uint64) (*Response, error) { - raw, err := c.post(key, value, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/add_child_test.go b/vendor/github.com/coreos/go-etcd/etcd/add_child_test.go deleted file mode 100644 index 26223ff1c..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/add_child_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package etcd - -import "testing" - -func TestAddChild(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("fooDir", true) - c.Delete("nonexistentDir", true) - }() - - c.CreateDir("fooDir", 5) - - _, err := c.AddChild("fooDir", "v0", 5) - if err != nil { - t.Fatal(err) - } - - _, err = c.AddChild("fooDir", "v1", 5) - if err != nil { - t.Fatal(err) - } - - resp, err := c.Get("fooDir", true, false) - // The child with v0 should proceed the child with v1 because it's added - // earlier, so it should have a lower key. - if !(len(resp.Node.Nodes) == 2 && (resp.Node.Nodes[0].Value == "v0" && resp.Node.Nodes[1].Value == "v1")) { - t.Fatalf("AddChild 1 failed. There should be two chlidren whose values are v0 and v1, respectively."+ - " The response was: %#v", resp) - } - - // Creating a child under a nonexistent directory should succeed. - // The directory should be created. - resp, err = c.AddChild("nonexistentDir", "foo", 5) - if err != nil { - t.Fatal(err) - } -} - -func TestAddChildDir(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("fooDir", true) - c.Delete("nonexistentDir", true) - }() - - c.CreateDir("fooDir", 5) - - _, err := c.AddChildDir("fooDir", 5) - if err != nil { - t.Fatal(err) - } - - _, err = c.AddChildDir("fooDir", 5) - if err != nil { - t.Fatal(err) - } - - resp, err := c.Get("fooDir", true, false) - // The child with v0 should proceed the child with v1 because it's added - // earlier, so it should have a lower key. - if !(len(resp.Node.Nodes) == 2 && (len(resp.Node.Nodes[0].Nodes) == 0 && len(resp.Node.Nodes[1].Nodes) == 0)) { - t.Fatalf("AddChildDir 1 failed. There should be two chlidren whose values are v0 and v1, respectively."+ - " The response was: %#v", resp) - } - - // Creating a child under a nonexistent directory should succeed. - // The directory should be created. - resp, err = c.AddChildDir("nonexistentDir", 5) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/client.go b/vendor/github.com/coreos/go-etcd/etcd/client.go deleted file mode 100644 index 7abcf11a2..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/client.go +++ /dev/null @@ -1,429 +0,0 @@ -package etcd - -import ( - "crypto/tls" - "crypto/x509" - "encoding/json" - "errors" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "os" - "path" - "time" -) - -// See SetConsistency for how to use these constants. -const ( - // Using strings rather than iota because the consistency level - // could be persisted to disk, so it'd be better to use - // human-readable values. - STRONG_CONSISTENCY = "STRONG" - WEAK_CONSISTENCY = "WEAK" -) - -const ( - defaultBufferSize = 10 -) - -type Config struct { - CertFile string `json:"certFile"` - KeyFile string `json:"keyFile"` - CaCertFile []string `json:"caCertFiles"` - Timeout time.Duration `json:"timeout"` - Consistency string `json: "consistency"` -} - -type Client struct { - config Config `json:"config"` - cluster *Cluster `json:"cluster"` - httpClient *http.Client - persistence io.Writer - cURLch chan string - // CheckRetry can be used to control the policy for failed requests - // and modify the cluster if needed. - // The client calls it before sending requests again, and - // stops retrying if CheckRetry returns some error. The cases that - // this function needs to handle include no response and unexpected - // http status code of response. - // If CheckRetry is nil, client will call the default one - // `DefaultCheckRetry`. - // Argument cluster is the etcd.Cluster object that these requests have been made on. - // Argument reqs is all of the http.Requests that have been made so far. - // Argument resps is all of the http.Responses from these requests. - // Argument err is the reason of the failure. - CheckRetry func(cluster *Cluster, reqs []http.Request, - resps []http.Response, err error) error -} - -// NewClient create a basic client that is configured to be used -// with the given machine list. -func NewClient(machines []string) *Client { - config := Config{ - // default timeout is one second - Timeout: time.Second, - // default consistency level is STRONG - Consistency: STRONG_CONSISTENCY, - } - - client := &Client{ - cluster: NewCluster(machines), - config: config, - } - - client.initHTTPClient() - client.saveConfig() - - return client -} - -// NewTLSClient create a basic client with TLS configuration -func NewTLSClient(machines []string, cert, key, caCert string) (*Client, error) { - // overwrite the default machine to use https - if len(machines) == 0 { - machines = []string{"https://127.0.0.1:4001"} - } - - config := Config{ - // default timeout is one second - Timeout: time.Second, - // default consistency level is STRONG - Consistency: STRONG_CONSISTENCY, - CertFile: cert, - KeyFile: key, - CaCertFile: make([]string, 0), - } - - client := &Client{ - cluster: NewCluster(machines), - config: config, - } - - err := client.initHTTPSClient(cert, key) - if err != nil { - return nil, err - } - - err = client.AddRootCA(caCert) - - client.saveConfig() - - return client, nil -} - -// NewClientFromFile creates a client from a given file path. -// The given file is expected to use the JSON format. -func NewClientFromFile(fpath string) (*Client, error) { - fi, err := os.Open(fpath) - if err != nil { - return nil, err - } - - defer func() { - if err := fi.Close(); err != nil { - panic(err) - } - }() - - return NewClientFromReader(fi) -} - -// NewClientFromReader creates a Client configured from a given reader. -// The configuration is expected to use the JSON format. -func NewClientFromReader(reader io.Reader) (*Client, error) { - c := new(Client) - - b, err := ioutil.ReadAll(reader) - if err != nil { - return nil, err - } - - err = json.Unmarshal(b, c) - if err != nil { - return nil, err - } - if c.config.CertFile == "" { - c.initHTTPClient() - } else { - err = c.initHTTPSClient(c.config.CertFile, c.config.KeyFile) - } - - if err != nil { - return nil, err - } - - for _, caCert := range c.config.CaCertFile { - if err := c.AddRootCA(caCert); err != nil { - return nil, err - } - } - - return c, nil -} - -// Override the Client's HTTP Transport object -func (c *Client) SetTransport(tr *http.Transport) { - c.httpClient.Transport = tr -} - -// initHTTPClient initializes a HTTP client for etcd client -func (c *Client) initHTTPClient() { - tr := &http.Transport{ - Dial: dialTimeout, - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - } - c.httpClient = &http.Client{Transport: tr} -} - -// initHTTPClient initializes a HTTPS client for etcd client -func (c *Client) initHTTPSClient(cert, key string) error { - if cert == "" || key == "" { - return errors.New("Require both cert and key path") - } - - tlsCert, err := tls.LoadX509KeyPair(cert, key) - if err != nil { - return err - } - - tlsConfig := &tls.Config{ - Certificates: []tls.Certificate{tlsCert}, - InsecureSkipVerify: true, - } - - tr := &http.Transport{ - TLSClientConfig: tlsConfig, - Dial: dialTimeout, - } - - c.httpClient = &http.Client{Transport: tr} - return nil -} - -// SetPersistence sets a writer to which the config will be -// written every time it's changed. -func (c *Client) SetPersistence(writer io.Writer) { - c.persistence = writer -} - -// SetConsistency changes the consistency level of the client. -// -// When consistency is set to STRONG_CONSISTENCY, all requests, -// including GET, are sent to the leader. This means that, assuming -// the absence of leader failures, GET requests are guaranteed to see -// the changes made by previous requests. -// -// When consistency is set to WEAK_CONSISTENCY, other requests -// are still sent to the leader, but GET requests are sent to a -// random server from the server pool. This reduces the read -// load on the leader, but it's not guaranteed that the GET requests -// will see changes made by previous requests (they might have not -// yet been committed on non-leader servers). -func (c *Client) SetConsistency(consistency string) error { - if !(consistency == STRONG_CONSISTENCY || consistency == WEAK_CONSISTENCY) { - return errors.New("The argument must be either STRONG_CONSISTENCY or WEAK_CONSISTENCY.") - } - c.config.Consistency = consistency - return nil -} - -// AddRootCA adds a root CA cert for the etcd client -func (c *Client) AddRootCA(caCert string) error { - if c.httpClient == nil { - return errors.New("Client has not been initialized yet!") - } - - certBytes, err := ioutil.ReadFile(caCert) - if err != nil { - return err - } - - tr, ok := c.httpClient.Transport.(*http.Transport) - - if !ok { - panic("AddRootCA(): Transport type assert should not fail") - } - - if tr.TLSClientConfig.RootCAs == nil { - caCertPool := x509.NewCertPool() - ok = caCertPool.AppendCertsFromPEM(certBytes) - if ok { - tr.TLSClientConfig.RootCAs = caCertPool - } - tr.TLSClientConfig.InsecureSkipVerify = false - } else { - ok = tr.TLSClientConfig.RootCAs.AppendCertsFromPEM(certBytes) - } - - if !ok { - err = errors.New("Unable to load caCert") - } - - c.config.CaCertFile = append(c.config.CaCertFile, caCert) - c.saveConfig() - - return err -} - -// SetCluster updates cluster information using the given machine list. -func (c *Client) SetCluster(machines []string) bool { - success := c.internalSyncCluster(machines) - return success -} - -func (c *Client) GetCluster() []string { - return c.cluster.Machines -} - -// SyncCluster updates the cluster information using the internal machine list. -func (c *Client) SyncCluster() bool { - return c.internalSyncCluster(c.cluster.Machines) -} - -// internalSyncCluster syncs cluster information using the given machine list. -func (c *Client) internalSyncCluster(machines []string) bool { - for _, machine := range machines { - httpPath := c.createHttpPath(machine, path.Join(version, "machines")) - resp, err := c.httpClient.Get(httpPath) - if err != nil { - // try another machine in the cluster - continue - } else { - b, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - if err != nil { - // try another machine in the cluster - continue - } - - // update Machines List - c.cluster.updateFromStr(string(b)) - - // update leader - // the first one in the machine list is the leader - c.cluster.switchLeader(0) - - logger.Debug("sync.machines ", c.cluster.Machines) - c.saveConfig() - return true - } - } - return false -} - -// createHttpPath creates a complete HTTP URL. -// serverName should contain both the host name and a port number, if any. -func (c *Client) createHttpPath(serverName string, _path string) string { - u, err := url.Parse(serverName) - if err != nil { - panic(err) - } - - u.Path = path.Join(u.Path, _path) - - if u.Scheme == "" { - u.Scheme = "http" - } - return u.String() -} - -// Dial with timeout. -func dialTimeout(network, addr string) (net.Conn, error) { - tcpAddr, err := net.ResolveTCPAddr(network, addr) - if err != nil { - return nil, err - } - - tcpConn, err := net.DialTCP(network, nil, tcpAddr) - if err != nil { - return nil, err - } - - // Keep TCP alive to check whether or not the remote machine is down - if err = tcpConn.SetKeepAlive(true); err != nil { - return nil, err - } - - if err = tcpConn.SetKeepAlivePeriod(time.Second); err != nil { - return nil, err - } - - return tcpConn, nil -} - -func (c *Client) OpenCURL() { - c.cURLch = make(chan string, defaultBufferSize) -} - -func (c *Client) CloseCURL() { - c.cURLch = nil -} - -func (c *Client) sendCURL(command string) { - go func() { - select { - case c.cURLch <- command: - default: - } - }() -} - -func (c *Client) RecvCURL() string { - return <-c.cURLch -} - -// saveConfig saves the current config using c.persistence. -func (c *Client) saveConfig() error { - if c.persistence != nil { - b, err := json.Marshal(c) - if err != nil { - return err - } - - _, err = c.persistence.Write(b) - if err != nil { - return err - } - } - - return nil -} - -// MarshalJSON implements the Marshaller interface -// as defined by the standard JSON package. -func (c *Client) MarshalJSON() ([]byte, error) { - b, err := json.Marshal(struct { - Config Config `json:"config"` - Cluster *Cluster `json:"cluster"` - }{ - Config: c.config, - Cluster: c.cluster, - }) - - if err != nil { - return nil, err - } - - return b, nil -} - -// UnmarshalJSON implements the Unmarshaller interface -// as defined by the standard JSON package. -func (c *Client) UnmarshalJSON(b []byte) error { - temp := struct { - Config Config `json: "config"` - Cluster *Cluster `json: "cluster"` - }{} - err := json.Unmarshal(b, &temp) - if err != nil { - return err - } - - c.cluster = temp.Cluster - c.config = temp.Config - return nil -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/client_test.go b/vendor/github.com/coreos/go-etcd/etcd/client_test.go deleted file mode 100644 index c245e4798..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/client_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package etcd - -import ( - "encoding/json" - "fmt" - "net" - "net/url" - "os" - "testing" -) - -// To pass this test, we need to create a cluster of 3 machines -// The server should be listening on 127.0.0.1:4001, 4002, 4003 -func TestSync(t *testing.T) { - fmt.Println("Make sure there are three nodes at 0.0.0.0:4001-4003") - - // Explicit trailing slash to ensure this doesn't reproduce: - // https://github.com/coreos/go-etcd/issues/82 - c := NewClient([]string{"http://127.0.0.1:4001/"}) - - success := c.SyncCluster() - if !success { - t.Fatal("cannot sync machines") - } - - for _, m := range c.GetCluster() { - u, err := url.Parse(m) - if err != nil { - t.Fatal(err) - } - if u.Scheme != "http" { - t.Fatal("scheme must be http") - } - - host, _, err := net.SplitHostPort(u.Host) - if err != nil { - t.Fatal(err) - } - if host != "127.0.0.1" { - t.Fatal("Host must be 127.0.0.1") - } - } - - badMachines := []string{"abc", "edef"} - - success = c.SetCluster(badMachines) - - if success { - t.Fatal("should not sync on bad machines") - } - - goodMachines := []string{"127.0.0.1:4002"} - - success = c.SetCluster(goodMachines) - - if !success { - t.Fatal("cannot sync machines") - } else { - fmt.Println(c.cluster.Machines) - } - -} - -func TestPersistence(t *testing.T) { - c := NewClient(nil) - c.SyncCluster() - - fo, err := os.Create("config.json") - if err != nil { - t.Fatal(err) - } - defer func() { - if err := fo.Close(); err != nil { - panic(err) - } - }() - - c.SetPersistence(fo) - err = c.saveConfig() - if err != nil { - t.Fatal(err) - } - - c2, err := NewClientFromFile("config.json") - if err != nil { - t.Fatal(err) - } - - // Verify that the two clients have the same config - b1, _ := json.Marshal(c) - b2, _ := json.Marshal(c2) - - if string(b1) != string(b2) { - t.Fatalf("The two configs should be equal!") - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/cluster.go b/vendor/github.com/coreos/go-etcd/etcd/cluster.go deleted file mode 100644 index aaa20546e..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/cluster.go +++ /dev/null @@ -1,51 +0,0 @@ -package etcd - -import ( - "net/url" - "strings" -) - -type Cluster struct { - Leader string `json:"leader"` - Machines []string `json:"machines"` -} - -func NewCluster(machines []string) *Cluster { - // if an empty slice was sent in then just assume HTTP 4001 on localhost - if len(machines) == 0 { - machines = []string{"http://127.0.0.1:4001"} - } - - // default leader and machines - return &Cluster{ - Leader: machines[0], - Machines: machines, - } -} - -// switchLeader switch the current leader to machines[num] -func (cl *Cluster) switchLeader(num int) { - logger.Debugf("switch.leader[from %v to %v]", - cl.Leader, cl.Machines[num]) - - cl.Leader = cl.Machines[num] -} - -func (cl *Cluster) updateFromStr(machines string) { - cl.Machines = strings.Split(machines, ", ") -} - -func (cl *Cluster) updateLeader(leader string) { - logger.Debugf("update.leader[%s,%s]", cl.Leader, leader) - cl.Leader = leader -} - -func (cl *Cluster) updateLeaderFromURL(u *url.URL) { - var leader string - if u.Scheme == "" { - leader = "http://" + u.Host - } else { - leader = u.Scheme + "://" + u.Host - } - cl.updateLeader(leader) -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go b/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go deleted file mode 100644 index 11131bb76..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go +++ /dev/null @@ -1,34 +0,0 @@ -package etcd - -import "fmt" - -func (c *Client) CompareAndDelete(key string, prevValue string, prevIndex uint64) (*Response, error) { - raw, err := c.RawCompareAndDelete(key, prevValue, prevIndex) - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -func (c *Client) RawCompareAndDelete(key string, prevValue string, prevIndex uint64) (*RawResponse, error) { - if prevValue == "" && prevIndex == 0 { - return nil, fmt.Errorf("You must give either prevValue or prevIndex.") - } - - options := Options{} - if prevValue != "" { - options["prevValue"] = prevValue - } - if prevIndex != 0 { - options["prevIndex"] = prevIndex - } - - raw, err := c.delete(key, options) - - if err != nil { - return nil, err - } - - return raw, err -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete_test.go b/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete_test.go deleted file mode 100644 index 223e50f29..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package etcd - -import ( - "testing" -) - -func TestCompareAndDelete(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - }() - - c.Set("foo", "bar", 5) - - // This should succeed an correct prevValue - resp, err := c.CompareAndDelete("foo", "bar", 0) - if err != nil { - t.Fatal(err) - } - if !(resp.PrevNode.Value == "bar" && resp.PrevNode.Key == "/foo" && resp.PrevNode.TTL == 5) { - t.Fatalf("CompareAndDelete 1 prevNode failed: %#v", resp) - } - - resp, _ = c.Set("foo", "bar", 5) - // This should fail because it gives an incorrect prevValue - _, err = c.CompareAndDelete("foo", "xxx", 0) - if err == nil { - t.Fatalf("CompareAndDelete 2 should have failed. The response is: %#v", resp) - } - - // This should succeed because it gives an correct prevIndex - resp, err = c.CompareAndDelete("foo", "", resp.Node.ModifiedIndex) - if err != nil { - t.Fatal(err) - } - if !(resp.PrevNode.Value == "bar" && resp.PrevNode.Key == "/foo" && resp.PrevNode.TTL == 5) { - t.Fatalf("CompareAndSwap 3 prevNode failed: %#v", resp) - } - - c.Set("foo", "bar", 5) - // This should fail because it gives an incorrect prevIndex - resp, err = c.CompareAndDelete("foo", "", 29817514) - if err == nil { - t.Fatalf("CompareAndDelete 4 should have failed. The response is: %#v", resp) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go b/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go deleted file mode 100644 index bb4f90643..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go +++ /dev/null @@ -1,36 +0,0 @@ -package etcd - -import "fmt" - -func (c *Client) CompareAndSwap(key string, value string, ttl uint64, - prevValue string, prevIndex uint64) (*Response, error) { - raw, err := c.RawCompareAndSwap(key, value, ttl, prevValue, prevIndex) - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -func (c *Client) RawCompareAndSwap(key string, value string, ttl uint64, - prevValue string, prevIndex uint64) (*RawResponse, error) { - if prevValue == "" && prevIndex == 0 { - return nil, fmt.Errorf("You must give either prevValue or prevIndex.") - } - - options := Options{} - if prevValue != "" { - options["prevValue"] = prevValue - } - if prevIndex != 0 { - options["prevIndex"] = prevIndex - } - - raw, err := c.put(key, value, ttl, options) - - if err != nil { - return nil, err - } - - return raw, err -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap_test.go b/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap_test.go deleted file mode 100644 index 14a1b00f5..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package etcd - -import ( - "testing" -) - -func TestCompareAndSwap(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - }() - - c.Set("foo", "bar", 5) - - // This should succeed - resp, err := c.CompareAndSwap("foo", "bar2", 5, "bar", 0) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Value == "bar2" && resp.Node.Key == "/foo" && resp.Node.TTL == 5) { - t.Fatalf("CompareAndSwap 1 failed: %#v", resp) - } - - if !(resp.PrevNode.Value == "bar" && resp.PrevNode.Key == "/foo" && resp.PrevNode.TTL == 5) { - t.Fatalf("CompareAndSwap 1 prevNode failed: %#v", resp) - } - - // This should fail because it gives an incorrect prevValue - resp, err = c.CompareAndSwap("foo", "bar3", 5, "xxx", 0) - if err == nil { - t.Fatalf("CompareAndSwap 2 should have failed. The response is: %#v", resp) - } - - resp, err = c.Set("foo", "bar", 5) - if err != nil { - t.Fatal(err) - } - - // This should succeed - resp, err = c.CompareAndSwap("foo", "bar2", 5, "", resp.Node.ModifiedIndex) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Value == "bar2" && resp.Node.Key == "/foo" && resp.Node.TTL == 5) { - t.Fatalf("CompareAndSwap 3 failed: %#v", resp) - } - - if !(resp.PrevNode.Value == "bar" && resp.PrevNode.Key == "/foo" && resp.PrevNode.TTL == 5) { - t.Fatalf("CompareAndSwap 3 prevNode failed: %#v", resp) - } - - // This should fail because it gives an incorrect prevIndex - resp, err = c.CompareAndSwap("foo", "bar3", 5, "", 29817514) - if err == nil { - t.Fatalf("CompareAndSwap 4 should have failed. The response is: %#v", resp) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/config.json b/vendor/github.com/coreos/go-etcd/etcd/config.json deleted file mode 100644 index 4d090a535..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/config.json +++ /dev/null @@ -1 +0,0 @@ -{"config":{"certFile":"","keyFile":"","scheme":"http","timeout":1000000000,"Consistency":"STRONG"},"cluster":{"leader":"http://127.0.0.1:4001","machines":["http://127.0.0.1:4001"]}} \ No newline at end of file diff --git a/vendor/github.com/coreos/go-etcd/etcd/debug.go b/vendor/github.com/coreos/go-etcd/etcd/debug.go deleted file mode 100644 index d170547eb..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/debug.go +++ /dev/null @@ -1,54 +0,0 @@ -package etcd - -import ( - "io/ioutil" - "log" - "strings" -) - -var logger *etcdLogger - -func SetLogger(l *log.Logger) { - logger = &etcdLogger{l} -} - -func GetLogger() *log.Logger { - return logger.log -} - -type etcdLogger struct { - log *log.Logger -} - -func (p *etcdLogger) Debug(args ...interface{}) { - args[0] = "DEBUG: " + args[0].(string) - p.log.Println(args) -} - -func (p *etcdLogger) Debugf(fmt string, args ...interface{}) { - args[0] = "DEBUG: " + args[0].(string) - // Append newline if necessary - if !strings.HasSuffix(fmt, "\n") { - fmt = fmt + "\n" - } - p.log.Printf(fmt, args) -} - -func (p *etcdLogger) Warning(args ...interface{}) { - args[0] = "WARNING: " + args[0].(string) - p.log.Println(args) -} - -func (p *etcdLogger) Warningf(fmt string, args ...interface{}) { - // Append newline if necessary - if !strings.HasSuffix(fmt, "\n") { - fmt = fmt + "\n" - } - args[0] = "WARNING: " + args[0].(string) - p.log.Printf(fmt, args) -} - -func init() { - // Default logger uses the go default log. - SetLogger(log.New(ioutil.Discard, "go-etcd", log.LstdFlags)) -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/delete.go b/vendor/github.com/coreos/go-etcd/etcd/delete.go deleted file mode 100644 index b37accd7d..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/delete.go +++ /dev/null @@ -1,40 +0,0 @@ -package etcd - -// Delete deletes the given key. -// -// When recursive set to false, if the key points to a -// directory the method will fail. -// -// When recursive set to true, if the key points to a file, -// the file will be deleted; if the key points to a directory, -// then everything under the directory (including all child directories) -// will be deleted. -func (c *Client) Delete(key string, recursive bool) (*Response, error) { - raw, err := c.RawDelete(key, recursive, false) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// DeleteDir deletes an empty directory or a key value pair -func (c *Client) DeleteDir(key string) (*Response, error) { - raw, err := c.RawDelete(key, false, true) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -func (c *Client) RawDelete(key string, recursive bool, dir bool) (*RawResponse, error) { - ops := Options{ - "recursive": recursive, - "dir": dir, - } - - return c.delete(key, ops) -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/delete_test.go b/vendor/github.com/coreos/go-etcd/etcd/delete_test.go deleted file mode 100644 index 590497155..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/delete_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package etcd - -import ( - "testing" -) - -func TestDelete(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - }() - - c.Set("foo", "bar", 5) - resp, err := c.Delete("foo", false) - if err != nil { - t.Fatal(err) - } - - if !(resp.Node.Value == "") { - t.Fatalf("Delete failed with %s", resp.Node.Value) - } - - if !(resp.PrevNode.Value == "bar") { - t.Fatalf("Delete PrevNode failed with %s", resp.Node.Value) - } - - resp, err = c.Delete("foo", false) - if err == nil { - t.Fatalf("Delete should have failed because the key foo did not exist. "+ - "The response was: %v", resp) - } -} - -func TestDeleteAll(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - c.Delete("fooDir", true) - }() - - c.SetDir("foo", 5) - // test delete an empty dir - resp, err := c.DeleteDir("foo") - if err != nil { - t.Fatal(err) - } - - if !(resp.Node.Value == "") { - t.Fatalf("DeleteAll 1 failed: %#v", resp) - } - - if !(resp.PrevNode.Dir == true && resp.PrevNode.Value == "") { - t.Fatalf("DeleteAll 1 PrevNode failed: %#v", resp) - } - - c.CreateDir("fooDir", 5) - c.Set("fooDir/foo", "bar", 5) - _, err = c.DeleteDir("fooDir") - if err == nil { - t.Fatal("should not able to delete a non-empty dir with deletedir") - } - - resp, err = c.Delete("fooDir", true) - if err != nil { - t.Fatal(err) - } - - if !(resp.Node.Value == "") { - t.Fatalf("DeleteAll 2 failed: %#v", resp) - } - - if !(resp.PrevNode.Dir == true && resp.PrevNode.Value == "") { - t.Fatalf("DeleteAll 2 PrevNode failed: %#v", resp) - } - - resp, err = c.Delete("foo", true) - if err == nil { - t.Fatalf("DeleteAll should have failed because the key foo did not exist. "+ - "The response was: %v", resp) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/error.go b/vendor/github.com/coreos/go-etcd/etcd/error.go deleted file mode 100644 index 7e6928724..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/error.go +++ /dev/null @@ -1,48 +0,0 @@ -package etcd - -import ( - "encoding/json" - "fmt" -) - -const ( - ErrCodeEtcdNotReachable = 501 -) - -var ( - errorMap = map[int]string{ - ErrCodeEtcdNotReachable: "All the given peers are not reachable", - } -) - -type EtcdError struct { - ErrorCode int `json:"errorCode"` - Message string `json:"message"` - Cause string `json:"cause,omitempty"` - Index uint64 `json:"index"` -} - -func (e EtcdError) Error() string { - return fmt.Sprintf("%v: %v (%v) [%v]", e.ErrorCode, e.Message, e.Cause, e.Index) -} - -func newError(errorCode int, cause string, index uint64) *EtcdError { - return &EtcdError{ - ErrorCode: errorCode, - Message: errorMap[errorCode], - Cause: cause, - Index: index, - } -} - -func handleError(b []byte) error { - etcdErr := new(EtcdError) - - err := json.Unmarshal(b, etcdErr) - if err != nil { - logger.Warningf("cannot unmarshal etcd error: %v", err) - return err - } - - return etcdErr -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/get.go b/vendor/github.com/coreos/go-etcd/etcd/get.go deleted file mode 100644 index 976bf07fd..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/get.go +++ /dev/null @@ -1,27 +0,0 @@ -package etcd - -// Get gets the file or directory associated with the given key. -// If the key points to a directory, files and directories under -// it will be returned in sorted or unsorted order, depending on -// the sort flag. -// If recursive is set to false, contents under child directories -// will not be returned. -// If recursive is set to true, all the contents will be returned. -func (c *Client) Get(key string, sort, recursive bool) (*Response, error) { - raw, err := c.RawGet(key, sort, recursive) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -func (c *Client) RawGet(key string, sort, recursive bool) (*RawResponse, error) { - ops := Options{ - "recursive": recursive, - "sorted": sort, - } - - return c.get(key, ops) -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/get_test.go b/vendor/github.com/coreos/go-etcd/etcd/get_test.go deleted file mode 100644 index eccae1894..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/get_test.go +++ /dev/null @@ -1,131 +0,0 @@ -package etcd - -import ( - "reflect" - "testing" -) - -// cleanNode scrubs Expiration, ModifiedIndex and CreatedIndex of a node. -func cleanNode(n *Node) { - n.Expiration = nil - n.ModifiedIndex = 0 - n.CreatedIndex = 0 -} - -// cleanResult scrubs a result object two levels deep of Expiration, -// ModifiedIndex and CreatedIndex. -func cleanResult(result *Response) { - // TODO(philips): make this recursive. - cleanNode(result.Node) - for i, _ := range result.Node.Nodes { - cleanNode(&result.Node.Nodes[i]) - for j, _ := range result.Node.Nodes[i].Nodes { - cleanNode(&result.Node.Nodes[i].Nodes[j]) - } - } -} - -func TestGet(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - }() - - c.Set("foo", "bar", 5) - - result, err := c.Get("foo", false, false) - - if err != nil { - t.Fatal(err) - } - - if result.Node.Key != "/foo" || result.Node.Value != "bar" { - t.Fatalf("Get failed with %s %s %v", result.Node.Key, result.Node.Value, result.Node.TTL) - } - - result, err = c.Get("goo", false, false) - if err == nil { - t.Fatalf("should not be able to get non-exist key") - } -} - -func TestGetAll(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("fooDir", true) - }() - - c.CreateDir("fooDir", 5) - c.Set("fooDir/k0", "v0", 5) - c.Set("fooDir/k1", "v1", 5) - - // Return kv-pairs in sorted order - result, err := c.Get("fooDir", true, false) - - if err != nil { - t.Fatal(err) - } - - expected := Nodes{ - Node{ - Key: "/fooDir/k0", - Value: "v0", - TTL: 5, - }, - Node{ - Key: "/fooDir/k1", - Value: "v1", - TTL: 5, - }, - } - - cleanResult(result) - - if !reflect.DeepEqual(result.Node.Nodes, expected) { - t.Fatalf("(actual) %v != (expected) %v", result.Node.Nodes, expected) - } - - // Test the `recursive` option - c.CreateDir("fooDir/childDir", 5) - c.Set("fooDir/childDir/k2", "v2", 5) - - // Return kv-pairs in sorted order - result, err = c.Get("fooDir", true, true) - - cleanResult(result) - - if err != nil { - t.Fatal(err) - } - - expected = Nodes{ - Node{ - Key: "/fooDir/childDir", - Dir: true, - Nodes: Nodes{ - Node{ - Key: "/fooDir/childDir/k2", - Value: "v2", - TTL: 5, - }, - }, - TTL: 5, - }, - Node{ - Key: "/fooDir/k0", - Value: "v0", - TTL: 5, - }, - Node{ - Key: "/fooDir/k1", - Value: "v1", - TTL: 5, - }, - } - - cleanResult(result) - - if !reflect.DeepEqual(result.Node.Nodes, expected) { - t.Fatalf("(actual) %v != (expected) %v", result.Node.Nodes, expected) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/options.go b/vendor/github.com/coreos/go-etcd/etcd/options.go deleted file mode 100644 index 701c9b35b..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/options.go +++ /dev/null @@ -1,72 +0,0 @@ -package etcd - -import ( - "fmt" - "net/url" - "reflect" -) - -type Options map[string]interface{} - -// An internally-used data structure that represents a mapping -// between valid options and their kinds -type validOptions map[string]reflect.Kind - -// Valid options for GET, PUT, POST, DELETE -// Using CAPITALIZED_UNDERSCORE to emphasize that these -// values are meant to be used as constants. -var ( - VALID_GET_OPTIONS = validOptions{ - "recursive": reflect.Bool, - "consistent": reflect.Bool, - "sorted": reflect.Bool, - "wait": reflect.Bool, - "waitIndex": reflect.Uint64, - } - - VALID_PUT_OPTIONS = validOptions{ - "prevValue": reflect.String, - "prevIndex": reflect.Uint64, - "prevExist": reflect.Bool, - "dir": reflect.Bool, - } - - VALID_POST_OPTIONS = validOptions{} - - VALID_DELETE_OPTIONS = validOptions{ - "recursive": reflect.Bool, - "dir": reflect.Bool, - "prevValue": reflect.String, - "prevIndex": reflect.Uint64, - } -) - -// Convert options to a string of HTML parameters -func (ops Options) toParameters(validOps validOptions) (string, error) { - p := "?" - values := url.Values{} - - if ops == nil { - return "", nil - } - - for k, v := range ops { - // Check if the given option is valid (that it exists) - kind := validOps[k] - if kind == reflect.Invalid { - return "", fmt.Errorf("Invalid option: %v", k) - } - - // Check if the given option is of the valid type - t := reflect.TypeOf(v) - if kind != t.Kind() { - return "", fmt.Errorf("Option %s should be of %v kind, not of %v kind.", - k, kind, t.Kind()) - } - - values.Set(k, fmt.Sprintf("%v", v)) - } - - p += values.Encode() - return p, nil -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/requests.go b/vendor/github.com/coreos/go-etcd/etcd/requests.go deleted file mode 100644 index ab71925d3..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/requests.go +++ /dev/null @@ -1,361 +0,0 @@ -package etcd - -import ( - "errors" - "fmt" - "io/ioutil" - "math/rand" - "net/http" - "net/url" - "path" - "strings" - "sync" - "time" -) - -// Errors introduced by handling requests -var ( - ErrRequestCancelled = errors.New("sending request is cancelled") -) - -type RawRequest struct { - Method string - RelativePath string - Values url.Values - Cancel <-chan bool -} - -// NewRawRequest returns a new RawRequest -func NewRawRequest(method, relativePath string, values url.Values, cancel <-chan bool) *RawRequest { - return &RawRequest{ - Method: method, - RelativePath: relativePath, - Values: values, - Cancel: cancel, - } -} - -// getCancelable issues a cancelable GET request -func (c *Client) getCancelable(key string, options Options, - cancel <-chan bool) (*RawResponse, error) { - logger.Debugf("get %s [%s]", key, c.cluster.Leader) - p := keyToPath(key) - - // If consistency level is set to STRONG, append - // the `consistent` query string. - if c.config.Consistency == STRONG_CONSISTENCY { - options["consistent"] = true - } - - str, err := options.toParameters(VALID_GET_OPTIONS) - if err != nil { - return nil, err - } - p += str - - req := NewRawRequest("GET", p, nil, cancel) - resp, err := c.SendRequest(req) - - if err != nil { - return nil, err - } - - return resp, nil -} - -// get issues a GET request -func (c *Client) get(key string, options Options) (*RawResponse, error) { - return c.getCancelable(key, options, nil) -} - -// put issues a PUT request -func (c *Client) put(key string, value string, ttl uint64, - options Options) (*RawResponse, error) { - - logger.Debugf("put %s, %s, ttl: %d, [%s]", key, value, ttl, c.cluster.Leader) - p := keyToPath(key) - - str, err := options.toParameters(VALID_PUT_OPTIONS) - if err != nil { - return nil, err - } - p += str - - req := NewRawRequest("PUT", p, buildValues(value, ttl), nil) - resp, err := c.SendRequest(req) - - if err != nil { - return nil, err - } - - return resp, nil -} - -// post issues a POST request -func (c *Client) post(key string, value string, ttl uint64) (*RawResponse, error) { - logger.Debugf("post %s, %s, ttl: %d, [%s]", key, value, ttl, c.cluster.Leader) - p := keyToPath(key) - - req := NewRawRequest("POST", p, buildValues(value, ttl), nil) - resp, err := c.SendRequest(req) - - if err != nil { - return nil, err - } - - return resp, nil -} - -// delete issues a DELETE request -func (c *Client) delete(key string, options Options) (*RawResponse, error) { - logger.Debugf("delete %s [%s]", key, c.cluster.Leader) - p := keyToPath(key) - - str, err := options.toParameters(VALID_DELETE_OPTIONS) - if err != nil { - return nil, err - } - p += str - - req := NewRawRequest("DELETE", p, nil, nil) - resp, err := c.SendRequest(req) - - if err != nil { - return nil, err - } - - return resp, nil -} - -// SendRequest sends a HTTP request and returns a Response as defined by etcd -func (c *Client) SendRequest(rr *RawRequest) (*RawResponse, error) { - - var req *http.Request - var resp *http.Response - var httpPath string - var err error - var respBody []byte - - reqs := make([]http.Request, 0) - resps := make([]http.Response, 0) - - checkRetry := c.CheckRetry - if checkRetry == nil { - checkRetry = DefaultCheckRetry - } - - cancelled := make(chan bool, 1) - reqLock := new(sync.Mutex) - - if rr.Cancel != nil { - cancelRoutine := make(chan bool) - defer close(cancelRoutine) - - go func() { - select { - case <-rr.Cancel: - cancelled <-true - logger.Debug("send.request is cancelled") - case <-cancelRoutine: - return - } - - // Repeat canceling request until this thread is stopped - // because we have no idea about whether it succeeds. - for { - reqLock.Lock() - c.httpClient.Transport.(*http.Transport).CancelRequest(req) - reqLock.Unlock() - - select { - case <-time.After(100 * time.Millisecond): - case <-cancelRoutine: - return - } - } - }() - } - - // if we connect to a follower, we will retry until we find a leader - for attempt := 0; ; attempt++ { - select { - case <-cancelled: - return nil, ErrRequestCancelled - default: - } - - logger.Debug("begin attempt", attempt, "for", rr.RelativePath) - - if rr.Method == "GET" && c.config.Consistency == WEAK_CONSISTENCY { - // If it's a GET and consistency level is set to WEAK, - // then use a random machine. - httpPath = c.getHttpPath(true, rr.RelativePath) - } else { - // Else use the leader. - httpPath = c.getHttpPath(false, rr.RelativePath) - } - - // Return a cURL command if curlChan is set - if c.cURLch != nil { - command := fmt.Sprintf("curl -X %s %s", rr.Method, httpPath) - for key, value := range rr.Values { - command += fmt.Sprintf(" -d %s=%s", key, value[0]) - } - c.sendCURL(command) - } - - logger.Debug("send.request.to ", httpPath, " | method ", rr.Method) - - reqLock.Lock() - if rr.Values == nil { - req, _ = http.NewRequest(rr.Method, httpPath, nil) - } else { - req, _ = http.NewRequest(rr.Method, httpPath, - strings.NewReader(rr.Values.Encode())) - - req.Header.Set("Content-Type", - "application/x-www-form-urlencoded; param=value") - } - reqLock.Unlock() - - resp, err = c.httpClient.Do(req) - // If the request was cancelled, return ErrRequestCancelled directly - select { - case <-cancelled: - return nil, ErrRequestCancelled - default: - } - - reqs = append(reqs, *req) - - // network error, change a machine! - if err != nil { - logger.Debug("network error:", err.Error()) - resps = append(resps, http.Response{}) - if checkErr := checkRetry(c.cluster, reqs, resps, err); checkErr != nil { - return nil, checkErr - } - - c.cluster.switchLeader(attempt % len(c.cluster.Machines)) - continue - } - - // if there is no error, it should receive response - resps = append(resps, *resp) - defer resp.Body.Close() - logger.Debug("recv.response.from", httpPath) - - if validHttpStatusCode[resp.StatusCode] { - // try to read byte code and break the loop - respBody, err = ioutil.ReadAll(resp.Body) - if err == nil { - logger.Debug("recv.success.", httpPath) - break - } - } - - // if resp is TemporaryRedirect, set the new leader and retry - if resp.StatusCode == http.StatusTemporaryRedirect { - u, err := resp.Location() - - if err != nil { - logger.Warning(err) - } else { - // Update cluster leader based on redirect location - // because it should point to the leader address - c.cluster.updateLeaderFromURL(u) - logger.Debug("recv.response.relocate", u.String()) - } - continue - } - - if checkErr := checkRetry(c.cluster, reqs, resps, - errors.New("Unexpected HTTP status code")); checkErr != nil { - return nil, checkErr - } - } - - r := &RawResponse{ - StatusCode: resp.StatusCode, - Body: respBody, - Header: resp.Header, - } - - return r, nil -} - -// DefaultCheckRetry checks retry cases -// If it has retried 2 * machine number, stop to retry it anymore -// If resp is nil, sleep for 200ms -// If status code is InternalServerError, sleep for 200ms. -func DefaultCheckRetry(cluster *Cluster, reqs []http.Request, - resps []http.Response, err error) error { - - if len(reqs) >= 2*len(cluster.Machines) { - return newError(ErrCodeEtcdNotReachable, - "Tried to connect to each peer twice and failed", 0) - } - - resp := &resps[len(resps)-1] - - if resp == nil { - time.Sleep(time.Millisecond * 200) - return nil - } - - code := resp.StatusCode - if code == http.StatusInternalServerError { - time.Sleep(time.Millisecond * 200) - - } - - logger.Warning("bad response status code", code) - return nil -} - -func (c *Client) getHttpPath(random bool, s ...string) string { - var machine string - if random { - machine = c.cluster.Machines[rand.Intn(len(c.cluster.Machines))] - } else { - machine = c.cluster.Leader - } - - fullPath := machine + "/" + version - for _, seg := range s { - fullPath = fullPath + "/" + seg - } - - return fullPath -} - -// buildValues builds a url.Values map according to the given value and ttl -func buildValues(value string, ttl uint64) url.Values { - v := url.Values{} - - if value != "" { - v.Set("value", value) - } - - if ttl > 0 { - v.Set("ttl", fmt.Sprintf("%v", ttl)) - } - - return v -} - -// convert key string to http path exclude version -// for example: key[foo] -> path[keys/foo] -// key[/] -> path[keys/] -func keyToPath(key string) string { - p := path.Join("keys", key) - - // corner case: if key is "/" or "//" ect - // path join will clear the tailing "/" - // we need to add it back - if p == "keys" { - p = "keys/" - } - - return p -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/response.go b/vendor/github.com/coreos/go-etcd/etcd/response.go deleted file mode 100644 index fbd7da43a..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/response.go +++ /dev/null @@ -1,89 +0,0 @@ -package etcd - -import ( - "encoding/json" - "net/http" - "strconv" - "time" -) - -const ( - rawResponse = iota - normalResponse -) - -type responseType int - -type RawResponse struct { - StatusCode int - Body []byte - Header http.Header -} - -var ( - validHttpStatusCode = map[int]bool{ - http.StatusCreated: true, - http.StatusOK: true, - http.StatusBadRequest: true, - http.StatusNotFound: true, - http.StatusPreconditionFailed: true, - http.StatusForbidden: true, - } -) - -// Unmarshal parses RawResponse and stores the result in Response -func (rr *RawResponse) Unmarshal() (*Response, error) { - if rr.StatusCode != http.StatusOK && rr.StatusCode != http.StatusCreated { - return nil, handleError(rr.Body) - } - - resp := new(Response) - - err := json.Unmarshal(rr.Body, resp) - - if err != nil { - return nil, err - } - - // attach index and term to response - resp.EtcdIndex, _ = strconv.ParseUint(rr.Header.Get("X-Etcd-Index"), 10, 64) - resp.RaftIndex, _ = strconv.ParseUint(rr.Header.Get("X-Raft-Index"), 10, 64) - resp.RaftTerm, _ = strconv.ParseUint(rr.Header.Get("X-Raft-Term"), 10, 64) - - return resp, nil -} - -type Response struct { - Action string `json:"action"` - Node *Node `json:"node"` - PrevNode *Node `json:"prevNode,omitempty"` - EtcdIndex uint64 `json:"etcdIndex"` - RaftIndex uint64 `json:"raftIndex"` - RaftTerm uint64 `json:"raftTerm"` -} - -type Node struct { - Key string `json:"key, omitempty"` - Value string `json:"value,omitempty"` - Dir bool `json:"dir,omitempty"` - Expiration *time.Time `json:"expiration,omitempty"` - TTL int64 `json:"ttl,omitempty"` - Nodes Nodes `json:"nodes,omitempty"` - ModifiedIndex uint64 `json:"modifiedIndex,omitempty"` - CreatedIndex uint64 `json:"createdIndex,omitempty"` -} - -type Nodes []Node - -// interfaces for sorting -func (ns Nodes) Len() int { - return len(ns) -} - -func (ns Nodes) Less(i, j int) bool { - return ns[i].Key < ns[j].Key -} - -func (ns Nodes) Swap(i, j int) { - ns[i], ns[j] = ns[j], ns[i] -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/set_curl_chan_test.go b/vendor/github.com/coreos/go-etcd/etcd/set_curl_chan_test.go deleted file mode 100644 index 756e31781..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/set_curl_chan_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package etcd - -import ( - "fmt" - "testing" -) - -func TestSetCurlChan(t *testing.T) { - c := NewClient(nil) - c.OpenCURL() - - defer func() { - c.Delete("foo", true) - }() - - _, err := c.Set("foo", "bar", 5) - if err != nil { - t.Fatal(err) - } - - expected := fmt.Sprintf("curl -X PUT %s/v2/keys/foo -d value=bar -d ttl=5", - c.cluster.Leader) - actual := c.RecvCURL() - if expected != actual { - t.Fatalf(`Command "%s" is not equal to expected value "%s"`, - actual, expected) - } - - c.SetConsistency(STRONG_CONSISTENCY) - _, err = c.Get("foo", false, false) - if err != nil { - t.Fatal(err) - } - - expected = fmt.Sprintf("curl -X GET %s/v2/keys/foo?consistent=true&recursive=false&sorted=false", - c.cluster.Leader) - actual = c.RecvCURL() - if expected != actual { - t.Fatalf(`Command "%s" is not equal to expected value "%s"`, - actual, expected) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/set_update_create.go b/vendor/github.com/coreos/go-etcd/etcd/set_update_create.go deleted file mode 100644 index cb0d56747..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/set_update_create.go +++ /dev/null @@ -1,137 +0,0 @@ -package etcd - -// Set sets the given key to the given value. -// It will create a new key value pair or replace the old one. -// It will not replace a existing directory. -func (c *Client) Set(key string, value string, ttl uint64) (*Response, error) { - raw, err := c.RawSet(key, value, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// Set sets the given key to a directory. -// It will create a new directory or replace the old key value pair by a directory. -// It will not replace a existing directory. -func (c *Client) SetDir(key string, ttl uint64) (*Response, error) { - raw, err := c.RawSetDir(key, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// CreateDir creates a directory. It succeeds only if -// the given key does not yet exist. -func (c *Client) CreateDir(key string, ttl uint64) (*Response, error) { - raw, err := c.RawCreateDir(key, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// UpdateDir updates the given directory. It succeeds only if the -// given key already exists. -func (c *Client) UpdateDir(key string, ttl uint64) (*Response, error) { - raw, err := c.RawUpdateDir(key, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// Create creates a file with the given value under the given key. It succeeds -// only if the given key does not yet exist. -func (c *Client) Create(key string, value string, ttl uint64) (*Response, error) { - raw, err := c.RawCreate(key, value, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// CreateInOrder creates a file with a key that's guaranteed to be higher than other -// keys in the given directory. It is useful for creating queues. -func (c *Client) CreateInOrder(dir string, value string, ttl uint64) (*Response, error) { - raw, err := c.RawCreateInOrder(dir, value, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -// Update updates the given key to the given value. It succeeds only if the -// given key already exists. -func (c *Client) Update(key string, value string, ttl uint64) (*Response, error) { - raw, err := c.RawUpdate(key, value, ttl) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() -} - -func (c *Client) RawUpdateDir(key string, ttl uint64) (*RawResponse, error) { - ops := Options{ - "prevExist": true, - "dir": true, - } - - return c.put(key, "", ttl, ops) -} - -func (c *Client) RawCreateDir(key string, ttl uint64) (*RawResponse, error) { - ops := Options{ - "prevExist": false, - "dir": true, - } - - return c.put(key, "", ttl, ops) -} - -func (c *Client) RawSet(key string, value string, ttl uint64) (*RawResponse, error) { - return c.put(key, value, ttl, nil) -} - -func (c *Client) RawSetDir(key string, ttl uint64) (*RawResponse, error) { - ops := Options{ - "dir": true, - } - - return c.put(key, "", ttl, ops) -} - -func (c *Client) RawUpdate(key string, value string, ttl uint64) (*RawResponse, error) { - ops := Options{ - "prevExist": true, - } - - return c.put(key, value, ttl, ops) -} - -func (c *Client) RawCreate(key string, value string, ttl uint64) (*RawResponse, error) { - ops := Options{ - "prevExist": false, - } - - return c.put(key, value, ttl, ops) -} - -func (c *Client) RawCreateInOrder(dir string, value string, ttl uint64) (*RawResponse, error) { - return c.post(dir, value, ttl) -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/set_update_create_test.go b/vendor/github.com/coreos/go-etcd/etcd/set_update_create_test.go deleted file mode 100644 index ced0f06e7..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/set_update_create_test.go +++ /dev/null @@ -1,241 +0,0 @@ -package etcd - -import ( - "testing" -) - -func TestSet(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - }() - - resp, err := c.Set("foo", "bar", 5) - if err != nil { - t.Fatal(err) - } - if resp.Node.Key != "/foo" || resp.Node.Value != "bar" || resp.Node.TTL != 5 { - t.Fatalf("Set 1 failed: %#v", resp) - } - if resp.PrevNode != nil { - t.Fatalf("Set 1 PrevNode failed: %#v", resp) - } - - resp, err = c.Set("foo", "bar2", 5) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/foo" && resp.Node.Value == "bar2" && resp.Node.TTL == 5) { - t.Fatalf("Set 2 failed: %#v", resp) - } - if resp.PrevNode.Key != "/foo" || resp.PrevNode.Value != "bar" || resp.Node.TTL != 5 { - t.Fatalf("Set 2 PrevNode failed: %#v", resp) - } -} - -func TestUpdate(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - c.Delete("nonexistent", true) - }() - - resp, err := c.Set("foo", "bar", 5) - - if err != nil { - t.Fatal(err) - } - - // This should succeed. - resp, err = c.Update("foo", "wakawaka", 5) - if err != nil { - t.Fatal(err) - } - - if !(resp.Action == "update" && resp.Node.Key == "/foo" && resp.Node.TTL == 5) { - t.Fatalf("Update 1 failed: %#v", resp) - } - if !(resp.PrevNode.Key == "/foo" && resp.PrevNode.Value == "bar" && resp.Node.TTL == 5) { - t.Fatalf("Update 1 prevValue failed: %#v", resp) - } - - // This should fail because the key does not exist. - resp, err = c.Update("nonexistent", "whatever", 5) - if err == nil { - t.Fatalf("The key %v did not exist, so the update should have failed."+ - "The response was: %#v", resp.Node.Key, resp) - } -} - -func TestCreate(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("newKey", true) - }() - - newKey := "/newKey" - newValue := "/newValue" - - // This should succeed - resp, err := c.Create(newKey, newValue, 5) - if err != nil { - t.Fatal(err) - } - - if !(resp.Action == "create" && resp.Node.Key == newKey && - resp.Node.Value == newValue && resp.Node.TTL == 5) { - t.Fatalf("Create 1 failed: %#v", resp) - } - if resp.PrevNode != nil { - t.Fatalf("Create 1 PrevNode failed: %#v", resp) - } - - // This should fail, because the key is already there - resp, err = c.Create(newKey, newValue, 5) - if err == nil { - t.Fatalf("The key %v did exist, so the creation should have failed."+ - "The response was: %#v", resp.Node.Key, resp) - } -} - -func TestCreateInOrder(t *testing.T) { - c := NewClient(nil) - dir := "/queue" - defer func() { - c.DeleteDir(dir) - }() - - var firstKey, secondKey string - - resp, err := c.CreateInOrder(dir, "1", 5) - if err != nil { - t.Fatal(err) - } - - if !(resp.Action == "create" && resp.Node.Value == "1" && resp.Node.TTL == 5) { - t.Fatalf("Create 1 failed: %#v", resp) - } - - firstKey = resp.Node.Key - - resp, err = c.CreateInOrder(dir, "2", 5) - if err != nil { - t.Fatal(err) - } - - if !(resp.Action == "create" && resp.Node.Value == "2" && resp.Node.TTL == 5) { - t.Fatalf("Create 2 failed: %#v", resp) - } - - secondKey = resp.Node.Key - - if firstKey >= secondKey { - t.Fatalf("Expected first key to be greater than second key, but %s is not greater than %s", - firstKey, secondKey) - } -} - -func TestSetDir(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("foo", true) - c.Delete("fooDir", true) - }() - - resp, err := c.CreateDir("fooDir", 5) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/fooDir" && resp.Node.Value == "" && resp.Node.TTL == 5) { - t.Fatalf("SetDir 1 failed: %#v", resp) - } - if resp.PrevNode != nil { - t.Fatalf("SetDir 1 PrevNode failed: %#v", resp) - } - - // This should fail because /fooDir already points to a directory - resp, err = c.CreateDir("/fooDir", 5) - if err == nil { - t.Fatalf("fooDir already points to a directory, so SetDir should have failed."+ - "The response was: %#v", resp) - } - - _, err = c.Set("foo", "bar", 5) - if err != nil { - t.Fatal(err) - } - - // This should succeed - // It should replace the key - resp, err = c.SetDir("foo", 5) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/foo" && resp.Node.Value == "" && resp.Node.TTL == 5) { - t.Fatalf("SetDir 2 failed: %#v", resp) - } - if !(resp.PrevNode.Key == "/foo" && resp.PrevNode.Value == "bar" && resp.PrevNode.TTL == 5) { - t.Fatalf("SetDir 2 failed: %#v", resp) - } -} - -func TestUpdateDir(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("fooDir", true) - }() - - resp, err := c.CreateDir("fooDir", 5) - if err != nil { - t.Fatal(err) - } - - // This should succeed. - resp, err = c.UpdateDir("fooDir", 5) - if err != nil { - t.Fatal(err) - } - - if !(resp.Action == "update" && resp.Node.Key == "/fooDir" && - resp.Node.Value == "" && resp.Node.TTL == 5) { - t.Fatalf("UpdateDir 1 failed: %#v", resp) - } - if !(resp.PrevNode.Key == "/fooDir" && resp.PrevNode.Dir == true && resp.PrevNode.TTL == 5) { - t.Fatalf("UpdateDir 1 PrevNode failed: %#v", resp) - } - - // This should fail because the key does not exist. - resp, err = c.UpdateDir("nonexistentDir", 5) - if err == nil { - t.Fatalf("The key %v did not exist, so the update should have failed."+ - "The response was: %#v", resp.Node.Key, resp) - } -} - -func TestCreateDir(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("fooDir", true) - }() - - // This should succeed - resp, err := c.CreateDir("fooDir", 5) - if err != nil { - t.Fatal(err) - } - - if !(resp.Action == "create" && resp.Node.Key == "/fooDir" && - resp.Node.Value == "" && resp.Node.TTL == 5) { - t.Fatalf("CreateDir 1 failed: %#v", resp) - } - if resp.PrevNode != nil { - t.Fatalf("CreateDir 1 PrevNode failed: %#v", resp) - } - - // This should fail, because the key is already there - resp, err = c.CreateDir("fooDir", 5) - if err == nil { - t.Fatalf("The key %v did exist, so the creation should have failed."+ - "The response was: %#v", resp.Node.Key, resp) - } -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/version.go b/vendor/github.com/coreos/go-etcd/etcd/version.go deleted file mode 100644 index b3d05df70..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package etcd - -const version = "v2" diff --git a/vendor/github.com/coreos/go-etcd/etcd/watch.go b/vendor/github.com/coreos/go-etcd/etcd/watch.go deleted file mode 100644 index 46da9ce2b..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/watch.go +++ /dev/null @@ -1,107 +0,0 @@ -package etcd - -import ( - "errors" -) - -// Errors introduced by the Watch command. -var ( - ErrWatchStoppedByUser = errors.New("Watch stopped by the user via stop channel") -) - -// If recursive is set to true the watch returns the first change under the given -// prefix since the given index. -// -// If recursive is set to false the watch returns the first change to the given key -// since the given index. -// -// To watch for the latest change, set waitIndex = 0. -// -// If a receiver channel is given, it will be a long-term watch. Watch will block at the -//channel. After someone receives the channel, it will go on to watch that -// prefix. If a stop channel is given, the client can close long-term watch using -// the stop channel. -func (c *Client) Watch(prefix string, waitIndex uint64, recursive bool, - receiver chan *Response, stop chan bool) (*Response, error) { - logger.Debugf("watch %s [%s]", prefix, c.cluster.Leader) - if receiver == nil { - raw, err := c.watchOnce(prefix, waitIndex, recursive, stop) - - if err != nil { - return nil, err - } - - return raw.Unmarshal() - } - defer close(receiver) - - for { - raw, err := c.watchOnce(prefix, waitIndex, recursive, stop) - - if err != nil { - return nil, err - } - - resp, err := raw.Unmarshal() - - if err != nil { - return nil, err - } - - waitIndex = resp.Node.ModifiedIndex + 1 - receiver <- resp - } - - return nil, nil -} - -func (c *Client) RawWatch(prefix string, waitIndex uint64, recursive bool, - receiver chan *RawResponse, stop chan bool) (*RawResponse, error) { - - logger.Debugf("rawWatch %s [%s]", prefix, c.cluster.Leader) - if receiver == nil { - return c.watchOnce(prefix, waitIndex, recursive, stop) - } - - for { - raw, err := c.watchOnce(prefix, waitIndex, recursive, stop) - - if err != nil { - return nil, err - } - - resp, err := raw.Unmarshal() - - if err != nil { - return nil, err - } - - waitIndex = resp.Node.ModifiedIndex + 1 - receiver <- raw - } - - return nil, nil -} - -// helper func -// return when there is change under the given prefix -func (c *Client) watchOnce(key string, waitIndex uint64, recursive bool, stop chan bool) (*RawResponse, error) { - - options := Options{ - "wait": true, - } - if waitIndex > 0 { - options["waitIndex"] = waitIndex - } - if recursive { - options["recursive"] = true - } - - resp, err := c.getCancelable(key, options, stop) - - if err == ErrRequestCancelled { - return nil, ErrWatchStoppedByUser - } - - return resp, err -} diff --git a/vendor/github.com/coreos/go-etcd/etcd/watch_test.go b/vendor/github.com/coreos/go-etcd/etcd/watch_test.go deleted file mode 100644 index 43e1dfeb8..000000000 --- a/vendor/github.com/coreos/go-etcd/etcd/watch_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package etcd - -import ( - "fmt" - "runtime" - "testing" - "time" -) - -func TestWatch(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("watch_foo", true) - }() - - go setHelper("watch_foo", "bar", c) - - resp, err := c.Watch("watch_foo", 0, false, nil, nil) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/watch_foo" && resp.Node.Value == "bar") { - t.Fatalf("Watch 1 failed: %#v", resp) - } - - go setHelper("watch_foo", "bar", c) - - resp, err = c.Watch("watch_foo", resp.Node.ModifiedIndex+1, false, nil, nil) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/watch_foo" && resp.Node.Value == "bar") { - t.Fatalf("Watch 2 failed: %#v", resp) - } - - routineNum := runtime.NumGoroutine() - - ch := make(chan *Response, 10) - stop := make(chan bool, 1) - - go setLoop("watch_foo", "bar", c) - - go receiver(ch, stop) - - _, err = c.Watch("watch_foo", 0, false, ch, stop) - if err != ErrWatchStoppedByUser { - t.Fatalf("Watch returned a non-user stop error") - } - - if newRoutineNum := runtime.NumGoroutine(); newRoutineNum != routineNum { - t.Fatalf("Routine numbers differ after watch stop: %v, %v", routineNum, newRoutineNum) - } -} - -func TestWatchAll(t *testing.T) { - c := NewClient(nil) - defer func() { - c.Delete("watch_foo", true) - }() - - go setHelper("watch_foo/foo", "bar", c) - - resp, err := c.Watch("watch_foo", 0, true, nil, nil) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/watch_foo/foo" && resp.Node.Value == "bar") { - t.Fatalf("WatchAll 1 failed: %#v", resp) - } - - go setHelper("watch_foo/foo", "bar", c) - - resp, err = c.Watch("watch_foo", resp.Node.ModifiedIndex+1, true, nil, nil) - if err != nil { - t.Fatal(err) - } - if !(resp.Node.Key == "/watch_foo/foo" && resp.Node.Value == "bar") { - t.Fatalf("WatchAll 2 failed: %#v", resp) - } - - ch := make(chan *Response, 10) - stop := make(chan bool, 1) - - routineNum := runtime.NumGoroutine() - - go setLoop("watch_foo/foo", "bar", c) - - go receiver(ch, stop) - - _, err = c.Watch("watch_foo", 0, true, ch, stop) - if err != ErrWatchStoppedByUser { - t.Fatalf("Watch returned a non-user stop error") - } - - if newRoutineNum := runtime.NumGoroutine(); newRoutineNum != routineNum { - t.Fatalf("Routine numbers differ after watch stop: %v, %v", routineNum, newRoutineNum) - } -} - -func setHelper(key, value string, c *Client) { - time.Sleep(time.Second) - c.Set(key, value, 100) -} - -func setLoop(key, value string, c *Client) { - time.Sleep(time.Second) - for i := 0; i < 10; i++ { - newValue := fmt.Sprintf("%s_%v", value, i) - c.Set(key, newValue, 100) - time.Sleep(time.Second / 10) - } -} - -func receiver(c chan *Response, stop chan bool) { - for i := 0; i < 10; i++ { - <-c - } - stop <- true -} diff --git a/vendor/github.com/davecgh/go-spew/spew/common_test.go b/vendor/github.com/davecgh/go-spew/spew/common_test.go deleted file mode 100644 index c27f798f2..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/common_test.go +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2013 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew_test - -import ( - "fmt" - "github.com/davecgh/go-spew/spew" - "reflect" - "testing" -) - -// custom type to test Stinger interface on non-pointer receiver. -type stringer string - -// String implements the Stringer interface for testing invocation of custom -// stringers on types with non-pointer receivers. -func (s stringer) String() string { - return "stringer " + string(s) -} - -// custom type to test Stinger interface on pointer receiver. -type pstringer string - -// String implements the Stringer interface for testing invocation of custom -// stringers on types with only pointer receivers. -func (s *pstringer) String() string { - return "stringer " + string(*s) -} - -// xref1 and xref2 are cross referencing structs for testing circular reference -// detection. -type xref1 struct { - ps2 *xref2 -} -type xref2 struct { - ps1 *xref1 -} - -// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular -// reference for testing detection. -type indirCir1 struct { - ps2 *indirCir2 -} -type indirCir2 struct { - ps3 *indirCir3 -} -type indirCir3 struct { - ps1 *indirCir1 -} - -// embed is used to test embedded structures. -type embed struct { - a string -} - -// embedwrap is used to test embedded structures. -type embedwrap struct { - *embed - e *embed -} - -// panicer is used to intentionally cause a panic for testing spew properly -// handles them -type panicer int - -func (p panicer) String() string { - panic("test panic") -} - -// customError is used to test custom error interface invocation. -type customError int - -func (e customError) Error() string { - return fmt.Sprintf("error: %d", int(e)) -} - -// stringizeWants converts a slice of wanted test output into a format suitable -// for a test error message. -func stringizeWants(wants []string) string { - s := "" - for i, want := range wants { - if i > 0 { - s += fmt.Sprintf("want%d: %s", i+1, want) - } else { - s += "want: " + want - } - } - return s -} - -// testFailed returns whether or not a test failed by checking if the result -// of the test is in the slice of wanted strings. -func testFailed(result string, wants []string) bool { - for _, want := range wants { - if result == want { - return false - } - } - return true -} - -// TestSortValues ensures the sort functionality for relect.Value based sorting -// works as intended. -func TestSortValues(t *testing.T) { - v := reflect.ValueOf - - a := v("a") - b := v("b") - c := v("c") - embedA := v(embed{"a"}) - embedB := v(embed{"b"}) - embedC := v(embed{"c"}) - tests := []struct { - input []reflect.Value - expected []reflect.Value - }{ - // No values. - { - []reflect.Value{}, - []reflect.Value{}, - }, - // Bools. - { - []reflect.Value{v(false), v(true), v(false)}, - []reflect.Value{v(false), v(false), v(true)}, - }, - // Ints. - { - []reflect.Value{v(2), v(1), v(3)}, - []reflect.Value{v(1), v(2), v(3)}, - }, - // Uints. - { - []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))}, - []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))}, - }, - // Floats. - { - []reflect.Value{v(2.0), v(1.0), v(3.0)}, - []reflect.Value{v(1.0), v(2.0), v(3.0)}, - }, - // Strings. - { - []reflect.Value{b, a, c}, - []reflect.Value{a, b, c}, - }, - // Uintptrs. - { - []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))}, - []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))}, - }, - // Invalid. - { - []reflect.Value{embedB, embedA, embedC}, - []reflect.Value{embedB, embedA, embedC}, - }, - } - for _, test := range tests { - spew.SortValues(test.input) - if !reflect.DeepEqual(test.input, test.expected) { - t.Errorf("Sort mismatch:\n %v != %v", test.input, test.expected) - } - } -} diff --git a/vendor/github.com/davecgh/go-spew/spew/dump_test.go b/vendor/github.com/davecgh/go-spew/spew/dump_test.go deleted file mode 100644 index 84de70712..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/dump_test.go +++ /dev/null @@ -1,912 +0,0 @@ -/* - * Copyright (c) 2013 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -Test Summary: -NOTE: For each test, a nil pointer, a single pointer and double pointer to the -base test element are also tested to ensure proper indirection across all types. - -- Max int8, int16, int32, int64, int -- Max uint8, uint16, uint32, uint64, uint -- Boolean true and false -- Standard complex64 and complex128 -- Array containing standard ints -- Array containing type with custom formatter on pointer receiver only -- Array containing interfaces -- Array containing bytes -- Slice containing standard float32 values -- Slice containing type with custom formatter on pointer receiver only -- Slice containing interfaces -- Slice containing bytes -- Nil slice -- Standard string -- Nil interface -- Sub-interface -- Map with string keys and int vals -- Map with custom formatter type on pointer receiver only keys and vals -- Map with interface keys and values -- Map with nil interface value -- Struct with primitives -- Struct that contains another struct -- Struct that contains custom type with Stringer pointer interface via both - exported and unexported fields -- Struct that contains embedded struct and field to same struct -- Uintptr to 0 (null pointer) -- Uintptr address of real variable -- Unsafe.Pointer to 0 (null pointer) -- Unsafe.Pointer to address of real variable -- Nil channel -- Standard int channel -- Function with no params and no returns -- Function with param and no returns -- Function with multiple params and multiple returns -- Struct that is circular through self referencing -- Structs that are circular through cross referencing -- Structs that are indirectly circular -- Type that panics in its Stringer interface -*/ - -package spew_test - -import ( - "bytes" - "fmt" - "github.com/davecgh/go-spew/spew" - "testing" - "unsafe" -) - -// dumpTest is used to describe a test to be perfomed against the Dump method. -type dumpTest struct { - in interface{} - wants []string -} - -// dumpTests houses all of the tests to be performed against the Dump method. -var dumpTests = make([]dumpTest, 0) - -// addDumpTest is a helper method to append the passed input and desired result -// to dumpTests -func addDumpTest(in interface{}, wants ...string) { - test := dumpTest{in, wants} - dumpTests = append(dumpTests, test) -} - -func addIntDumpTests() { - // Max int8. - v := int8(127) - nv := (*int8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "int8" - vs := "127" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Max int16. - v2 := int16(32767) - nv2 := (*int16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "int16" - v2s := "32767" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Max int32. - v3 := int32(2147483647) - nv3 := (*int32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "int32" - v3s := "2147483647" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Max int64. - v4 := int64(9223372036854775807) - nv4 := (*int64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "int64" - v4s := "9223372036854775807" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") - - // Max int. - v5 := int(2147483647) - nv5 := (*int)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "int" - v5s := "2147483647" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") - addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") - addDumpTest(nv5, "(*"+v5t+")()\n") -} - -func addUintDumpTests() { - // Max uint8. - v := uint8(255) - nv := (*uint8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uint8" - vs := "255" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Max uint16. - v2 := uint16(65535) - nv2 := (*uint16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Max uint32. - v3 := uint32(4294967295) - nv3 := (*uint32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "uint32" - v3s := "4294967295" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Max uint64. - v4 := uint64(18446744073709551615) - nv4 := (*uint64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "uint64" - v4s := "18446744073709551615" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") - - // Max uint. - v5 := uint(4294967295) - nv5 := (*uint)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "uint" - v5s := "4294967295" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") - addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") - addDumpTest(nv5, "(*"+v5t+")()\n") -} - -func addBoolDumpTests() { - // Boolean true. - v := bool(true) - nv := (*bool)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "bool" - vs := "true" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Boolean false. - v2 := bool(false) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "bool" - v2s := "false" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") -} - -func addFloatDumpTests() { - // Standard float32. - v := float32(3.1415) - nv := (*float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "float32" - vs := "3.1415" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Standard float64. - v2 := float64(3.1415926) - nv2 := (*float64)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "float64" - v2s := "3.1415926" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") -} - -func addComplexDumpTests() { - // Standard complex64. - v := complex(float32(6), -2) - nv := (*complex64)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "complex64" - vs := "(6-2i)" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Standard complex128. - v2 := complex(float64(-6), 2) - nv2 := (*complex128)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "complex128" - v2s := "(-6+2i)" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") -} - -func addArrayDumpTests() { - // Array containing standard ints. - v := [3]int{1, 2, 3} - nv := (*[3]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "int" - vs := "{\n (" + vt + ") 1,\n (" + vt + ") 2,\n (" + vt + ") 3\n}" - addDumpTest(v, "([3]"+vt+") "+vs+"\n") - addDumpTest(pv, "(*[3]"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**[3]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*[3]"+vt+")()\n") - - // Array containing type with custom formatter on pointer receiver only. - v2 := [3]pstringer{"1", "2", "3"} - nv2 := (*[3]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.pstringer" - v2s := "{\n (" + v2t + ") stringer 1,\n (" + v2t + ") stringer 2,\n (" + - v2t + ") stringer 3\n}" - addDumpTest(v2, "([3]"+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*[3]"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**[3]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*[3]"+v2t+")()\n") - - // Array containing interfaces. - v3 := [3]interface{}{"one", int(2), uint(3)} - nv3 := (*[3]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[3]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3s := "{\n (" + v3t2 + ") \"one\",\n (" + v3t3 + ") 2,\n (" + v3t4 + - ") 3\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Array containing bytes. - v4 := [34]byte{ - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, - } - nv4 := (*[34]byte)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "[34]uint8" - v4s := "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + - " |............... |\n" + - " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + - " |!\"#$%&'()*+,-./0|\n" + - " 00000020 31 32 " + - " |12|\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") -} - -func addSliceDumpTests() { - // Slice containing standard float32 values. - v := []float32{3.14, 6.28, 12.56} - nv := (*[]float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "float32" - vs := "{\n (" + vt + ") 3.14,\n (" + vt + ") 6.28,\n (" + vt + ") 12.56\n}" - addDumpTest(v, "([]"+vt+") "+vs+"\n") - addDumpTest(pv, "(*[]"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**[]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*[]"+vt+")()\n") - - // Slice containing type with custom formatter on pointer receiver only. - v2 := []pstringer{"1", "2", "3"} - nv2 := (*[]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.pstringer" - v2s := "{\n (" + v2t + ") stringer 1,\n (" + v2t + ") stringer 2,\n (" + - v2t + ") stringer 3\n}" - addDumpTest(v2, "([]"+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*[]"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**[]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*[]"+v2t+")()\n") - - // Slice containing interfaces. - v3 := []interface{}{"one", int(2), uint(3), nil} - nv3 := (*[]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3t5 := "interface {}" - v3s := "{\n (" + v3t2 + ") \"one\",\n (" + v3t3 + ") 2,\n (" + v3t4 + - ") 3,\n (" + v3t5 + ") \n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Slice containing bytes. - v4 := []byte{ - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, - } - nv4 := (*[]byte)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "[]uint8" - v4s := "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + - " |............... |\n" + - " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + - " |!\"#$%&'()*+,-./0|\n" + - " 00000020 31 32 " + - " |12|\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") - - // Nil slice. - v5 := []int(nil) - nv5 := (*[]int)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "[]int" - v5s := "" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") - addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") - addDumpTest(nv5, "(*"+v5t+")()\n") -} - -func addStringDumpTests() { - // Standard string. - v := "test" - nv := (*string)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "string" - vs := "\"test\"" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -func addInterfaceDumpTests() { - // Nil interface. - var v interface{} - nv := (*interface{})(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "interface {}" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Sub-interface. - v2 := interface{}(uint16(65535)) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") -} - -func addMapDumpTests() { - // Map with string keys and int vals. - v := map[string]int{"one": 1, "two": 2} - nv := (*map[string]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "map[string]int" - vt1 := "string" - vt2 := "int" - vs := "{\n (" + vt1 + ") \"one\": (" + vt2 + ") 1,\n (" + vt1 + - ") \"two\": (" + vt2 + ") 2\n}" - vs2 := "{\n (" + vt1 + ") \"two\": (" + vt2 + ") 2,\n (" + vt1 + - ") \"one\": (" + vt2 + ") 1\n}" - addDumpTest(v, "("+vt+") "+vs+"\n", "("+vt+") "+vs2+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n", - "(*"+vt+")("+vAddr+")("+vs2+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n", - "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs2+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Map with custom formatter type on pointer receiver only keys and vals. - v2 := map[pstringer]pstringer{"one": "1"} - nv2 := (*map[pstringer]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "map[spew_test.pstringer]spew_test.pstringer" - v2t1 := "spew_test.pstringer" - v2t2 := "spew_test.pstringer" - v2s := "{\n (" + v2t1 + ") stringer one: (" + v2t2 + ") stringer 1\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Map with interface keys and values. - v3 := map[interface{}]interface{}{"one": 1} - nv3 := (*map[interface{}]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "map[interface {}]interface {}" - v3t1 := "string" - v3t2 := "int" - v3s := "{\n (" + v3t1 + ") \"one\": (" + v3t2 + ") 1\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Map with nil interface value. - v4 := map[string]interface{}{"nil": nil} - nv4 := (*map[string]interface{})(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "map[string]interface {}" - v4t1 := "string" - v4t2 := "interface {}" - v4s := "{\n (" + v4t1 + ") \"nil\": (" + v4t2 + ") \n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") -} - -func addStructDumpTests() { - // Struct with primitives. - type s1 struct { - a int8 - b uint8 - } - v := s1{127, 255} - nv := (*s1)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.s1" - vt2 := "int8" - vt3 := "uint8" - vs := "{\n a: (" + vt2 + ") 127,\n b: (" + vt3 + ") 255\n}" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Struct that contains another struct. - type s2 struct { - s1 s1 - b bool - } - v2 := s2{s1{127, 255}, true} - nv2 := (*s2)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.s2" - v2t2 := "spew_test.s1" - v2t3 := "int8" - v2t4 := "uint8" - v2t5 := "bool" - v2s := "{\n s1: (" + v2t2 + ") {\n a: (" + v2t3 + ") 127,\n b: (" + - v2t4 + ") 255\n },\n b: (" + v2t5 + ") true\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Struct that contains custom type with Stringer pointer interface via both - // exported and unexported fields. - type s3 struct { - s pstringer - S pstringer - } - v3 := s3{"test", "test2"} - nv3 := (*s3)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.s3" - v3t2 := "spew_test.pstringer" - v3s := "{\n s: (" + v3t2 + ") stringer test,\n S: (" + v3t2 + - ") stringer test2\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Struct that contains embedded struct and field to same struct. - e := embed{"embedstr"} - v4 := embedwrap{embed: &e, e: &e} - nv4 := (*embedwrap)(nil) - pv4 := &v4 - eAddr := fmt.Sprintf("%p", &e) - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "spew_test.embedwrap" - v4t2 := "spew_test.embed" - v4t3 := "string" - v4s := "{\n embed: (*" + v4t2 + ")(" + eAddr + ")({\n a: (" + v4t3 + - ") \"embedstr\"\n }),\n e: (*" + v4t2 + ")(" + eAddr + ")({\n" + - " a: (" + v4t3 + ") \"embedstr\"\n })\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") -} - -func addUintptrDumpTests() { - // Null pointer. - v := uintptr(0) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uintptr" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - - // Address of real variable. - i := 1 - v2 := uintptr(unsafe.Pointer(&i)) - nv2 := (*uintptr)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uintptr" - v2s := fmt.Sprintf("%p", &i) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") -} - -func addUnsafePointerDumpTests() { - // Null pointer. - v := unsafe.Pointer(uintptr(0)) - nv := (*unsafe.Pointer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "unsafe.Pointer" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Address of real variable. - i := 1 - v2 := unsafe.Pointer(&i) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "unsafe.Pointer" - v2s := fmt.Sprintf("%p", &i) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -func addChanDumpTests() { - // Nil channel. - var v chan int - pv := &v - nv := (*chan int)(nil) - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "chan int" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Real channel. - v2 := make(chan int) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "chan int" - v2s := fmt.Sprintf("%p", v2) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") -} - -func addFuncDumpTests() { - // Function with no params and no returns. - v := addIntDumpTests - nv := (*func())(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "func()" - vs := fmt.Sprintf("%p", v) - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Function with param and no returns. - v2 := TestDump - nv2 := (*func(*testing.T))(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "func(*testing.T)" - v2s := fmt.Sprintf("%p", v2) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Function with multiple params and multiple returns. - var v3 = func(i int, s string) (b bool, err error) { - return true, nil - } - nv3 := (*func(int, string) (bool, error))(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "func(int, string) (bool, error)" - v3s := fmt.Sprintf("%p", v3) - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") -} - -func addCircularDumpTests() { - // Struct that is circular through self referencing. - type circular struct { - c *circular - } - v := circular{nil} - v.c = &v - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.circular" - vs := "{\n c: (*" + vt + ")(" + vAddr + ")({\n c: (*" + vt + ")(" + - vAddr + ")()\n })\n}" - vs2 := "{\n c: (*" + vt + ")(" + vAddr + ")()\n}" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs2+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs2+")\n") - - // Structs that are circular through cross referencing. - v2 := xref1{nil} - ts2 := xref2{&v2} - v2.ps2 = &ts2 - pv2 := &v2 - ts2Addr := fmt.Sprintf("%p", &ts2) - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.xref1" - v2t2 := "spew_test.xref2" - v2s := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + - ")(" + v2Addr + ")({\n ps2: (*" + v2t2 + ")(" + ts2Addr + - ")()\n })\n })\n}" - v2s2 := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + - ")(" + v2Addr + ")()\n })\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s2+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s2+")\n") - - // Structs that are indirectly circular. - v3 := indirCir1{nil} - tic2 := indirCir2{nil} - tic3 := indirCir3{&v3} - tic2.ps3 = &tic3 - v3.ps2 = &tic2 - pv3 := &v3 - tic2Addr := fmt.Sprintf("%p", &tic2) - tic3Addr := fmt.Sprintf("%p", &tic3) - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.indirCir1" - v3t2 := "spew_test.indirCir2" - v3t3 := "spew_test.indirCir3" - v3s := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + - ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + - ")({\n ps2: (*" + v3t2 + ")(" + tic2Addr + - ")()\n })\n })\n })\n}" - v3s2 := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + - ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + - ")()\n })\n })\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s2+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s2+")\n") -} - -func addPanicDumpTests() { - // Type that panics in its Stringer interface. - v := panicer(127) - nv := (*panicer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.panicer" - vs := "(PANIC=test panic)127" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -func addErrorDumpTests() { - // Type that has a custom Error interface. - v := customError(127) - nv := (*customError)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.customError" - vs := "error: 127" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -// TestDump executes all of the tests described by dumpTests. -func TestDump(t *testing.T) { - // Setup tests. - addIntDumpTests() - addUintDumpTests() - addBoolDumpTests() - addFloatDumpTests() - addComplexDumpTests() - addArrayDumpTests() - addSliceDumpTests() - addStringDumpTests() - addInterfaceDumpTests() - addMapDumpTests() - addStructDumpTests() - addUintptrDumpTests() - addUnsafePointerDumpTests() - addChanDumpTests() - addFuncDumpTests() - addCircularDumpTests() - addPanicDumpTests() - addErrorDumpTests() - addCgoDumpTests() - - t.Logf("Running %d tests", len(dumpTests)) - for i, test := range dumpTests { - buf := new(bytes.Buffer) - spew.Fdump(buf, test.in) - s := buf.String() - if testFailed(s, test.wants) { - t.Errorf("Dump #%d\n got: %s %s", i, s, stringizeWants(test.wants)) - continue - } - } -} - -func TestDumpSortedKeys(t *testing.T) { - cfg := spew.ConfigState{SortKeys: true} - s := cfg.Sdump(map[int]string{1: "1", 3: "3", 2: "2"}) - expected := `(map[int]string) { -(int) 1: (string) "1", -(int) 2: (string) "2", -(int) 3: (string) "3" -} -` - if s != expected { - t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) - } -} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go deleted file mode 100644 index 30e7f7c8a..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2013 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when both cgo is supported and "-tags testcgo" is added to the go test -// command line. This means the cgo tests are only added (and hence run) when -// specifially requested. This configuration is used because spew itself -// does not require cgo to run even though it does handle certain cgo types -// specially. Rather than forcing all clients to require cgo and an external -// C compiler just to run the tests, this scheme makes them optional. -// +build cgo,testcgo - -package spew_test - -import ( - "fmt" - "github.com/davecgh/go-spew/spew/testdata" -) - -func addCgoDumpTests() { - // C char pointer. - v := testdata.GetCgoCharPointer() - nv := testdata.GetCgoNullCharPointer() - pv := &v - vcAddr := fmt.Sprintf("%p", v) - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "*testdata._Ctype_char" - vs := "116" - addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n") - addDumpTest(nv, "("+vt+")()\n") - - // C char array. - v2 := testdata.GetCgoCharArray() - v2t := "[6]testdata._Ctype_char" - v2s := "{\n 00000000 74 65 73 74 32 00 " + - " |test2.|\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - - // C unsigned char array. - v3 := testdata.GetCgoUnsignedCharArray() - v3t := "[6]testdata._Ctype_unsignedchar" - v3s := "{\n 00000000 74 65 73 74 33 00 " + - " |test3.|\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - - // C signed char array. - v4 := testdata.GetCgoSignedCharArray() - v4t := "[6]testdata._Ctype_schar" - v4t2 := "testdata._Ctype_schar" - v4s := "{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 + - ") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 + - ") 0\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - - // C uint8_t array. - v5 := testdata.GetCgoUint8tArray() - v5t := "[6]testdata._Ctype_uint8_t" - v5s := "{\n 00000000 74 65 73 74 35 00 " + - " |test5.|\n}" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - - // C typedefed unsigned char array. - v6 := testdata.GetCgoTypdefedUnsignedCharArray() - v6t := "[6]testdata._Ctype_custom_uchar_t" - v6s := "{\n 00000000 74 65 73 74 36 00 " + - " |test6.|\n}" - addDumpTest(v6, "("+v6t+") "+v6s+"\n") -} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go deleted file mode 100644 index 52a0971fb..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2013 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when either cgo is not supported or "-tags testcgo" is not added to the go -// test command line. This file intentionally does not setup any cgo tests in -// this scenario. -// +build !cgo !testcgo - -package spew_test - -func addCgoDumpTests() { - // Don't add any tests for cgo since this file is only compiled when - // there should not be any cgo tests. -} diff --git a/vendor/github.com/davecgh/go-spew/spew/example_test.go b/vendor/github.com/davecgh/go-spew/spew/example_test.go deleted file mode 100644 index b1ec8a2d0..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/example_test.go +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2013 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew_test - -import ( - "fmt" - "github.com/davecgh/go-spew/spew" -) - -type Flag int - -const ( - flagOne Flag = iota - flagTwo -) - -var flagStrings = map[Flag]string{ - flagOne: "flagOne", - flagTwo: "flagTwo", -} - -func (f Flag) String() string { - if s, ok := flagStrings[f]; ok { - return s - } - return fmt.Sprintf("Unknown flag (%d)", int(f)) -} - -type Bar struct { - flag Flag - data uintptr -} - -type Foo struct { - unexportedField Bar - ExportedField map[interface{}]interface{} -} - -// This example demonstrates how to use Dump to dump variables to stdout. -func ExampleDump() { - // The following package level declarations are assumed for this example: - /* - type Flag int - - const ( - flagOne Flag = iota - flagTwo - ) - - var flagStrings = map[Flag]string{ - flagOne: "flagOne", - flagTwo: "flagTwo", - } - - func (f Flag) String() string { - if s, ok := flagStrings[f]; ok { - return s - } - return fmt.Sprintf("Unknown flag (%d)", int(f)) - } - - type Bar struct { - flag Flag - data uintptr - } - - type Foo struct { - unexportedField Bar - ExportedField map[interface{}]interface{} - } - */ - - // Setup some sample data structures for the example. - bar := Bar{Flag(flagTwo), uintptr(0)} - s1 := Foo{bar, map[interface{}]interface{}{"one": true}} - f := Flag(5) - b := []byte{ - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, - } - - // Dump! - spew.Dump(s1, f, b) - - // Output: - // (spew_test.Foo) { - // unexportedField: (spew_test.Bar) { - // flag: (spew_test.Flag) flagTwo, - // data: (uintptr) - // }, - // ExportedField: (map[interface {}]interface {}) { - // (string) "one": (bool) true - // } - // } - // (spew_test.Flag) Unknown flag (5) - // ([]uint8) { - // 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | - // 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| - // 00000020 31 32 |12| - // } - // -} - -// This example demonstrates how to use Printf to display a variable with a -// format string and inline formatting. -func ExamplePrintf() { - // Create a double pointer to a uint 8. - ui8 := uint8(5) - pui8 := &ui8 - ppui8 := &pui8 - - // Create a circular data type. - type circular struct { - ui8 uint8 - c *circular - } - c := circular{ui8: 1} - c.c = &c - - // Print! - spew.Printf("ppui8: %v\n", ppui8) - spew.Printf("circular: %v\n", c) - - // Output: - // ppui8: <**>5 - // circular: {1 <*>{1 <*>}} -} - -// This example demonstrates how to use a ConfigState. -func ExampleConfigState() { - // Modify the indent level of the ConfigState only. The global - // configuration is not modified. - scs := spew.ConfigState{Indent: "\t"} - - // Output using the ConfigState instance. - v := map[string]int{"one": 1} - scs.Printf("v: %v\n", v) - scs.Dump(v) - - // Output: - // v: map[one:1] - // (map[string]int) { - // (string) "one": (int) 1 - // } -} - -// This example demonstrates how to use ConfigState.Dump to dump variables to -// stdout -func ExampleConfigState_Dump() { - // See the top-level Dump example for details on the types used in this - // example. - - // Create two ConfigState instances with different indentation. - scs := spew.ConfigState{Indent: "\t"} - scs2 := spew.ConfigState{Indent: " "} - - // Setup some sample data structures for the example. - bar := Bar{Flag(flagTwo), uintptr(0)} - s1 := Foo{bar, map[interface{}]interface{}{"one": true}} - - // Dump using the ConfigState instances. - scs.Dump(s1) - scs2.Dump(s1) - - // Output: - // (spew_test.Foo) { - // unexportedField: (spew_test.Bar) { - // flag: (spew_test.Flag) flagTwo, - // data: (uintptr) - // }, - // ExportedField: (map[interface {}]interface {}) { - // (string) "one": (bool) true - // } - // } - // (spew_test.Foo) { - // unexportedField: (spew_test.Bar) { - // flag: (spew_test.Flag) flagTwo, - // data: (uintptr) - // }, - // ExportedField: (map[interface {}]interface {}) { - // (string) "one": (bool) true - // } - // } - // -} - -// This example demonstrates how to use ConfigState.Printf to display a variable -// with a format string and inline formatting. -func ExampleConfigState_Printf() { - // See the top-level Dump example for details on the types used in this - // example. - - // Create two ConfigState instances and modify the method handling of the - // first ConfigState only. - scs := spew.NewDefaultConfig() - scs2 := spew.NewDefaultConfig() - scs.DisableMethods = true - - // Alternatively - // scs := spew.ConfigState{Indent: " ", DisableMethods: true} - // scs2 := spew.ConfigState{Indent: " "} - - // This is of type Flag which implements a Stringer and has raw value 1. - f := flagTwo - - // Dump using the ConfigState instances. - scs.Printf("f: %v\n", f) - scs2.Printf("f: %v\n", f) - - // Output: - // f: 1 - // f: flagTwo -} diff --git a/vendor/github.com/davecgh/go-spew/spew/format_test.go b/vendor/github.com/davecgh/go-spew/spew/format_test.go deleted file mode 100644 index 80c5ef929..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/format_test.go +++ /dev/null @@ -1,1483 +0,0 @@ -/* - * Copyright (c) 2013 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -Test Summary: -NOTE: For each test, a nil pointer, a single pointer and double pointer to the -base test element are also tested to ensure proper indirection across all types. - -- Max int8, int16, int32, int64, int -- Max uint8, uint16, uint32, uint64, uint -- Boolean true and false -- Standard complex64 and complex128 -- Array containing standard ints -- Array containing type with custom formatter on pointer receiver only -- Array containing interfaces -- Slice containing standard float32 values -- Slice containing type with custom formatter on pointer receiver only -- Slice containing interfaces -- Nil slice -- Standard string -- Nil interface -- Sub-interface -- Map with string keys and int vals -- Map with custom formatter type on pointer receiver only keys and vals -- Map with interface keys and values -- Map with nil interface value -- Struct with primitives -- Struct that contains another struct -- Struct that contains custom type with Stringer pointer interface via both - exported and unexported fields -- Struct that contains embedded struct and field to same struct -- Uintptr to 0 (null pointer) -- Uintptr address of real variable -- Unsafe.Pointer to 0 (null pointer) -- Unsafe.Pointer to address of real variable -- Nil channel -- Standard int channel -- Function with no params and no returns -- Function with param and no returns -- Function with multiple params and multiple returns -- Struct that is circular through self referencing -- Structs that are circular through cross referencing -- Structs that are indirectly circular -- Type that panics in its Stringer interface -- Type that has a custom Error interface -- %x passthrough with uint -- %#x passthrough with uint -- %f passthrough with precision -- %f passthrough with width and precision -- %d passthrough with width -- %q passthrough with string -*/ - -package spew_test - -import ( - "bytes" - "fmt" - "github.com/davecgh/go-spew/spew" - "testing" - "unsafe" -) - -// formatterTest is used to describe a test to be perfomed against NewFormatter. -type formatterTest struct { - format string - in interface{} - wants []string -} - -// formatterTests houses all of the tests to be performed against NewFormatter. -var formatterTests = make([]formatterTest, 0) - -// addFormatterTest is a helper method to append the passed input and desired -// result to formatterTests. -func addFormatterTest(format string, in interface{}, wants ...string) { - test := formatterTest{format, in, wants} - formatterTests = append(formatterTests, test) -} - -func addIntFormatterTests() { - // Max int8. - v := int8(127) - nv := (*int8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "int8" - vs := "127" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Max int16. - v2 := int16(32767) - nv2 := (*int16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "int16" - v2s := "32767" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Max int32. - v3 := int32(2147483647) - nv3 := (*int32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "int32" - v3s := "2147483647" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - - // Max int64. - v4 := int64(9223372036854775807) - nv4 := (*int64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "int64" - v4s := "9223372036854775807" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") - - // Max int. - v5 := int(2147483647) - nv5 := (*int)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "int" - v5s := "2147483647" - addFormatterTest("%v", v5, v5s) - addFormatterTest("%v", pv5, "<*>"+v5s) - addFormatterTest("%v", &pv5, "<**>"+v5s) - addFormatterTest("%v", nv5, "") - addFormatterTest("%+v", v5, v5s) - addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) - addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%+v", nv5, "") - addFormatterTest("%#v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) - addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) - addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") - addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) - addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%#+v", nv5, "(*"+v5t+")"+"") -} - -func addUintFormatterTests() { - // Max uint8. - v := uint8(255) - nv := (*uint8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uint8" - vs := "255" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Max uint16. - v2 := uint16(65535) - nv2 := (*uint16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Max uint32. - v3 := uint32(4294967295) - nv3 := (*uint32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "uint32" - v3s := "4294967295" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - - // Max uint64. - v4 := uint64(18446744073709551615) - nv4 := (*uint64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "uint64" - v4s := "18446744073709551615" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") - - // Max uint. - v5 := uint(4294967295) - nv5 := (*uint)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "uint" - v5s := "4294967295" - addFormatterTest("%v", v5, v5s) - addFormatterTest("%v", pv5, "<*>"+v5s) - addFormatterTest("%v", &pv5, "<**>"+v5s) - addFormatterTest("%v", nv5, "") - addFormatterTest("%+v", v5, v5s) - addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) - addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%+v", nv5, "") - addFormatterTest("%#v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) - addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) - addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") - addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) - addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") -} - -func addBoolFormatterTests() { - // Boolean true. - v := bool(true) - nv := (*bool)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "bool" - vs := "true" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Boolean false. - v2 := bool(false) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "bool" - v2s := "false" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addFloatFormatterTests() { - // Standard float32. - v := float32(3.1415) - nv := (*float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "float32" - vs := "3.1415" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Standard float64. - v2 := float64(3.1415926) - nv2 := (*float64)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "float64" - v2s := "3.1415926" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") -} - -func addComplexFormatterTests() { - // Standard complex64. - v := complex(float32(6), -2) - nv := (*complex64)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "complex64" - vs := "(6-2i)" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Standard complex128. - v2 := complex(float64(-6), 2) - nv2 := (*complex128)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "complex128" - v2s := "(-6+2i)" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") -} - -func addArrayFormatterTests() { - // Array containing standard ints. - v := [3]int{1, 2, 3} - nv := (*[3]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "[3]int" - vs := "[1 2 3]" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Array containing type with custom formatter on pointer receiver only. - v2 := [3]pstringer{"1", "2", "3"} - nv2 := (*[3]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "[3]spew_test.pstringer" - v2s := "[stringer 1 stringer 2 stringer 3]" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Array containing interfaces. - v3 := [3]interface{}{"one", int(2), uint(3)} - nv3 := (*[3]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[3]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3s := "[one 2 3]" - v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3]" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") -} - -func addSliceFormatterTests() { - // Slice containing standard float32 values. - v := []float32{3.14, 6.28, 12.56} - nv := (*[]float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "[]float32" - vs := "[3.14 6.28 12.56]" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Slice containing type with custom formatter on pointer receiver only. - v2 := []pstringer{"1", "2", "3"} - nv2 := (*[]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "[]spew_test.pstringer" - v2s := "[stringer 1 stringer 2 stringer 3]" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Slice containing interfaces. - v3 := []interface{}{"one", int(2), uint(3), nil} - nv3 := (*[]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3t5 := "interface {}" - v3s := "[one 2 3 ]" - v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3 (" + v3t5 + - ")]" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") - - // Nil slice. - var v4 []int - nv4 := (*[]int)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "[]int" - v4s := "" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") -} - -func addStringFormatterTests() { - // Standard string. - v := "test" - nv := (*string)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "string" - vs := "test" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") -} - -func addInterfaceFormatterTests() { - // Nil interface. - var v interface{} - nv := (*interface{})(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "interface {}" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Sub-interface. - v2 := interface{}(uint16(65535)) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addMapFormatterTests() { - // Map with string keys and int vals. - v := map[string]int{"one": 1, "two": 2} - nv := (*map[string]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "map[string]int" - vs := "map[one:1 two:2]" - vs2 := "map[two:2 one:1]" - addFormatterTest("%v", v, vs, vs2) - addFormatterTest("%v", pv, "<*>"+vs, "<*>"+vs2) - addFormatterTest("%v", &pv, "<**>"+vs, "<**>"+vs2) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs, vs2) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs, "<*>("+vAddr+")"+vs2) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs, - "<**>("+pvAddr+"->"+vAddr+")"+vs2) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs, "("+vt+")"+vs2) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs, "(*"+vt+")"+vs2) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs, "(**"+vt+")"+vs2) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs, "("+vt+")"+vs2) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs, - "(*"+vt+")("+vAddr+")"+vs2) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs, - "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs2) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Map with custom formatter type on pointer receiver only keys and vals. - v2 := map[pstringer]pstringer{"one": "1"} - nv2 := (*map[pstringer]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "map[spew_test.pstringer]spew_test.pstringer" - v2s := "map[stringer one:stringer 1]" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Map with interface keys and values. - v3 := map[interface{}]interface{}{"one": 1} - nv3 := (*map[interface{}]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "map[interface {}]interface {}" - v3t1 := "string" - v3t2 := "int" - v3s := "map[one:1]" - v3s2 := "map[(" + v3t1 + ")one:(" + v3t2 + ")1]" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") - - // Map with nil interface value - v4 := map[string]interface{}{"nil": nil} - nv4 := (*map[string]interface{})(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "map[string]interface {}" - v4t1 := "interface {}" - v4s := "map[nil:]" - v4s2 := "map[nil:(" + v4t1 + ")]" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s2) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s2) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s2) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s2) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s2) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s2) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") -} - -func addStructFormatterTests() { - // Struct with primitives. - type s1 struct { - a int8 - b uint8 - } - v := s1{127, 255} - nv := (*s1)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.s1" - vt2 := "int8" - vt3 := "uint8" - vs := "{127 255}" - vs2 := "{a:127 b:255}" - vs3 := "{a:(" + vt2 + ")127 b:(" + vt3 + ")255}" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs2) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs2) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs2) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs3) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs3) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs3) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs3) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs3) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs3) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Struct that contains another struct. - type s2 struct { - s1 s1 - b bool - } - v2 := s2{s1{127, 255}, true} - nv2 := (*s2)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.s2" - v2t2 := "spew_test.s1" - v2t3 := "int8" - v2t4 := "uint8" - v2t5 := "bool" - v2s := "{{127 255} true}" - v2s2 := "{s1:{a:127 b:255} b:true}" - v2s3 := "{s1:(" + v2t2 + "){a:(" + v2t3 + ")127 b:(" + v2t4 + ")255} b:(" + - v2t5 + ")true}" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s2) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s2) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s2) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s3) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s3) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s3) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s3) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s3) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s3) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Struct that contains custom type with Stringer pointer interface via both - // exported and unexported fields. - type s3 struct { - s pstringer - S pstringer - } - v3 := s3{"test", "test2"} - nv3 := (*s3)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.s3" - v3t2 := "spew_test.pstringer" - v3s := "{stringer test stringer test2}" - v3s2 := "{s:stringer test S:stringer test2}" - v3s3 := "{s:(" + v3t2 + ")stringer test S:(" + v3t2 + ")stringer test2}" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s2) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s2) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s3) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s3) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s3) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s3) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s3) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s3) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") - - // Struct that contains embedded struct and field to same struct. - e := embed{"embedstr"} - v4 := embedwrap{embed: &e, e: &e} - nv4 := (*embedwrap)(nil) - pv4 := &v4 - eAddr := fmt.Sprintf("%p", &e) - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "spew_test.embedwrap" - v4t2 := "spew_test.embed" - v4t3 := "string" - v4s := "{<*>{embedstr} <*>{embedstr}}" - v4s2 := "{embed:<*>(" + eAddr + "){a:embedstr} e:<*>(" + eAddr + - "){a:embedstr}}" - v4s3 := "{embed:(*" + v4t2 + "){a:(" + v4t3 + ")embedstr} e:(*" + v4t2 + - "){a:(" + v4t3 + ")embedstr}}" - v4s4 := "{embed:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + - ")embedstr} e:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + ")embedstr}}" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%+v", v4, v4s2) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s2) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s2) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s3) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s3) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s3) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s4) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s4) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s4) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") -} - -func addUintptrFormatterTests() { - // Null pointer. - v := uintptr(0) - nv := (*uintptr)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uintptr" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Address of real variable. - i := 1 - v2 := uintptr(unsafe.Pointer(&i)) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uintptr" - v2s := fmt.Sprintf("%p", &i) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addUnsafePointerFormatterTests() { - // Null pointer. - v := unsafe.Pointer(uintptr(0)) - nv := (*unsafe.Pointer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "unsafe.Pointer" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Address of real variable. - i := 1 - v2 := unsafe.Pointer(&i) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "unsafe.Pointer" - v2s := fmt.Sprintf("%p", &i) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addChanFormatterTests() { - // Nil channel. - var v chan int - pv := &v - nv := (*chan int)(nil) - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "chan int" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Real channel. - v2 := make(chan int) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "chan int" - v2s := fmt.Sprintf("%p", v2) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addFuncFormatterTests() { - // Function with no params and no returns. - v := addIntFormatterTests - nv := (*func())(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "func()" - vs := fmt.Sprintf("%p", v) - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Function with param and no returns. - v2 := TestFormatter - nv2 := (*func(*testing.T))(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "func(*testing.T)" - v2s := fmt.Sprintf("%p", v2) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Function with multiple params and multiple returns. - var v3 = func(i int, s string) (b bool, err error) { - return true, nil - } - nv3 := (*func(int, string) (bool, error))(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "func(int, string) (bool, error)" - v3s := fmt.Sprintf("%p", v3) - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") -} - -func addCircularFormatterTests() { - // Struct that is circular through self referencing. - type circular struct { - c *circular - } - v := circular{nil} - v.c = &v - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.circular" - vs := "{<*>{<*>}}" - vs2 := "{<*>}" - vs3 := "{c:<*>(" + vAddr + "){c:<*>(" + vAddr + ")}}" - vs4 := "{c:<*>(" + vAddr + ")}" - vs5 := "{c:(*" + vt + "){c:(*" + vt + ")}}" - vs6 := "{c:(*" + vt + ")}" - vs7 := "{c:(*" + vt + ")(" + vAddr + "){c:(*" + vt + ")(" + vAddr + - ")}}" - vs8 := "{c:(*" + vt + ")(" + vAddr + ")}" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs2) - addFormatterTest("%v", &pv, "<**>"+vs2) - addFormatterTest("%+v", v, vs3) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs4) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs4) - addFormatterTest("%#v", v, "("+vt+")"+vs5) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs6) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs6) - addFormatterTest("%#+v", v, "("+vt+")"+vs7) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs8) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs8) - - // Structs that are circular through cross referencing. - v2 := xref1{nil} - ts2 := xref2{&v2} - v2.ps2 = &ts2 - pv2 := &v2 - ts2Addr := fmt.Sprintf("%p", &ts2) - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.xref1" - v2t2 := "spew_test.xref2" - v2s := "{<*>{<*>{<*>}}}" - v2s2 := "{<*>{<*>}}" - v2s3 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + "){ps2:<*>(" + - ts2Addr + ")}}}" - v2s4 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + ")}}" - v2s5 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + "){ps2:(*" + v2t2 + - ")}}}" - v2s6 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + ")}}" - v2s7 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + - ")(" + v2Addr + "){ps2:(*" + v2t2 + ")(" + ts2Addr + - ")}}}" - v2s8 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + - ")(" + v2Addr + ")}}" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s2) - addFormatterTest("%v", &pv2, "<**>"+v2s2) - addFormatterTest("%+v", v2, v2s3) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s4) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s4) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s5) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s6) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s6) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s7) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s8) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s8) - - // Structs that are indirectly circular. - v3 := indirCir1{nil} - tic2 := indirCir2{nil} - tic3 := indirCir3{&v3} - tic2.ps3 = &tic3 - v3.ps2 = &tic2 - pv3 := &v3 - tic2Addr := fmt.Sprintf("%p", &tic2) - tic3Addr := fmt.Sprintf("%p", &tic3) - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.indirCir1" - v3t2 := "spew_test.indirCir2" - v3t3 := "spew_test.indirCir3" - v3s := "{<*>{<*>{<*>{<*>}}}}" - v3s2 := "{<*>{<*>{<*>}}}" - v3s3 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + - v3Addr + "){ps2:<*>(" + tic2Addr + ")}}}}" - v3s4 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + - v3Addr + ")}}}" - v3s5 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + - "){ps2:(*" + v3t2 + ")}}}}" - v3s6 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + - ")}}}" - v3s7 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + - tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + "){ps2:(*" + v3t2 + - ")(" + tic2Addr + ")}}}}" - v3s8 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + - tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + ")}}}" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s2) - addFormatterTest("%v", &pv3, "<**>"+v3s2) - addFormatterTest("%+v", v3, v3s3) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s4) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s4) - addFormatterTest("%#v", v3, "("+v3t+")"+v3s5) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s6) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s6) - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s7) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s8) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s8) -} - -func addPanicFormatterTests() { - // Type that panics in its Stringer interface. - v := panicer(127) - nv := (*panicer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.panicer" - vs := "(PANIC=test panic)127" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") -} - -func addErrorFormatterTests() { - // Type that has a custom Error interface. - v := customError(127) - nv := (*customError)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.customError" - vs := "error: 127" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") -} - -func addPassthroughFormatterTests() { - // %x passthrough with uint. - v := uint(4294967295) - pv := &v - vAddr := fmt.Sprintf("%x", pv) - pvAddr := fmt.Sprintf("%x", &pv) - vs := "ffffffff" - addFormatterTest("%x", v, vs) - addFormatterTest("%x", pv, vAddr) - addFormatterTest("%x", &pv, pvAddr) - - // %#x passthrough with uint. - v2 := int(2147483647) - pv2 := &v2 - v2Addr := fmt.Sprintf("%#x", pv2) - pv2Addr := fmt.Sprintf("%#x", &pv2) - v2s := "0x7fffffff" - addFormatterTest("%#x", v2, v2s) - addFormatterTest("%#x", pv2, v2Addr) - addFormatterTest("%#x", &pv2, pv2Addr) - - // %f passthrough with precision. - addFormatterTest("%.2f", 3.1415, "3.14") - addFormatterTest("%.3f", 3.1415, "3.142") - addFormatterTest("%.4f", 3.1415, "3.1415") - - // %f passthrough with width and precision. - addFormatterTest("%5.2f", 3.1415, " 3.14") - addFormatterTest("%6.3f", 3.1415, " 3.142") - addFormatterTest("%7.4f", 3.1415, " 3.1415") - - // %d passthrough with width. - addFormatterTest("%3d", 127, "127") - addFormatterTest("%4d", 127, " 127") - addFormatterTest("%5d", 127, " 127") - - // %q passthrough with string. - addFormatterTest("%q", "test", "\"test\"") -} - -// TestFormatter executes all of the tests described by formatterTests. -func TestFormatter(t *testing.T) { - // Setup tests. - addIntFormatterTests() - addUintFormatterTests() - addBoolFormatterTests() - addFloatFormatterTests() - addComplexFormatterTests() - addArrayFormatterTests() - addSliceFormatterTests() - addStringFormatterTests() - addInterfaceFormatterTests() - addMapFormatterTests() - addStructFormatterTests() - addUintptrFormatterTests() - addUnsafePointerFormatterTests() - addChanFormatterTests() - addFuncFormatterTests() - addCircularFormatterTests() - addPanicFormatterTests() - addErrorFormatterTests() - addPassthroughFormatterTests() - - t.Logf("Running %d tests", len(formatterTests)) - for i, test := range formatterTests { - buf := new(bytes.Buffer) - spew.Fprintf(buf, test.format, test.in) - s := buf.String() - if testFailed(s, test.wants) { - t.Errorf("Formatter #%d format: %s got: %s %s", i, test.format, s, - stringizeWants(test.wants)) - continue - } - } -} - -func TestPrintSortedKeys(t *testing.T) { - cfg := spew.ConfigState{SortKeys: true} - s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"}) - expected := "map[1:1 2:2 3:3]" - if s != expected { - t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) - } -} diff --git a/vendor/github.com/davecgh/go-spew/spew/internal_test.go b/vendor/github.com/davecgh/go-spew/spew/internal_test.go deleted file mode 100644 index d8c976163..000000000 --- a/vendor/github.com/davecgh/go-spew/spew/internal_test.go +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2013 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -This test file is part of the spew package rather than than the spew_test -package because it needs access to internals to properly test certain cases -which are not possible via the public interface since they should never happen. -*/ - -package spew - -import ( - "bytes" - "reflect" - "testing" - "unsafe" -) - -// dummyFmtState implements a fake fmt.State to use for testing invalid -// reflect.Value handling. This is necessary because the fmt package catches -// invalid values before invoking the formatter on them. -type dummyFmtState struct { - bytes.Buffer -} - -func (dfs *dummyFmtState) Flag(f int) bool { - if f == int('+') { - return true - } - return false -} - -func (dfs *dummyFmtState) Precision() (int, bool) { - return 0, false -} - -func (dfs *dummyFmtState) Width() (int, bool) { - return 0, false -} - -// TestInvalidReflectValue ensures the dump and formatter code handles an -// invalid reflect value properly. This needs access to internal state since it -// should never happen in real code and therefore can't be tested via the public -// API. -func TestInvalidReflectValue(t *testing.T) { - i := 1 - - // Dump invalid reflect value. - v := new(reflect.Value) - buf := new(bytes.Buffer) - d := dumpState{w: buf, cs: &Config} - d.dump(*v) - s := buf.String() - want := "" - if s != want { - t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want) - } - i++ - - // Formatter invalid reflect value. - buf2 := new(dummyFmtState) - f := formatState{value: *v, cs: &Config, fs: buf2} - f.format(*v) - s = buf2.String() - want = "" - if s != want { - t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want) - } -} - -// flagRO, flagKindShift and flagKindWidth indicate various bit flags that the -// reflect package uses internally to track kind and state information. -const flagRO = 1 << 0 -const flagKindShift = 4 -const flagKindWidth = 5 - -// changeKind uses unsafe to intentionally change the kind of a reflect.Value to -// the maximum kind value which does not exist. This is needed to test the -// fallback code which punts to the standard fmt library for new types that -// might get added to the language. -func changeKind(v *reflect.Value, readOnly bool) { - rvf := (*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + - unsafe.Offsetof(reflectValue.flag))) - *rvf = *rvf | ((1< - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew_test - -import ( - "bytes" - "fmt" - "github.com/davecgh/go-spew/spew" - "io/ioutil" - "os" - "testing" -) - -// spewFunc is used to identify which public function of the spew package or -// ConfigState a test applies to. -type spewFunc int - -const ( - fCSFdump spewFunc = iota - fCSFprint - fCSFprintf - fCSFprintln - fCSPrint - fCSPrintln - fCSSdump - fCSSprint - fCSSprintf - fCSSprintln - fCSErrorf - fCSNewFormatter - fErrorf - fFprint - fFprintln - fPrint - fPrintln - fSdump - fSprint - fSprintf - fSprintln -) - -// Map of spewFunc values to names for pretty printing. -var spewFuncStrings = map[spewFunc]string{ - fCSFdump: "ConfigState.Fdump", - fCSFprint: "ConfigState.Fprint", - fCSFprintf: "ConfigState.Fprintf", - fCSFprintln: "ConfigState.Fprintln", - fCSSdump: "ConfigState.Sdump", - fCSPrint: "ConfigState.Print", - fCSPrintln: "ConfigState.Println", - fCSSprint: "ConfigState.Sprint", - fCSSprintf: "ConfigState.Sprintf", - fCSSprintln: "ConfigState.Sprintln", - fCSErrorf: "ConfigState.Errorf", - fCSNewFormatter: "ConfigState.NewFormatter", - fErrorf: "spew.Errorf", - fFprint: "spew.Fprint", - fFprintln: "spew.Fprintln", - fPrint: "spew.Print", - fPrintln: "spew.Println", - fSdump: "spew.Sdump", - fSprint: "spew.Sprint", - fSprintf: "spew.Sprintf", - fSprintln: "spew.Sprintln", -} - -func (f spewFunc) String() string { - if s, ok := spewFuncStrings[f]; ok { - return s - } - return fmt.Sprintf("Unknown spewFunc (%d)", int(f)) -} - -// spewTest is used to describe a test to be performed against the public -// functions of the spew package or ConfigState. -type spewTest struct { - cs *spew.ConfigState - f spewFunc - format string - in interface{} - want string -} - -// spewTests houses the tests to be performed against the public functions of -// the spew package and ConfigState. -// -// These tests are only intended to ensure the public functions are exercised -// and are intentionally not exhaustive of types. The exhaustive type -// tests are handled in the dump and format tests. -var spewTests []spewTest - -// redirStdout is a helper function to return the standard output from f as a -// byte slice. -func redirStdout(f func()) ([]byte, error) { - tempFile, err := ioutil.TempFile("", "ss-test") - if err != nil { - return nil, err - } - fileName := tempFile.Name() - defer os.Remove(fileName) // Ignore error - - origStdout := os.Stdout - os.Stdout = tempFile - f() - os.Stdout = origStdout - tempFile.Close() - - return ioutil.ReadFile(fileName) -} - -func initSpewTests() { - // Config states with various settings. - scsDefault := spew.NewDefaultConfig() - scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true} - scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true} - scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1} - scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true} - - // Variables for tests on types which implement Stringer interface with and - // without a pointer receiver. - ts := stringer("test") - tps := pstringer("test") - - // depthTester is used to test max depth handling for structs, array, slices - // and maps. - type depthTester struct { - ic indirCir1 - arr [1]string - slice []string - m map[string]int - } - dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"}, - map[string]int{"one": 1}} - - // Variable for tests on types which implement error interface. - te := customError(10) - - spewTests = []spewTest{ - {scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"}, - {scsDefault, fCSFprint, "", int16(32767), "32767"}, - {scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"}, - {scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"}, - {scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"}, - {scsDefault, fCSPrintln, "", uint8(255), "255\n"}, - {scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"}, - {scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"}, - {scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"}, - {scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"}, - {scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"}, - {scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"}, - {scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"}, - {scsDefault, fFprint, "", float32(3.14), "3.14"}, - {scsDefault, fFprintln, "", float64(6.28), "6.28\n"}, - {scsDefault, fPrint, "", true, "true"}, - {scsDefault, fPrintln, "", false, "false\n"}, - {scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"}, - {scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"}, - {scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"}, - {scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"}, - {scsNoMethods, fCSFprint, "", ts, "test"}, - {scsNoMethods, fCSFprint, "", &ts, "<*>test"}, - {scsNoMethods, fCSFprint, "", tps, "test"}, - {scsNoMethods, fCSFprint, "", &tps, "<*>test"}, - {scsNoPmethods, fCSFprint, "", ts, "stringer test"}, - {scsNoPmethods, fCSFprint, "", &ts, "<*>stringer test"}, - {scsNoPmethods, fCSFprint, "", tps, "test"}, - {scsNoPmethods, fCSFprint, "", &tps, "<*>stringer test"}, - {scsMaxDepth, fCSFprint, "", dt, "{{} [] [] map[]}"}, - {scsMaxDepth, fCSFdump, "", dt, "(spew_test.depthTester) {\n" + - " ic: (spew_test.indirCir1) {\n \n },\n" + - " arr: ([1]string) {\n \n },\n" + - " slice: ([]string) {\n \n },\n" + - " m: (map[string]int) {\n \n }\n}\n"}, - {scsContinue, fCSFprint, "", ts, "(stringer test) test"}, - {scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " + - "(stringer test) \"test\"\n"}, - {scsContinue, fCSFprint, "", te, "(error: 10) 10"}, - {scsContinue, fCSFdump, "", te, "(spew_test.customError) " + - "(error: 10) 10\n"}, - } -} - -// TestSpew executes all of the tests described by spewTests. -func TestSpew(t *testing.T) { - initSpewTests() - - t.Logf("Running %d tests", len(spewTests)) - for i, test := range spewTests { - buf := new(bytes.Buffer) - switch test.f { - case fCSFdump: - test.cs.Fdump(buf, test.in) - - case fCSFprint: - test.cs.Fprint(buf, test.in) - - case fCSFprintf: - test.cs.Fprintf(buf, test.format, test.in) - - case fCSFprintln: - test.cs.Fprintln(buf, test.in) - - case fCSPrint: - b, err := redirStdout(func() { test.cs.Print(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fCSPrintln: - b, err := redirStdout(func() { test.cs.Println(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fCSSdump: - str := test.cs.Sdump(test.in) - buf.WriteString(str) - - case fCSSprint: - str := test.cs.Sprint(test.in) - buf.WriteString(str) - - case fCSSprintf: - str := test.cs.Sprintf(test.format, test.in) - buf.WriteString(str) - - case fCSSprintln: - str := test.cs.Sprintln(test.in) - buf.WriteString(str) - - case fCSErrorf: - err := test.cs.Errorf(test.format, test.in) - buf.WriteString(err.Error()) - - case fCSNewFormatter: - fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in)) - - case fErrorf: - err := spew.Errorf(test.format, test.in) - buf.WriteString(err.Error()) - - case fFprint: - spew.Fprint(buf, test.in) - - case fFprintln: - spew.Fprintln(buf, test.in) - - case fPrint: - b, err := redirStdout(func() { spew.Print(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fPrintln: - b, err := redirStdout(func() { spew.Println(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fSdump: - str := spew.Sdump(test.in) - buf.WriteString(str) - - case fSprint: - str := spew.Sprint(test.in) - buf.WriteString(str) - - case fSprintf: - str := spew.Sprintf(test.format, test.in) - buf.WriteString(str) - - case fSprintln: - str := spew.Sprintln(test.in) - buf.WriteString(str) - - default: - t.Errorf("%v #%d unrecognized function", test.f, i) - continue - } - s := buf.String() - if test.want != s { - t.Errorf("ConfigState #%d\n got: %s want: %s", i, s, test.want) - continue - } - } -} diff --git a/vendor/github.com/gocql/gocql/.gitignore b/vendor/github.com/gocql/gocql/.gitignore deleted file mode 100644 index 22f57be40..000000000 --- a/vendor/github.com/gocql/gocql/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -gocql-fuzz -fuzz-corpus -fuzz-work -gocql.test \ No newline at end of file diff --git a/vendor/github.com/gocql/gocql/.travis.yml b/vendor/github.com/gocql/gocql/.travis.yml deleted file mode 100644 index 5a5602280..000000000 --- a/vendor/github.com/gocql/gocql/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: go - -sudo: false - -cache: - directories: - - $HOME/.ccm/repository - -matrix: - fast_finish: true - -env: - global: - - GOMAXPROCS=2 - matrix: - - CASS=1.2.19 AUTH=false - - CASS=2.0.14 AUTH=false - - CASS=2.1.5 AUTH=false - - CASS=2.1.5 AUTH=true - -go: - - 1.3 - - 1.4 - -install: - - pip install --user cql PyYAML six - - go get golang.org/x/tools/cmd/vet - - go get golang.org/x/tools/cmd/cover - - git clone https://github.com/pcmanus/ccm.git - - pushd ccm - - ./setup.py install --user - - popd - - go get . - -script: - - set -e - - go test -v -tags unit - - PATH=$PATH:$HOME/.local/bin bash -x integration.sh $CASS $AUTH - - go vet . - -notifications: - - email: false diff --git a/vendor/github.com/gocql/gocql/AUTHORS b/vendor/github.com/gocql/gocql/AUTHORS deleted file mode 100644 index f125b3f97..000000000 --- a/vendor/github.com/gocql/gocql/AUTHORS +++ /dev/null @@ -1,54 +0,0 @@ -# This source file refers to The gocql Authors for copyright purposes. - -Christoph Hack -Jonathan Rudenberg -Thorsten von Eicken -Matt Robenolt -Phillip Couto -Niklas Korz -Nimi Wariboko Jr -Ghais Issa -Sasha Klizhentas -Konstantin Cherkasov -Ben Hood <0x6e6562@gmail.com> -Pete Hopkins -Chris Bannister -Maxim Bublis -Alex Zorin -Kasper Middelboe Petersen -Harpreet Sawhney -Charlie Andrews -Stanislavs Koikovs -Dan Forest -Miguel Serrano -Stefan Radomski -Josh Wright -Jacob Rhoden -Ben Frye -Fred McCann -Dan Simmons -Muir Manders -Sankar P -Julien Da Silva -Dan Kennedy -Nick Dhupia -Yasuharu Goto -Jeremy Schlatter -Matthias Kadenbach -Dean Elbaz -Mike Berman -Dmitriy Fedorenko -Zach Marcantel -James Maloney -Ashwin Purohit -Dan Kinder -Oliver Beattie -Justin Corpron -Miles Delahunty -Zach Badgett -Maciek Sakrejda -Jeff Mitchell -Baptiste Fontaine -Matt Heath -Jamie Cuthill -Adrian Casajus diff --git a/vendor/github.com/gocql/gocql/CONTRIBUTING.md b/vendor/github.com/gocql/gocql/CONTRIBUTING.md deleted file mode 100644 index e149322bb..000000000 --- a/vendor/github.com/gocql/gocql/CONTRIBUTING.md +++ /dev/null @@ -1,78 +0,0 @@ -# Contributing to gocql - -**TL;DR** - this manifesto sets out the bare mimimum requirements for submitting a patch to gocql. - -This guide outlines the process of landing patches in gocql and the general approach to maintaining the code base. - -## Background - -The goal of the gocql project is to provide a stable and robust CQL driver for Golang. gocql is a community driven project that is coordinated by a small team of core developers. - -## Minimum Requirement Checklist - -The following is a check list of requirements that need to be satisfied in order for us to merge your patch: - -* You should raise a pull request to gocql/gocql on Github -* The pull request has a title that clearly summarizes the purpose of the patch -* The motivation behind the patch is clearly defined in the pull request summary -* Your name and email have been added to the `AUTHORS` file (for copyright purposes) -* The patch will merge cleanly -* The test coverage does not fall below the critical threshold (currently 64%) -* The merge commit passes the regression test suite on Travis -* `go fmt` has been applied to the submitted code -* Functional changes (i.e. new features or changed behavior) are appropriately documented, either as a godoc or in the README (non-functional changes such as bug fixes may not require documentation) - -If there are any requirements that can't be reasonably satifisfied, please state this either on the pull request or as part of discussion on the mailing list. Where appropriate, the core team may apply discretion and make an exception to these requirements. - -## Beyond The Checklist - -In addition to stating the hard requirements, there are a bunch of things that we consider when assessing changes to the library. These soft requirements are helpful pointers of how to get a patch landed quicker and with less fuss. - -### General QA Approach - -The gocql team needs to consider the ongoing maintainability of the library at all times. Patches that look like they will introduce maintenance issues for the team will not be accepted. - -Your patch will get merged quicker if you have decent test cases that provide test coverage for the new behavior you wish to introduce. - -Unit tests are good, integration tests are even better. An example of a unit test is `marshal_test.go` - this tests the serialization code in isolation. `cassandra_test.go` is an integration test suite that is executed against every version of Cassandra that gocql supports as part of the CI process on Travis. - -That said, the point of writing tests is to provide a safety net to catch regressions, so there is no need to go overboard with tests. Remember that the more tests you write, the more code we will have to maintain. So there's a balance to strike there. - -### When It's Too Difficult To Automate Testing - -There are legitimate examples of where it is infeasible to write a regression test for a change. Never fear, we will still consider the patch and quite possibly accept the change without a test. The gocql team takes a pragmatic approach to testing. At the end of the day, you could be addressing an issue that is too difficult to reproduce in a test suite, but still occurs in a real production app. In this case, your production app is the test case, and we will have to trust that your change is good. - -Examples of pull requests that have been accepted without tests include: - -* https://github.com/gocql/gocql/pull/181 - this patch would otherwise require a multi-node cluster to be booted as part of the CI build -* https://github.com/gocql/gocql/pull/179 - this bug can only be reproduced under heavy load in certain circumstances - -### Sign Off Procedure - -Generally speaking, a pull request can get merged by any one of the core gocql team. If your change is minor, chances are that one team member will just go ahead and merge it there and then. As stated earlier, suitable test coverage will increase the likelihood that a single reviewer will assess and merge your change. If your change has no test coverage, or looks like it may have wider implications for the health and stability of the library, the reviewer may elect to refer the change to another team member to acheive consensus before proceeding. Therefore, the tighter and cleaner your patch is, the quicker it will go through the review process. - -### Supported Features - -gocql is a low level wire driver for Cassandra CQL. By and large, we would like to keep the functional scope of the library as narrow as possible. We think that gocql should be tight and focussed, and we will be naturally sceptical of things that could just as easily be implemented in a higher layer. Inevitably you will come accross something that could be implemented in a higher layer, save for a minor change to the core API. In this instance, please strike up a conversation with the gocql team. Chances are we will understand what you are trying to acheive and will try to accommodate this in a maintainable way. - -### Longer Term Evolution - -There are some long term plans for gocql that have to be taken into account when assessing changes. That said, gocql is ultimately a community driven project and we don't have a massive development budget, so sometimes the long term view might need to be de-prioritized ahead of short term changes. - -## Officially Supported Server Versions - -Currently, the officiallly supported versions of the Cassandra server include: - -* 1.2.18 -* 2.0.9 - -Chances are that gocql will work with many other versions. If you would like us to support a particular version of Cassandra, please start a conversation about what version you'd like us to consider. We are more likely to accept a new version if you help out by extending the regression suite to cover the new version to be supported. - -## The Core Dev Team - -The core development team includes: - -* tux21b -* phillipCouto -* Zariel -* 0x6e6562 diff --git a/vendor/github.com/gocql/gocql/LICENSE b/vendor/github.com/gocql/gocql/LICENSE deleted file mode 100644 index 18d25f923..000000000 --- a/vendor/github.com/gocql/gocql/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2012 The gocql Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/gocql/gocql/README.md b/vendor/github.com/gocql/gocql/README.md deleted file mode 100644 index a7e17371c..000000000 --- a/vendor/github.com/gocql/gocql/README.md +++ /dev/null @@ -1,197 +0,0 @@ -gocql -===== - -[![Join the chat at https://gitter.im/gocql/gocql](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gocql/gocql?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build Status](https://travis-ci.org/gocql/gocql.png?branch=master)](https://travis-ci.org/gocql/gocql) -[![GoDoc](http://godoc.org/github.com/gocql/gocql?status.png)](http://godoc.org/github.com/gocql/gocql) - -Package gocql implements a fast and robust Cassandra client for the -Go programming language. - -Project Website: http://gocql.github.io/
-API documentation: http://godoc.org/github.com/gocql/gocql
-Discussions: https://groups.google.com/forum/#!forum/gocql - -Supported Versions ------------------- - -The following matrix shows the versions of Go and Cassandra that are tested with the integration test suite as part of the CI build: - -Go/Cassandra | 1.2.19 | 2.0.14 | 2.1.5 --------------| -------| ------| --------- -1.3 | yes | yes | yes -1.4 | yes | yes | yes - - -Sunsetting Model ----------------- - -In general, the gocql team will focus on supporting the current and previous versions of Golang. gocql may still work with older versions of Golang, but offical support for these versions will have been sunset. - -Installation ------------- - - go get github.com/gocql/gocql - - -Features --------- - -* Modern Cassandra client using the native transport -* Automatic type conversations between Cassandra and Go - * Support for all common types including sets, lists and maps - * Custom types can implement a `Marshaler` and `Unmarshaler` interface - * Strict type conversations without any loss of precision - * Built-In support for UUIDs (version 1 and 4) -* Support for logged, unlogged and counter batches -* Cluster management - * Automatic reconnect on connection failures with exponential falloff - * Round robin distribution of queries to different hosts - * Round robin distribution of queries to different connections on a host - * Each connection can execute up to n concurrent queries (whereby n is the limit set by the protocol version the client chooses to use) - * Optional automatic discovery of nodes - * Optional support for periodic node discovery via system.peers - * Policy based connection pool with token aware and round-robin policy implementations -* Support for password authentication -* Iteration over paged results with configurable page size -* Support for TLS/SSL -* Optional frame compression (using snappy) -* Automatic query preparation -* Support for query tracing -* Experimental support for [binary protocol version 3](https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v3.spec) - * Support for up to 32768 streams - * Support for tuple types - * Support for client side timestamps by default - * Support for UDTs via a custom marshaller or struct tags -* An API to access the schema metadata of a given keyspace - -Please visit the [Roadmap](https://github.com/gocql/gocql/wiki/Roadmap) page to see what is on the horizion. - -Important Default Keyspace Changes ----------------------------------- -gocql no longer supports executing "use " statements to simplfy the library. The user still has the -ability to define the default keyspace for connections but now the keyspace can only be defined before a -session is created. Queries can still access keyspaces by indicating the keyspace in the query: -```sql -SELECT * FROM example2.table; -``` - -Example of correct usage: -```go - cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3") - cluster.Keyspace = "example" - ... - session, err := cluster.CreateSession() - -``` -Example of incorrect usage: -```go - cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3") - cluster.Keyspace = "example" - ... - session, err := cluster.CreateSession() - - if err = session.Query("use example2").Exec(); err != nil { - log.Fatal(err) - } -``` -This will result in an err being returned from the session.Query line as the user is trying to execute a "use" -statement. - -Example -------- - -```go -/* Before you execute the program, Launch `cqlsh` and execute: -create keyspace example with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; -create table example.tweet(timeline text, id UUID, text text, PRIMARY KEY(id)); -create index on example.tweet(timeline); -*/ -package main - -import ( - "fmt" - "log" - - "github.com/gocql/gocql" -) - -func main() { - // connect to the cluster - cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3") - cluster.Keyspace = "example" - cluster.Consistency = gocql.Quorum - session, _ := cluster.CreateSession() - defer session.Close() - - // insert a tweet - if err := session.Query(`INSERT INTO tweet (timeline, id, text) VALUES (?, ?, ?)`, - "me", gocql.TimeUUID(), "hello world").Exec(); err != nil { - log.Fatal(err) - } - - var id gocql.UUID - var text string - - /* Search for a specific set of records whose 'timeline' column matches - * the value 'me'. The secondary index that we created earlier will be - * used for optimizing the search */ - if err := session.Query(`SELECT id, text FROM tweet WHERE timeline = ? LIMIT 1`, - "me").Consistency(gocql.One).Scan(&id, &text); err != nil { - log.Fatal(err) - } - fmt.Println("Tweet:", id, text) - - // list all tweets - iter := session.Query(`SELECT id, text FROM tweet WHERE timeline = ?`, "me").Iter() - for iter.Scan(&id, &text) { - fmt.Println("Tweet:", id, text) - } - if err := iter.Close(); err != nil { - log.Fatal(err) - } -} -``` - -Data Binding ------------- - -There are various ways to bind application level data structures to CQL statements: - -* You can write the data binding by hand, as outlined in the Tweet example. This provides you with the greatest flexibility, but it does mean that you need to keep your application code in sync with your Cassandra schema. -* You can dynamically marshal an entire query result into an `[]map[string]interface{}` using the `SliceMap()` API. This returns a slice of row maps keyed by CQL column mames. This method requires no special interaction with the gocql API, but it does require your application to be able to deal with a key value view of your data. -* As a refinement on the `SliceMap()` API you can also call `MapScan()` which returns `map[string]interface{}` instances in a row by row fashion. -* The `Bind()` API provides a client app with a low level mechanism to introspect query meta data and extract appropriate field values from application level data structures. -* Building on top of the gocql driver, [cqlr](https://github.com/relops/cqlr) adds the ability to auto-bind a CQL iterator to a struct or to bind a struct to an INSERT statement. -* Another external project that layers on top of gocql is [cqlc](http://relops.com/cqlc) which generates gocql compliant code from your Cassandra schema so that you can write type safe CQL statements in Go with a natural query syntax. -* [gocassa](https://github.com/hailocab/gocassa) is an external project that layers on top of gocql to provide convenient query building and data binding. -* [gocqltable](https://github.com/elvtechnology/gocqltable) provides an ORM-style convenience layer to make CRUD operations with gocql easier. - -Ecosphere ---------- - -The following community maintained tools are known to integrate with gocql: - -* [migrate](https://github.com/mattes/migrate) is a migration handling tool written in Go with Cassandra support. -* [negronicql](https://github.com/mikebthun/negronicql) is gocql middleware for Negroni. -* [cqlr](https://github.com/relops/cqlr) adds the ability to auto-bind a CQL iterator to a struct or to bind a struct to an INSERT statement. -* [cqlc](http://relops.com/cqlc) which generates gocql compliant code from your Cassandra schema so that you can write type safe CQL statements in Go with a natural query syntax. -* [gocassa](https://github.com/hailocab/gocassa) provides query building, adds data binding, and provides easy-to-use "recipe" tables for common query use-cases. -* [gocqltable](https://github.com/elvtechnology/gocqltable) is a wrapper around gocql that aims to simplify common operations whilst working the library. - -Other Projects --------------- - -* [gocqldriver](https://github.com/tux21b/gocqldriver) is the predecessor of gocql based on Go's "database/sql" package. This project isn't maintained anymore, because Cassandra wasn't a good fit for the traditional "database/sql" API. Use this package instead. - -SEO ---- - -For some reason, when you google `golang cassandra`, this project doesn't feature very highly in the result list. But if you google `go cassandra`, then we're a bit higher up the list. So this is note to try to convince Google that Golang is an alias for Go. - -License -------- - -> Copyright (c) 2012-2015 The gocql Authors. All rights reserved. -> Use of this source code is governed by a BSD-style -> license that can be found in the LICENSE file. diff --git a/vendor/github.com/gocql/gocql/cass1batch_test.go b/vendor/github.com/gocql/gocql/cass1batch_test.go deleted file mode 100644 index 35750a41d..000000000 --- a/vendor/github.com/gocql/gocql/cass1batch_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// +build all integration - -package gocql - -import ( - "strings" - "testing" -) - -func TestProto1BatchInsert(t *testing.T) { - session := createSession(t) - if err := session.Query("CREATE TABLE large (id int primary key)").Exec(); err != nil { - t.Fatal("create table:", err) - } - defer session.Close() - - begin := "BEGIN BATCH" - end := "APPLY BATCH" - query := "INSERT INTO large (id) VALUES (?)" - fullQuery := strings.Join([]string{begin, query, end}, "\n") - args := []interface{}{5} - if err := session.Query(fullQuery, args...).Consistency(Quorum).Exec(); err != nil { - t.Fatal(err) - } - -} - -func TestShouldPrepareFunction(t *testing.T) { - var shouldPrepareTests = []struct { - Stmt string - Result bool - }{ - {` - BEGIN BATCH - INSERT INTO users (userID, password) - VALUES ('smith', 'secret') - APPLY BATCH - ; - `, true}, - {`INSERT INTO users (userID, password, name) VALUES ('user2', 'ch@ngem3b', 'second user')`, true}, - {`BEGIN COUNTER BATCH UPDATE stats SET views = views + 1 WHERE pageid = 1 APPLY BATCH`, true}, - {`delete name from users where userID = 'smith';`, true}, - {` UPDATE users SET password = 'secret' WHERE userID = 'smith' `, true}, - {`CREATE TABLE users ( - user_name varchar PRIMARY KEY, - password varchar, - gender varchar, - session_token varchar, - state varchar, - birth_year bigint - );`, false}, - } - - for _, test := range shouldPrepareTests { - q := &Query{stmt: test.Stmt} - if got := q.shouldPrepare(); got != test.Result { - t.Fatalf("%q: got %v, expected %v\n", test.Stmt, got, test.Result) - } - } -} diff --git a/vendor/github.com/gocql/gocql/cassandra_test.go b/vendor/github.com/gocql/gocql/cassandra_test.go deleted file mode 100644 index 31cbc1136..000000000 --- a/vendor/github.com/gocql/gocql/cassandra_test.go +++ /dev/null @@ -1,2060 +0,0 @@ -// +build all integration - -package gocql - -import ( - "bytes" - "flag" - "fmt" - "log" - "math" - "math/big" - "net" - "reflect" - "strconv" - "strings" - "sync" - "testing" - "time" - "unicode" - - "gopkg.in/inf.v0" -) - -var ( - flagCluster = flag.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples") - flagProto = flag.Int("proto", 2, "protcol version") - flagCQL = flag.String("cql", "3.0.0", "CQL version") - flagRF = flag.Int("rf", 1, "replication factor for test keyspace") - clusterSize = flag.Int("clusterSize", 1, "the expected size of the cluster") - flagRetry = flag.Int("retries", 5, "number of times to retry queries") - flagAutoWait = flag.Duration("autowait", 1000*time.Millisecond, "time to wait for autodiscovery to fill the hosts poll") - flagRunSslTest = flag.Bool("runssl", false, "Set to true to run ssl test") - flagRunAuthTest = flag.Bool("runauth", false, "Set to true to run authentication test") - flagCompressTest = flag.String("compressor", "", "compressor to use") - clusterHosts []string -) - -func init() { - flag.Parse() - clusterHosts = strings.Split(*flagCluster, ",") - log.SetFlags(log.Lshortfile | log.LstdFlags) -} - -func addSslOptions(cluster *ClusterConfig) *ClusterConfig { - if *flagRunSslTest { - cluster.SslOpts = &SslOptions{ - CertPath: "testdata/pki/gocql.crt", - KeyPath: "testdata/pki/gocql.key", - CaPath: "testdata/pki/ca.crt", - EnableHostVerification: false, - } - } - return cluster -} - -var initOnce sync.Once - -func createTable(s *Session, table string) error { - err := s.Query(table).Consistency(All).Exec() - if *clusterSize > 1 { - // wait for table definition to propogate - time.Sleep(1 * time.Second) - } - return err -} - -func createCluster() *ClusterConfig { - cluster := NewCluster(clusterHosts...) - cluster.ProtoVersion = *flagProto - cluster.CQLVersion = *flagCQL - cluster.Timeout = 5 * time.Second - cluster.Consistency = Quorum - if *flagRetry > 0 { - cluster.RetryPolicy = &SimpleRetryPolicy{NumRetries: *flagRetry} - } - - switch *flagCompressTest { - case "snappy": - cluster.Compressor = &SnappyCompressor{} - case "": - default: - panic("invalid compressor: " + *flagCompressTest) - } - - cluster = addSslOptions(cluster) - return cluster -} - -func createKeyspace(tb testing.TB, cluster *ClusterConfig, keyspace string) { - session, err := cluster.CreateSession() - if err != nil { - tb.Fatal("createSession:", err) - } - defer session.Close() - if err = session.Query(`DROP KEYSPACE IF EXISTS ` + keyspace).Exec(); err != nil { - tb.Log("drop keyspace:", err) - } - if err := session.Query(fmt.Sprintf(`CREATE KEYSPACE %s - WITH replication = { - 'class' : 'SimpleStrategy', - 'replication_factor' : %d - }`, keyspace, *flagRF)).Consistency(All).Exec(); err != nil { - tb.Fatalf("error creating keyspace %s: %v", keyspace, err) - } - tb.Logf("Created keyspace %s", keyspace) -} - -func createSessionFromCluster(cluster *ClusterConfig, tb testing.TB) *Session { - // Drop and re-create the keyspace once. Different tests should use their own - // individual tables, but can assume that the table does not exist before. - initOnce.Do(func() { - createKeyspace(tb, cluster, "gocql_test") - }) - - cluster.Keyspace = "gocql_test" - session, err := cluster.CreateSession() - if err != nil { - tb.Fatal("createSession:", err) - } - - return session -} - -func createSession(tb testing.TB) *Session { - cluster := createCluster() - return createSessionFromCluster(cluster, tb) -} - -// TestAuthentication verifies that gocql will work with a host configured to only accept authenticated connections -func TestAuthentication(t *testing.T) { - - if *flagProto < 2 { - t.Skip("Authentication is not supported with protocol < 2") - } - - if !*flagRunAuthTest { - t.Skip("Authentication is not configured in the target cluster") - } - - cluster := createCluster() - - cluster.Authenticator = PasswordAuthenticator{ - Username: "cassandra", - Password: "cassandra", - } - - session, err := cluster.CreateSession() - - if err != nil { - t.Fatalf("Authentication error: %s", err) - } - - session.Close() -} - -//TestRingDiscovery makes sure that you can autodiscover other cluster members when you seed a cluster config with just one node -func TestRingDiscovery(t *testing.T) { - cluster := createCluster() - cluster.Hosts = clusterHosts[:1] - cluster.DiscoverHosts = true - - session, err := cluster.CreateSession() - if err != nil { - t.Fatalf("got error connecting to the cluster %v", err) - } - - if *clusterSize > 1 { - // wait for autodiscovery to update the pool with the list of known hosts - time.Sleep(*flagAutoWait) - } - - size := len(session.Pool.(*SimplePool).connPool) - - if *clusterSize != size { - t.Logf("WARN: Expected a cluster size of %d, but actual size was %d", *clusterSize, size) - } - - session.Close() -} - -func TestEmptyHosts(t *testing.T) { - cluster := createCluster() - cluster.Hosts = nil - if session, err := cluster.CreateSession(); err == nil { - session.Close() - t.Error("expected err, got nil") - } -} - -//TestUseStatementError checks to make sure the correct error is returned when the user tries to execute a use statement. -func TestUseStatementError(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := session.Query("USE gocql_test").Exec(); err != nil { - if err != ErrUseStmt { - t.Error("expected ErrUseStmt, got " + err.Error()) - } - } else { - t.Error("expected err, got nil.") - } -} - -//TestInvalidKeyspace checks that an invalid keyspace will return promptly and without a flood of connections -func TestInvalidKeyspace(t *testing.T) { - cluster := createCluster() - cluster.Keyspace = "invalidKeyspace" - session, err := cluster.CreateSession() - if err != nil { - if err != ErrNoConnectionsStarted { - t.Errorf("Expected ErrNoConnections but got %v", err) - } - } else { - session.Close() //Clean up the session - t.Error("expected err, got nil.") - } -} - -func TestTracing(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE trace (id int primary key)`); err != nil { - t.Fatal("create:", err) - } - - buf := &bytes.Buffer{} - trace := NewTraceWriter(session, buf) - - if err := session.Query(`INSERT INTO trace (id) VALUES (?)`, 42).Trace(trace).Exec(); err != nil { - t.Error("insert:", err) - } else if buf.Len() == 0 { - t.Error("insert: failed to obtain any tracing") - } - buf.Reset() - - var value int - if err := session.Query(`SELECT id FROM trace WHERE id = ?`, 42).Trace(trace).Scan(&value); err != nil { - t.Error("select:", err) - } else if value != 42 { - t.Errorf("value: expected %d, got %d", 42, value) - } else if buf.Len() == 0 { - t.Error("select: failed to obtain any tracing") - } -} - -func TestPaging(t *testing.T) { - if *flagProto == 1 { - t.Skip("Paging not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE paging (id int primary key)"); err != nil { - t.Fatal("create table:", err) - } - for i := 0; i < 100; i++ { - if err := session.Query("INSERT INTO paging (id) VALUES (?)", i).Exec(); err != nil { - t.Fatal("insert:", err) - } - } - - iter := session.Query("SELECT id FROM paging").PageSize(10).Iter() - var id int - count := 0 - for iter.Scan(&id) { - count++ - } - if err := iter.Close(); err != nil { - t.Fatal("close:", err) - } - if count != 100 { - t.Fatalf("expected %d, got %d", 100, count) - } -} - -func TestCAS(t *testing.T) { - if *flagProto == 1 { - t.Skip("lightweight transactions not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - session.cfg.SerialConsistency = LocalSerial - - if err := createTable(session, `CREATE TABLE cas_table ( - title varchar, - revid timeuuid, - last_modified timestamp, - PRIMARY KEY (title, revid) - )`); err != nil { - t.Fatal("create:", err) - } - - title, revid, modified := "baz", TimeUUID(), time.Now() - var titleCAS string - var revidCAS UUID - var modifiedCAS time.Time - - if applied, err := session.Query(`INSERT INTO cas_table (title, revid, last_modified) - VALUES (?, ?, ?) IF NOT EXISTS`, - title, revid, modified).ScanCAS(&titleCAS, &revidCAS, &modifiedCAS); err != nil { - t.Fatal("insert:", err) - } else if !applied { - t.Fatal("insert should have been applied") - } - - if applied, err := session.Query(`INSERT INTO cas_table (title, revid, last_modified) - VALUES (?, ?, ?) IF NOT EXISTS`, - title, revid, modified).ScanCAS(&titleCAS, &revidCAS, &modifiedCAS); err != nil { - t.Fatal("insert:", err) - } else if applied { - t.Fatal("insert should not have been applied") - } else if title != titleCAS || revid != revidCAS { - t.Fatalf("expected %s/%v/%v but got %s/%v/%v", title, revid, modified, titleCAS, revidCAS, modifiedCAS) - } - - tenSecondsLater := modified.Add(10 * time.Second) - - if applied, err := session.Query(`DELETE FROM cas_table WHERE title = ? and revid = ? IF last_modified = ?`, - title, revid, tenSecondsLater).ScanCAS(&modifiedCAS); err != nil { - t.Fatal("delete:", err) - } else if applied { - t.Fatal("delete should have not been applied") - } - - if modifiedCAS.Unix() != tenSecondsLater.Add(-10*time.Second).Unix() { - t.Fatalf("Was expecting modified CAS to be %v; but was one second later", modifiedCAS.UTC()) - } - - if _, err := session.Query(`DELETE FROM cas_table WHERE title = ? and revid = ? IF last_modified = ?`, - title, revid, tenSecondsLater).ScanCAS(); err.Error() != "count mismatch" { - t.Fatalf("delete: was expecting count mismatch error but got %s", err) - } - - if applied, err := session.Query(`DELETE FROM cas_table WHERE title = ? and revid = ? IF last_modified = ?`, - title, revid, modified).ScanCAS(&modifiedCAS); err != nil { - t.Fatal("delete:", err) - } else if !applied { - t.Fatal("delete should have been applied") - } -} - -func TestMapScanCAS(t *testing.T) { - if *flagProto == 1 { - t.Skip("lightweight transactions not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE cas_table2 ( - title varchar, - revid timeuuid, - last_modified timestamp, - deleted boolean, - PRIMARY KEY (title, revid) - )`); err != nil { - t.Fatal("create:", err) - } - - title, revid, modified, deleted := "baz", TimeUUID(), time.Now(), false - mapCAS := map[string]interface{}{} - - if applied, err := session.Query(`INSERT INTO cas_table2 (title, revid, last_modified, deleted) - VALUES (?, ?, ?, ?) IF NOT EXISTS`, - title, revid, modified, deleted).MapScanCAS(mapCAS); err != nil { - t.Fatal("insert:", err) - } else if !applied { - t.Fatal("insert should have been applied") - } - - mapCAS = map[string]interface{}{} - if applied, err := session.Query(`INSERT INTO cas_table2 (title, revid, last_modified, deleted) - VALUES (?, ?, ?, ?) IF NOT EXISTS`, - title, revid, modified, deleted).MapScanCAS(mapCAS); err != nil { - t.Fatal("insert:", err) - } else if applied { - t.Fatal("insert should not have been applied") - } else if title != mapCAS["title"] || revid != mapCAS["revid"] || deleted != mapCAS["deleted"] { - t.Fatalf("expected %s/%v/%v/%v but got %s/%v/%v%v", title, revid, modified, false, mapCAS["title"], mapCAS["revid"], mapCAS["last_modified"], mapCAS["deleted"]) - } - -} - -func TestBatch(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE batch_table (id int primary key)`); err != nil { - t.Fatal("create table:", err) - } - - batch := NewBatch(LoggedBatch) - for i := 0; i < 100; i++ { - batch.Query(`INSERT INTO batch_table (id) VALUES (?)`, i) - } - if err := session.ExecuteBatch(batch); err != nil { - t.Fatal("execute batch:", err) - } - - count := 0 - if err := session.Query(`SELECT COUNT(*) FROM batch_table`).Scan(&count); err != nil { - t.Fatal("select count:", err) - } else if count != 100 { - t.Fatalf("count: expected %d, got %d\n", 100, count) - } -} - -func TestUnpreparedBatch(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE batch_unprepared (id int primary key, c counter)`); err != nil { - t.Fatal("create table:", err) - } - - var batch *Batch - if *flagProto == 2 { - batch = NewBatch(CounterBatch) - } else { - batch = NewBatch(UnloggedBatch) - } - - for i := 0; i < 100; i++ { - batch.Query(`UPDATE batch_unprepared SET c = c + 1 WHERE id = 1`) - } - - if err := session.ExecuteBatch(batch); err != nil { - t.Fatal("execute batch:", err) - } - - count := 0 - if err := session.Query(`SELECT COUNT(*) FROM batch_unprepared`).Scan(&count); err != nil { - t.Fatal("select count:", err) - } else if count != 1 { - t.Fatalf("count: expected %d, got %d\n", 100, count) - } - - if err := session.Query(`SELECT c FROM batch_unprepared`).Scan(&count); err != nil { - t.Fatal("select count:", err) - } else if count != 100 { - t.Fatalf("count: expected %d, got %d\n", 100, count) - } -} - -// TestBatchLimit tests gocql to make sure batch operations larger than the maximum -// statement limit are not submitted to a cassandra node. -func TestBatchLimit(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE batch_table2 (id int primary key)`); err != nil { - t.Fatal("create table:", err) - } - - batch := NewBatch(LoggedBatch) - for i := 0; i < 65537; i++ { - batch.Query(`INSERT INTO batch_table2 (id) VALUES (?)`, i) - } - if err := session.ExecuteBatch(batch); err != ErrTooManyStmts { - t.Fatal("gocql attempted to execute a batch larger than the support limit of statements.") - } - -} - -func TestWhereIn(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE where_in_table (id int, cluster int, primary key (id,cluster))`); err != nil { - t.Fatal("create table:", err) - } - - if err := session.Query("INSERT INTO where_in_table (id, cluster) VALUES (?,?)", 100, 200).Exec(); err != nil { - t.Fatal("insert:", err) - } - - iter := session.Query("SELECT * FROM where_in_table WHERE id = ? AND cluster IN (?)", 100, 200).Iter() - var id, cluster int - count := 0 - for iter.Scan(&id, &cluster) { - count++ - } - - if id != 100 || cluster != 200 { - t.Fatalf("Was expecting id and cluster to be (100,200) but were (%d,%d)", id, cluster) - } -} - -// TestTooManyQueryArgs tests to make sure the library correctly handles the application level bug -// whereby too many query arguments are passed to a query -func TestTooManyQueryArgs(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE too_many_query_args (id int primary key, value int)`); err != nil { - t.Fatal("create table:", err) - } - - _, err := session.Query(`SELECT * FROM too_many_query_args WHERE id = ?`, 1, 2).Iter().SliceMap() - - if err == nil { - t.Fatal("'`SELECT * FROM too_many_query_args WHERE id = ?`, 1, 2' should return an ErrQueryArgLength") - } - - if err != ErrQueryArgLength { - t.Fatalf("'`SELECT * FROM too_many_query_args WHERE id = ?`, 1, 2' should return an ErrQueryArgLength, but returned: %s", err) - } - - batch := session.NewBatch(UnloggedBatch) - batch.Query("INSERT INTO too_many_query_args (id, value) VALUES (?, ?)", 1, 2, 3) - err = session.ExecuteBatch(batch) - - if err == nil { - t.Fatal("'`INSERT INTO too_many_query_args (id, value) VALUES (?, ?)`, 1, 2, 3' should return an ErrQueryArgLength") - } - - if err != ErrQueryArgLength { - t.Fatalf("'INSERT INTO too_many_query_args (id, value) VALUES (?, ?)`, 1, 2, 3' should return an ErrQueryArgLength, but returned: %s", err) - } - -} - -// TestNotEnoughQueryArgs tests to make sure the library correctly handles the application level bug -// whereby not enough query arguments are passed to a query -func TestNotEnoughQueryArgs(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE not_enough_query_args (id int, cluster int, value int, primary key (id, cluster))`); err != nil { - t.Fatal("create table:", err) - } - - _, err := session.Query(`SELECT * FROM not_enough_query_args WHERE id = ? and cluster = ?`, 1).Iter().SliceMap() - - if err == nil { - t.Fatal("'`SELECT * FROM not_enough_query_args WHERE id = ? and cluster = ?`, 1' should return an ErrQueryArgLength") - } - - if err != ErrQueryArgLength { - t.Fatalf("'`SELECT * FROM too_few_query_args WHERE id = ? and cluster = ?`, 1' should return an ErrQueryArgLength, but returned: %s", err) - } - - batch := session.NewBatch(UnloggedBatch) - batch.Query("INSERT INTO not_enough_query_args (id, cluster, value) VALUES (?, ?, ?)", 1, 2) - err = session.ExecuteBatch(batch) - - if err == nil { - t.Fatal("'`INSERT INTO not_enough_query_args (id, cluster, value) VALUES (?, ?, ?)`, 1, 2' should return an ErrQueryArgLength") - } - - if err != ErrQueryArgLength { - t.Fatalf("'INSERT INTO not_enough_query_args (id, cluster, value) VALUES (?, ?, ?)`, 1, 2' should return an ErrQueryArgLength, but returned: %s", err) - } -} - -// TestCreateSessionTimeout tests to make sure the CreateSession function timeouts out correctly -// and prevents an infinite loop of connection retries. -func TestCreateSessionTimeout(t *testing.T) { - go func() { - <-time.After(2 * time.Second) - t.Error("no startup timeout") - }() - - cluster := createCluster() - cluster.Hosts = []string{"127.0.0.1:1"} - session, err := cluster.CreateSession() - if err == nil { - session.Close() - t.Fatal("expected ErrNoConnectionsStarted, but no error was returned.") - } - - if err != ErrNoConnectionsStarted { - t.Fatalf("expected ErrNoConnectionsStarted, but received %v", err) - } -} - -type FullName struct { - FirstName string - LastName string -} - -func (n FullName) MarshalCQL(info TypeInfo) ([]byte, error) { - return []byte(n.FirstName + " " + n.LastName), nil -} - -func (n *FullName) UnmarshalCQL(info TypeInfo, data []byte) error { - t := strings.SplitN(string(data), " ", 2) - n.FirstName, n.LastName = t[0], t[1] - return nil -} - -func TestMapScanWithRefMap(t *testing.T) { - session := createSession(t) - defer session.Close() - if err := createTable(session, `CREATE TABLE scan_map_ref_table ( - testtext text PRIMARY KEY, - testfullname text, - testint int, - )`); err != nil { - t.Fatal("create table:", err) - } - m := make(map[string]interface{}) - m["testtext"] = "testtext" - m["testfullname"] = FullName{"John", "Doe"} - m["testint"] = 100 - - if err := session.Query(`INSERT INTO scan_map_ref_table (testtext, testfullname, testint) values (?,?,?)`, m["testtext"], m["testfullname"], m["testint"]).Exec(); err != nil { - t.Fatal("insert:", err) - } - - var testText string - var testFullName FullName - ret := map[string]interface{}{ - "testtext": &testText, - "testfullname": &testFullName, - // testint is not set here. - } - iter := session.Query(`SELECT * FROM scan_map_ref_table`).Iter() - if ok := iter.MapScan(ret); !ok { - t.Fatal("select:", iter.Close()) - } else { - if ret["testtext"] != "testtext" { - t.Fatal("returned testtext did not match") - } - f := ret["testfullname"].(FullName) - if f.FirstName != "John" || f.LastName != "Doe" { - t.Fatal("returned testfullname did not match") - } - if ret["testint"] != 100 { - t.Fatal("returned testinit did not match") - } - } - -} - -func TestSliceMap(t *testing.T) { - session := createSession(t) - defer session.Close() - if err := createTable(session, `CREATE TABLE slice_map_table ( - testuuid timeuuid PRIMARY KEY, - testtimestamp timestamp, - testvarchar varchar, - testbigint bigint, - testblob blob, - testbool boolean, - testfloat float, - testdouble double, - testint int, - testdecimal decimal, - testlist list, - testset set, - testmap map, - testvarint varint, - testinet inet - )`); err != nil { - t.Fatal("create table:", err) - } - m := make(map[string]interface{}) - - bigInt := new(big.Int) - if _, ok := bigInt.SetString("830169365738487321165427203929228", 10); !ok { - t.Fatal("Failed setting bigint by string") - } - - m["testuuid"] = TimeUUID() - m["testvarchar"] = "Test VarChar" - m["testbigint"] = time.Now().Unix() - m["testtimestamp"] = time.Now().Truncate(time.Millisecond).UTC() - m["testblob"] = []byte("test blob") - m["testbool"] = true - m["testfloat"] = float32(4.564) - m["testdouble"] = float64(4.815162342) - m["testint"] = 2343 - m["testdecimal"] = inf.NewDec(100, 0) - m["testlist"] = []string{"quux", "foo", "bar", "baz", "quux"} - m["testset"] = []int{1, 2, 3, 4, 5, 6, 7, 8, 9} - m["testmap"] = map[string]string{"field1": "val1", "field2": "val2", "field3": "val3"} - m["testvarint"] = bigInt - m["testinet"] = "213.212.2.19" - sliceMap := []map[string]interface{}{m} - if err := session.Query(`INSERT INTO slice_map_table (testuuid, testtimestamp, testvarchar, testbigint, testblob, testbool, testfloat, testdouble, testint, testdecimal, testlist, testset, testmap, testvarint, testinet) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, - m["testuuid"], m["testtimestamp"], m["testvarchar"], m["testbigint"], m["testblob"], m["testbool"], m["testfloat"], m["testdouble"], m["testint"], m["testdecimal"], m["testlist"], m["testset"], m["testmap"], m["testvarint"], m["testinet"]).Exec(); err != nil { - t.Fatal("insert:", err) - } - if returned, retErr := session.Query(`SELECT * FROM slice_map_table`).Iter().SliceMap(); retErr != nil { - t.Fatal("select:", retErr) - } else { - matchSliceMap(t, sliceMap, returned[0]) - } - - // Test for Iter.MapScan() - { - testMap := make(map[string]interface{}) - if !session.Query(`SELECT * FROM slice_map_table`).Iter().MapScan(testMap) { - t.Fatal("MapScan failed to work with one row") - } - matchSliceMap(t, sliceMap, testMap) - } - - // Test for Query.MapScan() - { - testMap := make(map[string]interface{}) - if session.Query(`SELECT * FROM slice_map_table`).MapScan(testMap) != nil { - t.Fatal("MapScan failed to work with one row") - } - matchSliceMap(t, sliceMap, testMap) - } -} -func matchSliceMap(t *testing.T, sliceMap []map[string]interface{}, testMap map[string]interface{}) { - if sliceMap[0]["testuuid"] != testMap["testuuid"] { - t.Fatal("returned testuuid did not match") - } - if sliceMap[0]["testtimestamp"] != testMap["testtimestamp"] { - t.Fatal("returned testtimestamp did not match") - } - if sliceMap[0]["testvarchar"] != testMap["testvarchar"] { - t.Fatal("returned testvarchar did not match") - } - if sliceMap[0]["testbigint"] != testMap["testbigint"] { - t.Fatal("returned testbigint did not match") - } - if !reflect.DeepEqual(sliceMap[0]["testblob"], testMap["testblob"]) { - t.Fatal("returned testblob did not match") - } - if sliceMap[0]["testbool"] != testMap["testbool"] { - t.Fatal("returned testbool did not match") - } - if sliceMap[0]["testfloat"] != testMap["testfloat"] { - t.Fatal("returned testfloat did not match") - } - if sliceMap[0]["testdouble"] != testMap["testdouble"] { - t.Fatal("returned testdouble did not match") - } - if sliceMap[0]["testinet"] != testMap["testinet"] { - t.Fatal("returned testinet did not match") - } - - expectedDecimal := sliceMap[0]["testdecimal"].(*inf.Dec) - returnedDecimal := testMap["testdecimal"].(*inf.Dec) - - if expectedDecimal.Cmp(returnedDecimal) != 0 { - t.Fatal("returned testdecimal did not match") - } - - if !reflect.DeepEqual(sliceMap[0]["testlist"], testMap["testlist"]) { - t.Fatal("returned testlist did not match") - } - if !reflect.DeepEqual(sliceMap[0]["testset"], testMap["testset"]) { - t.Fatal("returned testset did not match") - } - if !reflect.DeepEqual(sliceMap[0]["testmap"], testMap["testmap"]) { - t.Fatal("returned testmap did not match") - } - if sliceMap[0]["testint"] != testMap["testint"] { - t.Fatal("returned testint did not match") - } -} - -func TestScanWithNilArguments(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE scan_with_nil_arguments ( - foo varchar, - bar int, - PRIMARY KEY (foo, bar) - )`); err != nil { - t.Fatal("create:", err) - } - for i := 1; i <= 20; i++ { - if err := session.Query("INSERT INTO scan_with_nil_arguments (foo, bar) VALUES (?, ?)", - "squares", i*i).Exec(); err != nil { - t.Fatal("insert:", err) - } - } - - iter := session.Query("SELECT * FROM scan_with_nil_arguments WHERE foo = ?", "squares").Iter() - var n int - count := 0 - for iter.Scan(nil, &n) { - count += n - } - if err := iter.Close(); err != nil { - t.Fatal("close:", err) - } - if count != 2870 { - t.Fatalf("expected %d, got %d", 2870, count) - } -} - -func TestScanCASWithNilArguments(t *testing.T) { - if *flagProto == 1 { - t.Skip("lightweight transactions not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE scan_cas_with_nil_arguments ( - foo varchar, - bar varchar, - PRIMARY KEY (foo, bar) - )`); err != nil { - t.Fatal("create:", err) - } - - foo := "baz" - var cas string - - if applied, err := session.Query(`INSERT INTO scan_cas_with_nil_arguments (foo, bar) - VALUES (?, ?) IF NOT EXISTS`, - foo, foo).ScanCAS(nil, nil); err != nil { - t.Fatal("insert:", err) - } else if !applied { - t.Fatal("insert should have been applied") - } - - if applied, err := session.Query(`INSERT INTO scan_cas_with_nil_arguments (foo, bar) - VALUES (?, ?) IF NOT EXISTS`, - foo, foo).ScanCAS(&cas, nil); err != nil { - t.Fatal("insert:", err) - } else if applied { - t.Fatal("insert should not have been applied") - } else if foo != cas { - t.Fatalf("expected %v but got %v", foo, cas) - } - - if applied, err := session.Query(`INSERT INTO scan_cas_with_nil_arguments (foo, bar) - VALUES (?, ?) IF NOT EXISTS`, - foo, foo).ScanCAS(nil, &cas); err != nil { - t.Fatal("insert:", err) - } else if applied { - t.Fatal("insert should not have been applied") - } else if foo != cas { - t.Fatalf("expected %v but got %v", foo, cas) - } -} - -func TestRebindQueryInfo(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE rebind_query (id int, value text, PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - if err := session.Query("INSERT INTO rebind_query (id, value) VALUES (?, ?)", 23, "quux").Exec(); err != nil { - t.Fatalf("insert into rebind_query failed, err '%v'", err) - } - - if err := session.Query("INSERT INTO rebind_query (id, value) VALUES (?, ?)", 24, "w00t").Exec(); err != nil { - t.Fatalf("insert into rebind_query failed, err '%v'", err) - } - - q := session.Query("SELECT value FROM rebind_query WHERE ID = ?") - q.Bind(23) - - iter := q.Iter() - var value string - for iter.Scan(&value) { - } - - if value != "quux" { - t.Fatalf("expected %v but got %v", "quux", value) - } - - q.Bind(24) - iter = q.Iter() - - for iter.Scan(&value) { - } - - if value != "w00t" { - t.Fatalf("expected %v but got %v", "quux", value) - } -} - -//TestStaticQueryInfo makes sure that the application can manually bind query parameters using the simplest possible static binding strategy -func TestStaticQueryInfo(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE static_query_info (id int, value text, PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - if err := session.Query("INSERT INTO static_query_info (id, value) VALUES (?, ?)", 113, "foo").Exec(); err != nil { - t.Fatalf("insert into static_query_info failed, err '%v'", err) - } - - autobinder := func(q *QueryInfo) ([]interface{}, error) { - values := make([]interface{}, 1) - values[0] = 113 - return values, nil - } - - qry := session.Bind("SELECT id, value FROM static_query_info WHERE id = ?", autobinder) - - if err := qry.Exec(); err != nil { - t.Fatalf("expose query info failed, error '%v'", err) - } - - iter := qry.Iter() - - var id int - var value string - - iter.Scan(&id, &value) - - if err := iter.Close(); err != nil { - t.Fatalf("query with exposed info failed, err '%v'", err) - } - - if value != "foo" { - t.Fatalf("Expected value %s, but got %s", "foo", value) - } - -} - -type ClusteredKeyValue struct { - Id int - Cluster int - Value string -} - -func (kv *ClusteredKeyValue) Bind(q *QueryInfo) ([]interface{}, error) { - values := make([]interface{}, len(q.Args)) - - for i, info := range q.Args { - fieldName := upcaseInitial(info.Name) - value := reflect.ValueOf(kv) - field := reflect.Indirect(value).FieldByName(fieldName) - values[i] = field.Addr().Interface() - } - - return values, nil -} - -func upcaseInitial(str string) string { - for i, v := range str { - return string(unicode.ToUpper(v)) + str[i+1:] - } - return "" -} - -//TestBoundQueryInfo makes sure that the application can manually bind query parameters using the query meta data supplied at runtime -func TestBoundQueryInfo(t *testing.T) { - - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE clustered_query_info (id int, cluster int, value text, PRIMARY KEY (id, cluster))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - write := &ClusteredKeyValue{Id: 200, Cluster: 300, Value: "baz"} - - insert := session.Bind("INSERT INTO clustered_query_info (id, cluster, value) VALUES (?, ?,?)", write.Bind) - - if err := insert.Exec(); err != nil { - t.Fatalf("insert into clustered_query_info failed, err '%v'", err) - } - - read := &ClusteredKeyValue{Id: 200, Cluster: 300} - - qry := session.Bind("SELECT id, cluster, value FROM clustered_query_info WHERE id = ? and cluster = ?", read.Bind) - - iter := qry.Iter() - - var id, cluster int - var value string - - iter.Scan(&id, &cluster, &value) - - if err := iter.Close(); err != nil { - t.Fatalf("query with clustered_query_info info failed, err '%v'", err) - } - - if value != "baz" { - t.Fatalf("Expected value %s, but got %s", "baz", value) - } - -} - -//TestBatchQueryInfo makes sure that the application can manually bind query parameters when executing in a batch -func TestBatchQueryInfo(t *testing.T) { - - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE batch_query_info (id int, cluster int, value text, PRIMARY KEY (id, cluster))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - write := func(q *QueryInfo) ([]interface{}, error) { - values := make([]interface{}, 3) - values[0] = 4000 - values[1] = 5000 - values[2] = "bar" - return values, nil - } - - batch := session.NewBatch(LoggedBatch) - batch.Bind("INSERT INTO batch_query_info (id, cluster, value) VALUES (?, ?,?)", write) - - if err := session.ExecuteBatch(batch); err != nil { - t.Fatalf("batch insert into batch_query_info failed, err '%v'", err) - } - - read := func(q *QueryInfo) ([]interface{}, error) { - values := make([]interface{}, 2) - values[0] = 4000 - values[1] = 5000 - return values, nil - } - - qry := session.Bind("SELECT id, cluster, value FROM batch_query_info WHERE id = ? and cluster = ?", read) - - iter := qry.Iter() - - var id, cluster int - var value string - - iter.Scan(&id, &cluster, &value) - - if err := iter.Close(); err != nil { - t.Fatalf("query with batch_query_info info failed, err '%v'", err) - } - - if value != "bar" { - t.Fatalf("Expected value %s, but got %s", "bar", value) - } -} - -func injectInvalidPreparedStatement(t *testing.T, session *Session, table string) (string, *Conn) { - if err := createTable(session, `CREATE TABLE `+table+` ( - foo varchar, - bar int, - PRIMARY KEY (foo, bar) - )`); err != nil { - t.Fatal("create:", err) - } - stmt := "INSERT INTO " + table + " (foo, bar) VALUES (?, 7)" - conn := session.Pool.Pick(nil) - flight := new(inflightPrepare) - stmtsLRU.Lock() - stmtsLRU.lru.Add(conn.addr+stmt, flight) - stmtsLRU.Unlock() - flight.info = &resultPreparedFrame{ - preparedID: []byte{'f', 'o', 'o', 'b', 'a', 'r'}, - reqMeta: resultMetadata{ - columns: []ColumnInfo{ - { - Keyspace: "gocql_test", - Table: table, - Name: "foo", - TypeInfo: NativeType{ - typ: TypeVarchar, - }, - }, - }}, - } - return stmt, conn -} - -func TestMissingSchemaPrepare(t *testing.T) { - s := createSession(t) - conn := s.Pool.Pick(nil) - defer s.Close() - - insertQry := &Query{stmt: "INSERT INTO invalidschemaprep (val) VALUES (?)", values: []interface{}{5}, cons: s.cons, - session: s, pageSize: s.pageSize, trace: s.trace, - prefetch: s.prefetch, rt: s.cfg.RetryPolicy} - - if err := conn.executeQuery(insertQry).err; err == nil { - t.Fatal("expected error, but got nil.") - } - - if err := createTable(s, "CREATE TABLE invalidschemaprep (val int, PRIMARY KEY (val))"); err != nil { - t.Fatal("create table:", err) - } - - if err := conn.executeQuery(insertQry).err; err != nil { - t.Fatal(err) // unconfigured columnfamily - } -} - -func TestReprepareStatement(t *testing.T) { - session := createSession(t) - defer session.Close() - stmt, conn := injectInvalidPreparedStatement(t, session, "test_reprepare_statement") - query := session.Query(stmt, "bar") - if err := conn.executeQuery(query).Close(); err != nil { - t.Fatalf("Failed to execute query for reprepare statement: %v", err) - } -} - -func TestReprepareBatch(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - session := createSession(t) - defer session.Close() - stmt, conn := injectInvalidPreparedStatement(t, session, "test_reprepare_statement_batch") - batch := session.NewBatch(UnloggedBatch) - batch.Query(stmt, "bar") - if err := conn.executeBatch(batch); err != nil { - t.Fatalf("Failed to execute query for reprepare statement: %v", err) - } - -} - -func TestQueryInfo(t *testing.T) { - session := createSession(t) - defer session.Close() - - conn := session.Pool.Pick(nil) - info, err := conn.prepareStatement("SELECT release_version, host_id FROM system.local WHERE key = ?", nil) - - if err != nil { - t.Fatalf("Failed to execute query for preparing statement: %v", err) - } - - if len(info.reqMeta.columns) != 1 { - t.Fatalf("Was not expecting meta data for %d query arguments, but got %d\n", 1, len(info.reqMeta.columns)) - } - - if *flagProto > 1 { - if len(info.respMeta.columns) != 2 { - t.Fatalf("Was not expecting meta data for %d result columns, but got %d\n", 2, len(info.respMeta.columns)) - } - } -} - -//TestPreparedCacheEviction will make sure that the cache size is maintained -func TestPreparedCacheEviction(t *testing.T) { - session := createSession(t) - defer session.Close() - stmtsLRU.Lock() - stmtsLRU.Max(4) - stmtsLRU.Unlock() - - if err := createTable(session, "CREATE TABLE prepcachetest (id int,mod int,PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - //Fill the table - for i := 0; i < 2; i++ { - if err := session.Query("INSERT INTO prepcachetest (id,mod) VALUES (?, ?)", i, 10000%(i+1)).Exec(); err != nil { - t.Fatalf("insert into prepcachetest failed, err '%v'", err) - } - } - //Populate the prepared statement cache with select statements - var id, mod int - for i := 0; i < 2; i++ { - err := session.Query("SELECT id,mod FROM prepcachetest WHERE id = "+strconv.FormatInt(int64(i), 10)).Scan(&id, &mod) - if err != nil { - t.Fatalf("select from prepcachetest failed, error '%v'", err) - } - } - - //generate an update statement to test they are prepared - err := session.Query("UPDATE prepcachetest SET mod = ? WHERE id = ?", 1, 11).Exec() - if err != nil { - t.Fatalf("update prepcachetest failed, error '%v'", err) - } - - //generate a delete statement to test they are prepared - err = session.Query("DELETE FROM prepcachetest WHERE id = ?", 1).Exec() - if err != nil { - t.Fatalf("delete from prepcachetest failed, error '%v'", err) - } - - //generate an insert statement to test they are prepared - err = session.Query("INSERT INTO prepcachetest (id,mod) VALUES (?, ?)", 3, 11).Exec() - if err != nil { - t.Fatalf("insert into prepcachetest failed, error '%v'", err) - } - - stmtsLRU.Lock() - - //Make sure the cache size is maintained - if stmtsLRU.lru.Len() != stmtsLRU.lru.MaxEntries { - t.Fatalf("expected cache size of %v, got %v", stmtsLRU.lru.MaxEntries, stmtsLRU.lru.Len()) - } - - //Walk through all the configured hosts and test cache retention and eviction - var selFound, insFound, updFound, delFound, selEvict bool - for i := range session.cfg.Hosts { - _, ok := stmtsLRU.lru.Get(session.cfg.Hosts[i] + ":9042gocql_testSELECT id,mod FROM prepcachetest WHERE id = 1") - selFound = selFound || ok - - _, ok = stmtsLRU.lru.Get(session.cfg.Hosts[i] + ":9042gocql_testINSERT INTO prepcachetest (id,mod) VALUES (?, ?)") - insFound = insFound || ok - - _, ok = stmtsLRU.lru.Get(session.cfg.Hosts[i] + ":9042gocql_testUPDATE prepcachetest SET mod = ? WHERE id = ?") - updFound = updFound || ok - - _, ok = stmtsLRU.lru.Get(session.cfg.Hosts[i] + ":9042gocql_testDELETE FROM prepcachetest WHERE id = ?") - delFound = delFound || ok - - _, ok = stmtsLRU.lru.Get(session.cfg.Hosts[i] + ":9042gocql_testSELECT id,mod FROM prepcachetest WHERE id = 0") - selEvict = selEvict || !ok - } - - stmtsLRU.Unlock() - - if !selEvict { - t.Fatalf("expected first select statement to be purged, but statement was found in the cache.") - } - if !selFound { - t.Fatalf("expected second select statement to be cached, but statement was purged or not prepared.") - } - if !insFound { - t.Fatalf("expected insert statement to be cached, but statement was purged or not prepared.") - } - if !updFound { - t.Fatalf("expected update statement to be cached, but statement was purged or not prepared.") - } - if !delFound { - t.Error("expected delete statement to be cached, but statement was purged or not prepared.") - } -} - -func TestPreparedCacheKey(t *testing.T) { - session := createSession(t) - defer session.Close() - - // create a second keyspace - cluster2 := createCluster() - createKeyspace(t, cluster2, "gocql_test2") - cluster2.Keyspace = "gocql_test2" - session2, err := cluster2.CreateSession() - if err != nil { - t.Fatal("create session:", err) - } - defer session2.Close() - - // both keyspaces have a table named "test_stmt_cache_key" - if err := createTable(session, "CREATE TABLE test_stmt_cache_key (id varchar primary key, field varchar)"); err != nil { - t.Fatal("create table:", err) - } - if err := createTable(session2, "CREATE TABLE test_stmt_cache_key (id varchar primary key, field varchar)"); err != nil { - t.Fatal("create table:", err) - } - - // both tables have a single row with the same partition key but different column value - if err = session.Query(`INSERT INTO test_stmt_cache_key (id, field) VALUES (?, ?)`, "key", "one").Exec(); err != nil { - t.Fatal("insert:", err) - } - if err = session2.Query(`INSERT INTO test_stmt_cache_key (id, field) VALUES (?, ?)`, "key", "two").Exec(); err != nil { - t.Fatal("insert:", err) - } - - // should be able to see different values in each keyspace - var value string - if err = session.Query("SELECT field FROM test_stmt_cache_key WHERE id = ?", "key").Scan(&value); err != nil { - t.Fatal("select:", err) - } - if value != "one" { - t.Errorf("Expected one, got %s", value) - } - - if err = session2.Query("SELECT field FROM test_stmt_cache_key WHERE id = ?", "key").Scan(&value); err != nil { - t.Fatal("select:", err) - } - if value != "two" { - t.Errorf("Expected two, got %s", value) - } -} - -//TestMarshalFloat64Ptr tests to see that a pointer to a float64 is marshalled correctly. -func TestMarshalFloat64Ptr(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE float_test (id double, test double, primary key (id))"); err != nil { - t.Fatal("create table:", err) - } - testNum := float64(7500) - if err := session.Query(`INSERT INTO float_test (id,test) VALUES (?,?)`, float64(7500.00), &testNum).Exec(); err != nil { - t.Fatal("insert float64:", err) - } -} - -//TestMarshalInet tests to see that a pointer to a float64 is marshalled correctly. -func TestMarshalInet(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE inet_test (ip inet, name text, primary key (ip))"); err != nil { - t.Fatal("create table:", err) - } - stringIp := "123.34.45.56" - if err := session.Query(`INSERT INTO inet_test (ip,name) VALUES (?,?)`, stringIp, "Test IP 1").Exec(); err != nil { - t.Fatal("insert string inet:", err) - } - var stringResult string - if err := session.Query("SELECT ip FROM inet_test").Scan(&stringResult); err != nil { - t.Fatalf("select for string from inet_test 1 failed: %v", err) - } - if stringResult != stringIp { - t.Errorf("Expected %s, was %s", stringIp, stringResult) - } - - var ipResult net.IP - if err := session.Query("SELECT ip FROM inet_test").Scan(&ipResult); err != nil { - t.Fatalf("select for net.IP from inet_test 1 failed: %v", err) - } - if ipResult.String() != stringIp { - t.Errorf("Expected %s, was %s", stringIp, ipResult.String()) - } - - if err := session.Query(`DELETE FROM inet_test WHERE ip = ?`, stringIp).Exec(); err != nil { - t.Fatal("delete inet table:", err) - } - - netIp := net.ParseIP("222.43.54.65") - if err := session.Query(`INSERT INTO inet_test (ip,name) VALUES (?,?)`, netIp, "Test IP 2").Exec(); err != nil { - t.Fatal("insert netIp inet:", err) - } - - if err := session.Query("SELECT ip FROM inet_test").Scan(&stringResult); err != nil { - t.Fatalf("select for string from inet_test 2 failed: %v", err) - } - if stringResult != netIp.String() { - t.Errorf("Expected %s, was %s", netIp.String(), stringResult) - } - if err := session.Query("SELECT ip FROM inet_test").Scan(&ipResult); err != nil { - t.Fatalf("select for net.IP from inet_test 2 failed: %v", err) - } - if ipResult.String() != netIp.String() { - t.Errorf("Expected %s, was %s", netIp.String(), ipResult.String()) - } - -} - -func TestVarint(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE varint_test (id varchar, test varint, test2 varint, primary key (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - if err := session.Query(`INSERT INTO varint_test (id, test) VALUES (?, ?)`, "id", 0).Exec(); err != nil { - t.Fatalf("insert varint: %v", err) - } - - var result int - if err := session.Query("SELECT test FROM varint_test").Scan(&result); err != nil { - t.Fatalf("select from varint_test failed: %v", err) - } - - if result != 0 { - t.Errorf("Expected 0, was %d", result) - } - - if err := session.Query(`INSERT INTO varint_test (id, test) VALUES (?, ?)`, "id", -1).Exec(); err != nil { - t.Fatalf("insert varint: %v", err) - } - - if err := session.Query("SELECT test FROM varint_test").Scan(&result); err != nil { - t.Fatalf("select from varint_test failed: %v", err) - } - - if result != -1 { - t.Errorf("Expected -1, was %d", result) - } - - if err := session.Query(`INSERT INTO varint_test (id, test) VALUES (?, ?)`, "id", int64(math.MaxInt32)+1).Exec(); err != nil { - t.Fatalf("insert varint: %v", err) - } - - var result64 int64 - if err := session.Query("SELECT test FROM varint_test").Scan(&result64); err != nil { - t.Fatalf("select from varint_test failed: %v", err) - } - - if result64 != int64(math.MaxInt32)+1 { - t.Errorf("Expected %d, was %d", int64(math.MaxInt32)+1, result64) - } - - biggie := new(big.Int) - biggie.SetString("36893488147419103232", 10) // > 2**64 - if err := session.Query(`INSERT INTO varint_test (id, test) VALUES (?, ?)`, "id", biggie).Exec(); err != nil { - t.Fatalf("insert varint: %v", err) - } - - resultBig := new(big.Int) - if err := session.Query("SELECT test FROM varint_test").Scan(resultBig); err != nil { - t.Fatalf("select from varint_test failed: %v", err) - } - - if resultBig.String() != biggie.String() { - t.Errorf("Expected %s, was %s", biggie.String(), resultBig.String()) - } - - err := session.Query("SELECT test FROM varint_test").Scan(&result64) - if err == nil || strings.Index(err.Error(), "out of range") == -1 { - t.Errorf("expected out of range error since value is too big for int64") - } - - // value not set in cassandra, leave bind variable empty - resultBig = new(big.Int) - if err := session.Query("SELECT test2 FROM varint_test").Scan(resultBig); err != nil { - t.Fatalf("select from varint_test failed: %v", err) - } - - if resultBig.Int64() != 0 { - t.Errorf("Expected %s, was %s", biggie.String(), resultBig.String()) - } - - // can use double pointer to explicitly detect value is not set in cassandra - if err := session.Query("SELECT test2 FROM varint_test").Scan(&resultBig); err != nil { - t.Fatalf("select from varint_test failed: %v", err) - } - - if resultBig != nil { - t.Errorf("Expected %v, was %v", nil, *resultBig) - } -} - -//TestQueryStats confirms that the stats are returning valid data. Accuracy may be questionable. -func TestQueryStats(t *testing.T) { - session := createSession(t) - defer session.Close() - qry := session.Query("SELECT * FROM system.peers") - if err := qry.Exec(); err != nil { - t.Fatalf("query failed. %v", err) - } else { - if qry.Attempts() < 1 { - t.Fatal("expected at least 1 attempt, but got 0") - } - if qry.Latency() <= 0 { - t.Fatalf("expected latency to be greater than 0, but got %v instead.", qry.Latency()) - } - } -} - -//TestBatchStats confirms that the stats are returning valid data. Accuracy may be questionable. -func TestBatchStats(t *testing.T) { - if *flagProto == 1 { - t.Skip("atomic batches not supported. Please use Cassandra >= 2.0") - } - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE batchStats (id int, PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - b := session.NewBatch(LoggedBatch) - b.Query("INSERT INTO batchStats (id) VALUES (?)", 1) - b.Query("INSERT INTO batchStats (id) VALUES (?)", 2) - - if err := session.ExecuteBatch(b); err != nil { - t.Fatalf("query failed. %v", err) - } else { - if b.Attempts() < 1 { - t.Fatal("expected at least 1 attempt, but got 0") - } - if b.Latency() <= 0 { - t.Fatalf("expected latency to be greater than 0, but got %v instead.", b.Latency()) - } - } -} - -//TestNilInQuery tests to see that a nil value passed to a query is handled by Cassandra -//TODO validate the nil value by reading back the nil. Need to fix Unmarshalling. -func TestNilInQuery(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE testNilInsert (id int, count int, PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - if err := session.Query("INSERT INTO testNilInsert (id,count) VALUES (?,?)", 1, nil).Exec(); err != nil { - t.Fatalf("failed to insert with err: %v", err) - } - - var id int - - if err := session.Query("SELECT id FROM testNilInsert").Scan(&id); err != nil { - t.Fatalf("failed to select with err: %v", err) - } else if id != 1 { - t.Fatalf("expected id to be 1, got %v", id) - } -} - -// Don't initialize time.Time bind variable if cassandra timestamp column is empty -func TestEmptyTimestamp(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE test_empty_timestamp (id int, time timestamp, num int, PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - if err := session.Query("INSERT INTO test_empty_timestamp (id, num) VALUES (?,?)", 1, 561).Exec(); err != nil { - t.Fatalf("failed to insert with err: %v", err) - } - - var timeVal time.Time - - if err := session.Query("SELECT time FROM test_empty_timestamp where id = ?", 1).Scan(&timeVal); err != nil { - t.Fatalf("failed to select with err: %v", err) - } - - if !timeVal.IsZero() { - t.Errorf("time.Time bind variable should still be empty (was %s)", timeVal) - } -} - -// Integration test of just querying for data from the system.schema_keyspace table -func TestGetKeyspaceMetadata(t *testing.T) { - session := createSession(t) - defer session.Close() - - keyspaceMetadata, err := getKeyspaceMetadata(session, "gocql_test") - if err != nil { - t.Fatalf("failed to query the keyspace metadata with err: %v", err) - } - if keyspaceMetadata == nil { - t.Fatal("failed to query the keyspace metadata, nil returned") - } - if keyspaceMetadata.Name != "gocql_test" { - t.Errorf("Expected keyspace name to be 'gocql' but was '%s'", keyspaceMetadata.Name) - } - if keyspaceMetadata.StrategyClass != "org.apache.cassandra.locator.SimpleStrategy" { - t.Errorf("Expected replication strategy class to be 'org.apache.cassandra.locator.SimpleStrategy' but was '%s'", keyspaceMetadata.StrategyClass) - } - if keyspaceMetadata.StrategyOptions == nil { - t.Error("Expected replication strategy options map but was nil") - } - rfStr, ok := keyspaceMetadata.StrategyOptions["replication_factor"] - if !ok { - t.Fatalf("Expected strategy option 'replication_factor' but was not found in %v", keyspaceMetadata.StrategyOptions) - } - rfInt, err := strconv.Atoi(rfStr.(string)) - if err != nil { - t.Fatalf("Error converting string to int with err: %v", err) - } - if rfInt != *flagRF { - t.Errorf("Expected replication factor to be %d but was %d", *flagRF, rfInt) - } -} - -// Integration test of just querying for data from the system.schema_columnfamilies table -func TestGetTableMetadata(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE test_table_metadata (first_id int, second_id int, third_id int, PRIMARY KEY (first_id, second_id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - tables, err := getTableMetadata(session, "gocql_test") - if err != nil { - t.Fatalf("failed to query the table metadata with err: %v", err) - } - if tables == nil { - t.Fatal("failed to query the table metadata, nil returned") - } - - var testTable *TableMetadata - - // verify all tables have minimum expected data - for i := range tables { - table := &tables[i] - - if table.Name == "" { - t.Errorf("Expected table name to be set, but it was empty: index=%d metadata=%+v", i, table) - } - if table.Keyspace != "gocql_test" { - t.Errorf("Expected keyspace for '%d' table metadata to be 'gocql_test' but was '%s'", table.Name, table.Keyspace) - } - if table.KeyValidator == "" { - t.Errorf("Expected key validator to be set for table %s", table.Name) - } - if table.Comparator == "" { - t.Errorf("Expected comparator to be set for table %s", table.Name) - } - if table.DefaultValidator == "" { - t.Errorf("Expected default validator to be set for table %s", table.Name) - } - - // these fields are not set until the metadata is compiled - if table.PartitionKey != nil { - t.Errorf("Did not expect partition key for table %s", table.Name) - } - if table.ClusteringColumns != nil { - t.Errorf("Did not expect clustering columns for table %s", table.Name) - } - if table.Columns != nil { - t.Errorf("Did not expect columns for table %s", table.Name) - } - - // for the next part of the test after this loop, find the metadata for the test table - if table.Name == "test_table_metadata" { - testTable = table - } - } - - // verify actual values on the test tables - if testTable == nil { - t.Fatal("Expected table metadata for name 'test_table_metadata'") - } - if testTable.KeyValidator != "org.apache.cassandra.db.marshal.Int32Type" { - t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.Int32Type' but was '%s'", testTable.KeyValidator) - } - if testTable.Comparator != "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type)" { - t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type)' but was '%s'", testTable.Comparator) - } - if testTable.DefaultValidator != "org.apache.cassandra.db.marshal.BytesType" { - t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.BytesType' but was '%s'", testTable.DefaultValidator) - } - expectedKeyAliases := []string{"first_id"} - if !reflect.DeepEqual(testTable.KeyAliases, expectedKeyAliases) { - t.Errorf("Expected key aliases %v but was %v", expectedKeyAliases, testTable.KeyAliases) - } - expectedColumnAliases := []string{"second_id"} - if !reflect.DeepEqual(testTable.ColumnAliases, expectedColumnAliases) { - t.Errorf("Expected key aliases %v but was %v", expectedColumnAliases, testTable.ColumnAliases) - } - if testTable.ValueAlias != "" { - t.Errorf("Expected value alias '' but was '%s'", testTable.ValueAlias) - } -} - -// Integration test of just querying for data from the system.schema_columns table -func TestGetColumnMetadata(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE test_column_metadata (first_id int, second_id int, third_id int, PRIMARY KEY (first_id, second_id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - if err := session.Query("CREATE INDEX index_column_metadata ON test_column_metadata ( third_id )").Exec(); err != nil { - t.Fatalf("failed to create index with err: %v", err) - } - - columns, err := getColumnMetadata(session, "gocql_test") - if err != nil { - t.Fatalf("failed to query column metadata with err: %v", err) - } - if columns == nil { - t.Fatal("failed to query column metadata, nil returned") - } - - testColumns := map[string]*ColumnMetadata{} - - // verify actual values on the test columns - for i := range columns { - column := &columns[i] - - if column.Name == "" { - t.Errorf("Expected column name to be set, but it was empty: index=%d metadata=%+v", i, column) - } - if column.Table == "" { - t.Errorf("Expected column %s table name to be set, but it was empty", column.Name) - } - if column.Keyspace != "gocql_test" { - t.Errorf("Expected column %s keyspace name to be 'gocql_test', but it was '%s'", column.Name, column.Keyspace) - } - if column.Kind == "" { - t.Errorf("Expected column %s kind to be set, but it was empty", column.Name) - } - if session.cfg.ProtoVersion == 1 && column.Kind != "regular" { - t.Errorf("Expected column %s kind to be set to 'regular' for proto V1 but it was '%s'", column.Name, column.Kind) - } - if column.Validator == "" { - t.Errorf("Expected column %s validator to be set, but it was empty", column.Name) - } - - // find the test table columns for the next step after this loop - if column.Table == "test_column_metadata" { - testColumns[column.Name] = column - } - } - - if *flagProto == 1 { - // V1 proto only returns "regular columns" - if len(testColumns) != 1 { - t.Errorf("Expected 1 test columns but there were %d", len(testColumns)) - } - thirdID, found := testColumns["third_id"] - if !found { - t.Fatalf("Expected to find column 'third_id' metadata but there was only %v", testColumns) - } - - if thirdID.Kind != REGULAR { - t.Errorf("Expected %s column kind to be '%s' but it was '%s'", thirdID.Name, REGULAR, thirdID.Kind) - } - - if thirdID.Index.Name != "index_column_metadata" { - t.Errorf("Expected %s column index name to be 'index_column_metadata' but it was '%s'", thirdID.Name, thirdID.Index.Name) - } - } else { - if len(testColumns) != 3 { - t.Errorf("Expected 3 test columns but there were %d", len(testColumns)) - } - firstID, found := testColumns["first_id"] - if !found { - t.Fatalf("Expected to find column 'first_id' metadata but there was only %v", testColumns) - } - secondID, found := testColumns["second_id"] - if !found { - t.Fatalf("Expected to find column 'second_id' metadata but there was only %v", testColumns) - } - thirdID, found := testColumns["third_id"] - if !found { - t.Fatalf("Expected to find column 'third_id' metadata but there was only %v", testColumns) - } - - if firstID.Kind != PARTITION_KEY { - t.Errorf("Expected %s column kind to be '%s' but it was '%s'", firstID.Name, PARTITION_KEY, firstID.Kind) - } - if secondID.Kind != CLUSTERING_KEY { - t.Errorf("Expected %s column kind to be '%s' but it was '%s'", secondID.Name, CLUSTERING_KEY, secondID.Kind) - } - if thirdID.Kind != REGULAR { - t.Errorf("Expected %s column kind to be '%s' but it was '%s'", thirdID.Name, REGULAR, thirdID.Kind) - } - - if thirdID.Index.Name != "index_column_metadata" { - t.Errorf("Expected %s column index name to be 'index_column_metadata' but it was '%s'", thirdID.Name, thirdID.Index.Name) - } - } -} - -// Integration test of querying and composition the keyspace metadata -func TestKeyspaceMetadata(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE test_metadata (first_id int, second_id int, third_id int, PRIMARY KEY (first_id, second_id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - if err := session.Query("CREATE INDEX index_metadata ON test_metadata ( third_id )").Exec(); err != nil { - t.Fatalf("failed to create index with err: %v", err) - } - - keyspaceMetadata, err := session.KeyspaceMetadata("gocql_test") - if err != nil { - t.Fatalf("failed to query keyspace metadata with err: %v", err) - } - if keyspaceMetadata == nil { - t.Fatal("expected the keyspace metadata to not be nil, but it was nil") - } - if keyspaceMetadata.Name != session.cfg.Keyspace { - t.Fatalf("Expected the keyspace name to be %s but was %s", session.cfg.Keyspace, keyspaceMetadata.Name) - } - if len(keyspaceMetadata.Tables) == 0 { - t.Errorf("Expected tables but there were none") - } - - tableMetadata, found := keyspaceMetadata.Tables["test_metadata"] - if !found { - t.Fatalf("failed to find the test_metadata table metadata") - } - - if len(tableMetadata.PartitionKey) != 1 { - t.Errorf("expected partition key length of 1, but was %d", len(tableMetadata.PartitionKey)) - } - for i, column := range tableMetadata.PartitionKey { - if column == nil { - t.Errorf("partition key column metadata at index %d was nil", i) - } - } - if tableMetadata.PartitionKey[0].Name != "first_id" { - t.Errorf("Expected the first partition key column to be 'first_id' but was '%s'", tableMetadata.PartitionKey[0].Name) - } - if len(tableMetadata.ClusteringColumns) != 1 { - t.Fatalf("expected clustering columns length of 1, but was %d", len(tableMetadata.ClusteringColumns)) - } - for i, column := range tableMetadata.ClusteringColumns { - if column == nil { - t.Fatalf("clustering column metadata at index %d was nil", i) - } - } - if tableMetadata.ClusteringColumns[0].Name != "second_id" { - t.Errorf("Expected the first clustering column to be 'second_id' but was '%s'", tableMetadata.ClusteringColumns[0].Name) - } - thirdColumn, found := tableMetadata.Columns["third_id"] - if !found { - t.Fatalf("Expected a column definition for 'third_id'") - } - if thirdColumn.Index.Name != "index_metadata" { - t.Errorf("Expected column index named 'index_metadata' but was '%s'", thirdColumn.Index.Name) - } -} - -// Integration test of the routing key calculation -func TestRoutingKey(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, "CREATE TABLE test_single_routing_key (first_id int, second_id int, PRIMARY KEY (first_id, second_id))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - if err := createTable(session, "CREATE TABLE test_composite_routing_key (first_id int, second_id int, PRIMARY KEY ((first_id, second_id)))"); err != nil { - t.Fatalf("failed to create table with error '%v'", err) - } - - routingKeyInfo, err := session.routingKeyInfo("SELECT * FROM test_single_routing_key WHERE second_id=? AND first_id=?") - if err != nil { - t.Fatalf("failed to get routing key info due to error: %v", err) - } - if routingKeyInfo == nil { - t.Fatal("Expected routing key info, but was nil") - } - if len(routingKeyInfo.indexes) != 1 { - t.Fatalf("Expected routing key indexes length to be 1 but was %d", len(routingKeyInfo.indexes)) - } - if routingKeyInfo.indexes[0] != 1 { - t.Errorf("Expected routing key index[0] to be 1 but was %d", routingKeyInfo.indexes[0]) - } - if len(routingKeyInfo.types) != 1 { - t.Fatalf("Expected routing key types length to be 1 but was %d", len(routingKeyInfo.types)) - } - if routingKeyInfo.types[0] == nil { - t.Fatal("Expected routing key types[0] to be non-nil") - } - if routingKeyInfo.types[0].Type() != TypeInt { - t.Fatalf("Expected routing key types[0].Type to be %v but was %v", TypeInt, routingKeyInfo.types[0].Type()) - } - - // verify the cache is working - routingKeyInfo, err = session.routingKeyInfo("SELECT * FROM test_single_routing_key WHERE second_id=? AND first_id=?") - if err != nil { - t.Fatalf("failed to get routing key info due to error: %v", err) - } - if len(routingKeyInfo.indexes) != 1 { - t.Fatalf("Expected routing key indexes length to be 1 but was %d", len(routingKeyInfo.indexes)) - } - if routingKeyInfo.indexes[0] != 1 { - t.Errorf("Expected routing key index[0] to be 1 but was %d", routingKeyInfo.indexes[0]) - } - if len(routingKeyInfo.types) != 1 { - t.Fatalf("Expected routing key types length to be 1 but was %d", len(routingKeyInfo.types)) - } - if routingKeyInfo.types[0] == nil { - t.Fatal("Expected routing key types[0] to be non-nil") - } - if routingKeyInfo.types[0].Type() != TypeInt { - t.Fatalf("Expected routing key types[0] to be %v but was %v", TypeInt, routingKeyInfo.types[0].Type()) - } - cacheSize := session.routingKeyInfoCache.lru.Len() - if cacheSize != 1 { - t.Errorf("Expected cache size to be 1 but was %d", cacheSize) - } - - query := session.Query("SELECT * FROM test_single_routing_key WHERE second_id=? AND first_id=?", 1, 2) - routingKey, err := query.GetRoutingKey() - if err != nil { - t.Fatalf("Failed to get routing key due to error: %v", err) - } - expectedRoutingKey := []byte{0, 0, 0, 2} - if !reflect.DeepEqual(expectedRoutingKey, routingKey) { - t.Errorf("Expected routing key %v but was %v", expectedRoutingKey, routingKey) - } - - routingKeyInfo, err = session.routingKeyInfo("SELECT * FROM test_composite_routing_key WHERE second_id=? AND first_id=?") - if err != nil { - t.Fatalf("failed to get routing key info due to error: %v", err) - } - if routingKeyInfo == nil { - t.Fatal("Expected routing key info, but was nil") - } - if len(routingKeyInfo.indexes) != 2 { - t.Fatalf("Expected routing key indexes length to be 2 but was %d", len(routingKeyInfo.indexes)) - } - if routingKeyInfo.indexes[0] != 1 { - t.Errorf("Expected routing key index[0] to be 1 but was %d", routingKeyInfo.indexes[0]) - } - if routingKeyInfo.indexes[1] != 0 { - t.Errorf("Expected routing key index[1] to be 0 but was %d", routingKeyInfo.indexes[1]) - } - if len(routingKeyInfo.types) != 2 { - t.Fatalf("Expected routing key types length to be 1 but was %d", len(routingKeyInfo.types)) - } - if routingKeyInfo.types[0] == nil { - t.Fatal("Expected routing key types[0] to be non-nil") - } - if routingKeyInfo.types[0].Type() != TypeInt { - t.Fatalf("Expected routing key types[0] to be %v but was %v", TypeInt, routingKeyInfo.types[0].Type()) - } - if routingKeyInfo.types[1] == nil { - t.Fatal("Expected routing key types[1] to be non-nil") - } - if routingKeyInfo.types[1].Type() != TypeInt { - t.Fatalf("Expected routing key types[0] to be %v but was %v", TypeInt, routingKeyInfo.types[1].Type()) - } - - query = session.Query("SELECT * FROM test_composite_routing_key WHERE second_id=? AND first_id=?", 1, 2) - routingKey, err = query.GetRoutingKey() - if err != nil { - t.Fatalf("Failed to get routing key due to error: %v", err) - } - expectedRoutingKey = []byte{0, 4, 0, 0, 0, 2, 0, 0, 4, 0, 0, 0, 1, 0} - if !reflect.DeepEqual(expectedRoutingKey, routingKey) { - t.Errorf("Expected routing key %v but was %v", expectedRoutingKey, routingKey) - } - - // verify the cache is working - cacheSize = session.routingKeyInfoCache.lru.Len() - if cacheSize != 2 { - t.Errorf("Expected cache size to be 2 but was %d", cacheSize) - } -} - -// Integration test of the token-aware policy-based connection pool -func TestTokenAwareConnPool(t *testing.T) { - cluster := createCluster() - cluster.ConnPoolType = NewTokenAwareConnPool - cluster.DiscoverHosts = true - - // Drop and re-create the keyspace once. Different tests should use their own - // individual tables, but can assume that the table does not exist before. - initOnce.Do(func() { - createKeyspace(t, cluster, "gocql_test") - }) - - cluster.Keyspace = "gocql_test" - session, err := cluster.CreateSession() - if err != nil { - t.Fatal("createSession:", err) - } - defer session.Close() - - if *clusterSize > 1 { - // wait for autodiscovery to update the pool with the list of known hosts - time.Sleep(*flagAutoWait) - } - - if session.Pool.Size() != cluster.NumConns*len(cluster.Hosts) { - t.Errorf("Expected pool size %d but was %d", cluster.NumConns*len(cluster.Hosts), session.Pool.Size()) - } - - if err := createTable(session, "CREATE TABLE test_token_aware (id int, data text, PRIMARY KEY (id))"); err != nil { - t.Fatalf("failed to create test_token_aware table with err: %v", err) - } - query := session.Query("INSERT INTO test_token_aware (id, data) VALUES (?,?)", 42, "8 * 6 =") - if err := query.Exec(); err != nil { - t.Fatalf("failed to insert with err: %v", err) - } - query = session.Query("SELECT data FROM test_token_aware where id = ?", 42).Consistency(One) - iter := query.Iter() - var data string - if !iter.Scan(&data) { - t.Error("failed to scan data") - } - if err := iter.Close(); err != nil { - t.Errorf("iter failed with err: %v", err) - } - - // TODO add verification that the query went to the correct host -} - -type frameWriterFunc func(framer *framer, streamID int) error - -func (f frameWriterFunc) writeFrame(framer *framer, streamID int) error { - return f(framer, streamID) -} - -func TestStream0(t *testing.T) { - session := createSession(t) - defer session.Close() - - var conn *Conn - for i := 0; i < 5; i++ { - if conn != nil { - break - } - - conn = session.Pool.Pick(nil) - } - - if conn == nil { - t.Fatal("no connections available in the pool") - } - - writer := frameWriterFunc(func(f *framer, streamID int) error { - if streamID == 0 { - t.Fatal("should not use stream 0 for requests") - } - f.writeHeader(0, opError, streamID) - f.writeString("i am a bad frame") - f.wbuf[0] = 0xFF - return f.finishWrite() - }) - - const expErr = "gocql: error on stream 0:" - // need to write out an invalid frame, which we need a connection to do - frame, err := conn.exec(writer, nil) - if err == nil { - t.Fatal("expected to get an error on stream 0") - } else if !strings.HasPrefix(err.Error(), expErr) { - t.Fatalf("expected to get error prefix %q got %q", expErr, err.Error()) - } else if frame != nil { - t.Fatalf("expected to get nil frame got %+v", frame) - } -} - -func TestNegativeStream(t *testing.T) { - session := createSession(t) - defer session.Close() - - var conn *Conn - for i := 0; i < 5; i++ { - if conn != nil { - break - } - - conn = session.Pool.Pick(nil) - } - - if conn == nil { - t.Fatal("no connections available in the pool") - } - - const stream = -50 - writer := frameWriterFunc(func(f *framer, streamID int) error { - f.writeHeader(0, opOptions, stream) - return f.finishWrite() - }) - - frame, err := conn.exec(writer, nil) - if err == nil { - t.Fatalf("expected to get an error on stream %d", stream) - } else if frame != nil { - t.Fatalf("expected to get nil frame got %+v", frame) - } -} diff --git a/vendor/github.com/gocql/gocql/cluster.go b/vendor/github.com/gocql/gocql/cluster.go deleted file mode 100644 index 94b1bc486..000000000 --- a/vendor/github.com/gocql/gocql/cluster.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "errors" - "sync" - "time" - - "github.com/golang/groupcache/lru" -) - -const defaultMaxPreparedStmts = 1000 - -//Package global reference to Prepared Statements LRU -var stmtsLRU preparedLRU - -//preparedLRU is the prepared statement cache -type preparedLRU struct { - sync.Mutex - lru *lru.Cache -} - -//Max adjusts the maximum size of the cache and cleans up the oldest records if -//the new max is lower than the previous value. Not concurrency safe. -func (p *preparedLRU) Max(max int) { - for p.lru.Len() > max { - p.lru.RemoveOldest() - } - p.lru.MaxEntries = max -} - -func initStmtsLRU(max int) { - if stmtsLRU.lru != nil { - stmtsLRU.Max(max) - } else { - stmtsLRU.lru = lru.New(max) - } -} - -// To enable periodic node discovery enable DiscoverHosts in ClusterConfig -type DiscoveryConfig struct { - // If not empty will filter all discoverred hosts to a single Data Centre (default: "") - DcFilter string - // If not empty will filter all discoverred hosts to a single Rack (default: "") - RackFilter string - // The interval to check for new hosts (default: 30s) - Sleep time.Duration -} - -// ClusterConfig is a struct to configure the default cluster implementation -// of gocoql. It has a varity of attributes that can be used to modify the -// behavior to fit the most common use cases. Applications that requre a -// different setup must implement their own cluster. -type ClusterConfig struct { - Hosts []string // addresses for the initial connections - CQLVersion string // CQL version (default: 3.0.0) - ProtoVersion int // version of the native protocol (default: 2) - Timeout time.Duration // connection timeout (default: 600ms) - Port int // port (default: 9042) - Keyspace string // initial keyspace (optional) - NumConns int // number of connections per host (default: 2) - NumStreams int // number of streams per connection (default: max per protocol, either 128 or 32768) - Consistency Consistency // default consistency level (default: Quorum) - Compressor Compressor // compression algorithm (default: nil) - Authenticator Authenticator // authenticator (default: nil) - RetryPolicy RetryPolicy // Default retry policy to use for queries (default: 0) - SocketKeepalive time.Duration // The keepalive period to use, enabled if > 0 (default: 0) - ConnPoolType NewPoolFunc // The function used to create the connection pool for the session (default: NewSimplePool) - DiscoverHosts bool // If set, gocql will attempt to automatically discover other members of the Cassandra cluster (default: false) - MaxPreparedStmts int // Sets the maximum cache size for prepared statements globally for gocql (default: 1000) - MaxRoutingKeyInfo int // Sets the maximum cache size for query info about statements for each session (default: 1000) - PageSize int // Default page size to use for created sessions (default: 5000) - SerialConsistency SerialConsistency // Sets the consistency for the serial part of queries, values can be either SERIAL or LOCAL_SERIAL (default: unset) - Discovery DiscoveryConfig - SslOpts *SslOptions - DefaultTimestamp bool // Sends a client side timestamp for all requests which overrides the timestamp at which it arrives at the server. (default: true, only enabled for protocol 3 and above) -} - -// NewCluster generates a new config for the default cluster implementation. -func NewCluster(hosts ...string) *ClusterConfig { - cfg := &ClusterConfig{ - Hosts: hosts, - CQLVersion: "3.0.0", - ProtoVersion: 2, - Timeout: 600 * time.Millisecond, - Port: 9042, - NumConns: 2, - Consistency: Quorum, - ConnPoolType: NewSimplePool, - DiscoverHosts: false, - MaxPreparedStmts: defaultMaxPreparedStmts, - MaxRoutingKeyInfo: 1000, - PageSize: 5000, - DefaultTimestamp: true, - } - return cfg -} - -// CreateSession initializes the cluster based on this config and returns a -// session object that can be used to interact with the database. -func (cfg *ClusterConfig) CreateSession() (*Session, error) { - return NewSession(*cfg) -} - -var ( - ErrNoHosts = errors.New("no hosts provided") - ErrNoConnectionsStarted = errors.New("no connections were made when creating the session") - ErrHostQueryFailed = errors.New("unable to populate Hosts") -) diff --git a/vendor/github.com/gocql/gocql/compressor.go b/vendor/github.com/gocql/gocql/compressor.go deleted file mode 100644 index 26853ae7f..000000000 --- a/vendor/github.com/gocql/gocql/compressor.go +++ /dev/null @@ -1,28 +0,0 @@ -package gocql - -import ( - "github.com/golang/snappy" -) - -type Compressor interface { - Name() string - Encode(data []byte) ([]byte, error) - Decode(data []byte) ([]byte, error) -} - -// SnappyCompressor implements the Compressor interface and can be used to -// compress incoming and outgoing frames. The snappy compression algorithm -// aims for very high speeds and reasonable compression. -type SnappyCompressor struct{} - -func (s SnappyCompressor) Name() string { - return "snappy" -} - -func (s SnappyCompressor) Encode(data []byte) ([]byte, error) { - return snappy.Encode(nil, data), nil -} - -func (s SnappyCompressor) Decode(data []byte) ([]byte, error) { - return snappy.Decode(nil, data) -} diff --git a/vendor/github.com/gocql/gocql/compressor_test.go b/vendor/github.com/gocql/gocql/compressor_test.go deleted file mode 100644 index cbf16a468..000000000 --- a/vendor/github.com/gocql/gocql/compressor_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build all unit - -package gocql - -import ( - "bytes" - "testing" - - "github.com/golang/snappy" -) - -func TestSnappyCompressor(t *testing.T) { - c := SnappyCompressor{} - if c.Name() != "snappy" { - t.Fatalf("expected name to be 'snappy', got %v", c.Name()) - } - - str := "My Test String" - //Test Encoding - expected := snappy.Encode(nil, []byte(str)) - if res, err := c.Encode([]byte(str)); err != nil { - t.Fatalf("failed to encode '%v' with error %v", str, err) - } else if bytes.Compare(expected, res) != 0 { - t.Fatal("failed to match the expected encoded value with the result encoded value.") - } - - val, err := c.Encode([]byte(str)) - if err != nil { - t.Fatalf("failed to encode '%v' with error '%v'", str, err) - } - - //Test Decoding - if expected, err := snappy.Decode(nil, val); err != nil { - t.Fatalf("failed to decode '%v' with error %v", val, err) - } else if res, err := c.Decode(val); err != nil { - t.Fatalf("failed to decode '%v' with error %v", val, err) - } else if bytes.Compare(expected, res) != 0 { - t.Fatal("failed to match the expected decoded value with the result decoded value.") - } -} diff --git a/vendor/github.com/gocql/gocql/conn.go b/vendor/github.com/gocql/gocql/conn.go deleted file mode 100644 index cec77c3f6..000000000 --- a/vendor/github.com/gocql/gocql/conn.go +++ /dev/null @@ -1,824 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "bufio" - "crypto/tls" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" -) - -//JoinHostPort is a utility to return a address string that can be used -//gocql.Conn to form a connection with a host. -func JoinHostPort(addr string, port int) string { - addr = strings.TrimSpace(addr) - if _, _, err := net.SplitHostPort(addr); err != nil { - addr = net.JoinHostPort(addr, strconv.Itoa(port)) - } - return addr -} - -type Authenticator interface { - Challenge(req []byte) (resp []byte, auth Authenticator, err error) - Success(data []byte) error -} - -type PasswordAuthenticator struct { - Username string - Password string -} - -func (p PasswordAuthenticator) Challenge(req []byte) ([]byte, Authenticator, error) { - if string(req) != "org.apache.cassandra.auth.PasswordAuthenticator" { - return nil, nil, fmt.Errorf("unexpected authenticator %q", req) - } - resp := make([]byte, 2+len(p.Username)+len(p.Password)) - resp[0] = 0 - copy(resp[1:], p.Username) - resp[len(p.Username)+1] = 0 - copy(resp[2+len(p.Username):], p.Password) - return resp, nil, nil -} - -func (p PasswordAuthenticator) Success(data []byte) error { - return nil -} - -type SslOptions struct { - tls.Config - - // CertPath and KeyPath are optional depending on server - // config, but both fields must be omitted to avoid using a - // client certificate - CertPath string - KeyPath string - CaPath string //optional depending on server config - // If you want to verify the hostname and server cert (like a wildcard for cass cluster) then you should turn this on - // This option is basically the inverse of InSecureSkipVerify - // See InSecureSkipVerify in http://golang.org/pkg/crypto/tls/ for more info - EnableHostVerification bool -} - -type ConnConfig struct { - ProtoVersion int - CQLVersion string - Timeout time.Duration - NumStreams int - Compressor Compressor - Authenticator Authenticator - Keepalive time.Duration - tlsConfig *tls.Config -} - -type ConnErrorHandler interface { - HandleError(conn *Conn, err error, closed bool) -} - -// How many timeouts we will allow to occur before the connection is closed -// and restarted. This is to prevent a single query timeout from killing a connection -// which may be serving more queries just fine. -// Default is 10, should not be changed concurrently with queries. -var TimeoutLimit int64 = 10 - -// Conn is a single connection to a Cassandra node. It can be used to execute -// queries, but users are usually advised to use a more reliable, higher -// level API. -type Conn struct { - conn net.Conn - r *bufio.Reader - timeout time.Duration - - headerBuf []byte - - uniq chan int - calls []callReq - - errorHandler ConnErrorHandler - compressor Compressor - auth Authenticator - addr string - version uint8 - currentKeyspace string - started bool - - closed int32 - quit chan struct{} - - timeouts int64 -} - -// Connect establishes a connection to a Cassandra node. -// You must also call the Serve method before you can execute any queries. -func Connect(addr string, cfg ConnConfig, errorHandler ConnErrorHandler) (*Conn, error) { - var ( - err error - conn net.Conn - ) - - dialer := &net.Dialer{ - Timeout: cfg.Timeout, - } - - if cfg.tlsConfig != nil { - // the TLS config is safe to be reused by connections but it must not - // be modified after being used. - conn, err = tls.DialWithDialer(dialer, "tcp", addr, cfg.tlsConfig) - } else { - conn, err = dialer.Dial("tcp", addr) - } - - if err != nil { - return nil, err - } - - // going to default to proto 2 - if cfg.ProtoVersion < protoVersion1 || cfg.ProtoVersion > protoVersion3 { - log.Printf("unsupported protocol version: %d using 2\n", cfg.ProtoVersion) - cfg.ProtoVersion = 2 - } - - headerSize := 8 - - maxStreams := 128 - if cfg.ProtoVersion > protoVersion2 { - maxStreams = 32768 - headerSize = 9 - } - - if cfg.NumStreams <= 0 || cfg.NumStreams >= maxStreams { - cfg.NumStreams = maxStreams - } else { - cfg.NumStreams++ - } - - c := &Conn{ - conn: conn, - r: bufio.NewReader(conn), - uniq: make(chan int, cfg.NumStreams), - calls: make([]callReq, cfg.NumStreams), - timeout: cfg.Timeout, - version: uint8(cfg.ProtoVersion), - addr: conn.RemoteAddr().String(), - errorHandler: errorHandler, - compressor: cfg.Compressor, - auth: cfg.Authenticator, - headerBuf: make([]byte, headerSize), - quit: make(chan struct{}), - } - - if cfg.Keepalive > 0 { - c.setKeepalive(cfg.Keepalive) - } - - // reserve stream 0 incase cassandra returns an error on it without us sending - // a request. - for i := 1; i < cfg.NumStreams; i++ { - c.calls[i].resp = make(chan error) - c.uniq <- i - } - - go c.serve() - - if err := c.startup(&cfg); err != nil { - conn.Close() - return nil, err - } - c.started = true - - return c, nil -} - -func (c *Conn) Write(p []byte) (int, error) { - if c.timeout > 0 { - c.conn.SetWriteDeadline(time.Now().Add(c.timeout)) - } - - return c.conn.Write(p) -} - -func (c *Conn) Read(p []byte) (n int, err error) { - const maxAttempts = 5 - - for i := 0; i < maxAttempts; i++ { - var nn int - if c.timeout > 0 { - c.conn.SetReadDeadline(time.Now().Add(c.timeout)) - } - - nn, err = io.ReadFull(c.r, p[n:]) - n += nn - if err == nil { - break - } - - if verr, ok := err.(net.Error); !ok || !verr.Temporary() { - break - } - } - - return -} - -func (c *Conn) startup(cfg *ConnConfig) error { - m := map[string]string{ - "CQL_VERSION": cfg.CQLVersion, - } - - if c.compressor != nil { - m["COMPRESSION"] = c.compressor.Name() - } - - frame, err := c.exec(&writeStartupFrame{opts: m}, nil) - if err != nil { - return err - } - - switch v := frame.(type) { - case error: - return v - case *readyFrame: - return nil - case *authenticateFrame: - return c.authenticateHandshake(v) - default: - return NewErrProtocol("Unknown type of response to startup frame: %s", v) - } -} - -func (c *Conn) authenticateHandshake(authFrame *authenticateFrame) error { - if c.auth == nil { - return fmt.Errorf("authentication required (using %q)", authFrame.class) - } - - resp, challenger, err := c.auth.Challenge([]byte(authFrame.class)) - if err != nil { - return err - } - - req := &writeAuthResponseFrame{data: resp} - - for { - frame, err := c.exec(req, nil) - if err != nil { - return err - } - - switch v := frame.(type) { - case error: - return v - case *authSuccessFrame: - if challenger != nil { - return challenger.Success(v.data) - } - return nil - case *authChallengeFrame: - resp, challenger, err = challenger.Challenge(v.data) - if err != nil { - return err - } - - req = &writeAuthResponseFrame{ - data: resp, - } - default: - return fmt.Errorf("unknown frame response during authentication: %v", v) - } - } -} - -func (c *Conn) closeWithError(err error) { - if !atomic.CompareAndSwapInt32(&c.closed, 0, 1) { - return - } - - if err != nil { - // we should attempt to deliver the error back to the caller if it - // exists - for id := 0; id < len(c.calls); id++ { - req := &c.calls[id] - // we need to send the error to all waiting queries, put the state - // of this conn into not active so that it can not execute any queries. - if err != nil { - select { - case req.resp <- err: - default: - } - } - } - } - - // if error was nil then unblock the quit channel - close(c.quit) - c.conn.Close() - - if c.started && err != nil { - c.errorHandler.HandleError(c, err, true) - } -} - -func (c *Conn) Close() { - c.closeWithError(nil) -} - -// Serve starts the stream multiplexer for this connection, which is required -// to execute any queries. This method runs as long as the connection is -// open and is therefore usually called in a separate goroutine. -func (c *Conn) serve() { - var ( - err error - ) - - for { - err = c.recv() - if err != nil { - break - } - } - - c.closeWithError(err) -} - -func (c *Conn) recv() error { - // not safe for concurrent reads - - // read a full header, ignore timeouts, as this is being ran in a loop - // TODO: TCP level deadlines? or just query level deadlines? - if c.timeout > 0 { - c.conn.SetReadDeadline(time.Time{}) - } - - // were just reading headers over and over and copy bodies - head, err := readHeader(c.r, c.headerBuf) - if err != nil { - return err - } - - if head.stream > len(c.calls) { - return fmt.Errorf("gocql: frame header stream is beyond call exepected bounds: %d", head.stream) - } else if head.stream == -1 { - // TODO: handle cassandra event frames, we shouldnt get any currently - _, err := io.CopyN(ioutil.Discard, c, int64(head.length)) - if err != nil { - return err - } - return nil - } else if head.stream <= 0 { - // reserved stream that we dont use, probably due to a protocol error - // or a bug in Cassandra, this should be an error, parse it and return. - framer := newFramer(c, c, c.compressor, c.version) - if err := framer.readFrame(&head); err != nil { - return err - } - - frame, err := framer.parseFrame() - if err != nil { - return err - } - - switch v := frame.(type) { - case error: - return fmt.Errorf("gocql: error on stream %d: %v", head.stream, v) - default: - return fmt.Errorf("gocql: received frame on stream %d: %v", head.stream, frame) - } - } - - call := &c.calls[head.stream] - err = call.framer.readFrame(&head) - if err != nil { - // only net errors should cause the connection to be closed. Though - // cassandra returning corrupt frames will be returned here as well. - if _, ok := err.(net.Error); ok { - return err - } - } - - // we either, return a response to the caller, the caller timedout, or the - // connection has closed. Either way we should never block indefinatly here - select { - case call.resp <- err: - case <-call.timeout: - c.releaseStream(head.stream) - case <-c.quit: - } - - return nil -} - -type callReq struct { - // could use a waitgroup but this allows us to do timeouts on the read/send - resp chan error - framer *framer - timeout chan struct{} // indicates to recv() that a call has timedout -} - -func (c *Conn) releaseStream(stream int) { - call := &c.calls[stream] - framerPool.Put(call.framer) - call.framer = nil - - select { - case c.uniq <- stream: - case <-c.quit: - } -} - -func (c *Conn) handleTimeout() { - if atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit { - c.closeWithError(ErrTooManyTimeouts) - } -} - -func (c *Conn) exec(req frameWriter, tracer Tracer) (frame, error) { - // TODO: move tracer onto conn - var stream int - select { - case stream = <-c.uniq: - case <-c.quit: - return nil, ErrConnectionClosed - } - - // resp is basically a waiting semaphore protecting the framer - framer := newFramer(c, c, c.compressor, c.version) - call := &c.calls[stream] - call.framer = framer - call.timeout = make(chan struct{}) - - if tracer != nil { - framer.trace() - } - - err := req.writeFrame(framer, stream) - if err != nil { - return nil, err - } - - select { - case err := <-call.resp: - if err != nil { - return nil, err - } - case <-time.After(c.timeout): - close(call.timeout) - c.handleTimeout() - return nil, ErrTimeoutNoResponse - case <-c.quit: - return nil, ErrConnectionClosed - } - - // dont release the stream if detect a timeout as another request can reuse - // that stream and get a response for the old request, which we have no - // easy way of detecting. - // - // Ensure that the stream is not released if there are potentially outstanding - // requests on the stream to prevent nil pointer dereferences in recv(). - defer c.releaseStream(stream) - - if v := framer.header.version.version(); v != c.version { - return nil, NewErrProtocol("unexpected protocol version in response: got %d expected %d", v, c.version) - } - - frame, err := framer.parseFrame() - if err != nil { - return nil, err - } - - if len(framer.traceID) > 0 { - tracer.Trace(framer.traceID) - } - - return frame, nil -} - -func (c *Conn) prepareStatement(stmt string, trace Tracer) (*resultPreparedFrame, error) { - stmtsLRU.Lock() - if stmtsLRU.lru == nil { - initStmtsLRU(defaultMaxPreparedStmts) - } - - stmtCacheKey := c.addr + c.currentKeyspace + stmt - - if val, ok := stmtsLRU.lru.Get(stmtCacheKey); ok { - stmtsLRU.Unlock() - flight := val.(*inflightPrepare) - flight.wg.Wait() - return flight.info, flight.err - } - - flight := new(inflightPrepare) - flight.wg.Add(1) - stmtsLRU.lru.Add(stmtCacheKey, flight) - stmtsLRU.Unlock() - - prep := &writePrepareFrame{ - statement: stmt, - } - - resp, err := c.exec(prep, trace) - if err != nil { - flight.err = err - flight.wg.Done() - return nil, err - } - - switch x := resp.(type) { - case *resultPreparedFrame: - flight.info = x - case error: - flight.err = x - default: - flight.err = NewErrProtocol("Unknown type in response to prepare frame: %s", x) - } - flight.wg.Done() - - if flight.err != nil { - stmtsLRU.Lock() - stmtsLRU.lru.Remove(stmtCacheKey) - stmtsLRU.Unlock() - } - - return flight.info, flight.err -} - -func (c *Conn) executeQuery(qry *Query) *Iter { - params := queryParams{ - consistency: qry.cons, - } - - // frame checks that it is not 0 - params.serialConsistency = qry.serialCons - params.defaultTimestamp = qry.defaultTimestamp - - if len(qry.pageState) > 0 { - params.pagingState = qry.pageState - } - if qry.pageSize > 0 { - params.pageSize = qry.pageSize - } - - var frame frameWriter - if qry.shouldPrepare() { - // Prepare all DML queries. Other queries can not be prepared. - info, err := c.prepareStatement(qry.stmt, qry.trace) - if err != nil { - return &Iter{err: err} - } - - var values []interface{} - - if qry.binding == nil { - values = qry.values - } else { - binding := &QueryInfo{ - Id: info.preparedID, - Args: info.reqMeta.columns, - Rval: info.respMeta.columns, - } - - values, err = qry.binding(binding) - if err != nil { - return &Iter{err: err} - } - } - - if len(values) != len(info.reqMeta.columns) { - return &Iter{err: ErrQueryArgLength} - } - params.values = make([]queryValues, len(values)) - for i := 0; i < len(values); i++ { - val, err := Marshal(info.reqMeta.columns[i].TypeInfo, values[i]) - if err != nil { - return &Iter{err: err} - } - - v := ¶ms.values[i] - v.value = val - // TODO: handle query binding names - } - - frame = &writeExecuteFrame{ - preparedID: info.preparedID, - params: params, - } - } else { - frame = &writeQueryFrame{ - statement: qry.stmt, - params: params, - } - } - - resp, err := c.exec(frame, qry.trace) - if err != nil { - return &Iter{err: err} - } - - switch x := resp.(type) { - case *resultVoidFrame: - return &Iter{} - case *resultRowsFrame: - iter := &Iter{ - meta: x.meta, - rows: x.rows, - } - - if len(x.meta.pagingState) > 0 { - iter.next = &nextIter{ - qry: *qry, - pos: int((1 - qry.prefetch) * float64(len(iter.rows))), - } - - iter.next.qry.pageState = x.meta.pagingState - if iter.next.pos < 1 { - iter.next.pos = 1 - } - } - - return iter - case *resultKeyspaceFrame, *resultSchemaChangeFrame: - return &Iter{} - case *RequestErrUnprepared: - stmtsLRU.Lock() - stmtCacheKey := c.addr + c.currentKeyspace + qry.stmt - if _, ok := stmtsLRU.lru.Get(stmtCacheKey); ok { - stmtsLRU.lru.Remove(stmtCacheKey) - stmtsLRU.Unlock() - return c.executeQuery(qry) - } - stmtsLRU.Unlock() - return &Iter{err: x} - case error: - return &Iter{err: x} - default: - return &Iter{err: NewErrProtocol("Unknown type in response to execute query: %s", x)} - } -} - -func (c *Conn) Pick(qry *Query) *Conn { - if c.Closed() { - return nil - } - return c -} - -func (c *Conn) Closed() bool { - return atomic.LoadInt32(&c.closed) == 1 -} - -func (c *Conn) Address() string { - return c.addr -} - -func (c *Conn) AvailableStreams() int { - return len(c.uniq) -} - -func (c *Conn) UseKeyspace(keyspace string) error { - q := &writeQueryFrame{statement: `USE "` + keyspace + `"`} - q.params.consistency = Any - - resp, err := c.exec(q, nil) - if err != nil { - return err - } - - switch x := resp.(type) { - case *resultKeyspaceFrame: - case error: - return x - default: - return NewErrProtocol("unknown frame in response to USE: %v", x) - } - - c.currentKeyspace = keyspace - - return nil -} - -func (c *Conn) executeBatch(batch *Batch) error { - if c.version == protoVersion1 { - return ErrUnsupported - } - - n := len(batch.Entries) - req := &writeBatchFrame{ - typ: batch.Type, - statements: make([]batchStatment, n), - consistency: batch.Cons, - serialConsistency: batch.serialCons, - defaultTimestamp: batch.defaultTimestamp, - } - - stmts := make(map[string]string) - - for i := 0; i < n; i++ { - entry := &batch.Entries[i] - b := &req.statements[i] - if len(entry.Args) > 0 || entry.binding != nil { - info, err := c.prepareStatement(entry.Stmt, nil) - if err != nil { - return err - } - - var args []interface{} - if entry.binding == nil { - args = entry.Args - } else { - binding := &QueryInfo{ - Id: info.preparedID, - Args: info.reqMeta.columns, - Rval: info.respMeta.columns, - } - args, err = entry.binding(binding) - if err != nil { - return err - } - } - - if len(args) != len(info.reqMeta.columns) { - return ErrQueryArgLength - } - - b.preparedID = info.preparedID - stmts[string(info.preparedID)] = entry.Stmt - - b.values = make([]queryValues, len(info.reqMeta.columns)) - - for j := 0; j < len(info.reqMeta.columns); j++ { - val, err := Marshal(info.reqMeta.columns[j].TypeInfo, args[j]) - if err != nil { - return err - } - - b.values[j].value = val - // TODO: add names - } - } else { - b.statement = entry.Stmt - } - } - - // TODO: should batch support tracing? - resp, err := c.exec(req, nil) - if err != nil { - return err - } - - switch x := resp.(type) { - case *resultVoidFrame: - return nil - case *RequestErrUnprepared: - stmt, found := stmts[string(x.StatementId)] - if found { - stmtsLRU.Lock() - stmtsLRU.lru.Remove(c.addr + c.currentKeyspace + stmt) - stmtsLRU.Unlock() - } - if found { - return c.executeBatch(batch) - } else { - return x - } - case error: - return x - default: - return NewErrProtocol("Unknown type in response to batch statement: %s", x) - } -} - -func (c *Conn) setKeepalive(d time.Duration) error { - if tc, ok := c.conn.(*net.TCPConn); ok { - err := tc.SetKeepAlivePeriod(d) - if err != nil { - return err - } - - return tc.SetKeepAlive(true) - } - - return nil -} - -type inflightPrepare struct { - info *resultPreparedFrame - err error - wg sync.WaitGroup -} - -var ( - ErrQueryArgLength = errors.New("gocql: query argument length mismatch") - ErrTimeoutNoResponse = errors.New("gocql: no response received from cassandra within timeout period") - ErrTooManyTimeouts = errors.New("gocql: too many query timeouts on the connection") - ErrConnectionClosed = errors.New("gocql: connection closed waiting for response") -) diff --git a/vendor/github.com/gocql/gocql/conn_test.go b/vendor/github.com/gocql/gocql/conn_test.go deleted file mode 100644 index 85aea6437..000000000 --- a/vendor/github.com/gocql/gocql/conn_test.go +++ /dev/null @@ -1,817 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. -// +build all unit - -package gocql - -import ( - "crypto/tls" - "crypto/x509" - "fmt" - "io" - "io/ioutil" - "net" - "strings" - "sync" - "sync/atomic" - "testing" - "time" -) - -const ( - defaultProto = protoVersion2 -) - -func TestJoinHostPort(t *testing.T) { - tests := map[string]string{ - "127.0.0.1:0": JoinHostPort("127.0.0.1", 0), - "127.0.0.1:1": JoinHostPort("127.0.0.1:1", 9142), - "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:0": JoinHostPort("2001:0db8:85a3:0000:0000:8a2e:0370:7334", 0), - "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:1": JoinHostPort("[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:1", 9142), - } - for k, v := range tests { - if k != v { - t.Fatalf("expected '%v', got '%v'", k, v) - } - } -} - -func TestSimple(t *testing.T) { - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - cluster := NewCluster(srv.Address) - cluster.ProtoVersion = int(defaultProto) - db, err := cluster.CreateSession() - if err != nil { - t.Errorf("0x%x: NewCluster: %v", defaultProto, err) - return - } - - if err := db.Query("void").Exec(); err != nil { - t.Errorf("0x%x: %v", defaultProto, err) - } -} - -func TestSSLSimple(t *testing.T) { - srv := NewSSLTestServer(t, defaultProto) - defer srv.Stop() - - db, err := createTestSslCluster(srv.Address, defaultProto, true).CreateSession() - if err != nil { - t.Fatalf("0x%x: NewCluster: %v", defaultProto, err) - } - - if err := db.Query("void").Exec(); err != nil { - t.Fatalf("0x%x: %v", defaultProto, err) - } -} - -func TestSSLSimpleNoClientCert(t *testing.T) { - srv := NewSSLTestServer(t, defaultProto) - defer srv.Stop() - - db, err := createTestSslCluster(srv.Address, defaultProto, false).CreateSession() - if err != nil { - t.Fatalf("0x%x: NewCluster: %v", defaultProto, err) - } - - if err := db.Query("void").Exec(); err != nil { - t.Fatalf("0x%x: %v", defaultProto, err) - } -} - -func createTestSslCluster(hosts string, proto uint8, useClientCert bool) *ClusterConfig { - cluster := NewCluster(hosts) - sslOpts := &SslOptions{ - CaPath: "testdata/pki/ca.crt", - EnableHostVerification: false, - } - if useClientCert { - sslOpts.CertPath = "testdata/pki/gocql.crt" - sslOpts.KeyPath = "testdata/pki/gocql.key" - } - cluster.SslOpts = sslOpts - cluster.ProtoVersion = int(proto) - return cluster -} - -func TestClosed(t *testing.T) { - t.Skip("Skipping the execution of TestClosed for now to try to concentrate on more important test failures on Travis") - - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - cluster := NewCluster(srv.Address) - cluster.ProtoVersion = int(defaultProto) - - session, err := cluster.CreateSession() - defer session.Close() - if err != nil { - t.Errorf("0x%x: NewCluster: %v", defaultProto, err) - return - } - - if err := session.Query("void").Exec(); err != ErrSessionClosed { - t.Errorf("0x%x: expected %#v, got %#v", defaultProto, ErrSessionClosed, err) - return - } -} - -func newTestSession(addr string, proto uint8) (*Session, error) { - cluster := NewCluster(addr) - cluster.ProtoVersion = int(proto) - return cluster.CreateSession() -} - -func TestTimeout(t *testing.T) { - - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - db, err := newTestSession(srv.Address, defaultProto) - if err != nil { - t.Errorf("NewCluster: %v", err) - return - } - defer db.Close() - - go func() { - <-time.After(2 * time.Second) - t.Errorf("no timeout") - }() - - if err := db.Query("kill").Exec(); err == nil { - t.Errorf("expected error") - } -} - -// TestQueryRetry will test to make sure that gocql will execute -// the exact amount of retry queries designated by the user. -func TestQueryRetry(t *testing.T) { - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - db, err := newTestSession(srv.Address, defaultProto) - if err != nil { - t.Fatalf("NewCluster: %v", err) - } - defer db.Close() - - go func() { - <-time.After(5 * time.Second) - t.Fatalf("no timeout") - }() - rt := &SimpleRetryPolicy{NumRetries: 1} - - qry := db.Query("kill").RetryPolicy(rt) - if err := qry.Exec(); err == nil { - t.Fatalf("expected error") - } - - requests := atomic.LoadInt64(&srv.nKillReq) - attempts := qry.Attempts() - if requests != int64(attempts) { - t.Fatalf("expected requests %v to match query attemps %v", requests, attempts) - } - - //Minus 1 from the requests variable since there is the initial query attempt - if requests-1 != int64(rt.NumRetries) { - t.Fatalf("failed to retry the query %v time(s). Query executed %v times", rt.NumRetries, requests-1) - } -} - -func TestSimplePoolRoundRobin(t *testing.T) { - servers := make([]*TestServer, 5) - addrs := make([]string, len(servers)) - for n := 0; n < len(servers); n++ { - servers[n] = NewTestServer(t, defaultProto) - addrs[n] = servers[n].Address - defer servers[n].Stop() - } - cluster := NewCluster(addrs...) - cluster.ProtoVersion = defaultProto - - db, err := cluster.CreateSession() - time.Sleep(1 * time.Second) // Sleep to allow the Cluster.fillPool to complete - - if err != nil { - t.Fatalf("NewCluster: %v", err) - } - - var wg sync.WaitGroup - wg.Add(5) - for n := 0; n < 5; n++ { - go func() { - for j := 0; j < 5; j++ { - if err := db.Query("void").Exec(); err != nil { - t.Fatal(err) - } - } - wg.Done() - }() - } - wg.Wait() - - diff := 0 - for n := 1; n < len(servers); n++ { - d := 0 - if servers[n].nreq > servers[n-1].nreq { - d = int(servers[n].nreq - servers[n-1].nreq) - } else { - d = int(servers[n-1].nreq - servers[n].nreq) - } - if d > diff { - diff = d - } - } - - if diff > 0 { - t.Errorf("Expected 0 difference in usage but was %d", diff) - } -} - -func TestConnClosing(t *testing.T) { - t.Skip("Skipping until test can be ran reliably") - - srv := NewTestServer(t, protoVersion2) - defer srv.Stop() - - db, err := NewCluster(srv.Address).CreateSession() - if err != nil { - t.Errorf("NewCluster: %v", err) - } - defer db.Close() - - numConns := db.cfg.NumConns - count := db.cfg.NumStreams * numConns - - wg := &sync.WaitGroup{} - wg.Add(count) - for i := 0; i < count; i++ { - go func(wg *sync.WaitGroup) { - wg.Done() - db.Query("kill").Exec() - }(wg) - } - - wg.Wait() - - time.Sleep(1 * time.Second) //Sleep so the fillPool can complete. - pool := db.Pool.(ConnectionPool) - conns := pool.Size() - - if conns != numConns { - t.Errorf("Expected to have %d connections but have %d", numConns, conns) - } -} - -func TestStreams_Protocol1(t *testing.T) { - srv := NewTestServer(t, protoVersion1) - defer srv.Stop() - - // TODO: these are more like session tests and should instead operate - // on a single Conn - cluster := NewCluster(srv.Address) - cluster.NumConns = 1 - cluster.ProtoVersion = 1 - - db, err := cluster.CreateSession() - if err != nil { - t.Fatal(err) - } - defer db.Close() - - var wg sync.WaitGroup - for i := 1; i < db.cfg.NumStreams; i++ { - // here were just validating that if we send NumStream request we get - // a response for every stream and the lengths for the queries are set - // correctly. - wg.Add(1) - go func() { - defer wg.Done() - if err := db.Query("void").Exec(); err != nil { - t.Error(err) - } - }() - } - wg.Wait() -} - -func TestStreams_Protocol2(t *testing.T) { - srv := NewTestServer(t, protoVersion2) - defer srv.Stop() - - // TODO: these are more like session tests and should instead operate - // on a single Conn - cluster := NewCluster(srv.Address) - cluster.NumConns = 1 - cluster.ProtoVersion = 2 - - db, err := cluster.CreateSession() - if err != nil { - t.Fatal(err) - } - defer db.Close() - - for i := 1; i < db.cfg.NumStreams; i++ { - // the test server processes each conn synchronously - // here were just validating that if we send NumStream request we get - // a response for every stream and the lengths for the queries are set - // correctly. - if err = db.Query("void").Exec(); err != nil { - t.Fatal(err) - } - } -} - -func TestStreams_Protocol3(t *testing.T) { - srv := NewTestServer(t, protoVersion3) - defer srv.Stop() - - // TODO: these are more like session tests and should instead operate - // on a single Conn - cluster := NewCluster(srv.Address) - cluster.NumConns = 1 - cluster.ProtoVersion = 3 - - db, err := cluster.CreateSession() - if err != nil { - t.Fatal(err) - } - defer db.Close() - - for i := 1; i < db.cfg.NumStreams; i++ { - // the test server processes each conn synchronously - // here were just validating that if we send NumStream request we get - // a response for every stream and the lengths for the queries are set - // correctly. - if err = db.Query("void").Exec(); err != nil { - t.Fatal(err) - } - } -} - -func BenchmarkProtocolV3(b *testing.B) { - srv := NewTestServer(b, protoVersion3) - defer srv.Stop() - - // TODO: these are more like session tests and should instead operate - // on a single Conn - cluster := NewCluster(srv.Address) - cluster.NumConns = 1 - cluster.ProtoVersion = 3 - - db, err := cluster.CreateSession() - if err != nil { - b.Fatal(err) - } - defer db.Close() - - b.ResetTimer() - b.ReportAllocs() - for i := 0; i < b.N; i++ { - if err = db.Query("void").Exec(); err != nil { - b.Fatal(err) - } - } -} - -func TestRoundRobinConnPoolRoundRobin(t *testing.T) { - // create 5 test servers - servers := make([]*TestServer, 5) - addrs := make([]string, len(servers)) - for n := 0; n < len(servers); n++ { - servers[n] = NewTestServer(t, defaultProto) - addrs[n] = servers[n].Address - defer servers[n].Stop() - } - - // create a new cluster using the policy-based round robin conn pool - cluster := NewCluster(addrs...) - cluster.ConnPoolType = NewRoundRobinConnPool - - db, err := cluster.CreateSession() - if err != nil { - t.Fatalf("failed to create a new session: %v", err) - } - - // Sleep to allow the pool to fill - time.Sleep(100 * time.Millisecond) - - // run concurrent queries against the pool, server usage should - // be even - var wg sync.WaitGroup - wg.Add(5) - for n := 0; n < 5; n++ { - go func() { - for j := 0; j < 5; j++ { - if err := db.Query("void").Exec(); err != nil { - t.Errorf("Query failed with error: %v", err) - } - } - wg.Done() - }() - } - wg.Wait() - - db.Close() - - // wait for the pool to drain - time.Sleep(100 * time.Millisecond) - size := db.Pool.Size() - if size != 0 { - t.Errorf("connection pool did not drain, still contains %d connections", size) - } - - // verify that server usage is even - diff := 0 - for n := 1; n < len(servers); n++ { - d := 0 - if servers[n].nreq > servers[n-1].nreq { - d = int(servers[n].nreq - servers[n-1].nreq) - } else { - d = int(servers[n-1].nreq - servers[n].nreq) - } - if d > diff { - diff = d - } - } - - if diff > 0 { - t.Errorf("expected 0 difference in usage but was %d", diff) - } -} - -// This tests that the policy connection pool handles SSL correctly -func TestPolicyConnPoolSSL(t *testing.T) { - srv := NewSSLTestServer(t, defaultProto) - defer srv.Stop() - - cluster := createTestSslCluster(srv.Address, defaultProto, true) - cluster.ConnPoolType = NewRoundRobinConnPool - - db, err := cluster.CreateSession() - if err != nil { - t.Fatalf("failed to create new session: %v", err) - } - - if err := db.Query("void").Exec(); err != nil { - t.Errorf("query failed due to error: %v", err) - } - - db.Close() - - // wait for the pool to drain - time.Sleep(100 * time.Millisecond) - size := db.Pool.Size() - if size != 0 { - t.Errorf("connection pool did not drain, still contains %d connections", size) - } -} - -func TestQueryTimeout(t *testing.T) { - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - cluster := NewCluster(srv.Address) - // Set the timeout arbitrarily low so that the query hits the timeout in a - // timely manner. - cluster.Timeout = 1 * time.Millisecond - - db, err := cluster.CreateSession() - if err != nil { - t.Errorf("NewCluster: %v", err) - } - defer db.Close() - - ch := make(chan error, 1) - - go func() { - err := db.Query("timeout").Exec() - if err != nil { - ch <- err - return - } - t.Errorf("err was nil, expected to get a timeout after %v", db.cfg.Timeout) - }() - - select { - case err := <-ch: - if err != ErrTimeoutNoResponse { - t.Fatalf("expected to get %v for timeout got %v", ErrTimeoutNoResponse, err) - } - case <-time.After(10*time.Millisecond + db.cfg.Timeout): - // ensure that the query goroutines have been scheduled - t.Fatalf("query did not timeout after %v", db.cfg.Timeout) - } -} - -func TestQueryTimeoutReuseStream(t *testing.T) { - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - cluster := NewCluster(srv.Address) - // Set the timeout arbitrarily low so that the query hits the timeout in a - // timely manner. - cluster.Timeout = 1 * time.Millisecond - cluster.NumConns = 1 - cluster.NumStreams = 1 - - db, err := cluster.CreateSession() - if err != nil { - t.Fatalf("NewCluster: %v", err) - } - defer db.Close() - - db.Query("slow").Exec() - - err = db.Query("void").Exec() - if err != nil { - t.Fatal(err) - } -} - -func TestQueryTimeoutClose(t *testing.T) { - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - cluster := NewCluster(srv.Address) - // Set the timeout arbitrarily low so that the query hits the timeout in a - // timely manner. - cluster.Timeout = 1000 * time.Millisecond - cluster.NumConns = 1 - cluster.NumStreams = 1 - - db, err := cluster.CreateSession() - if err != nil { - t.Fatalf("NewCluster: %v", err) - } - - ch := make(chan error) - go func() { - err := db.Query("timeout").Exec() - ch <- err - }() - // ensure that the above goroutine gets sheduled - time.Sleep(50 * time.Millisecond) - - db.Close() - select { - case err = <-ch: - case <-time.After(1 * time.Second): - t.Fatal("timedout waiting to get a response once cluster is closed") - } - - if err != ErrConnectionClosed { - t.Fatalf("expected to get %v got %v", ErrConnectionClosed, err) - } -} - -func TestExecPanic(t *testing.T) { - t.Skip("test can cause unrelated failures, skipping until it can be fixed.") - srv := NewTestServer(t, defaultProto) - defer srv.Stop() - - cluster := NewCluster(srv.Address) - // Set the timeout arbitrarily low so that the query hits the timeout in a - // timely manner. - cluster.Timeout = 5 * time.Millisecond - cluster.NumConns = 1 - // cluster.NumStreams = 1 - - db, err := cluster.CreateSession() - if err != nil { - t.Fatal(err) - } - defer db.Close() - - streams := db.cfg.NumStreams - - wg := &sync.WaitGroup{} - wg.Add(streams) - for i := 0; i < streams; i++ { - go func() { - defer wg.Done() - q := db.Query("void") - for { - if err := q.Exec(); err != nil { - return - } - } - }() - } - - wg.Add(1) - - go func() { - defer wg.Done() - for i := 0; i < int(TimeoutLimit); i++ { - db.Query("timeout").Exec() - } - }() - - wg.Wait() - - time.Sleep(500 * time.Millisecond) -} - -func NewTestServer(t testing.TB, protocol uint8) *TestServer { - laddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - - listen, err := net.ListenTCP("tcp", laddr) - if err != nil { - t.Fatal(err) - } - - headerSize := 8 - if protocol > protoVersion2 { - headerSize = 9 - } - - srv := &TestServer{ - Address: listen.Addr().String(), - listen: listen, - t: t, - protocol: protocol, - headerSize: headerSize, - quit: make(chan struct{}), - } - - go srv.serve() - - return srv -} - -func NewSSLTestServer(t testing.TB, protocol uint8) *TestServer { - pem, err := ioutil.ReadFile("testdata/pki/ca.crt") - certPool := x509.NewCertPool() - if !certPool.AppendCertsFromPEM(pem) { - t.Errorf("Failed parsing or appending certs") - } - mycert, err := tls.LoadX509KeyPair("testdata/pki/cassandra.crt", "testdata/pki/cassandra.key") - if err != nil { - t.Errorf("could not load cert") - } - config := &tls.Config{ - Certificates: []tls.Certificate{mycert}, - RootCAs: certPool, - } - listen, err := tls.Listen("tcp", "127.0.0.1:0", config) - if err != nil { - t.Fatal(err) - } - - headerSize := 8 - if protocol > protoVersion2 { - headerSize = 9 - } - - srv := &TestServer{ - Address: listen.Addr().String(), - listen: listen, - t: t, - protocol: protocol, - headerSize: headerSize, - quit: make(chan struct{}), - } - go srv.serve() - return srv -} - -type TestServer struct { - Address string - t testing.TB - nreq uint64 - listen net.Listener - nKillReq int64 - compressor Compressor - - protocol byte - headerSize int - - quit chan struct{} -} - -func (srv *TestServer) serve() { - defer srv.listen.Close() - for { - conn, err := srv.listen.Accept() - if err != nil { - break - } - go func(conn net.Conn) { - defer conn.Close() - for { - framer, err := srv.readFrame(conn) - if err != nil { - if err == io.EOF { - return - } - - srv.t.Error(err) - return - } - - atomic.AddUint64(&srv.nreq, 1) - - go srv.process(framer) - } - }(conn) - } -} - -func (srv *TestServer) Stop() { - srv.listen.Close() - close(srv.quit) -} - -func (srv *TestServer) process(f *framer) { - head := f.header - if head == nil { - srv.t.Error("process frame with a nil header") - return - } - - switch head.op { - case opStartup: - f.writeHeader(0, opReady, head.stream) - case opOptions: - f.writeHeader(0, opSupported, head.stream) - f.writeShort(0) - case opQuery: - query := f.readLongString() - first := query - if n := strings.Index(query, " "); n > 0 { - first = first[:n] - } - switch strings.ToLower(first) { - case "kill": - atomic.AddInt64(&srv.nKillReq, 1) - f.writeHeader(0, opError, head.stream) - f.writeInt(0x1001) - f.writeString("query killed") - case "use": - f.writeInt(resultKindKeyspace) - f.writeString(strings.TrimSpace(query[3:])) - case "void": - f.writeHeader(0, opResult, head.stream) - f.writeInt(resultKindVoid) - case "timeout": - <-srv.quit - return - case "slow": - go func() { - f.writeHeader(0, opResult, head.stream) - f.writeInt(resultKindVoid) - f.wbuf[0] = srv.protocol | 0x80 - select { - case <-srv.quit: - case <-time.After(50 * time.Millisecond): - f.finishWrite() - } - }() - return - default: - f.writeHeader(0, opResult, head.stream) - f.writeInt(resultKindVoid) - } - default: - f.writeHeader(0, opError, head.stream) - f.writeInt(0) - f.writeString("not supported") - } - - f.wbuf[0] = srv.protocol | 0x80 - - if err := f.finishWrite(); err != nil { - srv.t.Error(err) - } -} - -func (srv *TestServer) readFrame(conn net.Conn) (*framer, error) { - buf := make([]byte, srv.headerSize) - head, err := readHeader(conn, buf) - if err != nil { - return nil, err - } - framer := newFramer(conn, conn, nil, srv.protocol) - - err = framer.readFrame(&head) - if err != nil { - return nil, err - } - - // should be a request frame - if head.version.response() { - return nil, fmt.Errorf("expected to read a request frame got version: %v", head.version) - } else if head.version.version() != srv.protocol { - return nil, fmt.Errorf("expected to read protocol version 0x%x got 0x%x", srv.protocol, head.version.version()) - } - - return framer, nil -} diff --git a/vendor/github.com/gocql/gocql/connectionpool.go b/vendor/github.com/gocql/gocql/connectionpool.go deleted file mode 100644 index 9f9904be1..000000000 --- a/vendor/github.com/gocql/gocql/connectionpool.go +++ /dev/null @@ -1,895 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "fmt" - "io/ioutil" - "log" - "math/rand" - "net" - "sync" - "time" -) - -/*ConnectionPool represents the interface gocql will use to work with a collection of connections. - -Purpose - -The connection pool in gocql opens and closes connections as well as selects an available connection -for gocql to execute a query against. The pool is also respnsible for handling connection errors that -are caught by the connection experiencing the error. - -A connection pool should make a copy of the variables used from the ClusterConfig provided to the pool -upon creation. ClusterConfig is a pointer and can be modified after the creation of the pool. This can -lead to issues with variables being modified outside the expectations of the ConnectionPool type. - -Example of Single Connection Pool: - - type SingleConnection struct { - conn *Conn - cfg *ClusterConfig - } - - func NewSingleConnection(cfg *ClusterConfig) ConnectionPool { - addr := JoinHostPort(cfg.Hosts[0], cfg.Port) - - connCfg := ConnConfig{ - ProtoVersion: cfg.ProtoVersion, - CQLVersion: cfg.CQLVersion, - Timeout: cfg.Timeout, - NumStreams: cfg.NumStreams, - Compressor: cfg.Compressor, - Authenticator: cfg.Authenticator, - Keepalive: cfg.SocketKeepalive, - } - pool := SingleConnection{cfg:cfg} - pool.conn = Connect(addr,connCfg,pool) - return &pool - } - - func (s *SingleConnection) HandleError(conn *Conn, err error, closed bool) { - if closed { - connCfg := ConnConfig{ - ProtoVersion: cfg.ProtoVersion, - CQLVersion: cfg.CQLVersion, - Timeout: cfg.Timeout, - NumStreams: cfg.NumStreams, - Compressor: cfg.Compressor, - Authenticator: cfg.Authenticator, - Keepalive: cfg.SocketKeepalive, - } - s.conn = Connect(conn.Address(),connCfg,s) - } - } - - func (s *SingleConnection) Pick(qry *Query) *Conn { - if s.conn.isClosed { - return nil - } - return s.conn - } - - func (s *SingleConnection) Size() int { - return 1 - } - - func (s *SingleConnection) Close() { - s.conn.Close() - } - -This is a very simple example of a type that exposes the connection pool interface. To assign -this type as the connection pool to use you would assign it to the ClusterConfig like so: - - cluster := NewCluster("127.0.0.1") - cluster.ConnPoolType = NewSingleConnection - ... - session, err := cluster.CreateSession() - -To see a more complete example of a ConnectionPool implementation please see the SimplePool type. -*/ -type ConnectionPool interface { - SetHosts - Pick(*Query) *Conn - Size() int - Close() -} - -// interface to implement to receive the host information -type SetHosts interface { - SetHosts(hosts []HostInfo) -} - -// interface to implement to receive the partitioner value -type SetPartitioner interface { - SetPartitioner(partitioner string) -} - -//NewPoolFunc is the type used by ClusterConfig to create a pool of a specific type. -type NewPoolFunc func(*ClusterConfig) (ConnectionPool, error) - -//SimplePool is the current implementation of the connection pool inside gocql. This -//pool is meant to be a simple default used by gocql so users can get up and running -//quickly. -type SimplePool struct { - cfg *ClusterConfig - hostPool *RoundRobin - connPool map[string]*RoundRobin - conns map[*Conn]struct{} - keyspace string - - hostMu sync.RWMutex - // this is the set of current hosts which the pool will attempt to connect to - hosts map[string]*HostInfo - - // protects hostpool, connPoll, conns, quit - mu sync.Mutex - - cFillingPool chan int - - quit bool - quitWait chan bool - quitOnce sync.Once - - tlsConfig *tls.Config -} - -func setupTLSConfig(sslOpts *SslOptions) (*tls.Config, error) { - // ca cert is optional - if sslOpts.CaPath != "" { - if sslOpts.RootCAs == nil { - sslOpts.RootCAs = x509.NewCertPool() - } - - pem, err := ioutil.ReadFile(sslOpts.CaPath) - if err != nil { - return nil, fmt.Errorf("connectionpool: unable to open CA certs: %v", err) - } - - if !sslOpts.RootCAs.AppendCertsFromPEM(pem) { - return nil, errors.New("connectionpool: failed parsing or CA certs") - } - } - - if sslOpts.CertPath != "" || sslOpts.KeyPath != "" { - mycert, err := tls.LoadX509KeyPair(sslOpts.CertPath, sslOpts.KeyPath) - if err != nil { - return nil, fmt.Errorf("connectionpool: unable to load X509 key pair: %v", err) - } - sslOpts.Certificates = append(sslOpts.Certificates, mycert) - } - - sslOpts.InsecureSkipVerify = !sslOpts.EnableHostVerification - - return &sslOpts.Config, nil -} - -//NewSimplePool is the function used by gocql to create the simple connection pool. -//This is the default if no other pool type is specified. -func NewSimplePool(cfg *ClusterConfig) (ConnectionPool, error) { - pool := &SimplePool{ - cfg: cfg, - hostPool: NewRoundRobin(), - connPool: make(map[string]*RoundRobin), - conns: make(map[*Conn]struct{}), - quitWait: make(chan bool), - cFillingPool: make(chan int, 1), - keyspace: cfg.Keyspace, - hosts: make(map[string]*HostInfo), - } - - for _, host := range cfg.Hosts { - // seed hosts have unknown topology - // TODO: Handle populating this during SetHosts - pool.hosts[host] = &HostInfo{Peer: host} - } - - if cfg.SslOpts != nil { - config, err := setupTLSConfig(cfg.SslOpts) - if err != nil { - return nil, err - } - pool.tlsConfig = config - } - - //Walk through connecting to hosts. As soon as one host connects - //defer the remaining connections to cluster.fillPool() - for i := 0; i < len(cfg.Hosts); i++ { - addr := JoinHostPort(cfg.Hosts[i], cfg.Port) - - if pool.connect(addr) == nil { - pool.cFillingPool <- 1 - go pool.fillPool() - break - } - } - - return pool, nil -} - -func (c *SimplePool) connect(addr string) error { - - cfg := ConnConfig{ - ProtoVersion: c.cfg.ProtoVersion, - CQLVersion: c.cfg.CQLVersion, - Timeout: c.cfg.Timeout, - NumStreams: c.cfg.NumStreams, - Compressor: c.cfg.Compressor, - Authenticator: c.cfg.Authenticator, - Keepalive: c.cfg.SocketKeepalive, - tlsConfig: c.tlsConfig, - } - - conn, err := Connect(addr, cfg, c) - if err != nil { - log.Printf("connect: failed to connect to %q: %v", addr, err) - return err - } - - return c.addConn(conn) -} - -func (c *SimplePool) addConn(conn *Conn) error { - c.mu.Lock() - defer c.mu.Unlock() - if c.quit { - conn.Close() - return nil - } - - //Set the connection's keyspace if any before adding it to the pool - if c.keyspace != "" { - if err := conn.UseKeyspace(c.keyspace); err != nil { - log.Printf("error setting connection keyspace. %v", err) - conn.Close() - return err - } - } - - connPool := c.connPool[conn.Address()] - if connPool == nil { - connPool = NewRoundRobin() - c.connPool[conn.Address()] = connPool - c.hostPool.AddNode(connPool) - } - - connPool.AddNode(conn) - c.conns[conn] = struct{}{} - - return nil -} - -//fillPool manages the pool of connections making sure that each host has the correct -//amount of connections defined. Also the method will test a host with one connection -//instead of flooding the host with number of connections defined in the cluster config -func (c *SimplePool) fillPool() { - //Debounce large amounts of requests to fill pool - select { - case <-time.After(1 * time.Millisecond): - return - case <-c.cFillingPool: - defer func() { c.cFillingPool <- 1 }() - } - - c.mu.Lock() - isClosed := c.quit - c.mu.Unlock() - //Exit if cluster(session) is closed - if isClosed { - return - } - - c.hostMu.RLock() - - //Walk through list of defined hosts - var wg sync.WaitGroup - for host := range c.hosts { - addr := JoinHostPort(host, c.cfg.Port) - - numConns := 1 - //See if the host already has connections in the pool - c.mu.Lock() - conns, ok := c.connPool[addr] - c.mu.Unlock() - - if ok { - //if the host has enough connections just exit - numConns = conns.Size() - if numConns >= c.cfg.NumConns { - continue - } - } else { - //See if the host is reachable - if err := c.connect(addr); err != nil { - continue - } - } - - //This is reached if the host is responsive and needs more connections - //Create connections for host synchronously to mitigate flooding the host. - wg.Add(1) - go func(a string, conns int) { - defer wg.Done() - for ; conns < c.cfg.NumConns; conns++ { - c.connect(a) - } - }(addr, numConns) - } - - c.hostMu.RUnlock() - - //Wait until we're finished connecting to each host before returning - wg.Wait() -} - -// Should only be called if c.mu is locked -func (c *SimplePool) removeConnLocked(conn *Conn) { - conn.Close() - connPool := c.connPool[conn.addr] - if connPool == nil { - return - } - connPool.RemoveNode(conn) - if connPool.Size() == 0 { - c.hostPool.RemoveNode(connPool) - delete(c.connPool, conn.addr) - } - delete(c.conns, conn) -} - -func (c *SimplePool) removeConn(conn *Conn) { - c.mu.Lock() - defer c.mu.Unlock() - c.removeConnLocked(conn) -} - -//HandleError is called by a Connection object to report to the pool an error has occured. -//Logic is then executed within the pool to clean up the erroroneous connection and try to -//top off the pool. -func (c *SimplePool) HandleError(conn *Conn, err error, closed bool) { - if !closed { - // ignore all non-fatal errors - return - } - c.removeConn(conn) - c.mu.Lock() - poolClosed := c.quit - c.mu.Unlock() - if !poolClosed { - go c.fillPool() // top off pool. - } -} - -//Pick selects a connection to be used by the query. -func (c *SimplePool) Pick(qry *Query) *Conn { - //Check if connections are available - c.mu.Lock() - conns := len(c.conns) - c.mu.Unlock() - - if conns == 0 { - //try to populate the pool before returning. - c.fillPool() - } - - return c.hostPool.Pick(qry) -} - -//Size returns the number of connections currently active in the pool -func (p *SimplePool) Size() int { - p.mu.Lock() - conns := len(p.conns) - p.mu.Unlock() - return conns -} - -//Close kills the pool and all associated connections. -func (c *SimplePool) Close() { - c.quitOnce.Do(func() { - c.mu.Lock() - defer c.mu.Unlock() - c.quit = true - close(c.quitWait) - for conn := range c.conns { - c.removeConnLocked(conn) - } - }) -} - -func (c *SimplePool) SetHosts(hosts []HostInfo) { - - c.hostMu.Lock() - toRemove := make(map[string]struct{}) - for k := range c.hosts { - toRemove[k] = struct{}{} - } - - for _, host := range hosts { - host := host - delete(toRemove, host.Peer) - // we already have it - if _, ok := c.hosts[host.Peer]; ok { - // TODO: Check rack, dc, token range is consistent, trigger topology change - // update stored host - continue - } - - c.hosts[host.Peer] = &host - } - - // can we hold c.mu whilst iterating this loop? - for addr := range toRemove { - c.removeHostLocked(addr) - } - c.hostMu.Unlock() - - c.fillPool() -} - -func (c *SimplePool) removeHostLocked(addr string) { - if _, ok := c.hosts[addr]; !ok { - return - } - delete(c.hosts, addr) - - c.mu.Lock() - defer c.mu.Unlock() - - if _, ok := c.connPool[addr]; !ok { - return - } - - for conn := range c.conns { - if conn.Address() == addr { - c.removeConnLocked(conn) - } - } -} - -//NewRoundRobinConnPool creates a connection pool which selects hosts by -//round-robin, and then selects a connection for that host by round-robin. -func NewRoundRobinConnPool(cfg *ClusterConfig) (ConnectionPool, error) { - return NewPolicyConnPool( - cfg, - NewRoundRobinHostPolicy(), - NewRoundRobinConnPolicy, - ) -} - -//NewTokenAwareConnPool creates a connection pool which selects hosts by -//a token aware policy, and then selects a connection for that host by -//round-robin. -func NewTokenAwareConnPool(cfg *ClusterConfig) (ConnectionPool, error) { - return NewPolicyConnPool( - cfg, - NewTokenAwareHostPolicy(NewRoundRobinHostPolicy()), - NewRoundRobinConnPolicy, - ) -} - -type policyConnPool struct { - port int - numConns int - connCfg ConnConfig - keyspace string - - mu sync.RWMutex - hostPolicy HostSelectionPolicy - connPolicy func() ConnSelectionPolicy - hostConnPools map[string]*hostConnPool -} - -//Creates a policy based connection pool. This func isn't meant to be directly -//used as a NewPoolFunc in ClusterConfig, instead a func should be created -//which satisfies the NewPoolFunc type, which calls this func with the desired -//hostPolicy and connPolicy; see NewRoundRobinConnPool or NewTokenAwareConnPool -//for examples. -func NewPolicyConnPool( - cfg *ClusterConfig, - hostPolicy HostSelectionPolicy, - connPolicy func() ConnSelectionPolicy, -) (ConnectionPool, error) { - var err error - var tlsConfig *tls.Config - - if cfg.SslOpts != nil { - tlsConfig, err = setupTLSConfig(cfg.SslOpts) - if err != nil { - return nil, err - } - } - - // create the pool - pool := &policyConnPool{ - port: cfg.Port, - numConns: cfg.NumConns, - connCfg: ConnConfig{ - ProtoVersion: cfg.ProtoVersion, - CQLVersion: cfg.CQLVersion, - Timeout: cfg.Timeout, - NumStreams: cfg.NumStreams, - Compressor: cfg.Compressor, - Authenticator: cfg.Authenticator, - Keepalive: cfg.SocketKeepalive, - tlsConfig: tlsConfig, - }, - keyspace: cfg.Keyspace, - hostPolicy: hostPolicy, - connPolicy: connPolicy, - hostConnPools: map[string]*hostConnPool{}, - } - - hosts := make([]HostInfo, len(cfg.Hosts)) - for i, hostAddr := range cfg.Hosts { - hosts[i].Peer = hostAddr - } - - pool.SetHosts(hosts) - - return pool, nil -} - -func (p *policyConnPool) SetHosts(hosts []HostInfo) { - p.mu.Lock() - - toRemove := make(map[string]struct{}) - for addr := range p.hostConnPools { - toRemove[addr] = struct{}{} - } - - // TODO connect to hosts in parallel, but wait for pools to be - // created before returning - - for i := range hosts { - pool, exists := p.hostConnPools[hosts[i].Peer] - if !exists { - // create a connection pool for the host - pool = newHostConnPool( - hosts[i].Peer, - p.port, - p.numConns, - p.connCfg, - p.keyspace, - p.connPolicy(), - ) - p.hostConnPools[hosts[i].Peer] = pool - } else { - // still have this host, so don't remove it - delete(toRemove, hosts[i].Peer) - } - } - - for addr := range toRemove { - pool := p.hostConnPools[addr] - delete(p.hostConnPools, addr) - pool.Close() - } - - // update the policy - p.hostPolicy.SetHosts(hosts) - - p.mu.Unlock() -} - -func (p *policyConnPool) SetPartitioner(partitioner string) { - p.hostPolicy.SetPartitioner(partitioner) -} - -func (p *policyConnPool) Size() int { - p.mu.RLock() - count := 0 - for _, pool := range p.hostConnPools { - count += pool.Size() - } - p.mu.RUnlock() - - return count -} - -func (p *policyConnPool) Pick(qry *Query) *Conn { - nextHost := p.hostPolicy.Pick(qry) - - p.mu.RLock() - var host *HostInfo - var conn *Conn - for conn == nil { - host = nextHost() - if host == nil { - break - } - conn = p.hostConnPools[host.Peer].Pick(qry) - } - p.mu.RUnlock() - return conn -} - -func (p *policyConnPool) Close() { - p.mu.Lock() - - // remove the hosts from the policy - p.hostPolicy.SetHosts([]HostInfo{}) - - // close the pools - for addr, pool := range p.hostConnPools { - delete(p.hostConnPools, addr) - pool.Close() - } - p.mu.Unlock() -} - -// hostConnPool is a connection pool for a single host. -// Connection selection is based on a provided ConnSelectionPolicy -type hostConnPool struct { - host string - port int - addr string - size int - connCfg ConnConfig - keyspace string - policy ConnSelectionPolicy - // protection for conns, closed, filling - mu sync.RWMutex - conns []*Conn - closed bool - filling bool -} - -func newHostConnPool( - host string, - port int, - size int, - connCfg ConnConfig, - keyspace string, - policy ConnSelectionPolicy, -) *hostConnPool { - - pool := &hostConnPool{ - host: host, - port: port, - addr: JoinHostPort(host, port), - size: size, - connCfg: connCfg, - keyspace: keyspace, - policy: policy, - conns: make([]*Conn, 0, size), - filling: false, - closed: false, - } - - // fill the pool with the initial connections before returning - pool.fill() - - return pool -} - -// Pick a connection from this connection pool for the given query. -func (pool *hostConnPool) Pick(qry *Query) *Conn { - pool.mu.RLock() - if pool.closed { - pool.mu.RUnlock() - return nil - } - - empty := len(pool.conns) == 0 - pool.mu.RUnlock() - - if empty { - // try to fill the empty pool - go pool.fill() - return nil - } - - return pool.policy.Pick(qry) -} - -//Size returns the number of connections currently active in the pool -func (pool *hostConnPool) Size() int { - pool.mu.RLock() - defer pool.mu.RUnlock() - - return len(pool.conns) -} - -//Close the connection pool -func (pool *hostConnPool) Close() { - pool.mu.Lock() - defer pool.mu.Unlock() - - if pool.closed { - return - } - pool.closed = true - - // drain, but don't wait - go pool.drain() -} - -// Fill the connection pool -func (pool *hostConnPool) fill() { - pool.mu.RLock() - // avoid filling a closed pool, or concurrent filling - if pool.closed || pool.filling { - pool.mu.RUnlock() - return - } - - // determine the filling work to be done - startCount := len(pool.conns) - fillCount := pool.size - startCount - - // avoid filling a full (or overfull) pool - if fillCount <= 0 { - pool.mu.RUnlock() - return - } - - // switch from read to write lock - pool.mu.RUnlock() - pool.mu.Lock() - - // double check everything since the lock was released - startCount = len(pool.conns) - fillCount = pool.size - startCount - if pool.closed || pool.filling || fillCount <= 0 { - // looks like another goroutine already beat this - // goroutine to the filling - pool.mu.Unlock() - return - } - - // ok fill the pool - pool.filling = true - - // allow others to access the pool while filling - pool.mu.Unlock() - // only this goroutine should make calls to fill/empty the pool at this - // point until after this routine or its subordinates calls - // fillingStopped - - // fill only the first connection synchronously - if startCount == 0 { - err := pool.connect() - pool.logConnectErr(err) - - if err != nil { - // probably unreachable host - go pool.fillingStopped() - return - } - - // filled one - fillCount-- - - // connect all connections to this host in sync - for fillCount > 0 { - err := pool.connect() - pool.logConnectErr(err) - - // decrement, even on error - fillCount-- - } - - go pool.fillingStopped() - return - } - - // fill the rest of the pool asynchronously - go func() { - for fillCount > 0 { - err := pool.connect() - pool.logConnectErr(err) - - // decrement, even on error - fillCount-- - } - - // mark the end of filling - pool.fillingStopped() - }() -} - -func (pool *hostConnPool) logConnectErr(err error) { - if opErr, ok := err.(*net.OpError); ok && (opErr.Op == "dial" || opErr.Op == "read") { - // connection refused - // these are typical during a node outage so avoid log spam. - } else if err != nil { - // unexpected error - log.Printf("error: failed to connect to %s due to error: %v", pool.addr, err) - } -} - -// transition back to a not-filling state. -func (pool *hostConnPool) fillingStopped() { - // wait for some time to avoid back-to-back filling - // this provides some time between failed attempts - // to fill the pool for the host to recover - time.Sleep(time.Duration(rand.Int31n(100)+31) * time.Millisecond) - - pool.mu.Lock() - pool.filling = false - pool.mu.Unlock() -} - -// create a new connection to the host and add it to the pool -func (pool *hostConnPool) connect() error { - // try to connect - conn, err := Connect(pool.addr, pool.connCfg, pool) - if err != nil { - return err - } - - if pool.keyspace != "" { - // set the keyspace - if err := conn.UseKeyspace(pool.keyspace); err != nil { - conn.Close() - return err - } - } - - // add the Conn to the pool - pool.mu.Lock() - defer pool.mu.Unlock() - - if pool.closed { - conn.Close() - return nil - } - - pool.conns = append(pool.conns, conn) - pool.policy.SetConns(pool.conns) - return nil -} - -// handle any error from a Conn -func (pool *hostConnPool) HandleError(conn *Conn, err error, closed bool) { - if !closed { - // still an open connection, so continue using it - return - } - - pool.mu.Lock() - defer pool.mu.Unlock() - - if pool.closed { - // pool closed - return - } - - // find the connection index - for i, candidate := range pool.conns { - if candidate == conn { - // remove the connection, not preserving order - pool.conns[i], pool.conns = pool.conns[len(pool.conns)-1], pool.conns[:len(pool.conns)-1] - - // update the policy - pool.policy.SetConns(pool.conns) - - // lost a connection, so fill the pool - go pool.fill() - break - } - } -} - -// removes and closes all connections from the pool -func (pool *hostConnPool) drain() { - pool.mu.Lock() - defer pool.mu.Unlock() - - // empty the pool - conns := pool.conns - pool.conns = pool.conns[:0] - - // update the policy - pool.policy.SetConns(pool.conns) - - // close the connections - for _, conn := range conns { - conn.Close() - } -} diff --git a/vendor/github.com/gocql/gocql/doc.go b/vendor/github.com/gocql/gocql/doc.go deleted file mode 100644 index f661cf65f..000000000 --- a/vendor/github.com/gocql/gocql/doc.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2012-2015 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package gocql implements a fast and robust Cassandra driver for the -// Go programming language. -package gocql - -// TODO(tux21b): write more docs. diff --git a/vendor/github.com/gocql/gocql/errors.go b/vendor/github.com/gocql/gocql/errors.go deleted file mode 100644 index 1f959dc07..000000000 --- a/vendor/github.com/gocql/gocql/errors.go +++ /dev/null @@ -1,88 +0,0 @@ -package gocql - -import "fmt" - -const ( - errServer = 0x0000 - errProtocol = 0x000A - errCredentials = 0x0100 - errUnavailable = 0x1000 - errOverloaded = 0x1001 - errBootstrapping = 0x1002 - errTruncate = 0x1003 - errWriteTimeout = 0x1100 - errReadTimeout = 0x1200 - errSyntax = 0x2000 - errUnauthorized = 0x2100 - errInvalid = 0x2200 - errConfig = 0x2300 - errAlreadyExists = 0x2400 - errUnprepared = 0x2500 -) - -type RequestError interface { - Code() int - Message() string - Error() string -} - -type errorFrame struct { - frameHeader - - code int - message string -} - -func (e errorFrame) Code() int { - return e.code -} - -func (e errorFrame) Message() string { - return e.message -} - -func (e errorFrame) Error() string { - return e.Message() -} - -func (e errorFrame) String() string { - return fmt.Sprintf("[error code=%x message=%q]", e.code, e.message) -} - -type RequestErrUnavailable struct { - errorFrame - Consistency Consistency - Required int - Alive int -} - -func (e *RequestErrUnavailable) String() string { - return fmt.Sprintf("[request_error_unavailable consistency=%s required=%d alive=%d]", e.Consistency, e.Required, e.Alive) -} - -type RequestErrWriteTimeout struct { - errorFrame - Consistency Consistency - Received int - BlockFor int - WriteType string -} - -type RequestErrReadTimeout struct { - errorFrame - Consistency Consistency - Received int - BlockFor int - DataPresent byte -} - -type RequestErrAlreadyExists struct { - errorFrame - Keyspace string - Table string -} - -type RequestErrUnprepared struct { - errorFrame - StatementId []byte -} diff --git a/vendor/github.com/gocql/gocql/errors_test.go b/vendor/github.com/gocql/gocql/errors_test.go deleted file mode 100644 index 8c4a588df..000000000 --- a/vendor/github.com/gocql/gocql/errors_test.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build all integration - -package gocql - -import ( - "testing" -) - -func TestErrorsParse(t *testing.T) { - session := createSession(t) - defer session.Close() - - if err := createTable(session, `CREATE TABLE errors_parse (id int primary key)`); err != nil { - t.Fatal("create:", err) - } - - if err := createTable(session, `CREATE TABLE errors_parse (id int primary key)`); err == nil { - t.Fatal("Should have gotten already exists error from cassandra server.") - } else { - switch e := err.(type) { - case *RequestErrAlreadyExists: - if e.Table != "errors_parse" { - t.Fatal("Failed to parse error response from cassandra for ErrAlreadyExists.") - } - default: - t.Fatal("Failed to parse error response from cassandra for ErrAlreadyExists.") - } - } -} diff --git a/vendor/github.com/gocql/gocql/frame.go b/vendor/github.com/gocql/gocql/frame.go deleted file mode 100644 index ba1ad2e47..000000000 --- a/vendor/github.com/gocql/gocql/frame.go +++ /dev/null @@ -1,1480 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "runtime" - "sync" - "time" -) - -const ( - protoDirectionMask = 0x80 - protoVersionMask = 0x7F - protoVersion1 = 0x01 - protoVersion2 = 0x02 - protoVersion3 = 0x03 - - maxFrameSize = 256 * 1024 * 1024 -) - -type protoVersion byte - -func (p protoVersion) request() bool { - return p&protoDirectionMask == 0x00 -} - -func (p protoVersion) response() bool { - return p&protoDirectionMask == 0x80 -} - -func (p protoVersion) version() byte { - return byte(p) & protoVersionMask -} - -func (p protoVersion) String() string { - dir := "REQ" - if p.response() { - dir = "RESP" - } - - return fmt.Sprintf("[version=%d direction=%s]", p.version(), dir) -} - -type frameOp byte - -const ( - // header ops - opError frameOp = 0x00 - opStartup = 0x01 - opReady = 0x02 - opAuthenticate = 0x03 - opOptions = 0x05 - opSupported = 0x06 - opQuery = 0x07 - opResult = 0x08 - opPrepare = 0x09 - opExecute = 0x0A - opRegister = 0x0B - opEvent = 0x0C - opBatch = 0x0D - opAuthChallenge = 0x0E - opAuthResponse = 0x0F - opAuthSuccess = 0x10 -) - -func (f frameOp) String() string { - switch f { - case opError: - return "ERROR" - case opStartup: - return "STARTUP" - case opReady: - return "READY" - case opAuthenticate: - return "AUTHENTICATE" - case opOptions: - return "OPTIONS" - case opSupported: - return "SUPPORTED" - case opQuery: - return "QUERY" - case opResult: - return "RESULT" - case opPrepare: - return "PREPARE" - case opExecute: - return "EXECUTE" - case opRegister: - return "REGISTER" - case opEvent: - return "EVENT" - case opBatch: - return "BATCH" - case opAuthChallenge: - return "AUTH_CHALLENGE" - case opAuthResponse: - return "AUTH_RESPONSE" - case opAuthSuccess: - return "AUTH_SUCCESS" - default: - return fmt.Sprintf("UNKNOWN_OP_%d", f) - } -} - -const ( - // result kind - resultKindVoid = 1 - resultKindRows = 2 - resultKindKeyspace = 3 - resultKindPrepared = 4 - resultKindSchemaChanged = 5 - - // rows flags - flagGlobalTableSpec int = 0x01 - flagHasMorePages = 0x02 - flagNoMetaData = 0x04 - - // query flags - flagValues byte = 0x01 - flagSkipMetaData = 0x02 - flagPageSize = 0x04 - flagWithPagingState = 0x08 - flagWithSerialConsistency = 0x10 - flagDefaultTimestamp = 0x20 - flagWithNameValues = 0x40 - - // header flags - flagCompress byte = 0x01 - flagTracing = 0x02 -) - -type Consistency uint16 - -const ( - Any Consistency = 0x00 - One Consistency = 0x01 - Two Consistency = 0x02 - Three Consistency = 0x03 - Quorum Consistency = 0x04 - All Consistency = 0x05 - LocalQuorum Consistency = 0x06 - EachQuorum Consistency = 0x07 - LocalOne Consistency = 0x0A -) - -func (c Consistency) String() string { - switch c { - case Any: - return "ANY" - case One: - return "ONE" - case Two: - return "TWO" - case Three: - return "THREE" - case Quorum: - return "QUORUM" - case All: - return "ALL" - case LocalQuorum: - return "LOCAL_QUORUM" - case EachQuorum: - return "EACH_QUORUM" - case LocalOne: - return "LOCAL_ONE" - default: - return fmt.Sprintf("UNKNOWN_CONS_0x%x", uint16(c)) - } -} - -type SerialConsistency uint16 - -const ( - Serial SerialConsistency = 0x08 - LocalSerial SerialConsistency = 0x09 -) - -func (s SerialConsistency) String() string { - switch s { - case Serial: - return "SERIAL" - case LocalSerial: - return "LOCAL_SERIAL" - default: - return fmt.Sprintf("UNKNOWN_SERIAL_CONS_0x%x", uint16(s)) - } -} - -const ( - apacheCassandraTypePrefix = "org.apache.cassandra.db.marshal." -) - -var ( - ErrFrameTooBig = errors.New("frame length is bigger than the maximum alowed") -) - -func writeInt(p []byte, n int32) { - p[0] = byte(n >> 24) - p[1] = byte(n >> 16) - p[2] = byte(n >> 8) - p[3] = byte(n) -} - -func readInt(p []byte) int32 { - return int32(p[0])<<24 | int32(p[1])<<16 | int32(p[2])<<8 | int32(p[3]) -} - -func writeShort(p []byte, n uint16) { - p[0] = byte(n >> 8) - p[1] = byte(n) -} - -func readShort(p []byte) uint16 { - return uint16(p[0])<<8 | uint16(p[1]) -} - -type frameHeader struct { - version protoVersion - flags byte - stream int - op frameOp - length int -} - -func (f frameHeader) String() string { - return fmt.Sprintf("[header version=%s flags=0x%x stream=%d op=%s length=%d]", f.version, f.flags, f.stream, f.op, f.length) -} - -func (f frameHeader) Header() frameHeader { - return f -} - -const defaultBufSize = 128 - -var framerPool = sync.Pool{ - New: func() interface{} { - return &framer{ - wbuf: make([]byte, defaultBufSize), - readBuffer: make([]byte, defaultBufSize), - } - }, -} - -// a framer is responsible for reading, writing and parsing frames on a single stream -type framer struct { - r io.Reader - w io.Writer - - proto byte - // flags are for outgoing flags, enabling compression and tracing etc - flags byte - compres Compressor - headSize int - // if this frame was read then the header will be here - header *frameHeader - - // if tracing flag is set this is not nil - traceID []byte - - // holds a ref to the whole byte slice for rbuf so that it can be reset to - // 0 after a read. - readBuffer []byte - - rbuf []byte - wbuf []byte -} - -func newFramer(r io.Reader, w io.Writer, compressor Compressor, version byte) *framer { - f := framerPool.Get().(*framer) - var flags byte - if compressor != nil { - flags |= flagCompress - } - - version &= protoVersionMask - - headSize := 8 - if version > protoVersion2 { - headSize = 9 - } - - f.compres = compressor - f.proto = version - f.flags = flags - f.headSize = headSize - - f.r = r - f.rbuf = f.readBuffer[:0] - - f.w = w - f.wbuf = f.wbuf[:0] - - f.header = nil - f.traceID = nil - - return f -} - -type frame interface { - Header() frameHeader -} - -func readHeader(r io.Reader, p []byte) (head frameHeader, err error) { - _, err = io.ReadFull(r, p) - if err != nil { - return - } - - version := p[0] & protoVersionMask - - if version < protoVersion1 || version > protoVersion3 { - err = fmt.Errorf("invalid version: %x", version) - return - } - - head.version = protoVersion(p[0]) - head.flags = p[1] - - if version > protoVersion2 { - if len(p) < 9 { - return frameHeader{}, fmt.Errorf("not enough bytes to read header require 9 got: %d", len(p)) - } - - head.stream = int(int16(p[2])<<8 | int16(p[3])) - head.op = frameOp(p[4]) - head.length = int(readInt(p[5:])) - } else { - if len(p) < 8 { - return frameHeader{}, fmt.Errorf("not enough bytes to read header require 8 got: %d", len(p)) - } - - head.stream = int(int8(p[2])) - head.op = frameOp(p[3]) - head.length = int(readInt(p[4:])) - } - - return -} - -// explicitly enables tracing for the framers outgoing requests -func (f *framer) trace() { - f.flags |= flagTracing -} - -// reads a frame form the wire into the framers buffer -func (f *framer) readFrame(head *frameHeader) error { - if head.length < 0 { - return fmt.Errorf("frame body length can not be less than 0: %d", head.length) - } else if head.length > maxFrameSize { - // need to free up the connection to be used again - _, err := io.CopyN(ioutil.Discard, f.r, int64(head.length)) - if err != nil { - return fmt.Errorf("error whilst trying to discard frame with invalid length: %v", err) - } - return ErrFrameTooBig - } - - if cap(f.readBuffer) >= head.length { - f.rbuf = f.readBuffer[:head.length] - } else { - f.readBuffer = make([]byte, head.length) - f.rbuf = f.readBuffer - } - - // assume the underlying reader takes care of timeouts and retries - _, err := io.ReadFull(f.r, f.rbuf) - if err != nil { - return err - } - - if head.flags&flagCompress == flagCompress { - if f.compres == nil { - return NewErrProtocol("no compressor available with compressed frame body") - } - - f.rbuf, err = f.compres.Decode(f.rbuf) - if err != nil { - return err - } - } - - f.header = head - return nil -} - -func (f *framer) parseFrame() (frame frame, err error) { - defer func() { - if r := recover(); r != nil { - if _, ok := r.(runtime.Error); ok { - panic(r) - } - err = r.(error) - } - }() - - if f.header.version.request() { - return nil, NewErrProtocol("got a request frame from server: %v", f.header.version) - } - - if f.header.flags&flagTracing == flagTracing { - f.readTrace() - } - - // asumes that the frame body has been read into rbuf - switch f.header.op { - case opError: - frame = f.parseErrorFrame() - case opReady: - frame = f.parseReadyFrame() - case opResult: - frame, err = f.parseResultFrame() - case opSupported: - frame = f.parseSupportedFrame() - case opAuthenticate: - frame = f.parseAuthenticateFrame() - case opAuthChallenge: - frame = f.parseAuthChallengeFrame() - case opAuthSuccess: - frame = f.parseAuthSuccessFrame() - default: - return nil, NewErrProtocol("unknown op in frame header: %s", f.header.op) - } - - return -} - -func (f *framer) parseErrorFrame() frame { - code := f.readInt() - msg := f.readString() - - errD := errorFrame{ - frameHeader: *f.header, - code: code, - message: msg, - } - - switch code { - case errUnavailable: - cl := f.readConsistency() - required := f.readInt() - alive := f.readInt() - return &RequestErrUnavailable{ - errorFrame: errD, - Consistency: cl, - Required: required, - Alive: alive, - } - case errWriteTimeout: - cl := f.readConsistency() - received := f.readInt() - blockfor := f.readInt() - writeType := f.readString() - return &RequestErrWriteTimeout{ - errorFrame: errD, - Consistency: cl, - Received: received, - BlockFor: blockfor, - WriteType: writeType, - } - case errReadTimeout: - cl := f.readConsistency() - received := f.readInt() - blockfor := f.readInt() - dataPresent := f.readByte() - return &RequestErrReadTimeout{ - errorFrame: errD, - Consistency: cl, - Received: received, - BlockFor: blockfor, - DataPresent: dataPresent, - } - case errAlreadyExists: - ks := f.readString() - table := f.readString() - return &RequestErrAlreadyExists{ - errorFrame: errD, - Keyspace: ks, - Table: table, - } - case errUnprepared: - stmtId := f.readShortBytes() - return &RequestErrUnprepared{ - errorFrame: errD, - StatementId: stmtId, - } - default: - return &errD - } -} - -func (f *framer) writeHeader(flags byte, op frameOp, stream int) { - f.wbuf = f.wbuf[:0] - f.wbuf = append(f.wbuf, - f.proto, - flags, - ) - - if f.proto > protoVersion2 { - f.wbuf = append(f.wbuf, - byte(stream>>8), - byte(stream), - ) - } else { - f.wbuf = append(f.wbuf, - byte(stream), - ) - } - - // pad out length - f.wbuf = append(f.wbuf, - byte(op), - 0, - 0, - 0, - 0, - ) -} - -func (f *framer) setLength(length int) { - p := 4 - if f.proto > protoVersion2 { - p = 5 - } - - f.wbuf[p+0] = byte(length >> 24) - f.wbuf[p+1] = byte(length >> 16) - f.wbuf[p+2] = byte(length >> 8) - f.wbuf[p+3] = byte(length) -} - -func (f *framer) finishWrite() error { - if len(f.wbuf) > maxFrameSize { - // huge app frame, lets remove it so it doesnt bloat the heap - f.wbuf = make([]byte, defaultBufSize) - return ErrFrameTooBig - } - - if f.wbuf[1]&flagCompress == flagCompress { - if f.compres == nil { - panic("compress flag set with no compressor") - } - - // TODO: only compress frames which are big enough - compressed, err := f.compres.Encode(f.wbuf[f.headSize:]) - if err != nil { - return err - } - - f.wbuf = append(f.wbuf[:f.headSize], compressed...) - } - length := len(f.wbuf) - f.headSize - f.setLength(length) - - _, err := f.w.Write(f.wbuf) - if err != nil { - return err - } - - return nil -} - -func (f *framer) readTrace() { - f.traceID = f.readUUID().Bytes() -} - -type readyFrame struct { - frameHeader -} - -func (f *framer) parseReadyFrame() frame { - return &readyFrame{ - frameHeader: *f.header, - } -} - -type supportedFrame struct { - frameHeader - - supported map[string][]string -} - -// TODO: if we move the body buffer onto the frameHeader then we only need a single -// framer, and can move the methods onto the header. -func (f *framer) parseSupportedFrame() frame { - return &supportedFrame{ - frameHeader: *f.header, - - supported: f.readStringMultiMap(), - } -} - -type writeStartupFrame struct { - opts map[string]string -} - -func (w *writeStartupFrame) writeFrame(framer *framer, streamID int) error { - return framer.writeStartupFrame(streamID, w.opts) -} - -func (f *framer) writeStartupFrame(streamID int, options map[string]string) error { - f.writeHeader(f.flags&^flagCompress, opStartup, streamID) - f.writeStringMap(options) - - return f.finishWrite() -} - -type writePrepareFrame struct { - statement string -} - -func (w *writePrepareFrame) writeFrame(framer *framer, streamID int) error { - return framer.writePrepareFrame(streamID, w.statement) -} - -func (f *framer) writePrepareFrame(stream int, statement string) error { - f.writeHeader(f.flags, opPrepare, stream) - f.writeLongString(statement) - return f.finishWrite() -} - -func (f *framer) readTypeInfo() TypeInfo { - // TODO: factor this out so the same code paths can be used to parse custom - // types and other types, as much of the logic will be duplicated. - id := f.readShort() - - simple := NativeType{ - proto: f.proto, - typ: Type(id), - } - - if simple.typ == TypeCustom { - simple.custom = f.readString() - if cassType := getApacheCassandraType(simple.custom); cassType != TypeCustom { - simple.typ = cassType - } - } - - switch simple.typ { - case TypeTuple: - n := f.readShort() - tuple := TupleTypeInfo{ - NativeType: simple, - Elems: make([]TypeInfo, n), - } - - for i := 0; i < int(n); i++ { - tuple.Elems[i] = f.readTypeInfo() - } - - return tuple - - case TypeUDT: - udt := UDTTypeInfo{ - NativeType: simple, - } - udt.KeySpace = f.readString() - udt.Name = f.readString() - - n := f.readShort() - udt.Elements = make([]UDTField, n) - for i := 0; i < int(n); i++ { - field := &udt.Elements[i] - field.Name = f.readString() - field.Type = f.readTypeInfo() - } - - return udt - case TypeMap, TypeList, TypeSet: - collection := CollectionType{ - NativeType: simple, - } - - if simple.typ == TypeMap { - collection.Key = f.readTypeInfo() - } - - collection.Elem = f.readTypeInfo() - - return collection - } - - return simple -} - -type resultMetadata struct { - flags int - - // only if flagPageState - pagingState []byte - - columns []ColumnInfo - - // this is a count of the total number of columns which can be scanned, - // it is at minimum len(columns) but may be larger, for instance when a column - // is a UDT or tuple. - actualColCount int -} - -func (r resultMetadata) String() string { - return fmt.Sprintf("[metadata flags=0x%x paging_state=% X columns=%v]", r.flags, r.pagingState, r.columns) -} - -func (f *framer) readCol(col *ColumnInfo, meta *resultMetadata, globalSpec bool, keyspace, table string) { - if !globalSpec { - col.Keyspace = f.readString() - col.Table = f.readString() - } else { - col.Keyspace = keyspace - col.Table = table - } - - col.Name = f.readString() - col.TypeInfo = f.readTypeInfo() - switch v := col.TypeInfo.(type) { - // maybe also UDT - case TupleTypeInfo: - // -1 because we already included the tuple column - meta.actualColCount += len(v.Elems) - 1 - } -} - -func (f *framer) parseResultMetadata() resultMetadata { - meta := resultMetadata{ - flags: f.readInt(), - } - - colCount := f.readInt() - if colCount < 0 { - panic(fmt.Errorf("received negative column count: %d", colCount)) - } - meta.actualColCount = colCount - - if meta.flags&flagHasMorePages == flagHasMorePages { - meta.pagingState = f.readBytes() - } - - if meta.flags&flagNoMetaData == flagNoMetaData { - return meta - } - - var keyspace, table string - globalSpec := meta.flags&flagGlobalTableSpec == flagGlobalTableSpec - if globalSpec { - keyspace = f.readString() - table = f.readString() - } - - var cols []ColumnInfo - if colCount < 1000 { - // preallocate columninfo to avoid excess copying - cols = make([]ColumnInfo, colCount) - for i := 0; i < colCount; i++ { - f.readCol(&cols[i], &meta, globalSpec, keyspace, table) - } - - } else { - // use append, huge number of columns usually indicates a corrupt frame or - // just a huge row. - for i := 0; i < colCount; i++ { - var col ColumnInfo - f.readCol(&col, &meta, globalSpec, keyspace, table) - cols = append(cols, col) - } - } - - meta.columns = cols - - return meta -} - -type resultVoidFrame struct { - frameHeader -} - -func (f *resultVoidFrame) String() string { - return "[result_void]" -} - -func (f *framer) parseResultFrame() (frame, error) { - kind := f.readInt() - - switch kind { - case resultKindVoid: - return &resultVoidFrame{frameHeader: *f.header}, nil - case resultKindRows: - return f.parseResultRows(), nil - case resultKindKeyspace: - return f.parseResultSetKeyspace(), nil - case resultKindPrepared: - return f.parseResultPrepared(), nil - case resultKindSchemaChanged: - return f.parseResultSchemaChange(), nil - } - - return nil, NewErrProtocol("unknown result kind: %x", kind) -} - -type resultRowsFrame struct { - frameHeader - - meta resultMetadata - rows [][][]byte -} - -func (f *resultRowsFrame) String() string { - return fmt.Sprintf("[result_rows meta=%v]", f.meta) -} - -func (f *framer) parseResultRows() frame { - meta := f.parseResultMetadata() - - numRows := f.readInt() - if numRows < 0 { - panic(fmt.Errorf("invalid row_count in result frame: %d", numRows)) - } - - colCount := len(meta.columns) - - rows := make([][][]byte, numRows) - for i := 0; i < numRows; i++ { - rows[i] = make([][]byte, colCount) - for j := 0; j < colCount; j++ { - rows[i][j] = f.readBytes() - } - } - - return &resultRowsFrame{ - frameHeader: *f.header, - meta: meta, - rows: rows, - } -} - -type resultKeyspaceFrame struct { - frameHeader - keyspace string -} - -func (r *resultKeyspaceFrame) String() string { - return fmt.Sprintf("[result_keyspace keyspace=%s]", r.keyspace) -} - -func (f *framer) parseResultSetKeyspace() frame { - return &resultKeyspaceFrame{ - frameHeader: *f.header, - keyspace: f.readString(), - } -} - -type resultPreparedFrame struct { - frameHeader - - preparedID []byte - reqMeta resultMetadata - respMeta resultMetadata -} - -func (f *framer) parseResultPrepared() frame { - frame := &resultPreparedFrame{ - frameHeader: *f.header, - preparedID: f.readShortBytes(), - reqMeta: f.parseResultMetadata(), - } - - if f.proto < protoVersion2 { - return frame - } - - frame.respMeta = f.parseResultMetadata() - - return frame -} - -type resultSchemaChangeFrame struct { - frameHeader - - change string - keyspace string - table string -} - -func (s *resultSchemaChangeFrame) String() string { - return fmt.Sprintf("[result_schema_change change=%s keyspace=%s table=%s]", s.change, s.keyspace, s.table) -} - -func (f *framer) parseResultSchemaChange() frame { - frame := &resultSchemaChangeFrame{ - frameHeader: *f.header, - } - - if f.proto < protoVersion3 { - frame.change = f.readString() - frame.keyspace = f.readString() - frame.table = f.readString() - } else { - // TODO: improve type representation of this - frame.change = f.readString() - target := f.readString() - switch target { - case "KEYSPACE": - frame.keyspace = f.readString() - case "TABLE", "TYPE": - frame.keyspace = f.readString() - frame.table = f.readString() - } - } - - return frame -} - -type authenticateFrame struct { - frameHeader - - class string -} - -func (a *authenticateFrame) String() string { - return fmt.Sprintf("[authenticate class=%q]", a.class) -} - -func (f *framer) parseAuthenticateFrame() frame { - return &authenticateFrame{ - frameHeader: *f.header, - class: f.readString(), - } -} - -type authSuccessFrame struct { - frameHeader - - data []byte -} - -func (a *authSuccessFrame) String() string { - return fmt.Sprintf("[auth_success data=%q]", a.data) -} - -func (f *framer) parseAuthSuccessFrame() frame { - return &authSuccessFrame{ - frameHeader: *f.header, - data: f.readBytes(), - } -} - -type authChallengeFrame struct { - frameHeader - - data []byte -} - -func (a *authChallengeFrame) String() string { - return fmt.Sprintf("[auth_challenge data=%q]", a.data) -} - -func (f *framer) parseAuthChallengeFrame() frame { - return &authChallengeFrame{ - frameHeader: *f.header, - data: f.readBytes(), - } -} - -type writeAuthResponseFrame struct { - data []byte -} - -func (a *writeAuthResponseFrame) String() string { - return fmt.Sprintf("[auth_response data=%q]", a.data) -} - -func (a *writeAuthResponseFrame) writeFrame(framer *framer, streamID int) error { - return framer.writeAuthResponseFrame(streamID, a.data) -} - -func (f *framer) writeAuthResponseFrame(streamID int, data []byte) error { - f.writeHeader(f.flags, opAuthResponse, streamID) - f.writeBytes(data) - return f.finishWrite() -} - -type queryValues struct { - value []byte - // optional name, will set With names for values flag - name string -} - -type queryParams struct { - consistency Consistency - // v2+ - skipMeta bool - values []queryValues - pageSize int - pagingState []byte - serialConsistency SerialConsistency - // v3+ - defaultTimestamp bool -} - -func (q queryParams) String() string { - return fmt.Sprintf("[query_params consistency=%v skip_meta=%v page_size=%d paging_state=%q serial_consistency=%v default_timestamp=%v values=%v]", - q.consistency, q.skipMeta, q.pageSize, q.pagingState, q.serialConsistency, q.defaultTimestamp, q.values) -} - -func (f *framer) writeQueryParams(opts *queryParams) { - f.writeConsistency(opts.consistency) - - if f.proto == protoVersion1 { - return - } - - var flags byte - if len(opts.values) > 0 { - flags |= flagValues - } - if opts.skipMeta { - flags |= flagSkipMetaData - } - if opts.pageSize > 0 { - flags |= flagPageSize - } - if len(opts.pagingState) > 0 { - flags |= flagWithPagingState - } - if opts.serialConsistency > 0 { - flags |= flagWithSerialConsistency - } - - names := false - - // protoV3 specific things - if f.proto > protoVersion2 { - if opts.defaultTimestamp { - flags |= flagDefaultTimestamp - } - - if len(opts.values) > 0 && opts.values[0].name != "" { - flags |= flagWithNameValues - names = true - } - } - - f.writeByte(flags) - - if n := len(opts.values); n > 0 { - f.writeShort(uint16(n)) - for i := 0; i < n; i++ { - if names { - f.writeString(opts.values[i].name) - } - f.writeBytes(opts.values[i].value) - } - } - - if opts.pageSize > 0 { - f.writeInt(int32(opts.pageSize)) - } - - if len(opts.pagingState) > 0 { - f.writeBytes(opts.pagingState) - } - - if opts.serialConsistency > 0 { - f.writeConsistency(Consistency(opts.serialConsistency)) - } - - if f.proto > protoVersion2 && opts.defaultTimestamp { - // timestamp in microseconds - ts := time.Now().UnixNano() / 1000 - f.writeLong(ts) - } -} - -type writeQueryFrame struct { - statement string - params queryParams -} - -func (w *writeQueryFrame) String() string { - return fmt.Sprintf("[query statement=%q params=%v]", w.statement, w.params) -} - -func (w *writeQueryFrame) writeFrame(framer *framer, streamID int) error { - return framer.writeQueryFrame(streamID, w.statement, &w.params) -} - -func (f *framer) writeQueryFrame(streamID int, statement string, params *queryParams) error { - f.writeHeader(f.flags, opQuery, streamID) - f.writeLongString(statement) - f.writeQueryParams(params) - - return f.finishWrite() -} - -type frameWriter interface { - writeFrame(framer *framer, streamID int) error -} - -type writeExecuteFrame struct { - preparedID []byte - params queryParams -} - -func (e *writeExecuteFrame) String() string { - return fmt.Sprintf("[execute id=% X params=%v]", e.preparedID, &e.params) -} - -func (e *writeExecuteFrame) writeFrame(fr *framer, streamID int) error { - return fr.writeExecuteFrame(streamID, e.preparedID, &e.params) -} - -func (f *framer) writeExecuteFrame(streamID int, preparedID []byte, params *queryParams) error { - f.writeHeader(f.flags, opExecute, streamID) - f.writeShortBytes(preparedID) - if f.proto > protoVersion1 { - f.writeQueryParams(params) - } else { - n := len(params.values) - f.writeShort(uint16(n)) - for i := 0; i < n; i++ { - f.writeBytes(params.values[i].value) - } - f.writeConsistency(params.consistency) - } - - return f.finishWrite() -} - -// TODO: can we replace BatchStatemt with batchStatement? As they prety much -// duplicate each other -type batchStatment struct { - preparedID []byte - statement string - values []queryValues -} - -type writeBatchFrame struct { - typ BatchType - statements []batchStatment - consistency Consistency - - // v3+ - serialConsistency SerialConsistency - defaultTimestamp bool -} - -func (w *writeBatchFrame) writeFrame(framer *framer, streamID int) error { - return framer.writeBatchFrame(streamID, w) -} - -func (f *framer) writeBatchFrame(streamID int, w *writeBatchFrame) error { - f.writeHeader(f.flags, opBatch, streamID) - f.writeByte(byte(w.typ)) - - n := len(w.statements) - f.writeShort(uint16(n)) - - var flags byte - - for i := 0; i < n; i++ { - b := &w.statements[i] - if len(b.preparedID) == 0 { - f.writeByte(0) - f.writeLongString(b.statement) - } else { - f.writeByte(1) - f.writeShortBytes(b.preparedID) - } - - f.writeShort(uint16(len(b.values))) - for j := range b.values { - col := &b.values[j] - if f.proto > protoVersion2 && col.name != "" { - // TODO: move this check into the caller and set a flag on writeBatchFrame - // to indicate using named values - flags |= flagWithNameValues - f.writeString(col.name) - } - f.writeBytes(col.value) - } - } - - f.writeConsistency(w.consistency) - - if f.proto > protoVersion2 { - if w.serialConsistency > 0 { - flags |= flagWithSerialConsistency - } - if w.defaultTimestamp { - flags |= flagDefaultTimestamp - } - - f.writeByte(flags) - - if w.serialConsistency > 0 { - f.writeConsistency(Consistency(w.serialConsistency)) - } - if w.defaultTimestamp { - now := time.Now().UnixNano() / 1000 - f.writeLong(now) - } - } - - return f.finishWrite() -} - -func (f *framer) readByte() byte { - if len(f.rbuf) < 1 { - panic(fmt.Errorf("not enough bytes in buffer to read byte require 1 got: %d", len(f.rbuf))) - } - - b := f.rbuf[0] - f.rbuf = f.rbuf[1:] - return b -} - -func (f *framer) readInt() (n int) { - if len(f.rbuf) < 4 { - panic(fmt.Errorf("not enough bytes in buffer to read int require 4 got: %d", len(f.rbuf))) - } - - n = int(int32(f.rbuf[0])<<24 | int32(f.rbuf[1])<<16 | int32(f.rbuf[2])<<8 | int32(f.rbuf[3])) - f.rbuf = f.rbuf[4:] - return -} - -func (f *framer) readShort() (n uint16) { - if len(f.rbuf) < 2 { - panic(fmt.Errorf("not enough bytes in buffer to read short require 2 got: %d", len(f.rbuf))) - } - n = uint16(f.rbuf[0])<<8 | uint16(f.rbuf[1]) - f.rbuf = f.rbuf[2:] - return -} - -func (f *framer) readLong() (n int64) { - if len(f.rbuf) < 8 { - panic(fmt.Errorf("not enough bytes in buffer to read long require 8 got: %d", len(f.rbuf))) - } - n = int64(f.rbuf[0])<<56 | int64(f.rbuf[1])<<48 | int64(f.rbuf[2])<<40 | int64(f.rbuf[3])<<32 | - int64(f.rbuf[4])<<24 | int64(f.rbuf[5])<<16 | int64(f.rbuf[6])<<8 | int64(f.rbuf[7]) - f.rbuf = f.rbuf[8:] - return -} - -func (f *framer) readString() (s string) { - size := f.readShort() - - if len(f.rbuf) < int(size) { - panic(fmt.Errorf("not enough bytes in buffer to read string require %d got: %d", size, len(f.rbuf))) - } - - s = string(f.rbuf[:size]) - f.rbuf = f.rbuf[size:] - return -} - -func (f *framer) readLongString() (s string) { - size := f.readInt() - - if len(f.rbuf) < size { - panic(fmt.Errorf("not enough bytes in buffer to read long string require %d got: %d", size, len(f.rbuf))) - } - - s = string(f.rbuf[:size]) - f.rbuf = f.rbuf[size:] - return -} - -func (f *framer) readUUID() *UUID { - if len(f.rbuf) < 16 { - panic(fmt.Errorf("not enough bytes in buffer to read uuid require %d got: %d", 16, len(f.rbuf))) - } - - // TODO: how to handle this error, if it is a uuid, then sureley, problems? - u, _ := UUIDFromBytes(f.rbuf[:16]) - f.rbuf = f.rbuf[16:] - return &u -} - -func (f *framer) readStringList() []string { - size := f.readShort() - - l := make([]string, size) - for i := 0; i < int(size); i++ { - l[i] = f.readString() - } - - return l -} - -func (f *framer) readBytes() []byte { - size := f.readInt() - if size < 0 { - return nil - } - - if len(f.rbuf) < size { - panic(fmt.Errorf("not enough bytes in buffer to read bytes require %d got: %d", size, len(f.rbuf))) - } - - // we cant make assumptions about the length of the life of the supplied byte - // slice so we defensivly copy it out of the underlying buffer. This has the - // downside of increasing allocs per read but will provide much greater memory - // safety. The allocs can hopefully be improved in the future. - // TODO: dont copy into a new slice - l := make([]byte, size) - copy(l, f.rbuf[:size]) - f.rbuf = f.rbuf[size:] - - return l -} - -func (f *framer) readShortBytes() []byte { - size := f.readShort() - if len(f.rbuf) < int(size) { - panic(fmt.Errorf("not enough bytes in buffer to read short bytes: require %d got %d", size, len(f.rbuf))) - } - - l := make([]byte, size) - copy(l, f.rbuf[:size]) - f.rbuf = f.rbuf[size:] - - return l -} - -func (f *framer) readInet() (net.IP, int) { - if len(f.rbuf) < 1 { - panic(fmt.Errorf("not enough bytes in buffer to read inet size require %d got: %d", 1, len(f.rbuf))) - } - - size := f.rbuf[0] - f.rbuf = f.rbuf[1:] - - if !(size == 4 || size == 16) { - panic(fmt.Errorf("invalid IP size: %d", size)) - } - - if len(f.rbuf) < 1 { - panic(fmt.Errorf("not enough bytes in buffer to read inet require %d got: %d", size, len(f.rbuf))) - } - - ip := make([]byte, size) - copy(ip, f.rbuf[:size]) - f.rbuf = f.rbuf[size:] - - port := f.readInt() - return net.IP(ip), port -} - -func (f *framer) readConsistency() Consistency { - return Consistency(f.readShort()) -} - -func (f *framer) readStringMap() map[string]string { - size := f.readShort() - m := make(map[string]string) - - for i := 0; i < int(size); i++ { - k := f.readString() - v := f.readString() - m[k] = v - } - - return m -} - -func (f *framer) readStringMultiMap() map[string][]string { - size := f.readShort() - m := make(map[string][]string) - - for i := 0; i < int(size); i++ { - k := f.readString() - v := f.readStringList() - m[k] = v - } - - return m -} - -func (f *framer) writeByte(b byte) { - f.wbuf = append(f.wbuf, b) -} - -// these are protocol level binary types -func (f *framer) writeInt(n int32) { - f.wbuf = append(f.wbuf, - byte(n>>24), - byte(n>>16), - byte(n>>8), - byte(n), - ) -} - -func (f *framer) writeShort(n uint16) { - f.wbuf = append(f.wbuf, - byte(n>>8), - byte(n), - ) -} - -func (f *framer) writeLong(n int64) { - f.wbuf = append(f.wbuf, - byte(n>>56), - byte(n>>48), - byte(n>>40), - byte(n>>32), - byte(n>>24), - byte(n>>16), - byte(n>>8), - byte(n), - ) -} - -func (f *framer) writeString(s string) { - f.writeShort(uint16(len(s))) - f.wbuf = append(f.wbuf, s...) -} - -func (f *framer) writeLongString(s string) { - f.writeInt(int32(len(s))) - f.wbuf = append(f.wbuf, s...) -} - -func (f *framer) writeUUID(u *UUID) { - f.wbuf = append(f.wbuf, u[:]...) -} - -func (f *framer) writeStringList(l []string) { - f.writeShort(uint16(len(l))) - for _, s := range l { - f.writeString(s) - } -} - -func (f *framer) writeBytes(p []byte) { - // TODO: handle null case correctly, - // [bytes] A [int] n, followed by n bytes if n >= 0. If n < 0, - // no byte should follow and the value represented is `null`. - if p == nil { - f.writeInt(-1) - } else { - f.writeInt(int32(len(p))) - f.wbuf = append(f.wbuf, p...) - } -} - -func (f *framer) writeShortBytes(p []byte) { - f.writeShort(uint16(len(p))) - f.wbuf = append(f.wbuf, p...) -} - -func (f *framer) writeInet(ip net.IP, port int) { - f.wbuf = append(f.wbuf, - byte(len(ip)), - ) - - f.wbuf = append(f.wbuf, - []byte(ip)..., - ) - - f.writeInt(int32(port)) -} - -func (f *framer) writeConsistency(cons Consistency) { - f.writeShort(uint16(cons)) -} - -func (f *framer) writeStringMap(m map[string]string) { - f.writeShort(uint16(len(m))) - for k, v := range m { - f.writeString(k) - f.writeString(v) - } -} diff --git a/vendor/github.com/gocql/gocql/frame_test.go b/vendor/github.com/gocql/gocql/frame_test.go deleted file mode 100644 index 87dcfb9a7..000000000 --- a/vendor/github.com/gocql/gocql/frame_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package gocql - -import ( - "bytes" - "testing" -) - -func TestFuzzBugs(t *testing.T) { - // these inputs are found using go-fuzz (https://github.com/dvyukov/go-fuzz) - // and should cause a panic unless fixed. - tests := [][]byte{ - []byte("00000\xa0000"), - []byte("\x8000\x0e\x00\x00\x00\x000"), - []byte("\x8000\x00\x00\x00\x00\t0000000000"), - []byte("\xa0\xff\x01\xae\xefqE\xf2\x1a"), - []byte("\x8200\b\x00\x00\x00c\x00\x00\x00\x02000\x01\x00\x00\x00\x03" + - "\x00\n0000000000\x00\x14000000" + - "00000000000000\x00\x020000" + - "\x00\a000000000\x00\x050000000" + - "\xff0000000000000000000" + - "0000000"), - []byte("\x82\xe600\x00\x00\x00\x000"), - []byte("\x8200\b\x00\x00\x00\b0\x00\x00\x00\x040000"), - []byte("\x8200\x00\x00\x00\x00\x100\x00\x00\x12\x00\x00\x0000000" + - "00000"), - []byte("\x83000\b\x00\x00\x00\x14\x00\x00\x00\x020000000" + - "000000000"), - []byte("\x83000\b\x00\x00\x000\x00\x00\x00\x04\x00\x1000000" + - "00000000000000e00000" + - "000\x800000000000000000" + - "0000000000000"), - } - - for i, test := range tests { - t.Logf("test %d input: %q", i, test) - - var bw bytes.Buffer - - r := bytes.NewReader(test) - head, err := readHeader(r, make([]byte, 9)) - if err != nil { - continue - } - - framer := newFramer(r, &bw, nil, byte(head.version)) - err = framer.readFrame(&head) - if err != nil { - continue - } - - _, err = framer.parseFrame() - if err != nil { - continue - } - - t.Errorf("(%d) expected to fail for input %q", i, test) - } -} - -func TestFrameWriteTooLong(t *testing.T) { - w := &bytes.Buffer{} - framer := newFramer(nil, w, nil, 2) - - framer.writeHeader(0, opStartup, 1) - framer.writeBytes(make([]byte, maxFrameSize+1)) - err := framer.finishWrite() - if err != ErrFrameTooBig { - t.Fatalf("expected to get %v got %v", ErrFrameTooBig, err) - } -} - -func TestFrameReadTooLong(t *testing.T) { - r := &bytes.Buffer{} - r.Write(make([]byte, maxFrameSize+1)) - // write a new header right after this frame to verify that we can read it - r.Write([]byte{0x02, 0x00, 0x00, opReady, 0x00, 0x00, 0x00, 0x00}) - - framer := newFramer(r, nil, nil, 2) - - head := frameHeader{ - version: 2, - op: opReady, - length: r.Len() - 8, - } - - err := framer.readFrame(&head) - if err != ErrFrameTooBig { - t.Fatalf("expected to get %v got %v", ErrFrameTooBig, err) - } - - head, err = readHeader(r, make([]byte, 8)) - if err != nil { - t.Fatal(err) - } - if head.op != opReady { - t.Fatalf("expected to get header %v got %v", opReady, head.op) - } -} diff --git a/vendor/github.com/gocql/gocql/fuzz.go b/vendor/github.com/gocql/gocql/fuzz.go deleted file mode 100644 index 3606f9381..000000000 --- a/vendor/github.com/gocql/gocql/fuzz.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build gofuzz - -package gocql - -import "bytes" - -func Fuzz(data []byte) int { - var bw bytes.Buffer - - r := bytes.NewReader(data) - - head, err := readHeader(r, make([]byte, 9)) - if err != nil { - return 0 - } - - framer := newFramer(r, &bw, nil, byte(head.version)) - err = framer.readFrame(&head) - if err != nil { - return 0 - } - - frame, err := framer.parseFrame() - if err != nil { - return 0 - } - - if frame != nil { - return 1 - } - - return 2 -} diff --git a/vendor/github.com/gocql/gocql/helpers.go b/vendor/github.com/gocql/gocql/helpers.go deleted file mode 100644 index 8e1ca0a4b..000000000 --- a/vendor/github.com/gocql/gocql/helpers.go +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "math/big" - "reflect" - "strings" - "time" - - "gopkg.in/inf.v0" -) - -type RowData struct { - Columns []string - Values []interface{} -} - -func goType(t TypeInfo) reflect.Type { - switch t.Type() { - case TypeVarchar, TypeAscii, TypeInet: - return reflect.TypeOf(*new(string)) - case TypeBigInt, TypeCounter: - return reflect.TypeOf(*new(int64)) - case TypeTimestamp: - return reflect.TypeOf(*new(time.Time)) - case TypeBlob: - return reflect.TypeOf(*new([]byte)) - case TypeBoolean: - return reflect.TypeOf(*new(bool)) - case TypeFloat: - return reflect.TypeOf(*new(float32)) - case TypeDouble: - return reflect.TypeOf(*new(float64)) - case TypeInt: - return reflect.TypeOf(*new(int)) - case TypeDecimal: - return reflect.TypeOf(*new(*inf.Dec)) - case TypeUUID, TypeTimeUUID: - return reflect.TypeOf(*new(UUID)) - case TypeList, TypeSet: - return reflect.SliceOf(goType(t.(CollectionType).Elem)) - case TypeMap: - return reflect.MapOf(goType(t.(CollectionType).Key), goType(t.(CollectionType).Elem)) - case TypeVarint: - return reflect.TypeOf(*new(*big.Int)) - case TypeTuple: - // what can we do here? all there is to do is to make a list of interface{} - tuple := t.(TupleTypeInfo) - return reflect.TypeOf(make([]interface{}, len(tuple.Elems))) - default: - return nil - } -} - -func dereference(i interface{}) interface{} { - return reflect.Indirect(reflect.ValueOf(i)).Interface() -} - -func getApacheCassandraType(class string) Type { - switch strings.TrimPrefix(class, apacheCassandraTypePrefix) { - case "AsciiType": - return TypeAscii - case "LongType": - return TypeBigInt - case "BytesType": - return TypeBlob - case "BooleanType": - return TypeBoolean - case "CounterColumnType": - return TypeCounter - case "DecimalType": - return TypeDecimal - case "DoubleType": - return TypeDouble - case "FloatType": - return TypeFloat - case "Int32Type": - return TypeInt - case "DateType", "TimestampType": - return TypeTimestamp - case "UUIDType": - return TypeUUID - case "UTF8Type": - return TypeVarchar - case "IntegerType": - return TypeVarint - case "TimeUUIDType": - return TypeTimeUUID - case "InetAddressType": - return TypeInet - case "MapType": - return TypeMap - case "ListType": - return TypeList - case "SetType": - return TypeSet - case "TupleType": - return TypeTuple - default: - return TypeCustom - } -} - -func (r *RowData) rowMap(m map[string]interface{}) { - for i, column := range r.Columns { - val := dereference(r.Values[i]) - if valVal := reflect.ValueOf(val); valVal.Kind() == reflect.Slice { - valCopy := reflect.MakeSlice(valVal.Type(), valVal.Len(), valVal.Cap()) - reflect.Copy(valCopy, valVal) - m[column] = valCopy.Interface() - } else { - m[column] = val - } - } -} - -func (iter *Iter) RowData() (RowData, error) { - if iter.err != nil { - return RowData{}, iter.err - } - columns := make([]string, 0) - values := make([]interface{}, 0) - for _, column := range iter.Columns() { - val := column.TypeInfo.New() - columns = append(columns, column.Name) - values = append(values, val) - } - rowData := RowData{ - Columns: columns, - Values: values, - } - return rowData, nil -} - -// SliceMap is a helper function to make the API easier to use -// returns the data from the query in the form of []map[string]interface{} -func (iter *Iter) SliceMap() ([]map[string]interface{}, error) { - if iter.err != nil { - return nil, iter.err - } - - // Not checking for the error because we just did - rowData, _ := iter.RowData() - dataToReturn := make([]map[string]interface{}, 0) - for iter.Scan(rowData.Values...) { - m := make(map[string]interface{}) - rowData.rowMap(m) - dataToReturn = append(dataToReturn, m) - } - if iter.err != nil { - return nil, iter.err - } - return dataToReturn, nil -} - -// MapScan takes a map[string]interface{} and populates it with a row -// That is returned from cassandra. -func (iter *Iter) MapScan(m map[string]interface{}) bool { - if iter.err != nil { - return false - } - - // Not checking for the error because we just did - rowData, _ := iter.RowData() - - for i, col := range rowData.Columns { - if dest, ok := m[col]; ok { - rowData.Values[i] = dest - } - } - - if iter.Scan(rowData.Values...) { - rowData.rowMap(m) - return true - } - return false -} diff --git a/vendor/github.com/gocql/gocql/host_source.go b/vendor/github.com/gocql/gocql/host_source.go deleted file mode 100644 index 801b6f914..000000000 --- a/vendor/github.com/gocql/gocql/host_source.go +++ /dev/null @@ -1,119 +0,0 @@ -package gocql - -import ( - "log" - "net" - "time" -) - -type HostInfo struct { - Peer string - DataCenter string - Rack string - HostId string - Tokens []string -} - -// Polls system.peers at a specific interval to find new hosts -type ringDescriber struct { - dcFilter string - rackFilter string - prevHosts []HostInfo - prevPartitioner string - session *Session - closeChan chan bool -} - -func (r *ringDescriber) GetHosts() ( - hosts []HostInfo, - partitioner string, - err error, -) { - // we need conn to be the same because we need to query system.peers and system.local - // on the same node to get the whole cluster - conn := r.session.Pool.Pick(nil) - if conn == nil { - return r.prevHosts, r.prevPartitioner, nil - } - - query := r.session.Query("SELECT data_center, rack, host_id, tokens, partitioner FROM system.local") - iter := conn.executeQuery(query) - - host := HostInfo{} - iter.Scan(&host.DataCenter, &host.Rack, &host.HostId, &host.Tokens, &partitioner) - - if err = iter.Close(); err != nil { - return nil, "", err - } - - addr, _, err := net.SplitHostPort(conn.Address()) - if err != nil { - // this should not happen, ever, as this is the address that was dialed by conn, here - // a panic makes sense, please report a bug if it occurs. - panic(err) - } - - host.Peer = addr - - hosts = []HostInfo{host} - - query = r.session.Query("SELECT peer, data_center, rack, host_id, tokens FROM system.peers") - iter = conn.executeQuery(query) - - host = HostInfo{} - for iter.Scan(&host.Peer, &host.DataCenter, &host.Rack, &host.HostId, &host.Tokens) { - if r.matchFilter(&host) { - hosts = append(hosts, host) - } - host = HostInfo{} - } - - if err = iter.Close(); err != nil { - return nil, "", err - } - - r.prevHosts = hosts - r.prevPartitioner = partitioner - - return hosts, partitioner, nil -} - -func (r *ringDescriber) matchFilter(host *HostInfo) bool { - - if r.dcFilter != "" && r.dcFilter != host.DataCenter { - return false - } - - if r.rackFilter != "" && r.rackFilter != host.Rack { - return false - } - - return true -} - -func (h *ringDescriber) run(sleep time.Duration) { - if sleep == 0 { - sleep = 30 * time.Second - } - - for { - select { - case <-time.After(sleep): - // if we have 0 hosts this will return the previous list of hosts to - // attempt to reconnect to the cluster otherwise we would never find - // downed hosts again, could possibly have an optimisation to only - // try to add new hosts if GetHosts didnt error and the hosts didnt change. - hosts, partitioner, err := h.GetHosts() - if err != nil { - log.Println("RingDescriber: unable to get ring topology:", err) - } else { - h.session.Pool.SetHosts(hosts) - if v, ok := h.session.Pool.(SetPartitioner); ok { - v.SetPartitioner(partitioner) - } - } - case <-h.closeChan: - return - } - } -} diff --git a/vendor/github.com/gocql/gocql/integration.sh b/vendor/github.com/gocql/gocql/integration.sh deleted file mode 100644 index 543b7d1e5..000000000 --- a/vendor/github.com/gocql/gocql/integration.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -set -e - -function run_tests() { - local clusterSize=3 - local version=$1 - local auth=$2 - - if [ "$auth" = true ]; then - clusterSize=1 - fi - - local keypath="$(pwd)/testdata/pki" - - local conf=( - "client_encryption_options.enabled: true" - "client_encryption_options.keystore: $keypath/.keystore" - "client_encryption_options.keystore_password: cassandra" - "client_encryption_options.require_client_auth: true" - "client_encryption_options.truststore: $keypath/.truststore" - "client_encryption_options.truststore_password: cassandra" - "concurrent_reads: 2" - "concurrent_writes: 2" - "rpc_server_type: sync" - "rpc_min_threads: 2" - "rpc_max_threads: 2" - "write_request_timeout_in_ms: 5000" - "read_request_timeout_in_ms: 5000" - ) - - ccm remove test || true - - ccm create test -v binary:$version -n $clusterSize -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m" - ccm updateconf "${conf[@]}" - - if [ "$auth" = true ] - then - ccm updateconf 'authenticator: PasswordAuthenticator' 'authorizer: CassandraAuthorizer' - rm -rf $HOME/.ccm/test/node1/data/system_auth - fi - - ccm start -v - ccm status - ccm node1 nodetool status - - local proto=2 - if [[ $version == 1.2.* ]]; then - proto=1 - elif [[ $version == 2.1.* ]]; then - proto=3 - fi - - if [ "$auth" = true ] - then - sleep 30s - go test -v . -timeout 15s -run=TestAuthentication -tags integration -runssl -runauth -proto=$proto -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=1000ms - else - - go test -timeout 5m -tags integration -cover -v -runssl -proto=$proto -rf=3 -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=2000ms -compressor=snappy ./... | tee results.txt - - if [ ${PIPESTATUS[0]} -ne 0 ]; then - echo "--- FAIL: ccm status follows:" - ccm status - ccm node1 nodetool status - ccm node1 showlog > status.log - cat status.log - echo "--- FAIL: Received a non-zero exit code from the go test execution, please investigate this" - exit 1 - fi - - cover=`cat results.txt | grep coverage: | grep -o "[0-9]\{1,3\}" | head -n 1` - - if [[ $cover -lt "55" ]]; then - echo "--- FAIL: expected coverage of at least 60 %, but coverage was $cover %" - exit 1 - fi - fi - - ccm remove -} - -run_tests $1 $2 diff --git a/vendor/github.com/gocql/gocql/marshal.go b/vendor/github.com/gocql/gocql/marshal.go deleted file mode 100644 index 4fcb22aab..000000000 --- a/vendor/github.com/gocql/gocql/marshal.go +++ /dev/null @@ -1,1624 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "bytes" - "encoding/binary" - "errors" - "fmt" - "math" - "math/big" - "net" - "reflect" - "strconv" - "strings" - "time" - - "gopkg.in/inf.v0" -) - -var ( - bigOne = big.NewInt(1) -) - -var ( - ErrorUDTUnavailable = errors.New("UDT are not available on protocols less than 3, please update config") -) - -// Marshaler is the interface implemented by objects that can marshal -// themselves into values understood by Cassandra. -type Marshaler interface { - MarshalCQL(info TypeInfo) ([]byte, error) -} - -// Unmarshaler is the interface implemented by objects that can unmarshal -// a Cassandra specific description of themselves. -type Unmarshaler interface { - UnmarshalCQL(info TypeInfo, data []byte) error -} - -// Marshal returns the CQL encoding of the value for the Cassandra -// internal type described by the info parameter. -func Marshal(info TypeInfo, value interface{}) ([]byte, error) { - if value == nil { - return nil, nil - } - if info.Version() < protoVersion1 { - panic("protocol version not set") - } - - if valueRef := reflect.ValueOf(value); valueRef.Kind() == reflect.Ptr { - if valueRef.IsNil() { - return nil, nil - } else if v, ok := value.(Marshaler); ok { - return v.MarshalCQL(info) - } else { - return Marshal(info, valueRef.Elem().Interface()) - } - } - - if v, ok := value.(Marshaler); ok { - return v.MarshalCQL(info) - } - - switch info.Type() { - case TypeVarchar, TypeAscii, TypeBlob: - return marshalVarchar(info, value) - case TypeBoolean: - return marshalBool(info, value) - case TypeInt: - return marshalInt(info, value) - case TypeBigInt, TypeCounter: - return marshalBigInt(info, value) - case TypeFloat: - return marshalFloat(info, value) - case TypeDouble: - return marshalDouble(info, value) - case TypeDecimal: - return marshalDecimal(info, value) - case TypeTimestamp: - return marshalTimestamp(info, value) - case TypeList, TypeSet: - return marshalList(info, value) - case TypeMap: - return marshalMap(info, value) - case TypeUUID, TypeTimeUUID: - return marshalUUID(info, value) - case TypeVarint: - return marshalVarint(info, value) - case TypeInet: - return marshalInet(info, value) - case TypeUDT: - return marshalUDT(info, value) - } - - // detect protocol 2 UDT - if strings.HasPrefix(info.Custom(), "org.apache.cassandra.db.marshal.UserType") && info.Version() < 3 { - return nil, ErrorUDTUnavailable - } - - // TODO(tux21b): add the remaining types - return nil, fmt.Errorf("can not marshal %T into %s", value, info) -} - -// Unmarshal parses the CQL encoded data based on the info parameter that -// describes the Cassandra internal data type and stores the result in the -// value pointed by value. -func Unmarshal(info TypeInfo, data []byte, value interface{}) error { - if v, ok := value.(Unmarshaler); ok { - return v.UnmarshalCQL(info, data) - } - if isNullableValue(value) { - return unmarshalNullable(info, data, value) - } - - switch info.Type() { - case TypeVarchar, TypeAscii, TypeBlob: - return unmarshalVarchar(info, data, value) - case TypeBoolean: - return unmarshalBool(info, data, value) - case TypeInt: - return unmarshalInt(info, data, value) - case TypeBigInt, TypeCounter: - return unmarshalBigInt(info, data, value) - case TypeVarint: - return unmarshalVarint(info, data, value) - case TypeFloat: - return unmarshalFloat(info, data, value) - case TypeDouble: - return unmarshalDouble(info, data, value) - case TypeDecimal: - return unmarshalDecimal(info, data, value) - case TypeTimestamp: - return unmarshalTimestamp(info, data, value) - case TypeList, TypeSet: - return unmarshalList(info, data, value) - case TypeMap: - return unmarshalMap(info, data, value) - case TypeTimeUUID: - return unmarshalTimeUUID(info, data, value) - case TypeUUID: - return unmarshalUUID(info, data, value) - case TypeInet: - return unmarshalInet(info, data, value) - case TypeTuple: - return unmarshalTuple(info, data, value) - case TypeUDT: - return unmarshalUDT(info, data, value) - } - - // detect protocol 2 UDT - if strings.HasPrefix(info.Custom(), "org.apache.cassandra.db.marshal.UserType") && info.Version() < 3 { - return ErrorUDTUnavailable - } - - // TODO(tux21b): add the remaining types - return fmt.Errorf("can not unmarshal %s into %T", info, value) -} - -func isNullableValue(value interface{}) bool { - v := reflect.ValueOf(value) - return v.Kind() == reflect.Ptr && v.Type().Elem().Kind() == reflect.Ptr -} - -func isNullData(info TypeInfo, data []byte) bool { - return len(data) == 0 -} - -func unmarshalNullable(info TypeInfo, data []byte, value interface{}) error { - valueRef := reflect.ValueOf(value) - - if isNullData(info, data) { - nilValue := reflect.Zero(valueRef.Type().Elem()) - valueRef.Elem().Set(nilValue) - return nil - } - - newValue := reflect.New(valueRef.Type().Elem().Elem()) - valueRef.Elem().Set(newValue) - return Unmarshal(info, data, newValue.Interface()) -} - -func marshalVarchar(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case string: - return []byte(v), nil - case []byte: - return v, nil - } - rv := reflect.ValueOf(value) - t := rv.Type() - k := t.Kind() - switch { - case k == reflect.String: - return []byte(rv.String()), nil - case k == reflect.Slice && t.Elem().Kind() == reflect.Uint8: - return rv.Bytes(), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func unmarshalVarchar(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *string: - *v = string(data) - return nil - case *[]byte: - var dataCopy []byte - if data != nil { - dataCopy = make([]byte, len(data)) - copy(dataCopy, data) - } - *v = dataCopy - return nil - } - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - t := rv.Type() - k := t.Kind() - switch { - case k == reflect.String: - rv.SetString(string(data)) - return nil - case k == reflect.Slice && t.Elem().Kind() == reflect.Uint8: - var dataCopy []byte - if data != nil { - dataCopy = make([]byte, len(data)) - copy(dataCopy, data) - } - rv.SetBytes(dataCopy) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func marshalInt(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case int: - if v > math.MaxInt32 || v < math.MinInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - case uint: - if v > math.MaxInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - case int64: - if v > math.MaxInt32 || v < math.MinInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - case uint64: - if v > math.MaxInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - case int32: - return encInt(v), nil - case uint32: - if v > math.MaxInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - case int16: - return encInt(int32(v)), nil - case uint16: - return encInt(int32(v)), nil - case int8: - return encInt(int32(v)), nil - case uint8: - return encInt(int32(v)), nil - case string: - i, err := strconv.ParseInt(value.(string), 10, 32) - if err != nil { - return nil, marshalErrorf("can not marshal string to int: %s", err) - } - return encInt(int32(i)), nil - } - rv := reflect.ValueOf(value) - switch rv.Type().Kind() { - case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8: - v := rv.Int() - if v > math.MaxInt32 || v < math.MinInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8: - v := rv.Uint() - if v > math.MaxInt32 { - return nil, marshalErrorf("marshal int: value %d out of range", v) - } - return encInt(int32(v)), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func encInt(x int32) []byte { - return []byte{byte(x >> 24), byte(x >> 16), byte(x >> 8), byte(x)} -} - -func decInt(x []byte) int32 { - if len(x) != 4 { - return 0 - } - return int32(x[0])<<24 | int32(x[1])<<16 | int32(x[2])<<8 | int32(x[3]) -} - -func marshalBigInt(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case int: - return encBigInt(int64(v)), nil - case uint: - if uint64(v) > math.MaxInt64 { - return nil, marshalErrorf("marshal bigint: value %d out of range", v) - } - return encBigInt(int64(v)), nil - case int64: - return encBigInt(v), nil - case uint64: - if v > math.MaxInt64 { - return nil, marshalErrorf("marshal bigint: value %d out of range", v) - } - return encBigInt(int64(v)), nil - case int32: - return encBigInt(int64(v)), nil - case uint32: - return encBigInt(int64(v)), nil - case int16: - return encBigInt(int64(v)), nil - case uint16: - return encBigInt(int64(v)), nil - case int8: - return encBigInt(int64(v)), nil - case uint8: - return encBigInt(int64(v)), nil - case big.Int: - return encBigInt2C(&v), nil - case string: - i, err := strconv.ParseInt(value.(string), 10, 64) - if err != nil { - return nil, marshalErrorf("can not marshal string to bigint: %s", err) - } - return encBigInt(i), nil - } - rv := reflect.ValueOf(value) - switch rv.Type().Kind() { - case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8: - v := rv.Int() - return encBigInt(v), nil - case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8: - v := rv.Uint() - if v > math.MaxInt64 { - return nil, marshalErrorf("marshal bigint: value %d out of range", v) - } - return encBigInt(int64(v)), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func encBigInt(x int64) []byte { - return []byte{byte(x >> 56), byte(x >> 48), byte(x >> 40), byte(x >> 32), - byte(x >> 24), byte(x >> 16), byte(x >> 8), byte(x)} -} - -func bytesToInt64(data []byte) (ret int64) { - for i := range data { - ret |= int64(data[i]) << (8 * uint(len(data)-i-1)) - } - return ret -} - -func unmarshalBigInt(info TypeInfo, data []byte, value interface{}) error { - return unmarshalIntlike(info, decBigInt(data), data, value) -} - -func unmarshalInt(info TypeInfo, data []byte, value interface{}) error { - return unmarshalIntlike(info, int64(decInt(data)), data, value) -} - -func unmarshalVarint(info TypeInfo, data []byte, value interface{}) error { - switch value.(type) { - case *big.Int: - return unmarshalIntlike(info, 0, data, value) - } - - if len(data) > 8 { - return unmarshalErrorf("unmarshal int: varint value %v out of range for %T (use big.Int)", data, value) - } - - int64Val := bytesToInt64(data) - if len(data) < 8 && data[0]&0x80 > 0 { - int64Val -= (1 << uint(len(data)*8)) - } - return unmarshalIntlike(info, int64Val, data, value) -} - -func marshalVarint(info TypeInfo, value interface{}) ([]byte, error) { - var ( - retBytes []byte - err error - ) - - switch v := value.(type) { - case uint64: - if v > uint64(math.MaxInt64) { - retBytes = make([]byte, 9) - binary.BigEndian.PutUint64(retBytes[1:], v) - } else { - retBytes = make([]byte, 8) - binary.BigEndian.PutUint64(retBytes, v) - } - default: - retBytes, err = marshalBigInt(info, value) - } - - if err == nil { - // trim down to most significant byte - i := 0 - for ; i < len(retBytes)-1; i++ { - b0 := retBytes[i] - if b0 != 0 && b0 != 0xFF { - break - } - - b1 := retBytes[i+1] - if b0 == 0 && b1 != 0 { - if b1&0x80 == 0 { - i++ - } - break - } - - if b0 == 0xFF && b1 != 0xFF { - if b1&0x80 > 0 { - i++ - } - break - } - } - retBytes = retBytes[i:] - } - - return retBytes, err -} - -func unmarshalIntlike(info TypeInfo, int64Val int64, data []byte, value interface{}) error { - switch v := value.(type) { - case *int: - if ^uint(0) == math.MaxUint32 && (int64Val < math.MinInt32 || int64Val > math.MaxInt32) { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = int(int64Val) - return nil - case *uint: - if int64Val < 0 || (^uint(0) == math.MaxUint32 && int64Val > math.MaxUint32) { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = uint(int64Val) - return nil - case *int64: - *v = int64Val - return nil - case *uint64: - if int64Val < 0 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = uint64(int64Val) - return nil - case *int32: - if int64Val < math.MinInt32 || int64Val > math.MaxInt32 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = int32(int64Val) - return nil - case *uint32: - if int64Val < 0 || int64Val > math.MaxUint32 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = uint32(int64Val) - return nil - case *int16: - if int64Val < math.MinInt16 || int64Val > math.MaxInt16 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = int16(int64Val) - return nil - case *uint16: - if int64Val < 0 || int64Val > math.MaxUint16 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = uint16(int64Val) - return nil - case *int8: - if int64Val < math.MinInt8 || int64Val > math.MaxInt8 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = int8(int64Val) - return nil - case *uint8: - if int64Val < 0 || int64Val > math.MaxUint8 { - return unmarshalErrorf("unmarshal int: value %d out of range for %T", int64Val, *v) - } - *v = uint8(int64Val) - return nil - case *big.Int: - decBigInt2C(data, v) - return nil - case *string: - *v = strconv.FormatInt(int64Val, 10) - return nil - } - - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - - switch rv.Type().Kind() { - case reflect.Int: - if ^uint(0) == math.MaxUint32 && (int64Val < math.MinInt32 || int64Val > math.MaxInt32) { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetInt(int64Val) - return nil - case reflect.Int64: - rv.SetInt(int64Val) - return nil - case reflect.Int32: - if int64Val < math.MinInt32 || int64Val > math.MaxInt32 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetInt(int64Val) - return nil - case reflect.Int16: - if int64Val < math.MinInt16 || int64Val > math.MaxInt16 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetInt(int64Val) - return nil - case reflect.Int8: - if int64Val < math.MinInt8 || int64Val > math.MaxInt8 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetInt(int64Val) - return nil - case reflect.Uint: - if int64Val < 0 || (^uint(0) == math.MaxUint32 && int64Val > math.MaxUint32) { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetUint(uint64(int64Val)) - return nil - case reflect.Uint64: - if int64Val < 0 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetUint(uint64(int64Val)) - return nil - case reflect.Uint32: - if int64Val < 0 || int64Val > math.MaxUint32 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetUint(uint64(int64Val)) - return nil - case reflect.Uint16: - if int64Val < 0 || int64Val > math.MaxUint16 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetUint(uint64(int64Val)) - return nil - case reflect.Uint8: - if int64Val < 0 || int64Val > math.MaxUint8 { - return unmarshalErrorf("unmarshal int: value %d out of range", int64Val) - } - rv.SetUint(uint64(int64Val)) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func decBigInt(data []byte) int64 { - if len(data) != 8 { - return 0 - } - return int64(data[0])<<56 | int64(data[1])<<48 | - int64(data[2])<<40 | int64(data[3])<<32 | - int64(data[4])<<24 | int64(data[5])<<16 | - int64(data[6])<<8 | int64(data[7]) -} - -func marshalBool(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case bool: - return encBool(v), nil - } - rv := reflect.ValueOf(value) - switch rv.Type().Kind() { - case reflect.Bool: - return encBool(rv.Bool()), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func encBool(v bool) []byte { - if v { - return []byte{1} - } - return []byte{0} -} - -func unmarshalBool(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *bool: - *v = decBool(data) - return nil - } - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - switch rv.Type().Kind() { - case reflect.Bool: - rv.SetBool(decBool(data)) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func decBool(v []byte) bool { - if len(v) == 0 { - return false - } - return v[0] != 0 -} - -func marshalFloat(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case float32: - return encInt(int32(math.Float32bits(v))), nil - } - rv := reflect.ValueOf(value) - switch rv.Type().Kind() { - case reflect.Float32: - return encInt(int32(math.Float32bits(float32(rv.Float())))), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func unmarshalFloat(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *float32: - *v = math.Float32frombits(uint32(decInt(data))) - return nil - } - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - switch rv.Type().Kind() { - case reflect.Float32: - rv.SetFloat(float64(math.Float32frombits(uint32(decInt(data))))) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func marshalDouble(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case float64: - return encBigInt(int64(math.Float64bits(v))), nil - } - rv := reflect.ValueOf(value) - switch rv.Type().Kind() { - case reflect.Float64: - return encBigInt(int64(math.Float64bits(rv.Float()))), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func unmarshalDouble(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *float64: - *v = math.Float64frombits(uint64(decBigInt(data))) - return nil - } - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - switch rv.Type().Kind() { - case reflect.Float64: - rv.SetFloat(math.Float64frombits(uint64(decBigInt(data)))) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func marshalDecimal(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case inf.Dec: - unscaled := encBigInt2C(v.UnscaledBig()) - if unscaled == nil { - return nil, marshalErrorf("can not marshal %T into %s", value, info) - } - - buf := make([]byte, 4+len(unscaled)) - copy(buf[0:4], encInt(int32(v.Scale()))) - copy(buf[4:], unscaled) - return buf, nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func unmarshalDecimal(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *inf.Dec: - scale := decInt(data[0:4]) - unscaled := decBigInt2C(data[4:], nil) - *v = *inf.NewDecBig(unscaled, inf.Scale(scale)) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -// decBigInt2C sets the value of n to the big-endian two's complement -// value stored in the given data. If data[0]&80 != 0, the number -// is negative. If data is empty, the result will be 0. -func decBigInt2C(data []byte, n *big.Int) *big.Int { - if n == nil { - n = new(big.Int) - } - n.SetBytes(data) - if len(data) > 0 && data[0]&0x80 > 0 { - n.Sub(n, new(big.Int).Lsh(bigOne, uint(len(data))*8)) - } - return n -} - -// encBigInt2C returns the big-endian two's complement -// form of n. -func encBigInt2C(n *big.Int) []byte { - switch n.Sign() { - case 0: - return []byte{0} - case 1: - b := n.Bytes() - if b[0]&0x80 > 0 { - b = append([]byte{0}, b...) - } - return b - case -1: - length := uint(n.BitLen()/8+1) * 8 - b := new(big.Int).Add(n, new(big.Int).Lsh(bigOne, length)).Bytes() - // When the most significant bit is on a byte - // boundary, we can get some extra significant - // bits, so strip them off when that happens. - if len(b) >= 2 && b[0] == 0xff && b[1]&0x80 != 0 { - b = b[1:] - } - return b - } - return nil -} - -func marshalTimestamp(info TypeInfo, value interface{}) ([]byte, error) { - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case int64: - return encBigInt(v), nil - case time.Time: - if v.IsZero() { - return []byte{}, nil - } - x := int64(v.UTC().Unix()*1e3) + int64(v.UTC().Nanosecond()/1e6) - return encBigInt(x), nil - } - rv := reflect.ValueOf(value) - switch rv.Type().Kind() { - case reflect.Int64: - return encBigInt(rv.Int()), nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func unmarshalTimestamp(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *int64: - *v = decBigInt(data) - return nil - case *time.Time: - if len(data) == 0 { - return nil - } - x := decBigInt(data) - sec := x / 1000 - nsec := (x - sec*1000) * 1000000 - *v = time.Unix(sec, nsec).In(time.UTC) - return nil - } - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - switch rv.Type().Kind() { - case reflect.Int64: - rv.SetInt(decBigInt(data)) - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func writeCollectionSize(info CollectionType, n int, buf *bytes.Buffer) error { - if info.proto > protoVersion2 { - if n > math.MaxInt32 { - return marshalErrorf("marshal: collection too large") - } - - buf.WriteByte(byte(n >> 24)) - buf.WriteByte(byte(n >> 16)) - buf.WriteByte(byte(n >> 8)) - buf.WriteByte(byte(n)) - } else { - if n > math.MaxUint16 { - return marshalErrorf("marshal: collection too large") - } - - buf.WriteByte(byte(n >> 8)) - buf.WriteByte(byte(n)) - } - - return nil -} - -func marshalList(info TypeInfo, value interface{}) ([]byte, error) { - listInfo, ok := info.(CollectionType) - if !ok { - return nil, marshalErrorf("marshal: can not marshal non collection type into list") - } - - rv := reflect.ValueOf(value) - t := rv.Type() - k := t.Kind() - switch k { - case reflect.Slice, reflect.Array: - if k == reflect.Slice && rv.IsNil() { - return nil, nil - } - buf := &bytes.Buffer{} - n := rv.Len() - - if err := writeCollectionSize(listInfo, n, buf); err != nil { - return nil, err - } - - for i := 0; i < n; i++ { - item, err := Marshal(listInfo.Elem, rv.Index(i).Interface()) - if err != nil { - return nil, err - } - if err := writeCollectionSize(listInfo, len(item), buf); err != nil { - return nil, err - } - buf.Write(item) - } - return buf.Bytes(), nil - case reflect.Map: - elem := t.Elem() - if elem.Kind() == reflect.Struct && elem.NumField() == 0 { - rkeys := rv.MapKeys() - keys := make([]interface{}, len(rkeys)) - for i := 0; i < len(keys); i++ { - keys[i] = rkeys[i].Interface() - } - return marshalList(listInfo, keys) - } - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func readCollectionSize(info CollectionType, data []byte) (size, read int) { - if info.proto > protoVersion2 { - size = int(data[0])<<24 | int(data[1])<<16 | int(data[2])<<8 | int(data[3]) - read = 4 - } else { - size = int(data[0])<<8 | int(data[1]) - read = 2 - } - return -} - -func unmarshalList(info TypeInfo, data []byte, value interface{}) error { - listInfo, ok := info.(CollectionType) - if !ok { - return unmarshalErrorf("unmarshal: can not unmarshal none collection type into list") - } - - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - t := rv.Type() - k := t.Kind() - - switch k { - case reflect.Slice, reflect.Array: - if data == nil { - if k == reflect.Array { - return unmarshalErrorf("unmarshal list: can not store nil in array value") - } - rv.Set(reflect.Zero(t)) - return nil - } - if len(data) < 2 { - return unmarshalErrorf("unmarshal list: unexpected eof") - } - n, p := readCollectionSize(listInfo, data) - data = data[p:] - if k == reflect.Array { - if rv.Len() != n { - return unmarshalErrorf("unmarshal list: array with wrong size") - } - } else { - rv.Set(reflect.MakeSlice(t, n, n)) - } - for i := 0; i < n; i++ { - if len(data) < 2 { - return unmarshalErrorf("unmarshal list: unexpected eof") - } - m, p := readCollectionSize(listInfo, data) - data = data[p:] - if err := Unmarshal(listInfo.Elem, data[:m], rv.Index(i).Addr().Interface()); err != nil { - return err - } - data = data[m:] - } - return nil - } - return unmarshalErrorf("can not unmarshal %s into %T", info, value) -} - -func marshalMap(info TypeInfo, value interface{}) ([]byte, error) { - mapInfo, ok := info.(CollectionType) - if !ok { - return nil, marshalErrorf("marshal: can not marshal none collection type into map") - } - - rv := reflect.ValueOf(value) - t := rv.Type() - if t.Kind() != reflect.Map { - return nil, marshalErrorf("can not marshal %T into %s", value, info) - } - if rv.IsNil() { - return nil, nil - } - buf := &bytes.Buffer{} - n := rv.Len() - - if err := writeCollectionSize(mapInfo, n, buf); err != nil { - return nil, err - } - - keys := rv.MapKeys() - for _, key := range keys { - item, err := Marshal(mapInfo.Key, key.Interface()) - if err != nil { - return nil, err - } - if err := writeCollectionSize(mapInfo, len(item), buf); err != nil { - return nil, err - } - buf.Write(item) - - item, err = Marshal(mapInfo.Elem, rv.MapIndex(key).Interface()) - if err != nil { - return nil, err - } - if err := writeCollectionSize(mapInfo, len(item), buf); err != nil { - return nil, err - } - buf.Write(item) - } - return buf.Bytes(), nil -} - -func unmarshalMap(info TypeInfo, data []byte, value interface{}) error { - mapInfo, ok := info.(CollectionType) - if !ok { - return unmarshalErrorf("unmarshal: can not unmarshal none collection type into map") - } - - rv := reflect.ValueOf(value) - if rv.Kind() != reflect.Ptr { - return unmarshalErrorf("can not unmarshal into non-pointer %T", value) - } - rv = rv.Elem() - t := rv.Type() - if t.Kind() != reflect.Map { - return unmarshalErrorf("can not unmarshal %s into %T", info, value) - } - if data == nil { - rv.Set(reflect.Zero(t)) - return nil - } - rv.Set(reflect.MakeMap(t)) - if len(data) < 2 { - return unmarshalErrorf("unmarshal map: unexpected eof") - } - n, p := readCollectionSize(mapInfo, data) - data = data[p:] - for i := 0; i < n; i++ { - if len(data) < 2 { - return unmarshalErrorf("unmarshal list: unexpected eof") - } - m, p := readCollectionSize(mapInfo, data) - data = data[p:] - key := reflect.New(t.Key()) - if err := Unmarshal(mapInfo.Key, data[:m], key.Interface()); err != nil { - return err - } - data = data[m:] - - m, p = readCollectionSize(mapInfo, data) - data = data[p:] - val := reflect.New(t.Elem()) - if err := Unmarshal(mapInfo.Elem, data[:m], val.Interface()); err != nil { - return err - } - data = data[m:] - - rv.SetMapIndex(key.Elem(), val.Elem()) - } - return nil -} - -func marshalUUID(info TypeInfo, value interface{}) ([]byte, error) { - switch val := value.(type) { - case UUID: - return val.Bytes(), nil - case []byte: - if len(val) == 16 { - return val, nil - } - case string: - b, err := ParseUUID(val) - if err != nil { - return nil, err - } - return b[:], nil - } - return nil, marshalErrorf("can not marshal %T into %s", value, info) -} - -func unmarshalUUID(info TypeInfo, data []byte, value interface{}) error { - if data == nil || len(data) == 0 { - switch v := value.(type) { - case *string: - *v = "" - case *[]byte: - *v = nil - case *UUID: - *v = UUID{} - default: - return unmarshalErrorf("can not unmarshal X %s into %T", info, value) - } - - return nil - } - - u, err := UUIDFromBytes(data) - if err != nil { - return unmarshalErrorf("Unable to parse UUID: %s", err) - } - - switch v := value.(type) { - case *string: - *v = u.String() - return nil - case *[]byte: - *v = u[:] - return nil - case *UUID: - *v = u - return nil - } - return unmarshalErrorf("can not unmarshal X %s into %T", info, value) -} - -func unmarshalTimeUUID(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *time.Time: - id, err := UUIDFromBytes(data) - if err != nil { - return err - } else if id.Version() != 1 { - return unmarshalErrorf("invalid timeuuid") - } - *v = id.Time() - return nil - default: - return unmarshalUUID(info, data, value) - } -} - -func marshalInet(info TypeInfo, value interface{}) ([]byte, error) { - // we return either the 4 or 16 byte representation of an - // ip address here otherwise the db value will be prefixed - // with the remaining byte values e.g. ::ffff:127.0.0.1 and not 127.0.0.1 - switch val := value.(type) { - case net.IP: - t := val.To4() - if t == nil { - return val.To16(), nil - } - return t, nil - case string: - b := net.ParseIP(val) - if b != nil { - t := b.To4() - if t == nil { - return b.To16(), nil - } - return t, nil - } - return nil, marshalErrorf("cannot marshal. invalid ip string %s", val) - } - return nil, marshalErrorf("cannot marshal %T into %s", value, info) -} - -func unmarshalInet(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case *net.IP: - ip := net.IP(data) - if v4 := ip.To4(); v4 != nil { - *v = v4 - return nil - } - *v = ip - return nil - case *string: - if len(data) == 0 { - *v = "" - return nil - } - ip := net.IP(data) - if v4 := ip.To4(); v4 != nil { - *v = v4.String() - return nil - } - *v = ip.String() - return nil - } - return unmarshalErrorf("cannot unmarshal %s into %T", info, value) -} - -// currently only support unmarshal into a list of values, this makes it possible -// to support tuples without changing the query API. In the future this can be extend -// to allow unmarshalling into custom tuple types. -func unmarshalTuple(info TypeInfo, data []byte, value interface{}) error { - if v, ok := value.(Unmarshaler); ok { - return v.UnmarshalCQL(info, data) - } - - tuple := info.(TupleTypeInfo) - switch v := value.(type) { - case []interface{}: - for i, elem := range tuple.Elems { - // each element inside data is a [bytes] - size := readInt(data) - data = data[4:] - - err := Unmarshal(elem, data[:size], v[i]) - if err != nil { - return err - } - data = data[size:] - } - - return nil - } - - return unmarshalErrorf("cannot unmarshal %s into %T", info, value) -} - -// UDTMarshaler is an interface which should be implemented by users wishing to -// handle encoding UDT types to sent to Cassandra. Note: due to current implentations -// methods defined for this interface must be value receivers not pointer receivers. -type UDTMarshaler interface { - // MarshalUDT will be called for each field in the the UDT returned by Cassandra, - // the implementor should marshal the type to return by for example calling - // Marshal. - MarshalUDT(name string, info TypeInfo) ([]byte, error) -} - -// UDTUnmarshaler should be implemented by users wanting to implement custom -// UDT unmarshaling. -type UDTUnmarshaler interface { - // UnmarshalUDT will be called for each field in the UDT return by Cassandra, - // the implementor should unmarshal the data into the value of their chosing, - // for example by calling Unmarshal. - UnmarshalUDT(name string, info TypeInfo, data []byte) error -} - -func marshalUDT(info TypeInfo, value interface{}) ([]byte, error) { - udt := info.(UDTTypeInfo) - - switch v := value.(type) { - case Marshaler: - return v.MarshalCQL(info) - case UDTMarshaler: - var buf []byte - for _, e := range udt.Elements { - data, err := v.MarshalUDT(e.Name, e.Type) - if err != nil { - return nil, err - } - - n := len(data) - buf = append(buf, byte(n>>24), - byte(n>>16), - byte(n>>8), - byte(n)) - - buf = append(buf, data...) - } - - return buf, nil - case map[string]interface{}: - var buf []byte - for _, e := range udt.Elements { - val, ok := v[e.Name] - if !ok { - return nil, marshalErrorf("missing UDT field in map: %s", e.Name) - } - - data, err := Marshal(e.Type, val) - if err != nil { - return nil, err - } - - n := len(data) - buf = append(buf, byte(n>>24), - byte(n>>16), - byte(n>>8), - byte(n)) - - buf = append(buf, data...) - } - - return buf, nil - } - - k := reflect.ValueOf(value) - if k.Kind() == reflect.Ptr { - if k.IsNil() { - return nil, marshalErrorf("cannot marshal %T into %s", value, info) - } - k = k.Elem() - } - - if k.Kind() != reflect.Struct || !k.IsValid() { - return nil, marshalErrorf("cannot marshal %T into %s", value, info) - } - - fields := make(map[string]reflect.Value) - t := reflect.TypeOf(value) - for i := 0; i < t.NumField(); i++ { - sf := t.Field(i) - - if tag := sf.Tag.Get("cql"); tag != "" { - fields[tag] = k.Field(i) - } - } - - var buf []byte - for _, e := range udt.Elements { - f, ok := fields[e.Name] - if !ok { - f = k.FieldByName(e.Name) - } - - if !f.IsValid() { - return nil, marshalErrorf("cannot marshal %T into %s", value, info) - } else if f.Kind() == reflect.Ptr { - f = f.Elem() - } - - data, err := Marshal(e.Type, f.Interface()) - if err != nil { - return nil, err - } - - n := len(data) - buf = append(buf, byte(n>>24), - byte(n>>16), - byte(n>>8), - byte(n)) - - buf = append(buf, data...) - } - - return buf, nil - -} - -func unmarshalUDT(info TypeInfo, data []byte, value interface{}) error { - switch v := value.(type) { - case Unmarshaler: - return v.UnmarshalCQL(info, data) - case UDTUnmarshaler: - udt := info.(UDTTypeInfo) - - for _, e := range udt.Elements { - size := readInt(data[:4]) - data = data[4:] - - var err error - if size < 0 { - err = v.UnmarshalUDT(e.Name, e.Type, nil) - } else { - err = v.UnmarshalUDT(e.Name, e.Type, data[:size]) - data = data[size:] - } - - if err != nil { - return err - } - } - - return nil - } - - k := reflect.ValueOf(value).Elem() - if k.Kind() != reflect.Struct || !k.IsValid() { - return unmarshalErrorf("cannot unmarshal %s into %T", info, value) - } - - fields := make(map[string]reflect.Value) - t := k.Type() - for i := 0; i < t.NumField(); i++ { - sf := t.Field(i) - - if tag := sf.Tag.Get("cql"); tag != "" { - fields[tag] = k.Field(i) - } - } - - if len(data) == 0 { - if k.CanSet() { - k.Set(reflect.Zero(k.Type())) - } - - return nil - } - - udt := info.(UDTTypeInfo) - for _, e := range udt.Elements { - size := readInt(data[:4]) - data = data[4:] - - var err error - if size >= 0 { - f, ok := fields[e.Name] - if !ok { - f = k.FieldByName(e.Name) - } - - if !f.IsValid() || !f.CanAddr() { - return unmarshalErrorf("cannot unmarshal %s into %T", info, value) - } - - fk := f.Addr().Interface() - if err := Unmarshal(e.Type, data[:size], fk); err != nil { - return err - } - data = data[size:] - } - - if err != nil { - return err - } - } - - return nil -} - -// TypeInfo describes a Cassandra specific data type. -type TypeInfo interface { - Type() Type - Version() byte - Custom() string - - // New creates a pointer to an empty version of whatever type - // is referenced by the TypeInfo receiver - New() interface{} -} - -type NativeType struct { - proto byte - typ Type - custom string // only used for TypeCustom -} - -func (t NativeType) New() interface{} { - return reflect.New(goType(t)).Interface() -} - -func (s NativeType) Type() Type { - return s.typ -} - -func (s NativeType) Version() byte { - return s.proto -} - -func (s NativeType) Custom() string { - return s.custom -} - -func (s NativeType) String() string { - switch s.typ { - case TypeCustom: - return fmt.Sprintf("%s(%s)", s.typ, s.custom) - default: - return s.typ.String() - } -} - -type CollectionType struct { - NativeType - Key TypeInfo // only used for TypeMap - Elem TypeInfo // only used for TypeMap, TypeList and TypeSet -} - -func (t CollectionType) New() interface{} { - return reflect.New(goType(t)).Interface() -} - -func (c CollectionType) String() string { - switch c.typ { - case TypeMap: - return fmt.Sprintf("%s(%s, %s)", c.typ, c.Key, c.Elem) - case TypeList, TypeSet: - return fmt.Sprintf("%s(%s)", c.typ, c.Elem) - case TypeCustom: - return fmt.Sprintf("%s(%s)", c.typ, c.custom) - default: - return c.typ.String() - } -} - -type TupleTypeInfo struct { - NativeType - Elems []TypeInfo -} - -type UDTField struct { - Name string - Type TypeInfo -} - -type UDTTypeInfo struct { - NativeType - KeySpace string - Name string - Elements []UDTField -} - -func (u UDTTypeInfo) String() string { - buf := &bytes.Buffer{} - - fmt.Fprintf(buf, "%s.%s{", u.KeySpace, u.Name) - first := true - for _, e := range u.Elements { - if !first { - fmt.Fprint(buf, ",") - } else { - first = false - } - - fmt.Fprintf(buf, "%s=%v", e.Name, e.Type) - } - fmt.Fprint(buf, "}") - - return buf.String() -} - -// String returns a human readable name for the Cassandra datatype -// described by t. -// Type is the identifier of a Cassandra internal datatype. -type Type int - -const ( - TypeCustom Type = 0x0000 - TypeAscii = 0x0001 - TypeBigInt = 0x0002 - TypeBlob = 0x0003 - TypeBoolean = 0x0004 - TypeCounter = 0x0005 - TypeDecimal = 0x0006 - TypeDouble = 0x0007 - TypeFloat = 0x0008 - TypeInt = 0x0009 - TypeTimestamp = 0x000B - TypeUUID = 0x000C - TypeVarchar = 0x000D - TypeVarint = 0x000E - TypeTimeUUID = 0x000F - TypeInet = 0x0010 - TypeList = 0x0020 - TypeMap = 0x0021 - TypeSet = 0x0022 - TypeUDT = 0x0030 - TypeTuple = 0x0031 -) - -// String returns the name of the identifier. -func (t Type) String() string { - switch t { - case TypeCustom: - return "custom" - case TypeAscii: - return "ascii" - case TypeBigInt: - return "bigint" - case TypeBlob: - return "blob" - case TypeBoolean: - return "boolean" - case TypeCounter: - return "counter" - case TypeDecimal: - return "decimal" - case TypeDouble: - return "double" - case TypeFloat: - return "float" - case TypeInt: - return "int" - case TypeTimestamp: - return "timestamp" - case TypeUUID: - return "uuid" - case TypeVarchar: - return "varchar" - case TypeTimeUUID: - return "timeuuid" - case TypeInet: - return "inet" - case TypeList: - return "list" - case TypeMap: - return "map" - case TypeSet: - return "set" - case TypeVarint: - return "varint" - case TypeTuple: - return "tuple" - default: - return fmt.Sprintf("unknown_type_%d", t) - } -} - -type MarshalError string - -func (m MarshalError) Error() string { - return string(m) -} - -func marshalErrorf(format string, args ...interface{}) MarshalError { - return MarshalError(fmt.Sprintf(format, args...)) -} - -type UnmarshalError string - -func (m UnmarshalError) Error() string { - return string(m) -} - -func unmarshalErrorf(format string, args ...interface{}) UnmarshalError { - return UnmarshalError(fmt.Sprintf(format, args...)) -} diff --git a/vendor/github.com/gocql/gocql/marshal_test.go b/vendor/github.com/gocql/gocql/marshal_test.go deleted file mode 100644 index e0493a99b..000000000 --- a/vendor/github.com/gocql/gocql/marshal_test.go +++ /dev/null @@ -1,862 +0,0 @@ -// +build all unit - -package gocql - -import ( - "bytes" - "math" - "math/big" - "net" - "reflect" - "strings" - "testing" - "time" - - "gopkg.in/inf.v0" -) - -var marshalTests = []struct { - Info TypeInfo - Data []byte - Value interface{} -}{ - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte("hello world"), - []byte("hello world"), - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte("hello world"), - "hello world", - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte(nil), - []byte(nil), - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte("hello world"), - MyString("hello world"), - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte("HELLO WORLD"), - CustomString("hello world"), - }, - { - NativeType{proto: 2, typ: TypeBlob}, - []byte("hello\x00"), - []byte("hello\x00"), - }, - { - NativeType{proto: 2, typ: TypeBlob}, - []byte(nil), - []byte(nil), - }, - { - NativeType{proto: 2, typ: TypeTimeUUID}, - []byte{0x3d, 0xcd, 0x98, 0x0, 0xf3, 0xd9, 0x11, 0xbf, 0x86, 0xd4, 0xb8, 0xe8, 0x56, 0x2c, 0xc, 0xd0}, - func() UUID { - x, _ := UUIDFromBytes([]byte{0x3d, 0xcd, 0x98, 0x0, 0xf3, 0xd9, 0x11, 0xbf, 0x86, 0xd4, 0xb8, 0xe8, 0x56, 0x2c, 0xc, 0xd0}) - return x - }(), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x00\x00\x00\x00"), - 0, - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x01\x02\x03\x04"), - int(16909060), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x80\x00\x00\x00"), - int32(math.MinInt32), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x7f\xff\xff\xff"), - int32(math.MaxInt32), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x00\x00\x00\x00"), - "0", - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x01\x02\x03\x04"), - "16909060", - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x80\x00\x00\x00"), - "-2147483648", // math.MinInt32 - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x7f\xff\xff\xff"), - "2147483647", // math.MaxInt32 - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x00\x00\x00\x00\x00\x00\x00\x00"), - 0, - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x01\x02\x03\x04\x05\x06\x07\x08"), - 72623859790382856, - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x80\x00\x00\x00\x00\x00\x00\x00"), - int64(math.MinInt64), - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x7f\xff\xff\xff\xff\xff\xff\xff"), - int64(math.MaxInt64), - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x00\x00\x00\x00\x00\x00\x00\x00"), - "0", - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x01\x02\x03\x04\x05\x06\x07\x08"), - "72623859790382856", - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x80\x00\x00\x00\x00\x00\x00\x00"), - "-9223372036854775808", // math.MinInt64 - }, - { - NativeType{proto: 2, typ: TypeBigInt}, - []byte("\x7f\xff\xff\xff\xff\xff\xff\xff"), - "9223372036854775807", // math.MaxInt64 - }, - { - NativeType{proto: 2, typ: TypeBoolean}, - []byte("\x00"), - false, - }, - { - NativeType{proto: 2, typ: TypeBoolean}, - []byte("\x01"), - true, - }, - { - NativeType{proto: 2, typ: TypeFloat}, - []byte("\x40\x49\x0f\xdb"), - float32(3.14159265), - }, - { - NativeType{proto: 2, typ: TypeDouble}, - []byte("\x40\x09\x21\xfb\x53\xc8\xd4\xf1"), - float64(3.14159265), - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x00\x00"), - inf.NewDec(0, 0), - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x00\x64"), - inf.NewDec(100, 0), - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x02\x19"), - decimalize("0.25"), - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x13\xD5\a;\x20\x14\xA2\x91"), - decimalize("-0.0012095473475870063"), // From the iconara/cql-rb test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x13*\xF8\xC4\xDF\xEB]o"), - decimalize("0.0012095473475870063"), // From the iconara/cql-rb test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x12\xF2\xD8\x02\xB6R\x7F\x99\xEE\x98#\x99\xA9V"), - decimalize("-1042342234234.123423435647768234"), // From the iconara/cql-rb test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\r\nJ\x04\"^\x91\x04\x8a\xb1\x18\xfe"), - decimalize("1243878957943.1234124191998"), // From the datastax/python-driver test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x06\xe5\xde]\x98Y"), - decimalize("-112233.441191"), // From the datastax/python-driver test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x14\x00\xfa\xce"), - decimalize("0.00000000000000064206"), // From the datastax/python-driver test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\x00\x00\x00\x14\xff\x052"), - decimalize("-0.00000000000000064206"), // From the datastax/python-driver test suite - }, - { - NativeType{proto: 2, typ: TypeDecimal}, - []byte("\xff\xff\xff\x9c\x00\xfa\xce"), - inf.NewDec(64206, -100), // From the datastax/python-driver test suite - }, - { - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x01\x40\x77\x16\xe1\xb8"), - time.Date(2013, time.August, 13, 9, 52, 3, 0, time.UTC), - }, - { - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x01\x40\x77\x16\xe1\xb8"), - int64(1376387523000), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeList}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte("\x00\x02\x00\x04\x00\x00\x00\x01\x00\x04\x00\x00\x00\x02"), - []int{1, 2}, - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeList}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte("\x00\x02\x00\x04\x00\x00\x00\x01\x00\x04\x00\x00\x00\x02"), - [2]int{1, 2}, - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeSet}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte("\x00\x02\x00\x04\x00\x00\x00\x01\x00\x04\x00\x00\x00\x02"), - []int{1, 2}, - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeSet}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte(nil), - []int(nil), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeMap}, - Key: NativeType{proto: 2, typ: TypeVarchar}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte("\x00\x01\x00\x03foo\x00\x04\x00\x00\x00\x01"), - map[string]int{"foo": 1}, - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeMap}, - Key: NativeType{proto: 2, typ: TypeVarchar}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte(nil), - map[string]int(nil), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeList}, - Elem: NativeType{proto: 2, typ: TypeVarchar}, - }, - bytes.Join([][]byte{ - []byte("\x00\x01\xFF\xFF"), - bytes.Repeat([]byte("X"), 65535)}, []byte("")), - []string{strings.Repeat("X", 65535)}, - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeMap}, - Key: NativeType{proto: 2, typ: TypeVarchar}, - Elem: NativeType{proto: 2, typ: TypeVarchar}, - }, - bytes.Join([][]byte{ - []byte("\x00\x01\xFF\xFF"), - bytes.Repeat([]byte("X"), 65535), - []byte("\xFF\xFF"), - bytes.Repeat([]byte("Y"), 65535)}, []byte("")), - map[string]string{ - strings.Repeat("X", 65535): strings.Repeat("Y", 65535), - }, - }, - { - NativeType{proto: 2, typ: TypeVarint}, - []byte("\x00"), - 0, - }, - { - NativeType{proto: 2, typ: TypeVarint}, - []byte("\x37\xE2\x3C\xEC"), - int32(937573612), - }, - { - NativeType{proto: 2, typ: TypeVarint}, - []byte("\x37\xE2\x3C\xEC"), - big.NewInt(937573612), - }, - { - NativeType{proto: 2, typ: TypeVarint}, - []byte("\x03\x9EV \x15\f\x03\x9DK\x18\xCDI\\$?\a["), - bigintize("1231312312331283012830129382342342412123"), // From the iconara/cql-rb test suite - }, - { - NativeType{proto: 2, typ: TypeVarint}, - []byte("\xC9v\x8D:\x86"), - big.NewInt(-234234234234), // From the iconara/cql-rb test suite - }, - { - NativeType{proto: 2, typ: TypeVarint}, - []byte("f\x1e\xfd\xf2\xe3\xb1\x9f|\x04_\x15"), - bigintize("123456789123456789123456789"), // From the datastax/python-driver test suite - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\x7F\x00\x00\x01"), - net.ParseIP("127.0.0.1").To4(), - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\xFF\xFF\xFF\xFF"), - net.ParseIP("255.255.255.255").To4(), - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\x7F\x00\x00\x01"), - "127.0.0.1", - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\xFF\xFF\xFF\xFF"), - "255.255.255.255", - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\x21\xDA\x00\xd3\x00\x00\x2f\x3b\x02\xaa\x00\xff\xfe\x28\x9c\x5a"), - "21da:d3:0:2f3b:2aa:ff:fe28:9c5a", - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x02\xb3\xff\xfe\x1e\x83\x29"), - "fe80::202:b3ff:fe1e:8329", - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\x21\xDA\x00\xd3\x00\x00\x2f\x3b\x02\xaa\x00\xff\xfe\x28\x9c\x5a"), - net.ParseIP("21da:d3:0:2f3b:2aa:ff:fe28:9c5a"), - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x02\xb3\xff\xfe\x1e\x83\x29"), - net.ParseIP("fe80::202:b3ff:fe1e:8329"), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte(nil), - nil, - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte("nullable string"), - func() *string { - value := "nullable string" - return &value - }(), - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte{}, - (*string)(nil), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte("\x7f\xff\xff\xff"), - func() *int { - var value int = math.MaxInt32 - return &value - }(), - }, - { - NativeType{proto: 2, typ: TypeInt}, - []byte(nil), - (*int)(nil), - }, - { - NativeType{proto: 2, typ: TypeTimeUUID}, - []byte{0x3d, 0xcd, 0x98, 0x0, 0xf3, 0xd9, 0x11, 0xbf, 0x86, 0xd4, 0xb8, 0xe8, 0x56, 0x2c, 0xc, 0xd0}, - &UUID{0x3d, 0xcd, 0x98, 0x0, 0xf3, 0xd9, 0x11, 0xbf, 0x86, 0xd4, 0xb8, 0xe8, 0x56, 0x2c, 0xc, 0xd0}, - }, - { - NativeType{proto: 2, typ: TypeTimeUUID}, - []byte{}, - (*UUID)(nil), - }, - { - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x01\x40\x77\x16\xe1\xb8"), - func() *time.Time { - t := time.Date(2013, time.August, 13, 9, 52, 3, 0, time.UTC) - return &t - }(), - }, - { - NativeType{proto: 2, typ: TypeTimestamp}, - []byte(nil), - (*time.Time)(nil), - }, - { - NativeType{proto: 2, typ: TypeBoolean}, - []byte("\x00"), - func() *bool { - b := false - return &b - }(), - }, - { - NativeType{proto: 2, typ: TypeBoolean}, - []byte("\x01"), - func() *bool { - b := true - return &b - }(), - }, - { - NativeType{proto: 2, typ: TypeBoolean}, - []byte(nil), - (*bool)(nil), - }, - { - NativeType{proto: 2, typ: TypeFloat}, - []byte("\x40\x49\x0f\xdb"), - func() *float32 { - f := float32(3.14159265) - return &f - }(), - }, - { - NativeType{proto: 2, typ: TypeFloat}, - []byte(nil), - (*float32)(nil), - }, - { - NativeType{proto: 2, typ: TypeDouble}, - []byte("\x40\x09\x21\xfb\x53\xc8\xd4\xf1"), - func() *float64 { - d := float64(3.14159265) - return &d - }(), - }, - { - NativeType{proto: 2, typ: TypeDouble}, - []byte(nil), - (*float64)(nil), - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte("\x7F\x00\x00\x01"), - func() *net.IP { - ip := net.ParseIP("127.0.0.1").To4() - return &ip - }(), - }, - { - NativeType{proto: 2, typ: TypeInet}, - []byte(nil), - (*net.IP)(nil), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeList}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte("\x00\x02\x00\x04\x00\x00\x00\x01\x00\x04\x00\x00\x00\x02"), - func() *[]int { - l := []int{1, 2} - return &l - }(), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeList}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte(nil), - (*[]int)(nil), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeMap}, - Key: NativeType{proto: 2, typ: TypeVarchar}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte("\x00\x01\x00\x03foo\x00\x04\x00\x00\x00\x01"), - func() *map[string]int { - m := map[string]int{"foo": 1} - return &m - }(), - }, - { - CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeMap}, - Key: NativeType{proto: 2, typ: TypeVarchar}, - Elem: NativeType{proto: 2, typ: TypeInt}, - }, - []byte(nil), - (*map[string]int)(nil), - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte("HELLO WORLD"), - func() *CustomString { - customString := CustomString("hello world") - return &customString - }(), - }, - { - NativeType{proto: 2, typ: TypeVarchar}, - []byte(nil), - (*CustomString)(nil), - }, -} - -func decimalize(s string) *inf.Dec { - i, _ := new(inf.Dec).SetString(s) - return i -} - -func bigintize(s string) *big.Int { - i, _ := new(big.Int).SetString(s, 10) - return i -} - -func TestMarshal(t *testing.T) { - for i, test := range marshalTests { - data, err := Marshal(test.Info, test.Value) - if err != nil { - t.Errorf("marshalTest[%d]: %v", i, err) - continue - } - if !bytes.Equal(data, test.Data) { - t.Errorf("marshalTest[%d]: expected %q, got %q (%#v)", i, test.Data, data, test.Value) - } - } -} - -func TestUnmarshal(t *testing.T) { - for i, test := range marshalTests { - if test.Value != nil { - v := reflect.New(reflect.TypeOf(test.Value)) - err := Unmarshal(test.Info, test.Data, v.Interface()) - if err != nil { - t.Errorf("unmarshalTest[%d]: %v", i, err) - continue - } - if !reflect.DeepEqual(v.Elem().Interface(), test.Value) { - t.Errorf("unmarshalTest[%d]: expected %#v, got %#v.", i, test.Value, v.Elem().Interface()) - } - } else { - if err := Unmarshal(test.Info, test.Data, test.Value); nil == err { - t.Errorf("unmarshalTest[%d]: %#v not return error.", i, test.Value) - } - } - } -} - -func TestMarshalVarint(t *testing.T) { - varintTests := []struct { - Value interface{} - Marshaled []byte - Unmarshaled *big.Int - }{ - { - Value: int8(0), - Marshaled: []byte("\x00"), - Unmarshaled: big.NewInt(0), - }, - { - Value: uint8(255), - Marshaled: []byte("\x00\xFF"), - Unmarshaled: big.NewInt(255), - }, - { - Value: int8(-1), - Marshaled: []byte("\xFF"), - Unmarshaled: big.NewInt(-1), - }, - { - Value: big.NewInt(math.MaxInt32), - Marshaled: []byte("\x7F\xFF\xFF\xFF"), - Unmarshaled: big.NewInt(math.MaxInt32), - }, - { - Value: big.NewInt(int64(math.MaxInt32) + 1), - Marshaled: []byte("\x00\x80\x00\x00\x00"), - Unmarshaled: big.NewInt(int64(math.MaxInt32) + 1), - }, - { - Value: big.NewInt(math.MinInt32), - Marshaled: []byte("\x80\x00\x00\x00"), - Unmarshaled: big.NewInt(math.MinInt32), - }, - { - Value: big.NewInt(int64(math.MinInt32) - 1), - Marshaled: []byte("\xFF\x7F\xFF\xFF\xFF"), - Unmarshaled: big.NewInt(int64(math.MinInt32) - 1), - }, - { - Value: math.MinInt64, - Marshaled: []byte("\x80\x00\x00\x00\x00\x00\x00\x00"), - Unmarshaled: big.NewInt(math.MinInt64), - }, - { - Value: uint64(math.MaxInt64) + 1, - Marshaled: []byte("\x00\x80\x00\x00\x00\x00\x00\x00\x00"), - Unmarshaled: bigintize("9223372036854775808"), - }, - { - Value: bigintize("2361183241434822606848"), // 2**71 - Marshaled: []byte("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00"), - Unmarshaled: bigintize("2361183241434822606848"), - }, - { - Value: bigintize("-9223372036854775809"), // -2**63 - 1 - Marshaled: []byte("\xFF\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF"), - Unmarshaled: bigintize("-9223372036854775809"), - }, - } - - for i, test := range varintTests { - data, err := Marshal(NativeType{proto: 2, typ: TypeVarint}, test.Value) - if err != nil { - t.Errorf("error marshaling varint: %v (test #%d)", err, i) - } - - if !bytes.Equal(test.Marshaled, data) { - t.Errorf("marshaled varint mismatch: expected %v, got %v (test #%d)", test.Marshaled, data, i) - } - - binder := new(big.Int) - err = Unmarshal(NativeType{proto: 2, typ: TypeVarint}, test.Marshaled, binder) - if err != nil { - t.Errorf("error unmarshaling varint: %v (test #%d)", err, i) - } - - if test.Unmarshaled.Cmp(binder) != 0 { - t.Errorf("unmarshaled varint mismatch: expected %v, got %v (test #%d)", test.Unmarshaled, binder, i) - } - } -} - -func equalStringSlice(leftList, rightList []string) bool { - if len(leftList) != len(rightList) { - return false - } - for index := range leftList { - if rightList[index] != leftList[index] { - return false - } - } - return true -} - -func TestMarshalList(t *testing.T) { - typeInfo := CollectionType{ - NativeType: NativeType{proto: 2, typ: TypeList}, - Elem: NativeType{proto: 2, typ: TypeVarchar}, - } - - sourceLists := [][]string{ - []string{"valueA"}, - []string{"valueA", "valueB"}, - []string{"valueB"}, - } - - listDatas := [][]byte{} - - for _, list := range sourceLists { - listData, marshalErr := Marshal(typeInfo, list) - if nil != marshalErr { - t.Errorf("Error marshal %+v of type %+v: %s", list, typeInfo, marshalErr) - } - listDatas = append(listDatas, listData) - } - - outputLists := [][]string{} - - var outputList []string - - for _, listData := range listDatas { - if unmarshalErr := Unmarshal(typeInfo, listData, &outputList); nil != unmarshalErr { - t.Error(unmarshalErr) - } - outputLists = append(outputLists, outputList) - } - - for index, sourceList := range sourceLists { - outputList := outputLists[index] - if !equalStringSlice(sourceList, outputList) { - t.Errorf("Lists %+v not equal to lists %+v, but should", sourceList, outputList) - } - } -} - -type CustomString string - -func (c CustomString) MarshalCQL(info TypeInfo) ([]byte, error) { - return []byte(strings.ToUpper(string(c))), nil -} -func (c *CustomString) UnmarshalCQL(info TypeInfo, data []byte) error { - *c = CustomString(strings.ToLower(string(data))) - return nil -} - -type MyString string - -type MyInt int - -var typeLookupTest = []struct { - TypeName string - ExpectedType Type -}{ - {"AsciiType", TypeAscii}, - {"LongType", TypeBigInt}, - {"BytesType", TypeBlob}, - {"BooleanType", TypeBoolean}, - {"CounterColumnType", TypeCounter}, - {"DecimalType", TypeDecimal}, - {"DoubleType", TypeDouble}, - {"FloatType", TypeFloat}, - {"Int32Type", TypeInt}, - {"DateType", TypeTimestamp}, - {"TimestampType", TypeTimestamp}, - {"UUIDType", TypeUUID}, - {"UTF8Type", TypeVarchar}, - {"IntegerType", TypeVarint}, - {"TimeUUIDType", TypeTimeUUID}, - {"InetAddressType", TypeInet}, - {"MapType", TypeMap}, - {"ListType", TypeList}, - {"SetType", TypeSet}, - {"unknown", TypeCustom}, -} - -func testType(t *testing.T, cassType string, expectedType Type) { - if computedType := getApacheCassandraType(apacheCassandraTypePrefix + cassType); computedType != expectedType { - t.Errorf("Cassandra custom type lookup for %s failed. Expected %s, got %s.", cassType, expectedType.String(), computedType.String()) - } -} - -func TestLookupCassType(t *testing.T) { - for _, lookupTest := range typeLookupTest { - testType(t, lookupTest.TypeName, lookupTest.ExpectedType) - } -} - -type MyPointerMarshaler struct{} - -func (m *MyPointerMarshaler) MarshalCQL(_ TypeInfo) ([]byte, error) { - return []byte{42}, nil -} - -func TestMarshalPointer(t *testing.T) { - m := &MyPointerMarshaler{} - typ := NativeType{proto: 2, typ: TypeInt} - - data, err := Marshal(typ, m) - - if err != nil { - t.Errorf("Pointer marshaling failed. Error: %s", err) - } - if len(data) != 1 || data[0] != 42 { - t.Errorf("Pointer marshaling failed. Expected %+v, got %+v", []byte{42}, data) - } -} - -func TestMarshalTimestamp(t *testing.T) { - var marshalTimestampTests = []struct { - Info TypeInfo - Data []byte - Value interface{} - }{ - { - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x01\x40\x77\x16\xe1\xb8"), - time.Date(2013, time.August, 13, 9, 52, 3, 0, time.UTC), - }, - { - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x01\x40\x77\x16\xe1\xb8"), - int64(1376387523000), - }, - { - // 9223372036854 is the maximum time representable in ms since the epoch - // with int64 if using UnixNano to convert - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x08\x63\x7b\xd0\x5a\xf6"), - time.Date(2262, time.April, 11, 23, 47, 16, 854775807, time.UTC), - }, - { - // One nanosecond after causes overflow when using UnixNano - // Instead it should resolve to the same time in ms - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\x00\x00\x08\x63\x7b\xd0\x5a\xf6"), - time.Date(2262, time.April, 11, 23, 47, 16, 854775808, time.UTC), - }, - { - // -9223372036855 is the minimum time representable in ms since the epoch - // with int64 if using UnixNano to convert - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\xff\xff\xf7\x9c\x84\x2f\xa5\x09"), - time.Date(1677, time.September, 21, 00, 12, 43, 145224192, time.UTC), - }, - { - // One nanosecond earlier causes overflow when using UnixNano - // it should resolve to the same time in ms - NativeType{proto: 2, typ: TypeTimestamp}, - []byte("\xff\xff\xf7\x9c\x84\x2f\xa5\x09"), - time.Date(1677, time.September, 21, 00, 12, 43, 145224191, time.UTC), - }, - { - // Store the zero time as a blank slice - NativeType{proto: 2, typ: TypeTimestamp}, - []byte{}, - time.Time{}, - }, - } - - for i, test := range marshalTimestampTests { - t.Log(i, test) - data, err := Marshal(test.Info, test.Value) - if err != nil { - t.Errorf("marshalTest[%d]: %v", i, err) - continue - } - if !bytes.Equal(data, test.Data) { - t.Errorf("marshalTest[%d]: expected %x (%v), got %x (%v) for time %s", i, - test.Data, decBigInt(test.Data), data, decBigInt(data), test.Value) - } - } -} diff --git a/vendor/github.com/gocql/gocql/metadata.go b/vendor/github.com/gocql/gocql/metadata.go deleted file mode 100644 index 131684b7d..000000000 --- a/vendor/github.com/gocql/gocql/metadata.go +++ /dev/null @@ -1,875 +0,0 @@ -// Copyright (c) 2015 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "log" - "strconv" - "strings" - "sync" -) - -// schema metadata for a keyspace -type KeyspaceMetadata struct { - Name string - DurableWrites bool - StrategyClass string - StrategyOptions map[string]interface{} - Tables map[string]*TableMetadata -} - -// schema metadata for a table (a.k.a. column family) -type TableMetadata struct { - Keyspace string - Name string - KeyValidator string - Comparator string - DefaultValidator string - KeyAliases []string - ColumnAliases []string - ValueAlias string - PartitionKey []*ColumnMetadata - ClusteringColumns []*ColumnMetadata - Columns map[string]*ColumnMetadata - OrderedColumns []string -} - -// schema metadata for a column -type ColumnMetadata struct { - Keyspace string - Table string - Name string - ComponentIndex int - Kind string - Validator string - Type TypeInfo - Order ColumnOrder - Index ColumnIndexMetadata -} - -// the ordering of the column with regard to its comparator -type ColumnOrder bool - -const ( - ASC ColumnOrder = false - DESC = true -) - -type ColumnIndexMetadata struct { - Name string - Type string - Options map[string]interface{} -} - -// Column kind values -const ( - PARTITION_KEY = "partition_key" - CLUSTERING_KEY = "clustering_key" - REGULAR = "regular" - COMPACT_VALUE = "compact_value" -) - -// default alias values -const ( - DEFAULT_KEY_ALIAS = "key" - DEFAULT_COLUMN_ALIAS = "column" - DEFAULT_VALUE_ALIAS = "value" -) - -// queries the cluster for schema information for a specific keyspace -type schemaDescriber struct { - session *Session - mu sync.Mutex - - cache map[string]*KeyspaceMetadata -} - -// creates a session bound schema describer which will query and cache -// keyspace metadata -func newSchemaDescriber(session *Session) *schemaDescriber { - return &schemaDescriber{ - session: session, - cache: map[string]*KeyspaceMetadata{}, - } -} - -// returns the cached KeyspaceMetadata held by the describer for the named -// keyspace. -func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) { - s.mu.Lock() - defer s.mu.Unlock() - - // TODO handle schema change events - - metadata, found := s.cache[keyspaceName] - if !found { - // refresh the cache for this keyspace - err := s.refreshSchema(keyspaceName) - if err != nil { - return nil, err - } - - metadata = s.cache[keyspaceName] - } - - return metadata, nil -} - -// forcibly updates the current KeyspaceMetadata held by the schema describer -// for a given named keyspace. -func (s *schemaDescriber) refreshSchema(keyspaceName string) error { - var err error - - // query the system keyspace for schema data - // TODO retrieve concurrently - keyspace, err := getKeyspaceMetadata(s.session, keyspaceName) - if err != nil { - return err - } - tables, err := getTableMetadata(s.session, keyspaceName) - if err != nil { - return err - } - columns, err := getColumnMetadata(s.session, keyspaceName) - if err != nil { - return err - } - - // organize the schema data - compileMetadata(s.session.cfg.ProtoVersion, keyspace, tables, columns) - - // update the cache - s.cache[keyspaceName] = keyspace - - return nil -} - -// "compiles" derived information about keyspace, table, and column metadata -// for a keyspace from the basic queried metadata objects returned by -// getKeyspaceMetadata, getTableMetadata, and getColumnMetadata respectively; -// Links the metadata objects together and derives the column composition of -// the partition key and clustering key for a table. -func compileMetadata( - protoVersion int, - keyspace *KeyspaceMetadata, - tables []TableMetadata, - columns []ColumnMetadata, -) { - keyspace.Tables = make(map[string]*TableMetadata) - for i := range tables { - tables[i].Columns = make(map[string]*ColumnMetadata) - - keyspace.Tables[tables[i].Name] = &tables[i] - } - - // add columns from the schema data - for i := range columns { - // decode the validator for TypeInfo and order - validatorParsed := parseType(columns[i].Validator) - columns[i].Type = validatorParsed.types[0] - columns[i].Order = ASC - if validatorParsed.reversed[0] { - columns[i].Order = DESC - } - - table := keyspace.Tables[columns[i].Table] - table.Columns[columns[i].Name] = &columns[i] - table.OrderedColumns = append(table.OrderedColumns, columns[i].Name) - } - - if protoVersion == 1 { - compileV1Metadata(tables) - } else { - compileV2Metadata(tables) - } -} - -// Compiles derived information from TableMetadata which have had -// ColumnMetadata added already. V1 protocol does not return as much -// column metadata as V2+ (because V1 doesn't support the "type" column in the -// system.schema_columns table) so determining PartitionKey and ClusterColumns -// is more complex. -func compileV1Metadata(tables []TableMetadata) { - for i := range tables { - table := &tables[i] - - // decode the key validator - keyValidatorParsed := parseType(table.KeyValidator) - // decode the comparator - comparatorParsed := parseType(table.Comparator) - - // the partition key length is the same as the number of types in the - // key validator - table.PartitionKey = make([]*ColumnMetadata, len(keyValidatorParsed.types)) - - // V1 protocol only returns "regular" columns from - // system.schema_columns (there is no type field for columns) - // so the alias information is used to - // create the partition key and clustering columns - - // construct the partition key from the alias - for i := range table.PartitionKey { - var alias string - if len(table.KeyAliases) > i { - alias = table.KeyAliases[i] - } else if i == 0 { - alias = DEFAULT_KEY_ALIAS - } else { - alias = DEFAULT_KEY_ALIAS + strconv.Itoa(i+1) - } - - column := &ColumnMetadata{ - Keyspace: table.Keyspace, - Table: table.Name, - Name: alias, - Type: keyValidatorParsed.types[i], - Kind: PARTITION_KEY, - ComponentIndex: i, - } - - table.PartitionKey[i] = column - table.Columns[alias] = column - } - - // determine the number of clustering columns - size := len(comparatorParsed.types) - if comparatorParsed.isComposite { - if len(comparatorParsed.collections) != 0 || - (len(table.ColumnAliases) == size-1 && - comparatorParsed.types[size-1].Type() == TypeVarchar) { - size = size - 1 - } - } else { - if !(len(table.ColumnAliases) != 0 || len(table.Columns) == 0) { - size = 0 - } - } - - table.ClusteringColumns = make([]*ColumnMetadata, size) - - for i := range table.ClusteringColumns { - var alias string - if len(table.ColumnAliases) > i { - alias = table.ColumnAliases[i] - } else if i == 0 { - alias = DEFAULT_COLUMN_ALIAS - } else { - alias = DEFAULT_COLUMN_ALIAS + strconv.Itoa(i+1) - } - - order := ASC - if comparatorParsed.reversed[i] { - order = DESC - } - - column := &ColumnMetadata{ - Keyspace: table.Keyspace, - Table: table.Name, - Name: alias, - Type: comparatorParsed.types[i], - Order: order, - Kind: CLUSTERING_KEY, - ComponentIndex: i, - } - - table.ClusteringColumns[i] = column - table.Columns[alias] = column - } - - if size != len(comparatorParsed.types)-1 { - alias := DEFAULT_VALUE_ALIAS - if len(table.ValueAlias) > 0 { - alias = table.ValueAlias - } - // decode the default validator - defaultValidatorParsed := parseType(table.DefaultValidator) - column := &ColumnMetadata{ - Keyspace: table.Keyspace, - Table: table.Name, - Name: alias, - Type: defaultValidatorParsed.types[0], - Kind: REGULAR, - } - table.Columns[alias] = column - } - } -} - -// The simpler compile case for V2+ protocol -func compileV2Metadata(tables []TableMetadata) { - for i := range tables { - table := &tables[i] - - keyValidatorParsed := parseType(table.KeyValidator) - table.PartitionKey = make([]*ColumnMetadata, len(keyValidatorParsed.types)) - - clusteringColumnCount := componentColumnCountOfType(table.Columns, CLUSTERING_KEY) - table.ClusteringColumns = make([]*ColumnMetadata, clusteringColumnCount) - - for _, columnName := range table.OrderedColumns { - column := table.Columns[columnName] - if column.Kind == PARTITION_KEY { - table.PartitionKey[column.ComponentIndex] = column - } else if column.Kind == CLUSTERING_KEY { - table.ClusteringColumns[column.ComponentIndex] = column - } - } - - } -} - -// returns the count of coluns with the given "kind" value. -func componentColumnCountOfType(columns map[string]*ColumnMetadata, kind string) int { - maxComponentIndex := -1 - for _, column := range columns { - if column.Kind == kind && column.ComponentIndex > maxComponentIndex { - maxComponentIndex = column.ComponentIndex - } - } - return maxComponentIndex + 1 -} - -// query only for the keyspace metadata for the specified keyspace from system.schema_keyspace -func getKeyspaceMetadata( - session *Session, - keyspaceName string, -) (*KeyspaceMetadata, error) { - query := session.Query( - ` - SELECT durable_writes, strategy_class, strategy_options - FROM system.schema_keyspaces - WHERE keyspace_name = ? - `, - keyspaceName, - ) - // Set a routing key to avoid GetRoutingKey from computing the routing key - // TODO use a separate connection (pool) for system keyspace queries. - query.RoutingKey([]byte{}) - - keyspace := &KeyspaceMetadata{Name: keyspaceName} - var strategyOptionsJSON []byte - - err := query.Scan( - &keyspace.DurableWrites, - &keyspace.StrategyClass, - &strategyOptionsJSON, - ) - if err != nil { - return nil, fmt.Errorf("Error querying keyspace schema: %v", err) - } - - err = json.Unmarshal(strategyOptionsJSON, &keyspace.StrategyOptions) - if err != nil { - return nil, fmt.Errorf( - "Invalid JSON value '%s' as strategy_options for in keyspace '%s': %v", - strategyOptionsJSON, keyspace.Name, err, - ) - } - - return keyspace, nil -} - -// query for only the table metadata in the specified keyspace from system.schema_columnfamilies -func getTableMetadata( - session *Session, - keyspaceName string, -) ([]TableMetadata, error) { - query := session.Query( - ` - SELECT - columnfamily_name, - key_validator, - comparator, - default_validator, - key_aliases, - column_aliases, - value_alias - FROM system.schema_columnfamilies - WHERE keyspace_name = ? - `, - keyspaceName, - ) - // Set a routing key to avoid GetRoutingKey from computing the routing key - // TODO use a separate connection (pool) for system keyspace queries. - query.RoutingKey([]byte{}) - iter := query.Iter() - - tables := []TableMetadata{} - table := TableMetadata{Keyspace: keyspaceName} - - var keyAliasesJSON []byte - var columnAliasesJSON []byte - for iter.Scan( - &table.Name, - &table.KeyValidator, - &table.Comparator, - &table.DefaultValidator, - &keyAliasesJSON, - &columnAliasesJSON, - &table.ValueAlias, - ) { - var err error - - // decode the key aliases - if keyAliasesJSON != nil { - table.KeyAliases = []string{} - err = json.Unmarshal(keyAliasesJSON, &table.KeyAliases) - if err != nil { - iter.Close() - return nil, fmt.Errorf( - "Invalid JSON value '%s' as key_aliases for in table '%s': %v", - keyAliasesJSON, table.Name, err, - ) - } - } - - // decode the column aliases - if columnAliasesJSON != nil { - table.ColumnAliases = []string{} - err = json.Unmarshal(columnAliasesJSON, &table.ColumnAliases) - if err != nil { - iter.Close() - return nil, fmt.Errorf( - "Invalid JSON value '%s' as column_aliases for in table '%s': %v", - columnAliasesJSON, table.Name, err, - ) - } - } - - tables = append(tables, table) - table = TableMetadata{Keyspace: keyspaceName} - } - - err := iter.Close() - if err != nil && err != ErrNotFound { - return nil, fmt.Errorf("Error querying table schema: %v", err) - } - - return tables, nil -} - -// query for only the column metadata in the specified keyspace from system.schema_columns -func getColumnMetadata( - session *Session, - keyspaceName string, -) ([]ColumnMetadata, error) { - // Deal with differences in protocol versions - var stmt string - var scan func(*Iter, *ColumnMetadata, *[]byte) bool - if session.cfg.ProtoVersion == 1 { - // V1 does not support the type column, and all returned rows are - // of kind "regular". - stmt = ` - SELECT - columnfamily_name, - column_name, - component_index, - validator, - index_name, - index_type, - index_options - FROM system.schema_columns - WHERE keyspace_name = ? - ` - scan = func( - iter *Iter, - column *ColumnMetadata, - indexOptionsJSON *[]byte, - ) bool { - // all columns returned by V1 are regular - column.Kind = REGULAR - return iter.Scan( - &column.Table, - &column.Name, - &column.ComponentIndex, - &column.Validator, - &column.Index.Name, - &column.Index.Type, - &indexOptionsJSON, - ) - } - } else { - // V2+ supports the type column - stmt = ` - SELECT - columnfamily_name, - column_name, - component_index, - validator, - index_name, - index_type, - index_options, - type - FROM system.schema_columns - WHERE keyspace_name = ? - ` - scan = func( - iter *Iter, - column *ColumnMetadata, - indexOptionsJSON *[]byte, - ) bool { - return iter.Scan( - &column.Table, - &column.Name, - &column.ComponentIndex, - &column.Validator, - &column.Index.Name, - &column.Index.Type, - &indexOptionsJSON, - &column.Kind, - ) - } - } - - // get the columns metadata - columns := []ColumnMetadata{} - column := ColumnMetadata{Keyspace: keyspaceName} - - var indexOptionsJSON []byte - - query := session.Query(stmt, keyspaceName) - // Set a routing key to avoid GetRoutingKey from computing the routing key - // TODO use a separate connection (pool) for system keyspace queries. - query.RoutingKey([]byte{}) - iter := query.Iter() - - for scan(iter, &column, &indexOptionsJSON) { - var err error - - // decode the index options - if indexOptionsJSON != nil { - err = json.Unmarshal(indexOptionsJSON, &column.Index.Options) - if err != nil { - iter.Close() - return nil, fmt.Errorf( - "Invalid JSON value '%s' as index_options for column '%s' in table '%s': %v", - indexOptionsJSON, - column.Name, - column.Table, - err, - ) - } - } - - columns = append(columns, column) - column = ColumnMetadata{Keyspace: keyspaceName} - } - - err := iter.Close() - if err != nil && err != ErrNotFound { - return nil, fmt.Errorf("Error querying column schema: %v", err) - } - - return columns, nil -} - -// type definition parser state -type typeParser struct { - input string - index int -} - -// the type definition parser result -type typeParserResult struct { - isComposite bool - types []TypeInfo - reversed []bool - collections map[string]TypeInfo -} - -// Parse the type definition used for validator and comparator schema data -func parseType(def string) typeParserResult { - parser := &typeParser{input: def} - return parser.parse() -} - -const ( - REVERSED_TYPE = "org.apache.cassandra.db.marshal.ReversedType" - COMPOSITE_TYPE = "org.apache.cassandra.db.marshal.CompositeType" - COLLECTION_TYPE = "org.apache.cassandra.db.marshal.ColumnToCollectionType" - LIST_TYPE = "org.apache.cassandra.db.marshal.ListType" - SET_TYPE = "org.apache.cassandra.db.marshal.SetType" - MAP_TYPE = "org.apache.cassandra.db.marshal.MapType" -) - -// represents a class specification in the type def AST -type typeParserClassNode struct { - name string - params []typeParserParamNode - // this is the segment of the input string that defined this node - input string -} - -// represents a class parameter in the type def AST -type typeParserParamNode struct { - name *string - class typeParserClassNode -} - -func (t *typeParser) parse() typeParserResult { - // parse the AST - ast, ok := t.parseClassNode() - if !ok { - // treat this is a custom type - return typeParserResult{ - isComposite: false, - types: []TypeInfo{ - NativeType{ - typ: TypeCustom, - custom: t.input, - }, - }, - reversed: []bool{false}, - collections: nil, - } - } - - // interpret the AST - if strings.HasPrefix(ast.name, COMPOSITE_TYPE) { - count := len(ast.params) - - // look for a collections param - last := ast.params[count-1] - collections := map[string]TypeInfo{} - if strings.HasPrefix(last.class.name, COLLECTION_TYPE) { - count-- - - for _, param := range last.class.params { - // decode the name - var name string - decoded, err := hex.DecodeString(*param.name) - if err != nil { - log.Printf( - "Error parsing type '%s', contains collection name '%s' with an invalid format: %v", - t.input, - *param.name, - err, - ) - // just use the provided name - name = *param.name - } else { - name = string(decoded) - } - collections[name] = param.class.asTypeInfo() - } - } - - types := make([]TypeInfo, count) - reversed := make([]bool, count) - - for i, param := range ast.params[:count] { - class := param.class - reversed[i] = strings.HasPrefix(class.name, REVERSED_TYPE) - if reversed[i] { - class = class.params[0].class - } - types[i] = class.asTypeInfo() - } - - return typeParserResult{ - isComposite: true, - types: types, - reversed: reversed, - collections: collections, - } - } else { - // not composite, so one type - class := *ast - reversed := strings.HasPrefix(class.name, REVERSED_TYPE) - if reversed { - class = class.params[0].class - } - typeInfo := class.asTypeInfo() - - return typeParserResult{ - isComposite: false, - types: []TypeInfo{typeInfo}, - reversed: []bool{reversed}, - } - } -} - -func (class *typeParserClassNode) asTypeInfo() TypeInfo { - if strings.HasPrefix(class.name, LIST_TYPE) { - elem := class.params[0].class.asTypeInfo() - return CollectionType{ - NativeType: NativeType{ - typ: TypeList, - }, - Elem: elem, - } - } - if strings.HasPrefix(class.name, SET_TYPE) { - elem := class.params[0].class.asTypeInfo() - return CollectionType{ - NativeType: NativeType{ - typ: TypeSet, - }, - Elem: elem, - } - } - if strings.HasPrefix(class.name, MAP_TYPE) { - key := class.params[0].class.asTypeInfo() - elem := class.params[1].class.asTypeInfo() - return CollectionType{ - NativeType: NativeType{ - typ: TypeMap, - }, - Key: key, - Elem: elem, - } - } - - // must be a simple type or custom type - info := NativeType{typ: getApacheCassandraType(class.name)} - if info.typ == TypeCustom { - // add the entire class definition - info.custom = class.input - } - return info -} - -// CLASS := ID [ PARAMS ] -func (t *typeParser) parseClassNode() (node *typeParserClassNode, ok bool) { - t.skipWhitespace() - - startIndex := t.index - - name, ok := t.nextIdentifier() - if !ok { - return nil, false - } - - params, ok := t.parseParamNodes() - if !ok { - return nil, false - } - - endIndex := t.index - - node = &typeParserClassNode{ - name: name, - params: params, - input: t.input[startIndex:endIndex], - } - return node, true -} - -// PARAMS := "(" PARAM { "," PARAM } ")" -// PARAM := [ PARAM_NAME ":" ] CLASS -// PARAM_NAME := ID -func (t *typeParser) parseParamNodes() (params []typeParserParamNode, ok bool) { - t.skipWhitespace() - - // the params are optional - if t.index == len(t.input) || t.input[t.index] != '(' { - return nil, true - } - - params = []typeParserParamNode{} - - // consume the '(' - t.index++ - - t.skipWhitespace() - - for t.input[t.index] != ')' { - // look for a named param, but if no colon, then we want to backup - backupIndex := t.index - - // name will be a hex encoded version of a utf-8 string - name, ok := t.nextIdentifier() - if !ok { - return nil, false - } - hasName := true - - // TODO handle '=>' used for DynamicCompositeType - - t.skipWhitespace() - - if t.input[t.index] == ':' { - // there is a name for this parameter - - // consume the ':' - t.index++ - - t.skipWhitespace() - } else { - // no name, backup - hasName = false - t.index = backupIndex - } - - // parse the next full parameter - classNode, ok := t.parseClassNode() - if !ok { - return nil, false - } - - if hasName { - params = append( - params, - typeParserParamNode{name: &name, class: *classNode}, - ) - } else { - params = append( - params, - typeParserParamNode{class: *classNode}, - ) - } - - t.skipWhitespace() - - if t.input[t.index] == ',' { - // consume the comma - t.index++ - - t.skipWhitespace() - } - } - - // consume the ')' - t.index++ - - return params, true -} - -func (t *typeParser) skipWhitespace() { - for t.index < len(t.input) && isWhitespaceChar(t.input[t.index]) { - t.index++ - } -} - -func isWhitespaceChar(c byte) bool { - return c == ' ' || c == '\n' || c == '\t' -} - -// ID := LETTER { LETTER } -// LETTER := "0"..."9" | "a"..."z" | "A"..."Z" | "-" | "+" | "." | "_" | "&" -func (t *typeParser) nextIdentifier() (id string, found bool) { - startIndex := t.index - for t.index < len(t.input) && isIdentifierChar(t.input[t.index]) { - t.index++ - } - if startIndex == t.index { - return "", false - } - return t.input[startIndex:t.index], true -} - -func isIdentifierChar(c byte) bool { - return (c >= '0' && c <= '9') || - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - c == '-' || - c == '+' || - c == '.' || - c == '_' || - c == '&' -} diff --git a/vendor/github.com/gocql/gocql/metadata_test.go b/vendor/github.com/gocql/gocql/metadata_test.go deleted file mode 100644 index 7ce9c7ce6..000000000 --- a/vendor/github.com/gocql/gocql/metadata_test.go +++ /dev/null @@ -1,815 +0,0 @@ -// Copyright (c) 2015 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "strconv" - "testing" -) - -// Tests V1 and V2 metadata "compilation" from example data which might be returned -// from metadata schema queries (see getKeyspaceMetadata, getTableMetadata, and getColumnMetadata) -func TestCompileMetadata(t *testing.T) { - // V1 tests - these are all based on real examples from the integration test ccm cluster - keyspace := &KeyspaceMetadata{ - Name: "V1Keyspace", - } - tables := []TableMetadata{ - TableMetadata{ - // This table, found in the system keyspace, has no key aliases or column aliases - Keyspace: "V1Keyspace", - Name: "Schema", - KeyValidator: "org.apache.cassandra.db.marshal.BytesType", - Comparator: "org.apache.cassandra.db.marshal.UTF8Type", - DefaultValidator: "org.apache.cassandra.db.marshal.BytesType", - KeyAliases: []string{}, - ColumnAliases: []string{}, - ValueAlias: "", - }, - TableMetadata{ - // This table, found in the system keyspace, has key aliases, column aliases, and a value alias. - Keyspace: "V1Keyspace", - Name: "hints", - KeyValidator: "org.apache.cassandra.db.marshal.UUIDType", - Comparator: "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.TimeUUIDType,org.apache.cassandra.db.marshal.Int32Type)", - DefaultValidator: "org.apache.cassandra.db.marshal.BytesType", - KeyAliases: []string{"target_id"}, - ColumnAliases: []string{"hint_id", "message_version"}, - ValueAlias: "mutation", - }, - TableMetadata{ - // This table, found in the system keyspace, has a comparator with collections, but no column aliases - Keyspace: "V1Keyspace", - Name: "peers", - KeyValidator: "org.apache.cassandra.db.marshal.InetAddressType", - Comparator: "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.ColumnToCollectionType(746f6b656e73:org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)))", - DefaultValidator: "org.apache.cassandra.db.marshal.BytesType", - KeyAliases: []string{"peer"}, - ColumnAliases: []string{}, - ValueAlias: "", - }, - TableMetadata{ - // This table, found in the system keyspace, has a column alias, but not a composite comparator - Keyspace: "V1Keyspace", - Name: "IndexInfo", - KeyValidator: "org.apache.cassandra.db.marshal.UTF8Type", - Comparator: "org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type)", - DefaultValidator: "org.apache.cassandra.db.marshal.BytesType", - KeyAliases: []string{"table_name"}, - ColumnAliases: []string{"index_name"}, - ValueAlias: "", - }, - TableMetadata{ - // This table, found in the gocql_test keyspace following an integration test run, has a composite comparator with collections as well as a column alias - Keyspace: "V1Keyspace", - Name: "wiki_page", - KeyValidator: "org.apache.cassandra.db.marshal.UTF8Type", - Comparator: "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.TimeUUIDType,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.ColumnToCollectionType(74616773:org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type),6174746163686d656e7473:org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.BytesType)))", - DefaultValidator: "org.apache.cassandra.db.marshal.BytesType", - KeyAliases: []string{"title"}, - ColumnAliases: []string{"revid"}, - ValueAlias: "", - }, - TableMetadata{ - // This is a made up example with multiple unnamed aliases - Keyspace: "V1Keyspace", - Name: "no_names", - KeyValidator: "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UUIDType,org.apache.cassandra.db.marshal.UUIDType)", - Comparator: "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.Int32Type)", - DefaultValidator: "org.apache.cassandra.db.marshal.BytesType", - KeyAliases: []string{}, - ColumnAliases: []string{}, - ValueAlias: "", - }, - } - columns := []ColumnMetadata{ - // Here are the regular columns from the peers table for testing regular columns - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "data_center", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UTF8Type"}, - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "host_id", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UUIDType"}, - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "rack", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UTF8Type"}, - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "release_version", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UTF8Type"}, - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "rpc_address", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.InetAddressType"}, - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "schema_version", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UUIDType"}, - ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "tokens", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)"}, - } - compileMetadata(1, keyspace, tables, columns) - assertKeyspaceMetadata( - t, - keyspace, - &KeyspaceMetadata{ - Name: "V1Keyspace", - Tables: map[string]*TableMetadata{ - "Schema": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "key", - Type: NativeType{typ: TypeBlob}, - }, - }, - ClusteringColumns: []*ColumnMetadata{}, - Columns: map[string]*ColumnMetadata{ - "key": &ColumnMetadata{ - Name: "key", - Type: NativeType{typ: TypeBlob}, - Kind: PARTITION_KEY, - }, - }, - }, - "hints": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "target_id", - Type: NativeType{typ: TypeUUID}, - }, - }, - ClusteringColumns: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "hint_id", - Type: NativeType{typ: TypeTimeUUID}, - Order: ASC, - }, - &ColumnMetadata{ - Name: "message_version", - Type: NativeType{typ: TypeInt}, - Order: ASC, - }, - }, - Columns: map[string]*ColumnMetadata{ - "target_id": &ColumnMetadata{ - Name: "target_id", - Type: NativeType{typ: TypeUUID}, - Kind: PARTITION_KEY, - }, - "hint_id": &ColumnMetadata{ - Name: "hint_id", - Type: NativeType{typ: TypeTimeUUID}, - Order: ASC, - Kind: CLUSTERING_KEY, - }, - "message_version": &ColumnMetadata{ - Name: "message_version", - Type: NativeType{typ: TypeInt}, - Order: ASC, - Kind: CLUSTERING_KEY, - }, - "mutation": &ColumnMetadata{ - Name: "mutation", - Type: NativeType{typ: TypeBlob}, - Kind: REGULAR, - }, - }, - }, - "peers": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "peer", - Type: NativeType{typ: TypeInet}, - }, - }, - ClusteringColumns: []*ColumnMetadata{}, - Columns: map[string]*ColumnMetadata{ - "peer": &ColumnMetadata{ - Name: "peer", - Type: NativeType{typ: TypeInet}, - Kind: PARTITION_KEY, - }, - "data_center": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "data_center", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UTF8Type", Type: NativeType{typ: TypeVarchar}}, - "host_id": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "host_id", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UUIDType", Type: NativeType{typ: TypeUUID}}, - "rack": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "rack", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UTF8Type", Type: NativeType{typ: TypeVarchar}}, - "release_version": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "release_version", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UTF8Type", Type: NativeType{typ: TypeVarchar}}, - "rpc_address": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "rpc_address", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.InetAddressType", Type: NativeType{typ: TypeInet}}, - "schema_version": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "schema_version", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UUIDType", Type: NativeType{typ: TypeUUID}}, - "tokens": &ColumnMetadata{Keyspace: "V1Keyspace", Table: "peers", Kind: REGULAR, Name: "tokens", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)", Type: CollectionType{NativeType: NativeType{typ: TypeSet}}}, - }, - }, - "IndexInfo": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "table_name", - Type: NativeType{typ: TypeVarchar}, - }, - }, - ClusteringColumns: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "index_name", - Type: NativeType{typ: TypeVarchar}, - Order: DESC, - }, - }, - Columns: map[string]*ColumnMetadata{ - "table_name": &ColumnMetadata{ - Name: "table_name", - Type: NativeType{typ: TypeVarchar}, - Kind: PARTITION_KEY, - }, - "index_name": &ColumnMetadata{ - Name: "index_name", - Type: NativeType{typ: TypeVarchar}, - Order: DESC, - Kind: CLUSTERING_KEY, - }, - "value": &ColumnMetadata{ - Name: "value", - Type: NativeType{typ: TypeBlob}, - Kind: REGULAR, - }, - }, - }, - "wiki_page": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "title", - Type: NativeType{typ: TypeVarchar}, - }, - }, - ClusteringColumns: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "revid", - Type: NativeType{typ: TypeTimeUUID}, - Order: ASC, - }, - }, - Columns: map[string]*ColumnMetadata{ - "title": &ColumnMetadata{ - Name: "title", - Type: NativeType{typ: TypeVarchar}, - Kind: PARTITION_KEY, - }, - "revid": &ColumnMetadata{ - Name: "revid", - Type: NativeType{typ: TypeTimeUUID}, - Kind: CLUSTERING_KEY, - }, - }, - }, - "no_names": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "key", - Type: NativeType{typ: TypeUUID}, - }, - &ColumnMetadata{ - Name: "key2", - Type: NativeType{typ: TypeUUID}, - }, - }, - ClusteringColumns: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "column", - Type: NativeType{typ: TypeInt}, - Order: ASC, - }, - &ColumnMetadata{ - Name: "column2", - Type: NativeType{typ: TypeInt}, - Order: ASC, - }, - &ColumnMetadata{ - Name: "column3", - Type: NativeType{typ: TypeInt}, - Order: ASC, - }, - }, - Columns: map[string]*ColumnMetadata{ - "key": &ColumnMetadata{ - Name: "key", - Type: NativeType{typ: TypeUUID}, - Kind: PARTITION_KEY, - }, - "key2": &ColumnMetadata{ - Name: "key2", - Type: NativeType{typ: TypeUUID}, - Kind: PARTITION_KEY, - }, - "column": &ColumnMetadata{ - Name: "column", - Type: NativeType{typ: TypeInt}, - Order: ASC, - Kind: CLUSTERING_KEY, - }, - "column2": &ColumnMetadata{ - Name: "column2", - Type: NativeType{typ: TypeInt}, - Order: ASC, - Kind: CLUSTERING_KEY, - }, - "column3": &ColumnMetadata{ - Name: "column3", - Type: NativeType{typ: TypeInt}, - Order: ASC, - Kind: CLUSTERING_KEY, - }, - "value": &ColumnMetadata{ - Name: "value", - Type: NativeType{typ: TypeBlob}, - Kind: REGULAR, - }, - }, - }, - }, - }, - ) - - // V2 test - V2+ protocol is simpler so here are some toy examples to verify that the mapping works - keyspace = &KeyspaceMetadata{ - Name: "V2Keyspace", - } - tables = []TableMetadata{ - TableMetadata{ - Keyspace: "V2Keyspace", - Name: "Table1", - }, - TableMetadata{ - Keyspace: "V2Keyspace", - Name: "Table2", - }, - } - columns = []ColumnMetadata{ - ColumnMetadata{ - Keyspace: "V2Keyspace", - Table: "Table1", - Name: "KEY1", - Kind: PARTITION_KEY, - ComponentIndex: 0, - Validator: "org.apache.cassandra.db.marshal.UTF8Type", - }, - ColumnMetadata{ - Keyspace: "V2Keyspace", - Table: "Table1", - Name: "Key1", - Kind: PARTITION_KEY, - ComponentIndex: 0, - Validator: "org.apache.cassandra.db.marshal.UTF8Type", - }, - ColumnMetadata{ - Keyspace: "V2Keyspace", - Table: "Table2", - Name: "Column1", - Kind: PARTITION_KEY, - ComponentIndex: 0, - Validator: "org.apache.cassandra.db.marshal.UTF8Type", - }, - ColumnMetadata{ - Keyspace: "V2Keyspace", - Table: "Table2", - Name: "Column2", - Kind: CLUSTERING_KEY, - ComponentIndex: 0, - Validator: "org.apache.cassandra.db.marshal.UTF8Type", - }, - ColumnMetadata{ - Keyspace: "V2Keyspace", - Table: "Table2", - Name: "Column3", - Kind: CLUSTERING_KEY, - ComponentIndex: 1, - Validator: "org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type)", - }, - ColumnMetadata{ - Keyspace: "V2Keyspace", - Table: "Table2", - Name: "Column4", - Kind: REGULAR, - Validator: "org.apache.cassandra.db.marshal.UTF8Type", - }, - } - compileMetadata(2, keyspace, tables, columns) - assertKeyspaceMetadata( - t, - keyspace, - &KeyspaceMetadata{ - Name: "V2Keyspace", - Tables: map[string]*TableMetadata{ - "Table1": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "Key1", - Type: NativeType{typ: TypeVarchar}, - }, - }, - ClusteringColumns: []*ColumnMetadata{}, - Columns: map[string]*ColumnMetadata{ - "KEY1": &ColumnMetadata{ - Name: "KEY1", - Type: NativeType{typ: TypeVarchar}, - Kind: PARTITION_KEY, - }, - "Key1": &ColumnMetadata{ - Name: "Key1", - Type: NativeType{typ: TypeVarchar}, - Kind: PARTITION_KEY, - }, - }, - }, - "Table2": &TableMetadata{ - PartitionKey: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "Column1", - Type: NativeType{typ: TypeVarchar}, - }, - }, - ClusteringColumns: []*ColumnMetadata{ - &ColumnMetadata{ - Name: "Column2", - Type: NativeType{typ: TypeVarchar}, - Order: ASC, - }, - &ColumnMetadata{ - Name: "Column3", - Type: NativeType{typ: TypeVarchar}, - Order: DESC, - }, - }, - Columns: map[string]*ColumnMetadata{ - "Column1": &ColumnMetadata{ - Name: "Column1", - Type: NativeType{typ: TypeVarchar}, - Kind: PARTITION_KEY, - }, - "Column2": &ColumnMetadata{ - Name: "Column2", - Type: NativeType{typ: TypeVarchar}, - Order: ASC, - Kind: CLUSTERING_KEY, - }, - "Column3": &ColumnMetadata{ - Name: "Column3", - Type: NativeType{typ: TypeVarchar}, - Order: DESC, - Kind: CLUSTERING_KEY, - }, - "Column4": &ColumnMetadata{ - Name: "Column4", - Type: NativeType{typ: TypeVarchar}, - Kind: REGULAR, - }, - }, - }, - }, - }, - ) -} - -// Helper function for asserting that actual metadata returned was as expected -func assertKeyspaceMetadata(t *testing.T, actual, expected *KeyspaceMetadata) { - if len(expected.Tables) != len(actual.Tables) { - t.Errorf("Expected len(%s.Tables) to be %v but was %v", expected.Name, len(expected.Tables), len(actual.Tables)) - } - for keyT := range expected.Tables { - et := expected.Tables[keyT] - at, found := actual.Tables[keyT] - - if !found { - t.Errorf("Expected %s.Tables[%s] but was not found", expected.Name, keyT) - } else { - if keyT != at.Name { - t.Errorf("Expected %s.Tables[%s].Name to be %v but was %v", expected.Name, keyT, keyT, at.Name) - } - if len(et.PartitionKey) != len(at.PartitionKey) { - t.Errorf("Expected len(%s.Tables[%s].PartitionKey) to be %v but was %v", expected.Name, keyT, len(et.PartitionKey), len(at.PartitionKey)) - } else { - for i := range et.PartitionKey { - if et.PartitionKey[i].Name != at.PartitionKey[i].Name { - t.Errorf("Expected %s.Tables[%s].PartitionKey[%d].Name to be '%v' but was '%v'", expected.Name, keyT, i, et.PartitionKey[i].Name, at.PartitionKey[i].Name) - } - if expected.Name != at.PartitionKey[i].Keyspace { - t.Errorf("Expected %s.Tables[%s].PartitionKey[%d].Keyspace to be '%v' but was '%v'", expected.Name, keyT, i, expected.Name, at.PartitionKey[i].Keyspace) - } - if keyT != at.PartitionKey[i].Table { - t.Errorf("Expected %s.Tables[%s].PartitionKey[%d].Table to be '%v' but was '%v'", expected.Name, keyT, i, keyT, at.PartitionKey[i].Table) - } - if et.PartitionKey[i].Type.Type() != at.PartitionKey[i].Type.Type() { - t.Errorf("Expected %s.Tables[%s].PartitionKey[%d].Type.Type to be %v but was %v", expected.Name, keyT, i, et.PartitionKey[i].Type.Type(), at.PartitionKey[i].Type.Type()) - } - if i != at.PartitionKey[i].ComponentIndex { - t.Errorf("Expected %s.Tables[%s].PartitionKey[%d].ComponentIndex to be %v but was %v", expected.Name, keyT, i, i, at.PartitionKey[i].ComponentIndex) - } - if PARTITION_KEY != at.PartitionKey[i].Kind { - t.Errorf("Expected %s.Tables[%s].PartitionKey[%d].Kind to be '%v' but was '%v'", expected.Name, keyT, i, PARTITION_KEY, at.PartitionKey[i].Kind) - } - } - } - if len(et.ClusteringColumns) != len(at.ClusteringColumns) { - t.Errorf("Expected len(%s.Tables[%s].ClusteringColumns) to be %v but was %v", expected.Name, keyT, len(et.ClusteringColumns), len(at.ClusteringColumns)) - } else { - for i := range et.ClusteringColumns { - if at.ClusteringColumns[i] == nil { - t.Fatalf("Unexpected nil value: %s.Tables[%s].ClusteringColumns[%d]", expected.Name, keyT, i) - } - if et.ClusteringColumns[i].Name != at.ClusteringColumns[i].Name { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].Name to be '%v' but was '%v'", expected.Name, keyT, i, et.ClusteringColumns[i].Name, at.ClusteringColumns[i].Name) - } - if expected.Name != at.ClusteringColumns[i].Keyspace { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].Keyspace to be '%v' but was '%v'", expected.Name, keyT, i, expected.Name, at.ClusteringColumns[i].Keyspace) - } - if keyT != at.ClusteringColumns[i].Table { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].Table to be '%v' but was '%v'", expected.Name, keyT, i, keyT, at.ClusteringColumns[i].Table) - } - if et.ClusteringColumns[i].Type.Type() != at.ClusteringColumns[i].Type.Type() { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].Type.Type to be %v but was %v", expected.Name, keyT, i, et.ClusteringColumns[i].Type.Type(), at.ClusteringColumns[i].Type.Type()) - } - if i != at.ClusteringColumns[i].ComponentIndex { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].ComponentIndex to be %v but was %v", expected.Name, keyT, i, i, at.ClusteringColumns[i].ComponentIndex) - } - if et.ClusteringColumns[i].Order != at.ClusteringColumns[i].Order { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].Order to be %v but was %v", expected.Name, keyT, i, et.ClusteringColumns[i].Order, at.ClusteringColumns[i].Order) - } - if CLUSTERING_KEY != at.ClusteringColumns[i].Kind { - t.Errorf("Expected %s.Tables[%s].ClusteringColumns[%d].Kind to be '%v' but was '%v'", expected.Name, keyT, i, CLUSTERING_KEY, at.ClusteringColumns[i].Kind) - } - } - } - if len(et.Columns) != len(at.Columns) { - eKeys := make([]string, 0, len(et.Columns)) - for key := range et.Columns { - eKeys = append(eKeys, key) - } - aKeys := make([]string, 0, len(at.Columns)) - for key := range at.Columns { - aKeys = append(aKeys, key) - } - t.Errorf("Expected len(%s.Tables[%s].Columns) to be %v (keys:%v) but was %v (keys:%v)", expected.Name, keyT, len(et.Columns), eKeys, len(at.Columns), aKeys) - } else { - for keyC := range et.Columns { - ec := et.Columns[keyC] - ac, found := at.Columns[keyC] - - if !found { - t.Errorf("Expected %s.Tables[%s].Columns[%s] but was not found", expected.Name, keyT, keyC) - } else { - if keyC != ac.Name { - t.Errorf("Expected %s.Tables[%s].Columns[%s].Name to be '%v' but was '%v'", expected.Name, keyT, keyC, keyC, at.Name) - } - if expected.Name != ac.Keyspace { - t.Errorf("Expected %s.Tables[%s].Columns[%s].Keyspace to be '%v' but was '%v'", expected.Name, keyT, keyC, expected.Name, ac.Keyspace) - } - if keyT != ac.Table { - t.Errorf("Expected %s.Tables[%s].Columns[%s].Table to be '%v' but was '%v'", expected.Name, keyT, keyC, keyT, ac.Table) - } - if ec.Type.Type() != ac.Type.Type() { - t.Errorf("Expected %s.Tables[%s].Columns[%s].Type.Type to be %v but was %v", expected.Name, keyT, keyC, ec.Type.Type(), ac.Type.Type()) - } - if ec.Order != ac.Order { - t.Errorf("Expected %s.Tables[%s].Columns[%s].Order to be %v but was %v", expected.Name, keyT, keyC, ec.Order, ac.Order) - } - if ec.Kind != ac.Kind { - t.Errorf("Expected %s.Tables[%s].Columns[%s].Kind to be '%v' but was '%v'", expected.Name, keyT, keyC, ec.Kind, ac.Kind) - } - } - } - } - } - } -} - -// Tests the cassandra type definition parser -func TestTypeParser(t *testing.T) { - // native type - assertParseNonCompositeType( - t, - "org.apache.cassandra.db.marshal.UTF8Type", - assertTypeInfo{Type: TypeVarchar}, - ) - - // reversed - assertParseNonCompositeType( - t, - "org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UUIDType)", - assertTypeInfo{Type: TypeUUID, Reversed: true}, - ) - - // set - assertParseNonCompositeType( - t, - "org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.Int32Type)", - assertTypeInfo{ - Type: TypeSet, - Elem: &assertTypeInfo{Type: TypeInt}, - }, - ) - - // list - assertParseNonCompositeType( - t, - "org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.TimeUUIDType)", - assertTypeInfo{ - Type: TypeList, - Elem: &assertTypeInfo{Type: TypeTimeUUID}, - }, - ) - - // map - assertParseNonCompositeType( - t, - " org.apache.cassandra.db.marshal.MapType( org.apache.cassandra.db.marshal.UUIDType , org.apache.cassandra.db.marshal.BytesType ) ", - assertTypeInfo{ - Type: TypeMap, - Key: &assertTypeInfo{Type: TypeUUID}, - Elem: &assertTypeInfo{Type: TypeBlob}, - }, - ) - - // custom - assertParseNonCompositeType( - t, - "org.apache.cassandra.db.marshal.UserType(sandbox,61646472657373,737472656574:org.apache.cassandra.db.marshal.UTF8Type,63697479:org.apache.cassandra.db.marshal.UTF8Type,7a6970:org.apache.cassandra.db.marshal.Int32Type)", - assertTypeInfo{Type: TypeCustom, Custom: "org.apache.cassandra.db.marshal.UserType(sandbox,61646472657373,737472656574:org.apache.cassandra.db.marshal.UTF8Type,63697479:org.apache.cassandra.db.marshal.UTF8Type,7a6970:org.apache.cassandra.db.marshal.Int32Type)"}, - ) - assertParseNonCompositeType( - t, - "org.apache.cassandra.db.marshal.DynamicCompositeType(u=>org.apache.cassandra.db.marshal.UUIDType,d=>org.apache.cassandra.db.marshal.DateType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,b=>org.apache.cassandra.db.marshal.BytesType,s=>org.apache.cassandra.db.marshal.UTF8Type,B=>org.apache.cassandra.db.marshal.BooleanType,a=>org.apache.cassandra.db.marshal.AsciiType,l=>org.apache.cassandra.db.marshal.LongType,i=>org.apache.cassandra.db.marshal.IntegerType,x=>org.apache.cassandra.db.marshal.LexicalUUIDType)", - assertTypeInfo{Type: TypeCustom, Custom: "org.apache.cassandra.db.marshal.DynamicCompositeType(u=>org.apache.cassandra.db.marshal.UUIDType,d=>org.apache.cassandra.db.marshal.DateType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,b=>org.apache.cassandra.db.marshal.BytesType,s=>org.apache.cassandra.db.marshal.UTF8Type,B=>org.apache.cassandra.db.marshal.BooleanType,a=>org.apache.cassandra.db.marshal.AsciiType,l=>org.apache.cassandra.db.marshal.LongType,i=>org.apache.cassandra.db.marshal.IntegerType,x=>org.apache.cassandra.db.marshal.LexicalUUIDType)"}, - ) - - // composite defs - assertParseCompositeType( - t, - "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type)", - []assertTypeInfo{ - assertTypeInfo{Type: TypeVarchar}, - }, - nil, - ) - assertParseCompositeType( - t, - "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.DateType),org.apache.cassandra.db.marshal.UTF8Type)", - []assertTypeInfo{ - assertTypeInfo{Type: TypeTimestamp, Reversed: true}, - assertTypeInfo{Type: TypeVarchar}, - }, - nil, - ) - assertParseCompositeType( - t, - "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.ColumnToCollectionType(726f77735f6d6572676564:org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.LongType)))", - []assertTypeInfo{ - assertTypeInfo{Type: TypeVarchar}, - }, - map[string]assertTypeInfo{ - "rows_merged": assertTypeInfo{ - Type: TypeMap, - Key: &assertTypeInfo{Type: TypeInt}, - Elem: &assertTypeInfo{Type: TypeBigInt}, - }, - }, - ) -} - -// expected data holder -type assertTypeInfo struct { - Type Type - Reversed bool - Elem *assertTypeInfo - Key *assertTypeInfo - Custom string -} - -// Helper function for asserting that the type parser returns the expected -// results for the given definition -func assertParseNonCompositeType( - t *testing.T, - def string, - typeExpected assertTypeInfo, -) { - - result := parseType(def) - if len(result.reversed) != 1 { - t.Errorf("%s expected %d reversed values but there were %d", def, 1, len(result.reversed)) - } - - assertParseNonCompositeTypes( - t, - def, - []assertTypeInfo{typeExpected}, - result.types, - ) - - // expect no composite part of the result - if result.isComposite { - t.Errorf("%s: Expected not composite", def) - } - if result.collections != nil { - t.Errorf("%s: Expected nil collections: %v", def, result.collections) - } -} - -// Helper function for asserting that the type parser returns the expected -// results for the given definition -func assertParseCompositeType( - t *testing.T, - def string, - typesExpected []assertTypeInfo, - collectionsExpected map[string]assertTypeInfo, -) { - - result := parseType(def) - if len(result.reversed) != len(typesExpected) { - t.Errorf("%s expected %d reversed values but there were %d", def, len(typesExpected), len(result.reversed)) - } - - assertParseNonCompositeTypes( - t, - def, - typesExpected, - result.types, - ) - - // expect composite part of the result - if !result.isComposite { - t.Errorf("%s: Expected composite", def) - } - if result.collections == nil { - t.Errorf("%s: Expected non-nil collections: %v", def, result.collections) - } - - for name, typeExpected := range collectionsExpected { - // check for an actual type for this name - typeActual, found := result.collections[name] - if !found { - t.Errorf("%s.tcollections: Expected param named %s but there wasn't", def, name) - } else { - // remove the actual from the collection so we can detect extras - delete(result.collections, name) - - // check the type - assertParseNonCompositeTypes( - t, - def+"collections["+name+"]", - []assertTypeInfo{typeExpected}, - []TypeInfo{typeActual}, - ) - } - } - - if len(result.collections) != 0 { - t.Errorf("%s.collections: Expected no more types in collections, but there was %v", def, result.collections) - } -} - -// Helper function for asserting that the type parser returns the expected -// results for the given definition -func assertParseNonCompositeTypes( - t *testing.T, - context string, - typesExpected []assertTypeInfo, - typesActual []TypeInfo, -) { - if len(typesActual) != len(typesExpected) { - t.Errorf("%s: Expected %d types, but there were %d", context, len(typesExpected), len(typesActual)) - } - - for i := range typesExpected { - typeExpected := typesExpected[i] - typeActual := typesActual[i] - - // shadow copy the context for local modification - context := context - if len(typesExpected) > 1 { - context = context + "[" + strconv.Itoa(i) + "]" - } - - // check the type - if typeActual.Type() != typeExpected.Type { - t.Errorf("%s: Expected to parse Type to %s but was %s", context, typeExpected.Type, typeActual.Type()) - } - // check the custom - if typeActual.Custom() != typeExpected.Custom { - t.Errorf("%s: Expected to parse Custom %s but was %s", context, typeExpected.Custom, typeActual.Custom()) - } - - collection, _ := typeActual.(CollectionType) - // check the elem - if typeExpected.Elem != nil { - if collection.Elem == nil { - t.Errorf("%s: Expected to parse Elem, but was nil ", context) - } else { - assertParseNonCompositeTypes( - t, - context+".Elem", - []assertTypeInfo{*typeExpected.Elem}, - []TypeInfo{collection.Elem}, - ) - } - } else if collection.Elem != nil { - t.Errorf("%s: Expected to not parse Elem, but was %+v", context, collection.Elem) - } - - // check the key - if typeExpected.Key != nil { - if collection.Key == nil { - t.Errorf("%s: Expected to parse Key, but was nil ", context) - } else { - assertParseNonCompositeTypes( - t, - context+".Key", - []assertTypeInfo{*typeExpected.Key}, - []TypeInfo{collection.Key}, - ) - } - } else if collection.Key != nil { - t.Errorf("%s: Expected to not parse Key, but was %+v", context, collection.Key) - } - } -} diff --git a/vendor/github.com/gocql/gocql/policies.go b/vendor/github.com/gocql/gocql/policies.go deleted file mode 100644 index cb68d4369..000000000 --- a/vendor/github.com/gocql/gocql/policies.go +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. -//This file will be the future home for more policies -package gocql - -import ( - "log" - "sync" - "sync/atomic" -) - -//RetryableQuery is an interface that represents a query or batch statement that -//exposes the correct functions for the retry policy logic to evaluate correctly. -type RetryableQuery interface { - Attempts() int - GetConsistency() Consistency -} - -// RetryPolicy interface is used by gocql to determine if a query can be attempted -// again after a retryable error has been received. The interface allows gocql -// users to implement their own logic to determine if a query can be attempted -// again. -// -// See SimpleRetryPolicy as an example of implementing and using a RetryPolicy -// interface. -type RetryPolicy interface { - Attempt(RetryableQuery) bool -} - -// SimpleRetryPolicy has simple logic for attempting a query a fixed number of times. -// -// See below for examples of usage: -// -// //Assign to the cluster -// cluster.RetryPolicy = &gocql.SimpleRetryPolicy{NumRetries: 3} -// -// //Assign to a query -// query.RetryPolicy(&gocql.SimpleRetryPolicy{NumRetries: 1}) -// -type SimpleRetryPolicy struct { - NumRetries int //Number of times to retry a query -} - -// Attempt tells gocql to attempt the query again based on query.Attempts being less -// than the NumRetries defined in the policy. -func (s *SimpleRetryPolicy) Attempt(q RetryableQuery) bool { - return q.Attempts() <= s.NumRetries -} - -//HostSelectionPolicy is an interface for selecting -//the most appropriate host to execute a given query. -type HostSelectionPolicy interface { - SetHosts - SetPartitioner - //Pick returns an iteration function over selected hosts - Pick(*Query) NextHost -} - -//NextHost is an iteration function over picked hosts -type NextHost func() *HostInfo - -//NewRoundRobinHostPolicy is a round-robin load balancing policy -func NewRoundRobinHostPolicy() HostSelectionPolicy { - return &roundRobinHostPolicy{hosts: []HostInfo{}} -} - -type roundRobinHostPolicy struct { - hosts []HostInfo - pos uint32 - mu sync.RWMutex -} - -func (r *roundRobinHostPolicy) SetHosts(hosts []HostInfo) { - r.mu.Lock() - r.hosts = hosts - r.mu.Unlock() -} - -func (r *roundRobinHostPolicy) SetPartitioner(partitioner string) { - // noop -} - -func (r *roundRobinHostPolicy) Pick(qry *Query) NextHost { - // i is used to limit the number of attempts to find a host - // to the number of hosts known to this policy - var i uint32 = 0 - return func() *HostInfo { - r.mu.RLock() - if len(r.hosts) == 0 { - r.mu.RUnlock() - return nil - } - - var host *HostInfo - // always increment pos to evenly distribute traffic in case of - // failures - pos := atomic.AddUint32(&r.pos, 1) - if int(i) < len(r.hosts) { - host = &r.hosts[(pos)%uint32(len(r.hosts))] - i++ - } - r.mu.RUnlock() - return host - } -} - -//NewTokenAwareHostPolicy is a token aware host selection policy -func NewTokenAwareHostPolicy(fallback HostSelectionPolicy) HostSelectionPolicy { - return &tokenAwareHostPolicy{fallback: fallback, hosts: []HostInfo{}} -} - -type tokenAwareHostPolicy struct { - mu sync.RWMutex - hosts []HostInfo - partitioner string - tokenRing *tokenRing - fallback HostSelectionPolicy -} - -func (t *tokenAwareHostPolicy) SetHosts(hosts []HostInfo) { - t.mu.Lock() - defer t.mu.Unlock() - - // always update the fallback - t.fallback.SetHosts(hosts) - t.hosts = hosts - - t.resetTokenRing() -} - -func (t *tokenAwareHostPolicy) SetPartitioner(partitioner string) { - t.mu.Lock() - defer t.mu.Unlock() - - if t.partitioner != partitioner { - t.fallback.SetPartitioner(partitioner) - t.partitioner = partitioner - - t.resetTokenRing() - } -} - -func (t *tokenAwareHostPolicy) resetTokenRing() { - if t.partitioner == "" { - // partitioner not yet set - return - } - - // create a new token ring - tokenRing, err := newTokenRing(t.partitioner, t.hosts) - if err != nil { - log.Printf("Unable to update the token ring due to error: %s", err) - return - } - - // replace the token ring - t.tokenRing = tokenRing -} - -func (t *tokenAwareHostPolicy) Pick(qry *Query) NextHost { - if qry == nil { - return t.fallback.Pick(qry) - } - - routingKey, err := qry.GetRoutingKey() - if err != nil { - return t.fallback.Pick(qry) - } - if routingKey == nil { - return t.fallback.Pick(qry) - } - - var host *HostInfo - - t.mu.RLock() - // TODO retrieve a list of hosts based on the replication strategy - host = t.tokenRing.GetHostForPartitionKey(routingKey) - t.mu.RUnlock() - - if host == nil { - return t.fallback.Pick(qry) - } - - // scope these variables for the same lifetime as the iterator function - var ( - hostReturned bool - fallbackIter NextHost - ) - return func() *HostInfo { - if !hostReturned { - hostReturned = true - return host - } - - // fallback - if fallbackIter == nil { - fallbackIter = t.fallback.Pick(qry) - } - - fallbackHost := fallbackIter() - - // filter the token aware selected hosts from the fallback hosts - if fallbackHost == host { - fallbackHost = fallbackIter() - } - - return fallbackHost - } -} - -//ConnSelectionPolicy is an interface for selecting an -//appropriate connection for executing a query -type ConnSelectionPolicy interface { - SetConns(conns []*Conn) - Pick(*Query) *Conn -} - -type roundRobinConnPolicy struct { - conns []*Conn - pos uint32 - mu sync.RWMutex -} - -func NewRoundRobinConnPolicy() ConnSelectionPolicy { - return &roundRobinConnPolicy{} -} - -func (r *roundRobinConnPolicy) SetConns(conns []*Conn) { - r.mu.Lock() - r.conns = conns - r.mu.Unlock() -} - -func (r *roundRobinConnPolicy) Pick(qry *Query) *Conn { - pos := atomic.AddUint32(&r.pos, 1) - var conn *Conn - r.mu.RLock() - if len(r.conns) > 0 { - conn = r.conns[pos%uint32(len(r.conns))] - } - r.mu.RUnlock() - return conn -} diff --git a/vendor/github.com/gocql/gocql/policies_test.go b/vendor/github.com/gocql/gocql/policies_test.go deleted file mode 100644 index 78f147f4c..000000000 --- a/vendor/github.com/gocql/gocql/policies_test.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2015 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import "testing" - -// Tests of the round-robin host selection policy implementation -func TestRoundRobinHostPolicy(t *testing.T) { - policy := NewRoundRobinHostPolicy() - - hosts := []HostInfo{ - HostInfo{HostId: "0"}, - HostInfo{HostId: "1"}, - } - - policy.SetHosts(hosts) - - // the first host selected is actually at [1], but this is ok for RR - // interleaved iteration should always increment the host - iterA := policy.Pick(nil) - if actual := iterA(); actual != &hosts[1] { - t.Errorf("Expected hosts[1] but was hosts[%s]", actual.HostId) - } - iterB := policy.Pick(nil) - if actual := iterB(); actual != &hosts[0] { - t.Errorf("Expected hosts[0] but was hosts[%s]", actual.HostId) - } - if actual := iterB(); actual != &hosts[1] { - t.Errorf("Expected hosts[1] but was hosts[%s]", actual.HostId) - } - if actual := iterA(); actual != &hosts[0] { - t.Errorf("Expected hosts[0] but was hosts[%s]", actual.HostId) - } - - iterC := policy.Pick(nil) - if actual := iterC(); actual != &hosts[1] { - t.Errorf("Expected hosts[1] but was hosts[%s]", actual.HostId) - } - if actual := iterC(); actual != &hosts[0] { - t.Errorf("Expected hosts[0] but was hosts[%s]", actual.HostId) - } -} - -// Tests of the token-aware host selection policy implementation with a -// round-robin host selection policy fallback. -func TestTokenAwareHostPolicy(t *testing.T) { - policy := NewTokenAwareHostPolicy(NewRoundRobinHostPolicy()) - - query := &Query{} - - iter := policy.Pick(nil) - if iter == nil { - t.Fatal("host iterator was nil") - } - actual := iter() - if actual != nil { - t.Fatalf("expected nil from iterator, but was %v", actual) - } - - // set the hosts - hosts := []HostInfo{ - HostInfo{Peer: "0", Tokens: []string{"00"}}, - HostInfo{Peer: "1", Tokens: []string{"25"}}, - HostInfo{Peer: "2", Tokens: []string{"50"}}, - HostInfo{Peer: "3", Tokens: []string{"75"}}, - } - policy.SetHosts(hosts) - - // the token ring is not setup without the partitioner, but the fallback - // should work - if actual := policy.Pick(nil)(); actual.Peer != "1" { - t.Errorf("Expected peer 1 but was %s", actual.Peer) - } - - query.RoutingKey([]byte("30")) - if actual := policy.Pick(query)(); actual.Peer != "2" { - t.Errorf("Expected peer 2 but was %s", actual.Peer) - } - - policy.SetPartitioner("OrderedPartitioner") - - // now the token ring is configured - query.RoutingKey([]byte("20")) - iter = policy.Pick(query) - if actual := iter(); actual.Peer != "1" { - t.Errorf("Expected peer 1 but was %s", actual.Peer) - } - // rest are round robin - if actual := iter(); actual.Peer != "3" { - t.Errorf("Expected peer 3 but was %s", actual.Peer) - } - if actual := iter(); actual.Peer != "0" { - t.Errorf("Expected peer 0 but was %s", actual.Peer) - } - if actual := iter(); actual.Peer != "2" { - t.Errorf("Expected peer 2 but was %s", actual.Peer) - } -} - -// Tests of the round-robin connection selection policy implementation -func TestRoundRobinConnPolicy(t *testing.T) { - policy := NewRoundRobinConnPolicy() - - conn0 := &Conn{} - conn1 := &Conn{} - conn := []*Conn{ - conn0, - conn1, - } - - policy.SetConns(conn) - - // the first conn selected is actually at [1], but this is ok for RR - if actual := policy.Pick(nil); actual != conn1 { - t.Error("Expected conn1") - } - if actual := policy.Pick(nil); actual != conn0 { - t.Error("Expected conn0") - } - if actual := policy.Pick(nil); actual != conn1 { - t.Error("Expected conn1") - } -} diff --git a/vendor/github.com/gocql/gocql/session.go b/vendor/github.com/gocql/gocql/session.go deleted file mode 100644 index 1ca657fe6..000000000 --- a/vendor/github.com/gocql/gocql/session.go +++ /dev/null @@ -1,1019 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "bytes" - "encoding/binary" - "errors" - "fmt" - "io" - "strings" - "sync" - "time" - "unicode" - - "github.com/golang/groupcache/lru" -) - -// Session is the interface used by users to interact with the database. -// -// It's safe for concurrent use by multiple goroutines and a typical usage -// scenario is to have one global session object to interact with the -// whole Cassandra cluster. -// -// This type extends the Node interface by adding a convinient query builder -// and automatically sets a default consinstency level on all operations -// that do not have a consistency level set. -type Session struct { - Pool ConnectionPool - cons Consistency - pageSize int - prefetch float64 - routingKeyInfoCache routingKeyInfoLRU - schemaDescriber *schemaDescriber - trace Tracer - hostSource *ringDescriber - mu sync.RWMutex - - cfg ClusterConfig - - closeMu sync.RWMutex - isClosed bool -} - -// NewSession wraps an existing Node. -func NewSession(cfg ClusterConfig) (*Session, error) { - //Check that hosts in the ClusterConfig is not empty - if len(cfg.Hosts) < 1 { - return nil, ErrNoHosts - } - - maxStreams := 128 - if cfg.ProtoVersion > protoVersion2 { - maxStreams = 32768 - } - - if cfg.NumStreams <= 0 || cfg.NumStreams > maxStreams { - cfg.NumStreams = maxStreams - } - - pool, err := cfg.ConnPoolType(&cfg) - if err != nil { - return nil, err - } - - //Adjust the size of the prepared statements cache to match the latest configuration - stmtsLRU.Lock() - initStmtsLRU(cfg.MaxPreparedStmts) - stmtsLRU.Unlock() - - s := &Session{ - Pool: pool, - cons: cfg.Consistency, - prefetch: 0.25, - cfg: cfg, - } - - //See if there are any connections in the pool - if pool.Size() > 0 { - s.routingKeyInfoCache.lru = lru.New(cfg.MaxRoutingKeyInfo) - - s.SetConsistency(cfg.Consistency) - s.SetPageSize(cfg.PageSize) - - if cfg.DiscoverHosts { - s.hostSource = &ringDescriber{ - session: s, - dcFilter: cfg.Discovery.DcFilter, - rackFilter: cfg.Discovery.RackFilter, - closeChan: make(chan bool), - } - - go s.hostSource.run(cfg.Discovery.Sleep) - } - - return s, nil - } - - s.Close() - - return nil, ErrNoConnectionsStarted -} - -// SetConsistency sets the default consistency level for this session. This -// setting can also be changed on a per-query basis and the default value -// is Quorum. -func (s *Session) SetConsistency(cons Consistency) { - s.mu.Lock() - s.cons = cons - s.mu.Unlock() -} - -// SetPageSize sets the default page size for this session. A value <= 0 will -// disable paging. This setting can also be changed on a per-query basis. -func (s *Session) SetPageSize(n int) { - s.mu.Lock() - s.pageSize = n - s.mu.Unlock() -} - -// SetPrefetch sets the default threshold for pre-fetching new pages. If -// there are only p*pageSize rows remaining, the next page will be requested -// automatically. This value can also be changed on a per-query basis and -// the default value is 0.25. -func (s *Session) SetPrefetch(p float64) { - s.mu.Lock() - s.prefetch = p - s.mu.Unlock() -} - -// SetTrace sets the default tracer for this session. This setting can also -// be changed on a per-query basis. -func (s *Session) SetTrace(trace Tracer) { - s.mu.Lock() - s.trace = trace - s.mu.Unlock() -} - -// Query generates a new query object for interacting with the database. -// Further details of the query may be tweaked using the resulting query -// value before the query is executed. Query is automatically prepared -// if it has not previously been executed. -func (s *Session) Query(stmt string, values ...interface{}) *Query { - s.mu.RLock() - qry := &Query{stmt: stmt, values: values, cons: s.cons, - session: s, pageSize: s.pageSize, trace: s.trace, - prefetch: s.prefetch, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency, - defaultTimestamp: s.cfg.DefaultTimestamp, - } - s.mu.RUnlock() - return qry -} - -type QueryInfo struct { - Id []byte - Args []ColumnInfo - Rval []ColumnInfo -} - -// Bind generates a new query object based on the query statement passed in. -// The query is automatically prepared if it has not previously been executed. -// The binding callback allows the application to define which query argument -// values will be marshalled as part of the query execution. -// During execution, the meta data of the prepared query will be routed to the -// binding callback, which is responsible for producing the query argument values. -func (s *Session) Bind(stmt string, b func(q *QueryInfo) ([]interface{}, error)) *Query { - s.mu.RLock() - qry := &Query{stmt: stmt, binding: b, cons: s.cons, - session: s, pageSize: s.pageSize, trace: s.trace, - prefetch: s.prefetch, rt: s.cfg.RetryPolicy} - s.mu.RUnlock() - return qry -} - -// Close closes all connections. The session is unusable after this -// operation. -func (s *Session) Close() { - - s.closeMu.Lock() - defer s.closeMu.Unlock() - if s.isClosed { - return - } - s.isClosed = true - - s.Pool.Close() - - if s.hostSource != nil { - close(s.hostSource.closeChan) - } -} - -func (s *Session) Closed() bool { - s.closeMu.RLock() - closed := s.isClosed - s.closeMu.RUnlock() - return closed -} - -func (s *Session) executeQuery(qry *Query) *Iter { - - // fail fast - if s.Closed() { - return &Iter{err: ErrSessionClosed} - } - - var iter *Iter - qry.attempts = 0 - qry.totalLatency = 0 - for { - conn := s.Pool.Pick(qry) - - //Assign the error unavailable to the iterator - if conn == nil { - iter = &Iter{err: ErrNoConnections} - break - } - - t := time.Now() - iter = conn.executeQuery(qry) - qry.totalLatency += time.Now().Sub(t).Nanoseconds() - qry.attempts++ - - //Exit for loop if the query was successful - if iter.err == nil { - break - } - - if qry.rt == nil || !qry.rt.Attempt(qry) { - break - } - } - - return iter -} - -// KeyspaceMetadata returns the schema metadata for the keyspace specified. -func (s *Session) KeyspaceMetadata(keyspace string) (*KeyspaceMetadata, error) { - // fail fast - if s.Closed() { - return nil, ErrSessionClosed - } - - if keyspace == "" { - return nil, ErrNoKeyspace - } - - s.mu.Lock() - // lazy-init schemaDescriber - if s.schemaDescriber == nil { - s.schemaDescriber = newSchemaDescriber(s) - } - s.mu.Unlock() - - return s.schemaDescriber.getSchema(keyspace) -} - -// returns routing key indexes and type info -func (s *Session) routingKeyInfo(stmt string) (*routingKeyInfo, error) { - s.routingKeyInfoCache.mu.Lock() - cacheKey := s.cfg.Keyspace + stmt - - entry, cached := s.routingKeyInfoCache.lru.Get(cacheKey) - if cached { - // done accessing the cache - s.routingKeyInfoCache.mu.Unlock() - // the entry is an inflight struct similiar to that used by - // Conn to prepare statements - inflight := entry.(*inflightCachedEntry) - - // wait for any inflight work - inflight.wg.Wait() - - if inflight.err != nil { - return nil, inflight.err - } - - key, _ := inflight.value.(*routingKeyInfo) - - return key, nil - } - - // create a new inflight entry while the data is created - inflight := new(inflightCachedEntry) - inflight.wg.Add(1) - defer inflight.wg.Done() - s.routingKeyInfoCache.lru.Add(cacheKey, inflight) - s.routingKeyInfoCache.mu.Unlock() - - var ( - prepared *resultPreparedFrame - partitionKey []*ColumnMetadata - ) - - // get the query info for the statement - conn := s.Pool.Pick(nil) - if conn == nil { - // no connections - inflight.err = ErrNoConnections - // don't cache this error - s.routingKeyInfoCache.Remove(cacheKey) - return nil, inflight.err - } - - prepared, inflight.err = conn.prepareStatement(stmt, nil) - if inflight.err != nil { - // don't cache this error - s.routingKeyInfoCache.Remove(cacheKey) - return nil, inflight.err - } - - if len(prepared.reqMeta.columns) == 0 { - // no arguments, no routing key, and no error - return nil, nil - } - - // get the table metadata - table := prepared.reqMeta.columns[0].Table - - var keyspaceMetadata *KeyspaceMetadata - keyspaceMetadata, inflight.err = s.KeyspaceMetadata(s.cfg.Keyspace) - if inflight.err != nil { - // don't cache this error - s.routingKeyInfoCache.Remove(cacheKey) - return nil, inflight.err - } - - tableMetadata, found := keyspaceMetadata.Tables[table] - if !found { - // unlikely that the statement could be prepared and the metadata for - // the table couldn't be found, but this may indicate either a bug - // in the metadata code, or that the table was just dropped. - inflight.err = ErrNoMetadata - // don't cache this error - s.routingKeyInfoCache.Remove(cacheKey) - return nil, inflight.err - } - - partitionKey = tableMetadata.PartitionKey - - size := len(partitionKey) - routingKeyInfo := &routingKeyInfo{ - indexes: make([]int, size), - types: make([]TypeInfo, size), - } - for keyIndex, keyColumn := range partitionKey { - // set an indicator for checking if the mapping is missing - routingKeyInfo.indexes[keyIndex] = -1 - - // find the column in the query info - for argIndex, boundColumn := range prepared.reqMeta.columns { - if keyColumn.Name == boundColumn.Name { - // there may be many such bound columns, pick the first - routingKeyInfo.indexes[keyIndex] = argIndex - routingKeyInfo.types[keyIndex] = boundColumn.TypeInfo - break - } - } - - if routingKeyInfo.indexes[keyIndex] == -1 { - // missing a routing key column mapping - // no routing key, and no error - return nil, nil - } - } - - // cache this result - inflight.value = routingKeyInfo - - return routingKeyInfo, nil -} - -// ExecuteBatch executes a batch operation and returns nil if successful -// otherwise an error is returned describing the failure. -func (s *Session) ExecuteBatch(batch *Batch) error { - // fail fast - if s.Closed() { - return ErrSessionClosed - } - - // Prevent the execution of the batch if greater than the limit - // Currently batches have a limit of 65536 queries. - // https://datastax-oss.atlassian.net/browse/JAVA-229 - if batch.Size() > BatchSizeMaximum { - return ErrTooManyStmts - } - - var err error - batch.attempts = 0 - batch.totalLatency = 0 - for { - conn := s.Pool.Pick(nil) - - //Assign the error unavailable and break loop - if conn == nil { - err = ErrNoConnections - break - } - t := time.Now() - err = conn.executeBatch(batch) - batch.totalLatency += time.Now().Sub(t).Nanoseconds() - batch.attempts++ - //Exit loop if operation executed correctly - if err == nil { - return nil - } - - if batch.rt == nil || !batch.rt.Attempt(batch) { - break - } - } - - return err -} - -// Query represents a CQL statement that can be executed. -type Query struct { - stmt string - values []interface{} - cons Consistency - pageSize int - routingKey []byte - pageState []byte - prefetch float64 - trace Tracer - session *Session - rt RetryPolicy - binding func(q *QueryInfo) ([]interface{}, error) - attempts int - totalLatency int64 - serialCons SerialConsistency - defaultTimestamp bool -} - -//Attempts returns the number of times the query was executed. -func (q *Query) Attempts() int { - return q.attempts -} - -//Latency returns the average amount of nanoseconds per attempt of the query. -func (q *Query) Latency() int64 { - if q.attempts > 0 { - return q.totalLatency / int64(q.attempts) - } - return 0 -} - -// Consistency sets the consistency level for this query. If no consistency -// level have been set, the default consistency level of the cluster -// is used. -func (q *Query) Consistency(c Consistency) *Query { - q.cons = c - return q -} - -// GetConsistency returns the currently configured consistency level for -// the query. -func (q *Query) GetConsistency() Consistency { - return q.cons -} - -// Trace enables tracing of this query. Look at the documentation of the -// Tracer interface to learn more about tracing. -func (q *Query) Trace(trace Tracer) *Query { - q.trace = trace - return q -} - -// PageSize will tell the iterator to fetch the result in pages of size n. -// This is useful for iterating over large result sets, but setting the -// page size to low might decrease the performance. This feature is only -// available in Cassandra 2 and onwards. -func (q *Query) PageSize(n int) *Query { - q.pageSize = n - return q -} - -// DefaultTimestamp will enable the with default timestamp flag on the query. -// If enable, this will replace the server side assigned -// timestamp as default timestamp. Note that a timestamp in the query itself -// will still override this timestamp. This is entirely optional. -// -// Only available on protocol >= 3 -func (q *Query) DefaultTimestamp(enable bool) *Query { - q.defaultTimestamp = enable - return q -} - -// RoutingKey sets the routing key to use when a token aware connection -// pool is used to optimize the routing of this query. -func (q *Query) RoutingKey(routingKey []byte) *Query { - q.routingKey = routingKey - return q -} - -// GetRoutingKey gets the routing key to use for routing this query. If -// a routing key has not been explicitly set, then the routing key will -// be constructed if possible using the keyspace's schema and the query -// info for this query statement. If the routing key cannot be determined -// then nil will be returned with no error. On any error condition, -// an error description will be returned. -func (q *Query) GetRoutingKey() ([]byte, error) { - if q.routingKey != nil { - return q.routingKey, nil - } - - // try to determine the routing key - routingKeyInfo, err := q.session.routingKeyInfo(q.stmt) - if err != nil { - return nil, err - } - if routingKeyInfo == nil { - return nil, nil - } - - if len(routingKeyInfo.indexes) == 1 { - // single column routing key - routingKey, err := Marshal( - routingKeyInfo.types[0], - q.values[routingKeyInfo.indexes[0]], - ) - if err != nil { - return nil, err - } - return routingKey, nil - } - - // composite routing key - buf := &bytes.Buffer{} - for i := range routingKeyInfo.indexes { - encoded, err := Marshal( - routingKeyInfo.types[i], - q.values[routingKeyInfo.indexes[i]], - ) - if err != nil { - return nil, err - } - binary.Write(buf, binary.BigEndian, int16(len(encoded))) - buf.Write(encoded) - buf.WriteByte(0x00) - } - routingKey := buf.Bytes() - return routingKey, nil -} - -func (q *Query) shouldPrepare() bool { - - stmt := strings.TrimLeftFunc(strings.TrimRightFunc(q.stmt, func(r rune) bool { - return unicode.IsSpace(r) || r == ';' - }), unicode.IsSpace) - - var stmtType string - if n := strings.IndexFunc(stmt, unicode.IsSpace); n >= 0 { - stmtType = strings.ToLower(stmt[:n]) - } - if stmtType == "begin" { - if n := strings.LastIndexFunc(stmt, unicode.IsSpace); n >= 0 { - stmtType = strings.ToLower(stmt[n+1:]) - } - } - switch stmtType { - case "select", "insert", "update", "delete", "batch": - return true - } - return false -} - -// SetPrefetch sets the default threshold for pre-fetching new pages. If -// there are only p*pageSize rows remaining, the next page will be requested -// automatically. -func (q *Query) Prefetch(p float64) *Query { - q.prefetch = p - return q -} - -// RetryPolicy sets the policy to use when retrying the query. -func (q *Query) RetryPolicy(r RetryPolicy) *Query { - q.rt = r - return q -} - -// Bind sets query arguments of query. This can also be used to rebind new query arguments -// to an existing query instance. -func (q *Query) Bind(v ...interface{}) *Query { - q.values = v - return q -} - -// SerialConsistency sets the consistencyc level for the -// serial phase of conditional updates. That consitency can only be -// either SERIAL or LOCAL_SERIAL and if not present, it defaults to -// SERIAL. This option will be ignored for anything else that a -// conditional update/insert. -func (q *Query) SerialConsistency(cons SerialConsistency) *Query { - q.serialCons = cons - return q -} - -// Exec executes the query without returning any rows. -func (q *Query) Exec() error { - iter := q.Iter() - return iter.err -} - -// Iter executes the query and returns an iterator capable of iterating -// over all results. -func (q *Query) Iter() *Iter { - if strings.Index(strings.ToLower(q.stmt), "use") == 0 { - return &Iter{err: ErrUseStmt} - } - return q.session.executeQuery(q) -} - -// MapScan executes the query, copies the columns of the first selected -// row into the map pointed at by m and discards the rest. If no rows -// were selected, ErrNotFound is returned. -func (q *Query) MapScan(m map[string]interface{}) error { - iter := q.Iter() - if err := iter.checkErrAndNotFound(); err != nil { - return err - } - iter.MapScan(m) - return iter.Close() -} - -// Scan executes the query, copies the columns of the first selected -// row into the values pointed at by dest and discards the rest. If no rows -// were selected, ErrNotFound is returned. -func (q *Query) Scan(dest ...interface{}) error { - iter := q.Iter() - if err := iter.checkErrAndNotFound(); err != nil { - return err - } - iter.Scan(dest...) - return iter.Close() -} - -// ScanCAS executes a lightweight transaction (i.e. an UPDATE or INSERT -// statement containing an IF clause). If the transaction fails because -// the existing values did not match, the previous values will be stored -// in dest. -func (q *Query) ScanCAS(dest ...interface{}) (applied bool, err error) { - iter := q.Iter() - if err := iter.checkErrAndNotFound(); err != nil { - return false, err - } - if len(iter.Columns()) > 1 { - dest = append([]interface{}{&applied}, dest...) - iter.Scan(dest...) - } else { - iter.Scan(&applied) - } - return applied, iter.Close() -} - -// MapScanCAS executes a lightweight transaction (i.e. an UPDATE or INSERT -// statement containing an IF clause). If the transaction fails because -// the existing values did not match, the previous values will be stored -// in dest map. -// -// As for INSERT .. IF NOT EXISTS, previous values will be returned as if -// SELECT * FROM. So using ScanCAS with INSERT is inherently prone to -// column mismatching. MapScanCAS is added to capture them safely. -func (q *Query) MapScanCAS(dest map[string]interface{}) (applied bool, err error) { - iter := q.Iter() - if err := iter.checkErrAndNotFound(); err != nil { - return false, err - } - iter.MapScan(dest) - applied = dest["[applied]"].(bool) - delete(dest, "[applied]") - - return applied, iter.Close() -} - -// Iter represents an iterator that can be used to iterate over all rows that -// were returned by a query. The iterator might send additional queries to the -// database during the iteration if paging was enabled. -type Iter struct { - err error - pos int - rows [][][]byte - meta resultMetadata - next *nextIter -} - -// Columns returns the name and type of the selected columns. -func (iter *Iter) Columns() []ColumnInfo { - return iter.meta.columns -} - -// Scan consumes the next row of the iterator and copies the columns of the -// current row into the values pointed at by dest. Use nil as a dest value -// to skip the corresponding column. Scan might send additional queries -// to the database to retrieve the next set of rows if paging was enabled. -// -// Scan returns true if the row was successfully unmarshaled or false if the -// end of the result set was reached or if an error occurred. Close should -// be called afterwards to retrieve any potential errors. -func (iter *Iter) Scan(dest ...interface{}) bool { - if iter.err != nil { - return false - } - if iter.pos >= len(iter.rows) { - if iter.next != nil { - *iter = *iter.next.fetch() - return iter.Scan(dest...) - } - return false - } - if iter.next != nil && iter.pos == iter.next.pos { - go iter.next.fetch() - } - - // currently only support scanning into an expand tuple, such that its the same - // as scanning in more values from a single column - if len(dest) != iter.meta.actualColCount { - iter.err = errors.New("count mismatch") - return false - } - - // i is the current position in dest, could posible replace it and just use - // slices of dest - i := 0 - for c, col := range iter.meta.columns { - if dest[i] == nil { - i++ - continue - } - - switch col.TypeInfo.Type() { - case TypeTuple: - // this will panic, actually a bug, please report - tuple := col.TypeInfo.(TupleTypeInfo) - - count := len(tuple.Elems) - // here we pass in a slice of the struct which has the number number of - // values as elements in the tuple - iter.err = Unmarshal(col.TypeInfo, iter.rows[iter.pos][c], dest[i:i+count]) - i += count - default: - iter.err = Unmarshal(col.TypeInfo, iter.rows[iter.pos][c], dest[i]) - i++ - } - - if iter.err != nil { - return false - } - } - - iter.pos++ - return true -} - -// Close closes the iterator and returns any errors that happened during -// the query or the iteration. -func (iter *Iter) Close() error { - return iter.err -} - -// checkErrAndNotFound handle error and NotFound in one method. -func (iter *Iter) checkErrAndNotFound() error { - if iter.err != nil { - return iter.err - } else if len(iter.rows) == 0 { - return ErrNotFound - } - return nil -} - -type nextIter struct { - qry Query - pos int - once sync.Once - next *Iter -} - -func (n *nextIter) fetch() *Iter { - n.once.Do(func() { - n.next = n.qry.session.executeQuery(&n.qry) - }) - return n.next -} - -type Batch struct { - Type BatchType - Entries []BatchEntry - Cons Consistency - rt RetryPolicy - attempts int - totalLatency int64 - serialCons SerialConsistency - defaultTimestamp bool -} - -// NewBatch creates a new batch operation without defaults from the cluster -func NewBatch(typ BatchType) *Batch { - return &Batch{Type: typ} -} - -// NewBatch creates a new batch operation using defaults defined in the cluster -func (s *Session) NewBatch(typ BatchType) *Batch { - s.mu.RLock() - batch := &Batch{Type: typ, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency, - Cons: s.cons, defaultTimestamp: s.cfg.DefaultTimestamp} - s.mu.RUnlock() - return batch -} - -// Attempts returns the number of attempts made to execute the batch. -func (b *Batch) Attempts() int { - return b.attempts -} - -//Latency returns the average number of nanoseconds to execute a single attempt of the batch. -func (b *Batch) Latency() int64 { - if b.attempts > 0 { - return b.totalLatency / int64(b.attempts) - } - return 0 -} - -// GetConsistency returns the currently configured consistency level for the batch -// operation. -func (b *Batch) GetConsistency() Consistency { - return b.Cons -} - -// Query adds the query to the batch operation -func (b *Batch) Query(stmt string, args ...interface{}) { - b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, Args: args}) -} - -// Bind adds the query to the batch operation and correlates it with a binding callback -// that will be invoked when the batch is executed. The binding callback allows the application -// to define which query argument values will be marshalled as part of the batch execution. -func (b *Batch) Bind(stmt string, bind func(q *QueryInfo) ([]interface{}, error)) { - b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, binding: bind}) -} - -// RetryPolicy sets the retry policy to use when executing the batch operation -func (b *Batch) RetryPolicy(r RetryPolicy) *Batch { - b.rt = r - return b -} - -// Size returns the number of batch statements to be executed by the batch operation. -func (b *Batch) Size() int { - return len(b.Entries) -} - -// SerialConsistency sets the consistencyc level for the -// serial phase of conditional updates. That consitency can only be -// either SERIAL or LOCAL_SERIAL and if not present, it defaults to -// SERIAL. This option will be ignored for anything else that a -// conditional update/insert. -// -// Only available for protocol 3 and above -func (b *Batch) SerialConsistency(cons SerialConsistency) *Batch { - b.serialCons = cons - return b -} - -// DefaultTimestamp will enable the with default timestamp flag on the query. -// If enable, this will replace the server side assigned -// timestamp as default timestamp. Note that a timestamp in the query itself -// will still override this timestamp. This is entirely optional. -// -// Only available on protocol >= 3 -func (b *Batch) DefaultTimestamp(enable bool) *Batch { - b.defaultTimestamp = enable - return b -} - -type BatchType byte - -const ( - LoggedBatch BatchType = 0 - UnloggedBatch = 1 - CounterBatch = 2 -) - -type BatchEntry struct { - Stmt string - Args []interface{} - binding func(q *QueryInfo) ([]interface{}, error) -} - -type ColumnInfo struct { - Keyspace string - Table string - Name string - TypeInfo TypeInfo -} - -func (c ColumnInfo) String() string { - return fmt.Sprintf("[column keyspace=%s table=%s name=%s type=%v]", c.Keyspace, c.Table, c.Name, c.TypeInfo) -} - -// routing key indexes LRU cache -type routingKeyInfoLRU struct { - lru *lru.Cache - mu sync.Mutex -} - -type routingKeyInfo struct { - indexes []int - types []TypeInfo -} - -func (r *routingKeyInfoLRU) Remove(key string) { - r.mu.Lock() - r.lru.Remove(key) - r.mu.Unlock() -} - -//Max adjusts the maximum size of the cache and cleans up the oldest records if -//the new max is lower than the previous value. Not concurrency safe. -func (r *routingKeyInfoLRU) Max(max int) { - r.mu.Lock() - for r.lru.Len() > max { - r.lru.RemoveOldest() - } - r.lru.MaxEntries = max - r.mu.Unlock() -} - -type inflightCachedEntry struct { - wg sync.WaitGroup - err error - value interface{} -} - -// Tracer is the interface implemented by query tracers. Tracers have the -// ability to obtain a detailed event log of all events that happened during -// the execution of a query from Cassandra. Gathering this information might -// be essential for debugging and optimizing queries, but this feature should -// not be used on production systems with very high load. -type Tracer interface { - Trace(traceId []byte) -} - -type traceWriter struct { - session *Session - w io.Writer - mu sync.Mutex -} - -// NewTraceWriter returns a simple Tracer implementation that outputs -// the event log in a textual format. -func NewTraceWriter(session *Session, w io.Writer) Tracer { - return &traceWriter{session: session, w: w} -} - -func (t *traceWriter) Trace(traceId []byte) { - var ( - coordinator string - duration int - ) - t.session.Query(`SELECT coordinator, duration - FROM system_traces.sessions - WHERE session_id = ?`, traceId). - Consistency(One).Scan(&coordinator, &duration) - - iter := t.session.Query(`SELECT event_id, activity, source, source_elapsed - FROM system_traces.events - WHERE session_id = ?`, traceId). - Consistency(One).Iter() - var ( - timestamp time.Time - activity string - source string - elapsed int - ) - t.mu.Lock() - defer t.mu.Unlock() - fmt.Fprintf(t.w, "Tracing session %016x (coordinator: %s, duration: %v):\n", - traceId, coordinator, time.Duration(duration)*time.Microsecond) - for iter.Scan(×tamp, &activity, &source, &elapsed) { - fmt.Fprintf(t.w, "%s: %s (source: %s, elapsed: %d)\n", - timestamp.Format("2006/01/02 15:04:05.999999"), activity, source, elapsed) - } - if err := iter.Close(); err != nil { - fmt.Fprintln(t.w, "Error:", err) - } -} - -type Error struct { - Code int - Message string -} - -func (e Error) Error() string { - return e.Message -} - -var ( - ErrNotFound = errors.New("not found") - ErrUnavailable = errors.New("unavailable") - ErrUnsupported = errors.New("feature not supported") - ErrTooManyStmts = errors.New("too many statements") - ErrUseStmt = errors.New("use statements aren't supported. Please see https://github.com/gocql/gocql for explaination.") - ErrSessionClosed = errors.New("session has been closed") - ErrNoConnections = errors.New("no connections available") - ErrNoKeyspace = errors.New("no keyspace provided") - ErrNoMetadata = errors.New("no metadata available") -) - -type ErrProtocol struct{ error } - -func NewErrProtocol(format string, args ...interface{}) error { - return ErrProtocol{fmt.Errorf(format, args...)} -} - -// BatchSizeMaximum is the maximum number of statements a batch operation can have. -// This limit is set by cassandra and could change in the future. -const BatchSizeMaximum = 65535 diff --git a/vendor/github.com/gocql/gocql/session_test.go b/vendor/github.com/gocql/gocql/session_test.go deleted file mode 100644 index fa41b6689..000000000 --- a/vendor/github.com/gocql/gocql/session_test.go +++ /dev/null @@ -1,255 +0,0 @@ -// +build all integration - -package gocql - -import ( - "fmt" - "testing" -) - -func TestSessionAPI(t *testing.T) { - - cfg := &ClusterConfig{} - pool, err := NewSimplePool(cfg) - if err != nil { - t.Fatal(err) - } - - s := &Session{ - Pool: pool, - cfg: *cfg, - cons: Quorum, - } - - defer s.Close() - - s.SetConsistency(All) - if s.cons != All { - t.Fatalf("expected consistency 'All', got '%v'", s.cons) - } - - s.SetPageSize(100) - if s.pageSize != 100 { - t.Fatalf("expected pageSize 100, got %v", s.pageSize) - } - - s.SetPrefetch(0.75) - if s.prefetch != 0.75 { - t.Fatalf("expceted prefetch 0.75, got %v", s.prefetch) - } - - trace := &traceWriter{} - - s.SetTrace(trace) - if s.trace != trace { - t.Fatalf("expected traceWriter '%v',got '%v'", trace, s.trace) - } - - qry := s.Query("test", 1) - if v, ok := qry.values[0].(int); !ok { - t.Fatalf("expected qry.values[0] to be an int, got %v", qry.values[0]) - } else if v != 1 { - t.Fatalf("expceted qry.values[0] to be 1, got %v", v) - } else if qry.stmt != "test" { - t.Fatalf("expected qry.stmt to be 'test', got '%v'", qry.stmt) - } - - boundQry := s.Bind("test", func(q *QueryInfo) ([]interface{}, error) { - return nil, nil - }) - if boundQry.binding == nil { - t.Fatal("expected qry.binding to be defined, got nil") - } else if boundQry.stmt != "test" { - t.Fatalf("expected qry.stmt to be 'test', got '%v'", boundQry.stmt) - } - - itr := s.executeQuery(qry) - if itr.err != ErrNoConnections { - t.Fatalf("expected itr.err to be '%v', got '%v'", ErrNoConnections, itr.err) - } - - testBatch := s.NewBatch(LoggedBatch) - testBatch.Query("test") - err = s.ExecuteBatch(testBatch) - - if err != ErrNoConnections { - t.Fatalf("expected session.ExecuteBatch to return '%v', got '%v'", ErrNoConnections, err) - } - - s.Close() - if !s.Closed() { - t.Fatal("expected s.Closed() to be true, got false") - } - //Should just return cleanly - s.Close() - - err = s.ExecuteBatch(testBatch) - if err != ErrSessionClosed { - t.Fatalf("expected session.ExecuteBatch to return '%v', got '%v'", ErrSessionClosed, err) - } -} - -func TestQueryBasicAPI(t *testing.T) { - qry := &Query{} - - if qry.Latency() != 0 { - t.Fatalf("expected Query.Latency() to return 0, got %v", qry.Latency()) - } - - qry.attempts = 2 - qry.totalLatency = 4 - if qry.Attempts() != 2 { - t.Fatalf("expected Query.Attempts() to return 2, got %v", qry.Attempts()) - } - if qry.Latency() != 2 { - t.Fatalf("expected Query.Latency() to return 2, got %v", qry.Latency()) - } - - qry.Consistency(All) - if qry.GetConsistency() != All { - t.Fatalf("expected Query.GetConsistency to return 'All', got '%s'", qry.GetConsistency()) - } - - trace := &traceWriter{} - qry.Trace(trace) - if qry.trace != trace { - t.Fatalf("expected Query.Trace to be '%v', got '%v'", trace, qry.trace) - } - - qry.PageSize(10) - if qry.pageSize != 10 { - t.Fatalf("expected Query.PageSize to be 10, got %v", qry.pageSize) - } - - qry.Prefetch(0.75) - if qry.prefetch != 0.75 { - t.Fatalf("expected Query.Prefetch to be 0.75, got %v", qry.prefetch) - } - - rt := &SimpleRetryPolicy{NumRetries: 3} - if qry.RetryPolicy(rt); qry.rt != rt { - t.Fatalf("expected Query.RetryPolicy to be '%v', got '%v'", rt, qry.rt) - } - - qry.Bind(qry) - if qry.values[0] != qry { - t.Fatalf("expected Query.Values[0] to be '%v', got '%v'", qry, qry.values[0]) - } -} - -func TestQueryShouldPrepare(t *testing.T) { - toPrepare := []string{"select * ", "INSERT INTO", "update table", "delete from", "begin batch"} - cantPrepare := []string{"create table", "USE table", "LIST keyspaces", "alter table", "drop table", "grant user", "revoke user"} - q := &Query{} - - for i := 0; i < len(toPrepare); i++ { - q.stmt = toPrepare[i] - if !q.shouldPrepare() { - t.Fatalf("expected Query.shouldPrepare to return true, got false for statement '%v'", toPrepare[i]) - } - } - - for i := 0; i < len(cantPrepare); i++ { - q.stmt = cantPrepare[i] - if q.shouldPrepare() { - t.Fatalf("expected Query.shouldPrepare to return false, got true for statement '%v'", cantPrepare[i]) - } - } -} - -func TestBatchBasicAPI(t *testing.T) { - - cfg := &ClusterConfig{RetryPolicy: &SimpleRetryPolicy{NumRetries: 2}} - pool, err := NewSimplePool(cfg) - if err != nil { - t.Fatal(err) - } - - s := &Session{ - Pool: pool, - cfg: *cfg, - cons: Quorum, - } - defer s.Close() - - b := s.NewBatch(UnloggedBatch) - if b.Type != UnloggedBatch { - t.Fatalf("expceted batch.Type to be '%v', got '%v'", UnloggedBatch, b.Type) - } else if b.rt != cfg.RetryPolicy { - t.Fatalf("expceted batch.RetryPolicy to be '%v', got '%v'", cfg.RetryPolicy, b.rt) - } - - b = NewBatch(LoggedBatch) - if b.Type != LoggedBatch { - t.Fatalf("expected batch.Type to be '%v', got '%v'", LoggedBatch, b.Type) - } - - b.attempts = 1 - if b.Attempts() != 1 { - t.Fatalf("expceted batch.Attempts() to return %v, got %v", 1, b.Attempts()) - } - - if b.Latency() != 0 { - t.Fatalf("expected batch.Latency() to be 0, got %v", b.Latency()) - } - - b.totalLatency = 4 - if b.Latency() != 4 { - t.Fatalf("expected batch.Latency() to return %v, got %v", 4, b.Latency()) - } - - b.Cons = One - if b.GetConsistency() != One { - t.Fatalf("expected batch.GetConsistency() to return 'One', got '%s'", b.GetConsistency()) - } - - b.Query("test", 1) - if b.Entries[0].Stmt != "test" { - t.Fatalf("expected batch.Entries[0].Stmt to be 'test', got '%v'", b.Entries[0].Stmt) - } else if b.Entries[0].Args[0].(int) != 1 { - t.Fatalf("expected batch.Entries[0].Args[0] to be 1, got %v", b.Entries[0].Args[0]) - } - - b.Bind("test2", func(q *QueryInfo) ([]interface{}, error) { - return nil, nil - }) - - if b.Entries[1].Stmt != "test2" { - t.Fatalf("expected batch.Entries[1].Stmt to be 'test2', got '%v'", b.Entries[1].Stmt) - } else if b.Entries[1].binding == nil { - t.Fatal("expected batch.Entries[1].binding to be defined, got nil") - } - r := &SimpleRetryPolicy{NumRetries: 4} - - b.RetryPolicy(r) - if b.rt != r { - t.Fatalf("expected batch.RetryPolicy to be '%v', got '%v'", r, b.rt) - } - - if b.Size() != 2 { - t.Fatalf("expected batch.Size() to return 2, got %v", b.Size()) - } - -} - -func TestConsistencyNames(t *testing.T) { - names := map[fmt.Stringer]string{ - Any: "ANY", - One: "ONE", - Two: "TWO", - Three: "THREE", - Quorum: "QUORUM", - All: "ALL", - LocalQuorum: "LOCAL_QUORUM", - EachQuorum: "EACH_QUORUM", - Serial: "SERIAL", - LocalSerial: "LOCAL_SERIAL", - LocalOne: "LOCAL_ONE", - } - - for k, v := range names { - if k.String() != v { - t.Fatalf("expected '%v', got '%v'", v, k.String()) - } - } -} diff --git a/vendor/github.com/gocql/gocql/stress_test.go b/vendor/github.com/gocql/gocql/stress_test.go deleted file mode 100644 index 57e07085d..000000000 --- a/vendor/github.com/gocql/gocql/stress_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build all integration - -package gocql - -import ( - "sync/atomic" - - "testing" -) - -func BenchmarkConnStress(b *testing.B) { - const workers = 16 - - cluster := createCluster() - cluster.NumConns = 1 - cluster.NumStreams = workers - session := createSessionFromCluster(cluster, b) - defer session.Close() - - if err := createTable(session, "CREATE TABLE IF NOT EXISTS conn_stress (id int primary key)"); err != nil { - b.Fatal(err) - } - - var seed uint64 - writer := func(pb *testing.PB) { - seed := atomic.AddUint64(&seed, 1) - var i uint64 = 0 - for pb.Next() { - if err := session.Query("insert into conn_stress (id) values (?)", i*seed).Exec(); err != nil { - b.Error(err) - return - } - i++ - } - } - - b.SetParallelism(workers) - b.RunParallel(writer) - -} diff --git a/vendor/github.com/gocql/gocql/token.go b/vendor/github.com/gocql/gocql/token.go deleted file mode 100644 index 00541707d..000000000 --- a/vendor/github.com/gocql/gocql/token.go +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright (c) 2015 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "bytes" - "crypto/md5" - "fmt" - "math/big" - "sort" - "strconv" - "strings" - "unsafe" -) - -// a token partitioner -type partitioner interface { - Name() string - Hash([]byte) token - ParseString(string) token -} - -// a token -type token interface { - fmt.Stringer - Less(token) bool -} - -// murmur3 partitioner and token -type murmur3Partitioner struct{} -type murmur3Token int64 - -func (p murmur3Partitioner) Name() string { - return "Murmur3Partitioner" -} - -func (p murmur3Partitioner) Hash(partitionKey []byte) token { - h1 := murmur3H1(partitionKey) - return murmur3Token(int64(h1)) -} - -// murmur3 little-endian, 128-bit hash, but returns only h1 -func murmur3H1(data []byte) uint64 { - length := len(data) - - var h1, h2, k1, k2 uint64 - - const ( - c1 = 0x87c37b91114253d5 - c2 = 0x4cf5ad432745937f - ) - - // body - nBlocks := length / 16 - for i := 0; i < nBlocks; i++ { - block := (*[2]uint64)(unsafe.Pointer(&data[i*16])) - - k1 = block[0] - k2 = block[1] - - k1 *= c1 - k1 = (k1 << 31) | (k1 >> 33) // ROTL64(k1, 31) - k1 *= c2 - h1 ^= k1 - - h1 = (h1 << 27) | (h1 >> 37) // ROTL64(h1, 27) - h1 += h2 - h1 = h1*5 + 0x52dce729 - - k2 *= c2 - k2 = (k2 << 33) | (k2 >> 31) // ROTL64(k2, 33) - k2 *= c1 - h2 ^= k2 - - h2 = (h2 << 31) | (h2 >> 33) // ROTL64(h2, 31) - h2 += h1 - h2 = h2*5 + 0x38495ab5 - } - - // tail - tail := data[nBlocks*16:] - k1 = 0 - k2 = 0 - switch length & 15 { - case 15: - k2 ^= uint64(tail[14]) << 48 - fallthrough - case 14: - k2 ^= uint64(tail[13]) << 40 - fallthrough - case 13: - k2 ^= uint64(tail[12]) << 32 - fallthrough - case 12: - k2 ^= uint64(tail[11]) << 24 - fallthrough - case 11: - k2 ^= uint64(tail[10]) << 16 - fallthrough - case 10: - k2 ^= uint64(tail[9]) << 8 - fallthrough - case 9: - k2 ^= uint64(tail[8]) - - k2 *= c2 - k2 = (k2 << 33) | (k2 >> 31) // ROTL64(k2, 33) - k2 *= c1 - h2 ^= k2 - - fallthrough - case 8: - k1 ^= uint64(tail[7]) << 56 - fallthrough - case 7: - k1 ^= uint64(tail[6]) << 48 - fallthrough - case 6: - k1 ^= uint64(tail[5]) << 40 - fallthrough - case 5: - k1 ^= uint64(tail[4]) << 32 - fallthrough - case 4: - k1 ^= uint64(tail[3]) << 24 - fallthrough - case 3: - k1 ^= uint64(tail[2]) << 16 - fallthrough - case 2: - k1 ^= uint64(tail[1]) << 8 - fallthrough - case 1: - k1 ^= uint64(tail[0]) - - k1 *= c1 - k1 = (k1 << 31) | (k1 >> 33) // ROTL64(k1, 31) - k1 *= c2 - h1 ^= k1 - } - - h1 ^= uint64(length) - h2 ^= uint64(length) - - h1 += h2 - h2 += h1 - - // finalizer - const ( - fmix1 = 0xff51afd7ed558ccd - fmix2 = 0xc4ceb9fe1a85ec53 - ) - - // fmix64(h1) - h1 ^= h1 >> 33 - h1 *= fmix1 - h1 ^= h1 >> 33 - h1 *= fmix2 - h1 ^= h1 >> 33 - - // fmix64(h2) - h2 ^= h2 >> 33 - h2 *= fmix1 - h2 ^= h2 >> 33 - h2 *= fmix2 - h2 ^= h2 >> 33 - - h1 += h2 - // the following is extraneous since h2 is discarded - // h2 += h1 - - return h1 -} - -func (p murmur3Partitioner) ParseString(str string) token { - val, _ := strconv.ParseInt(str, 10, 64) - return murmur3Token(val) -} - -func (m murmur3Token) String() string { - return strconv.FormatInt(int64(m), 10) -} - -func (m murmur3Token) Less(token token) bool { - return m < token.(murmur3Token) -} - -// order preserving partitioner and token -type orderedPartitioner struct{} -type orderedToken []byte - -func (p orderedPartitioner) Name() string { - return "OrderedPartitioner" -} - -func (p orderedPartitioner) Hash(partitionKey []byte) token { - // the partition key is the token - return orderedToken(partitionKey) -} - -func (p orderedPartitioner) ParseString(str string) token { - return orderedToken([]byte(str)) -} - -func (o orderedToken) String() string { - return string([]byte(o)) -} - -func (o orderedToken) Less(token token) bool { - return -1 == bytes.Compare(o, token.(orderedToken)) -} - -// random partitioner and token -type randomPartitioner struct{} -type randomToken big.Int - -func (r randomPartitioner) Name() string { - return "RandomPartitioner" -} - -func (p randomPartitioner) Hash(partitionKey []byte) token { - hash := md5.New() - sum := hash.Sum(partitionKey) - - val := new(big.Int) - val = val.SetBytes(sum) - val = val.Abs(val) - - return (*randomToken)(val) -} - -func (p randomPartitioner) ParseString(str string) token { - val := new(big.Int) - val.SetString(str, 10) - return (*randomToken)(val) -} - -func (r *randomToken) String() string { - return (*big.Int)(r).String() -} - -func (r *randomToken) Less(token token) bool { - return -1 == (*big.Int)(r).Cmp((*big.Int)(token.(*randomToken))) -} - -// a data structure for organizing the relationship between tokens and hosts -type tokenRing struct { - partitioner partitioner - tokens []token - hosts []*HostInfo -} - -func newTokenRing(partitioner string, hosts []HostInfo) (*tokenRing, error) { - tokenRing := &tokenRing{ - tokens: []token{}, - hosts: []*HostInfo{}, - } - - if strings.HasSuffix(partitioner, "Murmur3Partitioner") { - tokenRing.partitioner = murmur3Partitioner{} - } else if strings.HasSuffix(partitioner, "OrderedPartitioner") { - tokenRing.partitioner = orderedPartitioner{} - } else if strings.HasSuffix(partitioner, "RandomPartitioner") { - tokenRing.partitioner = randomPartitioner{} - } else { - return nil, fmt.Errorf("Unsupported partitioner '%s'", partitioner) - } - - for i := range hosts { - host := &hosts[i] - for _, strToken := range host.Tokens { - token := tokenRing.partitioner.ParseString(strToken) - tokenRing.tokens = append(tokenRing.tokens, token) - tokenRing.hosts = append(tokenRing.hosts, host) - } - } - - sort.Sort(tokenRing) - - return tokenRing, nil -} - -func (t *tokenRing) Len() int { - return len(t.tokens) -} - -func (t *tokenRing) Less(i, j int) bool { - return t.tokens[i].Less(t.tokens[j]) -} - -func (t *tokenRing) Swap(i, j int) { - t.tokens[i], t.hosts[i], t.tokens[j], t.hosts[j] = - t.tokens[j], t.hosts[j], t.tokens[i], t.hosts[i] -} - -func (t *tokenRing) String() string { - - buf := &bytes.Buffer{} - buf.WriteString("TokenRing(") - if t.partitioner != nil { - buf.WriteString(t.partitioner.Name()) - } - buf.WriteString("){") - sep := "" - for i := range t.tokens { - buf.WriteString(sep) - sep = "," - buf.WriteString("\n\t[") - buf.WriteString(strconv.Itoa(i)) - buf.WriteString("]") - buf.WriteString(t.tokens[i].String()) - buf.WriteString(":") - buf.WriteString(t.hosts[i].Peer) - } - buf.WriteString("\n}") - return string(buf.Bytes()) -} - -func (t *tokenRing) GetHostForPartitionKey(partitionKey []byte) *HostInfo { - if t == nil { - return nil - } - - token := t.partitioner.Hash(partitionKey) - return t.GetHostForToken(token) -} - -func (t *tokenRing) GetHostForToken(token token) *HostInfo { - if t == nil { - return nil - } - - // find the primary replica - ringIndex := sort.Search( - len(t.tokens), - func(i int) bool { - return !t.tokens[i].Less(token) - }, - ) - if ringIndex == len(t.tokens) { - // wrap around to the first in the ring - ringIndex = 0 - } - host := t.hosts[ringIndex] - return host -} diff --git a/vendor/github.com/gocql/gocql/token_test.go b/vendor/github.com/gocql/gocql/token_test.go deleted file mode 100644 index c17585ed4..000000000 --- a/vendor/github.com/gocql/gocql/token_test.go +++ /dev/null @@ -1,474 +0,0 @@ -// Copyright (c) 2015 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "bytes" - "math/big" - "sort" - "strconv" - "testing" -) - -// Test the implementation of murmur3 -func TestMurmur3H1(t *testing.T) { - // these examples are based on adding a index number to a sample string in - // a loop. The expected values were generated by the java datastax murmur3 - // implementation. The number of examples here of increasing lengths ensure - // test coverage of all tail-length branches in the murmur3 algorithm - seriesExpected := [...]uint64{ - 0x0000000000000000, // "" - 0x2ac9debed546a380, // "0" - 0x649e4eaa7fc1708e, // "01" - 0xce68f60d7c353bdb, // "012" - 0x0f95757ce7f38254, // "0123" - 0x0f04e459497f3fc1, // "01234" - 0x88c0a92586be0a27, // "012345" - 0x13eb9fb82606f7a6, // "0123456" - 0x8236039b7387354d, // "01234567" - 0x4c1e87519fe738ba, // "012345678" - 0x3f9652ac3effeb24, // "0123456789" - 0x3f33760ded9006c6, // "01234567890" - 0xaed70a6631854cb1, // "012345678901" - 0x8a299a8f8e0e2da7, // "0123456789012" - 0x624b675c779249a6, // "01234567890123" - 0xa4b203bb1d90b9a3, // "012345678901234" - 0xa3293ad698ecb99a, // "0123456789012345" - 0xbc740023dbd50048, // "01234567890123456" - 0x3fe5ab9837d25cdd, // "012345678901234567" - 0x2d0338c1ca87d132, // "0123456789012345678" - } - sample := "" - for i, expected := range seriesExpected { - assertMurmur3H1(t, []byte(sample), expected) - - sample = sample + strconv.Itoa(i%10) - } - - // Here are some test examples from other driver implementations - assertMurmur3H1(t, []byte("hello"), 0xcbd8a7b341bd9b02) - assertMurmur3H1(t, []byte("hello, world"), 0x342fac623a5ebc8e) - assertMurmur3H1(t, []byte("19 Jan 2038 at 3:14:07 AM"), 0xb89e5988b737affc) - assertMurmur3H1(t, []byte("The quick brown fox jumps over the lazy dog."), 0xcd99481f9ee902c9) -} - -// helper function for testing the murmur3 implementation -func assertMurmur3H1(t *testing.T, data []byte, expected uint64) { - actual := murmur3H1(data) - if actual != expected { - t.Errorf("Expected h1 = %x for data = %x, but was %x", expected, data, actual) - } -} - -// Benchmark of the performance of the murmur3 implementation -func BenchmarkMurmur3H1(b *testing.B) { - var h1 uint64 - var data [1024]byte - for i := 0; i < 1024; i++ { - data[i] = byte(i) - } - for i := 0; i < b.N; i++ { - b.ResetTimer() - h1 = murmur3H1(data[:]) - _ = murmur3Token(int64(h1)) - } -} - -// Tests of the murmur3Patitioner -func TestMurmur3Partitioner(t *testing.T) { - token := murmur3Partitioner{}.ParseString("-1053604476080545076") - - if "-1053604476080545076" != token.String() { - t.Errorf("Expected '-1053604476080545076' but was '%s'", token) - } - - // at least verify that the partitioner - // doesn't return nil - pk, _ := marshalInt(nil, 1) - token = murmur3Partitioner{}.Hash(pk) - if token == nil { - t.Fatal("token was nil") - } -} - -// Tests of the murmur3Token -func TestMurmur3Token(t *testing.T) { - if murmur3Token(42).Less(murmur3Token(42)) { - t.Errorf("Expected Less to return false, but was true") - } - if !murmur3Token(-42).Less(murmur3Token(42)) { - t.Errorf("Expected Less to return true, but was false") - } - if murmur3Token(42).Less(murmur3Token(-42)) { - t.Errorf("Expected Less to return false, but was true") - } -} - -// Tests of the orderedPartitioner -func TestOrderedPartitioner(t *testing.T) { - // at least verify that the partitioner - // doesn't return nil - p := orderedPartitioner{} - pk, _ := marshalInt(nil, 1) - token := p.Hash(pk) - if token == nil { - t.Fatal("token was nil") - } - - str := token.String() - parsedToken := p.ParseString(str) - - if !bytes.Equal([]byte(token.(orderedToken)), []byte(parsedToken.(orderedToken))) { - t.Errorf("Failed to convert to and from a string %s expected %x but was %x", - str, - []byte(token.(orderedToken)), - []byte(parsedToken.(orderedToken)), - ) - } -} - -// Tests of the orderedToken -func TestOrderedToken(t *testing.T) { - if orderedToken([]byte{0, 0, 4, 2}).Less(orderedToken([]byte{0, 0, 4, 2})) { - t.Errorf("Expected Less to return false, but was true") - } - if !orderedToken([]byte{0, 0, 3}).Less(orderedToken([]byte{0, 0, 4, 2})) { - t.Errorf("Expected Less to return true, but was false") - } - if orderedToken([]byte{0, 0, 4, 2}).Less(orderedToken([]byte{0, 0, 3})) { - t.Errorf("Expected Less to return false, but was true") - } -} - -// Tests of the randomPartitioner -func TestRandomPartitioner(t *testing.T) { - // at least verify that the partitioner - // doesn't return nil - p := randomPartitioner{} - pk, _ := marshalInt(nil, 1) - token := p.Hash(pk) - if token == nil { - t.Fatal("token was nil") - } - - str := token.String() - parsedToken := p.ParseString(str) - - if (*big.Int)(token.(*randomToken)).Cmp((*big.Int)(parsedToken.(*randomToken))) != 0 { - t.Errorf("Failed to convert to and from a string %s expected %v but was %v", - str, - token, - parsedToken, - ) - } -} - -// Tests of the randomToken -func TestRandomToken(t *testing.T) { - if ((*randomToken)(big.NewInt(42))).Less((*randomToken)(big.NewInt(42))) { - t.Errorf("Expected Less to return false, but was true") - } - if !((*randomToken)(big.NewInt(41))).Less((*randomToken)(big.NewInt(42))) { - t.Errorf("Expected Less to return true, but was false") - } - if ((*randomToken)(big.NewInt(42))).Less((*randomToken)(big.NewInt(41))) { - t.Errorf("Expected Less to return false, but was true") - } -} - -type intToken int - -func (i intToken) String() string { - return strconv.Itoa(int(i)) -} - -func (i intToken) Less(token token) bool { - return i < token.(intToken) -} - -// Test of the token ring implementation based on example at the start of this -// page of documentation: -// http://www.datastax.com/docs/0.8/cluster_architecture/partitioning -func TestIntTokenRing(t *testing.T) { - host0 := &HostInfo{} - host25 := &HostInfo{} - host50 := &HostInfo{} - host75 := &HostInfo{} - ring := &tokenRing{ - partitioner: nil, - // these tokens and hosts are out of order to test sorting - tokens: []token{ - intToken(0), - intToken(50), - intToken(75), - intToken(25), - }, - hosts: []*HostInfo{ - host0, - host50, - host75, - host25, - }, - } - - sort.Sort(ring) - - if ring.GetHostForToken(intToken(0)) != host0 { - t.Error("Expected host 0 for token 0") - } - if ring.GetHostForToken(intToken(1)) != host25 { - t.Error("Expected host 25 for token 1") - } - if ring.GetHostForToken(intToken(24)) != host25 { - t.Error("Expected host 25 for token 24") - } - if ring.GetHostForToken(intToken(25)) != host25 { - t.Error("Expected host 25 for token 25") - } - if ring.GetHostForToken(intToken(26)) != host50 { - t.Error("Expected host 50 for token 26") - } - if ring.GetHostForToken(intToken(49)) != host50 { - t.Error("Expected host 50 for token 49") - } - if ring.GetHostForToken(intToken(50)) != host50 { - t.Error("Expected host 50 for token 50") - } - if ring.GetHostForToken(intToken(51)) != host75 { - t.Error("Expected host 75 for token 51") - } - if ring.GetHostForToken(intToken(74)) != host75 { - t.Error("Expected host 75 for token 74") - } - if ring.GetHostForToken(intToken(75)) != host75 { - t.Error("Expected host 75 for token 75") - } - if ring.GetHostForToken(intToken(76)) != host0 { - t.Error("Expected host 0 for token 76") - } - if ring.GetHostForToken(intToken(99)) != host0 { - t.Error("Expected host 0 for token 99") - } - if ring.GetHostForToken(intToken(100)) != host0 { - t.Error("Expected host 0 for token 100") - } -} - -// Test for the behavior of a nil pointer to tokenRing -func TestNilTokenRing(t *testing.T) { - var ring *tokenRing = nil - - if ring.GetHostForToken(nil) != nil { - t.Error("Expected nil for nil token ring") - } - if ring.GetHostForPartitionKey(nil) != nil { - t.Error("Expected nil for nil token ring") - } -} - -// Test of the recognition of the partitioner class -func TestUnknownTokenRing(t *testing.T) { - _, err := newTokenRing("UnknownPartitioner", nil) - if err == nil { - t.Error("Expected error for unknown partitioner value, but was nil") - } -} - -// Test of the tokenRing with the Murmur3Partitioner -func TestMurmur3TokenRing(t *testing.T) { - // Note, strings are parsed directly to int64, they are not murmur3 hashed - var hosts []HostInfo = []HostInfo{ - HostInfo{ - Peer: "0", - Tokens: []string{"0"}, - }, - HostInfo{ - Peer: "1", - Tokens: []string{"25"}, - }, - HostInfo{ - Peer: "2", - Tokens: []string{"50"}, - }, - HostInfo{ - Peer: "3", - Tokens: []string{"75"}, - }, - } - ring, err := newTokenRing("Murmur3Partitioner", hosts) - if err != nil { - t.Fatalf("Failed to create token ring due to error: %v", err) - } - - p := murmur3Partitioner{} - - var actual *HostInfo - actual = ring.GetHostForToken(p.ParseString("0")) - if actual.Peer != "0" { - t.Errorf("Expected peer 0 for token \"0\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("25")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"25\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("50")) - if actual.Peer != "2" { - t.Errorf("Expected peer 2 for token \"50\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("75")) - if actual.Peer != "3" { - t.Errorf("Expected peer 3 for token \"01\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("12")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"12\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("24324545443332")) - if actual.Peer != "0" { - t.Errorf("Expected peer 0 for token \"24324545443332\", but was %s", actual.Peer) - } -} - -// Test of the tokenRing with the OrderedPartitioner -func TestOrderedTokenRing(t *testing.T) { - // Tokens here more or less are similar layout to the int tokens above due - // to each numeric character translating to a consistently offset byte. - var hosts []HostInfo = []HostInfo{ - HostInfo{ - Peer: "0", - Tokens: []string{ - "00", - }, - }, - HostInfo{ - Peer: "1", - Tokens: []string{ - "25", - }, - }, - HostInfo{ - Peer: "2", - Tokens: []string{ - "50", - }, - }, - HostInfo{ - Peer: "3", - Tokens: []string{ - "75", - }, - }, - } - ring, err := newTokenRing("OrderedPartitioner", hosts) - if err != nil { - t.Fatalf("Failed to create token ring due to error: %v", err) - } - - p := orderedPartitioner{} - - var actual *HostInfo - actual = ring.GetHostForToken(p.ParseString("0")) - if actual.Peer != "0" { - t.Errorf("Expected peer 0 for token \"0\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("25")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"25\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("50")) - if actual.Peer != "2" { - t.Errorf("Expected peer 2 for token \"50\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("75")) - if actual.Peer != "3" { - t.Errorf("Expected peer 3 for token \"01\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("12")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"12\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("24324545443332")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"24324545443332\", but was %s", actual.Peer) - } -} - -// Test of the tokenRing with the RandomPartitioner -func TestRandomTokenRing(t *testing.T) { - // String tokens are parsed into big.Int in base 10 - var hosts []HostInfo = []HostInfo{ - HostInfo{ - Peer: "0", - Tokens: []string{ - "00", - }, - }, - HostInfo{ - Peer: "1", - Tokens: []string{ - "25", - }, - }, - HostInfo{ - Peer: "2", - Tokens: []string{ - "50", - }, - }, - HostInfo{ - Peer: "3", - Tokens: []string{ - "75", - }, - }, - } - ring, err := newTokenRing("RandomPartitioner", hosts) - if err != nil { - t.Fatalf("Failed to create token ring due to error: %v", err) - } - - p := randomPartitioner{} - - var actual *HostInfo - actual = ring.GetHostForToken(p.ParseString("0")) - if actual.Peer != "0" { - t.Errorf("Expected peer 0 for token \"0\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("25")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"25\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("50")) - if actual.Peer != "2" { - t.Errorf("Expected peer 2 for token \"50\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("75")) - if actual.Peer != "3" { - t.Errorf("Expected peer 3 for token \"01\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("12")) - if actual.Peer != "1" { - t.Errorf("Expected peer 1 for token \"12\", but was %s", actual.Peer) - } - - actual = ring.GetHostForToken(p.ParseString("24324545443332")) - if actual.Peer != "0" { - t.Errorf("Expected peer 0 for token \"24324545443332\", but was %s", actual.Peer) - } -} diff --git a/vendor/github.com/gocql/gocql/topology.go b/vendor/github.com/gocql/gocql/topology.go deleted file mode 100644 index 08ac094a1..000000000 --- a/vendor/github.com/gocql/gocql/topology.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gocql - -import ( - "sync" - "sync/atomic" -) - -type Node interface { - Pick(qry *Query) *Conn - Close() -} - -type RoundRobin struct { - pool []Node - pos uint32 - mu sync.RWMutex -} - -func NewRoundRobin() *RoundRobin { - return &RoundRobin{} -} - -func (r *RoundRobin) AddNode(node Node) { - r.mu.Lock() - r.pool = append(r.pool, node) - r.mu.Unlock() -} - -func (r *RoundRobin) RemoveNode(node Node) { - r.mu.Lock() - n := len(r.pool) - for i := 0; i < n; i++ { - if r.pool[i] == node { - r.pool[i], r.pool[n-1] = r.pool[n-1], r.pool[i] - r.pool = r.pool[:n-1] - break - } - } - r.mu.Unlock() -} - -func (r *RoundRobin) Size() int { - r.mu.RLock() - n := len(r.pool) - r.mu.RUnlock() - return n -} - -func (r *RoundRobin) Pick(qry *Query) *Conn { - pos := atomic.AddUint32(&r.pos, 1) - var node Node - r.mu.RLock() - if len(r.pool) > 0 { - node = r.pool[pos%uint32(len(r.pool))] - } - r.mu.RUnlock() - if node == nil { - return nil - } - return node.Pick(qry) -} - -func (r *RoundRobin) Close() { - r.mu.Lock() - for i := 0; i < len(r.pool); i++ { - r.pool[i].Close() - } - r.pool = nil - r.mu.Unlock() -} diff --git a/vendor/github.com/gocql/gocql/topology_test.go b/vendor/github.com/gocql/gocql/topology_test.go deleted file mode 100644 index 8384824ab..000000000 --- a/vendor/github.com/gocql/gocql/topology_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// +build all unit - -package gocql - -import ( - "testing" -) - -// fakeNode is used as a simple structure to test the RoundRobin API -type fakeNode struct { - conn *Conn - closed bool -} - -// Pick is needed to satisfy the Node interface -func (n *fakeNode) Pick(qry *Query) *Conn { - if n.conn == nil { - n.conn = &Conn{} - } - return n.conn -} - -//Close is needed to satisfy the Node interface -func (n *fakeNode) Close() { - n.closed = true -} - -//TestRoundRobinAPI tests the exported methods of the RoundRobin struct -//to make sure the API behaves accordingly. -func TestRoundRobinAPI(t *testing.T) { - node := &fakeNode{} - rr := NewRoundRobin() - rr.AddNode(node) - - if rr.Size() != 1 { - t.Fatalf("expected size to be 1, got %v", rr.Size()) - } - - if c := rr.Pick(nil); c != node.conn { - t.Fatalf("expected conn %v, got %v", node.conn, c) - } - - rr.Close() - if rr.pool != nil { - t.Fatalf("expected rr.pool to be nil, got %v", rr.pool) - } - - if !node.closed { - t.Fatal("expected node.closed to be true, got false") - } -} diff --git a/vendor/github.com/gocql/gocql/tuple_test.go b/vendor/github.com/gocql/gocql/tuple_test.go deleted file mode 100644 index bf94191f6..000000000 --- a/vendor/github.com/gocql/gocql/tuple_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// +build all integration - -package gocql - -import "testing" - -func TestTupleSimple(t *testing.T) { - if *flagProto < protoVersion3 { - t.Skip("tuple types are only available of proto>=3") - } - - session := createSession(t) - defer session.Close() - - err := createTable(session, `CREATE TABLE tuple_test( - id int, - coord frozen>, - - primary key(id))`) - if err != nil { - t.Fatal(err) - } - - err = session.Query("INSERT INTO tuple_test(id, coord) VALUES(?, (?, ?))", 1, 100, -100).Exec() - if err != nil { - t.Fatal(err) - } - - var ( - id int - coord struct { - x int - y int - } - ) - - iter := session.Query("SELECT id, coord FROM tuple_test WHERE id=?", 1) - if err := iter.Scan(&id, &coord.x, &coord.y); err != nil { - t.Fatal(err) - } - - if id != 1 { - t.Errorf("expected to get id=1 got: %v", id) - } - if coord.x != 100 { - t.Errorf("expected to get coord.x=100 got: %v", coord.x) - } - if coord.y != -100 { - t.Errorf("expected to get coord.y=-100 got: %v", coord.y) - } -} diff --git a/vendor/github.com/gocql/gocql/udt_test.go b/vendor/github.com/gocql/gocql/udt_test.go deleted file mode 100644 index 1e0a9fcd1..000000000 --- a/vendor/github.com/gocql/gocql/udt_test.go +++ /dev/null @@ -1,254 +0,0 @@ -// +build all integration - -package gocql - -import ( - "fmt" - "strings" - "testing" -) - -type position struct { - Lat int `cql:"lat"` - Lon int `cql:"lon"` - Padding string `json:"padding"` -} - -// NOTE: due to current implementation details it is not currently possible to use -// a pointer receiver type for the UDTMarshaler interface to handle UDT's -func (p position) MarshalUDT(name string, info TypeInfo) ([]byte, error) { - switch name { - case "lat": - return Marshal(info, p.Lat) - case "lon": - return Marshal(info, p.Lon) - case "padding": - return Marshal(info, p.Padding) - default: - return nil, fmt.Errorf("unknown column for position: %q", name) - } -} - -func (p *position) UnmarshalUDT(name string, info TypeInfo, data []byte) error { - switch name { - case "lat": - return Unmarshal(info, data, &p.Lat) - case "lon": - return Unmarshal(info, data, &p.Lon) - case "padding": - return Unmarshal(info, data, &p.Padding) - default: - return fmt.Errorf("unknown column for position: %q", name) - } -} - -func TestUDT_Marshaler(t *testing.T) { - if *flagProto < protoVersion3 { - t.Skip("UDT are only available on protocol >= 3") - } - - session := createSession(t) - defer session.Close() - - err := createTable(session, `CREATE TYPE position( - lat int, - lon int, - padding text);`) - if err != nil { - t.Fatal(err) - } - - err = createTable(session, `CREATE TABLE houses( - id int, - name text, - loc frozen, - - primary key(id) - );`) - if err != nil { - t.Fatal(err) - } - - const ( - expLat = -1 - expLon = 2 - ) - pad := strings.Repeat("X", 1000) - - err = session.Query("INSERT INTO houses(id, name, loc) VALUES(?, ?, ?)", 1, "test", &position{expLat, expLon, pad}).Exec() - if err != nil { - t.Fatal(err) - } - - pos := &position{} - - err = session.Query("SELECT loc FROM houses WHERE id = ?", 1).Scan(pos) - if err != nil { - t.Fatal(err) - } - - if pos.Lat != expLat { - t.Errorf("expeceted lat to be be %d got %d", expLat, pos.Lat) - } - if pos.Lon != expLon { - t.Errorf("expeceted lon to be be %d got %d", expLon, pos.Lon) - } - if pos.Padding != pad { - t.Errorf("expected to get padding %q got %q\n", pad, pos.Padding) - } -} - -func TestUDT_Reflect(t *testing.T) { - if *flagProto < protoVersion3 { - t.Skip("UDT are only available on protocol >= 3") - } - - // Uses reflection instead of implementing the marshaling type - session := createSession(t) - defer session.Close() - - err := createTable(session, `CREATE TYPE horse( - name text, - owner text);`) - if err != nil { - t.Fatal(err) - } - - err = createTable(session, `CREATE TABLE horse_race( - position int, - horse frozen, - - primary key(position) - );`) - if err != nil { - t.Fatal(err) - } - - type horse struct { - Name string `cql:"name"` - Owner string `cql:"owner"` - } - - insertedHorse := &horse{ - Name: "pony", - Owner: "jim", - } - - err = session.Query("INSERT INTO horse_race(position, horse) VALUES(?, ?)", 1, insertedHorse).Exec() - if err != nil { - t.Fatal(err) - } - - retrievedHorse := &horse{} - err = session.Query("SELECT horse FROM horse_race WHERE position = ?", 1).Scan(retrievedHorse) - if err != nil { - t.Fatal(err) - } - - if *retrievedHorse != *insertedHorse { - t.Fatal("exepcted to get %+v got %+v", insertedHorse, retrievedHorse) - } -} - -func TestUDT_Proto2error(t *testing.T) { - if *flagProto < protoVersion3 { - t.Skip("UDT are only available on protocol >= 3") - } - - cluster := createCluster() - cluster.ProtoVersion = 2 - cluster.Keyspace = "gocql_test" - - // Uses reflection instead of implementing the marshaling type - session, err := cluster.CreateSession() - if err != nil { - t.Fatal(err) - } - defer session.Close() - - err = createTable(session, `CREATE TYPE fish( - name text, - owner text);`) - if err != nil { - t.Fatal(err) - } - - err = createTable(session, `CREATE TABLE fish_race( - position int, - fish frozen, - - primary key(position) - );`) - if err != nil { - t.Fatal(err) - } - - type fish struct { - Name string `cql:"name"` - Owner string `cql:"owner"` - } - - insertedFish := &fish{ - Name: "pony", - Owner: "jim", - } - - err = session.Query("INSERT INTO fish_race(position, fish) VALUES(?, ?)", 1, insertedFish).Exec() - if err != ErrorUDTUnavailable { - t.Fatalf("expected to get %v got %v", ErrorUDTUnavailable, err) - } -} - -func TestUDT_NullObject(t *testing.T) { - if *flagProto < protoVersion3 { - t.Skip("UDT are only available on protocol >= 3") - } - - session := createSession(t) - defer session.Close() - - err := createTable(session, `CREATE TYPE udt_null_type( - name text, - owner text);`) - if err != nil { - t.Fatal(err) - } - - err = createTable(session, `CREATE TABLE udt_null_table( - id uuid, - udt_col frozen, - - primary key(id) - );`) - if err != nil { - t.Fatal(err) - } - - type col struct { - Name string `cql:"name"` - Owner string `cql:"owner"` - } - - id := TimeUUID() - err = session.Query("INSERT INTO udt_null_table(id) VALUES(?)", id).Exec() - if err != nil { - t.Fatal(err) - } - - readCol := &col{ - Name: "temp", - Owner: "temp", - } - - err = session.Query("SELECT udt_col FROM udt_null_table WHERE id = ?", id).Scan(readCol) - if err != nil { - t.Fatal(err) - } - - if readCol.Name != "" { - t.Errorf("expected empty string to be returned for null udt: got %q", readCol.Name) - } - if readCol.Owner != "" { - t.Errorf("expected empty string to be returned for null udt: got %q", readCol.Owner) - } -} diff --git a/vendor/github.com/gocql/gocql/uuid.go b/vendor/github.com/gocql/gocql/uuid.go deleted file mode 100644 index 0017d99a9..000000000 --- a/vendor/github.com/gocql/gocql/uuid.go +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// The uuid package can be used to generate and parse universally unique -// identifiers, a standardized format in the form of a 128 bit number. -// -// http://tools.ietf.org/html/rfc4122 -package gocql - -import ( - "crypto/rand" - "errors" - "fmt" - "io" - "net" - "strings" - "sync/atomic" - "time" -) - -type UUID [16]byte - -var hardwareAddr []byte -var clockSeq uint32 - -const ( - VariantNCSCompat = 0 - VariantIETF = 2 - VariantMicrosoft = 6 - VariantFuture = 7 -) - -func init() { - if interfaces, err := net.Interfaces(); err == nil { - for _, i := range interfaces { - if i.Flags&net.FlagLoopback == 0 && len(i.HardwareAddr) > 0 { - hardwareAddr = i.HardwareAddr - break - } - } - } - if hardwareAddr == nil { - // If we failed to obtain the MAC address of the current computer, - // we will use a randomly generated 6 byte sequence instead and set - // the multicast bit as recommended in RFC 4122. - hardwareAddr = make([]byte, 6) - _, err := io.ReadFull(rand.Reader, hardwareAddr) - if err != nil { - panic(err) - } - hardwareAddr[0] = hardwareAddr[0] | 0x01 - } - - // initialize the clock sequence with a random number - var clockSeqRand [2]byte - io.ReadFull(rand.Reader, clockSeqRand[:]) - clockSeq = uint32(clockSeqRand[1])<<8 | uint32(clockSeqRand[0]) -} - -// ParseUUID parses a 32 digit hexadecimal number (that might contain hypens) -// representing an UUID. -func ParseUUID(input string) (UUID, error) { - var u UUID - j := 0 - for _, r := range input { - switch { - case r == '-' && j&1 == 0: - continue - case r >= '0' && r <= '9' && j < 32: - u[j/2] |= byte(r-'0') << uint(4-j&1*4) - case r >= 'a' && r <= 'f' && j < 32: - u[j/2] |= byte(r-'a'+10) << uint(4-j&1*4) - case r >= 'A' && r <= 'F' && j < 32: - u[j/2] |= byte(r-'A'+10) << uint(4-j&1*4) - default: - return UUID{}, fmt.Errorf("invalid UUID %q", input) - } - j += 1 - } - if j != 32 { - return UUID{}, fmt.Errorf("invalid UUID %q", input) - } - return u, nil -} - -// UUIDFromBytes converts a raw byte slice to an UUID. -func UUIDFromBytes(input []byte) (UUID, error) { - var u UUID - if len(input) != 16 { - return u, errors.New("UUIDs must be exactly 16 bytes long") - } - - copy(u[:], input) - return u, nil -} - -// RandomUUID generates a totally random UUID (version 4) as described in -// RFC 4122. -func RandomUUID() (UUID, error) { - var u UUID - _, err := io.ReadFull(rand.Reader, u[:]) - if err != nil { - return u, err - } - u[6] &= 0x0F // clear version - u[6] |= 0x40 // set version to 4 (random uuid) - u[8] &= 0x3F // clear variant - u[8] |= 0x80 // set to IETF variant - return u, nil -} - -var timeBase = time.Date(1582, time.October, 15, 0, 0, 0, 0, time.UTC).Unix() - -// TimeUUID generates a new time based UUID (version 1) using the current -// time as the timestamp. -func TimeUUID() UUID { - return UUIDFromTime(time.Now()) -} - -// UUIDFromTime generates a new time based UUID (version 1) as described in -// RFC 4122. This UUID contains the MAC address of the node that generated -// the UUID, the given timestamp and a sequence number. -func UUIDFromTime(aTime time.Time) UUID { - var u UUID - - utcTime := aTime.In(time.UTC) - t := uint64(utcTime.Unix()-timeBase)*10000000 + uint64(utcTime.Nanosecond()/100) - u[0], u[1], u[2], u[3] = byte(t>>24), byte(t>>16), byte(t>>8), byte(t) - u[4], u[5] = byte(t>>40), byte(t>>32) - u[6], u[7] = byte(t>>56)&0x0F, byte(t>>48) - - clock := atomic.AddUint32(&clockSeq, 1) - u[8] = byte(clock >> 8) - u[9] = byte(clock) - - copy(u[10:], hardwareAddr) - - u[6] |= 0x10 // set version to 1 (time based uuid) - u[8] &= 0x3F // clear variant - u[8] |= 0x80 // set to IETF variant - - return u -} - -// String returns the UUID in it's canonical form, a 32 digit hexadecimal -// number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. -func (u UUID) String() string { - var offsets = [...]int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34} - const hexString = "0123456789abcdef" - r := make([]byte, 36) - for i, b := range u { - r[offsets[i]] = hexString[b>>4] - r[offsets[i]+1] = hexString[b&0xF] - } - r[8] = '-' - r[13] = '-' - r[18] = '-' - r[23] = '-' - return string(r) - -} - -// Bytes returns the raw byte slice for this UUID. A UUID is always 128 bits -// (16 bytes) long. -func (u UUID) Bytes() []byte { - return u[:] -} - -// Variant returns the variant of this UUID. This package will only generate -// UUIDs in the IETF variant. -func (u UUID) Variant() int { - x := u[8] - if x&0x80 == 0 { - return VariantNCSCompat - } - if x&0x40 == 0 { - return VariantIETF - } - if x&0x20 == 0 { - return VariantMicrosoft - } - return VariantFuture -} - -// Version extracts the version of this UUID variant. The RFC 4122 describes -// five kinds of UUIDs. -func (u UUID) Version() int { - return int(u[6] & 0xF0 >> 4) -} - -// Node extracts the MAC address of the node who generated this UUID. It will -// return nil if the UUID is not a time based UUID (version 1). -func (u UUID) Node() []byte { - if u.Version() != 1 { - return nil - } - return u[10:] -} - -// Timestamp extracts the timestamp information from a time based UUID -// (version 1). -func (u UUID) Timestamp() int64 { - if u.Version() != 1 { - return 0 - } - return int64(uint64(u[0])<<24|uint64(u[1])<<16| - uint64(u[2])<<8|uint64(u[3])) + - int64(uint64(u[4])<<40|uint64(u[5])<<32) + - int64(uint64(u[6]&0x0F)<<56|uint64(u[7])<<48) -} - -// Time is like Timestamp, except that it returns a time.Time. -func (u UUID) Time() time.Time { - if u.Version() != 1 { - return time.Time{} - } - t := u.Timestamp() - sec := t / 1e7 - nsec := (t % 1e7) * 100 - return time.Unix(sec+timeBase, nsec).UTC() -} - -// Marshaling for JSON -func (u UUID) MarshalJSON() ([]byte, error) { - return []byte(`"` + u.String() + `"`), nil -} - -// Unmarshaling for JSON -func (u *UUID) UnmarshalJSON(data []byte) error { - str := strings.Trim(string(data), `"`) - if len(str) > 36 { - return fmt.Errorf("invalid JSON UUID %s", str) - } - - parsed, err := ParseUUID(str) - if err == nil { - copy(u[:], parsed[:]) - } - - return err -} diff --git a/vendor/github.com/gocql/gocql/uuid_test.go b/vendor/github.com/gocql/gocql/uuid_test.go deleted file mode 100644 index ec6a69ff9..000000000 --- a/vendor/github.com/gocql/gocql/uuid_test.go +++ /dev/null @@ -1,197 +0,0 @@ -// +build all unit - -package gocql - -import ( - "bytes" - "strings" - "testing" - "time" -) - -func TestUUIDNil(t *testing.T) { - var uuid UUID - want, got := "00000000-0000-0000-0000-000000000000", uuid.String() - if want != got { - t.Fatalf("TestNil: expected %q got %q", want, got) - } -} - -var testsUUID = []struct { - input string - variant int - version int -}{ - {"b4f00409-cef8-4822-802c-deb20704c365", VariantIETF, 4}, - {"B4F00409-CEF8-4822-802C-DEB20704C365", VariantIETF, 4}, //Use capital letters - {"f81d4fae-7dec-11d0-a765-00a0c91e6bf6", VariantIETF, 1}, - {"00000000-7dec-11d0-a765-00a0c91e6bf6", VariantIETF, 1}, - {"3051a8d7-aea7-1801-e0bf-bc539dd60cf3", VariantFuture, 1}, - {"3051a8d7-aea7-2801-e0bf-bc539dd60cf3", VariantFuture, 2}, - {"3051a8d7-aea7-3801-e0bf-bc539dd60cf3", VariantFuture, 3}, - {"3051a8d7-aea7-4801-e0bf-bc539dd60cf3", VariantFuture, 4}, - {"3051a8d7-aea7-3801-e0bf-bc539dd60cf3", VariantFuture, 5}, - {"d0e817e1-e4b1-1801-3fe6-b4b60ccecf9d", VariantNCSCompat, 0}, - {"d0e817e1-e4b1-1801-bfe6-b4b60ccecf9d", VariantIETF, 1}, - {"d0e817e1-e4b1-1801-dfe6-b4b60ccecf9d", VariantMicrosoft, 0}, - {"d0e817e1-e4b1-1801-ffe6-b4b60ccecf9d", VariantFuture, 0}, -} - -func TestPredefinedUUID(t *testing.T) { - for i := range testsUUID { - uuid, err := ParseUUID(testsUUID[i].input) - if err != nil { - t.Errorf("ParseUUID #%d: %v", i, err) - continue - } - - if str := uuid.String(); str != strings.ToLower(testsUUID[i].input) { - t.Errorf("String #%d: expected %q got %q", i, testsUUID[i].input, str) - continue - } - - if variant := uuid.Variant(); variant != testsUUID[i].variant { - t.Errorf("Variant #%d: expected %d got %d", i, testsUUID[i].variant, variant) - } - - if testsUUID[i].variant == VariantIETF { - if version := uuid.Version(); version != testsUUID[i].version { - t.Errorf("Version #%d: expected %d got %d", i, testsUUID[i].version, version) - } - } - - json, err := uuid.MarshalJSON() - if err != nil { - t.Errorf("MarshalJSON #%d: %v", i, err) - } - expectedJson := `"` + strings.ToLower(testsUUID[i].input) + `"` - if string(json) != expectedJson { - t.Errorf("MarshalJSON #%d: expected %v got %v", i, expectedJson, string(json)) - } - - var unmarshaled UUID - err = unmarshaled.UnmarshalJSON(json) - if err != nil { - t.Errorf("UnmarshalJSON #%d: %v", i, err) - } - if unmarshaled != uuid { - t.Errorf("UnmarshalJSON #%d: expected %v got %v", i, uuid, unmarshaled) - } - } -} - -func TestInvalidUUIDCharacter(t *testing.T) { - _, err := ParseUUID("z4f00409-cef8-4822-802c-deb20704c365") - if err == nil || !strings.Contains(err.Error(), "invalid UUID") { - t.Fatalf("expected invalid UUID error, got '%v' ", err) - } -} - -func TestInvalidUUIDLength(t *testing.T) { - _, err := ParseUUID("4f00") - if err == nil || !strings.Contains(err.Error(), "invalid UUID") { - t.Fatalf("expected invalid UUID error, got '%v' ", err) - } - - _, err = UUIDFromBytes(TimeUUID().Bytes()[:15]) - if err == nil || err.Error() != "UUIDs must be exactly 16 bytes long" { - t.Fatalf("expected error '%v', got '%v'", "UUIDs must be exactly 16 bytes long", err) - } -} - -func TestRandomUUID(t *testing.T) { - for i := 0; i < 20; i++ { - uuid, err := RandomUUID() - if err != nil { - t.Errorf("RandomUUID: %v", err) - } - if variant := uuid.Variant(); variant != VariantIETF { - t.Errorf("wrong variant. expected %d got %d", VariantIETF, variant) - } - if version := uuid.Version(); version != 4 { - t.Errorf("wrong version. expected %d got %d", 4, version) - } - } -} - -func TestRandomUUIDInvalidAPICalls(t *testing.T) { - uuid, err := RandomUUID() - if err != nil { - t.Fatalf("unexpected error %v", err) - } - - if node := uuid.Node(); node != nil { - t.Fatalf("expected nil, got %v", node) - } - - if stamp := uuid.Timestamp(); stamp != 0 { - t.Fatalf("expceted 0, got %v", stamp) - } - zeroT := time.Time{} - if to := uuid.Time(); to != zeroT { - t.Fatalf("expected %v, got %v", zeroT, to) - } -} - -func TestUUIDFromTime(t *testing.T) { - date := time.Date(1982, 5, 5, 12, 34, 56, 400, time.UTC) - uuid := UUIDFromTime(date) - - if uuid.Time() != date { - t.Errorf("embedded time incorrect. Expected %v got %v", date, uuid.Time()) - } -} - -func TestParseUUID(t *testing.T) { - uuid, _ := ParseUUID("486f3a88-775b-11e3-ae07-d231feb1dc81") - if uuid.Time() != time.Date(2014, 1, 7, 5, 19, 29, 222516000, time.UTC) { - t.Errorf("Expected date of 1/7/2014 at 5:19:29.222516, got %v", uuid.Time()) - } -} - -func TestTimeUUID(t *testing.T) { - var node []byte - timestamp := int64(0) - for i := 0; i < 20; i++ { - uuid := TimeUUID() - - if variant := uuid.Variant(); variant != VariantIETF { - t.Errorf("wrong variant. expected %d got %d", VariantIETF, variant) - } - if version := uuid.Version(); version != 1 { - t.Errorf("wrong version. expected %d got %d", 1, version) - } - - if n := uuid.Node(); !bytes.Equal(n, node) && i > 0 { - t.Errorf("wrong node. expected %x, got %x", node, n) - } else if i == 0 { - node = n - } - - ts := uuid.Timestamp() - if ts < timestamp { - t.Errorf("timestamps must grow") - } - timestamp = ts - } -} - -func TestUnmarshalJSON(t *testing.T) { - var withHyphens, withoutHypens, tooLong UUID - - withHyphens.UnmarshalJSON([]byte(`"486f3a88-775b-11e3-ae07-d231feb1dc81"`)) - if withHyphens.Time().Truncate(time.Second) != time.Date(2014, 1, 7, 5, 19, 29, 0, time.UTC) { - t.Errorf("Expected date of 1/7/2014 at 5:19:29, got %v", withHyphens.Time()) - } - - withoutHypens.UnmarshalJSON([]byte(`"486f3a88775b11e3ae07d231feb1dc81"`)) - if withoutHypens.Time().Truncate(time.Second) != time.Date(2014, 1, 7, 5, 19, 29, 0, time.UTC) { - t.Errorf("Expected date of 1/7/2014 at 5:19:29, got %v", withoutHypens.Time()) - } - - err := tooLong.UnmarshalJSON([]byte(`"486f3a88-775b-11e3-ae07-d231feb1dc81486f3a88"`)) - if err == nil { - t.Errorf("no error for invalid JSON UUID") - } - -} diff --git a/vendor/github.com/gocql/gocql/website/css/bootstrap-theme.css b/vendor/github.com/gocql/gocql/website/css/bootstrap-theme.css deleted file mode 100644 index ad1173569..000000000 --- a/vendor/github.com/gocql/gocql/website/css/bootstrap-theme.css +++ /dev/null @@ -1,384 +0,0 @@ -.btn-default, -.btn-primary, -.btn-success, -.btn-info, -.btn-warning, -.btn-danger { - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2); - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075); -} - -.btn-default:active, -.btn-primary:active, -.btn-success:active, -.btn-info:active, -.btn-warning:active, -.btn-danger:active, -.btn-default.active, -.btn-primary.active, -.btn-success.active, -.btn-info.active, -.btn-warning.active, -.btn-danger.active { - -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} - -.btn:active, -.btn.active { - background-image: none; -} - -.btn-default { - text-shadow: 0 1px 0 #fff; - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#ffffff), to(#e6e6e6)); - background-image: -webkit-linear-gradient(top, #ffffff, 0%, #e6e6e6, 100%); - background-image: -moz-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); - background-image: linear-gradient(to bottom, #ffffff 0%, #e6e6e6 100%); - background-repeat: repeat-x; - border-color: #e0e0e0; - border-color: #ccc; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0); -} - -.btn-default:active, -.btn-default.active { - background-color: #e6e6e6; - border-color: #e0e0e0; -} - -.btn-primary { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3071a9)); - background-image: -webkit-linear-gradient(top, #428bca, 0%, #3071a9, 100%); - background-image: -moz-linear-gradient(top, #428bca 0%, #3071a9 100%); - background-image: linear-gradient(to bottom, #428bca 0%, #3071a9 100%); - background-repeat: repeat-x; - border-color: #2d6ca2; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0); -} - -.btn-primary:active, -.btn-primary.active { - background-color: #3071a9; - border-color: #2d6ca2; -} - -.btn-success { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5cb85c), to(#449d44)); - background-image: -webkit-linear-gradient(top, #5cb85c, 0%, #449d44, 100%); - background-image: -moz-linear-gradient(top, #5cb85c 0%, #449d44 100%); - background-image: linear-gradient(to bottom, #5cb85c 0%, #449d44 100%); - background-repeat: repeat-x; - border-color: #419641; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0); -} - -.btn-success:active, -.btn-success.active { - background-color: #449d44; - border-color: #419641; -} - -.btn-warning { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f0ad4e), to(#ec971f)); - background-image: -webkit-linear-gradient(top, #f0ad4e, 0%, #ec971f, 100%); - background-image: -moz-linear-gradient(top, #f0ad4e 0%, #ec971f 100%); - background-image: linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%); - background-repeat: repeat-x; - border-color: #eb9316; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0); -} - -.btn-warning:active, -.btn-warning.active { - background-color: #ec971f; - border-color: #eb9316; -} - -.btn-danger { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9534f), to(#c9302c)); - background-image: -webkit-linear-gradient(top, #d9534f, 0%, #c9302c, 100%); - background-image: -moz-linear-gradient(top, #d9534f 0%, #c9302c 100%); - background-image: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%); - background-repeat: repeat-x; - border-color: #c12e2a; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0); -} - -.btn-danger:active, -.btn-danger.active { - background-color: #c9302c; - border-color: #c12e2a; -} - -.btn-info { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5bc0de), to(#31b0d5)); - background-image: -webkit-linear-gradient(top, #5bc0de, 0%, #31b0d5, 100%); - background-image: -moz-linear-gradient(top, #5bc0de 0%, #31b0d5 100%); - background-image: linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%); - background-repeat: repeat-x; - border-color: #2aabd2; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0); -} - -.btn-info:active, -.btn-info.active { - background-color: #31b0d5; - border-color: #2aabd2; -} - -.thumbnail, -.img-thumbnail { - -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); -} - -.dropdown-menu > li > a:hover, -.dropdown-menu > li > a:focus, -.dropdown-menu > .active > a, -.dropdown-menu > .active > a:hover, -.dropdown-menu > .active > a:focus { - background-color: #357ebd; - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#357ebd)); - background-image: -webkit-linear-gradient(top, #428bca, 0%, #357ebd, 100%); - background-image: -moz-linear-gradient(top, #428bca 0%, #357ebd 100%); - background-image: linear-gradient(to bottom, #428bca 0%, #357ebd 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0); -} - -.navbar { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#ffffff), to(#f8f8f8)); - background-image: -webkit-linear-gradient(top, #ffffff, 0%, #f8f8f8, 100%); - background-image: -moz-linear-gradient(top, #ffffff 0%, #f8f8f8 100%); - background-image: linear-gradient(to bottom, #ffffff 0%, #f8f8f8 100%); - background-repeat: repeat-x; - border-radius: 4px; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0); - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 5px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 5px rgba(0, 0, 0, 0.075); -} - -.navbar .navbar-nav > .active > a { - background-color: #f8f8f8; -} - -.navbar-brand, -.navbar-nav > li > a { - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25); -} - -.navbar-inverse { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#3c3c3c), to(#222222)); - background-image: -webkit-linear-gradient(top, #3c3c3c, 0%, #222222, 100%); - background-image: -moz-linear-gradient(top, #3c3c3c 0%, #222222 100%); - background-image: linear-gradient(to bottom, #3c3c3c 0%, #222222 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0); -} - -.navbar-inverse .navbar-nav > .active > a { - background-color: #222222; -} - -.navbar-inverse .navbar-brand, -.navbar-inverse .navbar-nav > li > a { - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} - -.navbar-static-top, -.navbar-fixed-top, -.navbar-fixed-bottom { - border-radius: 0; -} - -.alert { - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2); - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05); -} - -.alert-success { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#dff0d8), to(#c8e5bc)); - background-image: -webkit-linear-gradient(top, #dff0d8, 0%, #c8e5bc, 100%); - background-image: -moz-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%); - background-image: linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%); - background-repeat: repeat-x; - border-color: #b2dba1; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0); -} - -.alert-info { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9edf7), to(#b9def0)); - background-image: -webkit-linear-gradient(top, #d9edf7, 0%, #b9def0, 100%); - background-image: -moz-linear-gradient(top, #d9edf7 0%, #b9def0 100%); - background-image: linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%); - background-repeat: repeat-x; - border-color: #9acfea; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0); -} - -.alert-warning { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#fcf8e3), to(#f8efc0)); - background-image: -webkit-linear-gradient(top, #fcf8e3, 0%, #f8efc0, 100%); - background-image: -moz-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%); - background-image: linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%); - background-repeat: repeat-x; - border-color: #f5e79e; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0); -} - -.alert-danger { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f2dede), to(#e7c3c3)); - background-image: -webkit-linear-gradient(top, #f2dede, 0%, #e7c3c3, 100%); - background-image: -moz-linear-gradient(top, #f2dede 0%, #e7c3c3 100%); - background-image: linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%); - background-repeat: repeat-x; - border-color: #dca7a7; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0); -} - -.progress { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#ebebeb), to(#f5f5f5)); - background-image: -webkit-linear-gradient(top, #ebebeb, 0%, #f5f5f5, 100%); - background-image: -moz-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%); - background-image: linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0); -} - -.progress-bar { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3071a9)); - background-image: -webkit-linear-gradient(top, #428bca, 0%, #3071a9, 100%); - background-image: -moz-linear-gradient(top, #428bca 0%, #3071a9 100%); - background-image: linear-gradient(to bottom, #428bca 0%, #3071a9 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0); -} - -.progress-bar-success { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5cb85c), to(#449d44)); - background-image: -webkit-linear-gradient(top, #5cb85c, 0%, #449d44, 100%); - background-image: -moz-linear-gradient(top, #5cb85c 0%, #449d44 100%); - background-image: linear-gradient(to bottom, #5cb85c 0%, #449d44 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0); -} - -.progress-bar-info { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5bc0de), to(#31b0d5)); - background-image: -webkit-linear-gradient(top, #5bc0de, 0%, #31b0d5, 100%); - background-image: -moz-linear-gradient(top, #5bc0de 0%, #31b0d5 100%); - background-image: linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0); -} - -.progress-bar-warning { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f0ad4e), to(#ec971f)); - background-image: -webkit-linear-gradient(top, #f0ad4e, 0%, #ec971f, 100%); - background-image: -moz-linear-gradient(top, #f0ad4e 0%, #ec971f 100%); - background-image: linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0); -} - -.progress-bar-danger { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9534f), to(#c9302c)); - background-image: -webkit-linear-gradient(top, #d9534f, 0%, #c9302c, 100%); - background-image: -moz-linear-gradient(top, #d9534f 0%, #c9302c 100%); - background-image: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0); -} - -.list-group { - border-radius: 4px; - -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); -} - -.list-group-item.active, -.list-group-item.active:hover, -.list-group-item.active:focus { - text-shadow: 0 -1px 0 #3071a9; - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3278b3)); - background-image: -webkit-linear-gradient(top, #428bca, 0%, #3278b3, 100%); - background-image: -moz-linear-gradient(top, #428bca 0%, #3278b3 100%); - background-image: linear-gradient(to bottom, #428bca 0%, #3278b3 100%); - background-repeat: repeat-x; - border-color: #3278b3; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3278b3', GradientType=0); -} - -.panel { - -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); -} - -.panel-default > .panel-heading { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f5f5f5), to(#e8e8e8)); - background-image: -webkit-linear-gradient(top, #f5f5f5, 0%, #e8e8e8, 100%); - background-image: -moz-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%); - background-image: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0); -} - -.panel-primary > .panel-heading { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#357ebd)); - background-image: -webkit-linear-gradient(top, #428bca, 0%, #357ebd, 100%); - background-image: -moz-linear-gradient(top, #428bca 0%, #357ebd 100%); - background-image: linear-gradient(to bottom, #428bca 0%, #357ebd 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0); -} - -.panel-success > .panel-heading { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#dff0d8), to(#d0e9c6)); - background-image: -webkit-linear-gradient(top, #dff0d8, 0%, #d0e9c6, 100%); - background-image: -moz-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%); - background-image: linear-gradient(to bottom, #dff0d8 0%, #d0e9c6 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0); -} - -.panel-info > .panel-heading { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9edf7), to(#c4e3f3)); - background-image: -webkit-linear-gradient(top, #d9edf7, 0%, #c4e3f3, 100%); - background-image: -moz-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%); - background-image: linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0); -} - -.panel-warning > .panel-heading { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#fcf8e3), to(#faf2cc)); - background-image: -webkit-linear-gradient(top, #fcf8e3, 0%, #faf2cc, 100%); - background-image: -moz-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%); - background-image: linear-gradient(to bottom, #fcf8e3 0%, #faf2cc 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0); -} - -.panel-danger > .panel-heading { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f2dede), to(#ebcccc)); - background-image: -webkit-linear-gradient(top, #f2dede, 0%, #ebcccc, 100%); - background-image: -moz-linear-gradient(top, #f2dede 0%, #ebcccc 100%); - background-image: linear-gradient(to bottom, #f2dede 0%, #ebcccc 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0); -} - -.well { - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#e8e8e8), to(#f5f5f5)); - background-image: -webkit-linear-gradient(top, #e8e8e8, 0%, #f5f5f5, 100%); - background-image: -moz-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%); - background-image: linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%); - background-repeat: repeat-x; - border-color: #dcdcdc; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0); - -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(255, 255, 255, 0.1); - box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(255, 255, 255, 0.1); -} \ No newline at end of file diff --git a/vendor/github.com/gocql/gocql/website/css/bootstrap-theme.min.css b/vendor/github.com/gocql/gocql/website/css/bootstrap-theme.min.css deleted file mode 100644 index cad36b4e6..000000000 --- a/vendor/github.com/gocql/gocql/website/css/bootstrap-theme.min.css +++ /dev/null @@ -1 +0,0 @@ -.btn-default,.btn-primary,.btn-success,.btn-info,.btn-warning,.btn-danger{text-shadow:0 -1px 0 rgba(0,0,0,0.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.15),0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.15),0 1px 1px rgba(0,0,0,0.075)}.btn-default:active,.btn-primary:active,.btn-success:active,.btn-info:active,.btn-warning:active,.btn-danger:active,.btn-default.active,.btn-primary.active,.btn-success.active,.btn-info.active,.btn-warning.active,.btn-danger.active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn:active,.btn.active{background-image:none}.btn-default{text-shadow:0 1px 0 #fff;background-image:-webkit-gradient(linear,left 0,left 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,0%,#e6e6e6,100%);background-image:-moz-linear-gradient(top,#fff 0,#e6e6e6 100%);background-image:linear-gradient(to bottom,#fff 0,#e6e6e6 100%);background-repeat:repeat-x;border-color:#e0e0e0;border-color:#ccc;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0)}.btn-default:active,.btn-default.active{background-color:#e6e6e6;border-color:#e0e0e0}.btn-primary{background-image:-webkit-gradient(linear,left 0,left 100%,from(#428bca),to(#3071a9));background-image:-webkit-linear-gradient(top,#428bca,0%,#3071a9,100%);background-image:-moz-linear-gradient(top,#428bca 0,#3071a9 100%);background-image:linear-gradient(to bottom,#428bca 0,#3071a9 100%);background-repeat:repeat-x;border-color:#2d6ca2;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca',endColorstr='#ff3071a9',GradientType=0)}.btn-primary:active,.btn-primary.active{background-color:#3071a9;border-color:#2d6ca2}.btn-success{background-image:-webkit-gradient(linear,left 0,left 100%,from(#5cb85c),to(#449d44));background-image:-webkit-linear-gradient(top,#5cb85c,0%,#449d44,100%);background-image:-moz-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:linear-gradient(to bottom,#5cb85c 0,#449d44 100%);background-repeat:repeat-x;border-color:#419641;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c',endColorstr='#ff449d44',GradientType=0)}.btn-success:active,.btn-success.active{background-color:#449d44;border-color:#419641}.btn-warning{background-image:-webkit-gradient(linear,left 0,left 100%,from(#f0ad4e),to(#ec971f));background-image:-webkit-linear-gradient(top,#f0ad4e,0%,#ec971f,100%);background-image:-moz-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:linear-gradient(to bottom,#f0ad4e 0,#ec971f 100%);background-repeat:repeat-x;border-color:#eb9316;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e',endColorstr='#ffec971f',GradientType=0)}.btn-warning:active,.btn-warning.active{background-color:#ec971f;border-color:#eb9316}.btn-danger{background-image:-webkit-gradient(linear,left 0,left 100%,from(#d9534f),to(#c9302c));background-image:-webkit-linear-gradient(top,#d9534f,0%,#c9302c,100%);background-image:-moz-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:linear-gradient(to bottom,#d9534f 0,#c9302c 100%);background-repeat:repeat-x;border-color:#c12e2a;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f',endColorstr='#ffc9302c',GradientType=0)}.btn-danger:active,.btn-danger.active{background-color:#c9302c;border-color:#c12e2a}.btn-info{background-image:-webkit-gradient(linear,left 0,left 100%,from(#5bc0de),to(#31b0d5));background-image:-webkit-linear-gradient(top,#5bc0de,0%,#31b0d5,100%);background-image:-moz-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:linear-gradient(to bottom,#5bc0de 0,#31b0d5 100%);background-repeat:repeat-x;border-color:#2aabd2;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff31b0d5',GradientType=0)}.btn-info:active,.btn-info.active{background-color:#31b0d5;border-color:#2aabd2}.thumbnail,.img-thumbnail{-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.075);box-shadow:0 1px 2px rgba(0,0,0,0.075)}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus,.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{background-color:#357ebd;background-image:-webkit-gradient(linear,left 0,left 100%,from(#428bca),to(#357ebd));background-image:-webkit-linear-gradient(top,#428bca,0%,#357ebd,100%);background-image:-moz-linear-gradient(top,#428bca 0,#357ebd 100%);background-image:linear-gradient(to bottom,#428bca 0,#357ebd 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca',endColorstr='#ff357ebd',GradientType=0)}.navbar{background-image:-webkit-gradient(linear,left 0,left 100%,from(#fff),to(#f8f8f8));background-image:-webkit-linear-gradient(top,#fff,0%,#f8f8f8,100%);background-image:-moz-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:linear-gradient(to bottom,#fff 0,#f8f8f8 100%);background-repeat:repeat-x;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#fff8f8f8',GradientType=0);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.15),0 1px 5px rgba(0,0,0,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.15),0 1px 5px rgba(0,0,0,0.075)}.navbar .navbar-nav>.active>a{background-color:#f8f8f8}.navbar-brand,.navbar-nav>li>a{text-shadow:0 1px 0 rgba(255,255,255,0.25)}.navbar-inverse{background-image:-webkit-gradient(linear,left 0,left 100%,from(#3c3c3c),to(#222));background-image:-webkit-linear-gradient(top,#3c3c3c,0%,#222,100%);background-image:-moz-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:linear-gradient(to bottom,#3c3c3c 0,#222 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c',endColorstr='#ff222222',GradientType=0)}.navbar-inverse .navbar-nav>.active>a{background-color:#222}.navbar-inverse .navbar-brand,.navbar-inverse .navbar-nav>li>a{text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar-static-top,.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}.alert{text-shadow:0 1px 0 rgba(255,255,255,0.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.25),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.25),0 1px 2px rgba(0,0,0,0.05)}.alert-success{background-image:-webkit-gradient(linear,left 0,left 100%,from(#dff0d8),to(#c8e5bc));background-image:-webkit-linear-gradient(top,#dff0d8,0%,#c8e5bc,100%);background-image:-moz-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:linear-gradient(to bottom,#dff0d8 0,#c8e5bc 100%);background-repeat:repeat-x;border-color:#b2dba1;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8',endColorstr='#ffc8e5bc',GradientType=0)}.alert-info{background-image:-webkit-gradient(linear,left 0,left 100%,from(#d9edf7),to(#b9def0));background-image:-webkit-linear-gradient(top,#d9edf7,0%,#b9def0,100%);background-image:-moz-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:linear-gradient(to bottom,#d9edf7 0,#b9def0 100%);background-repeat:repeat-x;border-color:#9acfea;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7',endColorstr='#ffb9def0',GradientType=0)}.alert-warning{background-image:-webkit-gradient(linear,left 0,left 100%,from(#fcf8e3),to(#f8efc0));background-image:-webkit-linear-gradient(top,#fcf8e3,0%,#f8efc0,100%);background-image:-moz-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:linear-gradient(to bottom,#fcf8e3 0,#f8efc0 100%);background-repeat:repeat-x;border-color:#f5e79e;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3',endColorstr='#fff8efc0',GradientType=0)}.alert-danger{background-image:-webkit-gradient(linear,left 0,left 100%,from(#f2dede),to(#e7c3c3));background-image:-webkit-linear-gradient(top,#f2dede,0%,#e7c3c3,100%);background-image:-moz-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:linear-gradient(to bottom,#f2dede 0,#e7c3c3 100%);background-repeat:repeat-x;border-color:#dca7a7;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede',endColorstr='#ffe7c3c3',GradientType=0)}.progress{background-image:-webkit-gradient(linear,left 0,left 100%,from(#ebebeb),to(#f5f5f5));background-image:-webkit-linear-gradient(top,#ebebeb,0%,#f5f5f5,100%);background-image:-moz-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:linear-gradient(to bottom,#ebebeb 0,#f5f5f5 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb',endColorstr='#fff5f5f5',GradientType=0)}.progress-bar{background-image:-webkit-gradient(linear,left 0,left 100%,from(#428bca),to(#3071a9));background-image:-webkit-linear-gradient(top,#428bca,0%,#3071a9,100%);background-image:-moz-linear-gradient(top,#428bca 0,#3071a9 100%);background-image:linear-gradient(to bottom,#428bca 0,#3071a9 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca',endColorstr='#ff3071a9',GradientType=0)}.progress-bar-success{background-image:-webkit-gradient(linear,left 0,left 100%,from(#5cb85c),to(#449d44));background-image:-webkit-linear-gradient(top,#5cb85c,0%,#449d44,100%);background-image:-moz-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:linear-gradient(to bottom,#5cb85c 0,#449d44 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c',endColorstr='#ff449d44',GradientType=0)}.progress-bar-info{background-image:-webkit-gradient(linear,left 0,left 100%,from(#5bc0de),to(#31b0d5));background-image:-webkit-linear-gradient(top,#5bc0de,0%,#31b0d5,100%);background-image:-moz-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:linear-gradient(to bottom,#5bc0de 0,#31b0d5 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff31b0d5',GradientType=0)}.progress-bar-warning{background-image:-webkit-gradient(linear,left 0,left 100%,from(#f0ad4e),to(#ec971f));background-image:-webkit-linear-gradient(top,#f0ad4e,0%,#ec971f,100%);background-image:-moz-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:linear-gradient(to bottom,#f0ad4e 0,#ec971f 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e',endColorstr='#ffec971f',GradientType=0)}.progress-bar-danger{background-image:-webkit-gradient(linear,left 0,left 100%,from(#d9534f),to(#c9302c));background-image:-webkit-linear-gradient(top,#d9534f,0%,#c9302c,100%);background-image:-moz-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:linear-gradient(to bottom,#d9534f 0,#c9302c 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f',endColorstr='#ffc9302c',GradientType=0)}.list-group{border-radius:4px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.075);box-shadow:0 1px 2px rgba(0,0,0,0.075)}.list-group-item.active,.list-group-item.active:hover,.list-group-item.active:focus{text-shadow:0 -1px 0 #3071a9;background-image:-webkit-gradient(linear,left 0,left 100%,from(#428bca),to(#3278b3));background-image:-webkit-linear-gradient(top,#428bca,0%,#3278b3,100%);background-image:-moz-linear-gradient(top,#428bca 0,#3278b3 100%);background-image:linear-gradient(to bottom,#428bca 0,#3278b3 100%);background-repeat:repeat-x;border-color:#3278b3;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca',endColorstr='#ff3278b3',GradientType=0)}.panel{-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.panel-default>.panel-heading{background-image:-webkit-gradient(linear,left 0,left 100%,from(#f5f5f5),to(#e8e8e8));background-image:-webkit-linear-gradient(top,#f5f5f5,0%,#e8e8e8,100%);background-image:-moz-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='#ffe8e8e8',GradientType=0)}.panel-primary>.panel-heading{background-image:-webkit-gradient(linear,left 0,left 100%,from(#428bca),to(#357ebd));background-image:-webkit-linear-gradient(top,#428bca,0%,#357ebd,100%);background-image:-moz-linear-gradient(top,#428bca 0,#357ebd 100%);background-image:linear-gradient(to bottom,#428bca 0,#357ebd 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca',endColorstr='#ff357ebd',GradientType=0)}.panel-success>.panel-heading{background-image:-webkit-gradient(linear,left 0,left 100%,from(#dff0d8),to(#d0e9c6));background-image:-webkit-linear-gradient(top,#dff0d8,0%,#d0e9c6,100%);background-image:-moz-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:linear-gradient(to bottom,#dff0d8 0,#d0e9c6 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8',endColorstr='#ffd0e9c6',GradientType=0)}.panel-info>.panel-heading{background-image:-webkit-gradient(linear,left 0,left 100%,from(#d9edf7),to(#c4e3f3));background-image:-webkit-linear-gradient(top,#d9edf7,0%,#c4e3f3,100%);background-image:-moz-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:linear-gradient(to bottom,#d9edf7 0,#c4e3f3 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7',endColorstr='#ffc4e3f3',GradientType=0)}.panel-warning>.panel-heading{background-image:-webkit-gradient(linear,left 0,left 100%,from(#fcf8e3),to(#faf2cc));background-image:-webkit-linear-gradient(top,#fcf8e3,0%,#faf2cc,100%);background-image:-moz-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:linear-gradient(to bottom,#fcf8e3 0,#faf2cc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3',endColorstr='#fffaf2cc',GradientType=0)}.panel-danger>.panel-heading{background-image:-webkit-gradient(linear,left 0,left 100%,from(#f2dede),to(#ebcccc));background-image:-webkit-linear-gradient(top,#f2dede,0%,#ebcccc,100%);background-image:-moz-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:linear-gradient(to bottom,#f2dede 0,#ebcccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede',endColorstr='#ffebcccc',GradientType=0)}.well{background-image:-webkit-gradient(linear,left 0,left 100%,from(#e8e8e8),to(#f5f5f5));background-image:-webkit-linear-gradient(top,#e8e8e8,0%,#f5f5f5,100%);background-image:-moz-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:linear-gradient(to bottom,#e8e8e8 0,#f5f5f5 100%);background-repeat:repeat-x;border-color:#dcdcdc;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8',endColorstr='#fff5f5f5',GradientType=0);-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,0.05),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 3px rgba(0,0,0,0.05),0 1px 0 rgba(255,255,255,0.1)} \ No newline at end of file diff --git a/vendor/github.com/gocql/gocql/website/css/bootstrap.css b/vendor/github.com/gocql/gocql/website/css/bootstrap.css deleted file mode 100644 index bbda4eed4..000000000 --- a/vendor/github.com/gocql/gocql/website/css/bootstrap.css +++ /dev/null @@ -1,6805 +0,0 @@ -/*! - * Bootstrap v3.0.0 - * - * Copyright 2013 Twitter, Inc - * Licensed under the Apache License v2.0 - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Designed and built with all the love in the world by @mdo and @fat. - */ - -/*! normalize.css v2.1.0 | MIT License | git.io/normalize */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -nav, -section, -summary { - display: block; -} - -audio, -canvas, -video { - display: inline-block; -} - -audio:not([controls]) { - display: none; - height: 0; -} - -[hidden] { - display: none; -} - -html { - font-family: sans-serif; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} - -body { - margin: 0; -} - -a:focus { - outline: thin dotted; -} - -a:active, -a:hover { - outline: 0; -} - -h1 { - margin: 0.67em 0; - font-size: 2em; -} - -abbr[title] { - border-bottom: 1px dotted; -} - -b, -strong { - font-weight: bold; -} - -dfn { - font-style: italic; -} - -hr { - height: 0; - -moz-box-sizing: content-box; - box-sizing: content-box; -} - -mark { - color: #000; - background: #ff0; -} - -code, -kbd, -pre, -samp { - font-family: monospace, serif; - font-size: 1em; -} - -pre { - white-space: pre-wrap; -} - -q { - quotes: "\201C" "\201D" "\2018" "\2019"; -} - -small { - font-size: 80%; -} - -sub, -sup { - position: relative; - font-size: 75%; - line-height: 0; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -img { - border: 0; -} - -svg:not(:root) { - overflow: hidden; -} - -figure { - margin: 0; -} - -fieldset { - padding: 0.35em 0.625em 0.75em; - margin: 0 2px; - border: 1px solid #c0c0c0; -} - -legend { - padding: 0; - border: 0; -} - -button, -input, -select, -textarea { - margin: 0; - font-family: inherit; - font-size: 100%; -} - -button, -input { - line-height: normal; -} - -button, -select { - text-transform: none; -} - -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { - cursor: pointer; - -webkit-appearance: button; -} - -button[disabled], -html input[disabled] { - cursor: default; -} - -input[type="checkbox"], -input[type="radio"] { - padding: 0; - box-sizing: border-box; -} - -input[type="search"] { - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; - -webkit-appearance: textfield; -} - -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -button::-moz-focus-inner, -input::-moz-focus-inner { - padding: 0; - border: 0; -} - -textarea { - overflow: auto; - vertical-align: top; -} - -table { - border-collapse: collapse; - border-spacing: 0; -} - -@media print { - * { - color: #000 !important; - text-shadow: none !important; - background: transparent !important; - box-shadow: none !important; - } - a, - a:visited { - text-decoration: underline; - } - a[href]:after { - content: " (" attr(href) ")"; - } - abbr[title]:after { - content: " (" attr(title) ")"; - } - .ir a:after, - a[href^="javascript:"]:after, - a[href^="#"]:after { - content: ""; - } - pre, - blockquote { - border: 1px solid #999; - page-break-inside: avoid; - } - thead { - display: table-header-group; - } - tr, - img { - page-break-inside: avoid; - } - img { - max-width: 100% !important; - } - @page { - margin: 2cm .5cm; - } - p, - h2, - h3 { - orphans: 3; - widows: 3; - } - h2, - h3 { - page-break-after: avoid; - } - .navbar { - display: none; - } - .table td, - .table th { - background-color: #fff !important; - } - .btn > .caret, - .dropup > .btn > .caret { - border-top-color: #000 !important; - } - .label { - border: 1px solid #000; - } - .table { - border-collapse: collapse !important; - } - .table-bordered th, - .table-bordered td { - border: 1px solid #ddd !important; - } -} - -*, -*:before, -*:after { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -html { - font-size: 62.5%; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} - -body { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 1.428571429; - color: #333333; - background-color: #ffffff; -} - -input, -button, -select, -textarea { - font-family: inherit; - font-size: inherit; - line-height: inherit; -} - -button, -input, -select[multiple], -textarea { - background-image: none; -} - -a { - color: #428bca; - text-decoration: none; -} - -a:hover, -a:focus { - color: #2a6496; - text-decoration: underline; -} - -a:focus { - outline: thin dotted #333; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} - -img { - vertical-align: middle; -} - -.img-responsive { - display: block; - height: auto; - max-width: 100%; -} - -.img-rounded { - border-radius: 6px; -} - -.img-thumbnail { - display: inline-block; - height: auto; - max-width: 100%; - padding: 4px; - line-height: 1.428571429; - background-color: #ffffff; - border: 1px solid #dddddd; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; -} - -.img-circle { - border-radius: 50%; -} - -hr { - margin-top: 20px; - margin-bottom: 20px; - border: 0; - border-top: 1px solid #eeeeee; -} - -.sr-only { - position: absolute; - width: 1px; - height: 1px; - padding: 0; - margin: -1px; - overflow: hidden; - clip: rect(0 0 0 0); - border: 0; -} - -p { - margin: 0 0 10px; -} - -.lead { - margin-bottom: 20px; - font-size: 16.099999999999998px; - font-weight: 200; - line-height: 1.4; -} - -@media (min-width: 768px) { - .lead { - font-size: 21px; - } -} - -small { - font-size: 85%; -} - -cite { - font-style: normal; -} - -.text-muted { - color: #999999; -} - -.text-primary { - color: #428bca; -} - -.text-warning { - color: #c09853; -} - -.text-danger { - color: #b94a48; -} - -.text-success { - color: #468847; -} - -.text-info { - color: #3a87ad; -} - -.text-left { - text-align: left; -} - -.text-right { - text-align: right; -} - -.text-center { - text-align: center; -} - -h1, -h2, -h3, -h4, -h5, -h6, -.h1, -.h2, -.h3, -.h4, -.h5, -.h6 { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-weight: 500; - line-height: 1.1; -} - -h1 small, -h2 small, -h3 small, -h4 small, -h5 small, -h6 small, -.h1 small, -.h2 small, -.h3 small, -.h4 small, -.h5 small, -.h6 small { - font-weight: normal; - line-height: 1; - color: #999999; -} - -h1, -h2, -h3 { - margin-top: 20px; - margin-bottom: 10px; -} - -h4, -h5, -h6 { - margin-top: 10px; - margin-bottom: 10px; -} - -h1, -.h1 { - font-size: 36px; -} - -h2, -.h2 { - font-size: 30px; -} - -h3, -.h3 { - font-size: 24px; -} - -h4, -.h4 { - font-size: 18px; -} - -h5, -.h5 { - font-size: 14px; -} - -h6, -.h6 { - font-size: 12px; -} - -h1 small, -.h1 small { - font-size: 24px; -} - -h2 small, -.h2 small { - font-size: 18px; -} - -h3 small, -.h3 small, -h4 small, -.h4 small { - font-size: 14px; -} - -.page-header { - padding-bottom: 9px; - margin: 40px 0 20px; - border-bottom: 1px solid #eeeeee; -} - -ul, -ol { - margin-top: 0; - margin-bottom: 10px; -} - -ul ul, -ol ul, -ul ol, -ol ol { - margin-bottom: 0; -} - -.list-unstyled { - padding-left: 0; - list-style: none; -} - -.list-inline { - padding-left: 0; - list-style: none; -} - -.list-inline > li { - display: inline-block; - padding-right: 5px; - padding-left: 5px; -} - -dl { - margin-bottom: 20px; -} - -dt, -dd { - line-height: 1.428571429; -} - -dt { - font-weight: bold; -} - -dd { - margin-left: 0; -} - -@media (min-width: 768px) { - .dl-horizontal dt { - float: left; - width: 160px; - overflow: hidden; - clear: left; - text-align: right; - text-overflow: ellipsis; - white-space: nowrap; - } - .dl-horizontal dd { - margin-left: 180px; - } - .dl-horizontal dd:before, - .dl-horizontal dd:after { - display: table; - content: " "; - } - .dl-horizontal dd:after { - clear: both; - } - .dl-horizontal dd:before, - .dl-horizontal dd:after { - display: table; - content: " "; - } - .dl-horizontal dd:after { - clear: both; - } -} - -abbr[title], -abbr[data-original-title] { - cursor: help; - border-bottom: 1px dotted #999999; -} - -abbr.initialism { - font-size: 90%; - text-transform: uppercase; -} - -blockquote { - padding: 10px 20px; - margin: 0 0 20px; - border-left: 5px solid #eeeeee; -} - -blockquote p { - font-size: 17.5px; - font-weight: 300; - line-height: 1.25; -} - -blockquote p:last-child { - margin-bottom: 0; -} - -blockquote small { - display: block; - line-height: 1.428571429; - color: #999999; -} - -blockquote small:before { - content: '\2014 \00A0'; -} - -blockquote.pull-right { - padding-right: 15px; - padding-left: 0; - border-right: 5px solid #eeeeee; - border-left: 0; -} - -blockquote.pull-right p, -blockquote.pull-right small { - text-align: right; -} - -blockquote.pull-right small:before { - content: ''; -} - -blockquote.pull-right small:after { - content: '\00A0 \2014'; -} - -q:before, -q:after, -blockquote:before, -blockquote:after { - content: ""; -} - -address { - display: block; - margin-bottom: 20px; - font-style: normal; - line-height: 1.428571429; -} - -code, -pre { - font-family: Monaco, Menlo, Consolas, "Courier New", monospace; -} - -code { - padding: 2px 4px; - font-size: 90%; - color: #c7254e; - white-space: nowrap; - background-color: #f9f2f4; - border-radius: 4px; -} - -pre { - display: block; - padding: 9.5px; - margin: 0 0 10px; - font-size: 13px; - line-height: 1.428571429; - color: #333333; - word-break: break-all; - word-wrap: break-word; - background-color: #f5f5f5; - border: 1px solid #cccccc; - border-radius: 4px; -} - -pre.prettyprint { - margin-bottom: 20px; -} - -pre code { - padding: 0; - font-size: inherit; - color: inherit; - white-space: pre-wrap; - background-color: transparent; - border: 0; -} - -.pre-scrollable { - max-height: 340px; - overflow-y: scroll; -} - -.container { - padding-right: 15px; - padding-left: 15px; - margin-right: auto; - margin-left: auto; -} - -.container:before, -.container:after { - display: table; - content: " "; -} - -.container:after { - clear: both; -} - -.container:before, -.container:after { - display: table; - content: " "; -} - -.container:after { - clear: both; -} - -.row { - margin-right: -15px; - margin-left: -15px; -} - -.row:before, -.row:after { - display: table; - content: " "; -} - -.row:after { - clear: both; -} - -.row:before, -.row:after { - display: table; - content: " "; -} - -.row:after { - clear: both; -} - -.col-xs-1, -.col-xs-2, -.col-xs-3, -.col-xs-4, -.col-xs-5, -.col-xs-6, -.col-xs-7, -.col-xs-8, -.col-xs-9, -.col-xs-10, -.col-xs-11, -.col-xs-12, -.col-sm-1, -.col-sm-2, -.col-sm-3, -.col-sm-4, -.col-sm-5, -.col-sm-6, -.col-sm-7, -.col-sm-8, -.col-sm-9, -.col-sm-10, -.col-sm-11, -.col-sm-12, -.col-md-1, -.col-md-2, -.col-md-3, -.col-md-4, -.col-md-5, -.col-md-6, -.col-md-7, -.col-md-8, -.col-md-9, -.col-md-10, -.col-md-11, -.col-md-12, -.col-lg-1, -.col-lg-2, -.col-lg-3, -.col-lg-4, -.col-lg-5, -.col-lg-6, -.col-lg-7, -.col-lg-8, -.col-lg-9, -.col-lg-10, -.col-lg-11, -.col-lg-12 { - position: relative; - min-height: 1px; - padding-right: 15px; - padding-left: 15px; -} - -.col-xs-1, -.col-xs-2, -.col-xs-3, -.col-xs-4, -.col-xs-5, -.col-xs-6, -.col-xs-7, -.col-xs-8, -.col-xs-9, -.col-xs-10, -.col-xs-11 { - float: left; -} - -.col-xs-1 { - width: 8.333333333333332%; -} - -.col-xs-2 { - width: 16.666666666666664%; -} - -.col-xs-3 { - width: 25%; -} - -.col-xs-4 { - width: 33.33333333333333%; -} - -.col-xs-5 { - width: 41.66666666666667%; -} - -.col-xs-6 { - width: 50%; -} - -.col-xs-7 { - width: 58.333333333333336%; -} - -.col-xs-8 { - width: 66.66666666666666%; -} - -.col-xs-9 { - width: 75%; -} - -.col-xs-10 { - width: 83.33333333333334%; -} - -.col-xs-11 { - width: 91.66666666666666%; -} - -.col-xs-12 { - width: 100%; -} - -@media (min-width: 768px) { - .container { - max-width: 750px; - } - .col-sm-1, - .col-sm-2, - .col-sm-3, - .col-sm-4, - .col-sm-5, - .col-sm-6, - .col-sm-7, - .col-sm-8, - .col-sm-9, - .col-sm-10, - .col-sm-11 { - float: left; - } - .col-sm-1 { - width: 8.333333333333332%; - } - .col-sm-2 { - width: 16.666666666666664%; - } - .col-sm-3 { - width: 25%; - } - .col-sm-4 { - width: 33.33333333333333%; - } - .col-sm-5 { - width: 41.66666666666667%; - } - .col-sm-6 { - width: 50%; - } - .col-sm-7 { - width: 58.333333333333336%; - } - .col-sm-8 { - width: 66.66666666666666%; - } - .col-sm-9 { - width: 75%; - } - .col-sm-10 { - width: 83.33333333333334%; - } - .col-sm-11 { - width: 91.66666666666666%; - } - .col-sm-12 { - width: 100%; - } - .col-sm-push-1 { - left: 8.333333333333332%; - } - .col-sm-push-2 { - left: 16.666666666666664%; - } - .col-sm-push-3 { - left: 25%; - } - .col-sm-push-4 { - left: 33.33333333333333%; - } - .col-sm-push-5 { - left: 41.66666666666667%; - } - .col-sm-push-6 { - left: 50%; - } - .col-sm-push-7 { - left: 58.333333333333336%; - } - .col-sm-push-8 { - left: 66.66666666666666%; - } - .col-sm-push-9 { - left: 75%; - } - .col-sm-push-10 { - left: 83.33333333333334%; - } - .col-sm-push-11 { - left: 91.66666666666666%; - } - .col-sm-pull-1 { - right: 8.333333333333332%; - } - .col-sm-pull-2 { - right: 16.666666666666664%; - } - .col-sm-pull-3 { - right: 25%; - } - .col-sm-pull-4 { - right: 33.33333333333333%; - } - .col-sm-pull-5 { - right: 41.66666666666667%; - } - .col-sm-pull-6 { - right: 50%; - } - .col-sm-pull-7 { - right: 58.333333333333336%; - } - .col-sm-pull-8 { - right: 66.66666666666666%; - } - .col-sm-pull-9 { - right: 75%; - } - .col-sm-pull-10 { - right: 83.33333333333334%; - } - .col-sm-pull-11 { - right: 91.66666666666666%; - } - .col-sm-offset-1 { - margin-left: 8.333333333333332%; - } - .col-sm-offset-2 { - margin-left: 16.666666666666664%; - } - .col-sm-offset-3 { - margin-left: 25%; - } - .col-sm-offset-4 { - margin-left: 33.33333333333333%; - } - .col-sm-offset-5 { - margin-left: 41.66666666666667%; - } - .col-sm-offset-6 { - margin-left: 50%; - } - .col-sm-offset-7 { - margin-left: 58.333333333333336%; - } - .col-sm-offset-8 { - margin-left: 66.66666666666666%; - } - .col-sm-offset-9 { - margin-left: 75%; - } - .col-sm-offset-10 { - margin-left: 83.33333333333334%; - } - .col-sm-offset-11 { - margin-left: 91.66666666666666%; - } -} - -@media (min-width: 992px) { - .container { - max-width: 970px; - } - .col-md-1, - .col-md-2, - .col-md-3, - .col-md-4, - .col-md-5, - .col-md-6, - .col-md-7, - .col-md-8, - .col-md-9, - .col-md-10, - .col-md-11 { - float: left; - } - .col-md-1 { - width: 8.333333333333332%; - } - .col-md-2 { - width: 16.666666666666664%; - } - .col-md-3 { - width: 25%; - } - .col-md-4 { - width: 33.33333333333333%; - } - .col-md-5 { - width: 41.66666666666667%; - } - .col-md-6 { - width: 50%; - } - .col-md-7 { - width: 58.333333333333336%; - } - .col-md-8 { - width: 66.66666666666666%; - } - .col-md-9 { - width: 75%; - } - .col-md-10 { - width: 83.33333333333334%; - } - .col-md-11 { - width: 91.66666666666666%; - } - .col-md-12 { - width: 100%; - } - .col-md-push-0 { - left: auto; - } - .col-md-push-1 { - left: 8.333333333333332%; - } - .col-md-push-2 { - left: 16.666666666666664%; - } - .col-md-push-3 { - left: 25%; - } - .col-md-push-4 { - left: 33.33333333333333%; - } - .col-md-push-5 { - left: 41.66666666666667%; - } - .col-md-push-6 { - left: 50%; - } - .col-md-push-7 { - left: 58.333333333333336%; - } - .col-md-push-8 { - left: 66.66666666666666%; - } - .col-md-push-9 { - left: 75%; - } - .col-md-push-10 { - left: 83.33333333333334%; - } - .col-md-push-11 { - left: 91.66666666666666%; - } - .col-md-pull-0 { - right: auto; - } - .col-md-pull-1 { - right: 8.333333333333332%; - } - .col-md-pull-2 { - right: 16.666666666666664%; - } - .col-md-pull-3 { - right: 25%; - } - .col-md-pull-4 { - right: 33.33333333333333%; - } - .col-md-pull-5 { - right: 41.66666666666667%; - } - .col-md-pull-6 { - right: 50%; - } - .col-md-pull-7 { - right: 58.333333333333336%; - } - .col-md-pull-8 { - right: 66.66666666666666%; - } - .col-md-pull-9 { - right: 75%; - } - .col-md-pull-10 { - right: 83.33333333333334%; - } - .col-md-pull-11 { - right: 91.66666666666666%; - } - .col-md-offset-0 { - margin-left: 0; - } - .col-md-offset-1 { - margin-left: 8.333333333333332%; - } - .col-md-offset-2 { - margin-left: 16.666666666666664%; - } - .col-md-offset-3 { - margin-left: 25%; - } - .col-md-offset-4 { - margin-left: 33.33333333333333%; - } - .col-md-offset-5 { - margin-left: 41.66666666666667%; - } - .col-md-offset-6 { - margin-left: 50%; - } - .col-md-offset-7 { - margin-left: 58.333333333333336%; - } - .col-md-offset-8 { - margin-left: 66.66666666666666%; - } - .col-md-offset-9 { - margin-left: 75%; - } - .col-md-offset-10 { - margin-left: 83.33333333333334%; - } - .col-md-offset-11 { - margin-left: 91.66666666666666%; - } -} - -@media (min-width: 1200px) { - .container { - max-width: 1170px; - } - .col-lg-1, - .col-lg-2, - .col-lg-3, - .col-lg-4, - .col-lg-5, - .col-lg-6, - .col-lg-7, - .col-lg-8, - .col-lg-9, - .col-lg-10, - .col-lg-11 { - float: left; - } - .col-lg-1 { - width: 8.333333333333332%; - } - .col-lg-2 { - width: 16.666666666666664%; - } - .col-lg-3 { - width: 25%; - } - .col-lg-4 { - width: 33.33333333333333%; - } - .col-lg-5 { - width: 41.66666666666667%; - } - .col-lg-6 { - width: 50%; - } - .col-lg-7 { - width: 58.333333333333336%; - } - .col-lg-8 { - width: 66.66666666666666%; - } - .col-lg-9 { - width: 75%; - } - .col-lg-10 { - width: 83.33333333333334%; - } - .col-lg-11 { - width: 91.66666666666666%; - } - .col-lg-12 { - width: 100%; - } - .col-lg-push-0 { - left: auto; - } - .col-lg-push-1 { - left: 8.333333333333332%; - } - .col-lg-push-2 { - left: 16.666666666666664%; - } - .col-lg-push-3 { - left: 25%; - } - .col-lg-push-4 { - left: 33.33333333333333%; - } - .col-lg-push-5 { - left: 41.66666666666667%; - } - .col-lg-push-6 { - left: 50%; - } - .col-lg-push-7 { - left: 58.333333333333336%; - } - .col-lg-push-8 { - left: 66.66666666666666%; - } - .col-lg-push-9 { - left: 75%; - } - .col-lg-push-10 { - left: 83.33333333333334%; - } - .col-lg-push-11 { - left: 91.66666666666666%; - } - .col-lg-pull-0 { - right: auto; - } - .col-lg-pull-1 { - right: 8.333333333333332%; - } - .col-lg-pull-2 { - right: 16.666666666666664%; - } - .col-lg-pull-3 { - right: 25%; - } - .col-lg-pull-4 { - right: 33.33333333333333%; - } - .col-lg-pull-5 { - right: 41.66666666666667%; - } - .col-lg-pull-6 { - right: 50%; - } - .col-lg-pull-7 { - right: 58.333333333333336%; - } - .col-lg-pull-8 { - right: 66.66666666666666%; - } - .col-lg-pull-9 { - right: 75%; - } - .col-lg-pull-10 { - right: 83.33333333333334%; - } - .col-lg-pull-11 { - right: 91.66666666666666%; - } - .col-lg-offset-0 { - margin-left: 0; - } - .col-lg-offset-1 { - margin-left: 8.333333333333332%; - } - .col-lg-offset-2 { - margin-left: 16.666666666666664%; - } - .col-lg-offset-3 { - margin-left: 25%; - } - .col-lg-offset-4 { - margin-left: 33.33333333333333%; - } - .col-lg-offset-5 { - margin-left: 41.66666666666667%; - } - .col-lg-offset-6 { - margin-left: 50%; - } - .col-lg-offset-7 { - margin-left: 58.333333333333336%; - } - .col-lg-offset-8 { - margin-left: 66.66666666666666%; - } - .col-lg-offset-9 { - margin-left: 75%; - } - .col-lg-offset-10 { - margin-left: 83.33333333333334%; - } - .col-lg-offset-11 { - margin-left: 91.66666666666666%; - } -} - -table { - max-width: 100%; - background-color: transparent; -} - -th { - text-align: left; -} - -.table { - width: 100%; - margin-bottom: 20px; -} - -.table thead > tr > th, -.table tbody > tr > th, -.table tfoot > tr > th, -.table thead > tr > td, -.table tbody > tr > td, -.table tfoot > tr > td { - padding: 8px; - line-height: 1.428571429; - vertical-align: top; - border-top: 1px solid #dddddd; -} - -.table thead > tr > th { - vertical-align: bottom; - border-bottom: 2px solid #dddddd; -} - -.table caption + thead tr:first-child th, -.table colgroup + thead tr:first-child th, -.table thead:first-child tr:first-child th, -.table caption + thead tr:first-child td, -.table colgroup + thead tr:first-child td, -.table thead:first-child tr:first-child td { - border-top: 0; -} - -.table tbody + tbody { - border-top: 2px solid #dddddd; -} - -.table .table { - background-color: #ffffff; -} - -.table-condensed thead > tr > th, -.table-condensed tbody > tr > th, -.table-condensed tfoot > tr > th, -.table-condensed thead > tr > td, -.table-condensed tbody > tr > td, -.table-condensed tfoot > tr > td { - padding: 5px; -} - -.table-bordered { - border: 1px solid #dddddd; -} - -.table-bordered > thead > tr > th, -.table-bordered > tbody > tr > th, -.table-bordered > tfoot > tr > th, -.table-bordered > thead > tr > td, -.table-bordered > tbody > tr > td, -.table-bordered > tfoot > tr > td { - border: 1px solid #dddddd; -} - -.table-bordered > thead > tr > th, -.table-bordered > thead > tr > td { - border-bottom-width: 2px; -} - -.table-striped > tbody > tr:nth-child(odd) > td, -.table-striped > tbody > tr:nth-child(odd) > th { - background-color: #f9f9f9; -} - -.table-hover > tbody > tr:hover > td, -.table-hover > tbody > tr:hover > th { - background-color: #f5f5f5; -} - -table col[class*="col-"] { - display: table-column; - float: none; -} - -table td[class*="col-"], -table th[class*="col-"] { - display: table-cell; - float: none; -} - -.table > thead > tr > td.active, -.table > tbody > tr > td.active, -.table > tfoot > tr > td.active, -.table > thead > tr > th.active, -.table > tbody > tr > th.active, -.table > tfoot > tr > th.active, -.table > thead > tr.active > td, -.table > tbody > tr.active > td, -.table > tfoot > tr.active > td, -.table > thead > tr.active > th, -.table > tbody > tr.active > th, -.table > tfoot > tr.active > th { - background-color: #f5f5f5; -} - -.table > thead > tr > td.success, -.table > tbody > tr > td.success, -.table > tfoot > tr > td.success, -.table > thead > tr > th.success, -.table > tbody > tr > th.success, -.table > tfoot > tr > th.success, -.table > thead > tr.success > td, -.table > tbody > tr.success > td, -.table > tfoot > tr.success > td, -.table > thead > tr.success > th, -.table > tbody > tr.success > th, -.table > tfoot > tr.success > th { - background-color: #dff0d8; - border-color: #d6e9c6; -} - -.table-hover > tbody > tr > td.success:hover, -.table-hover > tbody > tr > th.success:hover, -.table-hover > tbody > tr.success:hover > td { - background-color: #d0e9c6; - border-color: #c9e2b3; -} - -.table > thead > tr > td.danger, -.table > tbody > tr > td.danger, -.table > tfoot > tr > td.danger, -.table > thead > tr > th.danger, -.table > tbody > tr > th.danger, -.table > tfoot > tr > th.danger, -.table > thead > tr.danger > td, -.table > tbody > tr.danger > td, -.table > tfoot > tr.danger > td, -.table > thead > tr.danger > th, -.table > tbody > tr.danger > th, -.table > tfoot > tr.danger > th { - background-color: #f2dede; - border-color: #eed3d7; -} - -.table-hover > tbody > tr > td.danger:hover, -.table-hover > tbody > tr > th.danger:hover, -.table-hover > tbody > tr.danger:hover > td { - background-color: #ebcccc; - border-color: #e6c1c7; -} - -.table > thead > tr > td.warning, -.table > tbody > tr > td.warning, -.table > tfoot > tr > td.warning, -.table > thead > tr > th.warning, -.table > tbody > tr > th.warning, -.table > tfoot > tr > th.warning, -.table > thead > tr.warning > td, -.table > tbody > tr.warning > td, -.table > tfoot > tr.warning > td, -.table > thead > tr.warning > th, -.table > tbody > tr.warning > th, -.table > tfoot > tr.warning > th { - background-color: #fcf8e3; - border-color: #fbeed5; -} - -.table-hover > tbody > tr > td.warning:hover, -.table-hover > tbody > tr > th.warning:hover, -.table-hover > tbody > tr.warning:hover > td { - background-color: #faf2cc; - border-color: #f8e5be; -} - -@media (max-width: 768px) { - .table-responsive { - width: 100%; - margin-bottom: 15px; - overflow-x: scroll; - overflow-y: hidden; - border: 1px solid #dddddd; - } - .table-responsive > .table { - margin-bottom: 0; - background-color: #fff; - } - .table-responsive > .table > thead > tr > th, - .table-responsive > .table > tbody > tr > th, - .table-responsive > .table > tfoot > tr > th, - .table-responsive > .table > thead > tr > td, - .table-responsive > .table > tbody > tr > td, - .table-responsive > .table > tfoot > tr > td { - white-space: nowrap; - } - .table-responsive > .table-bordered { - border: 0; - } - .table-responsive > .table-bordered > thead > tr > th:first-child, - .table-responsive > .table-bordered > tbody > tr > th:first-child, - .table-responsive > .table-bordered > tfoot > tr > th:first-child, - .table-responsive > .table-bordered > thead > tr > td:first-child, - .table-responsive > .table-bordered > tbody > tr > td:first-child, - .table-responsive > .table-bordered > tfoot > tr > td:first-child { - border-left: 0; - } - .table-responsive > .table-bordered > thead > tr > th:last-child, - .table-responsive > .table-bordered > tbody > tr > th:last-child, - .table-responsive > .table-bordered > tfoot > tr > th:last-child, - .table-responsive > .table-bordered > thead > tr > td:last-child, - .table-responsive > .table-bordered > tbody > tr > td:last-child, - .table-responsive > .table-bordered > tfoot > tr > td:last-child { - border-right: 0; - } - .table-responsive > .table-bordered > thead > tr:last-child > th, - .table-responsive > .table-bordered > tbody > tr:last-child > th, - .table-responsive > .table-bordered > tfoot > tr:last-child > th, - .table-responsive > .table-bordered > thead > tr:last-child > td, - .table-responsive > .table-bordered > tbody > tr:last-child > td, - .table-responsive > .table-bordered > tfoot > tr:last-child > td { - border-bottom: 0; - } -} - -fieldset { - padding: 0; - margin: 0; - border: 0; -} - -legend { - display: block; - width: 100%; - padding: 0; - margin-bottom: 20px; - font-size: 21px; - line-height: inherit; - color: #333333; - border: 0; - border-bottom: 1px solid #e5e5e5; -} - -label { - display: inline-block; - margin-bottom: 5px; - font-weight: bold; -} - -input[type="search"] { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -input[type="radio"], -input[type="checkbox"] { - margin: 4px 0 0; - margin-top: 1px \9; - /* IE8-9 */ - - line-height: normal; -} - -input[type="file"] { - display: block; -} - -select[multiple], -select[size] { - height: auto; -} - -select optgroup { - font-family: inherit; - font-size: inherit; - font-style: inherit; -} - -input[type="file"]:focus, -input[type="radio"]:focus, -input[type="checkbox"]:focus { - outline: thin dotted #333; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} - -input[type="number"]::-webkit-outer-spin-button, -input[type="number"]::-webkit-inner-spin-button { - height: auto; -} - -.form-control:-moz-placeholder { - color: #999999; -} - -.form-control::-moz-placeholder { - color: #999999; -} - -.form-control:-ms-input-placeholder { - color: #999999; -} - -.form-control::-webkit-input-placeholder { - color: #999999; -} - -.form-control { - display: block; - width: 100%; - height: 34px; - padding: 6px 12px; - font-size: 14px; - line-height: 1.428571429; - color: #555555; - vertical-align: middle; - background-color: #ffffff; - border: 1px solid #cccccc; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; -} - -.form-control:focus { - border-color: #66afe9; - outline: 0; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); -} - -.form-control[disabled], -.form-control[readonly], -fieldset[disabled] .form-control { - cursor: not-allowed; - background-color: #eeeeee; -} - -textarea.form-control { - height: auto; -} - -.form-group { - margin-bottom: 15px; -} - -.radio, -.checkbox { - display: block; - min-height: 20px; - padding-left: 20px; - margin-top: 10px; - margin-bottom: 10px; - vertical-align: middle; -} - -.radio label, -.checkbox label { - display: inline; - margin-bottom: 0; - font-weight: normal; - cursor: pointer; -} - -.radio input[type="radio"], -.radio-inline input[type="radio"], -.checkbox input[type="checkbox"], -.checkbox-inline input[type="checkbox"] { - float: left; - margin-left: -20px; -} - -.radio + .radio, -.checkbox + .checkbox { - margin-top: -5px; -} - -.radio-inline, -.checkbox-inline { - display: inline-block; - padding-left: 20px; - margin-bottom: 0; - font-weight: normal; - vertical-align: middle; - cursor: pointer; -} - -.radio-inline + .radio-inline, -.checkbox-inline + .checkbox-inline { - margin-top: 0; - margin-left: 10px; -} - -input[type="radio"][disabled], -input[type="checkbox"][disabled], -.radio[disabled], -.radio-inline[disabled], -.checkbox[disabled], -.checkbox-inline[disabled], -fieldset[disabled] input[type="radio"], -fieldset[disabled] input[type="checkbox"], -fieldset[disabled] .radio, -fieldset[disabled] .radio-inline, -fieldset[disabled] .checkbox, -fieldset[disabled] .checkbox-inline { - cursor: not-allowed; -} - -.input-sm { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} - -select.input-sm { - height: 30px; - line-height: 30px; -} - -textarea.input-sm { - height: auto; -} - -.input-lg { - height: 45px; - padding: 10px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} - -select.input-lg { - height: 45px; - line-height: 45px; -} - -textarea.input-lg { - height: auto; -} - -.has-warning .help-block, -.has-warning .control-label { - color: #c09853; -} - -.has-warning .form-control { - border-color: #c09853; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} - -.has-warning .form-control:focus { - border-color: #a47e3c; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; -} - -.has-warning .input-group-addon { - color: #c09853; - background-color: #fcf8e3; - border-color: #c09853; -} - -.has-error .help-block, -.has-error .control-label { - color: #b94a48; -} - -.has-error .form-control { - border-color: #b94a48; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} - -.has-error .form-control:focus { - border-color: #953b39; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; -} - -.has-error .input-group-addon { - color: #b94a48; - background-color: #f2dede; - border-color: #b94a48; -} - -.has-success .help-block, -.has-success .control-label { - color: #468847; -} - -.has-success .form-control { - border-color: #468847; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} - -.has-success .form-control:focus { - border-color: #356635; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; -} - -.has-success .input-group-addon { - color: #468847; - background-color: #dff0d8; - border-color: #468847; -} - -.form-control-static { - padding-top: 7px; - margin-bottom: 0; -} - -.help-block { - display: block; - margin-top: 5px; - margin-bottom: 10px; - color: #737373; -} - -@media (min-width: 768px) { - .form-inline .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .form-control { - display: inline-block; - } - .form-inline .radio, - .form-inline .checkbox { - display: inline-block; - padding-left: 0; - margin-top: 0; - margin-bottom: 0; - } - .form-inline .radio input[type="radio"], - .form-inline .checkbox input[type="checkbox"] { - float: none; - margin-left: 0; - } -} - -.form-horizontal .control-label, -.form-horizontal .radio, -.form-horizontal .checkbox, -.form-horizontal .radio-inline, -.form-horizontal .checkbox-inline { - padding-top: 7px; - margin-top: 0; - margin-bottom: 0; -} - -.form-horizontal .form-group { - margin-right: -15px; - margin-left: -15px; -} - -.form-horizontal .form-group:before, -.form-horizontal .form-group:after { - display: table; - content: " "; -} - -.form-horizontal .form-group:after { - clear: both; -} - -.form-horizontal .form-group:before, -.form-horizontal .form-group:after { - display: table; - content: " "; -} - -.form-horizontal .form-group:after { - clear: both; -} - -@media (min-width: 768px) { - .form-horizontal .control-label { - text-align: right; - } -} - -.btn { - display: inline-block; - padding: 6px 12px; - margin-bottom: 0; - font-size: 14px; - font-weight: normal; - line-height: 1.428571429; - text-align: center; - white-space: nowrap; - vertical-align: middle; - cursor: pointer; - border: 1px solid transparent; - border-radius: 4px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; -} - -.btn:focus { - outline: thin dotted #333; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} - -.btn:hover, -.btn:focus { - color: #333333; - text-decoration: none; -} - -.btn:active, -.btn.active { - background-image: none; - outline: 0; - -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} - -.btn.disabled, -.btn[disabled], -fieldset[disabled] .btn { - pointer-events: none; - cursor: not-allowed; - opacity: 0.65; - filter: alpha(opacity=65); - -webkit-box-shadow: none; - box-shadow: none; -} - -.btn-default { - color: #333333; - background-color: #ffffff; - border-color: #cccccc; -} - -.btn-default:hover, -.btn-default:focus, -.btn-default:active, -.btn-default.active, -.open .dropdown-toggle.btn-default { - color: #333333; - background-color: #ebebeb; - border-color: #adadad; -} - -.btn-default:active, -.btn-default.active, -.open .dropdown-toggle.btn-default { - background-image: none; -} - -.btn-default.disabled, -.btn-default[disabled], -fieldset[disabled] .btn-default, -.btn-default.disabled:hover, -.btn-default[disabled]:hover, -fieldset[disabled] .btn-default:hover, -.btn-default.disabled:focus, -.btn-default[disabled]:focus, -fieldset[disabled] .btn-default:focus, -.btn-default.disabled:active, -.btn-default[disabled]:active, -fieldset[disabled] .btn-default:active, -.btn-default.disabled.active, -.btn-default[disabled].active, -fieldset[disabled] .btn-default.active { - background-color: #ffffff; - border-color: #cccccc; -} - -.btn-primary { - color: #ffffff; - background-color: #428bca; - border-color: #357ebd; -} - -.btn-primary:hover, -.btn-primary:focus, -.btn-primary:active, -.btn-primary.active, -.open .dropdown-toggle.btn-primary { - color: #ffffff; - background-color: #3276b1; - border-color: #285e8e; -} - -.btn-primary:active, -.btn-primary.active, -.open .dropdown-toggle.btn-primary { - background-image: none; -} - -.btn-primary.disabled, -.btn-primary[disabled], -fieldset[disabled] .btn-primary, -.btn-primary.disabled:hover, -.btn-primary[disabled]:hover, -fieldset[disabled] .btn-primary:hover, -.btn-primary.disabled:focus, -.btn-primary[disabled]:focus, -fieldset[disabled] .btn-primary:focus, -.btn-primary.disabled:active, -.btn-primary[disabled]:active, -fieldset[disabled] .btn-primary:active, -.btn-primary.disabled.active, -.btn-primary[disabled].active, -fieldset[disabled] .btn-primary.active { - background-color: #428bca; - border-color: #357ebd; -} - -.btn-warning { - color: #ffffff; - background-color: #f0ad4e; - border-color: #eea236; -} - -.btn-warning:hover, -.btn-warning:focus, -.btn-warning:active, -.btn-warning.active, -.open .dropdown-toggle.btn-warning { - color: #ffffff; - background-color: #ed9c28; - border-color: #d58512; -} - -.btn-warning:active, -.btn-warning.active, -.open .dropdown-toggle.btn-warning { - background-image: none; -} - -.btn-warning.disabled, -.btn-warning[disabled], -fieldset[disabled] .btn-warning, -.btn-warning.disabled:hover, -.btn-warning[disabled]:hover, -fieldset[disabled] .btn-warning:hover, -.btn-warning.disabled:focus, -.btn-warning[disabled]:focus, -fieldset[disabled] .btn-warning:focus, -.btn-warning.disabled:active, -.btn-warning[disabled]:active, -fieldset[disabled] .btn-warning:active, -.btn-warning.disabled.active, -.btn-warning[disabled].active, -fieldset[disabled] .btn-warning.active { - background-color: #f0ad4e; - border-color: #eea236; -} - -.btn-danger { - color: #ffffff; - background-color: #d9534f; - border-color: #d43f3a; -} - -.btn-danger:hover, -.btn-danger:focus, -.btn-danger:active, -.btn-danger.active, -.open .dropdown-toggle.btn-danger { - color: #ffffff; - background-color: #d2322d; - border-color: #ac2925; -} - -.btn-danger:active, -.btn-danger.active, -.open .dropdown-toggle.btn-danger { - background-image: none; -} - -.btn-danger.disabled, -.btn-danger[disabled], -fieldset[disabled] .btn-danger, -.btn-danger.disabled:hover, -.btn-danger[disabled]:hover, -fieldset[disabled] .btn-danger:hover, -.btn-danger.disabled:focus, -.btn-danger[disabled]:focus, -fieldset[disabled] .btn-danger:focus, -.btn-danger.disabled:active, -.btn-danger[disabled]:active, -fieldset[disabled] .btn-danger:active, -.btn-danger.disabled.active, -.btn-danger[disabled].active, -fieldset[disabled] .btn-danger.active { - background-color: #d9534f; - border-color: #d43f3a; -} - -.btn-success { - color: #ffffff; - background-color: #5cb85c; - border-color: #4cae4c; -} - -.btn-success:hover, -.btn-success:focus, -.btn-success:active, -.btn-success.active, -.open .dropdown-toggle.btn-success { - color: #ffffff; - background-color: #47a447; - border-color: #398439; -} - -.btn-success:active, -.btn-success.active, -.open .dropdown-toggle.btn-success { - background-image: none; -} - -.btn-success.disabled, -.btn-success[disabled], -fieldset[disabled] .btn-success, -.btn-success.disabled:hover, -.btn-success[disabled]:hover, -fieldset[disabled] .btn-success:hover, -.btn-success.disabled:focus, -.btn-success[disabled]:focus, -fieldset[disabled] .btn-success:focus, -.btn-success.disabled:active, -.btn-success[disabled]:active, -fieldset[disabled] .btn-success:active, -.btn-success.disabled.active, -.btn-success[disabled].active, -fieldset[disabled] .btn-success.active { - background-color: #5cb85c; - border-color: #4cae4c; -} - -.btn-info { - color: #ffffff; - background-color: #5bc0de; - border-color: #46b8da; -} - -.btn-info:hover, -.btn-info:focus, -.btn-info:active, -.btn-info.active, -.open .dropdown-toggle.btn-info { - color: #ffffff; - background-color: #39b3d7; - border-color: #269abc; -} - -.btn-info:active, -.btn-info.active, -.open .dropdown-toggle.btn-info { - background-image: none; -} - -.btn-info.disabled, -.btn-info[disabled], -fieldset[disabled] .btn-info, -.btn-info.disabled:hover, -.btn-info[disabled]:hover, -fieldset[disabled] .btn-info:hover, -.btn-info.disabled:focus, -.btn-info[disabled]:focus, -fieldset[disabled] .btn-info:focus, -.btn-info.disabled:active, -.btn-info[disabled]:active, -fieldset[disabled] .btn-info:active, -.btn-info.disabled.active, -.btn-info[disabled].active, -fieldset[disabled] .btn-info.active { - background-color: #5bc0de; - border-color: #46b8da; -} - -.btn-link { - font-weight: normal; - color: #428bca; - cursor: pointer; - border-radius: 0; -} - -.btn-link, -.btn-link:active, -.btn-link[disabled], -fieldset[disabled] .btn-link { - background-color: transparent; - -webkit-box-shadow: none; - box-shadow: none; -} - -.btn-link, -.btn-link:hover, -.btn-link:focus, -.btn-link:active { - border-color: transparent; -} - -.btn-link:hover, -.btn-link:focus { - color: #2a6496; - text-decoration: underline; - background-color: transparent; -} - -.btn-link[disabled]:hover, -fieldset[disabled] .btn-link:hover, -.btn-link[disabled]:focus, -fieldset[disabled] .btn-link:focus { - color: #999999; - text-decoration: none; -} - -.btn-lg { - padding: 10px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} - -.btn-sm, -.btn-xs { - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} - -.btn-xs { - padding: 1px 5px; -} - -.btn-block { - display: block; - width: 100%; - padding-right: 0; - padding-left: 0; -} - -.btn-block + .btn-block { - margin-top: 5px; -} - -input[type="submit"].btn-block, -input[type="reset"].btn-block, -input[type="button"].btn-block { - width: 100%; -} - -.fade { - opacity: 0; - -webkit-transition: opacity 0.15s linear; - transition: opacity 0.15s linear; -} - -.fade.in { - opacity: 1; -} - -.collapse { - display: none; -} - -.collapse.in { - display: block; -} - -.collapsing { - position: relative; - height: 0; - overflow: hidden; - -webkit-transition: height 0.35s ease; - transition: height 0.35s ease; -} - -@font-face { - font-family: 'Glyphicons Halflings'; - src: url('../fonts/glyphicons-halflings-regular.eot'); - src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg'); -} - -.glyphicon { - position: relative; - top: 1px; - display: inline-block; - font-family: 'Glyphicons Halflings'; - -webkit-font-smoothing: antialiased; - font-style: normal; - font-weight: normal; - line-height: 1; -} - -.glyphicon-asterisk:before { - content: "\2a"; -} - -.glyphicon-plus:before { - content: "\2b"; -} - -.glyphicon-euro:before { - content: "\20ac"; -} - -.glyphicon-minus:before { - content: "\2212"; -} - -.glyphicon-cloud:before { - content: "\2601"; -} - -.glyphicon-envelope:before { - content: "\2709"; -} - -.glyphicon-pencil:before { - content: "\270f"; -} - -.glyphicon-glass:before { - content: "\e001"; -} - -.glyphicon-music:before { - content: "\e002"; -} - -.glyphicon-search:before { - content: "\e003"; -} - -.glyphicon-heart:before { - content: "\e005"; -} - -.glyphicon-star:before { - content: "\e006"; -} - -.glyphicon-star-empty:before { - content: "\e007"; -} - -.glyphicon-user:before { - content: "\e008"; -} - -.glyphicon-film:before { - content: "\e009"; -} - -.glyphicon-th-large:before { - content: "\e010"; -} - -.glyphicon-th:before { - content: "\e011"; -} - -.glyphicon-th-list:before { - content: "\e012"; -} - -.glyphicon-ok:before { - content: "\e013"; -} - -.glyphicon-remove:before { - content: "\e014"; -} - -.glyphicon-zoom-in:before { - content: "\e015"; -} - -.glyphicon-zoom-out:before { - content: "\e016"; -} - -.glyphicon-off:before { - content: "\e017"; -} - -.glyphicon-signal:before { - content: "\e018"; -} - -.glyphicon-cog:before { - content: "\e019"; -} - -.glyphicon-trash:before { - content: "\e020"; -} - -.glyphicon-home:before { - content: "\e021"; -} - -.glyphicon-file:before { - content: "\e022"; -} - -.glyphicon-time:before { - content: "\e023"; -} - -.glyphicon-road:before { - content: "\e024"; -} - -.glyphicon-download-alt:before { - content: "\e025"; -} - -.glyphicon-download:before { - content: "\e026"; -} - -.glyphicon-upload:before { - content: "\e027"; -} - -.glyphicon-inbox:before { - content: "\e028"; -} - -.glyphicon-play-circle:before { - content: "\e029"; -} - -.glyphicon-repeat:before { - content: "\e030"; -} - -.glyphicon-refresh:before { - content: "\e031"; -} - -.glyphicon-list-alt:before { - content: "\e032"; -} - -.glyphicon-flag:before { - content: "\e034"; -} - -.glyphicon-headphones:before { - content: "\e035"; -} - -.glyphicon-volume-off:before { - content: "\e036"; -} - -.glyphicon-volume-down:before { - content: "\e037"; -} - -.glyphicon-volume-up:before { - content: "\e038"; -} - -.glyphicon-qrcode:before { - content: "\e039"; -} - -.glyphicon-barcode:before { - content: "\e040"; -} - -.glyphicon-tag:before { - content: "\e041"; -} - -.glyphicon-tags:before { - content: "\e042"; -} - -.glyphicon-book:before { - content: "\e043"; -} - -.glyphicon-print:before { - content: "\e045"; -} - -.glyphicon-font:before { - content: "\e047"; -} - -.glyphicon-bold:before { - content: "\e048"; -} - -.glyphicon-italic:before { - content: "\e049"; -} - -.glyphicon-text-height:before { - content: "\e050"; -} - -.glyphicon-text-width:before { - content: "\e051"; -} - -.glyphicon-align-left:before { - content: "\e052"; -} - -.glyphicon-align-center:before { - content: "\e053"; -} - -.glyphicon-align-right:before { - content: "\e054"; -} - -.glyphicon-align-justify:before { - content: "\e055"; -} - -.glyphicon-list:before { - content: "\e056"; -} - -.glyphicon-indent-left:before { - content: "\e057"; -} - -.glyphicon-indent-right:before { - content: "\e058"; -} - -.glyphicon-facetime-video:before { - content: "\e059"; -} - -.glyphicon-picture:before { - content: "\e060"; -} - -.glyphicon-map-marker:before { - content: "\e062"; -} - -.glyphicon-adjust:before { - content: "\e063"; -} - -.glyphicon-tint:before { - content: "\e064"; -} - -.glyphicon-edit:before { - content: "\e065"; -} - -.glyphicon-share:before { - content: "\e066"; -} - -.glyphicon-check:before { - content: "\e067"; -} - -.glyphicon-move:before { - content: "\e068"; -} - -.glyphicon-step-backward:before { - content: "\e069"; -} - -.glyphicon-fast-backward:before { - content: "\e070"; -} - -.glyphicon-backward:before { - content: "\e071"; -} - -.glyphicon-play:before { - content: "\e072"; -} - -.glyphicon-pause:before { - content: "\e073"; -} - -.glyphicon-stop:before { - content: "\e074"; -} - -.glyphicon-forward:before { - content: "\e075"; -} - -.glyphicon-fast-forward:before { - content: "\e076"; -} - -.glyphicon-step-forward:before { - content: "\e077"; -} - -.glyphicon-eject:before { - content: "\e078"; -} - -.glyphicon-chevron-left:before { - content: "\e079"; -} - -.glyphicon-chevron-right:before { - content: "\e080"; -} - -.glyphicon-plus-sign:before { - content: "\e081"; -} - -.glyphicon-minus-sign:before { - content: "\e082"; -} - -.glyphicon-remove-sign:before { - content: "\e083"; -} - -.glyphicon-ok-sign:before { - content: "\e084"; -} - -.glyphicon-question-sign:before { - content: "\e085"; -} - -.glyphicon-info-sign:before { - content: "\e086"; -} - -.glyphicon-screenshot:before { - content: "\e087"; -} - -.glyphicon-remove-circle:before { - content: "\e088"; -} - -.glyphicon-ok-circle:before { - content: "\e089"; -} - -.glyphicon-ban-circle:before { - content: "\e090"; -} - -.glyphicon-arrow-left:before { - content: "\e091"; -} - -.glyphicon-arrow-right:before { - content: "\e092"; -} - -.glyphicon-arrow-up:before { - content: "\e093"; -} - -.glyphicon-arrow-down:before { - content: "\e094"; -} - -.glyphicon-share-alt:before { - content: "\e095"; -} - -.glyphicon-resize-full:before { - content: "\e096"; -} - -.glyphicon-resize-small:before { - content: "\e097"; -} - -.glyphicon-exclamation-sign:before { - content: "\e101"; -} - -.glyphicon-gift:before { - content: "\e102"; -} - -.glyphicon-leaf:before { - content: "\e103"; -} - -.glyphicon-eye-open:before { - content: "\e105"; -} - -.glyphicon-eye-close:before { - content: "\e106"; -} - -.glyphicon-warning-sign:before { - content: "\e107"; -} - -.glyphicon-plane:before { - content: "\e108"; -} - -.glyphicon-random:before { - content: "\e110"; -} - -.glyphicon-comment:before { - content: "\e111"; -} - -.glyphicon-magnet:before { - content: "\e112"; -} - -.glyphicon-chevron-up:before { - content: "\e113"; -} - -.glyphicon-chevron-down:before { - content: "\e114"; -} - -.glyphicon-retweet:before { - content: "\e115"; -} - -.glyphicon-shopping-cart:before { - content: "\e116"; -} - -.glyphicon-folder-close:before { - content: "\e117"; -} - -.glyphicon-folder-open:before { - content: "\e118"; -} - -.glyphicon-resize-vertical:before { - content: "\e119"; -} - -.glyphicon-resize-horizontal:before { - content: "\e120"; -} - -.glyphicon-hdd:before { - content: "\e121"; -} - -.glyphicon-bullhorn:before { - content: "\e122"; -} - -.glyphicon-certificate:before { - content: "\e124"; -} - -.glyphicon-thumbs-up:before { - content: "\e125"; -} - -.glyphicon-thumbs-down:before { - content: "\e126"; -} - -.glyphicon-hand-right:before { - content: "\e127"; -} - -.glyphicon-hand-left:before { - content: "\e128"; -} - -.glyphicon-hand-up:before { - content: "\e129"; -} - -.glyphicon-hand-down:before { - content: "\e130"; -} - -.glyphicon-circle-arrow-right:before { - content: "\e131"; -} - -.glyphicon-circle-arrow-left:before { - content: "\e132"; -} - -.glyphicon-circle-arrow-up:before { - content: "\e133"; -} - -.glyphicon-circle-arrow-down:before { - content: "\e134"; -} - -.glyphicon-globe:before { - content: "\e135"; -} - -.glyphicon-tasks:before { - content: "\e137"; -} - -.glyphicon-filter:before { - content: "\e138"; -} - -.glyphicon-fullscreen:before { - content: "\e140"; -} - -.glyphicon-dashboard:before { - content: "\e141"; -} - -.glyphicon-heart-empty:before { - content: "\e143"; -} - -.glyphicon-link:before { - content: "\e144"; -} - -.glyphicon-phone:before { - content: "\e145"; -} - -.glyphicon-usd:before { - content: "\e148"; -} - -.glyphicon-gbp:before { - content: "\e149"; -} - -.glyphicon-sort:before { - content: "\e150"; -} - -.glyphicon-sort-by-alphabet:before { - content: "\e151"; -} - -.glyphicon-sort-by-alphabet-alt:before { - content: "\e152"; -} - -.glyphicon-sort-by-order:before { - content: "\e153"; -} - -.glyphicon-sort-by-order-alt:before { - content: "\e154"; -} - -.glyphicon-sort-by-attributes:before { - content: "\e155"; -} - -.glyphicon-sort-by-attributes-alt:before { - content: "\e156"; -} - -.glyphicon-unchecked:before { - content: "\e157"; -} - -.glyphicon-expand:before { - content: "\e158"; -} - -.glyphicon-collapse-down:before { - content: "\e159"; -} - -.glyphicon-collapse-up:before { - content: "\e160"; -} - -.glyphicon-log-in:before { - content: "\e161"; -} - -.glyphicon-flash:before { - content: "\e162"; -} - -.glyphicon-log-out:before { - content: "\e163"; -} - -.glyphicon-new-window:before { - content: "\e164"; -} - -.glyphicon-record:before { - content: "\e165"; -} - -.glyphicon-save:before { - content: "\e166"; -} - -.glyphicon-open:before { - content: "\e167"; -} - -.glyphicon-saved:before { - content: "\e168"; -} - -.glyphicon-import:before { - content: "\e169"; -} - -.glyphicon-export:before { - content: "\e170"; -} - -.glyphicon-send:before { - content: "\e171"; -} - -.glyphicon-floppy-disk:before { - content: "\e172"; -} - -.glyphicon-floppy-saved:before { - content: "\e173"; -} - -.glyphicon-floppy-remove:before { - content: "\e174"; -} - -.glyphicon-floppy-save:before { - content: "\e175"; -} - -.glyphicon-floppy-open:before { - content: "\e176"; -} - -.glyphicon-credit-card:before { - content: "\e177"; -} - -.glyphicon-transfer:before { - content: "\e178"; -} - -.glyphicon-cutlery:before { - content: "\e179"; -} - -.glyphicon-header:before { - content: "\e180"; -} - -.glyphicon-compressed:before { - content: "\e181"; -} - -.glyphicon-earphone:before { - content: "\e182"; -} - -.glyphicon-phone-alt:before { - content: "\e183"; -} - -.glyphicon-tower:before { - content: "\e184"; -} - -.glyphicon-stats:before { - content: "\e185"; -} - -.glyphicon-sd-video:before { - content: "\e186"; -} - -.glyphicon-hd-video:before { - content: "\e187"; -} - -.glyphicon-subtitles:before { - content: "\e188"; -} - -.glyphicon-sound-stereo:before { - content: "\e189"; -} - -.glyphicon-sound-dolby:before { - content: "\e190"; -} - -.glyphicon-sound-5-1:before { - content: "\e191"; -} - -.glyphicon-sound-6-1:before { - content: "\e192"; -} - -.glyphicon-sound-7-1:before { - content: "\e193"; -} - -.glyphicon-copyright-mark:before { - content: "\e194"; -} - -.glyphicon-registration-mark:before { - content: "\e195"; -} - -.glyphicon-cloud-download:before { - content: "\e197"; -} - -.glyphicon-cloud-upload:before { - content: "\e198"; -} - -.glyphicon-tree-conifer:before { - content: "\e199"; -} - -.glyphicon-tree-deciduous:before { - content: "\e200"; -} - -.glyphicon-briefcase:before { - content: "\1f4bc"; -} - -.glyphicon-calendar:before { - content: "\1f4c5"; -} - -.glyphicon-pushpin:before { - content: "\1f4cc"; -} - -.glyphicon-paperclip:before { - content: "\1f4ce"; -} - -.glyphicon-camera:before { - content: "\1f4f7"; -} - -.glyphicon-lock:before { - content: "\1f512"; -} - -.glyphicon-bell:before { - content: "\1f514"; -} - -.glyphicon-bookmark:before { - content: "\1f516"; -} - -.glyphicon-fire:before { - content: "\1f525"; -} - -.glyphicon-wrench:before { - content: "\1f527"; -} - -.caret { - display: inline-block; - width: 0; - height: 0; - margin-left: 2px; - vertical-align: middle; - border-top: 4px solid #000000; - border-right: 4px solid transparent; - border-bottom: 0 dotted; - border-left: 4px solid transparent; - content: ""; -} - -.dropdown { - position: relative; -} - -.dropdown-toggle:focus { - outline: 0; -} - -.dropdown-menu { - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - padding: 5px 0; - margin: 2px 0 0; - font-size: 14px; - list-style: none; - background-color: #ffffff; - border: 1px solid #cccccc; - border: 1px solid rgba(0, 0, 0, 0.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - background-clip: padding-box; -} - -.dropdown-menu.pull-right { - right: 0; - left: auto; -} - -.dropdown-menu .divider { - height: 1px; - margin: 9px 0; - overflow: hidden; - background-color: #e5e5e5; -} - -.dropdown-menu > li > a { - display: block; - padding: 3px 20px; - clear: both; - font-weight: normal; - line-height: 1.428571429; - color: #333333; - white-space: nowrap; -} - -.dropdown-menu > li > a:hover, -.dropdown-menu > li > a:focus { - color: #ffffff; - text-decoration: none; - background-color: #428bca; -} - -.dropdown-menu > .active > a, -.dropdown-menu > .active > a:hover, -.dropdown-menu > .active > a:focus { - color: #ffffff; - text-decoration: none; - background-color: #428bca; - outline: 0; -} - -.dropdown-menu > .disabled > a, -.dropdown-menu > .disabled > a:hover, -.dropdown-menu > .disabled > a:focus { - color: #999999; -} - -.dropdown-menu > .disabled > a:hover, -.dropdown-menu > .disabled > a:focus { - text-decoration: none; - cursor: not-allowed; - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} - -.open > .dropdown-menu { - display: block; -} - -.open > a { - outline: 0; -} - -.dropdown-header { - display: block; - padding: 3px 20px; - font-size: 12px; - line-height: 1.428571429; - color: #999999; -} - -.dropdown-backdrop { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 990; -} - -.pull-right > .dropdown-menu { - right: 0; - left: auto; -} - -.dropup .caret, -.navbar-fixed-bottom .dropdown .caret { - border-top: 0 dotted; - border-bottom: 4px solid #000000; - content: ""; -} - -.dropup .dropdown-menu, -.navbar-fixed-bottom .dropdown .dropdown-menu { - top: auto; - bottom: 100%; - margin-bottom: 1px; -} - -@media (min-width: 768px) { - .navbar-right .dropdown-menu { - right: 0; - left: auto; - } -} - -.btn-default .caret { - border-top-color: #333333; -} - -.btn-primary .caret, -.btn-success .caret, -.btn-warning .caret, -.btn-danger .caret, -.btn-info .caret { - border-top-color: #fff; -} - -.dropup .btn-default .caret { - border-bottom-color: #333333; -} - -.dropup .btn-primary .caret, -.dropup .btn-success .caret, -.dropup .btn-warning .caret, -.dropup .btn-danger .caret, -.dropup .btn-info .caret { - border-bottom-color: #fff; -} - -.btn-group, -.btn-group-vertical { - position: relative; - display: inline-block; - vertical-align: middle; -} - -.btn-group > .btn, -.btn-group-vertical > .btn { - position: relative; - float: left; -} - -.btn-group > .btn:hover, -.btn-group-vertical > .btn:hover, -.btn-group > .btn:focus, -.btn-group-vertical > .btn:focus, -.btn-group > .btn:active, -.btn-group-vertical > .btn:active, -.btn-group > .btn.active, -.btn-group-vertical > .btn.active { - z-index: 2; -} - -.btn-group > .btn:focus, -.btn-group-vertical > .btn:focus { - outline: none; -} - -.btn-group .btn + .btn, -.btn-group .btn + .btn-group, -.btn-group .btn-group + .btn, -.btn-group .btn-group + .btn-group { - margin-left: -1px; -} - -.btn-toolbar:before, -.btn-toolbar:after { - display: table; - content: " "; -} - -.btn-toolbar:after { - clear: both; -} - -.btn-toolbar:before, -.btn-toolbar:after { - display: table; - content: " "; -} - -.btn-toolbar:after { - clear: both; -} - -.btn-toolbar .btn-group { - float: left; -} - -.btn-toolbar > .btn + .btn, -.btn-toolbar > .btn-group + .btn, -.btn-toolbar > .btn + .btn-group, -.btn-toolbar > .btn-group + .btn-group { - margin-left: 5px; -} - -.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) { - border-radius: 0; -} - -.btn-group > .btn:first-child { - margin-left: 0; -} - -.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.btn-group > .btn:last-child:not(:first-child), -.btn-group > .dropdown-toggle:not(:first-child) { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} - -.btn-group > .btn-group { - float: left; -} - -.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn { - border-radius: 0; -} - -.btn-group > .btn-group:first-child > .btn:last-child, -.btn-group > .btn-group:first-child > .dropdown-toggle { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.btn-group > .btn-group:last-child > .btn:first-child { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} - -.btn-group .dropdown-toggle:active, -.btn-group.open .dropdown-toggle { - outline: 0; -} - -.btn-group-xs > .btn { - padding: 5px 10px; - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} - -.btn-group-sm > .btn { - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} - -.btn-group-lg > .btn { - padding: 10px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} - -.btn-group > .btn + .dropdown-toggle { - padding-right: 8px; - padding-left: 8px; -} - -.btn-group > .btn-lg + .dropdown-toggle { - padding-right: 12px; - padding-left: 12px; -} - -.btn-group.open .dropdown-toggle { - -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} - -.btn .caret { - margin-left: 0; -} - -.btn-lg .caret { - border-width: 5px 5px 0; - border-bottom-width: 0; -} - -.dropup .btn-lg .caret { - border-width: 0 5px 5px; -} - -.btn-group-vertical > .btn, -.btn-group-vertical > .btn-group { - display: block; - float: none; - width: 100%; - max-width: 100%; -} - -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after { - display: table; - content: " "; -} - -.btn-group-vertical > .btn-group:after { - clear: both; -} - -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after { - display: table; - content: " "; -} - -.btn-group-vertical > .btn-group:after { - clear: both; -} - -.btn-group-vertical > .btn-group > .btn { - float: none; -} - -.btn-group-vertical > .btn + .btn, -.btn-group-vertical > .btn + .btn-group, -.btn-group-vertical > .btn-group + .btn, -.btn-group-vertical > .btn-group + .btn-group { - margin-top: -1px; - margin-left: 0; -} - -.btn-group-vertical > .btn:not(:first-child):not(:last-child) { - border-radius: 0; -} - -.btn-group-vertical > .btn:first-child:not(:last-child) { - border-top-right-radius: 4px; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} - -.btn-group-vertical > .btn:last-child:not(:first-child) { - border-top-right-radius: 0; - border-bottom-left-radius: 4px; - border-top-left-radius: 0; -} - -.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn { - border-radius: 0; -} - -.btn-group-vertical > .btn-group:first-child > .btn:last-child, -.btn-group-vertical > .btn-group:first-child > .dropdown-toggle { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} - -.btn-group-vertical > .btn-group:last-child > .btn:first-child { - border-top-right-radius: 0; - border-top-left-radius: 0; -} - -.btn-group-justified { - display: table; - width: 100%; - border-collapse: separate; - table-layout: fixed; -} - -.btn-group-justified .btn { - display: table-cell; - float: none; - width: 1%; -} - -[data-toggle="buttons"] > .btn > input[type="radio"], -[data-toggle="buttons"] > .btn > input[type="checkbox"] { - display: none; -} - -.input-group { - position: relative; - display: table; - border-collapse: separate; -} - -.input-group.col { - float: none; - padding-right: 0; - padding-left: 0; -} - -.input-group .form-control { - width: 100%; - margin-bottom: 0; -} - -.input-group-lg > .form-control, -.input-group-lg > .input-group-addon, -.input-group-lg > .input-group-btn > .btn { - height: 45px; - padding: 10px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} - -select.input-group-lg > .form-control, -select.input-group-lg > .input-group-addon, -select.input-group-lg > .input-group-btn > .btn { - height: 45px; - line-height: 45px; -} - -textarea.input-group-lg > .form-control, -textarea.input-group-lg > .input-group-addon, -textarea.input-group-lg > .input-group-btn > .btn { - height: auto; -} - -.input-group-sm > .form-control, -.input-group-sm > .input-group-addon, -.input-group-sm > .input-group-btn > .btn { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} - -select.input-group-sm > .form-control, -select.input-group-sm > .input-group-addon, -select.input-group-sm > .input-group-btn > .btn { - height: 30px; - line-height: 30px; -} - -textarea.input-group-sm > .form-control, -textarea.input-group-sm > .input-group-addon, -textarea.input-group-sm > .input-group-btn > .btn { - height: auto; -} - -.input-group-addon, -.input-group-btn, -.input-group .form-control { - display: table-cell; -} - -.input-group-addon:not(:first-child):not(:last-child), -.input-group-btn:not(:first-child):not(:last-child), -.input-group .form-control:not(:first-child):not(:last-child) { - border-radius: 0; -} - -.input-group-addon, -.input-group-btn { - width: 1%; - white-space: nowrap; - vertical-align: middle; -} - -.input-group-addon { - padding: 6px 12px; - font-size: 14px; - font-weight: normal; - line-height: 1; - text-align: center; - background-color: #eeeeee; - border: 1px solid #cccccc; - border-radius: 4px; -} - -.input-group-addon.input-sm { - padding: 5px 10px; - font-size: 12px; - border-radius: 3px; -} - -.input-group-addon.input-lg { - padding: 10px 16px; - font-size: 18px; - border-radius: 6px; -} - -.input-group-addon input[type="radio"], -.input-group-addon input[type="checkbox"] { - margin-top: 0; -} - -.input-group .form-control:first-child, -.input-group-addon:first-child, -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .dropdown-toggle, -.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.input-group-addon:first-child { - border-right: 0; -} - -.input-group .form-control:last-child, -.input-group-addon:last-child, -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .dropdown-toggle, -.input-group-btn:first-child > .btn:not(:first-child) { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} - -.input-group-addon:last-child { - border-left: 0; -} - -.input-group-btn { - position: relative; - white-space: nowrap; -} - -.input-group-btn > .btn { - position: relative; -} - -.input-group-btn > .btn + .btn { - margin-left: -4px; -} - -.input-group-btn > .btn:hover, -.input-group-btn > .btn:active { - z-index: 2; -} - -.nav { - padding-left: 0; - margin-bottom: 0; - list-style: none; -} - -.nav:before, -.nav:after { - display: table; - content: " "; -} - -.nav:after { - clear: both; -} - -.nav:before, -.nav:after { - display: table; - content: " "; -} - -.nav:after { - clear: both; -} - -.nav > li { - position: relative; - display: block; -} - -.nav > li > a { - position: relative; - display: block; - padding: 10px 15px; -} - -.nav > li > a:hover, -.nav > li > a:focus { - text-decoration: none; - background-color: #eeeeee; -} - -.nav > li.disabled > a { - color: #999999; -} - -.nav > li.disabled > a:hover, -.nav > li.disabled > a:focus { - color: #999999; - text-decoration: none; - cursor: not-allowed; - background-color: transparent; -} - -.nav .open > a, -.nav .open > a:hover, -.nav .open > a:focus { - background-color: #eeeeee; - border-color: #428bca; -} - -.nav .nav-divider { - height: 1px; - margin: 9px 0; - overflow: hidden; - background-color: #e5e5e5; -} - -.nav > li > a > img { - max-width: none; -} - -.nav-tabs { - border-bottom: 1px solid #dddddd; -} - -.nav-tabs > li { - float: left; - margin-bottom: -1px; -} - -.nav-tabs > li > a { - margin-right: 2px; - line-height: 1.428571429; - border: 1px solid transparent; - border-radius: 4px 4px 0 0; -} - -.nav-tabs > li > a:hover { - border-color: #eeeeee #eeeeee #dddddd; -} - -.nav-tabs > li.active > a, -.nav-tabs > li.active > a:hover, -.nav-tabs > li.active > a:focus { - color: #555555; - cursor: default; - background-color: #ffffff; - border: 1px solid #dddddd; - border-bottom-color: transparent; -} - -.nav-tabs.nav-justified { - width: 100%; - border-bottom: 0; -} - -.nav-tabs.nav-justified > li { - float: none; -} - -.nav-tabs.nav-justified > li > a { - text-align: center; -} - -@media (min-width: 768px) { - .nav-tabs.nav-justified > li { - display: table-cell; - width: 1%; - } -} - -.nav-tabs.nav-justified > li > a { - margin-right: 0; - border-bottom: 1px solid #dddddd; -} - -.nav-tabs.nav-justified > .active > a { - border-bottom-color: #ffffff; -} - -.nav-pills > li { - float: left; -} - -.nav-pills > li > a { - border-radius: 5px; -} - -.nav-pills > li + li { - margin-left: 2px; -} - -.nav-pills > li.active > a, -.nav-pills > li.active > a:hover, -.nav-pills > li.active > a:focus { - color: #ffffff; - background-color: #428bca; -} - -.nav-stacked > li { - float: none; -} - -.nav-stacked > li + li { - margin-top: 2px; - margin-left: 0; -} - -.nav-justified { - width: 100%; -} - -.nav-justified > li { - float: none; -} - -.nav-justified > li > a { - text-align: center; -} - -@media (min-width: 768px) { - .nav-justified > li { - display: table-cell; - width: 1%; - } -} - -.nav-tabs-justified { - border-bottom: 0; -} - -.nav-tabs-justified > li > a { - margin-right: 0; - border-bottom: 1px solid #dddddd; -} - -.nav-tabs-justified > .active > a { - border-bottom-color: #ffffff; -} - -.tabbable:before, -.tabbable:after { - display: table; - content: " "; -} - -.tabbable:after { - clear: both; -} - -.tabbable:before, -.tabbable:after { - display: table; - content: " "; -} - -.tabbable:after { - clear: both; -} - -.tab-content > .tab-pane, -.pill-content > .pill-pane { - display: none; -} - -.tab-content > .active, -.pill-content > .active { - display: block; -} - -.nav .caret { - border-top-color: #428bca; - border-bottom-color: #428bca; -} - -.nav a:hover .caret { - border-top-color: #2a6496; - border-bottom-color: #2a6496; -} - -.nav-tabs .dropdown-menu { - margin-top: -1px; - border-top-right-radius: 0; - border-top-left-radius: 0; -} - -.navbar { - position: relative; - z-index: 1000; - min-height: 50px; - margin-bottom: 20px; - border: 1px solid transparent; -} - -.navbar:before, -.navbar:after { - display: table; - content: " "; -} - -.navbar:after { - clear: both; -} - -.navbar:before, -.navbar:after { - display: table; - content: " "; -} - -.navbar:after { - clear: both; -} - -@media (min-width: 768px) { - .navbar { - border-radius: 4px; - } -} - -.navbar-header:before, -.navbar-header:after { - display: table; - content: " "; -} - -.navbar-header:after { - clear: both; -} - -.navbar-header:before, -.navbar-header:after { - display: table; - content: " "; -} - -.navbar-header:after { - clear: both; -} - -@media (min-width: 768px) { - .navbar-header { - float: left; - } -} - -.navbar-collapse { - max-height: 340px; - padding-right: 15px; - padding-left: 15px; - overflow-x: visible; - border-top: 1px solid transparent; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); - -webkit-overflow-scrolling: touch; -} - -.navbar-collapse:before, -.navbar-collapse:after { - display: table; - content: " "; -} - -.navbar-collapse:after { - clear: both; -} - -.navbar-collapse:before, -.navbar-collapse:after { - display: table; - content: " "; -} - -.navbar-collapse:after { - clear: both; -} - -.navbar-collapse.in { - overflow-y: auto; -} - -@media (min-width: 768px) { - .navbar-collapse { - width: auto; - border-top: 0; - box-shadow: none; - } - .navbar-collapse.collapse { - display: block !important; - height: auto !important; - padding-bottom: 0; - overflow: visible !important; - } - .navbar-collapse.in { - overflow-y: visible; - } - .navbar-collapse .navbar-nav.navbar-left:first-child { - margin-left: -15px; - } - .navbar-collapse .navbar-nav.navbar-right:last-child { - margin-right: -15px; - } - .navbar-collapse .navbar-text:last-child { - margin-right: 0; - } -} - -.container > .navbar-header, -.container > .navbar-collapse { - margin-right: -15px; - margin-left: -15px; -} - -@media (min-width: 768px) { - .container > .navbar-header, - .container > .navbar-collapse { - margin-right: 0; - margin-left: 0; - } -} - -.navbar-static-top { - border-width: 0 0 1px; -} - -@media (min-width: 768px) { - .navbar-static-top { - border-radius: 0; - } -} - -.navbar-fixed-top, -.navbar-fixed-bottom { - position: fixed; - right: 0; - left: 0; - border-width: 0 0 1px; -} - -@media (min-width: 768px) { - .navbar-fixed-top, - .navbar-fixed-bottom { - border-radius: 0; - } -} - -.navbar-fixed-top { - top: 0; - z-index: 1030; -} - -.navbar-fixed-bottom { - bottom: 0; - margin-bottom: 0; -} - -.navbar-brand { - float: left; - padding: 15px 15px; - font-size: 18px; - line-height: 20px; -} - -.navbar-brand:hover, -.navbar-brand:focus { - text-decoration: none; -} - -@media (min-width: 768px) { - .navbar > .container .navbar-brand { - margin-left: -15px; - } -} - -.navbar-toggle { - position: relative; - float: right; - padding: 9px 10px; - margin-top: 8px; - margin-right: 15px; - margin-bottom: 8px; - background-color: transparent; - border: 1px solid transparent; - border-radius: 4px; -} - -.navbar-toggle .icon-bar { - display: block; - width: 22px; - height: 2px; - border-radius: 1px; -} - -.navbar-toggle .icon-bar + .icon-bar { - margin-top: 4px; -} - -@media (min-width: 768px) { - .navbar-toggle { - display: none; - } -} - -.navbar-nav { - margin: 7.5px -15px; -} - -.navbar-nav > li > a { - padding-top: 10px; - padding-bottom: 10px; - line-height: 20px; -} - -@media (max-width: 767px) { - .navbar-nav .open .dropdown-menu { - position: static; - float: none; - width: auto; - margin-top: 0; - background-color: transparent; - border: 0; - box-shadow: none; - } - .navbar-nav .open .dropdown-menu > li > a, - .navbar-nav .open .dropdown-menu .dropdown-header { - padding: 5px 15px 5px 25px; - } - .navbar-nav .open .dropdown-menu > li > a { - line-height: 20px; - } - .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-nav .open .dropdown-menu > li > a:focus { - background-image: none; - } -} - -@media (min-width: 768px) { - .navbar-nav { - float: left; - margin: 0; - } - .navbar-nav > li { - float: left; - } - .navbar-nav > li > a { - padding-top: 15px; - padding-bottom: 15px; - } -} - -@media (min-width: 768px) { - .navbar-left { - float: left !important; - } - .navbar-right { - float: right !important; - } -} - -.navbar-form { - padding: 10px 15px; - margin-top: 8px; - margin-right: -15px; - margin-bottom: 8px; - margin-left: -15px; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); -} - -@media (min-width: 768px) { - .navbar-form .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .form-control { - display: inline-block; - } - .navbar-form .radio, - .navbar-form .checkbox { - display: inline-block; - padding-left: 0; - margin-top: 0; - margin-bottom: 0; - } - .navbar-form .radio input[type="radio"], - .navbar-form .checkbox input[type="checkbox"] { - float: none; - margin-left: 0; - } -} - -@media (max-width: 767px) { - .navbar-form .form-group { - margin-bottom: 5px; - } -} - -@media (min-width: 768px) { - .navbar-form { - width: auto; - padding-top: 0; - padding-bottom: 0; - margin-right: 0; - margin-left: 0; - border: 0; - -webkit-box-shadow: none; - box-shadow: none; - } -} - -.navbar-nav > li > .dropdown-menu { - margin-top: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; -} - -.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} - -.navbar-nav.pull-right > li > .dropdown-menu, -.navbar-nav > li > .dropdown-menu.pull-right { - right: 0; - left: auto; -} - -.navbar-btn { - margin-top: 8px; - margin-bottom: 8px; -} - -.navbar-text { - float: left; - margin-top: 15px; - margin-bottom: 15px; -} - -@media (min-width: 768px) { - .navbar-text { - margin-right: 15px; - margin-left: 15px; - } -} - -.navbar-default { - background-color: #f8f8f8; - border-color: #e7e7e7; -} - -.navbar-default .navbar-brand { - color: #777777; -} - -.navbar-default .navbar-brand:hover, -.navbar-default .navbar-brand:focus { - color: #5e5e5e; - background-color: transparent; -} - -.navbar-default .navbar-text { - color: #777777; -} - -.navbar-default .navbar-nav > li > a { - color: #777777; -} - -.navbar-default .navbar-nav > li > a:hover, -.navbar-default .navbar-nav > li > a:focus { - color: #333333; - background-color: transparent; -} - -.navbar-default .navbar-nav > .active > a, -.navbar-default .navbar-nav > .active > a:hover, -.navbar-default .navbar-nav > .active > a:focus { - color: #555555; - background-color: #e7e7e7; -} - -.navbar-default .navbar-nav > .disabled > a, -.navbar-default .navbar-nav > .disabled > a:hover, -.navbar-default .navbar-nav > .disabled > a:focus { - color: #cccccc; - background-color: transparent; -} - -.navbar-default .navbar-toggle { - border-color: #dddddd; -} - -.navbar-default .navbar-toggle:hover, -.navbar-default .navbar-toggle:focus { - background-color: #dddddd; -} - -.navbar-default .navbar-toggle .icon-bar { - background-color: #cccccc; -} - -.navbar-default .navbar-collapse, -.navbar-default .navbar-form { - border-color: #e6e6e6; -} - -.navbar-default .navbar-nav > .dropdown > a:hover .caret, -.navbar-default .navbar-nav > .dropdown > a:focus .caret { - border-top-color: #333333; - border-bottom-color: #333333; -} - -.navbar-default .navbar-nav > .open > a, -.navbar-default .navbar-nav > .open > a:hover, -.navbar-default .navbar-nav > .open > a:focus { - color: #555555; - background-color: #e7e7e7; -} - -.navbar-default .navbar-nav > .open > a .caret, -.navbar-default .navbar-nav > .open > a:hover .caret, -.navbar-default .navbar-nav > .open > a:focus .caret { - border-top-color: #555555; - border-bottom-color: #555555; -} - -.navbar-default .navbar-nav > .dropdown > a .caret { - border-top-color: #777777; - border-bottom-color: #777777; -} - -@media (max-width: 767px) { - .navbar-default .navbar-nav .open .dropdown-menu > li > a { - color: #777777; - } - .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { - color: #333333; - background-color: transparent; - } - .navbar-default .navbar-nav .open .dropdown-menu > .active > a, - .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #555555; - background-color: #e7e7e7; - } - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a, - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #cccccc; - background-color: transparent; - } -} - -.navbar-default .navbar-link { - color: #777777; -} - -.navbar-default .navbar-link:hover { - color: #333333; -} - -.navbar-inverse { - background-color: #222222; - border-color: #080808; -} - -.navbar-inverse .navbar-brand { - color: #999999; -} - -.navbar-inverse .navbar-brand:hover, -.navbar-inverse .navbar-brand:focus { - color: #ffffff; - background-color: transparent; -} - -.navbar-inverse .navbar-text { - color: #999999; -} - -.navbar-inverse .navbar-nav > li > a { - color: #999999; -} - -.navbar-inverse .navbar-nav > li > a:hover, -.navbar-inverse .navbar-nav > li > a:focus { - color: #ffffff; - background-color: transparent; -} - -.navbar-inverse .navbar-nav > .active > a, -.navbar-inverse .navbar-nav > .active > a:hover, -.navbar-inverse .navbar-nav > .active > a:focus { - color: #ffffff; - background-color: #080808; -} - -.navbar-inverse .navbar-nav > .disabled > a, -.navbar-inverse .navbar-nav > .disabled > a:hover, -.navbar-inverse .navbar-nav > .disabled > a:focus { - color: #444444; - background-color: transparent; -} - -.navbar-inverse .navbar-toggle { - border-color: #333333; -} - -.navbar-inverse .navbar-toggle:hover, -.navbar-inverse .navbar-toggle:focus { - background-color: #333333; -} - -.navbar-inverse .navbar-toggle .icon-bar { - background-color: #ffffff; -} - -.navbar-inverse .navbar-collapse, -.navbar-inverse .navbar-form { - border-color: #101010; -} - -.navbar-inverse .navbar-nav > .open > a, -.navbar-inverse .navbar-nav > .open > a:hover, -.navbar-inverse .navbar-nav > .open > a:focus { - color: #ffffff; - background-color: #080808; -} - -.navbar-inverse .navbar-nav > .dropdown > a:hover .caret { - border-top-color: #ffffff; - border-bottom-color: #ffffff; -} - -.navbar-inverse .navbar-nav > .dropdown > a .caret { - border-top-color: #999999; - border-bottom-color: #999999; -} - -.navbar-inverse .navbar-nav > .open > a .caret, -.navbar-inverse .navbar-nav > .open > a:hover .caret, -.navbar-inverse .navbar-nav > .open > a:focus .caret { - border-top-color: #ffffff; - border-bottom-color: #ffffff; -} - -@media (max-width: 767px) { - .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header { - border-color: #080808; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { - color: #999999; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { - color: #ffffff; - background-color: transparent; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #ffffff; - background-color: #080808; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a, - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #444444; - background-color: transparent; - } -} - -.navbar-inverse .navbar-link { - color: #999999; -} - -.navbar-inverse .navbar-link:hover { - color: #ffffff; -} - -.breadcrumb { - padding: 8px 15px; - margin-bottom: 20px; - list-style: none; - background-color: #f5f5f5; - border-radius: 4px; -} - -.breadcrumb > li { - display: inline-block; -} - -.breadcrumb > li + li:before { - padding: 0 5px; - color: #cccccc; - content: "/\00a0"; -} - -.breadcrumb > .active { - color: #999999; -} - -.pagination { - display: inline-block; - padding-left: 0; - margin: 20px 0; - border-radius: 4px; -} - -.pagination > li { - display: inline; -} - -.pagination > li > a, -.pagination > li > span { - position: relative; - float: left; - padding: 6px 12px; - margin-left: -1px; - line-height: 1.428571429; - text-decoration: none; - background-color: #ffffff; - border: 1px solid #dddddd; -} - -.pagination > li:first-child > a, -.pagination > li:first-child > span { - margin-left: 0; - border-bottom-left-radius: 4px; - border-top-left-radius: 4px; -} - -.pagination > li:last-child > a, -.pagination > li:last-child > span { - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; -} - -.pagination > li > a:hover, -.pagination > li > span:hover, -.pagination > li > a:focus, -.pagination > li > span:focus { - background-color: #eeeeee; -} - -.pagination > .active > a, -.pagination > .active > span, -.pagination > .active > a:hover, -.pagination > .active > span:hover, -.pagination > .active > a:focus, -.pagination > .active > span:focus { - z-index: 2; - color: #ffffff; - cursor: default; - background-color: #428bca; - border-color: #428bca; -} - -.pagination > .disabled > span, -.pagination > .disabled > a, -.pagination > .disabled > a:hover, -.pagination > .disabled > a:focus { - color: #999999; - cursor: not-allowed; - background-color: #ffffff; - border-color: #dddddd; -} - -.pagination-lg > li > a, -.pagination-lg > li > span { - padding: 10px 16px; - font-size: 18px; -} - -.pagination-lg > li:first-child > a, -.pagination-lg > li:first-child > span { - border-bottom-left-radius: 6px; - border-top-left-radius: 6px; -} - -.pagination-lg > li:last-child > a, -.pagination-lg > li:last-child > span { - border-top-right-radius: 6px; - border-bottom-right-radius: 6px; -} - -.pagination-sm > li > a, -.pagination-sm > li > span { - padding: 5px 10px; - font-size: 12px; -} - -.pagination-sm > li:first-child > a, -.pagination-sm > li:first-child > span { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} - -.pagination-sm > li:last-child > a, -.pagination-sm > li:last-child > span { - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; -} - -.pager { - padding-left: 0; - margin: 20px 0; - text-align: center; - list-style: none; -} - -.pager:before, -.pager:after { - display: table; - content: " "; -} - -.pager:after { - clear: both; -} - -.pager:before, -.pager:after { - display: table; - content: " "; -} - -.pager:after { - clear: both; -} - -.pager li { - display: inline; -} - -.pager li > a, -.pager li > span { - display: inline-block; - padding: 5px 14px; - background-color: #ffffff; - border: 1px solid #dddddd; - border-radius: 15px; -} - -.pager li > a:hover, -.pager li > a:focus { - text-decoration: none; - background-color: #eeeeee; -} - -.pager .next > a, -.pager .next > span { - float: right; -} - -.pager .previous > a, -.pager .previous > span { - float: left; -} - -.pager .disabled > a, -.pager .disabled > a:hover, -.pager .disabled > a:focus, -.pager .disabled > span { - color: #999999; - cursor: not-allowed; - background-color: #ffffff; -} - -.label { - display: inline; - padding: .2em .6em .3em; - font-size: 75%; - font-weight: bold; - line-height: 1; - color: #ffffff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25em; -} - -.label[href]:hover, -.label[href]:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} - -.label:empty { - display: none; -} - -.label-default { - background-color: #999999; -} - -.label-default[href]:hover, -.label-default[href]:focus { - background-color: #808080; -} - -.label-primary { - background-color: #428bca; -} - -.label-primary[href]:hover, -.label-primary[href]:focus { - background-color: #3071a9; -} - -.label-success { - background-color: #5cb85c; -} - -.label-success[href]:hover, -.label-success[href]:focus { - background-color: #449d44; -} - -.label-info { - background-color: #5bc0de; -} - -.label-info[href]:hover, -.label-info[href]:focus { - background-color: #31b0d5; -} - -.label-warning { - background-color: #f0ad4e; -} - -.label-warning[href]:hover, -.label-warning[href]:focus { - background-color: #ec971f; -} - -.label-danger { - background-color: #d9534f; -} - -.label-danger[href]:hover, -.label-danger[href]:focus { - background-color: #c9302c; -} - -.badge { - display: inline-block; - min-width: 10px; - padding: 3px 7px; - font-size: 12px; - font-weight: bold; - line-height: 1; - color: #ffffff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - background-color: #999999; - border-radius: 10px; -} - -.badge:empty { - display: none; -} - -a.badge:hover, -a.badge:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} - -.btn .badge { - position: relative; - top: -1px; -} - -a.list-group-item.active > .badge, -.nav-pills > .active > a > .badge { - color: #428bca; - background-color: #ffffff; -} - -.nav-pills > li > a > .badge { - margin-left: 3px; -} - -.jumbotron { - padding: 30px; - margin-bottom: 30px; - font-size: 21px; - font-weight: 200; - line-height: 2.1428571435; - color: inherit; - background-color: #eeeeee; -} - -.jumbotron h1 { - line-height: 1; - color: inherit; -} - -.jumbotron p { - line-height: 1.4; -} - -.container .jumbotron { - border-radius: 6px; -} - -@media screen and (min-width: 768px) { - .jumbotron { - padding-top: 48px; - padding-bottom: 48px; - } - .container .jumbotron { - padding-right: 60px; - padding-left: 60px; - } - .jumbotron h1 { - font-size: 63px; - } -} - -.thumbnail { - display: inline-block; - display: block; - height: auto; - max-width: 100%; - padding: 4px; - line-height: 1.428571429; - background-color: #ffffff; - border: 1px solid #dddddd; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; -} - -.thumbnail > img { - display: block; - height: auto; - max-width: 100%; -} - -a.thumbnail:hover, -a.thumbnail:focus { - border-color: #428bca; -} - -.thumbnail > img { - margin-right: auto; - margin-left: auto; -} - -.thumbnail .caption { - padding: 9px; - color: #333333; -} - -.alert { - padding: 15px; - margin-bottom: 20px; - border: 1px solid transparent; - border-radius: 4px; -} - -.alert h4 { - margin-top: 0; - color: inherit; -} - -.alert .alert-link { - font-weight: bold; -} - -.alert > p, -.alert > ul { - margin-bottom: 0; -} - -.alert > p + p { - margin-top: 5px; -} - -.alert-dismissable { - padding-right: 35px; -} - -.alert-dismissable .close { - position: relative; - top: -2px; - right: -21px; - color: inherit; -} - -.alert-success { - color: #468847; - background-color: #dff0d8; - border-color: #d6e9c6; -} - -.alert-success hr { - border-top-color: #c9e2b3; -} - -.alert-success .alert-link { - color: #356635; -} - -.alert-info { - color: #3a87ad; - background-color: #d9edf7; - border-color: #bce8f1; -} - -.alert-info hr { - border-top-color: #a6e1ec; -} - -.alert-info .alert-link { - color: #2d6987; -} - -.alert-warning { - color: #c09853; - background-color: #fcf8e3; - border-color: #fbeed5; -} - -.alert-warning hr { - border-top-color: #f8e5be; -} - -.alert-warning .alert-link { - color: #a47e3c; -} - -.alert-danger { - color: #b94a48; - background-color: #f2dede; - border-color: #eed3d7; -} - -.alert-danger hr { - border-top-color: #e6c1c7; -} - -.alert-danger .alert-link { - color: #953b39; -} - -@-webkit-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} - -@-moz-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} - -@-o-keyframes progress-bar-stripes { - from { - background-position: 0 0; - } - to { - background-position: 40px 0; - } -} - -@keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} - -.progress { - height: 20px; - margin-bottom: 20px; - overflow: hidden; - background-color: #f5f5f5; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); -} - -.progress-bar { - float: left; - width: 0; - height: 100%; - font-size: 12px; - color: #ffffff; - text-align: center; - background-color: #428bca; - -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-transition: width 0.6s ease; - transition: width 0.6s ease; -} - -.progress-striped .progress-bar { - background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-size: 40px 40px; -} - -.progress.active .progress-bar { - -webkit-animation: progress-bar-stripes 2s linear infinite; - -moz-animation: progress-bar-stripes 2s linear infinite; - -ms-animation: progress-bar-stripes 2s linear infinite; - -o-animation: progress-bar-stripes 2s linear infinite; - animation: progress-bar-stripes 2s linear infinite; -} - -.progress-bar-success { - background-color: #5cb85c; -} - -.progress-striped .progress-bar-success { - background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} - -.progress-bar-info { - background-color: #5bc0de; -} - -.progress-striped .progress-bar-info { - background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} - -.progress-bar-warning { - background-color: #f0ad4e; -} - -.progress-striped .progress-bar-warning { - background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} - -.progress-bar-danger { - background-color: #d9534f; -} - -.progress-striped .progress-bar-danger { - background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} - -.media, -.media-body { - overflow: hidden; - zoom: 1; -} - -.media, -.media .media { - margin-top: 15px; -} - -.media:first-child { - margin-top: 0; -} - -.media-object { - display: block; -} - -.media-heading { - margin: 0 0 5px; -} - -.media > .pull-left { - margin-right: 10px; -} - -.media > .pull-right { - margin-left: 10px; -} - -.media-list { - padding-left: 0; - list-style: none; -} - -.list-group { - padding-left: 0; - margin-bottom: 20px; -} - -.list-group-item { - position: relative; - display: block; - padding: 10px 15px; - margin-bottom: -1px; - background-color: #ffffff; - border: 1px solid #dddddd; -} - -.list-group-item:first-child { - border-top-right-radius: 4px; - border-top-left-radius: 4px; -} - -.list-group-item:last-child { - margin-bottom: 0; - border-bottom-right-radius: 4px; - border-bottom-left-radius: 4px; -} - -.list-group-item > .badge { - float: right; -} - -.list-group-item > .badge + .badge { - margin-right: 5px; -} - -a.list-group-item { - color: #555555; -} - -a.list-group-item .list-group-item-heading { - color: #333333; -} - -a.list-group-item:hover, -a.list-group-item:focus { - text-decoration: none; - background-color: #f5f5f5; -} - -.list-group-item.active, -.list-group-item.active:hover, -.list-group-item.active:focus { - z-index: 2; - color: #ffffff; - background-color: #428bca; - border-color: #428bca; -} - -.list-group-item.active .list-group-item-heading, -.list-group-item.active:hover .list-group-item-heading, -.list-group-item.active:focus .list-group-item-heading { - color: inherit; -} - -.list-group-item.active .list-group-item-text, -.list-group-item.active:hover .list-group-item-text, -.list-group-item.active:focus .list-group-item-text { - color: #e1edf7; -} - -.list-group-item-heading { - margin-top: 0; - margin-bottom: 5px; -} - -.list-group-item-text { - margin-bottom: 0; - line-height: 1.3; -} - -.panel { - margin-bottom: 20px; - background-color: #ffffff; - border: 1px solid transparent; - border-radius: 4px; - -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); -} - -.panel-body { - padding: 15px; -} - -.panel-body:before, -.panel-body:after { - display: table; - content: " "; -} - -.panel-body:after { - clear: both; -} - -.panel-body:before, -.panel-body:after { - display: table; - content: " "; -} - -.panel-body:after { - clear: both; -} - -.panel > .list-group { - margin-bottom: 0; -} - -.panel > .list-group .list-group-item { - border-width: 1px 0; -} - -.panel > .list-group .list-group-item:first-child { - border-top-right-radius: 0; - border-top-left-radius: 0; -} - -.panel > .list-group .list-group-item:last-child { - border-bottom: 0; -} - -.panel-heading + .list-group .list-group-item:first-child { - border-top-width: 0; -} - -.panel > .table { - margin-bottom: 0; -} - -.panel > .panel-body + .table { - border-top: 1px solid #dddddd; -} - -.panel-heading { - padding: 10px 15px; - border-bottom: 1px solid transparent; - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} - -.panel-title { - margin-top: 0; - margin-bottom: 0; - font-size: 16px; -} - -.panel-title > a { - color: inherit; -} - -.panel-footer { - padding: 10px 15px; - background-color: #f5f5f5; - border-top: 1px solid #dddddd; - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} - -.panel-group .panel { - margin-bottom: 0; - overflow: hidden; - border-radius: 4px; -} - -.panel-group .panel + .panel { - margin-top: 5px; -} - -.panel-group .panel-heading { - border-bottom: 0; -} - -.panel-group .panel-heading + .panel-collapse .panel-body { - border-top: 1px solid #dddddd; -} - -.panel-group .panel-footer { - border-top: 0; -} - -.panel-group .panel-footer + .panel-collapse .panel-body { - border-bottom: 1px solid #dddddd; -} - -.panel-default { - border-color: #dddddd; -} - -.panel-default > .panel-heading { - color: #333333; - background-color: #f5f5f5; - border-color: #dddddd; -} - -.panel-default > .panel-heading + .panel-collapse .panel-body { - border-top-color: #dddddd; -} - -.panel-default > .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #dddddd; -} - -.panel-primary { - border-color: #428bca; -} - -.panel-primary > .panel-heading { - color: #ffffff; - background-color: #428bca; - border-color: #428bca; -} - -.panel-primary > .panel-heading + .panel-collapse .panel-body { - border-top-color: #428bca; -} - -.panel-primary > .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #428bca; -} - -.panel-success { - border-color: #d6e9c6; -} - -.panel-success > .panel-heading { - color: #468847; - background-color: #dff0d8; - border-color: #d6e9c6; -} - -.panel-success > .panel-heading + .panel-collapse .panel-body { - border-top-color: #d6e9c6; -} - -.panel-success > .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #d6e9c6; -} - -.panel-warning { - border-color: #fbeed5; -} - -.panel-warning > .panel-heading { - color: #c09853; - background-color: #fcf8e3; - border-color: #fbeed5; -} - -.panel-warning > .panel-heading + .panel-collapse .panel-body { - border-top-color: #fbeed5; -} - -.panel-warning > .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #fbeed5; -} - -.panel-danger { - border-color: #eed3d7; -} - -.panel-danger > .panel-heading { - color: #b94a48; - background-color: #f2dede; - border-color: #eed3d7; -} - -.panel-danger > .panel-heading + .panel-collapse .panel-body { - border-top-color: #eed3d7; -} - -.panel-danger > .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #eed3d7; -} - -.panel-info { - border-color: #bce8f1; -} - -.panel-info > .panel-heading { - color: #3a87ad; - background-color: #d9edf7; - border-color: #bce8f1; -} - -.panel-info > .panel-heading + .panel-collapse .panel-body { - border-top-color: #bce8f1; -} - -.panel-info > .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #bce8f1; -} - -.well { - min-height: 20px; - padding: 19px; - margin-bottom: 20px; - background-color: #f5f5f5; - border: 1px solid #e3e3e3; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); -} - -.well blockquote { - border-color: #ddd; - border-color: rgba(0, 0, 0, 0.15); -} - -.well-lg { - padding: 24px; - border-radius: 6px; -} - -.well-sm { - padding: 9px; - border-radius: 3px; -} - -.close { - float: right; - font-size: 21px; - font-weight: bold; - line-height: 1; - color: #000000; - text-shadow: 0 1px 0 #ffffff; - opacity: 0.2; - filter: alpha(opacity=20); -} - -.close:hover, -.close:focus { - color: #000000; - text-decoration: none; - cursor: pointer; - opacity: 0.5; - filter: alpha(opacity=50); -} - -button.close { - padding: 0; - cursor: pointer; - background: transparent; - border: 0; - -webkit-appearance: none; -} - -.modal-open { - overflow: hidden; -} - -body.modal-open, -.modal-open .navbar-fixed-top, -.modal-open .navbar-fixed-bottom { - margin-right: 15px; -} - -.modal { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1040; - display: none; - overflow: auto; - overflow-y: scroll; -} - -.modal.fade .modal-dialog { - -webkit-transform: translate(0, -25%); - -ms-transform: translate(0, -25%); - transform: translate(0, -25%); - -webkit-transition: -webkit-transform 0.3s ease-out; - -moz-transition: -moz-transform 0.3s ease-out; - -o-transition: -o-transform 0.3s ease-out; - transition: transform 0.3s ease-out; -} - -.modal.in .modal-dialog { - -webkit-transform: translate(0, 0); - -ms-transform: translate(0, 0); - transform: translate(0, 0); -} - -.modal-dialog { - z-index: 1050; - width: auto; - padding: 10px; - margin-right: auto; - margin-left: auto; -} - -.modal-content { - position: relative; - background-color: #ffffff; - border: 1px solid #999999; - border: 1px solid rgba(0, 0, 0, 0.2); - border-radius: 6px; - outline: none; - -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); - box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); - background-clip: padding-box; -} - -.modal-backdrop { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1030; - background-color: #000000; -} - -.modal-backdrop.fade { - opacity: 0; - filter: alpha(opacity=0); -} - -.modal-backdrop.in { - opacity: 0.5; - filter: alpha(opacity=50); -} - -.modal-header { - min-height: 16.428571429px; - padding: 15px; - border-bottom: 1px solid #e5e5e5; -} - -.modal-header .close { - margin-top: -2px; -} - -.modal-title { - margin: 0; - line-height: 1.428571429; -} - -.modal-body { - position: relative; - padding: 20px; -} - -.modal-footer { - padding: 19px 20px 20px; - margin-top: 15px; - text-align: right; - border-top: 1px solid #e5e5e5; -} - -.modal-footer:before, -.modal-footer:after { - display: table; - content: " "; -} - -.modal-footer:after { - clear: both; -} - -.modal-footer:before, -.modal-footer:after { - display: table; - content: " "; -} - -.modal-footer:after { - clear: both; -} - -.modal-footer .btn + .btn { - margin-bottom: 0; - margin-left: 5px; -} - -.modal-footer .btn-group .btn + .btn { - margin-left: -1px; -} - -.modal-footer .btn-block + .btn-block { - margin-left: 0; -} - -@media screen and (min-width: 768px) { - .modal-dialog { - right: auto; - left: 50%; - width: 600px; - padding-top: 30px; - padding-bottom: 30px; - } - .modal-content { - -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); - box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); - } -} - -.tooltip { - position: absolute; - z-index: 1030; - display: block; - font-size: 12px; - line-height: 1.4; - opacity: 0; - filter: alpha(opacity=0); - visibility: visible; -} - -.tooltip.in { - opacity: 0.9; - filter: alpha(opacity=90); -} - -.tooltip.top { - padding: 5px 0; - margin-top: -3px; -} - -.tooltip.right { - padding: 0 5px; - margin-left: 3px; -} - -.tooltip.bottom { - padding: 5px 0; - margin-top: 3px; -} - -.tooltip.left { - padding: 0 5px; - margin-left: -3px; -} - -.tooltip-inner { - max-width: 200px; - padding: 3px 8px; - color: #ffffff; - text-align: center; - text-decoration: none; - background-color: #000000; - border-radius: 4px; -} - -.tooltip-arrow { - position: absolute; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} - -.tooltip.top .tooltip-arrow { - bottom: 0; - left: 50%; - margin-left: -5px; - border-top-color: #000000; - border-width: 5px 5px 0; -} - -.tooltip.top-left .tooltip-arrow { - bottom: 0; - left: 5px; - border-top-color: #000000; - border-width: 5px 5px 0; -} - -.tooltip.top-right .tooltip-arrow { - right: 5px; - bottom: 0; - border-top-color: #000000; - border-width: 5px 5px 0; -} - -.tooltip.right .tooltip-arrow { - top: 50%; - left: 0; - margin-top: -5px; - border-right-color: #000000; - border-width: 5px 5px 5px 0; -} - -.tooltip.left .tooltip-arrow { - top: 50%; - right: 0; - margin-top: -5px; - border-left-color: #000000; - border-width: 5px 0 5px 5px; -} - -.tooltip.bottom .tooltip-arrow { - top: 0; - left: 50%; - margin-left: -5px; - border-bottom-color: #000000; - border-width: 0 5px 5px; -} - -.tooltip.bottom-left .tooltip-arrow { - top: 0; - left: 5px; - border-bottom-color: #000000; - border-width: 0 5px 5px; -} - -.tooltip.bottom-right .tooltip-arrow { - top: 0; - right: 5px; - border-bottom-color: #000000; - border-width: 0 5px 5px; -} - -.popover { - position: absolute; - top: 0; - left: 0; - z-index: 1010; - display: none; - max-width: 276px; - padding: 1px; - text-align: left; - white-space: normal; - background-color: #ffffff; - border: 1px solid #cccccc; - border: 1px solid rgba(0, 0, 0, 0.2); - border-radius: 6px; - -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - background-clip: padding-box; -} - -.popover.top { - margin-top: -10px; -} - -.popover.right { - margin-left: 10px; -} - -.popover.bottom { - margin-top: 10px; -} - -.popover.left { - margin-left: -10px; -} - -.popover-title { - padding: 8px 14px; - margin: 0; - font-size: 14px; - font-weight: normal; - line-height: 18px; - background-color: #f7f7f7; - border-bottom: 1px solid #ebebeb; - border-radius: 5px 5px 0 0; -} - -.popover-content { - padding: 9px 14px; -} - -.popover .arrow, -.popover .arrow:after { - position: absolute; - display: block; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} - -.popover .arrow { - border-width: 11px; -} - -.popover .arrow:after { - border-width: 10px; - content: ""; -} - -.popover.top .arrow { - bottom: -11px; - left: 50%; - margin-left: -11px; - border-top-color: #999999; - border-top-color: rgba(0, 0, 0, 0.25); - border-bottom-width: 0; -} - -.popover.top .arrow:after { - bottom: 1px; - margin-left: -10px; - border-top-color: #ffffff; - border-bottom-width: 0; - content: " "; -} - -.popover.right .arrow { - top: 50%; - left: -11px; - margin-top: -11px; - border-right-color: #999999; - border-right-color: rgba(0, 0, 0, 0.25); - border-left-width: 0; -} - -.popover.right .arrow:after { - bottom: -10px; - left: 1px; - border-right-color: #ffffff; - border-left-width: 0; - content: " "; -} - -.popover.bottom .arrow { - top: -11px; - left: 50%; - margin-left: -11px; - border-bottom-color: #999999; - border-bottom-color: rgba(0, 0, 0, 0.25); - border-top-width: 0; -} - -.popover.bottom .arrow:after { - top: 1px; - margin-left: -10px; - border-bottom-color: #ffffff; - border-top-width: 0; - content: " "; -} - -.popover.left .arrow { - top: 50%; - right: -11px; - margin-top: -11px; - border-left-color: #999999; - border-left-color: rgba(0, 0, 0, 0.25); - border-right-width: 0; -} - -.popover.left .arrow:after { - right: 1px; - bottom: -10px; - border-left-color: #ffffff; - border-right-width: 0; - content: " "; -} - -.carousel { - position: relative; -} - -.carousel-inner { - position: relative; - width: 100%; - overflow: hidden; -} - -.carousel-inner > .item { - position: relative; - display: none; - -webkit-transition: 0.6s ease-in-out left; - transition: 0.6s ease-in-out left; -} - -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - display: block; - height: auto; - max-width: 100%; - line-height: 1; -} - -.carousel-inner > .active, -.carousel-inner > .next, -.carousel-inner > .prev { - display: block; -} - -.carousel-inner > .active { - left: 0; -} - -.carousel-inner > .next, -.carousel-inner > .prev { - position: absolute; - top: 0; - width: 100%; -} - -.carousel-inner > .next { - left: 100%; -} - -.carousel-inner > .prev { - left: -100%; -} - -.carousel-inner > .next.left, -.carousel-inner > .prev.right { - left: 0; -} - -.carousel-inner > .active.left { - left: -100%; -} - -.carousel-inner > .active.right { - left: 100%; -} - -.carousel-control { - position: absolute; - top: 0; - bottom: 0; - left: 0; - width: 15%; - font-size: 20px; - color: #ffffff; - text-align: center; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); - opacity: 0.5; - filter: alpha(opacity=50); -} - -.carousel-control.left { - background-image: -webkit-gradient(linear, 0 top, 100% top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0.0001))); - background-image: -webkit-linear-gradient(left, color-stop(rgba(0, 0, 0, 0.5) 0), color-stop(rgba(0, 0, 0, 0.0001) 100%)); - background-image: -moz-linear-gradient(left, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0.0001) 100%); - background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0.0001) 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1); -} - -.carousel-control.right { - right: 0; - left: auto; - background-image: -webkit-gradient(linear, 0 top, 100% top, from(rgba(0, 0, 0, 0.0001)), to(rgba(0, 0, 0, 0.5))); - background-image: -webkit-linear-gradient(left, color-stop(rgba(0, 0, 0, 0.0001) 0), color-stop(rgba(0, 0, 0, 0.5) 100%)); - background-image: -moz-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0, rgba(0, 0, 0, 0.5) 100%); - background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0, rgba(0, 0, 0, 0.5) 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1); -} - -.carousel-control:hover, -.carousel-control:focus { - color: #ffffff; - text-decoration: none; - opacity: 0.9; - filter: alpha(opacity=90); -} - -.carousel-control .icon-prev, -.carousel-control .icon-next, -.carousel-control .glyphicon-chevron-left, -.carousel-control .glyphicon-chevron-right { - position: absolute; - top: 50%; - left: 50%; - z-index: 5; - display: inline-block; -} - -.carousel-control .icon-prev, -.carousel-control .icon-next { - width: 20px; - height: 20px; - margin-top: -10px; - margin-left: -10px; - font-family: serif; -} - -.carousel-control .icon-prev:before { - content: '\2039'; -} - -.carousel-control .icon-next:before { - content: '\203a'; -} - -.carousel-indicators { - position: absolute; - bottom: 10px; - left: 50%; - z-index: 15; - width: 60%; - padding-left: 0; - margin-left: -30%; - text-align: center; - list-style: none; -} - -.carousel-indicators li { - display: inline-block; - width: 10px; - height: 10px; - margin: 1px; - text-indent: -999px; - cursor: pointer; - border: 1px solid #ffffff; - border-radius: 10px; -} - -.carousel-indicators .active { - width: 12px; - height: 12px; - margin: 0; - background-color: #ffffff; -} - -.carousel-caption { - position: absolute; - right: 15%; - bottom: 20px; - left: 15%; - z-index: 10; - padding-top: 20px; - padding-bottom: 20px; - color: #ffffff; - text-align: center; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); -} - -.carousel-caption .btn { - text-shadow: none; -} - -@media screen and (min-width: 768px) { - .carousel-control .icon-prev, - .carousel-control .icon-next { - width: 30px; - height: 30px; - margin-top: -15px; - margin-left: -15px; - font-size: 30px; - } - .carousel-caption { - right: 20%; - left: 20%; - padding-bottom: 30px; - } - .carousel-indicators { - bottom: 20px; - } -} - -.clearfix:before, -.clearfix:after { - display: table; - content: " "; -} - -.clearfix:after { - clear: both; -} - -.pull-right { - float: right !important; -} - -.pull-left { - float: left !important; -} - -.hide { - display: none !important; -} - -.show { - display: block !important; -} - -.invisible { - visibility: hidden; -} - -.text-hide { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} - -.affix { - position: fixed; -} - -@-ms-viewport { - width: device-width; -} - -@media screen and (max-width: 400px) { - @-ms-viewport { - width: 320px; - } -} - -.hidden { - display: none !important; - visibility: hidden !important; -} - -.visible-xs { - display: none !important; -} - -tr.visible-xs { - display: none !important; -} - -th.visible-xs, -td.visible-xs { - display: none !important; -} - -@media (max-width: 767px) { - .visible-xs { - display: block !important; - } - tr.visible-xs { - display: table-row !important; - } - th.visible-xs, - td.visible-xs { - display: table-cell !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .visible-xs.visible-sm { - display: block !important; - } - tr.visible-xs.visible-sm { - display: table-row !important; - } - th.visible-xs.visible-sm, - td.visible-xs.visible-sm { - display: table-cell !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .visible-xs.visible-md { - display: block !important; - } - tr.visible-xs.visible-md { - display: table-row !important; - } - th.visible-xs.visible-md, - td.visible-xs.visible-md { - display: table-cell !important; - } -} - -@media (min-width: 1200px) { - .visible-xs.visible-lg { - display: block !important; - } - tr.visible-xs.visible-lg { - display: table-row !important; - } - th.visible-xs.visible-lg, - td.visible-xs.visible-lg { - display: table-cell !important; - } -} - -.visible-sm { - display: none !important; -} - -tr.visible-sm { - display: none !important; -} - -th.visible-sm, -td.visible-sm { - display: none !important; -} - -@media (max-width: 767px) { - .visible-sm.visible-xs { - display: block !important; - } - tr.visible-sm.visible-xs { - display: table-row !important; - } - th.visible-sm.visible-xs, - td.visible-sm.visible-xs { - display: table-cell !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm { - display: block !important; - } - tr.visible-sm { - display: table-row !important; - } - th.visible-sm, - td.visible-sm { - display: table-cell !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .visible-sm.visible-md { - display: block !important; - } - tr.visible-sm.visible-md { - display: table-row !important; - } - th.visible-sm.visible-md, - td.visible-sm.visible-md { - display: table-cell !important; - } -} - -@media (min-width: 1200px) { - .visible-sm.visible-lg { - display: block !important; - } - tr.visible-sm.visible-lg { - display: table-row !important; - } - th.visible-sm.visible-lg, - td.visible-sm.visible-lg { - display: table-cell !important; - } -} - -.visible-md { - display: none !important; -} - -tr.visible-md { - display: none !important; -} - -th.visible-md, -td.visible-md { - display: none !important; -} - -@media (max-width: 767px) { - .visible-md.visible-xs { - display: block !important; - } - tr.visible-md.visible-xs { - display: table-row !important; - } - th.visible-md.visible-xs, - td.visible-md.visible-xs { - display: table-cell !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .visible-md.visible-sm { - display: block !important; - } - tr.visible-md.visible-sm { - display: table-row !important; - } - th.visible-md.visible-sm, - td.visible-md.visible-sm { - display: table-cell !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md { - display: block !important; - } - tr.visible-md { - display: table-row !important; - } - th.visible-md, - td.visible-md { - display: table-cell !important; - } -} - -@media (min-width: 1200px) { - .visible-md.visible-lg { - display: block !important; - } - tr.visible-md.visible-lg { - display: table-row !important; - } - th.visible-md.visible-lg, - td.visible-md.visible-lg { - display: table-cell !important; - } -} - -.visible-lg { - display: none !important; -} - -tr.visible-lg { - display: none !important; -} - -th.visible-lg, -td.visible-lg { - display: none !important; -} - -@media (max-width: 767px) { - .visible-lg.visible-xs { - display: block !important; - } - tr.visible-lg.visible-xs { - display: table-row !important; - } - th.visible-lg.visible-xs, - td.visible-lg.visible-xs { - display: table-cell !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .visible-lg.visible-sm { - display: block !important; - } - tr.visible-lg.visible-sm { - display: table-row !important; - } - th.visible-lg.visible-sm, - td.visible-lg.visible-sm { - display: table-cell !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .visible-lg.visible-md { - display: block !important; - } - tr.visible-lg.visible-md { - display: table-row !important; - } - th.visible-lg.visible-md, - td.visible-lg.visible-md { - display: table-cell !important; - } -} - -@media (min-width: 1200px) { - .visible-lg { - display: block !important; - } - tr.visible-lg { - display: table-row !important; - } - th.visible-lg, - td.visible-lg { - display: table-cell !important; - } -} - -.hidden-xs { - display: block !important; -} - -tr.hidden-xs { - display: table-row !important; -} - -th.hidden-xs, -td.hidden-xs { - display: table-cell !important; -} - -@media (max-width: 767px) { - .hidden-xs { - display: none !important; - } - tr.hidden-xs { - display: none !important; - } - th.hidden-xs, - td.hidden-xs { - display: none !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .hidden-xs.hidden-sm { - display: none !important; - } - tr.hidden-xs.hidden-sm { - display: none !important; - } - th.hidden-xs.hidden-sm, - td.hidden-xs.hidden-sm { - display: none !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .hidden-xs.hidden-md { - display: none !important; - } - tr.hidden-xs.hidden-md { - display: none !important; - } - th.hidden-xs.hidden-md, - td.hidden-xs.hidden-md { - display: none !important; - } -} - -@media (min-width: 1200px) { - .hidden-xs.hidden-lg { - display: none !important; - } - tr.hidden-xs.hidden-lg { - display: none !important; - } - th.hidden-xs.hidden-lg, - td.hidden-xs.hidden-lg { - display: none !important; - } -} - -.hidden-sm { - display: block !important; -} - -tr.hidden-sm { - display: table-row !important; -} - -th.hidden-sm, -td.hidden-sm { - display: table-cell !important; -} - -@media (max-width: 767px) { - .hidden-sm.hidden-xs { - display: none !important; - } - tr.hidden-sm.hidden-xs { - display: none !important; - } - th.hidden-sm.hidden-xs, - td.hidden-sm.hidden-xs { - display: none !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .hidden-sm { - display: none !important; - } - tr.hidden-sm { - display: none !important; - } - th.hidden-sm, - td.hidden-sm { - display: none !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .hidden-sm.hidden-md { - display: none !important; - } - tr.hidden-sm.hidden-md { - display: none !important; - } - th.hidden-sm.hidden-md, - td.hidden-sm.hidden-md { - display: none !important; - } -} - -@media (min-width: 1200px) { - .hidden-sm.hidden-lg { - display: none !important; - } - tr.hidden-sm.hidden-lg { - display: none !important; - } - th.hidden-sm.hidden-lg, - td.hidden-sm.hidden-lg { - display: none !important; - } -} - -.hidden-md { - display: block !important; -} - -tr.hidden-md { - display: table-row !important; -} - -th.hidden-md, -td.hidden-md { - display: table-cell !important; -} - -@media (max-width: 767px) { - .hidden-md.hidden-xs { - display: none !important; - } - tr.hidden-md.hidden-xs { - display: none !important; - } - th.hidden-md.hidden-xs, - td.hidden-md.hidden-xs { - display: none !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .hidden-md.hidden-sm { - display: none !important; - } - tr.hidden-md.hidden-sm { - display: none !important; - } - th.hidden-md.hidden-sm, - td.hidden-md.hidden-sm { - display: none !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .hidden-md { - display: none !important; - } - tr.hidden-md { - display: none !important; - } - th.hidden-md, - td.hidden-md { - display: none !important; - } -} - -@media (min-width: 1200px) { - .hidden-md.hidden-lg { - display: none !important; - } - tr.hidden-md.hidden-lg { - display: none !important; - } - th.hidden-md.hidden-lg, - td.hidden-md.hidden-lg { - display: none !important; - } -} - -.hidden-lg { - display: block !important; -} - -tr.hidden-lg { - display: table-row !important; -} - -th.hidden-lg, -td.hidden-lg { - display: table-cell !important; -} - -@media (max-width: 767px) { - .hidden-lg.hidden-xs { - display: none !important; - } - tr.hidden-lg.hidden-xs { - display: none !important; - } - th.hidden-lg.hidden-xs, - td.hidden-lg.hidden-xs { - display: none !important; - } -} - -@media (min-width: 768px) and (max-width: 991px) { - .hidden-lg.hidden-sm { - display: none !important; - } - tr.hidden-lg.hidden-sm { - display: none !important; - } - th.hidden-lg.hidden-sm, - td.hidden-lg.hidden-sm { - display: none !important; - } -} - -@media (min-width: 992px) and (max-width: 1199px) { - .hidden-lg.hidden-md { - display: none !important; - } - tr.hidden-lg.hidden-md { - display: none !important; - } - th.hidden-lg.hidden-md, - td.hidden-lg.hidden-md { - display: none !important; - } -} - -@media (min-width: 1200px) { - .hidden-lg { - display: none !important; - } - tr.hidden-lg { - display: none !important; - } - th.hidden-lg, - td.hidden-lg { - display: none !important; - } -} - -.visible-print { - display: none !important; -} - -tr.visible-print { - display: none !important; -} - -th.visible-print, -td.visible-print { - display: none !important; -} - -@media print { - .visible-print { - display: block !important; - } - tr.visible-print { - display: table-row !important; - } - th.visible-print, - td.visible-print { - display: table-cell !important; - } - .hidden-print { - display: none !important; - } - tr.hidden-print { - display: none !important; - } - th.hidden-print, - td.hidden-print { - display: none !important; - } -} \ No newline at end of file diff --git a/vendor/github.com/gocql/gocql/website/css/bootstrap.min.css b/vendor/github.com/gocql/gocql/website/css/bootstrap.min.css deleted file mode 100644 index a553c4f5e..000000000 --- a/vendor/github.com/gocql/gocql/website/css/bootstrap.min.css +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * Bootstrap v3.0.0 - * - * Copyright 2013 Twitter, Inc - * Licensed under the Apache License v2.0 - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Designed and built with all the love in the world by @mdo and @fat. - *//*! normalize.css v2.1.0 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{margin:.67em 0;font-size:2em}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{height:0;-moz-box-sizing:content-box;box-sizing:content-box}mark{color:#000;background:#ff0}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid #c0c0c0}legend{padding:0;border:0}button,input,select,textarea{margin:0;font-family:inherit;font-size:100%}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{padding:0;box-sizing:border-box}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:2cm .5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.table td,.table th{background-color:#fff!important}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table-bordered th,.table-bordered td{border:1px solid #ddd!important}}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:62.5%;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.428571429;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}button,input,select[multiple],textarea{background-image:none}a{color:#428bca;text-decoration:none}a:hover,a:focus{color:#2a6496;text-decoration:underline}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}img{vertical-align:middle}.img-responsive{display:block;height:auto;max-width:100%}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;height:auto;max-width:100%;padding:4px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);border:0}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16.099999999999998px;font-weight:200;line-height:1.4}@media(min-width:768px){.lead{font-size:21px}}small{font-size:85%}cite{font-style:normal}.text-muted{color:#999}.text-primary{color:#428bca}.text-warning{color:#c09853}.text-danger{color:#b94a48}.text-success{color:#468847}.text-info{color:#3a87ad}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-weight:500;line-height:1.1}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{margin-top:20px;margin-bottom:10px}h4,h5,h6{margin-top:10px;margin-bottom:10px}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}h1 small,.h1 small{font-size:24px}h2 small,.h2 small{font-size:18px}h3 small,.h3 small,h4 small,.h4 small{font-size:14px}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}dl{margin-bottom:20px}dt,dd{line-height:1.428571429}dt{font-weight:bold}dd{margin-left:0}@media(min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{font-size:17.5px;font-weight:300;line-height:1.25}blockquote p:last-child{margin-bottom:0}blockquote small{display:block;line-height:1.428571429;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}blockquote.pull-right small:before{content:''}blockquote.pull-right small:after{content:'\00A0 \2014'}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:20px;font-style:normal;line-height:1.428571429}code,pre{font-family:Monaco,Menlo,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;white-space:nowrap;background-color:#f9f2f4;border-radius:4px}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.428571429;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre.prettyprint{margin-bottom:20px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.row{margin-right:-15px;margin-left:-15px}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11{float:left}.col-xs-1{width:8.333333333333332%}.col-xs-2{width:16.666666666666664%}.col-xs-3{width:25%}.col-xs-4{width:33.33333333333333%}.col-xs-5{width:41.66666666666667%}.col-xs-6{width:50%}.col-xs-7{width:58.333333333333336%}.col-xs-8{width:66.66666666666666%}.col-xs-9{width:75%}.col-xs-10{width:83.33333333333334%}.col-xs-11{width:91.66666666666666%}.col-xs-12{width:100%}@media(min-width:768px){.container{max-width:750px}.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11{float:left}.col-sm-1{width:8.333333333333332%}.col-sm-2{width:16.666666666666664%}.col-sm-3{width:25%}.col-sm-4{width:33.33333333333333%}.col-sm-5{width:41.66666666666667%}.col-sm-6{width:50%}.col-sm-7{width:58.333333333333336%}.col-sm-8{width:66.66666666666666%}.col-sm-9{width:75%}.col-sm-10{width:83.33333333333334%}.col-sm-11{width:91.66666666666666%}.col-sm-12{width:100%}.col-sm-push-1{left:8.333333333333332%}.col-sm-push-2{left:16.666666666666664%}.col-sm-push-3{left:25%}.col-sm-push-4{left:33.33333333333333%}.col-sm-push-5{left:41.66666666666667%}.col-sm-push-6{left:50%}.col-sm-push-7{left:58.333333333333336%}.col-sm-push-8{left:66.66666666666666%}.col-sm-push-9{left:75%}.col-sm-push-10{left:83.33333333333334%}.col-sm-push-11{left:91.66666666666666%}.col-sm-pull-1{right:8.333333333333332%}.col-sm-pull-2{right:16.666666666666664%}.col-sm-pull-3{right:25%}.col-sm-pull-4{right:33.33333333333333%}.col-sm-pull-5{right:41.66666666666667%}.col-sm-pull-6{right:50%}.col-sm-pull-7{right:58.333333333333336%}.col-sm-pull-8{right:66.66666666666666%}.col-sm-pull-9{right:75%}.col-sm-pull-10{right:83.33333333333334%}.col-sm-pull-11{right:91.66666666666666%}.col-sm-offset-1{margin-left:8.333333333333332%}.col-sm-offset-2{margin-left:16.666666666666664%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-4{margin-left:33.33333333333333%}.col-sm-offset-5{margin-left:41.66666666666667%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-7{margin-left:58.333333333333336%}.col-sm-offset-8{margin-left:66.66666666666666%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-10{margin-left:83.33333333333334%}.col-sm-offset-11{margin-left:91.66666666666666%}}@media(min-width:992px){.container{max-width:970px}.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11{float:left}.col-md-1{width:8.333333333333332%}.col-md-2{width:16.666666666666664%}.col-md-3{width:25%}.col-md-4{width:33.33333333333333%}.col-md-5{width:41.66666666666667%}.col-md-6{width:50%}.col-md-7{width:58.333333333333336%}.col-md-8{width:66.66666666666666%}.col-md-9{width:75%}.col-md-10{width:83.33333333333334%}.col-md-11{width:91.66666666666666%}.col-md-12{width:100%}.col-md-push-0{left:auto}.col-md-push-1{left:8.333333333333332%}.col-md-push-2{left:16.666666666666664%}.col-md-push-3{left:25%}.col-md-push-4{left:33.33333333333333%}.col-md-push-5{left:41.66666666666667%}.col-md-push-6{left:50%}.col-md-push-7{left:58.333333333333336%}.col-md-push-8{left:66.66666666666666%}.col-md-push-9{left:75%}.col-md-push-10{left:83.33333333333334%}.col-md-push-11{left:91.66666666666666%}.col-md-pull-0{right:auto}.col-md-pull-1{right:8.333333333333332%}.col-md-pull-2{right:16.666666666666664%}.col-md-pull-3{right:25%}.col-md-pull-4{right:33.33333333333333%}.col-md-pull-5{right:41.66666666666667%}.col-md-pull-6{right:50%}.col-md-pull-7{right:58.333333333333336%}.col-md-pull-8{right:66.66666666666666%}.col-md-pull-9{right:75%}.col-md-pull-10{right:83.33333333333334%}.col-md-pull-11{right:91.66666666666666%}.col-md-offset-0{margin-left:0}.col-md-offset-1{margin-left:8.333333333333332%}.col-md-offset-2{margin-left:16.666666666666664%}.col-md-offset-3{margin-left:25%}.col-md-offset-4{margin-left:33.33333333333333%}.col-md-offset-5{margin-left:41.66666666666667%}.col-md-offset-6{margin-left:50%}.col-md-offset-7{margin-left:58.333333333333336%}.col-md-offset-8{margin-left:66.66666666666666%}.col-md-offset-9{margin-left:75%}.col-md-offset-10{margin-left:83.33333333333334%}.col-md-offset-11{margin-left:91.66666666666666%}}@media(min-width:1200px){.container{max-width:1170px}.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11{float:left}.col-lg-1{width:8.333333333333332%}.col-lg-2{width:16.666666666666664%}.col-lg-3{width:25%}.col-lg-4{width:33.33333333333333%}.col-lg-5{width:41.66666666666667%}.col-lg-6{width:50%}.col-lg-7{width:58.333333333333336%}.col-lg-8{width:66.66666666666666%}.col-lg-9{width:75%}.col-lg-10{width:83.33333333333334%}.col-lg-11{width:91.66666666666666%}.col-lg-12{width:100%}.col-lg-push-0{left:auto}.col-lg-push-1{left:8.333333333333332%}.col-lg-push-2{left:16.666666666666664%}.col-lg-push-3{left:25%}.col-lg-push-4{left:33.33333333333333%}.col-lg-push-5{left:41.66666666666667%}.col-lg-push-6{left:50%}.col-lg-push-7{left:58.333333333333336%}.col-lg-push-8{left:66.66666666666666%}.col-lg-push-9{left:75%}.col-lg-push-10{left:83.33333333333334%}.col-lg-push-11{left:91.66666666666666%}.col-lg-pull-0{right:auto}.col-lg-pull-1{right:8.333333333333332%}.col-lg-pull-2{right:16.666666666666664%}.col-lg-pull-3{right:25%}.col-lg-pull-4{right:33.33333333333333%}.col-lg-pull-5{right:41.66666666666667%}.col-lg-pull-6{right:50%}.col-lg-pull-7{right:58.333333333333336%}.col-lg-pull-8{right:66.66666666666666%}.col-lg-pull-9{right:75%}.col-lg-pull-10{right:83.33333333333334%}.col-lg-pull-11{right:91.66666666666666%}.col-lg-offset-0{margin-left:0}.col-lg-offset-1{margin-left:8.333333333333332%}.col-lg-offset-2{margin-left:16.666666666666664%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-4{margin-left:33.33333333333333%}.col-lg-offset-5{margin-left:41.66666666666667%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-7{margin-left:58.333333333333336%}.col-lg-offset-8{margin-left:66.66666666666666%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-10{margin-left:83.33333333333334%}.col-lg-offset-11{margin-left:91.66666666666666%}}table{max-width:100%;background-color:transparent}th{text-align:left}.table{width:100%;margin-bottom:20px}.table thead>tr>th,.table tbody>tr>th,.table tfoot>tr>th,.table thead>tr>td,.table tbody>tr>td,.table tfoot>tr>td{padding:8px;line-height:1.428571429;vertical-align:top;border-top:1px solid #ddd}.table thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table caption+thead tr:first-child th,.table colgroup+thead tr:first-child th,.table thead:first-child tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed thead>tr>th,.table-condensed tbody>tr>th,.table-condensed tfoot>tr>th,.table-condensed thead>tr>td,.table-condensed tbody>tr>td,.table-condensed tfoot>tr>td{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}.table-striped>tbody>tr:nth-child(odd)>td,.table-striped>tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#f5f5f5}table col[class*="col-"]{display:table-column;float:none}table td[class*="col-"],table th[class*="col-"]{display:table-cell;float:none}.table>thead>tr>td.active,.table>tbody>tr>td.active,.table>tfoot>tr>td.active,.table>thead>tr>th.active,.table>tbody>tr>th.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>tbody>tr.active>td,.table>tfoot>tr.active>td,.table>thead>tr.active>th,.table>tbody>tr.active>th,.table>tfoot>tr.active>th{background-color:#f5f5f5}.table>thead>tr>td.success,.table>tbody>tr>td.success,.table>tfoot>tr>td.success,.table>thead>tr>th.success,.table>tbody>tr>th.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>tbody>tr.success>td,.table>tfoot>tr.success>td,.table>thead>tr.success>th,.table>tbody>tr.success>th,.table>tfoot>tr.success>th{background-color:#dff0d8;border-color:#d6e9c6}.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover,.table-hover>tbody>tr.success:hover>td{background-color:#d0e9c6;border-color:#c9e2b3}.table>thead>tr>td.danger,.table>tbody>tr>td.danger,.table>tfoot>tr>td.danger,.table>thead>tr>th.danger,.table>tbody>tr>th.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>tbody>tr.danger>td,.table>tfoot>tr.danger>td,.table>thead>tr.danger>th,.table>tbody>tr.danger>th,.table>tfoot>tr.danger>th{background-color:#f2dede;border-color:#eed3d7}.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover,.table-hover>tbody>tr.danger:hover>td{background-color:#ebcccc;border-color:#e6c1c7}.table>thead>tr>td.warning,.table>tbody>tr>td.warning,.table>tfoot>tr>td.warning,.table>thead>tr>th.warning,.table>tbody>tr>th.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>tbody>tr.warning>td,.table>tfoot>tr.warning>td,.table>thead>tr.warning>th,.table>tbody>tr.warning>th,.table>tfoot>tr.warning>th{background-color:#fcf8e3;border-color:#fbeed5}.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover,.table-hover>tbody>tr.warning:hover>td{background-color:#faf2cc;border-color:#f8e5be}@media(max-width:768px){.table-responsive{width:100%;margin-bottom:15px;overflow-x:scroll;overflow-y:hidden;border:1px solid #ddd}.table-responsive>.table{margin-bottom:0;background-color:#fff}.table-responsive>.table>thead>tr>th,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tfoot>tr>td{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>thead>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>thead>tr:last-child>td,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;margin-bottom:5px;font-weight:bold}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type="file"]{display:block}select[multiple],select[size]{height:auto}select optgroup{font-family:inherit;font-size:inherit;font-style:inherit}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}input[type="number"]::-webkit-outer-spin-button,input[type="number"]::-webkit-inner-spin-button{height:auto}.form-control:-moz-placeholder{color:#999}.form-control::-moz-placeholder{color:#999}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle;background-color:#fff;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6)}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{cursor:not-allowed;background-color:#eee}textarea.form-control{height:auto}.form-group{margin-bottom:15px}.radio,.checkbox{display:block;min-height:20px;padding-left:20px;margin-top:10px;margin-bottom:10px;vertical-align:middle}.radio label,.checkbox label{display:inline;margin-bottom:0;font-weight:normal;cursor:pointer}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{float:left;margin-left:-20px}.radio+.radio,.checkbox+.checkbox{margin-top:-5px}.radio-inline,.checkbox-inline{display:inline-block;padding-left:20px;margin-bottom:0;font-weight:normal;vertical-align:middle;cursor:pointer}.radio-inline+.radio-inline,.checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}input[type="radio"][disabled],input[type="checkbox"][disabled],.radio[disabled],.radio-inline[disabled],.checkbox[disabled],.checkbox-inline[disabled],fieldset[disabled] input[type="radio"],fieldset[disabled] input[type="checkbox"],fieldset[disabled] .radio,fieldset[disabled] .radio-inline,fieldset[disabled] .checkbox,fieldset[disabled] .checkbox-inline{cursor:not-allowed}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}textarea.input-sm{height:auto}.input-lg{height:45px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-lg{height:45px;line-height:45px}textarea.input-lg{height:auto}.has-warning .help-block,.has-warning .control-label{color:#c09853}.has-warning .form-control{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-warning .form-control:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.has-warning .input-group-addon{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.has-error .help-block,.has-error .control-label{color:#b94a48}.has-error .form-control{border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-error .form-control:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392}.has-error .input-group-addon{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.has-success .help-block,.has-success .control-label{color:#468847}.has-success .form-control{border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-success .form-control:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b}.has-success .input-group-addon{color:#468847;background-color:#dff0d8;border-color:#468847}.form-control-static{padding-top:7px;margin-bottom:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media(min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block}.form-inline .radio,.form-inline .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:none;margin-left:0}}.form-horizontal .control-label,.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}@media(min-width:768px){.form-horizontal .control-label{text-align:right}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.428571429;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;border:1px solid transparent;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus{color:#333;text-decoration:none}.btn:active,.btn.active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:hover,.btn-default:focus,.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{color:#333;background-color:#ebebeb;border-color:#adadad}.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default[disabled],fieldset[disabled] .btn-default,.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled:active,.btn-default[disabled]:active,fieldset[disabled] .btn-default:active,.btn-default.disabled.active,.btn-default[disabled].active,fieldset[disabled] .btn-default.active{background-color:#fff;border-color:#ccc}.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{color:#fff;background-color:#3276b1;border-color:#285e8e}.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary[disabled],fieldset[disabled] .btn-primary,.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled:active,.btn-primary[disabled]:active,fieldset[disabled] .btn-primary:active,.btn-primary.disabled.active,.btn-primary[disabled].active,fieldset[disabled] .btn-primary.active{background-color:#428bca;border-color:#357ebd}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{color:#fff;background-color:#ed9c28;border-color:#d58512}.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-warning,.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled:active,.btn-warning[disabled]:active,fieldset[disabled] .btn-warning:active,.btn-warning.disabled.active,.btn-warning[disabled].active,fieldset[disabled] .btn-warning.active{background-color:#f0ad4e;border-color:#eea236}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{color:#fff;background-color:#d2322d;border-color:#ac2925}.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger[disabled],fieldset[disabled] .btn-danger,.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled:active,.btn-danger[disabled]:active,fieldset[disabled] .btn-danger:active,.btn-danger.disabled.active,.btn-danger[disabled].active,fieldset[disabled] .btn-danger.active{background-color:#d9534f;border-color:#d43f3a}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{color:#fff;background-color:#47a447;border-color:#398439}.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success[disabled],fieldset[disabled] .btn-success,.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled:active,.btn-success[disabled]:active,fieldset[disabled] .btn-success:active,.btn-success.disabled.active,.btn-success[disabled].active,fieldset[disabled] .btn-success.active{background-color:#5cb85c;border-color:#4cae4c}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{color:#fff;background-color:#39b3d7;border-color:#269abc}.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info[disabled],fieldset[disabled] .btn-info,.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled:active,.btn-info[disabled]:active,fieldset[disabled] .btn-info:active,.btn-info.disabled.active,.btn-info[disabled].active,fieldset[disabled] .btn-info.active{background-color:#5bc0de;border-color:#46b8da}.btn-link{font-weight:normal;color:#428bca;cursor:pointer;border-radius:0}.btn-link,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#2a6496;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#999;text-decoration:none}.btn-lg{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-sm,.btn-xs{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-xs{padding:1px 5px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;transition:height .35s ease}@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';-webkit-font-smoothing:antialiased;font-style:normal;font-weight:normal;line-height:1}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-print:before{content:"\e045"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.glyphicon-briefcase:before{content:"\1f4bc"}.glyphicon-calendar:before{content:"\1f4c5"}.glyphicon-pushpin:before{content:"\1f4cc"}.glyphicon-paperclip:before{content:"\1f4ce"}.glyphicon-camera:before{content:"\1f4f7"}.glyphicon-lock:before{content:"\1f512"}.glyphicon-bell:before{content:"\1f514"}.glyphicon-bookmark:before{content:"\1f516"}.glyphicon-fire:before{content:"\1f525"}.glyphicon-wrench:before{content:"\1f527"}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px solid #000;border-right:4px solid transparent;border-bottom:0 dotted;border-left:4px solid transparent;content:""}.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.428571429;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{color:#fff;text-decoration:none;background-color:#428bca}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#428bca;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.428571429;color:#999}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0 dotted;border-bottom:4px solid #000;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}@media(min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}}.btn-default .caret{border-top-color:#333}.btn-primary .caret,.btn-success .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret{border-top-color:#fff}.dropup .btn-default .caret{border-bottom-color:#333}.dropup .btn-primary .caret,.dropup .btn-success .caret,.dropup .btn-warning .caret,.dropup .btn-danger .caret,.dropup .btn-info .caret{border-bottom-color:#fff}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;float:left}.btn-group>.btn:hover,.btn-group-vertical>.btn:hover,.btn-group>.btn:focus,.btn-group-vertical>.btn:focus,.btn-group>.btn:active,.btn-group-vertical>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn.active{z-index:2}.btn-group>.btn:focus,.btn-group-vertical>.btn:focus{outline:0}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar .btn-group{float:left}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group,.btn-toolbar>.btn-group+.btn-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child>.btn:last-child,.btn-group>.btn-group:first-child>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group-xs>.btn{padding:5px 10px;padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-sm>.btn{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-lg>.btn{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-bottom-left-radius:4px;border-top-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child>.btn:last-child,.btn-group-vertical>.btn-group:first-child>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.btn-group-justified{display:table;width:100%;border-collapse:separate;table-layout:fixed}.btn-group-justified .btn{display:table-cell;float:none;width:1%}[data-toggle="buttons"]>.btn>input[type="radio"],[data-toggle="buttons"]>.btn>input[type="checkbox"]{display:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group.col{float:none;padding-right:0;padding-left:0}.input-group .form-control{width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:45px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:45px;line-height:45px}textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:normal;line-height:1;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type="radio"],.input-group-addon input[type="checkbox"]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:last-child>.btn,.input-group-btn:last-child>.dropdown-toggle,.input-group-btn:first-child>.btn:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;white-space:nowrap}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-4px}.input-group-btn>.btn:hover,.input-group-btn>.btn:active{z-index:2}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#999}.nav>li.disabled>a:hover,.nav>li.disabled>a:focus{color:#999;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:hover,.nav .open>a:focus{background-color:#eee;border-color:#428bca}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.428571429;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{text-align:center}@media(min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}}.nav-tabs.nav-justified>li>a{margin-right:0;border-bottom:1px solid #ddd}.nav-tabs.nav-justified>.active>a{border-bottom-color:#fff}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:5px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:hover,.nav-pills>li.active>a:focus{color:#fff;background-color:#428bca}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{text-align:center}@media(min-width:768px){.nav-justified>li{display:table-cell;width:1%}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-bottom:1px solid #ddd}.nav-tabs-justified>.active>a{border-bottom-color:#fff}.tabbable:before,.tabbable:after{display:table;content:" "}.tabbable:after{clear:both}.tabbable:before,.tabbable:after{display:table;content:" "}.tabbable:after{clear:both}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.nav .caret{border-top-color:#428bca;border-bottom-color:#428bca}.nav a:hover .caret{border-top-color:#2a6496;border-bottom-color:#2a6496}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.navbar{position:relative;z-index:1000;min-height:50px;margin-bottom:20px;border:1px solid transparent}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}@media(min-width:768px){.navbar{border-radius:4px}}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}@media(min-width:768px){.navbar-header{float:left}}.navbar-collapse{max-height:340px;padding-right:15px;padding-left:15px;overflow-x:visible;border-top:1px solid transparent;box-shadow:inset 0 1px 0 rgba(255,255,255,0.1);-webkit-overflow-scrolling:touch}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse.in{overflow-y:auto}@media(min-width:768px){.navbar-collapse{width:auto;border-top:0;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:visible}.navbar-collapse .navbar-nav.navbar-left:first-child{margin-left:-15px}.navbar-collapse .navbar-nav.navbar-right:last-child{margin-right:-15px}.navbar-collapse .navbar-text:last-child{margin-right:0}}.container>.navbar-header,.container>.navbar-collapse{margin-right:-15px;margin-left:-15px}@media(min-width:768px){.container>.navbar-header,.container>.navbar-collapse{margin-right:0;margin-left:0}}.navbar-static-top{border-width:0 0 1px}@media(min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;border-width:0 0 1px}@media(min-width:768px){.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}}.navbar-fixed-top{top:0;z-index:1030}.navbar-fixed-bottom{bottom:0;margin-bottom:0}.navbar-brand{float:left;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:hover,.navbar-brand:focus{text-decoration:none}@media(min-width:768px){.navbar>.container .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;border:1px solid transparent;border-radius:4px}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media(min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media(max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;box-shadow:none}.navbar-nav .open .dropdown-menu>li>a,.navbar-nav .open .dropdown-menu .dropdown-header{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:hover,.navbar-nav .open .dropdown-menu>li>a:focus{background-image:none}}@media(min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}}@media(min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}@media(min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block}.navbar-form .radio,.navbar-form .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.navbar-form .radio input[type="radio"],.navbar-form .checkbox input[type="checkbox"]{float:none;margin-left:0}}@media(max-width:767px){.navbar-form .form-group{margin-bottom:5px}}@media(min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-right-radius:0;border-top-left-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-nav.pull-right>li>.dropdown-menu,.navbar-nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-text{float:left;margin-top:15px;margin-bottom:15px}@media(min-width:768px){.navbar-text{margin-right:15px;margin-left:15px}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:hover,.navbar-default .navbar-brand:focus{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:hover,.navbar-default .navbar-nav>.disabled>a:focus{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#ccc}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e6e6e6}.navbar-default .navbar-nav>.dropdown>a:hover .caret,.navbar-default .navbar-nav>.dropdown>a:focus .caret{border-top-color:#333;border-bottom-color:#333}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.open>a .caret,.navbar-default .navbar-nav>.open>a:hover .caret,.navbar-default .navbar-nav>.open>a:focus .caret{border-top-color:#555;border-bottom-color:#555}.navbar-default .navbar-nav>.dropdown>a .caret{border-top-color:#777;border-bottom-color:#777}@media(max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#999}.navbar-inverse .navbar-brand:hover,.navbar-inverse .navbar-brand:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .navbar-nav>li>a{color:#999}.navbar-inverse .navbar-nav>li>a:hover,.navbar-inverse .navbar-nav>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-nav>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:hover,.navbar-inverse .navbar-nav>.disabled>a:focus{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:hover,.navbar-inverse .navbar-toggle:focus{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.dropdown>a:hover .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .navbar-nav>.dropdown>a .caret{border-top-color:#999;border-bottom-color:#999}.navbar-inverse .navbar-nav>.open>a .caret,.navbar-inverse .navbar-nav>.open>a:hover .caret,.navbar-inverse .navbar-nav>.open>a:focus .caret{border-top-color:#fff;border-bottom-color:#fff}@media(max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#999}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#999}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.428571429;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-bottom-left-radius:4px;border-top-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#eee}.pagination>.active>a,.pagination>.active>span,.pagination>.active>a:hover,.pagination>.active>span:hover,.pagination>.active>a:focus,.pagination>.active>span:focus{z-index:2;color:#fff;cursor:default;background-color:#428bca;border-color:#428bca}.pagination>.disabled>span,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#999;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-bottom-left-radius:6px;border-top-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-bottom-left-radius:3px;border-top-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}.label[href]:hover,.label[href]:focus{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.label-default{background-color:#999}.label-default[href]:hover,.label-default[href]:focus{background-color:#808080}.label-primary{background-color:#428bca}.label-primary[href]:hover,.label-primary[href]:focus{background-color:#3071a9}.label-success{background-color:#5cb85c}.label-success[href]:hover,.label-success[href]:focus{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:hover,.label-info[href]:focus{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:hover,.label-warning[href]:focus{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:hover,.label-danger[href]:focus{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#999;border-radius:10px}.badge:empty{display:none}a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}.btn .badge{position:relative;top:-1px}a.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#428bca;background-color:#fff}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px;margin-bottom:30px;font-size:21px;font-weight:200;line-height:2.1428571435;color:inherit;background-color:#eee}.jumbotron h1{line-height:1;color:inherit}.jumbotron p{line-height:1.4}.container .jumbotron{border-radius:6px}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron{padding-right:60px;padding-left:60px}.jumbotron h1{font-size:63px}}.thumbnail{display:inline-block;display:block;height:auto;max-width:100%;padding:4px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.thumbnail>img{display:block;height:auto;max-width:100%}a.thumbnail:hover,a.thumbnail:focus{border-color:#428bca}.thumbnail>img{margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable{padding-right:35px}.alert-dismissable .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#356635}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#2d6987}.alert-warning{color:#c09853;background-color:#fcf8e3;border-color:#fbeed5}.alert-warning hr{border-top-color:#f8e5be}.alert-warning .alert-link{color:#a47e3c}.alert-danger{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-danger hr{border-top-color:#e6c1c7}.alert-danger .alert-link{color:#953b39}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;color:#fff;text-align:center;background-color:#428bca;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;transition:width .6s ease}.progress-striped .progress-bar{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-size:40px 40px}.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.media,.media-body{overflow:hidden;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:4px;border-top-left-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:hover,a.list-group-item:focus{text-decoration:none;background-color:#f5f5f5}.list-group-item.active,.list-group-item.active:hover,.list-group-item.active:focus{z-index:2;color:#fff;background-color:#428bca;border-color:#428bca}.list-group-item.active .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:hover .list-group-item-text,.list-group-item.active:focus .list-group-item-text{color:#e1edf7}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.05);box-shadow:0 1px 1px rgba(0,0,0,0.05)}.panel-body{padding:15px}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel>.list-group{margin-bottom:0}.panel>.list-group .list-group-item{border-width:1px 0}.panel>.list-group .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.panel>.list-group .list-group-item:last-child{border-bottom:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.panel>.table{margin-bottom:0}.panel>.panel-body+.table{border-top:1px solid #ddd}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-right-radius:3px;border-top-left-radius:3px}.panel-title{margin-top:0;margin-bottom:0;font-size:16px}.panel-title>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel-group .panel{margin-bottom:0;overflow:hidden;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse .panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse .panel-body{border-top-color:#ddd}.panel-default>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#428bca}.panel-primary>.panel-heading{color:#fff;background-color:#428bca;border-color:#428bca}.panel-primary>.panel-heading+.panel-collapse .panel-body{border-top-color:#428bca}.panel-primary>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#428bca}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse .panel-body{border-top-color:#d6e9c6}.panel-success>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#d6e9c6}.panel-warning{border-color:#fbeed5}.panel-warning>.panel-heading{color:#c09853;background-color:#fcf8e3;border-color:#fbeed5}.panel-warning>.panel-heading+.panel-collapse .panel-body{border-top-color:#fbeed5}.panel-warning>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#fbeed5}.panel-danger{border-color:#eed3d7}.panel-danger>.panel-heading{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.panel-danger>.panel-heading+.panel-collapse .panel-body{border-top-color:#eed3d7}.panel-danger>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#eed3d7}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse .panel-body{border-top-color:#bce8f1}.panel-info>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#bce8f1}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal-open{overflow:hidden}body.modal-open,.modal-open .navbar-fixed-top,.modal-open .navbar-fixed-bottom{margin-right:15px}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;display:none;overflow:auto;overflow-y:scroll}.modal.fade .modal-dialog{-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);transform:translate(0,-25%);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.modal-dialog{z-index:1050;width:auto;padding:10px;margin-right:auto;margin-left:auto}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);background-clip:padding-box}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1030;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{min-height:16.428571429px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.428571429}.modal-body{position:relative;padding:20px}.modal-footer{padding:19px 20px 20px;margin-top:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}@media screen and (min-width:768px){.modal-dialog{right:auto;left:50%;width:600px;padding-top:30px;padding-bottom:30px}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}}.tooltip{position:absolute;z-index:1030;display:block;font-size:12px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.9;filter:alpha(opacity=90)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-left .tooltip-arrow{bottom:0;left:5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-right .tooltip-arrow{right:5px;bottom:0;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-left .tooltip-arrow{top:0;left:5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-right .tooltip-arrow{top:0;right:5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0;content:" "}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0;content:" "}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0;content:" "}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0;content:" "}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;height:auto;max-width:100%;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6);opacity:.5;filter:alpha(opacity=50)}.carousel-control.left{background-image:-webkit-gradient(linear,0 top,100% top,from(rgba(0,0,0,0.5)),to(rgba(0,0,0,0.0001)));background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.5) 0),color-stop(rgba(0,0,0,0.0001) 100%));background-image:-moz-linear-gradient(left,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-image:linear-gradient(to right,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000',endColorstr='#00000000',GradientType=1)}.carousel-control.right{right:0;left:auto;background-image:-webkit-gradient(linear,0 top,100% top,from(rgba(0,0,0,0.0001)),to(rgba(0,0,0,0.5)));background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.0001) 0),color-stop(rgba(0,0,0,0.5) 100%));background-image:-moz-linear-gradient(left,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-image:linear-gradient(to right,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000',endColorstr='#80000000',GradientType=1)}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-control .icon-prev,.carousel-control .icon-next,.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right{position:absolute;top:50%;left:50%;z-index:5;display:inline-block}.carousel-control .icon-prev,.carousel-control .icon-next{width:20px;height:20px;margin-top:-10px;margin-left:-10px;font-family:serif}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .icon-prev,.carousel-control .icon-next{width:30px;height:30px;margin-top:-15px;margin-left:-15px;font-size:30px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.clearfix:before,.clearfix:after{display:table;content:" "}.clearfix:after{clear:both}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.affix{position:fixed}@-ms-viewport{width:device-width}@media screen and (max-width:400px){@-ms-viewport{width:320px}}.hidden{display:none!important;visibility:hidden!important}.visible-xs{display:none!important}tr.visible-xs{display:none!important}th.visible-xs,td.visible-xs{display:none!important}@media(max-width:767px){.visible-xs{display:block!important}tr.visible-xs{display:table-row!important}th.visible-xs,td.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-xs.visible-sm{display:block!important}tr.visible-xs.visible-sm{display:table-row!important}th.visible-xs.visible-sm,td.visible-xs.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-xs.visible-md{display:block!important}tr.visible-xs.visible-md{display:table-row!important}th.visible-xs.visible-md,td.visible-xs.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-xs.visible-lg{display:block!important}tr.visible-xs.visible-lg{display:table-row!important}th.visible-xs.visible-lg,td.visible-xs.visible-lg{display:table-cell!important}}.visible-sm{display:none!important}tr.visible-sm{display:none!important}th.visible-sm,td.visible-sm{display:none!important}@media(max-width:767px){.visible-sm.visible-xs{display:block!important}tr.visible-sm.visible-xs{display:table-row!important}th.visible-sm.visible-xs,td.visible-sm.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-sm{display:block!important}tr.visible-sm{display:table-row!important}th.visible-sm,td.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-sm.visible-md{display:block!important}tr.visible-sm.visible-md{display:table-row!important}th.visible-sm.visible-md,td.visible-sm.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-sm.visible-lg{display:block!important}tr.visible-sm.visible-lg{display:table-row!important}th.visible-sm.visible-lg,td.visible-sm.visible-lg{display:table-cell!important}}.visible-md{display:none!important}tr.visible-md{display:none!important}th.visible-md,td.visible-md{display:none!important}@media(max-width:767px){.visible-md.visible-xs{display:block!important}tr.visible-md.visible-xs{display:table-row!important}th.visible-md.visible-xs,td.visible-md.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-md.visible-sm{display:block!important}tr.visible-md.visible-sm{display:table-row!important}th.visible-md.visible-sm,td.visible-md.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-md{display:block!important}tr.visible-md{display:table-row!important}th.visible-md,td.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-md.visible-lg{display:block!important}tr.visible-md.visible-lg{display:table-row!important}th.visible-md.visible-lg,td.visible-md.visible-lg{display:table-cell!important}}.visible-lg{display:none!important}tr.visible-lg{display:none!important}th.visible-lg,td.visible-lg{display:none!important}@media(max-width:767px){.visible-lg.visible-xs{display:block!important}tr.visible-lg.visible-xs{display:table-row!important}th.visible-lg.visible-xs,td.visible-lg.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-lg.visible-sm{display:block!important}tr.visible-lg.visible-sm{display:table-row!important}th.visible-lg.visible-sm,td.visible-lg.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-lg.visible-md{display:block!important}tr.visible-lg.visible-md{display:table-row!important}th.visible-lg.visible-md,td.visible-lg.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-lg{display:block!important}tr.visible-lg{display:table-row!important}th.visible-lg,td.visible-lg{display:table-cell!important}}.hidden-xs{display:block!important}tr.hidden-xs{display:table-row!important}th.hidden-xs,td.hidden-xs{display:table-cell!important}@media(max-width:767px){.hidden-xs{display:none!important}tr.hidden-xs{display:none!important}th.hidden-xs,td.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-xs.hidden-sm{display:none!important}tr.hidden-xs.hidden-sm{display:none!important}th.hidden-xs.hidden-sm,td.hidden-xs.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-xs.hidden-md{display:none!important}tr.hidden-xs.hidden-md{display:none!important}th.hidden-xs.hidden-md,td.hidden-xs.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-xs.hidden-lg{display:none!important}tr.hidden-xs.hidden-lg{display:none!important}th.hidden-xs.hidden-lg,td.hidden-xs.hidden-lg{display:none!important}}.hidden-sm{display:block!important}tr.hidden-sm{display:table-row!important}th.hidden-sm,td.hidden-sm{display:table-cell!important}@media(max-width:767px){.hidden-sm.hidden-xs{display:none!important}tr.hidden-sm.hidden-xs{display:none!important}th.hidden-sm.hidden-xs,td.hidden-sm.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-sm{display:none!important}tr.hidden-sm{display:none!important}th.hidden-sm,td.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-sm.hidden-md{display:none!important}tr.hidden-sm.hidden-md{display:none!important}th.hidden-sm.hidden-md,td.hidden-sm.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-sm.hidden-lg{display:none!important}tr.hidden-sm.hidden-lg{display:none!important}th.hidden-sm.hidden-lg,td.hidden-sm.hidden-lg{display:none!important}}.hidden-md{display:block!important}tr.hidden-md{display:table-row!important}th.hidden-md,td.hidden-md{display:table-cell!important}@media(max-width:767px){.hidden-md.hidden-xs{display:none!important}tr.hidden-md.hidden-xs{display:none!important}th.hidden-md.hidden-xs,td.hidden-md.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-md.hidden-sm{display:none!important}tr.hidden-md.hidden-sm{display:none!important}th.hidden-md.hidden-sm,td.hidden-md.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-md{display:none!important}tr.hidden-md{display:none!important}th.hidden-md,td.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-md.hidden-lg{display:none!important}tr.hidden-md.hidden-lg{display:none!important}th.hidden-md.hidden-lg,td.hidden-md.hidden-lg{display:none!important}}.hidden-lg{display:block!important}tr.hidden-lg{display:table-row!important}th.hidden-lg,td.hidden-lg{display:table-cell!important}@media(max-width:767px){.hidden-lg.hidden-xs{display:none!important}tr.hidden-lg.hidden-xs{display:none!important}th.hidden-lg.hidden-xs,td.hidden-lg.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-lg.hidden-sm{display:none!important}tr.hidden-lg.hidden-sm{display:none!important}th.hidden-lg.hidden-sm,td.hidden-lg.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-lg.hidden-md{display:none!important}tr.hidden-lg.hidden-md{display:none!important}th.hidden-lg.hidden-md,td.hidden-lg.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-lg{display:none!important}tr.hidden-lg{display:none!important}th.hidden-lg,td.hidden-lg{display:none!important}}.visible-print{display:none!important}tr.visible-print{display:none!important}th.visible-print,td.visible-print{display:none!important}@media print{.visible-print{display:block!important}tr.visible-print{display:table-row!important}th.visible-print,td.visible-print{display:table-cell!important}.hidden-print{display:none!important}tr.hidden-print{display:none!important}th.hidden-print,td.hidden-print{display:none!important}} \ No newline at end of file diff --git a/vendor/github.com/gocql/gocql/website/favicon.ico b/vendor/github.com/gocql/gocql/website/favicon.ico deleted file mode 100644 index 8215473739c23f7c7dcb9a6977b2508a551eb26e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13870 zcmd5@3Al|_7yhoxHM?d?xKXAkZus5b9Ep%hh6jm4rX;GzRE7uFSmBYOD9TV06@Epz zzj>Z1^TlrpnK{?J=dAyIcW0lz^WE<|=R3Fi{LjB1>+bXIz4lsbPiwEW_GTDSMzm2f z&Ojb#RERZpaFpGoRWwbRse2oz)rvh zzgH zmX?;*2IcHt41n^bncD5Q(suero9U)@ig&3}rBbU^tCm{4cyWn}ic)3K(b4ko!w>tO zdg>`p&6+hm);9QF?Zm@c4&1VUjW#sQeGm8hJleOn(hl{#e*OCHB}$Yqk5f1vs-9y| zvSi8Bx^?R|4@KXmu4so29qwebpD{5p^1%lmoUoyrZoO)p&p!KXXU?2CZTnTIP$4N& zq=@9sojWkEcCtPC=%e0Kr%v_MG{fYDnl)>7&rGL$`SLP&@L*ZGbg5jweqHX}yC=W@ z{=016yjcbf8YH!A*OshVv!;`=ckkXez$+>YKV!?5E#va%&#&6&%9Tsrdh0E@efzc? zIB-DTe*10d*|Vp-^2#gHwryJhO*we*AV`YLo;_R2lqnO$w_?SLX&#TKaX6mn&qekz zd-m)yX3Q8xZ@_>7qUB&+o;-OZF)>lvw{I``^5v5@ZQ96>KmI6Z&z=?R;~>5>X3W?d zj;CHbm=C#s|GrF_G9_roVBe*E#ra_-zYp&rnEA3JueeD&2=N**-`_%m|kNL62;Kmj!e6DCXu^p$-G!?PLo zmQVA1?6JorIXPKA{q$2co}5qeguWB(Kbb#&zGAy^Hyv3l=Pp8#lNtMP|*KCESxedh`&i z8F~Nx_tjXleU&OzQh`zvV7oVe{q@&@T&rfD{9U!F_y25T;9NJ$&`6NIt zKz+b|Kv-Uxgfkg*7Dqzsfd?LtfddCBU4%0;BXaHlzki!~LbnI@in(0>u3o*meDTE> zJU5j7(dAA#&jjpmj_WPJH9#LgMZiJ;`#ZUH>(-8E7|)WeTem9RI&tDerRyGi@WGIM z$Itk1v^~BQvEIVzcMa2~Kd_wmm^|NIG>+v+`YIo3%c><`sf>K1bvKYn~rUuZk% zv~uOjpgNop_fb~@5SAzOQAOB%sk*N`D}VXr7nwYHGHtpby0ne@_U)_e3Fy{99qm8N zw-+?ZyWt7E39VYS5;G0W-);WVOD}1?IMOB0RooLiuQ(@e`Di?zt^4=y*F0U>erVf) z`@d7CPC~oG$?nuV%z3tK*?cu>)X;PAAJpY{(@)|cH37^9jlL^ZteA=YcaL+2vUCs| z8!Peg@u{Omjk+**?%Zd9GaN7&P}D6y2fU(3j~*Qb+vhyi)OFYlw_)2}fsL^H%$YO8 z(B>b2u(m8|rwvc>cxokk;8c0ij3|%Kh*r4=zgc$uPZ)$e9V8n@tt7+9F#;X(C;krL zq5U8~fTlru{8qnxBVs+0JlsP+xiX*&AW}csJT_?F60i<%2(SmR08rVClhNOx(;6@b zumtc4AjtlRlrGvA2H4puCs5uY1icv4Wp}DaTiPb{`|ktH>+vMMUFj@4+GtzLLeEV5 z51bq0(5_)>YU=1UYt|fv9=`*9kVgN9IuHKK{h2doUWE^~2YCGfr9qE=_|_0~6YXSi zQwEyF0NmGRIRn38^ZB52yyeQ3^YP4c!lO>X{`Ge6-rWb>yH0ri@&RsSbHV|QnE>m& zIm#ABmLOlv2KO+^ayrT4wj4CZ0BFBuSWXvhxtHVJ$`lR{x_BebjeyPLg1@W2Ax7oH z*|!e#Y;DSLa@p0x@9xQUnprZM=`eNxKb_8{>)4{5jHa?U?DJH{>dbsH^EYFFzy0>x zG850RHkcDGeC)lj%`$x*So;h6)(aULImzL&JidAJ<{{SsZ4ksw<%JhsP&&6;w{FU3 zhyNsv8#fmEgI3w>zG+jz&i?~)MZ1(O-5eY{c5FWUuykWfTefP|sxoQPBo&hbeaCe9 z@?{n4g6|a8mPP!8V;pIGRLh+M{$4u0TcJV)6`x@2i-|FwIdkSH8=Yg?qD2ek<96=c zS;b-)tI~%|o?K(kBlVcpQ-FoQIp(Tt*YQBuIVSOl`r%#{e`5LIxILu#v z{dM{N`|p*%v}DN=Y1pu#!lU1d7@NR%RWulrqn~JQ%ir*my@-QsS^ApCygjW<;674h%@{v(e(BHOlYQ?wW}u=*>s zLlAe{41`GJjfRaCv=$hH@%em;59e3Qsq-Ix_(9sWYbTV4zAfXO^syNuzi{D#^20SQ z_W<;*qQ!W&F4y_cp+oORC~t-5pMO3`UieY6c=2MzW8uPuLF2+0-Pd1#t>zwnjly9( z-<X)H*b=STBqy-%W3N}4#ik1 z6XTe1adFBoRt5OOaW?zr)Z0gn98uNJKKpEtytQi8N<#$$ByQ#HN1N8%XZ`!>r=J$? zai&*aeO1MdVb==wrz+zg#tj%tVjM=Nix)2{|60@W$InzX`=`s9W4?UgF&LGud!y_TnZO193(Hl zvHqz5UCE2N8yCuEpv=5q!d;)@$+bFt`gElmsHeDAIiB2aye~pbK*jsHW~t+txOcgR z?Bba0)6Shcmjlg}ycnw)jE$J*$nH0BxOTb!b>f{C?;&{K!gCMzUUKISLyCVT>fiMizzK3C@9y2Z7n|?2?C6=xxQ}=iKo7}@6DI=eTT4itefaQU88&Q~(jnG+ z7c(vW8+(qiN%}QKoa9Db6~HXmTNj&NMK5fsgUAw9~YMy(%U*tLK zbT?^7Lzj^^<_4iqL*G-=HaG}q2H>-xEdbW@OuLLdz6~~*?fHiKbYn(c^3g{hsWGMf z!aEq+8N7eyJ&9eLP-V1#U|Y-sPBlPRKz%?U?t|Y^fH*(`fN_9m-0!%4qe6M{E=Zkg z^cz7#pg)!TUAlCMSYF(z(Z}ckaCKe~54PixNObTMPduUSC~5z)9q&5$WBNBOW#!fQ7IdH>^_lvx5#QO+&=%I%K^3mSlePF$M^@40lCz`l-qy3vB5_y5! z0(O_}njnAr!n9r1u3f9{>73#WJbP&a(f;9E2d-3}b9pC-dtznJag1p@(>9~MW0jNNwAXMavk2r}uU(A`KX{(i zuH@L#c46XuA?+gg;Od)id#p0>{*1mq&kmj^yenlwyfYmx+xp{D2|$ThUbKnF-E)v% zM8APHBNKfb-r4H6PrTQ(%FBCDrdzjeDSKFb;1A#2SaG>e;g{2p&xow54c6#st8GQw z)|xoajH6j)&}W?)pD`c$cUD}SIX>9wqyCP(@Vgu0{Z!D|L7hcATqoM&PJ4*!hj*j& z@p*Sn|A(OO+bRMKMnL(^nVp9SwWm7Xxa2Q%YD^4k>ap-w8V`A3qY zT@2s~?QiaLeRf46hZ|h_ReWEi-*2Ez+eqZpxM)|2{ODUUF}`P_88qH*UXl3*tWE?xbAzgXbaFJ@q5sJNo-`8hM^b%s(T)L8CK(J`;V`>*9V@@ z7)vkCuoXDVCIV*{;2dBrplL?rb7}*6*-Uj&uy4CT7oUSI=EeEt(_;_3AUSykBL1ZA zV>fKrZ~!#8Au@a>WJ24@uwy16uDb*4{1V9^^{{oLrfC7J; zS0XOW;aT8TCM}k^F``y>mE*$EoR2UJg_i_lpXEB&<%Yi=Iot7o(K+eyn>m%M&ZGU` z;qoZp;eCf;&FK;0pJDX>)2TD^8^#EJJ0*WT=}-p2jB=`DeUJm@WbljUTrMixW+?|=SBGx0R6>u zHWHIte?-5fGyR2w!58wI-{Z0HI5y2i1_`S;hc=OFSmHn#kdGIb|yR|LuC$BTM z%Xg#X!#CZuS71Xazl>)H#{hWOEN!D;t8vMxyF&W;d_&Fm=d^$6>+xQOv2XlNL0hxl zDUS1B*|5~hj0y1VD&xuYX&D38J~!gTKEym4k~h*buot%4oeR`YdafuFfny1vKQbDi zVlaGvqU)J6PR(($`mwO3e3(b-_Vs`SKxe$0{)25a(0<|DJM$c|4&&{C51s?R1NXR? zORh&{v-auJNBNGlQ5Zv|O`&7XkcaobL3$N-WEZSIALXRq#F#2+aeV1R;eJ|uBNn^T z+7@`_;NN&@WAMGIzL#NahQ12Nh;rb}nq$+p9_&Y-lYfpe^74)tJSJJ&@*Al(`c)gc zc_sX&vsh<$5U;v~d%fMTcQ~dk0D&<&kJB_c-(QdfOVJD?fXt-Jl2Nb0Q_nE|3(5MI AnE(I) diff --git a/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.eot b/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.eot deleted file mode 100644 index 87eaa434234e2a984c261e0450a2f4ad837aa7b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14079 zcma)jRa_K6^zJUrQcHI&-Agwt-Q6i&BGL^KOLw;{-AD_FG)Q-gGzdrvN-EcX-iP~g z&*b^eH{Y4xyv%PN=0ykqC=mnzkp2}Ez<(I(fA#{~JL1@9|&czbr17 z?0>QUi2(qt040DrzyzQTPzI;~05<^oukZrI|7re*(tmmX7j^o_^aj}eC*Svf zS8xM_|1re@Z~iI2{-^mL9EX2e|B>GY!1r$^_@7M#!2iz^{g+$h|9j_j|IfYw09iey z|2e7uJq%=kUm`%z3m_N(;2I^EK8c@Rz+WzA_5K>K_A~&N-y3An#=6kB0L1`ghg@hn zZl7)JRrzdfN4}^l((rOb8!6cPsFL3<+h>Ko$*N(B`~JnKcb$DjB~XQQFl-maOT7?| z=??-O{TBG@KcAzmSNxsJz-Lt-`@AJr0kN!Di;SF6C_P<|x%6Q{;498Vwc}wHl?UCr z{Q~3fpz|ayjwAvkULRl`8oaqCD1Wz4@8$~fj$UC?mYD}9H~K)mrxoe9!WwG7+6D1~ zu)}%fLgSy{-z-;>e_xUdTzZz=OI{SZWnRf9!Z!c1f25WUO+5X9vri&A$czeCIfk$M z9$(eLNbUdRcqZ=w)1@@tN<^z0pQP-fOfjvjK3hvorqiV%Rl2xSOKU%hzr6ahgV9*$ zJlgSvPU509MBT=C+`yifpkEyy8#9c4UL5|r5gWS_tr}Av>(G)ZhAtjcTRS3?SSA9N z_Kegnh`V2N6RU=69p<{&He6g~O%EZ5+2OH{@ca1ru$Z)c3E&|1G!5~|4CfxK{)bF7rn^i` zwcKpWlzAHWR{;3USb36)e|%;$T55rp9tZ<6==s|-B*BebGk#$IYB|(ZrzrewrIl2Q zcVZsN=FLe{6k5m7YDaR%(#gdFf#BlrKVjI$R-nNKpd*2(T6`_?7Tr%rq~E9(yIypk z15x#%OfK;;uk|PQR~)DEppbSH6DmW;v@k*#ZhaG5{w7e$S`ot*K<^C*oB^co5cNr- z84k3(uHIXMy>++r-IRV%?Vpo$*r`8)jmh{vx(My9BI&4V4t z@q&H_L`zH3p725(a{oTG;rYk3%_{r*|8>5_6G?cTr)|U^XlDg8z zm^W6r3{qR3liJadUw%-DfiMsiV2YTxYOPA_X1lBkNTo&NjbQ(_zP!Rimikpp%G~h_ ztU^LLtxb8e!>D>CG^8eZ_@-EFi+JA&%Ym}4^tY?&sz92_hbFAune34RX{tbjogYXK zb;~ja9%4IE{_iiY6WdJ>_PH&3&@yDo2T(p1E`%?ub^PQ3)diW6ii}#+*!=`BpbGP_1R+t&;29S$UAcpH3h}2^>rGvH){c0jJtjcaSiIpFl?|Ykw|FXrNy% zn~l3m7e4&RgrOCH+jCRW=Ls5PATEyA`J8Ad?TVOG`l@pE({KV)pF3Z7;oa4-Hx3nk z^j1RZ{N?bQZy$cYv6=A&0^)qVweZ{+Bno|~E=9j=k-GDXeQ3qsW?N%I&@}1?wxuHf zA|Ro-_+d*C6M-#@VpM30RTEPdo!APpRrFObUDP^Ic|AJ;)&LVdnWX#RxiFb+zGKCQ zI_Kger%ADWvepR*8TGZ{JN(1K9%&P;^!XU4tSvkgGe_{JR~^f9$<0Tklc96r9x1B=VltaV_PCB77l_0tL3{`BdedCe5j3CF zO*e3HwE9GE<^LnU6k=*E%b)otxd+9+t<9)#+ze$kGPmX41&oF?8tHV!$ntX{*8aX^eeP@F2xMvpFGcra42@FI zDr{tW)yt3)P*7pvoD&$N2UDat?KH#6Zr3Wj1ocGNeW7Gj^2e)tH;o4O)FyAx_b=b8 zd=9(x+S@-Ai=UJC?i@DuZ0CtTtAU!S<4~e$K4CsxC85Tve7fHoj%T!vPv{JHch5_Y zM%K`rC>1Uk_m|u`%z4L~W*R<1JgN zI(cyXr))hytWI9~bat*Gf;?_avFr#*aq=$;3DEl;rBBbSfL&s-CmEN9Z=FWBPq|*w zV=1XfmME`nZtgN@DBWrbTSnz2oWcA9yL*=L#%fP3TXt!c0F%_>FvWM9H}5Urg0WkI zNt&dRN)2J@03gGYXLU}Ws1SoLa(2xNG04O@u`3C?42=UF%K^ZmD2OcrLpkyPD{zkZ zqZSrZ%U#vZMaTD{N9>OdGG?lPL;z?aQq&oxZHacwkYDWEjRc9X)Mg4w1*sqqdytQc z;>DOou1OedrNNb->@o%dNQsBess9-iEOg6MCTz%8RuuTHw%yfj66ap};<tL)BjF!!xYDU^iC@^Rt2BMhA>^Oluv#5vBd^doV(|U*_eW!Fpo^kadb~1qfM1 z-4xV$$`eWJMc%3OjU5A{fCA-11x&T35;A``cBD@_K+AfYp`ItY-nO9GFXyk(6H&gC zgVP-%-^o=btFjCC^slGFm}WC)1Fkw6WT{3uKjkNm`0Q%U67%Y#OLYbxB}u8qEXyBf z+jt?k7GWf9V1;7X7NJF^$kk!j@XFwhY;np}TTfKNM)sdEtVZLgSNz~z0}w_y_MM$P z{7ZPot7f{~deqdkb!?PO@3M6uVpZ)~0PM!uFW*8tGxGouYU+idM&+mch>1YWrfYbw zNHh7S!OA3^0A)hxl7xkSusWMIn}pAG7sVY<1G(8sqQS{%57LmXJp-HiSyD=l$*Riw zY+20T)}-|#pikZ7^U!gc1p%vkX1Q*!C%Ns1AbUha>5MtQHVJ(Q7;^mZrN_`4&gR#d z*GMiPozmbFnk7GQMUfb1z-LiF4xQ67RJ<1As!AEvs7ht4PG7P&xpL)JUK!S%jeUiX ziGEQ1j5YCz%;X#HVS2_}6~%)EQ*SZCzV-TqZo{O6%{r8|Py{vm3>zZHrnDT-D+S?Jo!n<`QZ%7N z6#HY((OAs1v%<)LZ%T1o@hclr9U{s$FY2`$#A222+iwA0^_ZWa}Sp$~Z`tSRz?fYd)Prtgp>DC@x&win* zYx)}AGLxzuz+^6ox_-KQe7OJaF4>UhEn2<^kp=1~zSKf2O8lsvgwt(+%dH&YE^$~{ zmIZuN4KWfnT+eLo`$Ntu+@_4dx-xCn%;H+*qI*rz{Pj+IMWV4q&4&v_vDJ?KnuhT? zp`HFH-{i7G z&cb3tRVzJC2)Aj&v-_2I=-cTnDad;U%gi?|r{%q8M3=JWIA4A_$1xksNX8fGQ0MXv z7jsG@yqP^YVXh~FGG7ztRofbb%v-Y2Oa0c4{DoEW2+ghB#=X?sC)zOnd<$FcA;P}k z!&0wB1tjlcu)sC=F=AuzvQsD3oXvch4Ur;5+K@a2;bjf`X@%InJU~*7p!QXL|3UP=)q(sV!;RVRF4eC( z5w2y7m}t3+flB}{o?fK>I$D|ykMw@kZumiw3J18$_+UA|-{#xqT-R~i?db}=&OhR9(;d>s&5GJ-M zuHl@XB;EHQ^c`j#mM47s|SScy-SD&Q0s(780*ui5*B(NU{ z1JAM6oymA%{(T`Qwoer|4`e4fbXpw=Ujf|X8hmq7E&vxv*}=+Rye%5X2xD0*^}YEf zEGd7~le2mpyS%mw8xl44hIvof|Pxp1T*z47AL}K^XlL>J6(gyYOmc|;VYs(tHAWpG7 znr9Tel(H$KV%()2(VBNVoP!o~|Gd)(^S&Q{PCqTk&dV;xZm_-lB_hr!QE$$#GqKT6 zV~RS4<7x-=tx0m&jE1BDqd(cc2iA@B7Ib0!{b&v`-5`t7XEV6UG7WdVy)z(@VR3p< zDC1lTpXHX3oE}5E3V7yx^8>jVnwr!w1_he&_17RJW+}R?{niZFG|4RyT7ZmC!Y^% zbR{57inS^QNGx!}+P3f7%?Sionp@*#h+8;FTaj1>q z1~X!#NO{YL-6+QR)z_o*SW%A+v-XebXs8&@TRzyDRieHy_t(B}bl)uwdFg%YXZ-^# zMWTYOwIkzv%>xr%$CBM=*m$T9k}!UxqnsS6rl-gw-*rU&V2or^ZkP6vPI|0njAB4O zn5CyBPHvXL)29>zpPkhW{`Qw3B?(G-TWfAV0^+}Ji$*Wob6n`WzRTBhd{);=mfm^% z{;`v`S>9Z(j2Nv-VLKD3~iA$Oj{Dq0(I z8U*-!Po9%GdOD|LVS~3(q-_)biNZxTiT)GN)YVr!4f4IRLNhAD48qw@0S#E{-e>UP z!dWH9**gQ$DqT?TkKNJl#J(f~7r6JAfSveml{UZ6jueeC&zR#Vi@e*Z==rWJgp@xj zDdR~Hd=3W?q0l(VMfRu(XreTXK*$pogtsuagZUmp^U^=wp0PM}Wf8W^Fm9n^8S4AS z7GJfQqzDgu-5C9o_f0zKKx$9L$|nGrE2rf%PLxV|c5LZ}PzELiSVok_zxZdiw78@4 zczsV08yXH>t5P&u(+XYPsiu48SXe7a3yEBGFiS7KFN#T`R)LMID_lZrUwvIx-Jfbw zW&lwFFkZK~+S9BQcb`8iqN%$0O{ zd_R#~i~MUF@fY!H4LxF+H=SJ{%h^?na-7Yogv2T6317oP^NJ}Jbg&)D&P;P^w8oe# zDNHRAqcPe>x zP|B*V4YPfm)deuX7-N@-7Mz4N1KmAfyYI78#jS0>Bkd}i9TWLsIZgXQY}1jqm+pG` zy{JiBImlPiF($3(sE&p7ntgNWLh&&5y{|mea7L8%c);7R2$T z_HrZz(`Nx;xE)NtPgF(IH0m#(y)Npg}NBkIWpJb(OJq&ymq^iBIHfZB+V!qd}3EnxDKf_XvD zT3tuka_2>|KJ_Qr(qpGJAf}w3%5Qo=u)K?~`O2CzZnMD_J96QGYE`74E@)I~ODsKK zH%}vL(dJC~ZUF3t99-z<+)r4yfgnU{Y-RryR^-SYY95;xsg#!aUC-Afy-0t%`Ccv_)YQ)A}F@oIMmu2ZX7PQ72ukwf(Cvsr!%uk z?~fxQtYEo0ehCIE`*_+|rxqV~hPV#FQyC(#HP&p@G#fKOUMp?w>)uN0&^pgnu4xwA z{+=Wo;`6mUi`y&O^6j1|StaDJHzuv-uBNf~cik{Jl#-tM_hJ^k+>c0kMduSMRtVAB zXTfh&yMOb>MNO5I1PZ0o!i;G4!y_^YHKHq6oX4a^KR@ocvM24QDH>)gQ-zdAXg{pR zt7?3h$uSFFv$4~lRcBSlUCKIO9p9VFeN}^EPQrbB!iSk~Ba2aSpMlf7sUnT!2PnKp z*Z0Gpr%sIM*x*BP?6E2Zk^y$a@Bl!Rt4YArYn_Po5M;&@gJz097wEglfz`ESLsIET zBs|I>ZJ0yIG}&DmAFB*@>{;;yJ_vO?f1N3M;xsLT(}SOFekLA$9KWf&-oNL?8X4J4oyU8tKa|1>*wEyh6Ebf)U!Z zYdS#`zoaL-RrPmx!}8501YZ{qj!4m&Y7SrdF&73udbUZylkG?gV+qAaszsvHEe+{D z<45m&hYodO2}g4E7>W2VeQ&n7!#30RJ8KbdK;T;5$lg`8J^y4jw3DP%j^Drg_woO{_t+eT$A)(~X?aCV(oI(=tpI1st*S@&~g6?&k z>s|?NRJcDff1`1?-Jc?K@U3-!Ys+&;g!A9IYGA|)zLH&vmifA**}mdVQFo{e8U~b2 zO2E010oyxaVfzV>!DiaH1em79k8chs%8c=txP&UaPiGwS0WcWl(|%w+^T*t*H|mk8 zz)Ak3o-PR;*!0I#w>D*9!+3J9$A|8=Ap!W>(U}g$h&Z!YOggAp^3=wF!Yaz_P($@? z(n!BM5i+f_^FX8~nrY$)=ZBTKHqm zVdAIS4fs!QL{-!F1~xy(})Hxa6p?Rjwv#-#Pvf zm8TQQeBr%Pn(2S+vFpu&c%{Rrk4#{RycSckZsn7q)i-C?s^e~PurOnw~O zv`sbAk*TMuA3Lo&9S}C+NVe+lL`zRzEuw^L!#*K_R{1j-SsyFUDFnW}3R%$ zis0vASSvzW7Jd2#61)h4#M6URkA_A3SsK4n#`cE2$ zLWp@8V}aGF=zO!}e(^Si*LlMGu3Si8)@_u+nrICpR-ng^i~GNd$UP_6*gd;57I81d zqLuuFat(5+->FEsY>{47M=^M$XX_r^DhHhyoVF&%)642YK9oHn`28XL@oD6zTRCr_ zQj#&uvxDDr@MK}Rs%^cX(zMsDRa3RzUQqW?O#N@x@1442leTwu=(D`c&~bPJX1eJx zR}5A8N$9Bq;W2HP`r4=%i4+)}>MCN-g9+FaIfz4#pX3o%gk8jR#?u%4F3+u2WCA{+7b24rYuJ1 zwW3Y9w-Bt2a(91Hcuj#xdB*q8Hy&$|)<1KPvN*|iiK~tq?ka$u;jeH>1QR}^dUxIFtyRN6z{I4L_o?enJ zFR95EMp$tQTUr!1vOm|XcjELh%@1qHj^++_t7XehC^Kxgs_HUQqFOBndGbf*;KnrP z>1BrQ)f5<&={TbN%QdERb6ljEbbCGjdd@5M#n06;VPP)$ z>chCAA@WK55n7o^L|)RL4<9m6lWth#q>&#GG5)ftZ#UzvbU+$2(jP)!o(zaw#;sdv z^%g(${-K@o670tu4>IZELt3#`+>9j?qf(`5Ch+>S&;~QQKzkSNY)16RqV;^f>T9$m zdqgaB84{#YEI4zWG)0m2{JP4snKf5{q~3>X2#QxOjG=sO9EHimSic@4V^<|@R-5Hy zEp^BF6R52jd09ovYpsaxywq*xnqd^%9fxrz=LFuUgxW6tSBC@dGWefD{H&>5oMjlj z6Ud@Q2;X<$!M}!W1R~uQvtTfS6QH%6nlH&~+q&RAWmVP$rbyZI&7MJD!MWh1sb*t; z&V+sSq(hi;g5~PTh!VqP_4Zlgx`%k?t19FqAJy6{$9?t}qv_oZP(+mjL!&s9hsSi0 z`1hZBgO1QyH=#|A^)bdk-w<5x6J#hivLy8_sDXLZ9cyp#>1cVkuO~R8$$=T!YcnR* z2IK3z=tD9$YM0E;xMYvjGX;DYEKeMPAY0k(Lwzo{Vh7}c15$J|s~_D_e%+RH^Zh!m zk4lp6r#OascmM8jGUcEAXfHU(neLo*wABl3)3I;N>=s`|zJAWwZHZtQNH-HR7WUvwmZrG!N z6@C{M0eWXL%2LZxW5tb=HS-8XP81s4JBB@;v&wkf0l#Qa_S5T7lahYrpP#_4z4ku! z%79{Wf8-DjEOK`d7PC)LJqBs(n-#-j1cvFr54a3Sabtu+VZ|9mz#=H?Or~eqxl$PQ@(j-#K-^vA1?!cVSYHiqjG%wgoo{ z;V>B_%aMBK*fx*zO(E~G2V^Rge0k6DE6)El91p>sh#YPjHEIdf%#qo8d;2q;-PEL# zM$qSYuUAeQ2&IGK;PK6zotMsO$LC!pl>@QKlp--=jQIkEwD||8ke1rQc)#gAZCdSP zbp|sBqb`OyD=c13US7+@&9PO~KE57bfoh^{0jOecez`2lpKQh@(KW*IF9t5p(vD6; zqC<&N{Yb0E4bC_{JpkUsO@rlnQkGCgPZc&=!#+=sq3)AE1cd=a-Lo&kH67=u3f~^x z$gvF;{hY5N=zW-MGNTT=kuvj=Eeje|_OvDefcre>sl=DrFKM*}wkk;l`}4haQL%D& zozLBx7UB^7A2;9x3fXkFDG|nU!vVTV#n;l`sA<8?C44E$S_CvCJyIKcbBTSJm2-dp z+A@d77melYFx?WF=8D}pZGaBq7o{5e+?i$`$d&UL1MLb{9o$$YA(U~As5FJ(o8zOW zjycOOtBY}?CJP+$sVEXp?BZ2aL1i4K0obmwIcc&4(62jbW8swa9f?DjTSetJS_F2B z5Z$cKkvqo(>(e|^<$|2NpV%tz7CM|Ai^m?Kd>Yu-{R!v%f8RBr7rWNtfZ^9vKm!u^dP~TR}A-E{C@XK9TX7!)BcW+IpovW>PA7tEh)jxk?zJUM*2{Y zN?T}i@F{LR5-+vp%IKQlcB3Ym)7}cJ12(U+D}MPeLlGDyvcfbe8%LPEy)G!?=e1L= zDJJoWSy{8;p|+#$)~16&EB2)`e$!tX1y-N{WXm?gwG*OnD!ci3u-9+(iLd7=7;7jR zmcY=*?xB}|#asYF%EX6t2{+RK&4M4{66KihGOAs;ij@mK&3Uu)3^b|?B;3B+z!38I z93x_C6}@3&mJvH)!lIq0oQQL86oWy_A|U@GvyD(NwO$c!`%U{`)TMN_Jau#t*Y0lu z0c4~`*Vxk$tP&+W8%8kVnREOkJevuHD;AI8ltWOEzPR%_#f5(Y$jArOxfd2TY42x( zvdviv@hBSfQLqM3;mpaTz|811VlQ7jQEm?Is1NzX>fhX*)3?iglf#v5#%li7DBSDs z9yr*Son&|AfaSp^FHcK!iyS|rW|~Ho3BGnwfGSacSD-Pd3HZx4^Tn{rw@X)t0G#!L z)6pFajr<=k25R8M>3^D^?Vl5V6+B+5p3Y=}-8meaQr23s5Ci^QiE_I#JND7F{`x)Z z${rPtj&q-)Eg1mQ&R^d8PLmmpTs0_NfM;Ld9p`~M`3B|`d)KSkHhIgWGh4h9V(M!E zprOL?IrlHS-Zj#5YaezY^EfJop++5!6~dG@VczVZsShn@a!H)^)mLap zN-5d|ZA^-9-}C0NQY-(>WWq2>z$nZ#9f)04o}#fdrZX(@%ws*mvWvY{x|!V;M+h(u zc(X?j+n3l}NT?SeX>yk#wP026HlrMO$^jJSY9}JbsQW`La`|uCRVgB?-NUkr!Q62rlZJ0 z4(P@;r`r%R2v%XcY4gwA4RY5cS9^>;1!-;WRHH6?A9H4nS~L6+Erf{kNRARp0%v#mG!BN`{Z0DT(;hL>q2tUur3n4FyKJATTZeC)I7~MlF{vYq zP#u$a?65CY1gX<_^dpm$T93g7cEiaEzJi=f(PP7*$Cf< z3e!q;mMXoy);Hc=X!%VmT-e!^igX6GoDK`Lrz#=>sc zkvcN?I-(oNR%$y<5v;+H$CX{e0F$s;-Dc+ckzFlEF7xK<7+Ij5F~FWrmDWsXraDch zDC0G}@xv|q?bH-m|Mjy0Ms)dZNpHw-DvLp2+c4S+O0)kVJ7zx(o)JrS?zKB>t||@D zeBgbVopB;#ax&umSZS)xCuXSI)HhTG6R!eRH?)QacpQ5#6L!rNa(`x=`VUEj)U|nB z1MMG_Tv{ZK#mpijK)fq&ckNP|V4+@K=S)c}ve;M#Pdu?5l^rr)DvUwV0PT?vKYzR% zGPWilY;hyPpFoR|5JP6?I@iC3Vq6S&sN@s)yy2Kk_{_=#E{tj(A~6Gn2o~=^zMyvs zejH=*na5H)n8DO#XSngd{F-OXphTbN9bu!~RA1@WgFi`~<6C$z-&Eg~>%F!po2S1_ ze(jCXcwQ%!S`|5^h}24Cf%DGYlJ8~b8L?zf;0`mM@)Jd|9&jr#{?*Qg1XJuUM}jTV zML9{SGQW{o>!LsKk$gTo3em@>#xK?}8b9NgS$?dN7ub9st#1lf=`*RfERqiz( z%zTB8hI6(Wpm4#3HbZ{z&OHArOIRM>JR?w6>jxW$d~1R( z8=RTg(0-+#XZ>UEu5%s=xiU`S%_}9ZcU{{C`IHp8yqFeq7L^5hHPf(B>{qz0U zx75z&dEB?!YvH!0%yFPn0dnvtlCDFL)%Bh>h0|%OxMnXF0(`E_T1cWldfPUNA#532 zF_UFlhm*4BwrzGZgWp~l89&g1;$Os_(e;Y|xl=2m@`F6(@A7#Zg$6~4{MITfoS(mY z#oK2mo@6)ugHMq+fCN82iP%cl>0rRR$+U-6UX}VIBZ_N3v^l9y2J@~+nXeeKV5tl_ z58#~`c(ljwfpHzaef#fbnkmRlut=er45g1&uFAxlaV4_Qd(S_*vcPY6fo5V{29CqR zh0CQnCWemD$tb;75jw?v?k%iaE$Zb*lYKU|?cRSJjsw=kp)Q^XpVWYrI2cu!TG~H7n=oNXG9I#<8 z2XoyS^Mf6^!*Rvnvc8xyFfpcXmSrE)F%hEOCa_GWBD#KOV3`AJX5v%eZiII@eMG4w zP{6>u6syX2q59xdCM#LN@M@N#|``%$kWIB0~(ROY~Ve=g* zNO-8sq+gRLR{DVwQ!Jfm!U>SpZI$h+6PlG3&djhh9*Vu$hD=4jV#(`EepWBB)od_U z1z*Wewx!;!ADjqaCwDW1G6@8ht6c*A{M}l8%l0jf?jh`J4b);-n=1;fmgB)4p1;ZG zDDk{q6&;eqX;tp_US%-mWh|)q)i{eHZbo|{^0}=bKxC@sGOV$YXz)91vn7~h<-uH& zQb0dByDZJPD`EGPd`kqAvI?*g=B3fqa9H9Rd{L`va?B=t~Y&l0h{I!^E9pG>!S z#>{UpLngb5T`Uqt6sO=~BOjkJh)+u0qiSo-es@5}f!h*a9Gx*&<5{Eoxc-WF!jSyn zM@qOve{Y;Ok^%FZK{2K;y}YNN_;1tethBv;U%(w z%RNe4t*ldJayql#MMurNnNoO;%!n-U0V4mzVpPdGu`LKf+RWv>l>VJ zh|rXJv9Mk&iDk|e!hBRh$KiV}utL&NkptF@GM$|`tR)5FxIigOLHS7vqDnsGiFl7bTk4baLCJDyHe`hWp4JT~ zxRJRy9oc;pw2eW?wv3s^8AsUEk+&zZY`Ez-Lo@iJt=-gFZhS`U&Ct+KB$VGUar1N* z@v1?8ygBYN+o*ZMCgDHM7MC=Korw86(SB>G1fFAvHmj{-oZNU|ZY7bG?7% za!4;s_~l~@pOTy7Zo^+6AY`23W==`h_ME&XEh#dIqn)Ei1rAP5;j0oaGirRuwQysr zBa#0yNX`7Po5nBsn|`gMKsYvFEKdsi0e?F_b6jl8h=+@ms+m|v$is-!NWtw6(@?$V zl_q&yu*vK7NYkl6M5O+M8>hB}h=2U?wrE48%##YSN^?I=0+$V|M7{IRFWf36;()R* zxJPdQDzTQ8c-0|B0$0G*)swoM=@rL%&=A*ZOgwL>7z1a%8 zFKtztnNhe(UFtdIA>1N=eN!pq;(cN?j@4UgtmpU_OVf+Lt5A!~Q-4!7z4rNbGV*<4 z`3S~~rTA$L`Bs@(J%h0xlX-Cme-na$&VA?CWqV?s!6CpeZMEoe$7DyV^%f(Y$CD^& zqb+UVeb3zQ$3puFCqi%M<_{j4`f>6W>Qts%OZ(sH37e1+(`!sDT=vci2*%*lcnLfGx#FXv!uiQm` zC&DPMh8FaCMRu3k7P2;P<>)CU&Sw8mr%`j%w6%l28(zv})E#p^r{~M)l3_X_Eef#9 z!fgwyX5@Oqx9=Waz>)cTxBx#FRZ7Q4&|@q3fbSjP*Pt|Bw)q1)JAG_&4Bc0~QYI5; z9l5@3gJ7IgX2*bCLz?mlb1Z8!pV-p58bZOp4MrH)-?C4BM%`bn_bw_v8c^mNSm=5N}{I(?E;74 zX%b#E#TsuQAAXq1n>W8vD~|I|L(Aqg?g=aXtg!r5BXJq%+P*yi5*0j^`Ml4I6;HT7 z5db0$wG~_=*tJmS#%smF=#xa&&Jz8fS=qB8x{B|9vz!fwmKbQU8&%pTg}ZM=3#kzV z_ZQ6}eE9}~T4%V0Xs%r}Jw9AwZlZ~)%XtE(9Q39 z5S-nO>sGi>EdT88T`M*cJ-QO2)(J{jpdX2j!noU=B@Ze69N9Z*ygRJ((WnKT=0Xa4 z5>HTd{3T)O`V-xs9(FA8^R$B+<_d`Zg!1rg#WK2+HXS(SR!(O)SwKq@O>%tXdp}KT zpzS>sB$N=B!h1`B*_hr3l_}mcGqYM@5PwPL1j^?PC&BQ_KvG0v0}CmL3|yC_fNyLi zaib~0C!;PY#bDnTXvPWs+Y5`ZCeOAdxX zCQNr*a)lN~1JDbninPT|6#xvPr!u6P!D6j#QGyAlSi+iMZzAA8s4!|Oo;I<&P#87f z1}&8+%t~ev%@`NRwfE8lg1+grWmTX#j0Luf0bat{$*Vv6?Oll&1AW4N=p!AztoBEDh8Zbul!(v09dV^(vw_m;E~n7Ix72vc`pWtfDyKs=Ist`7lb zYP5YlV6WodgY`h z&;}e>0a?Pt@c>>_fJG=UQ(rXrUsV^iQy0~j7nOpEOwo~<;9xV3M&qR&z^trFp|Dga z%#afXVTGYE$^|P&Bhs+bBC)Q+6RvGR*Dzw6Fg8?xZ5*HlD1 zp==t)lZj-JiTHwSbr}Zi=tnw-A&Z3toC4Q#(PpeD$iv(YfbFqpp>$-%VOD!U+gMaL z0Fg03#R`b$j_fdp`mKrB7p7qXn6*PHa>q32r&t2sKcoxsl=5LGrqWU=$$(DfX?Z*- zZDL9~XrfbHDB*7s)JG)=$rjZu)RQU*#d&mL*HpM3ux+Bz<4Qp}-b(Vs)G51Y8=Uo+ z7zZlqTu0xvo&(e>I!;k&;b#AbQzV}1(2(z1y>Fk6KE@waF^Kq{d@b-3Ge{J{jt>gwJni6ufU{X-fc+B2-`YjYGsmBSgS6oO)Aq; zI7J~w=8hx-a2*4z3=5D&uDPO|4O?(UBedeq1L}`~nEDmC0d1YYpF1Hr$ZOS9QLtrp z6nW>C@!SbU@@ZZaznY-{-@R|GhS4I()!-?p@Vi*TJjF`oVea-G1XNzd! y-^Vp%pcMc>T*9)K0*lM!C8AZPg+G7PFFQ7O_Sp6RwD_p|> diff --git a/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.svg b/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.svg deleted file mode 100644 index 5fee06854..000000000 --- a/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.svg +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.ttf b/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.ttf deleted file mode 100644 index be784dc1d5bcb92ab155f578f3723524a3dd9688..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 29512 zcmd753w%_?**|{foU^;hX0w~U=bqhcl1(6Nvb)J{LP$Waa=$}B<>qo1h^Sl?5fQHy z3@Rvsm7*022$ABYeX&1l3tg19UZPd{Y7=d(ZPnK*Z!eHN`F)=`XUP&m>-+!xexJ{O zH?uQy&YWkSnR(`!XP)Po6M+eWU=cP6lF%}8|&%ddqyBm-N z{Tbxb7T>Ub5&Qa-3;A|IxTbl@!uc_wt`W~KsKouq5?nAIk=G#~L%w9miksK%HQQQ{ zzfTavPj6Ut{ruBkb_@}Og}BCEUNL`N3kwKu2*ToWl=rNhzhYtg&RxKL@zsJLZD?6_ z)6MT)KY6VnEc-dCU%z(Yf<p=6vpVK=EbUm|aev2Sol<97XHI8v zXGLdiXI~kpyFL~$jshU}17x8WWT8XXk=5bpsP3rg7y`(n zIwk?~f{vDsO&zVBtW(#S)#>Rh>8$RIb`I$r)_Ha3q|SMrEuEV>TRR^k$lafGpY2}M zVffuAzdQcBB_By=ogbJ#NcZG;vOPAB$)oq^in@!GqD0Z(i~d^lRneb|eqZ!a(Je(c z7p*8-T(qcYUeVm5=AxNJ(~Bk+jV>Bi)L0ZPiWI)7_7<@IzyG1}62u2Jz_o}yTA=aj zhtMB^C}pn}Kx-Z(Js2;+fVfHxf(`LpH3)XZht(iB1fdxBC(c1#}I^JNDoFl zLJb1)9itFNdk&aVx@ONUs!x zPPD6&a9)ELICrKYjb}Qu5OR>d9kB-ixC{3pEezwwFAxLw z&Rt0VQV>2yL_q+xojbvUAiRb6BoBh{HsUip2*Nvvf5n3!v?KmI4}$Qn!2a9DgCM+z z*ujG!{06a$2SIoraVZai@Bv~!4+1!nz(8B*M*d+UA_}P=+@vm6KQemx|IZ&{%9ngF z6Ta1luR8(*pAzxKdcc-Q9yHt_1fFL?)u3YrS@cW)NIdu6+TkMQK-BSSzbUXicV+ z7LJQfeo#IlfbN;MP!5Nh#M-dlp!XH~1I+J>hHIkui9{peklW?<)dWOeu~{^D4PL#| zD|wXm^y>OyVQ0aZap5CH^Ox`c<=T>=rVnB_>dwaQEggHy@vmD3>0bzs8&jBFKYXyA z-4;{Y^=v0QH|FM{{VloGGiwhoyXCuqL+fHywXyxPx4yD?S+u!2$5A=EDHezTzc_1^ z$B8G1@Tg7lxULP-7V(4vy6^s)Rm!i)R}n9>dqa`hnlfLpA;5gadZ)u}W=@CenE2(o zg9q0IDl1=D`S|^^4>Hy=gPFMtS+t4OT5HM-I`k92rd^Ug8!~3%Oq=!oi6f_)jfpIynerv~O}wgE zdN%R*EO+keNVFoyJvl1fXv~m)D%p*RiPr3#)hjD9neu_m!lbUMtEAt2Y*Aj8D_t8ZI( zOLJt{`Yi{Vn)Yv5Kdf%{+O_MY7e-ty516`UNd5XvcO08O{n#Cw*4GbNGj)JG8eJ@Q zzbuTBcc6cbBu_DWIP5GH!@THQWpxD<2Gj#x+Ol-P&stk*TFHxBwc zkvJeWBhj@X7L&I0#BsWw7=GzRdEABL@;Hz!%_2nV2boGO$>*rR`I`keR*_V}tZ1jV zxD1pW3422>U9bGVy??I2skAr?3Y@IfSs*s2<`M@|bC=$eb9TLQ$KZ#x_MPtP==*wV`EOH3 z&P~?T11}||T=Rc&Tiu<}Jh`;r`|NR|C7MA*OAN~iMnsRfH?*pM8{gs&flJGQr>@Q4eq1ZnwMC4)3ed| zy64ZIe|{ar5b(>Gz(DuUU*zvXsm~f_TF@bu+v0Jhy(ggfg-Il*vU9i&7^09XY-!SfL3is01oMw=+<0u`OONSvkBOPN(&Wm24|CRYu-M^_clmsRI@E6Vi2O5HsTfyq*CrnqKf^Q?^^DGDyGgj_z>R@RGLqE=-UPD8ENsq-cmp9W_2*&+8QgS3U&jTUppg-(K4_w-?!PX4|`0`BFKde7Se8I9ECN%{OeuH_8Iw7?TfQyu)l%()Epc{}6<1$YOh- z|8f9Vl1~KYle{b};mf=k$cS%!U7q*@JNlM$pW{t-H1TOD?_eIam4tLw3GwF~1Y!^} z-^pU_O~Rp$VzfUCGm>aX_+WolK8mx-xbhLZ_2^Lo!uLz(6ceySkD<-zYsi{Mfr(ov z#FbE?s7~UVCf3vF3;+(ZkIsFxckbN1S|p0f;jh1D)4o>XJI|lr8JCY^h ztaba7r!;0sJXLH4rvy)(Om}Y87%d{sy9Lg>vji`oM*&dp^kGAR3ZmE#f(J%w!x(w& zkquVy#3L>DK7W2E@!(TWZciMzBrACynRNbns`l3H*oC+BGYd$1gSCkjicJg;Nn6Tq+tPaP&9fbY?p?QG^)g^U)lME^EH5{Xn5>uv zRcCthbQ3u};0JAd480i?u0oGmp+&$LC09d8?@i28h<&IgX@UAk7AC2l%fh|#a@+M! zfArZ$PhSrfnPJ}gd#3;WR-WwYFs1EHGw~m>xhIYNTjk9tkH>CS+BsXRyyLCatKYhV z=iXOp=plB7epAvwo90GbZk9fS%miMU!@N3cCWFcb`Wh%}qHdb5;Ezvj9kn(22c<|0 z=1V-Dyns6Zqr#F}I4tlo4og=W#e!(?V?L;mSnG&Y%ZANJ!lZJ0`6o$%5A z6$~H5XaXsLdWjWxZQz|tiVbWb#S^g@zi}?kx0O^PaR5sksL{h8B#Osc6^pS-6y!1t z-KG_c0I5_?WXjWVB77`C0E0X9N$$~z7hXOe1-sAMkd&T~4x>?4OukyeKg!$Ss|6H5 zgB~bOk%}NSOT8$!b!AJRrG^W~W3lvW_(!D??CLo`Fkp;@bdj&gQl!RTR&3Ba+^!HQ zcM>BYMw~rfP*6Cvkbcl06VyMyHCmL{3Z@kl7Saz|0P59!h_)Coo>-$bXk4NXvs9SR z6HF}jXQj^+Q;59=KB5$x&J7=^@jchhecIDX(a}&ek zaq&bvo@jmCXf_+^N9}Lu{ej0(tmnmo;H@o#*0YK+AJaokW}(q74zR({(gF=9v%Bqb zTXDIqP_I|+xK6n-JKxmLVqq&Pno8`~vU{gw^{-X79}C<(l=ZU*%$d@sUAF2xQ?9`< zbf_y*`R9)Y%p5AFv(pbMKjVFXev^KNx?$@i#U6B+n8{|*!U|=?=#N^iqzg!Xot4&{ znled^`m-4O&AK1Ey~P=(w7d~D{ntD@Q886Ci0Q79B3AjGaW@>;{k>V6ZlCj%e6;Ps z=ylQZG=pRcU$tiBwC&?(8N%gKL%zEp(_#oIci%RC%KWbF^QX0NGgLlcYIBh)+oT4{yo9ax;B(`_Zh3EE_-KeH0}s1>WWM1zi|8vM8yb;}!f zhO(RiZ!uU31~)ERJQg?5Gr9D$Xe*Xm5Hp*qC}v^p;w z*N{S;G6K<5kG?@5T>?=z=@LN2k=}Xf-`uBNVd4PSA2h4_n67NfNuN0j;swsG4xaJg z7L*Pbj#Ew^=PZz3RJW3j!b0VUbGT$csKSDU|GP+LcF9pJrBsJ=9lH5vrwS)Ti|K!5=NyGy*{4rGE8dDr?fg=uqmT+G`HiEHcE>4gPhlm$92*;Zd%Ul{ zpmt$35ulqOKA6%j;t{EBA`5A6KB6PRvexkL+I708Ne}>H@zhp9`it*R{N>86N@>x- z3&+I=F1F%dHA>wNv_XcqkjF)D`$D=XZK*6u*orDEi^MOB_}+k3N>3)%@GB4CHv#nt z?eKeKAnG4CEE<Mp%Hx^%i-A(-muYYU(^2Z)~Z|7t3D;wYa+m6+L8#*+-c=@Wm zW509ThTq(o7(us|Eq@Gk^yo;icf3SH!mP#63-wZru;#W47kX(!x~`LE(6$}Vi^47N zi~60;0vj61428fB)@M?iHc3)I^p`;w$?chLv7dAF#F^sX6=eK$oe@it)27o_nti2wO;QUQ$BiYO?c(b z$y08CxwPs&TMntO#Z)Evb|%dVLKxVcG&vO(48(u&^5bWy0(G0UOiUy_ndu-2YWw~_EjnngQRBr9$MJm7l7k%1~8!AYCYpA$= zT8QnrQCZI0jvv?|#|imD02riJ?se-8q?N#qnQE_vj^0^p))|_lA|{W!SiMfXd;0cd z^)uNLWtSoQ>R~g6)n^ngUOcz3fSs&O;xNh6oW$WSsNtI47tQYQuoc6~YGD7wM5eJI zeD(vM0&uBb_>k(Q2OsnXw=bliQaNbYG3DtbF3J~TOsU_U;tY z<)?53WlkyY6HG4WZb4hH%kt7RPE|NKt$?YRQdX67>@#HyaYvH4pnf0A{>X7t(qyZ__dbhJ@DNS8g3wYhwr*rrmI;~1cYLv&N zili4|Knm6RtQ`GL?L(L0OWR9m5@8WgvY|ynH;~r?jS)Uvj;65>V{deEnD}#ewk9Iy zCf9fBXLQlI0$x2AkJ*d7qcy02{DKo|6UG&+pQ&SiIoz6vG^GdTW$-wL91iKx7v;xf`du&bMkZ0 zDWdmMHLyAu+rpSOw8C-)tR1@fFQA+MV((ry8G4I&Tz;T0q~q_+N!MMs!}?LK-r=mm?8D1TwQF%q;k^xz(Wtad5na1(q_0unK2 zkStczCfz_zWDaN)WH<4v-qlWy>udvx^L@eL!MvsSw8|EPUet-{vRSrEc2}BPXYm(g zv&%;%@khy65o!*F$CYR6Tka6`CZj9kVuwa~skwI_5y2mv$! z-JPnCPwkP(WTGLx++|&IKk2l%j*I$4T^mSmmP?up==#je0EHj9kky8pq-br}Stz=7 z&PWt_T*W<`T`RY}k@M25_=EQqzV@1>--zX-JXZOU(U)SQmzEE*jjyE6N& zx3gD`g#u^M0q@C^d5_&5A2e%fG&3G|OuB1C{8!cAjgMLGKJ!NQ@~h*cS7iSRZSJu_ z*h#iZZFAC8V@Xlu@NclqH;?>(4VU1(nZoUN}no& zm0_%$RVIri4)D5v!PgFGvP-RS2?GsUQT^PuXEyuvBk%v?9m|r}*nI83TRc0zJo0Si?GC#&vwQ=pj z{(yY4dP&pJ#?dy)Z7*cxo|-))T{LB}?+ui*oxgTu%L8SfBjWJcz}k0RyiJ}3 zi9fP{qoBZ{yp7*GW3&qKHMb2i?*RCJMWOK*m~Rk+iJu%R;mBt|lIY3;x!b|l66o`x z`45*y3ngC#D~3c4n^lEKl(9+_i!&Pio`U~!+3e0Qy#@Y8qfZo9k%k;xMd|;#&g`*? ziGM18l!|S({bY9KbkrhkVMa&VVSlx?HPe-CYPAK*o=JZH`+*V;C0TDDYsM1yCu58e|qLKI0(-%dwMusZ?{BW7uS~!p1WyU$dRrq$O+%%@ti!fDs$>k;3swe zOt@YCLJng`F_`?_nZc|t4(Q-K(WDO*>fA!8NseMOmUNMb>J5dmojfPNFy$|D_4y+w z-n8bC)<@RdG;w6UKDYOU#E4C6r_8FnI)g#>?)Vygkk?ECJTFS%MHY_o-(WN5>=8Ty|-h$Id&pc$D*Epw+{chQY zVN0{;l?XE0BA_j8*p~%_Iwt+j4c|pi=htTtn&Xg^!Fba}B5}uC`aP`ThOF?hIrm0;S6zLX+Np z0?ny%7Y?+LA@d>U!o}(U7{rfO#X6ylmv_je&z+2lizmuw_4`LL_<14{$byGpU)@TQACXCAB4nM?DW ziH(jrM`EKhPs)lb``Ih(6=gq`!ciXC3xQYiu;mt4wpG~`%eBw>XpTKMrtGq2yDV&Z z^M+>e7s`K_gN_PErsFZ;;`~2 zxwpvUkUoIjF*>TDLTs)8#{sSoT)4jm+2IDD18GGdc8~qP4wI&ldEw*jB7dYNy}zcB zsYX6>3}==4Z2$O$Prmx(!twrWJ+jv6{@T)piXv+Uq$4mEGyt`DGy|H?+ zGWgPESV)nOk97V1H|+LPtUv4j&!6MB@(p(9Z{Us93WF!S2mZkFuxREfe*o?xJe82Hr(qPEN8kx^iW9sEp$L7-p|E;n{Bi2 zvy#pyDGQF%e0CsNhBZGa_()+(I@b@B`Xs+6I7`zaOxE6$NHT* zrMyS70w-*kkEuph1({|uFApmalndC(z?%Yh)sn30QSn=)9wlT9|C z7p2S$i#{I84rOMZ7Y$Aq8qVMy;FR~sdx&Q;gCBc0e918)>Lw2fe-y3~?3Do>6aMtW zAO2}V$AI0tk^b}X{UV7&Bo#vg zBX?XFBhgMM!+9hbyiUpI_gM!s_^O2AlM~9THqYDch&A4pbv{t~WkI7~c{#t)599Uu z_wI}BjD=tjmfOnnPyIZ%RB0I-t7pwc{bQAr*BEwIPFB9?yj{6J#@4pK3+4xbmE)uG zG_n(ezP#vpcsoK9*ucoN;kIkT&Ld86et47m;G~ zADaJ({++k8wK3)X_IEjdOamWr%G1$5johcE6eLl^xF-lmP-O#TQRiMXI9BBL+MBqb z$ZZAvL{;fK7~&{RjvLrAbB5Kl!kjUk1*R`wF>U!~L!L!BWOz2;JTS&e@6zX4-pI1q zvXm&xkkciDEQ>nhBQvN0($Y`$rWUiqW?nz8b%OGo%fByE%(RvouU67$v8m4TLZ_pE zF;UVF-)LZRHKriVX9L%&d%Swi|U!2ZYn*45pNP zL?u}1GUcH7DWu^^pURnjYvSw7@0B~*)CsNQ*!rw2XXcHjXI{>*WTXRS5vL|99LjUE z*x$ZT5toGdv^MF?kTd!IpS*khFnN*g-0ClbWK2@INQzm5SAyFsgwR2B+9pE8;d1M8 zh{4F?%ALw{sB*of)ZF6A;+Tk;nfqQ*(m$X2k}F58JQO0#uwVLs&Cpu6e7f@XG!x5Q z=_*oo==9IZXyW$4b>R zK%~1PJAV=663FfjXf0})6$gWek%4{&k+fC@pI)4R36hHqo9d|8mznqmV{H7?;%dn( zv#e+1TPJ{}9(I(6LXttB?Rt6Y7wqryq@0Gv%w!qVgd0{)1GKZ7 z_4$_9T{fGG#WM_9X;P-`;Tdcyts_`V!2=G#PZjG53ne{FiM!b$u0V$)UbF9_2Iup= zbN7CD3uo@^VP&O!Xs`0Qrq;6WyY<7pa~0d^*H{_rcX5q61lU=ebHS6->EQ0G1RP=z zB%@k!Iz5$y0^rK$*tG_51ndwpx9;N_GZl2=IpyqYr%$Hf+!tJle5AradOe3rN;i)5 z3sA3J0V)?#mt-~7zm@ZnWItyK_X)eGr!VOZc!5AX zg{27FCGFSYGQfHS@vBgby7Y+QtwLlj(oO|`bV5)M+YIS{A`qgHjz(x3P{@jKyaIQk z*ou`!NkJBcdrQPml!uajy#dxoH!fl8<_a}k-d7J>`sX&KSsE=)7=Yke64a&T>5G}k zm7SJ7&DB(2kQR{o4bU^)qP2y^KFJ)&G>^2VH+lkDp)8r{D`YV(C)aJaXXvx^<#~Ej zx!G)&k^nocByC=)a(kt^zOj537v}RzN(0lyn zm~46@Lq8e(mJGL{_(r#PZGQU5oD92cDom>?lx<@iqp(3Vn#9!wB~3+;4-HuvOw7pe zxy33mGfi@p*$Q$B@(Z){j2VpfQtV1cJKg<_=6;TxbemmD&v5&l9z%tcDe2@ApUWgI zu?79IsFzJ?rV@kEL@G|wo(S_WXAWyNSHHT0Cn>zQRC1Z5LK}eI<#0_C*SWMJTQQyC z!A1g#c7c@cy)S`i<-@6R41~5Gq2`hd@a6vKnygO}8+fA|y9EOoG_pf5#O%XL4JnBn zv9VgF$X}#eaexcMI)~%4R_vPmvX|DntAJ1@LNTAcW{f$II_`Jn^y0m!pXaL+nns4xzAU+VF$c{P{P+RK+NU6f1Q zYTj>1Zt8K8Rx46lQ$qe;yfiyTuJ3&~$tT`*c|0z+$HN>f-Q%W=*%GyeuMSrf{Vh;L zx0K?5hwjJ+F7u>UJ*FS<1U%kK?=)sMySzvnx4Q~T!r>B6P-iYupXF6RtPzDtLPY+V z+ziQ$I9CgF&z+ETryz}H; zf!Q~V8hPq=_Nu9AWOM$gc~cG@nYds?-i)i7T(ehQ%ju-P`)hfv{1f0tyB*jFpuh$5 zp`)yHz!ryp8E|pKXD}R!!od;O{028Pt!Rb;ci4a0m$tLJ|323iC@Szphi)Bu-P|F{ zABGNX=P8yqbm&%-VQIT^8x<*t4rM#7{DFD4Ky86#p47VSCsL~NkC z4~9!UBu?cAGa4IbG{&SKIYWWM!a&H`HHx+i&%p%~*BfU5JamLMh&7!;6|{6$p+~H4 zavao?;+=cyg~3X#etsC1aSgoe_63*(XKsubddY1ipF;7(km5m;qUFbS#~zWwf7D)OqeL!D+ezfdi7Z40<)zxj4r6mcIpk{o62e1-9tt} zB8dr$q(@<+x|&9l-05kR0ZlG1f2BXEQl=*PNoBQy&IMT7t#iJg+?&i z(t=RMM1Mc`+ado9cXm|oG+Is8^lDSdhtFm^jOkL7GFTnT=$7+u)z>^NLg8)mK8%_{Gm zf;s@Z#nbp>mDk6vhh+wK8&%IimTZ`C&f!uE)Kc8(`I7pwpu^+dugUt7Rn)3=K$(lf zdF0|;>r1KcVl}7-U>Bkeu2+FIo;I%Ju?dw0s-{yRGVdEYf1}6F-i8`s-BvpWt+D#t zR0VJ0#g5|Ur8t_Tb(RON;aCI67!~gYk6LgM-bF|fhpfSq$HWNMLO{LP`6?`cR7^B} zd<^)WQx6RpjY0}kz=FHGHyJKs3EyK<5~!z^xdECFEi6?WTl)RCumKkisA@nxNsNyW zI1MmWL5>YXHoakka%evSoe9|q1co&{$z^EIp-ZvMBVR^_mwjJ;@ig~P5o=Yq6LL?1 zCQiHheFmo#EYm&rs0z{__S6IVgsz|OF0s+!HA=l|(pgJMANTYZU+yD-f4Qm$UV}1< zjfa0s<#&Sy-3p1+Yu9l#wWLEQgB?F05TAd9L z3Q0E6h@%nayB*5GciH?M?A)4@6%t1Cw3@Ly~}3oNPOqEN2!mgKX09o z^rl*X_FZaMCdVP5k^Uz1xEvj(Wj!J7I_e4Pm@+m`xn2+|vVA`Fx$sPZ5@$yKNm@kF1+Q4>cU8pW*FUVaEn&urJfoWAG`zW{W}K_ z-jV$4RjKmL;)CqrcvoTa{-z%sBvMgnn)JoAYWLMn>PW1uszin{GxgL8Q3XN)_ZzIl z2J@0u@{S}!042UvJ>adVM-|<~*~-eEdbA^91dG(Zm)5f~{*+94mJkr zP3Y@1&u=m5@`+jCgfS)cOa%@xg94;2yvm)i#9400DMNMCN2D8A1eiyVBKbx=*9VFq z17HP%hfbI|k=W>fc*`&gcU~^*NL{0?m$7`>k9pgW8TS>0+c}^+N&oFY&L^^K6 z6R}W;|H)H|?ABYdMieQ#3TnOCdYy6;O3RNxUV1~hirUTo*BgW+jhp&QeULn>HZEyL zp_Ry)ob6#s7fK{ws7JqmmzOqd5VeZ~k~|J}5*Q0|6jRPvoG~Yh39dk0pTo}OjKzzp z=*lu_ohyflb#lW*L}&$>;Yv>^0GEAs$7+{CzW!GhaczY+)f;$ zB>i%#oI?YzD|PDd?xzY^e^AWtjfzjhHo)B~{7VxDu)MYN6$~#Lpac6j7D?VYEzl!V z`lrmV%+$)0`7OR+0md&WSl~giAnv>S>AM%i7bx%HHu^0~$dbP+KSkCqyFriLW1$p= z%8r~t&{<{JVPnrmP9i_t$5>I*!;2Qb_1JAiMNenx?XTKvverJdVdKIzR=xQ<<^l5d zeHs1lf2e)Y;)ff(Y@fBte4kmiu35ZcII9_)YY-LSb zc>*1?!t5+`(4i!}f@6i~Dx1wx~S9Nu`hxbm1Cn_4qy3FNC?n9%a_bu>#r&YX&zx{%*L`kWNWPLi`2`d}6 ziJYg_dSOALOWv33L#8Ia+=B-ETvGcZkFRRP5H8BK z$=)FEN$LbO?z0!D5BNIMyJqwNRjIZ=)~ileQWm(Z&P)~_01CgXze!IDXw;RxYhvei z;sg4;w14UJ37x_1qh%5ppdH?WL|L$T>WOprQ70_#vCS2c`m)XJ+~%_SNX6#fRZ}Br z&6~D)#*EF=XpUTpLlMq*z&EBZ98zhG?Dl+h{GQ>}g11{k04f}c%@ngcGopd#q;X!9C z=q+q19yF>PNIn#(8&i)IL8S;*AH6}zixiGH)70V8;Nl(-MZ!j48?QFs0}R3Q>`Gcno>A@aRC*P*9qwX?+$2H zzCK8QkWG2~HKZCgXDkQK#w$Oh8@mU<5sP50$3R8p-85g}!p8du_BtRBbuBjsxSXn4 zz~zRvmXz^UgI7Eeh>Tg99%{I4R_-HnZhl%cr;k}$UnMUcQ&)+q2EgjLbWC=UXHnzq zyY#beeEMcNOA?okscm*OoVdj+B*} zHlUGVD@=kA=?}^C2(Ci3JklEhR6CaR83ZQU1z;&u4OL)hD1(A{Ar3W~@5`*HQ{@io z+Y!k-wqQ-ztp2fffAUUXR6L7+JC-6O9jUlT#Eib#fUdyQOpcGB$RqCK4?!3!0L zvt0b^>PX4pYVSPX6%efxpoES5fy6IS?q7V+Y{uJ8ay)k6^d?V(z8J4ZfSnCTQ2bt) ze`;XQlI~%77K^!`xkUL>`4z$t?|~@xW1{msi_%ef{F&bFrv0U3OF6A!3n}X z7$wTIDjig)3HXQzD$VC`nTJc8J#tS2$Q+Xm`zE}VNE14xEqvy5ZJ@eiYo@TuDQmFE zRq}0{=n5@ONV7dcvxXS!Dn<7&P%Z3k*5`$ zUt!j=3&rpmfcJo0W_9G{+FVl-=l?ozpe;AgVO=xWa_dx^-sYI&!0*&sErXShZU~y{ zM%HD};WkIPAw54(f!FR-z$NZEHfsDvhsU1lw3piN7_a8}qqHqs#$vf*LgKabtA z0B)b$g~i!x>^1d-8#|$lkT=p?LOU4V&h)2vt!~6 ztFFjpOt(l1`o`_H(X{!td&#HqS)X1~Q_0^&EOhP;}*a(7OaYz&N_ z;R&omD8Wn;RVn4 ze6S;}Xwi!OoCk>T)4H4MAEPdKbKrHp*!R^$85}txZk=@eLgq8KZB87v^tY_CSj1-U zgn7?wQxcMK@-9Nb>VIds!$aXej}+OU;W9 z(vu)>EoR36awH!8KnqVJPxJ9=HKu!bmY#<;2G(Z|r~4atAtd3Gz6)=MrZU|xtKs6k zWEqMJ5SD3Wsl4`#kc%|Ihg8jD88G%BP0!FZR;9W9xL!5!)n75hBJoqY1L`B zrtM1?(#z6Erf*39hq2B$$M~@Eu<@&mK*qX^XEQoXxu!Lyw=)Bo_n1TG?^@C<0m~xG zz{3ATeWSt?ONM?w!^lM>_+% zbmTfFIqq|O*Kyntcl@X0AI^MdlXIQ(Jy)6QLDxBViF=Xz3HOO?A={B%o;@l1iR_oN z&t`v}W6T+v)0%T4SI!-mdnC`87t8xe-skz*`NQ*97c>_fD|o$7EL>N3swlr`LeUYA z%TwdI!SjsgjOTCO67Ll6J>H*q|5jXGJg4~a;xoQ9-w@w2-=n@0zRyeYOClxnN_LjC zm!_2tDqU2%r}Q(ND%nzY!k_OS?qBCWQ7)7ZEWe@rNcqqv_{SprSmSGU=(9=c zWimXY@LpbJe3qJtrOO8Mq-(Ua9cl80rZRECB_?q=EmVsSuU)$~fd9kP@0DAH|KKs7mtT(l z@W8L-27Em!5N_hRg~Cn3LR?*g-xx}cLd$1iUS2JXMy(Tt3BpvAyBe@=5EdaU1^mT$ zW(vwL##<$B;I#ztWHra7L70x(XX3erK4D!BX+SSn-xdQ;ujgj)cH9IESMfeb#c2|6 zg^FPhrb|%rX5o5XehpfwJ`sSgUp25_ftD=?Oe(Vo?W49YK#vE6S{~}q?;-H7zVQ9` zt?YZG`o6kWpl<;EeFH|h1>?U|!}=y%CHzKbHjzzYli3tDl}%&Q*$g(5HM3c4HoJyh%dTT{*jzRb=DY>$db~z%AzQ>2 zvn6aPTgH~-9KZ^;lC5Gb>_)bl-NbHYx3D#AEnCOdvs>A1Yy-QUZDe<_P3%s#ncc;< zu)Enk>|S;syPrM4zQZ15TiG`D5Nt-<*~9D+_9)wdfA;Yhdz|gUy0e?@VNbH}vZvTy z_C2eZR~ldb$-Z>vlpOSdWpTve#Cyv{)3%> zmHQ|7M+>jApF#@%8T&aq$xg9fusA!-UT1HxGwhe_SM1kV;of3zvv*iKdzZb(exv7X zDX2yv!!0Y9R##tDO>wBYIvEGGJim|YVJ%;y#kE=-(c-8U*J*LR7GI^tp^<7_J5nBT z%j#7;6RB1!iB_wHqt(372n`9u{61oi1Y(W^VqQ67UO8f3IbvQpVh(Rab&xj(u?8oo z!3k<`g1j-fufYpy@PZn=paw6f!3$~dLK?h~1}~(+3u*8|8a$kMK&OtV4r%a08oZDO zFRZ}}Yw&QagO?9$aKaj#um&fr!3k?{!Wx_!4Ni>)r$&QQqv2Jf!Ku-nuhE{b(Vnl> zp0CxOuhpKf)t<-ei8)@i8k|}UpIQxGtp=}FgBQ`@MKm}O4NgRZ6Vc#AG&m6rPDFzf z(cnZiI8hC+s0J^p!Ha6}q8hxY1~00?i)!$q8oW9UUY!Q7PJ>sc!K>5Y)oJkRG(REOx>!3#0L5;418eIo9x(;e|9n|PLsL^#$qwAnX*FlZ0gBm>tHF^$e^c>Xa zIjGTdP^0IdM$bWwo`V`a2g7QA1U0%2YIGgc=sBp-b5Nt>phm|*jedhQYCi@wIu2^| z8`S7GsL^jwqu-!Lzd?lBXP@~_VM!&&`I<7&Dj)NK<2Q@kl zYIGdb=s2j+aZsb<(Q#0tzL5+@s8XX5UIu2@d z9MtGIsL^pyqvN1P$3cybgBl$NH98JzbR5*^IH=KaP^06ZM#n*oj)NK<2b1($ug-@c z-fc?!0jq@mmf*;mp~HAItX7S*+z6f<8KtN;7*eAeHHz>k#2=^)MM>6RliwO!E(re{ DlhOCh diff --git a/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.woff b/vendor/github.com/gocql/gocql/website/fonts/glyphicons-halflings-regular.woff deleted file mode 100644 index 2cc3e4852a5a42e6aadd6284e067b66e14a57bc7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16448 zcmbXJW03CL7d?tTjor45-QI26wzb=~ZQHhO@3w8*w(ZmJ@BZ(tbF0p$la(=N#>kvm zE2(5vQkCfPhySAC*&%gOhXNAMqjXaM8ZdR9h1n(j|bAOHa3xsaUpVQb^?bFN$mKV0Ewcy3Du z@-8k$`ak32WBbVi`wx;7^0Pnwe^+&aJAe9T8!-8dp8P-m^j_k+W}s`RtGffD4+(~# ztFH^%r@=P?d_)fbz?K5R0s#N*H#RfO?CBZn>6_?x^z-v0gc4w+(WBE}13CaHLhywQ z!#%^j8s6#2z4_*~82qM%VW?EZaP{qr6q7)~zyRXUfu8*DIFkvyQi}2zgVP1nasq{A zzK$~<^8~1Leh9gA7?OYdWb(rhHBCeLF_~b@=XwJtb#c@X=&{tLR~#2+TS{-c`vBYE zGBWX|sg2q1)>^5WQl6tV-S^gSSDaqgl)f0g5bP3XzB_opq(U*a%n-{&Nsp#<PXeb*#gCojQ<~*y?%~jIH!wY%g9nHSRoaSF?Kj+nhFb0uC&n_VOmpd_OBYox zmnx5#Y6>`tg|imfwPr|~9o*VGw6l}bCod<5GtgOopG#Z3FYU1yX;{uJt(#*r8r_e7 zFtr;Gdot=wqBrPOr&Auqx9S#4&q}4+IV@$;lS%g;OwuPXe}-tkmpsZwyFbf2RoE|~ z^I*n!=-?L4caqmD0 ze6gB6sXkw{<`|Cx?yb^4okCyXCb!Pswu?l=&V6!>eVjh=XD+I%?*-Gd7M;9>8h)~6 z&0J!HkB*tz&l&C|b)oTW*SdHifwpF*1$>(yA`o_PKmUNb%3cQp@DV=5e(dQG!VdB# z4zOo2dD*d^}VrwZDE>cjbvV3uXQpX;>NPr?6LUB>JyOhwrqV5Mj1Q8A=HxZxa- zQwXEXE4&D0kFPJik^cKOC{0^_Gd~wNu89<_dGZ;!WUzzZ3ld}@(h^<$4X6-4pZP0> z4cT8q?NQVurwRI1@u5c=cK!0A)|eeN43pohgBKnf%Zphd-bWZGHIQE~`m`*h=F^&l ziYiYp2Bli;gaHnZjhfJboUR`tiB7foe6NfemF%KO8OT@`0*rjk^<*{<(SKi84B6$c zSAeZ)XeDt@7mIt)7s!bPz7`HP9ftqc{+RVQxN1rHewmj8Yp3IVyy5+hfQzfO*PnR6 zhtk{-Yu&KlSEH<_;xUIck%#8F?#Q96cq(tN&Y&yCP>~SwZF+9EW+Z}7E5H4?%I{Wg z(N$R$e70H+BskvgkMrx=s0NkTo4j@vUJI?-vt>?b>ZKxs;_5=f0G)6f@U^u0(`_>iKBH|X`>9ka9q#!rMTZ#DaG+DNj4Hb@5WUDRx;OQyC`$YMi^IjCMmr8 zI(s_$k$_>i*!Zw?b0n%}L?TE;8iYNv&D5Okc@@2k64bhgEg9atc=7JTCCwE4`m2d) zotf55o`s|4kAD`L4d20r!>w61;4e~qalSSgRUGOBHl z9RTUz=#A|RA)-_XJ;fPvhjE(w=K~z`rx{{e9EixI()Jy>7>q7pDk!X2)o;7@b}3Yu z9i|Jv^->~KNaK}*?iz`k`wWk?k2H%PP(=B6#}1W+=RSZgxN>tnUk$!WK4gXlQ5YlR zTsK(s$>9-qC_*h|B?@VYC<>v5_KI>C2z_VFA`o{64(?4{0alZ{Nw|H`!{CqynYP_3XpLG_k ziP$}NfO!Bc1h;p(xMku(+}e9AFC+)*b7-cf-zFY{y5q^zfrbBu7o09H&lgsnQ0~~g zy2GlijEBH%4KeBzhNc5k{iK+Y1-<2Q>UF|@>0Y(&Q0+KPt-?=>*O;tSLw&e#b>>(F zM@%`Dp)}XMSMJ?EoMgkl7E2Dlkm_n=3YT5*wm_QDoZ>7lvtsY4O)?QU&&U>WL1boz zQpm^5oPSA<)4GyW3E#Ps%#pgS9&NNgd{L&{3U4mAPIsPKsgeU0qP%W$`ZjtthBo>w z{j$ZZ`}y)?bf|%(x(~j-JG@sY%R;$v#5BH_v+zHz7j`4+RX_0>ExySHVGK_8?ls$< zCG8GiJ4!l$_CUvA=~B4lvLPO5zU!YI$VaRmBu-~t`|-fjE8m|b--_hjHI@%Obfn<5 zqFvMMzZAUzVr-;8sF5B#27-ldl$|mdx)l)mQQFu2FIOtOc7Gu;oB3aT zkoEXW@GtHDhHTLayMa&3)3q|?*fC_}cttu?Q9^2h4(mFdWi>)r&@Pv28u{R72XTH0 zZRuM=#0U~(p`Qab%BV&JME9I}R{we>pw1JgB;y5-iwrmRLHP%hMOR#-7%AknieOMN zo?28Tc1wE+o31Am+Nv4Dye*YinTqC2UW;J%&TbQ$KFih z&(4l%v^}kxB%IPw1bwe_&i`(w`EDZ;rR4y4yR?*>qOb6Ki?AP+?18T2(HMlK=(_{9 zdm{~sd*AEH(5!TkVTELf1xG!^WBK_T~kY*#Ba=bK-yDs2kr{xCsRh;tzmzhb6>9 z!z+!FI)u7k9fl1aR<{6Rb(#qU59Ak=h_2T0ar}&kf$rP4^hRW*)_l%I!1KROf`P)) z2MGiZQI*|?s^T!TAY`p_e+dw98bH9&ELHjiE7;c;&=hB;DbKUs*7chHcwS>>?5k2X zp7QG43(FDIEQzG>$ws8!ZtSL+a~6-GO3XhBmGXD*rd@xN*P6&K%~IvQsKK~mQb@B& znOIXfL%=A0T}>ki50;ffb)L6t)Hpo7O2uKpP*QnuNkvcZ7+jf1M9EJKck{Er0rd+S z=^O6^6DG2}`u2S{E__E%YL(>)Yet6OO*dmT3ItOyJl?OsHTW3*HpI6^v($s$sAGQW&Iq+~bF@Em2$N)h_?PSD zFNSos=ZjgM*=UQLi`D+ET-=unMuvArE5e=BJ$R=i1hS?y}#89}ucRG*1PD=%dmAiyfM#)nR(>UJ0wzQnF2;OY3FpZoVXs+cy2w5;?GQ$<2e zu|#iFD=ow}--1<8ZyobjRWkurqBk9Rt{?GAKrI;Q9zBLzZJaQ;ho{E4;I!6;pT$iX zS#$C8bIak_Kk3dF92Spdm6>ggwrk&Z%+#hbn9KM1UQBdba`4JOzLqFGQ$(Mc6`_Sa z>2U(>7)j=}3e*Pz?%(KIyA1H%1{)%%Nf*%@0bM+D+(`kq2KwZ*I4VfHF!=@9FDvf( z`D5Cx&Iap(E)z~MuBMM|Ns<5%P%f*;vidnD<8)(8dNv&jv|>5$nb&i>+#`geKYw6} zs3PT6u=@HGWyd^;J@9Q$(ot!|lp4;Qrkl549^Q|)eBMOVeorn*`w#^4TIQ!@;j7&} z9jKr9SzUF3jZ=DpFN7>#&2XI5qjeoeB~fm-glu&dEb0p1Vc|JcV|rPadNR7eIg+YT zLWliky9=Z8uLXGp{|#G$P#Gg@h1E>)KAdDmO{b&8e2ke8G}t7k_78@NFc#F0JXn|K zBvx!abv-#UJu8Tw>T4$Mnk!cA>%@Qq*QbZ};0q`@1DY5aSuFp7Bp-&rG7uC;x6rA7 z-&=2G!#I_&T8pGOhQO5XUKHg8{w~_v^~rQ=q+?je+e{P>8?c)n&tiGj12TFTV;$st z=imv0loSAktP4ipl*=6htfl+=WF}G)C<@j{hH6KSSnUA^irkKXuN>mhbMO<&)L9qz ztxRgH)b)$4gWy-G7G{hdY%H>OqmH8Kiy4|O$&Qj{IOnqbUcP|=?pi__3Uy1aLIaXT z;d4MJh&5FK?Qa(sU1p@pZKR<{N-QlW{S#Orx5zh4 zlU(^I9ua#zo)9`cmCW5Kvt)91pz~0b@&G?Uw2oD%2yV27VTW}>Eenh@0=U_{(9%HS z*C(a5G=1JvO&8Gjti7os4ro{Vz)^K%IlS?fIYb%(zC8>f85Ll-9YkHMM6S$>y!cYT z1!SeBmg^~lOVX+>Lz83WdPQ++h8if4oWH1slf@6-32CtPG{~*G_I6H&G&0VYX-=$# zq7{EUG?nMAbXe7^NV!fPq7}KKeYt2&Fi7xVgvFQ%z4Z~Q27(JT@Cadr_?d|J;tJeEN9xPppq8Bu@=l-p?5xgbM{uJIeJS-PkEfhDz|l3rh3e{N z6Cl11KlvT7)QQ+Xl`qK>!Ae6u1K$q+%+?(XC?gGoN4>bRfpG6Fh@Q{H2N^RdDSz> z9#GX){2iX!;5fyiR~cPQ9@+BDz*xjn<1~BopQ?g3p6ZM_OE~H2fF1hvX;z=qfH<`i z_cPC*N)R{+*jZy%z|hj71bRpZ44Wm3Hy?9bl;fDtL3zH{a`}+!);WGv8VBmF(Ag<5 zvs#%3Mf|+(y)9->pV$x9Ce!7TyyjVegn{&u;Sw~l<2as_WBAt>PSk88Hc28D;TW4s zN>HnoZ$=YxHg+OkcX|B&kQ=@aCMH^UV@sD1ZauA(hjO!9ebL?KskYqa;piGWM1P^y z1@Y3$$V5t!4}m9XMbDLXadOE(9L3v26t;yxGY;P}ZbMx+#Gh<*J5>WKi==HW>GtE- z0k&s-L-LJ4?!0cLr4X&4>&$rrPIuZCHv!tRJ0`AyV#S}yU?7L`D3Tn$iMEOF*nn=M zIDL9;bkMPXrQN-JL+W@>%o%^wD{XBlQ>A)+uI)nFTA&;MYtebFrK1q-&0p9k<5VSF z@?(|%Gdp164bk76uKRMb82gs%moxKY-syEm0U^sI38*rKAiLv8C(>6E0j2T zI4B48ksbj&V)aN9gVR@x`Flb*{v`D=w&v8`MavBqkxb>4 zc~+y2AGRQ?Uck}=nxIDfq{ zd;hm3d8#P^Q#M5dNa3yGk(4=vl=k;PViIqw%R~LT4L*_kZ&GXvChe3)^_otV+Nkxp zwzDTrd>n_#DJ5!~)aSi&x9#_%1TxNL3@+q9!#3q%)Z6q{Z&kvpb?l?tz!i;sptI0` z;AF`$Oag5*)Xjp3N;T0yVn{^qBdF6h)Ck_Ue@nNQF+6W9>e_E0mrQRrBSGbVt!`LH zuaedju6j`$BvedYKBHA2ecp)#x8ThyKcL%t9zLH^{mpC>c*G-&;?>pDU6Zr|Y0WCHAfrOseG`WZPzMHfc-H0N> zQRK|s>|TkRlvYl_B)9L{Z4^4UG~h9l=gDh#iMZu-lkUBzpq3oxA;FJohjMo;j41a3 z22P0kqTrNq(`H}pKIwGX*)WfYX5tw$?mhDxE^3s-%sce9W=+wsS7-imPiGXkgDsM6 zowj>a_V}8QTB;`$Cr&tw#D@sFvE*wgI#!HW@wE`#gc6z(W0-fGSMu^44^NHXUmRo} zjD*Umr|s!tcFJP7>E7ch*6h#Me$J)$ULRJ>%&@s^%fD<}tyI4m=q(~k2Yj_PL@fOF z-`+Ipi3#=$i7;V#TQ|nmYadI+(l%B@20A_0h7lYrR>tmoXD6#*RMKK+TbdvI&Ek5E{W>TYiXL>cS-q5P9fP{aqMdq{g1fQ4~^4 zB<@ZMjpvP~FuYacPKg{Q#;1f<_zn4dgEE#2)(9QXIn~_#_hpayOcnnri%k!k&iK@o zdA4n#?9<(2(yYmL*41h6&YyLQs>SNJho)Ae4!c|Z%WeB2;_`&pQAN4O*{8vR4$N0D zhhEvoTE#EP8kJ#M$`|397jd)iTV#!BqUZ3uP!M?TMyhw0K{W|snIa!*7SecH%O+)y zBlwJ?4(CCz>xC!&*J+O?! z=_McM8)pWN&%c)@;2I1TcTq~;%rhf|p}0Xdve(0rcre)J-M@KB$(rDbbK2Cf84qho zMTpD#+f}g3mc3wKOn`4>|5XdTK(4L-4S9lNkMn{)-voy7QmHX9to!YvVlg8UCxLVY zCbRy9nS}dFo>PfqDk2WfN!t592XAU}6~Kvfu+A9M7_x(C79i@#lgQ}p&DhNj64FI0 zI4sc8w=JauYjuSK_t@mZnt)=kVrjm4!>34cswwp-vn0%WlVZmhF31ZR7Ptv|}&DCmE8RN2m3rG}~5+ z07c@dPb{WT!B&%LSTsSexqny^i$20G((4$QdvnGZQjq(XfnQV=5rgQdCUmabx9?zK#wco#!O>KX@_k^Je2Q$W*QEtQY*y# zP3qZ{M%>vS@*3Ru-N0RMn#E>5)5JJTgIn)vmpeMhqMH8acp{Uxy3Kv#BhBFt{omz% zZHuxMCX74Hf`Hwa?!BLx(O6;Zh{oh1 zk9?Tm2WBR8GEiCj!Ywjjg5qkgkPm)OBVoAa0Anb-81s@YwA8POu|YybRh{Z;Y(#=@ zawHH3n>7}m6HFy7o)u+jG#HquHrn`{XwYP9Kbp>0P{)$LPq58;1P&37^OF|AYi;g( zE16q5W@YMaw(_GY8gy8eh?GsirgiJ?)11BHon@2 z2k?CyXF^c}@a~onwJ2e|$bbMr`g-rOR3+#ozPd#1YrHd=nv`(%_VP<2+PIWPF9N9H zq+6r#yodRe~GJSDxd?Ysbs(A`;H~ z2cshGOmhy@h`h}Qg0l#en1aR&tgOq58Og{h_aT_b1|_!y{)7i=8)AC`425Fh09Ef; zN&2hR2k%RQ-Ib&6T}w&$)d#LE`~BN1n`xW2bBb!JP938R*}P4syXwi|1=W+q`;6tI zlglY7sem`;(Egfr5sE7uEVom^we!@iKGxnxZ#qanxh7>x2W2Z37J++aIyhFb6i6i+ z-%r|}!ZM=pgJka17$qBs#RWv}k&v)mVoP!e>9*5Rd|tQtLODMmYupBbTRto0vVNE~ zL@KHU%7Ug+km4GhdVO;$7N^1Z$9eElbk#&HRa2IB$&aL6F+ZZ~-%K8_&lArt8ZFNa zZ>>@-;66ED@^3F8hF{M-hN49}Z?RN8x47e(yE^-6Qr1~~``1k+jokRzdZJ#T ze?CJnKrp8Y165+f+?bw+@_Y?%u-$k&ci>&Vc9##X6b%V5UtVQ*F}#yDp3kS?#jw{a z&8gS$#pxj?^)F+5IVA)w(M>1t0UW|k8er6zQ)6(%j<9)3`6h+jSR~?fvI3fPVJVM+ zwCN#RBLikE)5lbgaD2zd0Gq_Nk%QjTkTEbwie6*tgDY65K~K&^CzhMnZ1OIY#TcIE z17&d65gVw?>P|QcQFP0(gEe1c%<%(p$kg7L)n0cfC3mJtR?d`sGa2(^aQ6>ISNN?a z-J^~O2SXiYVn6bO#&kDj*^5@Dq(FM5XiX4+0uyC;ECk&Q7&k8-5s%231WBA?$q0a9 zXMy6;|QB#W|+(v zO`d8rhA}$HuBy9OscnOYCeZFokYRpi@1bRp-I_&4qY0mz)dv8 z#psFjfRS)w6fSp|gt2NY0OR?&ol6BnpGjYkiYa3CnjR6X!%qwmPg)L#a&-Nb{oV2H zO_$lCeg)Jzczqn6q+{^q-BgdzhMM-Sbi>iS0zdfdq6(c8zG7_{jgca5gy~#3d7O0} z#=MarJ;x^wl?0x2m=3AZqWyJqK?Ge;x4qX#DpG8$R4pVvS1%z2%!}@Idi(P#hs=l0 zbeX2*YrM|Dr`N*!Ifv|L#sj|afrtl@aUa4)SDlXmz+EP`&5FD zH^4h6n@v8B&1dA=lz<+14Z?%#FV_l(PX(uP^O83`(#wDb`dpW)0(y8nGWxbRTN4qg zbPU*fXZ^u~Yy|M%@qq=pIZX~a)a<1{R}ixEQ{PwCmvJcSi??WZ5K>LnI@Cj9K={AN zbtd=RRU~KDiP{d~1tc=>BfLc^!n7cB9`KcuG*3h%hC>>Gc-FqGJ#D{Az`w4n z>;DvS&)uSF;os}x#=WTf%HmFzK>{QbkiW!_RO6LL>ck8dr}b%)tf7M}m$@%eVNR~$pjWIY>)K76S&6D)ErTYo$!HbpW?J(LEb1Oh$ZHwXN1VXL70mn0hQUgw2^-o1YBD=iZc88NCXQc; zG}na7)C7!ox@$qVt+U6?6dipyH+rh4^T|;1{c5 z+KB?(kr}w(*g+=mOvH}!!q=G z_xI0Tg_ykAxA`S9xAJZ$P^cB4EX&1`Ps=_2hRR4R!B zePQ~o{hbjJpb3KMMZsq1*J@(r{ltu{JFT3YkH>GUB1~8#?T>dK(ZY)hUEV?TAckZEm<8m!rW?ciPRR}Sl6Yh7Qq z@;hYn@cSF`r9^T-)LuFshVKpK(d^`c`5B{_nCxn(lLIv0F)EirmwNF7Guoeyd}Vkm zve@n34B@6edk^VE|A2|r`k( zRg-Mi;u||Z`OySCTK3@T>(UrSTgPBLBFc4pTFx2xHmpm;PO3L5{mkDGSOUGEZ$3!5 zLj6t*e#X8riT-kd@x-b6y~G?N@rX2u5QNA4ld=4cAiA!g#TjIOw^LMNR>9B~k5|tu z6}X36Ay|b*C|MGbBT5Krbc;*8Q(0;IU@;5{`tp^#?0HS14m5^2BAtv7Jr<^r1yQGu zP|-$dQdV_YmC&%Ml2j@pjzKzfk)XN2JhaOcS<=ftV9^@Nn9S(0f6rT0GqeX_^pl{X zRfjUNPfT@zW|`PwNr9da2U{AeQ|S;=R!Bq|Ku^+a?TuGF-A+MX+36CbQ(Z{d2zybS zgye5ZsWq(9HY{3t;~hhCbOvo9fcxL?@`w;9S0%{PnBWwuFQv>o!S4U=j2?e6q-vl@?G zk~X>MqMKZrw9{AkYtz>yuM4k*q2jbBOI6D#~xqViag*hj9#4yU#j=25+6~h{c5z2|Mh?PZe?Tuj&(Su5)z2AX0V3TOflX7$@yQZv$<@WkFiv(@D z#q*Q@2#_7oiKZ-KGIjCmroEgtO4+{>u$!qm+{V4gJ{&}%Je;oN$4BHJ??a?9w%Qn+ zA49Rv&qUp;b?CTvTi+K}?3$;dHhk{7-etD%(>%^w>PoIidH*fMSkYjz`n>h_E22eH zWP2%hnp{~e%kyA5zbbm8eiQY;R^eibVl@I|K36Ttm7u7d>!RA5qLM;xI$|Rk0aF2) zkQ08N{@vimdl`nE5-VHIvD{d2{e&fI;$>lRo}pCOSZNvkO>;G~q>pM-A9rCpgMP$G zWLM)e+H<~}Byt%;WYf|m{|=_vht2D&3hH^7!^#E@E6t+KD;tAYn#PR=w}VOBPmEg| zFVg;q-Ik&r)BN*&9N~=b`kPs^IpEPMVa>&Od2zB@(r!B?A2Ej(DT!k^ul2^#y-_7Z z7?2%^K~~D#ZBVWkJ>OxDi3|>V;#!jCPOm0`OW1~)ECr_^6%~w4oZvjvP)Dl~9p%1gogfOFu6PbC5kIiBpYj;{s!w655Podi3k^ zSY;L!&rb1E6)u%b+IgZ(lfz>!iiJVA5lsc&LPq;}hTQHBWee3>ZNv3Z=n~29XfgUZ z7@9a>q^mm1nTO6E=P`_GuWN{RTvOTsRy`GBffl_SeMb5?X1EsJm&1tL2X=EcYX5|B zgnsne&jRtH8Z?rnneHz$2@{_;BUU;!Ix%egsGc1LxW=C?kK!IH2K&VTG%km2N={MP zDu@Y3Rmk8EE|=^HZ+8aS`10U)bO|FJYMbA?RzVEQBlp5+_bOZFBdnZKqtyEfg7Lyl z4adqX_*%-0bpw<^A!!js3?@B)M@#atJDMOHk`m9qL}&iI^s8^z37kB^6nF#kbL}L$ zhp+R=>NZ&qczRWV#K5@2uE2C-@U7c1kfcUQ(5*<%NA9NzM&W78uQf2@albRKYyS&t*#b-9 zCxDExUpqG^6>dJ+N<1@{U39t94_ILuf_0O~AYIG;^>%!k4{xn!`(kA2|5O_x$J9}n zEmE7PW<)Uw%m4_GH>Y)d(sb2|WrJb|iOJ#9+XSU+53T9)rL0@K-*{#g>M~E$tPw(A>A*=(>X}~13FV?jQPpzRnmN~C|6*YBW zklLeHW@NO5Z)YrGuPwGO*R`)bsj5{y0u{S_4cE3JT6iVS`Sj<%N^~Zz?qHb8VzPFM zTOov74bZ1&W@=h`Fzm?fb}Csc!CweLKugfg|EA$!Gp|#fNaj8i*c{;o+uGdA&cPsH zlIW9@|A91NkcXwDplXVQX!DQ)ila%e8v5}3H)1?N3CNYLwbag@wLZ|9`)VK6V{j8Q zOd-Hf*EiA7f+HJGAVLeFm?rHg`Yc~1X>EkG9^Dv>XypCXxJYw0NMF?z;Ru_?V`rr9 zuD*C)vplMXD|@OUTP(PJES$X9Zu-u%ncLiKl35Mh7OvM6+ZV>pF5Z-j^5&oz|MGOX z=GQ#pe|gY1+g?x9)b1o8Ve@=?e{p-crf3tlx<0R?{@!#!x5dn!(bpKO*TuG#9(Adb z>mMSqiR!|`@m#6dYI2BL(0(UDHJ#<~#&J1yp~+OAD2ozOJxY`SG^+iZj04%zZ`J!W zHHkAIL;r+~$hJLV(0FbNIb}6HTpN+p)`3P2D+kuBpz$q?ozCf-V-sa{4u8VqWQ%m8 zRp7qc-EU)R%2NQl-9VK_Xl`g~qbSPDGvyx>IKg%hk!W|WysrV(81RSC$C@~NEhoAo z6#-eZi{*D9_f{)6I18^4|F8fp%16TI&tDp?FL&%rBYne-$ly1znJDh@%@~A*!?pk^ z$|;f?=ylF6FwFvS-=0y;n+I(2l+!Mxk8~J8OUemtH6*ps?Hp)#bUPns@EdOSAdcnvO?&cBxRLd z-c8puf_=_Tv!OSJ4~py(@oo&m0@>14&?UwKtrqYuz$&~t(n~zbfzg+$NuhNY9P)Bz zr)rGPm8i>=b#Fb_lKE?m*Y2L@lLZT{;;J_t@+UYN(c3jTUVFHE5W6{Scd{>ZYDAi* zt$FzH6gjxF4a*w@#CsuwwB12*hS80^S^`@%ZzpV;1o1ad_Z^1enve=#4b@=3E znJ=I+l%sH}YHV%F7)xSoCN7m^9iCC9eOjk-_nx{9)kb4cFt@wt*J=SL``S%4ACo@n za1@J9nI&*4oH8=SA_pGTclike?rlZDXP+PW;pqTs!aY2pgh%cl1IntO`9w}q&VnQcj9M@Rsh3=x6Mu?_G{(GY zby#Ytdq!xOqkSHU2#-)$$&dnIFr#tJCo9c|1RSm;4BWCwQ%Jm8qKHv%swi%1=gu42 z4ELwEFBh?KMk|r20=Qf8*D`JY7!R2ue!tCGUl5%)`x@lA@+UmkXODnW-V+N7$mT_4 z);HKUib%U=K2W77KDq?~q!bvC{;%FXungD)p|19n*txf1w9Sv9eG5s+oPXGwyv~a& zs#faFU&SgRy>F=J1m5S`_dTNj9I4t~>o|fgoRl>1|J_9|Wh_^1Z=7N5@$51j3?PiB z#f^L-Zs}MbTD@e!Y(S}rA{jAgrXa}*j0Da%$W##b9^8;KU~OBIOH^?-e6^WeNihdT ziPXHKHoG8~Z41%*(v4TfPe&n()yErElCgCfxz7kfRFt~~slt}UCyq%BS}GI?Xzz{} z4MRcUC5-LX*GhQwV>!%c{ldLUO;Qql{iqih)zZ{waPl(n+ml_sD@5wsG)8JFc*qe< z2Gy+~+JJT`VJLH?u--2+IE#*Wdy;>EY%ZkHp78V_fSxYB{#?9Qi8FJkZmW0i#TxMC zIB9xg{{(Yt)+^O|UhHl71Cy+>sPC8t$2pmYc;f+`#toUuiayt^J!hihFMz{jg0Q^M zvga}|vw#J>1hc)>MZ=BNAhNQ5zNXyRU>i`})luG<6Qxfw|5Om1ogK-1F9N>g#e2&G zu#`RXE>=j(s-U0D8}o$0{{CzX^j7c<@H&|vhUVPS$+1hO2zs{)0-3TOoRMdaCC`=F zAKR48D0?_r2reI}-2t=L6SP&!Hy8BD5=vur=)YLSHhvnm0Gfz;Wzg<-xm ze1%lC6#&fi{q`N89g}Ofx&z~#eOV8}u zf`^kf*Uv!`6t_yWNwh}K@9RcsJ}ENiRs6n;%H8K|G}N=2(kwHYi%k^Ws50a=R#h8~ zgxeJ@+?k4-PVkdP&bXyN7$(Xg$%RzqAk95;xoe0006BO)ynGqiyuYe~Co;tR62#YB z>U5WL`P<-{z;sDowb*n(;JBOFgyP_hi%r)% zIJ1qbh9DzClTf15Zvo)=>opRhCN80LG}fI6x;d&R*@=_v)y7zK04TP216M(Bpf1+QvxAP2<3 zmzy)@XiCJWn8_dtKEs{-%P&}7Moi%D3ZV~3D>y#|u`58zKe*1TG2umydw*BW(Sw?X z%go}e=M?9Fw&%eN!dL&;iMTFP_U(|N1|d5Fsmm!XqkS7b@V02=`*uz@C9fgHFky^0 z6eG;jm1aOZ#3LSL$#C**5_oqQK3@}2_#9{TvzqYs9Pv@)w7}MFTK!n_vB0(YQt$|< z^ymy2L6zGUc|E=3l%oCyF*SgCE7Qf&y#OZj=U;e!0s>iV5SP24b4wA)6slbkKPqVa z?L7vIXHveS>h38t5DB(K7mO+b>$HL{jmcsulpV9gIQ+x8|K(jy>TN9DWHsRd-ESVJQ5c}`_fCcA#g-Gmp zL9`a{aW52!x-Xv(liSJ&(t9irNI!(V-XjjUhIaKPVf1eo_X~Srh+bxvmvd1SB{2vp z%wybkv@OTW;}j214>YImKO4Mx*VExQxs$uc1oj(hCj=~pPXQce4-mYN3K~rT&4clb zV5Q3QA)*t>xFc<)$Gw1SYsK|7B|$F-FRzC1FnhN_gFTQu|AQqEncRzh0Z6B{M)+C< z?u7TwN`dnG0r#=owToakaXE%{HxfBuQy5p=EZ(YlaaVUr2=-6PP)+q>>hzs585^st zY6X>ID{0?7@ z=h44eJX;z{S1wJhYB!nt&1~C_TX)&^X*2?!zN!SN1c%|6_m5ayicG1(l*Fy;#;DzL zNcKsqTvA%YiB)@?rim}#*ZBHl+u8^>-_NuAuhV<%)0+B}?EN!mTw3Dx*D$=fr${(d ztqrI?OuuBAvJdwwJ4{1s#VOB+F3a$^pK;jc!^>uQA}tp0M?tagM(|)71f;VY>(F>& z5E?p1FmY%imeRp8ba6QUHQK$*NNA)javS{-@X&e zvtv0<#1x?N>6t|SePNQkwwJyq(K<7g@jJmdML2nT?gZO?nqU;AwC0{U8(w-dM`0*L z>xv;G(}c96S4)A_{IyijaH#&KvIJB`3D48TL;Ez}==}t%=T7tmytIby6cLutzXBlT zg%rq64!uz)`MUkLozQE9WyU#Ua)^a8;n>HbA^Aw^JVulCABWe7wT?Bmsmbw%BZu9l zbPU79H^?Pg&By<#ThlePHJnSOr_bI#q72{~2g`-%U$yB@=|A~a`97}QGD-s2vty+4 z?F!Pw8XCm3MuY0uqe?= zSwbc1gbRN{l5YYTfwFkLBUr^3bqOrHY;3XDO8DMMEd;wD9o z0A%eejz)}V2c{GY%pwWsd*cO1^>_UGe)vX~t47NI;2jX64Mv7}g@FM$!j#4Sul`SW z#=nm)7`WpG(9a%B8>tW}6R9039@&6FOZTN8uXkrKX23C2IrI@q5>*s#1UC+%g1N-D z1h%AO31q2m$!!U~l3m+Sw_b~0H?7ax{}s{iTM%x5NCr}ZRf25-dkjwlUCmZ4u4&Q2 zV|#9=YD>HC-9t2}IOGtf8q*v#9cqKe3*L?AgY^yb1@hqodI7oy3J1}Fc!1o9@PHhN zc!8)%*dlwAgpd>K7aJiLDHk$>mFLl?*(cto7^e?279nmX79uv4q)u=zd4NouMx1OEGTx(5t}jn}~>T|FSoYs}qzy6e$!tlqAX&xu>F%JdA>+;zr4f z^e7*Nj9Ks;rV*SG_#xFH#h6FpcIilIY8i2Xp!d`Cg#4)@x5w9&t&5KU(>mL;#=D)k_n!<{DfwCzCKT@`SI(eT5`YzvG~WPcZM|H&2*@KD4d z>ZZ&d%IB$Z4elssli^YR@DKb_?x&>sq=6BfclO8%R(xFRQh)rr5*PyK-r^5}4GT(l z(-Y?(M64o)+Qlq4z`myGQhFU9)CHLk2ixKqNeHfUWv*$V*`7&Ty0JGoEhhl9&h-d* zXUnhVqeXXu3;AMkfGcaZn+#+$P#2ewEuZhXC^A9#t1B5K2yqA)1ge(y_I3?h7njx@LRV0N zd5f!)3@xoilPpGM9cc?qi--H^K9$+G?rEJWw0(?itnKuT^gd8DgWm~inIvlQMQZ7z zQhJ!lM(oKppOa9PBNCMpe=5h!E2pq3NB>q%a#W7HS5AXjj)+)JkXnuzTTY=_j;dHr zvNS^e!j<@Aj@93+Gklxb6P7tJn%U=QOqZa@9;Kc+WqCxG!k9XomN^Jv;sAHd zkaN$L1KkoEq1H2~*;k}Fbg0>zq&c{#+25o&{J7B*wJ|Wc(O0!Gbh*)+wK2H4(cif- z{K?f5z%|g%)mOkZw9nO>z%@9})!)E1eBaR%(J?UI(O1zibWU{uyLCXlb%eWh$h~z8 z!gD~xbA-%u$jEaH-E~0Ob%fn@$k}xa?tMV!eT43P$m)Fz|CPz+we-=-$dIZ(H*%47 z`LytqPrY_o7p2jH+w4f$?2O%f{($h%u25c}K0$c|{f`>d{I8W5{Qp{` z;u^(eVpm0@qI=ha=jrR%ebO=Iv}$&Zr>s%Q9d}aan6^>PKh^cJ%LQk1&Zew28LN_i z^DAbass=T6%PSTa%uiSzQJq8D%l{8;TKoUrY-S?53a(E$-=e$b@!mgozD_vWqN@we z|Bo}QWPIVw{~yaPI6h%_kN*F<`CG030)I4)=;(s&#O!&yvAS)K8t;Pb6V|t=|GR7A z#uXi&wR6Pzf8#Lk*Bj=s9lzdfcBP)6GcZ7tJ;_Plym#NZpL^c9_nvb{Ac-ZA-wqBA?rCgnjA?3WTHDgn z;yyMuw#>`RYsk;fuP-1Vph>IMUI9=Hpnp+4k({>zaG3U6n3$OOYhhtwds0%8_`(Y> z7#$oO2w;{fl}d(%g^6itX~yrr|Ndu^k@oa!#xPINQ~-AY3<7BJ^z_UvEiL^yJUm=< zbab=`X-(bS+?bM*A~rWSUstQurvX$0Xa{fuK>VVC0qmdZOrz0o%8SdFFSiSHraC)2 zo35o&>D2WYfIlx77=Qrakst`XeEBj-a>tGx6a-;Wu+u@))6?0|(7=?Gl&SlV0XQ!d z_%{F;85v2EJb3WnqCGoPU0q$7m6b)EPB-25?-vT}2%vY}x^+Bx@+9SQ`I5p;sY<2d z)vH&h11B#ghR*|_i;Ig{Co-9gTeogyVqzlw{QMRT?e6YAbv*$Pfox^#)b!NFF+6$-`GMXeG=MMaON z&u9QFEG*Wa?j$7#4jix;4wh6Rk?^ap zzG7`{t!Xz54-Y3v?%A`)Zr}|YHi#tmSzILqK?nnI3qUP^N&vqomC9T9?%lJwg3OeM z4<8~ZC(t%m4toyStY)H#bKLf)FAI!e0bIh!F%qHs#q0 z05LOPa&T~f!C;toCkllEiHV5_3kyS4RTW--`DI+cejVR@^NndKo3A)HIAHDCwF9lK ztujpJGe!W70R900Kf}&XW=)SCJxY?M-EHU2ol9bOnpR2x`~g6KT`sU9dc7VuZ{Ebc zd-qUTS&8cEYV`Lnu7sN*{Q%&D$?|8Zz42@4)u~lt1%L|xp8Ov`S<(qiE)4F%b6@~~ zAP5@)WQ2r-Y`=g1zNaXPbAF?l;_B)OrBVsGTn@Qhj^W{9Jbn5U0|Nul>-Bcq1MmRA zzW`*DG+Nv=?%usypj0a7?Ez0uPsYW?@yL-QY;A3&!C){;Cx?fJ+0f9y_uqe?v9Ymq zb90;1W_Wn`Ab{flR?WH7wY0QcRH;;R8da%O+`oT6J32Z{aC*I-m6eq&EG%ShZZ2=% zzRjVbA+rJ0)YNdxmMye)jsburB_($(u}Lj`1BF5{@Z6YS>A4^X*t~f&va_=h9UYC) z(NTQ#(MJ$P5lW>Jfq{XDiHU)mn;V*&n^9O;i1PAs==FN+-n|=1Nl7RxE5q5dXYt{O zAL7ZACua6#G8t4VRj0)Ou`~)%6c73O`dUnU1VP}gUAs6wK2DOna^(u6qN3Q+(qa|@ zckbLV^J-O96@kfG@U_=oV{dOSN%GRAOZ4#YFzds^!-J0=J-T2|@^ir7-`^tetFOLl ziqW^M*f-`S!+O!E@eDMXOQYq5Y(~+N_kD;LXa|%xXCY2L~1u z6p$o8`|LByWU}cV;pd-!&e+&kwzaj9Bu7R@%tE5Jw${vxJ9q9RN$PYuu3Wj&?Afke zyNo2g?D4QptyY`e2nq^9a&j^N;Ny=!#>mKs=~-J_+tftC)~#DnQc{Aht}cv^kE5rj z2c4ar`1I3HP3;2$0+5}Z4FEWDQhClr914;7Ov14Xm3IH7)9a&yp ze#;t{Rp9#i`l9D?OaOfG#TTj5=}3}~A3tVjXsE^Y^PP9z;n!b(&9bsG78MmSHa3>P zn)L_Y9YW*nVFfh%KU(U03JJb z%(M;<4-YdpH$BIGAV7oMCr&H*HBzPY;hDKhF60_&F=)sHiBBuvvWBB*ChkSWai)dE5~sSfY3z)1IPhj@z`}CI>%pT4FF^d1_s~>;6K(nSg~S- zF*-V0^!N8S+WJRSCX+EVG*nDWOEdcW`w!1Cs7zZ-7E7dQvL1l9m1q4E6BGZudGluJ z#Kc5gMMXt&b#=9OUtizyp`jrONhp;{!@70r1_J{F+ae+&E(7>d5CkcJD*%3H#qKJb zM00r91Axwg7g_=Aw(+hb$>lcet^n{QW{27X0N%Ek=Gy5X2*Nf1nE+JJJ7~b<8G+@B szzz`vArZhI0Vn`G1#p&RldX6D3-H=#py?Rlu>b%707*qoM6N<$f-ATC>i_@% diff --git a/vendor/github.com/gocql/gocql/website/index.html b/vendor/github.com/gocql/gocql/website/index.html deleted file mode 100644 index 7016b2a6d..000000000 --- a/vendor/github.com/gocql/gocql/website/index.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - GoCQL - - - - - - - - - - - - - -
- -
-
- -

GoCQL tux21b.org/v1/gocql

-
- -
- -
- Under Development: The GoCQL package is currently actively - developed and the API may change in the future. -
- - -

Highlights

- -
-
-

Cluster Management

-

GoCQL automatically discovers all data centers, racks and hosts - in your cluster, manages a pool of connections to them and distributes - queries in a reasonable and efficient way.

-
- -
-

Type Conversation

-

Automatic and safe type conversation between Cassandra and Go without - any loss of precision. Basic types, collections and UUIDs are supported - by default and custom types can implement their own marshaling logic.

-
- -
-

Synchronous and Concurrent

-

Synchronous API with an asynchronous and concurrent back-end. Each - connection can handle up to 128 concurrent queries and may receive - server side push events at any time.

-
- -
-

Failover Management

-

TODO :(

-
-
- -
-
-

Result Paging

-

Iterate over large results sets and let GoCQL fetch one page after - another. The next page is automatically pre-fetched in the background - once the iterator has passed a certain threshold.

-
- -
-

Atomic Batches

-

Execute a batch of related updates in a single query. GoCQL supports - logged, unlogged and counter batches.

-
- -
-

Query Tracing

-

Trace queries to obtain a detailed output of all events that - happened during the query execution from Cassandra. The output might - help to identify bugs and performance bottlenecks in your - application.

-
- -
-

Frame Compression

-

Speed up and reduce the network traffic by compressing the frames - that are sent to Cassandra. - Snappy, a - compression algorithm that aims for very high speeds and reasonable - compression, is enabled by default.

-
-
- -
-
-

Multiple Cassandra Versions

-

GoCQL supports multiple Cassandra version. Currently Cassandra 1.2 - and Cassandra 2.0 are fully supported.

-
- -
-

Thoroughly Tested

-

TODO :(

-
- -
-

BSD License

-

Completely open source. Browse the source on - GitHub and start - contributing today.

-
-
- - - - diff --git a/vendor/github.com/gocql/gocql/website/js/bootstrap.js b/vendor/github.com/gocql/gocql/website/js/bootstrap.js deleted file mode 100644 index 2c6425714..000000000 --- a/vendor/github.com/gocql/gocql/website/js/bootstrap.js +++ /dev/null @@ -1,1999 +0,0 @@ -/** -* bootstrap.js v3.0.0 by @fat and @mdo -* Copyright 2013 Twitter Inc. -* http://www.apache.org/licenses/LICENSE-2.0 -*/ -if (!jQuery) { throw new Error("Bootstrap requires jQuery") } - -/* ======================================================================== - * Bootstrap: transition.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#transitions - * ======================================================================== - * Copyright 2013 Twitter, 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. - * ======================================================================== */ - - -+function ($) { "use strict"; - - // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) - // ============================================================ - - function transitionEnd() { - var el = document.createElement('bootstrap') - - var transEndEventNames = { - 'WebkitTransition' : 'webkitTransitionEnd' - , 'MozTransition' : 'transitionend' - , 'OTransition' : 'oTransitionEnd otransitionend' - , 'transition' : 'transitionend' - } - - for (var name in transEndEventNames) { - if (el.style[name] !== undefined) { - return { end: transEndEventNames[name] } - } - } - } - - // http://blog.alexmaccaw.com/css-transitions - $.fn.emulateTransitionEnd = function (duration) { - var called = false, $el = this - $(this).one($.support.transition.end, function () { called = true }) - var callback = function () { if (!called) $($el).trigger($.support.transition.end) } - setTimeout(callback, duration) - return this - } - - $(function () { - $.support.transition = transitionEnd() - }) - -}(window.jQuery); - -/* ======================================================================== - * Bootstrap: alert.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#alerts - * ======================================================================== - * Copyright 2013 Twitter, 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. - * ======================================================================== */ - - -+function ($) { "use strict"; - - // ALERT CLASS DEFINITION - // ====================== - - var dismiss = '[data-dismiss="alert"]' - var Alert = function (el) { - $(el).on('click', dismiss, this.close) - } - - Alert.prototype.close = function (e) { - var $this = $(this) - var selector = $this.attr('data-target') - - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 - } - - var $parent = $(selector) - - if (e) e.preventDefault() - - if (!$parent.length) { - $parent = $this.hasClass('alert') ? $this : $this.parent() - } - - $parent.trigger(e = $.Event('close.bs.alert')) - - if (e.isDefaultPrevented()) return - - $parent.removeClass('in') - - function removeElement() { - $parent.trigger('closed.bs.alert').remove() - } - - $.support.transition && $parent.hasClass('fade') ? - $parent - .one($.support.transition.end, removeElement) - .emulateTransitionEnd(150) : - removeElement() - } - - - // ALERT PLUGIN DEFINITION - // ======================= - - var old = $.fn.alert - - $.fn.alert = function (option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.alert') - - if (!data) $this.data('bs.alert', (data = new Alert(this))) - if (typeof option == 'string') data[option].call($this) - }) - } - - $.fn.alert.Constructor = Alert - - - // ALERT NO CONFLICT - // ================= - - $.fn.alert.noConflict = function () { - $.fn.alert = old - return this - } - - - // ALERT DATA-API - // ============== - - $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) - -}(window.jQuery); - -/* ======================================================================== - * Bootstrap: button.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#buttons - * ======================================================================== - * Copyright 2013 Twitter, 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. - * ======================================================================== */ - - -+function ($) { "use strict"; - - // BUTTON PUBLIC CLASS DEFINITION - // ============================== - - var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) - } - - Button.DEFAULTS = { - loadingText: 'loading...' - } - - Button.prototype.setState = function (state) { - var d = 'disabled' - var $el = this.$element - var val = $el.is('input') ? 'val' : 'html' - var data = $el.data() - - state = state + 'Text' - - if (!data.resetText) $el.data('resetText', $el[val]()) - - $el[val](data[state] || this.options[state]) - - // push to event loop to allow forms to submit - setTimeout(function () { - state == 'loadingText' ? - $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d); - }, 0) - } - - Button.prototype.toggle = function () { - var $parent = this.$element.closest('[data-toggle="buttons"]') - - if ($parent.length) { - var $input = this.$element.find('input') - .prop('checked', !this.$element.hasClass('active')) - .trigger('change') - if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') - } - - this.$element.toggleClass('active') - } - - - // BUTTON PLUGIN DEFINITION - // ======================== - - var old = $.fn.button - - $.fn.button = function (option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.button') - var options = typeof option == 'object' && option - - if (!data) $this.data('bs.button', (data = new Button(this, options))) - - if (option == 'toggle') data.toggle() - else if (option) data.setState(option) - }) - } - - $.fn.button.Constructor = Button - - - // BUTTON NO CONFLICT - // ================== - - $.fn.button.noConflict = function () { - $.fn.button = old - return this - } - - - // BUTTON DATA-API - // =============== - - $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - $btn.button('toggle') - e.preventDefault() - }) - -}(window.jQuery); - -/* ======================================================================== - * Bootstrap: carousel.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#carousel - * ======================================================================== - * Copyright 2012 Twitter, 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. - * ======================================================================== */ - - -+function ($) { "use strict"; - - // CAROUSEL CLASS DEFINITION - // ========================= - - var Carousel = function (element, options) { - this.$element = $(element) - this.$indicators = this.$element.find('.carousel-indicators') - this.options = options - this.paused = - this.sliding = - this.interval = - this.$active = - this.$items = null - - this.options.pause == 'hover' && this.$element - .on('mouseenter', $.proxy(this.pause, this)) - .on('mouseleave', $.proxy(this.cycle, this)) - } - - Carousel.DEFAULTS = { - interval: 5000 - , pause: 'hover' - , wrap: true - } - - Carousel.prototype.cycle = function (e) { - e || (this.paused = false) - - this.interval && clearInterval(this.interval) - - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - - return this - } - - Carousel.prototype.getActiveIndex = function () { - this.$active = this.$element.find('.item.active') - this.$items = this.$active.parent().children() - - return this.$items.index(this.$active) - } - - Carousel.prototype.to = function (pos) { - var that = this - var activeIndex = this.getActiveIndex() - - if (pos > (this.$items.length - 1) || pos < 0) return - - if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) - if (activeIndex == pos) return this.pause().cycle() - - return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) - } - - Carousel.prototype.pause = function (e) { - e || (this.paused = true) - - if (this.$element.find('.next, .prev').length && $.support.transition.end) { - this.$element.trigger($.support.transition.end) - this.cycle(true) - } - - this.interval = clearInterval(this.interval) - - return this - } - - Carousel.prototype.next = function () { - if (this.sliding) return - return this.slide('next') - } - - Carousel.prototype.prev = function () { - if (this.sliding) return - return this.slide('prev') - } - - Carousel.prototype.slide = function (type, next) { - var $active = this.$element.find('.item.active') - var $next = next || $active[type]() - var isCycling = this.interval - var direction = type == 'next' ? 'left' : 'right' - var fallback = type == 'next' ? 'first' : 'last' - var that = this - - if (!$next.length) { - if (!this.options.wrap) return - $next = this.$element.find('.item')[fallback]() - } - - this.sliding = true - - isCycling && this.pause() - - var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) - - if ($next.hasClass('active')) return - - if (this.$indicators.length) { - this.$indicators.find('.active').removeClass('active') - this.$element.one('slid', function () { - var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) - $nextIndicator && $nextIndicator.addClass('active') - }) - } - - if ($.support.transition && this.$element.hasClass('slide')) { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return - $next.addClass(type) - $next[0].offsetWidth // force reflow - $active.addClass(direction) - $next.addClass(direction) - $active - .one($.support.transition.end, function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { that.$element.trigger('slid') }, 0) - }) - .emulateTransitionEnd(600) - } else { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return - $active.removeClass('active') - $next.addClass('active') - this.sliding = false - this.$element.trigger('slid') - } - - isCycling && this.cycle() - - return this - } - - - // CAROUSEL PLUGIN DEFINITION - // ========================== - - var old = $.fn.carousel - - $.fn.carousel = function (option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.carousel') - var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) - var action = typeof option == 'string' ? option : options.slide - - if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) - if (typeof option == 'number') data.to(option) - else if (action) data[action]() - else if (options.interval) data.pause().cycle() - }) - } - - $.fn.carousel.Constructor = Carousel - - - // CAROUSEL NO CONFLICT - // ==================== - - $.fn.carousel.noConflict = function () { - $.fn.carousel = old - return this - } - - - // CAROUSEL DATA-API - // ================= - - $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { - var $this = $(this), href - var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - var options = $.extend({}, $target.data(), $this.data()) - var slideIndex = $this.attr('data-slide-to') - if (slideIndex) options.interval = false - - $target.carousel(options) - - if (slideIndex = $this.attr('data-slide-to')) { - $target.data('bs.carousel').to(slideIndex) - } - - e.preventDefault() - }) - - $(window).on('load', function () { - $('[data-ride="carousel"]').each(function () { - var $carousel = $(this) - $carousel.carousel($carousel.data()) - }) - }) - -}(window.jQuery); - -/* ======================================================================== - * Bootstrap: collapse.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#collapse - * ======================================================================== - * Copyright 2012 Twitter, 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. - * ======================================================================== */ - - -+function ($) { "use strict"; - - // COLLAPSE PUBLIC CLASS DEFINITION - // ================================ - - var Collapse = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Collapse.DEFAULTS, options) - this.transitioning = null - - if (this.options.parent) this.$parent = $(this.options.parent) - if (this.options.toggle) this.toggle() - } - - Collapse.DEFAULTS = { - toggle: true - } - - Collapse.prototype.dimension = function () { - var hasWidth = this.$element.hasClass('width') - return hasWidth ? 'width' : 'height' - } - - Collapse.prototype.show = function () { - if (this.transitioning || this.$element.hasClass('in')) return - - var startEvent = $.Event('show.bs.collapse') - this.$element.trigger(startEvent) - if (startEvent.isDefaultPrevented()) return - - var actives = this.$parent && this.$parent.find('> .panel > .in') - - if (actives && actives.length) { - var hasData = actives.data('bs.collapse') - if (hasData && hasData.transitioning) return - actives.collapse('hide') - hasData || actives.data('bs.collapse', null) - } - - var dimension = this.dimension() - - this.$element - .removeClass('collapse') - .addClass('collapsing') - [dimension](0) - - this.transitioning = 1 - - var complete = function () { - this.$element - .removeClass('collapsing') - .addClass('in') - [dimension]('auto') - this.transitioning = 0 - this.$element.trigger('shown.bs.collapse') - } - - if (!$.support.transition) return complete.call(this) - - var scrollSize = $.camelCase(['scroll', dimension].join('-')) - - this.$element - .one($.support.transition.end, $.proxy(complete, this)) - .emulateTransitionEnd(350) - [dimension](this.$element[0][scrollSize]) - } - - Collapse.prototype.hide = function () { - if (this.transitioning || !this.$element.hasClass('in')) return - - var startEvent = $.Event('hide.bs.collapse') - this.$element.trigger(startEvent) - if (startEvent.isDefaultPrevented()) return - - var dimension = this.dimension() - - this.$element - [dimension](this.$element[dimension]()) - [0].offsetHeight - - this.$element - .addClass('collapsing') - .removeClass('collapse') - .removeClass('in') - - this.transitioning = 1 - - var complete = function () { - this.transitioning = 0 - this.$element - .trigger('hidden.bs.collapse') - .removeClass('collapsing') - .addClass('collapse') - } - - if (!$.support.transition) return complete.call(this) - - this.$element - [dimension](0) - .one($.support.transition.end, $.proxy(complete, this)) - .emulateTransitionEnd(350) - } - - Collapse.prototype.toggle = function () { - this[this.$element.hasClass('in') ? 'hide' : 'show']() - } - - - // COLLAPSE PLUGIN DEFINITION - // ========================== - - var old = $.fn.collapse - - $.fn.collapse = function (option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.collapse') - var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) - - if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) - if (typeof option == 'string') data[option]() - }) - } - - $.fn.collapse.Constructor = Collapse - - - // COLLAPSE NO CONFLICT - // ==================== - - $.fn.collapse.noConflict = function () { - $.fn.collapse = old - return this - } - - - // COLLAPSE DATA-API - // ================= - - $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { - var $this = $(this), href - var target = $this.attr('data-target') - || e.preventDefault() - || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 - var $target = $(target) - var data = $target.data('bs.collapse') - var option = data ? 'toggle' : $this.data() - var parent = $this.attr('data-parent') - var $parent = parent && $(parent) - - if (!data || !data.transitioning) { - if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') - $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') - } - - $target.collapse(option) - }) - -}(window.jQuery); - -/* ======================================================================== - * Bootstrap: dropdown.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#dropdowns - * ======================================================================== - * Copyright 2012 Twitter, 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. - * ======================================================================== */ - - -+function ($) { "use strict"; - - // DROPDOWN CLASS DEFINITION - // ========================= - - var backdrop = '.dropdown-backdrop' - var toggle = '[data-toggle=dropdown]' - var Dropdown = function (element) { - var $el = $(element).on('click.bs.dropdown', this.toggle) - } - - Dropdown.prototype.toggle = function (e) { - var $this = $(this) - - if ($this.is('.disabled, :disabled')) return - - var $parent = getParent($this) - var isActive = $parent.hasClass('open') - - clearMenus() - - if (!isActive) { - if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { - // if mobile we we use a backdrop because click events don't delegate - $('