From 61be9321a74711a44155aa385e3d340f6400990c Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 10 May 2016 16:04:10 +0200 Subject: [PATCH] removed unused code --- UnitTests/Basics/VelocyPackHelper-test.cpp | 408 --------------------- UnitTests/Basics/json-utilities-test.cpp | 193 ---------- arangod/HttpServer/HttpCommTask.cpp | 9 +- lib/Basics/json-utilities.cpp | 30 -- lib/Basics/json-utilities.h | 9 - lib/Rest/HttpResponse.cpp | 2 +- lib/Rest/HttpResponse.h | 2 - 7 files changed, 3 insertions(+), 650 deletions(-) diff --git a/UnitTests/Basics/VelocyPackHelper-test.cpp b/UnitTests/Basics/VelocyPackHelper-test.cpp index 6e8d5945b6..0dfe4b2f7c 100644 --- a/UnitTests/Basics/VelocyPackHelper-test.cpp +++ b/UnitTests/Basics/VelocyPackHelper-test.cpp @@ -184,414 +184,6 @@ BOOST_AUTO_TEST_CASE (tst_compare_values_unequal) { VPACK_CHECK(-1, arangodb::basics::VelocyPackHelper::compare, "1", "{}"); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief test duplicate keys -//////////////////////////////////////////////////////////////////////////////// -/* -BOOST_AUTO_TEST_CASE (tst_duplicate_keys) { - INIT_BUFFER - - TRI_json_t* json; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[\"a\",\"a\"]"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":1}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":1,\"b\":1}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":1,\"b\":1,\"A\":1}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":1,\"b\":1,\"a\":1}"); - BOOST_CHECK_EQUAL(true, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":1,\"b\":1,\"c\":1,\"d\":{},\"c\":1}"); - BOOST_CHECK_EQUAL(true, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{}}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{\"a\":1}}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{\"a\":1,\"b\":1},\"b\":1}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{\"a\":1,\"b\":1,\"a\":3},\"b\":1}"); - BOOST_CHECK_EQUAL(true, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{\"a\":1,\"b\":1,\"a\":3}}"); - BOOST_CHECK_EQUAL(true, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{\"a\":{\"a\":{}}}}"); - BOOST_CHECK_EQUAL(false, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{\"a\":{\"a\":{\"a\":{},\"a\":2}}}"); - BOOST_CHECK_EQUAL(true, TRI_HasDuplicateKeyJson(json)); - FREE_JSON - - FREE_BUFFER -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing -//////////////////////////////////////////////////////////////////////////////// -/* -BOOST_AUTO_TEST_CASE (tst_json_hash_utf8) { - TRI_json_t* json; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"äöüßÄÖÜ€µ\""); - BOOST_CHECK_EQUAL(17926322495289827824ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"코리아닷컴 메일알리미 서비스 중단안내 [안내] 개인정보취급방침 변경 안내 회사소개 | 광고안내 | 제휴안내 | 개인정보취급방침 | 청소년보호정책 | 스팸방지정책 | 사이버고객센터 | 약관안내 | 이메일 무단수집거부 | 서비스 전체보기\""); - BOOST_CHECK_EQUAL(11647939066062684691ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"بان يأسف لمقتل لاجئين سوريين بتركيا المرزوقي يندد بعنف الأمن التونسي تنديد بقتل الجيش السوري مصورا تلفزيونيا 14 قتيلا وعشرات الجرحى بانفجار بالصومال\""); - BOOST_CHECK_EQUAL(9773937585298648628ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"中华网以中国的市场为核心,致力为当地用户提供流动增值服务、网上娱乐及互联网服务。本公司亦推出网上游戏,及透过其门户网站提供包罗万有的网上产品及服务。\""); - BOOST_CHECK_EQUAL(5348732066920102360ULL, TRI_HashJson(json)); - FREE_JSON -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing -//////////////////////////////////////////////////////////////////////////////// - -/* -BOOST_AUTO_TEST_CASE (tst_json_hash) { - TRI_json_t* json; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "null"); - BOOST_CHECK_EQUAL(6601085983368743140ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "false"); - BOOST_CHECK_EQUAL(13113042584710199672ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "true"); - BOOST_CHECK_EQUAL(6583304908937478053ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "0"); - BOOST_CHECK_EQUAL(12161962213042174405ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "123"); - BOOST_CHECK_EQUAL(3423744850239007323ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"\""); - BOOST_CHECK_EQUAL(12638153115695167455ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\" \""); - BOOST_CHECK_EQUAL(560073664097094349ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"foobar\""); - BOOST_CHECK_EQUAL(3770388817002598200ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"Foobar\""); - BOOST_CHECK_EQUAL(6228943802847363544ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "\"FOOBAR\""); - BOOST_CHECK_EQUAL(7710850877466186488ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[]"); - BOOST_CHECK_EQUAL(13796666053062066497ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ null ]"); - BOOST_CHECK_EQUAL(12579909069687325360ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ 0 ]"); - BOOST_CHECK_EQUAL(10101894954932532065ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ false ]"); - BOOST_CHECK_EQUAL(4554324570636443940ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ \"false\" ]"); - BOOST_CHECK_EQUAL(295270779373686828ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ [ ] ]"); - BOOST_CHECK_EQUAL(3935687115999630221ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ { } ]"); - BOOST_CHECK_EQUAL(13595004369025342186ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "[ [ false, 0 ] ]"); - BOOST_CHECK_EQUAL(8026218647638185280ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{}"); - BOOST_CHECK_EQUAL(5737045748118630438ULL, TRI_HashJson(json)); - FREE_JSON - - // the following hashes should be identical - const uint64_t a = 5721494255658103046ULL; - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"1\", \"b\": \"2\" }"); - BOOST_CHECK_EQUAL(a, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"2\", \"a\": \"1\" }"); - BOOST_CHECK_EQUAL(a, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"2\", \"b\": \"1\" }"); - BOOST_CHECK_EQUAL(a, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"b\": \"1\" }"); - BOOST_CHECK_EQUAL(2549570315580563109ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"1\" }"); - BOOST_CHECK_EQUAL(5635413490308263533ULL, TRI_HashJson(json)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": 123, \"b\": [ ] }"); - BOOST_CHECK_EQUAL(9398364376493393319ULL, TRI_HashJson(json)); - FREE_JSON -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names -//////////////////////////////////////////////////////////////////////////////// - -/* -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_single) { - TRI_json_t* json; - int error; - - const char* v1[] = { "_key" }; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ }"); - const uint64_t h1 = TRI_HashJsonByAttributes(json, v1, 1, true, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"_key\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"_key\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"keys\": { \"_key\": \"foobar\" } }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"KEY\": 1234, \"_KEY\": \"foobar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"_key\": \"i-am-a-foo\" }"); - const uint64_t h2 = TRI_HashJsonByAttributes(json, v1, 1, true, error); - BOOST_CHECK(h1 != h2); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"KEY\": 1234, \"_key\": \"i-am-a-foo\" }"); - BOOST_CHECK_EQUAL(h2, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": [ \"foobar\" ], \"KEY\": { }, \"_key\": \"i-am-a-foo\" }"); - BOOST_CHECK_EQUAL(h2, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names -//////////////////////////////////////////////////////////////////////////////// - -/* -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_mult1) { - TRI_json_t* json; - int error; - - const char* v1[] = { "a", "b" }; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ }"); - const uint64_t h1 = TRI_HashJsonByAttributes(json, v1, 2, true, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"b\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": null, \"a\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - // test if non-relevant attributes influence our hash - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"B\": 123 }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"B\": 1234, \"a\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"A\": 123, \"B\": \"hihi\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"c\": null, \"d\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"A\": 1, \"B\": 2, \" a\": \"bar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"ab\": 1, \"ba\": 2 }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names -//////////////////////////////////////////////////////////////////////////////// - -/* -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_mult2) { - TRI_json_t* json; - int error; - - const char* v1[] = { "a", "b" }; - - const uint64_t h1 = 6369173190757857502ULL; - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"bar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\", \"a\": \"foo\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"food\", \"b\": \"bar\" }"); - BOOST_CHECK_EQUAL(720060016857102700ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"baz\" }"); - BOOST_CHECK_EQUAL(6361520589827022742ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"FOO\", \"b\": \"BAR\" }"); - BOOST_CHECK_EQUAL(3595137217367956894ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\" }"); - BOOST_CHECK_EQUAL(12739237936894360852ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"meow\" }"); - BOOST_CHECK_EQUAL(13378327204915572311ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\" }"); - BOOST_CHECK_EQUAL(10085884912118216755ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\", \"a\": \"meow\" }"); - BOOST_CHECK_EQUAL(15753579192430387496ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names with incomplete docs -//////////////////////////////////////////////////////////////////////////////// - -/* -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_mult3) { - TRI_json_t* json; - int error; - - const char* v1[] = { "a", "b" }; - - int error; - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"bar\" }"); - TRI_HashJsonByAttributes(json, v1, 2, false, &error); - BOOST_CHECK_EQUAL(TRI_ERROR_NO_ERROR, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\" }"); - TRI_HashJsonByAttributes(json, v1, 2, false, &error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\" }"); - TRI_HashJsonByAttributes(json, v1, 2, false, &error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ }"); - TRI_HashJsonByAttributes(json, v1, 2, false, &error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"c\": 12 }"); - TRI_HashJsonByAttributes(json, v1, 2, false, &error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": 1, \"b\": null }"); - TRI_HashJsonByAttributes(json, v1, 2, false, &error); - BOOST_CHECK_EQUAL(TRI_ERROR_NO_ERROR, error); - FREE_JSON -} -*/ - //////////////////////////////////////////////////////////////////////////////// /// @brief generate tests //////////////////////////////////////////////////////////////////////////////// diff --git a/UnitTests/Basics/json-utilities-test.cpp b/UnitTests/Basics/json-utilities-test.cpp index 40e1586740..8b651b70e1 100644 --- a/UnitTests/Basics/json-utilities-test.cpp +++ b/UnitTests/Basics/json-utilities-test.cpp @@ -212,199 +212,6 @@ BOOST_AUTO_TEST_CASE (tst_compare_values_unequal) { JSON_CHECK(-1, TRI_CompareValuesJson, "1", "{}"); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names -//////////////////////////////////////////////////////////////////////////////// - -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_single) { - TRI_json_t* json; - int error; - - const char* v1[] = { "_key" }; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ }"); - uint64_t const h1 = TRI_HashJsonByAttributes(json, v1, 1, true, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"_key\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"_key\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"keys\": { \"_key\": \"foobar\" } }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"KEY\": 1234, \"_KEY\": \"foobar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"_key\": \"i-am-a-foo\" }"); - uint64_t const h2 = TRI_HashJsonByAttributes(json, v1, 1, true, error); - BOOST_CHECK(h1 != h2); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foobar\", \"KEY\": 1234, \"_key\": \"i-am-a-foo\" }"); - BOOST_CHECK_EQUAL(h2, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": [ \"foobar\" ], \"KEY\": { }, \"_key\": \"i-am-a-foo\" }"); - BOOST_CHECK_EQUAL(h2, TRI_HashJsonByAttributes(json, v1, 1, true, error)); - FREE_JSON -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names -//////////////////////////////////////////////////////////////////////////////// - -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_mult1) { - TRI_json_t* json; - int error; - - const char* v1[] = { "a", "b" }; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ }"); - const uint64_t h1 = TRI_HashJsonByAttributes(json, v1, 2, true, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"b\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": null, \"a\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - // test if non-relevant attributes influence our hash - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"B\": 123 }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"B\": 1234, \"a\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": null, \"A\": 123, \"B\": \"hihi\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"c\": null, \"d\": null }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"A\": 1, \"B\": 2, \" a\": \"bar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"ab\": 1, \"ba\": 2 }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names -//////////////////////////////////////////////////////////////////////////////// - -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_mult2) { - TRI_json_t* json; - int error; - - const char* v1[] = { "a", "b" }; - - uint64_t const h1 = 18170770464635016704ULL; - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"bar\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\", \"a\": \"foo\" }"); - BOOST_CHECK_EQUAL(h1, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"food\", \"b\": \"bar\" }"); - BOOST_CHECK_EQUAL(9898865118744151582ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"baz\" }"); - BOOST_CHECK_EQUAL(4146172384428429960ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"FOO\", \"b\": \"BAR\" }"); - BOOST_CHECK_EQUAL(1969665727812990435ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\" }"); - BOOST_CHECK_EQUAL(17850048730013513424ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"meow\" }"); - BOOST_CHECK_EQUAL(828267433082628493ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\" }"); - BOOST_CHECK_EQUAL(8536899277477494659ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\", \"a\": \"meow\" }"); - BOOST_CHECK_EQUAL(6298354225815173479ULL, TRI_HashJsonByAttributes(json, v1, 2, true, error)); - FREE_JSON -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief test hashing by attribute names with incomplete docs -//////////////////////////////////////////////////////////////////////////////// - -BOOST_AUTO_TEST_CASE (tst_json_hashattributes_mult3) { - TRI_json_t* json; - int error; - - const char* v1[] = { "a", "b" }; - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\", \"b\": \"bar\" }"); - TRI_HashJsonByAttributes(json, v1, 2, false, error); - BOOST_CHECK_EQUAL(TRI_ERROR_NO_ERROR, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": \"foo\" }"); - TRI_HashJsonByAttributes(json, v1, 2, false, error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"b\": \"bar\" }"); - TRI_HashJsonByAttributes(json, v1, 2, false, error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ }"); - TRI_HashJsonByAttributes(json, v1, 2, false, error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"c\": 12 }"); - TRI_HashJsonByAttributes(json, v1, 2, false, error); - BOOST_CHECK_EQUAL(TRI_ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN, error); - FREE_JSON - - json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, "{ \"a\": 1, \"b\": null }"); - TRI_HashJsonByAttributes(json, v1, 2, false, error); - BOOST_CHECK_EQUAL(TRI_ERROR_NO_ERROR, error); - FREE_JSON -} - //////////////////////////////////////////////////////////////////////////////// /// @brief generate tests //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/HttpServer/HttpCommTask.cpp b/arangod/HttpServer/HttpCommTask.cpp index f99a473eec..e90cc12f46 100644 --- a/arangod/HttpServer/HttpCommTask.cpp +++ b/arangod/HttpServer/HttpCommTask.cpp @@ -113,13 +113,8 @@ HttpCommTask::~HttpCommTask() { //////////////////////////////////////////////////////////////////////////////// void HttpCommTask::handleResponse(HttpResponse* response) { - if (response->isChunked()) { - _requestPending = true; - _isChunked = true; - } else { - _requestPending = false; - _isChunked = false; - } + _requestPending = false; + _isChunked = false; addResponse(response); } diff --git a/lib/Basics/json-utilities.cpp b/lib/Basics/json-utilities.cpp index 0636d31fd4..11ec13fc04 100644 --- a/lib/Basics/json-utilities.cpp +++ b/lib/Basics/json-utilities.cpp @@ -411,33 +411,3 @@ TRI_json_t* TRI_MergeJson(TRI_memory_zone_t* zone, TRI_json_t const* lhs, return MergeRecursive(zone, lhs, rhs, nullMeansRemove, mergeObjects); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief compute a hash value for a JSON document depending on a list -/// of attributes. This is used for sharding to map documents to shards. -/// -/// The attributes array `attributes` has to contain exactly `nrAttributes` -/// pointers to zero-terminated strings. -/// Note that all JSON values given for `json` that are not JSON arrays -/// hash to the same value, which is not the same value a JSON array gets -/// that does not contain any of the specified attributes. -/// If the flag `docComplete` is false, it is an error if the document -/// does not contain explicit values for all attributes. An error -/// is reported by setting *error to -/// TRI_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN instead of -/// TRI_ERROR_NO_ERROR. It is allowed to give NULL as error in which -/// case no error is reported. -//////////////////////////////////////////////////////////////////////////////// - -uint64_t TRI_HashJsonByAttributes(TRI_json_t const* json, - char const* attributes[], int nrAttributes, - bool docComplete, int& error) { - error = TRI_ERROR_NO_ERROR; - std::shared_ptr transformed = arangodb::basics::JsonHelper::toVelocyPack(json); - std::vector attr; - - for (int i = 0; i < nrAttributes; i++) { - attr.emplace_back(attributes[i]); - } - return arangodb::basics::VelocyPackHelper::hashByAttributes( - transformed->slice(), attr, docComplete, error); -} diff --git a/lib/Basics/json-utilities.h b/lib/Basics/json-utilities.h index cfd9f6f525..d0f32d8983 100644 --- a/lib/Basics/json-utilities.h +++ b/lib/Basics/json-utilities.h @@ -57,13 +57,4 @@ TRI_json_t* TRI_MergeJson(TRI_memory_zone_t*, TRI_json_t const*, uint64_t TRI_FastHashJson(TRI_json_t const* json); -//////////////////////////////////////////////////////////////////////////////// -/// @brief compute a hash value for a JSON document depending on a list -/// of attributes. -//////////////////////////////////////////////////////////////////////////////// - -uint64_t TRI_HashJsonByAttributes(TRI_json_t const* json, - char const* attributes[], int nrAttributes, - bool docComplete, int& error); - #endif diff --git a/lib/Rest/HttpResponse.cpp b/lib/Rest/HttpResponse.cpp index 9769be8d2f..4d44e88a7b 100644 --- a/lib/Rest/HttpResponse.cpp +++ b/lib/Rest/HttpResponse.cpp @@ -40,7 +40,6 @@ HttpResponse::HttpResponse(ResponseCode code) _connectionType(CONNECTION_KEEP_ALIVE), _contentType(CONTENT_TYPE_TEXT), _isHeadResponse(false), - _isChunked(false), // TODO: remove _body(TRI_UNKNOWN_MEM_ZONE, false), _bodySize(0) { @@ -213,6 +212,7 @@ void HttpResponse::writeHeader(StringBuffer* output) { } } + // add "Content-Type" header switch (_contentType) { case CONTENT_TYPE_JSON: output->appendText(TRI_CHAR_LENGTH_PAIR("Content-Type: application/json; charset=utf-8\r\n")); diff --git a/lib/Rest/HttpResponse.h b/lib/Rest/HttpResponse.h index 7ad75e1054..df828a08f6 100644 --- a/lib/Rest/HttpResponse.h +++ b/lib/Rest/HttpResponse.h @@ -40,7 +40,6 @@ class HttpResponse : public GeneralResponse { public: bool isHeadResponse() const { return _isHeadResponse; } - bool isChunked() const { return _isChunked; } enum ConnectionType { CONNECTION_NONE, @@ -105,7 +104,6 @@ class HttpResponse : public GeneralResponse { ConnectionType _connectionType; ContentType _contentType; bool _isHeadResponse; - bool _isChunked; // TODO: remove std::vector _cookies; basics::StringBuffer _body; size_t _bodySize;