This is an automated email from the ASF dual-hosted git repository. jaydoane pushed a commit to branch cleanup-hastings in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 2c01d825f8c1696b082f1a3b97c8806328fc485a Author: Jay Doane <[email protected]> AuthorDate: Mon Oct 27 11:13:09 2025 -0700 Remove hastings references Hastings was a geospatial search application from cloudant-labs [1] that is no longer supported because Cloudant no longer supports geospatial search in its product. The last hastings bug fix was in 2021, so it seems likely that this scaffolding is safe to remove. [1] https://github.com/cloudant-labs/hastings --- build-aux/xref-helper.sh | 1 - src/ken/rebar.config.script | 4 -- src/ken/src/ken.app.src.script | 2 - src/ken/src/ken_server.erl | 69 +------------------------------ src/mem3/src/mem3_reshard_index.erl | 24 +---------- src/mem3/test/eunit/mem3_reshard_test.erl | 51 ++--------------------- 6 files changed, 7 insertions(+), 144 deletions(-) diff --git a/build-aux/xref-helper.sh b/build-aux/xref-helper.sh index 5e1c3ed1a..2b83c74f3 100755 --- a/build-aux/xref-helper.sh +++ b/build-aux/xref-helper.sh @@ -9,7 +9,6 @@ mkdir -p ./tmp $REBAR --keep-going --recursive xref $DIALYZE_OPTS | \ grep -v '==>' | \ grep -v 'WARN' | \ - grep -v hastings | \ sort > ./tmp/xref-output.txt # compare result against known allowed output diff --git a/src/ken/rebar.config.script b/src/ken/rebar.config.script index d219b606a..ceef74a9c 100644 --- a/src/ken/rebar.config.script +++ b/src/ken/rebar.config.script @@ -14,9 +14,6 @@ HaveDreyfus = element(1, file:list_dir("../dreyfus")) == ok. -HastingsHome = os:getenv("HASTINGS_HOME", "../hastings"). -HaveHastings = element(1, file:list_dir(HastingsHome)) == ok. - CurrOpts = case lists:keyfind(erl_opts, 1, CONFIG) of {erl_opts, Opts} -> Opts; false -> [] @@ -24,7 +21,6 @@ end, NewOpts = if HaveDreyfus -> [{d, 'HAVE_DREYFUS'}]; true -> [] end ++ - if HaveHastings -> [{d, 'HAVE_HASTINGS'}]; true -> [] end ++ [{i, "../"}] ++ CurrOpts. lists:keystore(erl_opts, 1, CONFIG, {erl_opts, NewOpts}). diff --git a/src/ken/src/ken.app.src.script b/src/ken/src/ken.app.src.script index aad00a7b9..5ee3f4b25 100644 --- a/src/ken/src/ken.app.src.script +++ b/src/ken/src/ken.app.src.script @@ -11,7 +11,6 @@ % the License. HaveDreyfus = code:lib_dir(dreyfus) /= {error, bad_name}. -HaveHastings = code:lib_dir(hastings) /= {error, bad_name}. BaseApplications = [ kernel, @@ -24,7 +23,6 @@ BaseApplications = [ Applications = if HaveDreyfus -> [dreyfus]; true -> [] end ++ - if HaveHastings -> [hastings]; true -> [] end ++ BaseApplications. {application, ken, [ diff --git a/src/ken/src/ken_server.erl b/src/ken/src/ken_server.erl index acafb41c5..749629ef1 100644 --- a/src/ken/src/ken_server.erl +++ b/src/ken/src/ken_server.erl @@ -55,10 +55,6 @@ -include_lib("dreyfus/include/dreyfus.hrl"). -endif. --ifdef(HAVE_HASTINGS). --include_lib("hastings/src/hastings.hrl"). --endif. - start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). @@ -145,17 +141,6 @@ handle_cast({remove, DbName}, State) -> handle_cast({resubmit, DbName}, State) -> ets:delete(ken_resubmit, DbName), handle_cast({add, DbName}, State); -% st index job names have 3 elements, 3rd being 'hastings'. See job record definition. -handle_cast({trigger_update, #job{name = {_, _, hastings}, server = GPid, seq = Seq} = Job}, State) -> - % hastings_index:await will trigger a hastings index update - {Pid, _} = spawn_monitor( - hastings_index, - await, - [GPid, Seq] - ), - Now = erlang:monotonic_time(), - ets:insert(ken_workers, Job#job{worker_pid = Pid, lru = Now}), - {noreply, State, 0}; handle_cast({trigger_update, #job{name = {_, Index, nouveau}} = Job}, State) -> % nouveau_index_manager:update_index will trigger a search index update. {Pid, _} = spawn_monitor( @@ -330,10 +315,9 @@ update_ddoc_indexes(Name, #doc{} = Doc, State) -> ok end, SearchUpdated = search_updated(Name, Doc, Seq, State), - STUpdated = st_updated(Name, Doc, Seq, State), NouveauUpdated = nouveau_updated(Name, Doc, Seq, State), - case {ViewUpdated, SearchUpdated, STUpdated, NouveauUpdated} of - {ok, ok, ok, ok} -> ok; + case {ViewUpdated, SearchUpdated, NouveauUpdated} of + {ok, ok, ok} -> ok; _ -> resubmit end. @@ -355,24 +339,6 @@ search_updated(_Name, _Doc, _Seq, _State) -> ok. -endif. --ifdef(HAVE_HASTINGS). -st_updated(Name, Doc, Seq, State) -> - case should_update(Doc, <<"st_indexes">>) of - true -> - try hastings_index:design_doc_to_indexes(Doc) of - STIndexes -> update_ddoc_st_indexes(Name, STIndexes, Seq, State) - catch - _:_ -> - ok - end; - false -> - ok - end. --else. -st_updated(_Name, _Doc, _Seq, _State) -> - ok. --endif. - nouveau_updated(Name, Doc, Seq, State) -> case should_update(Doc, <<"nouveau">>) of true -> @@ -440,33 +406,6 @@ update_ddoc_search_indexes(DbName, Indexes, Seq, State) -> end. -endif. --ifdef(HAVE_HASTINGS). -update_ddoc_st_indexes(DbName, Indexes, Seq, State) -> - if - Indexes =/= [] -> - % The record name in hastings is #h_idx rather than #index as it is for dreyfus - % Spawn a job for each spatial index in the ddoc - lists:foldl( - fun(#h_idx{ddoc_id = DDocName} = Index, Acc) -> - case hastings_index_manager:get_index(DbName, Index) of - {ok, Pid} -> - case maybe_start_job({DbName, DDocName, hastings}, Pid, Seq, State) of - resubmit -> resubmit; - _ -> Acc - end; - _ -> - % If any job fails, retry the db. - resubmit - end - end, - ok, - Indexes - ); - true -> - ok - end. --endif. - update_ddoc_nouveau_indexes(DbName, Indexes, Seq, State) -> if Indexes =/= [] -> @@ -504,10 +443,6 @@ should_start_job(#job{name = Name, seq = Seq, server = Pid}, State) -> true; A < TotalChannels -> case Name of - % st_index name has three elements - {_, _, hastings} -> - {ok, CurrentSeq} = hastings_index:await(Pid, 0), - (Seq - CurrentSeq) < Threshold; % View name has two elements. _ when IsView -> % Since seq is 0, couch_index:get_state/2 won't diff --git a/src/mem3/src/mem3_reshard_index.erl b/src/mem3/src/mem3_reshard_index.erl index 0cd6f2cf3..61390588a 100644 --- a/src/mem3/src/mem3_reshard_index.erl +++ b/src/mem3/src/mem3_reshard_index.erl @@ -21,7 +21,6 @@ -define(MRVIEW, mrview). -define(DREYFUS, dreyfus). --define(HASTINGS, hastings). -define(NOUVEAU, nouveau). -include_lib("mem3/include/mem3.hrl"). @@ -63,8 +62,7 @@ fabric_design_docs(DbName) -> indices(DbName, Doc) -> mrview_indices(DbName, Doc) ++ nouveau_indices(DbName, Doc) ++ - [dreyfus_indices(DbName, Doc) || has_app(dreyfus)] ++ - [hastings_indices(DbName, Doc) || has_app(hastings)]. + [dreyfus_indices(DbName, Doc) || has_app(dreyfus)]. mrview_indices(DbName, Doc) -> try @@ -110,17 +108,6 @@ dreyfus_indices(DbName, Doc) -> [] end. -hastings_indices(DbName, Doc) -> - try - Indices = hastings_index:design_doc_to_indexes(Doc), - [{?HASTINGS, DbName, Index} || Index <- Indices] - catch - Tag:Err -> - Msg = "~p couldn't get hasting indices ~p ~p ~p:~p", - couch_log:error(Msg, [?MODULE, DbName, Doc, Tag, Err]), - [] - end. - build_index({?MRVIEW, DbName, MRSt} = Ctx, Try) -> ioq:set_io_priority({reshard, DbName}), await_retry( @@ -138,13 +125,6 @@ build_index({?DREYFUS, DbName, DIndex} = Ctx, Try) -> fun dreyfus_index:await/2, Ctx, Try - ); -build_index({?HASTINGS, DbName, HIndex} = Ctx, Try) -> - await_retry( - hastings_index_manager:get_index(DbName, HIndex), - fun hastings_index:await/2, - Ctx, - Try ). await_retry({ok, Pid}, AwaitIndex, {_, DbName, _} = Ctx, Try) -> @@ -196,8 +176,6 @@ index_info({?MRVIEW, DbName, MRSt}) -> GroupName = couch_mrview_index:get(idx_name, MRSt), {DbName, GroupName}; index_info({?DREYFUS, DbName, Index}) -> - {DbName, Index}; -index_info({?HASTINGS, DbName, Index}) -> {DbName, Index}. has_app(App) -> diff --git a/src/mem3/test/eunit/mem3_reshard_test.erl b/src/mem3/test/eunit/mem3_reshard_test.erl index 9fed4e295..42aeba6b3 100644 --- a/src/mem3/test/eunit/mem3_reshard_test.erl +++ b/src/mem3/test/eunit/mem3_reshard_test.erl @@ -27,12 +27,6 @@ setup() -> false -> ok; true -> mock_dreyfus_indices() end, - - HaveHastings = code:lib_dir(hastings) /= {error, bad_name}, - case HaveHastings of - false -> ok; - true -> mock_hastings_indices() - end, {Db1, Db2} = {?tempdb(), ?tempdb()}, create_db(Db1, [{q, 1}, {n, 1}]), PartProps = [{partitioned, true}, {hash, [couch_partition, hash, []]}], @@ -300,17 +294,14 @@ update_docs_before_topoff1(#{db1 := Db}) -> indices_are_built(#{db1 := Db}) -> {timeout, ?TIMEOUT, ?_test(begin - HaveDreyfus = code:lib_dir(dreyfus) /= {error, bad_name}, - HaveHastings = code:lib_dir(hastings) /= {error, bad_name}, - - add_test_docs(Db, #{docs => 10, mrview => 2, search => 2, geo => 2}), + add_test_docs(Db, #{docs => 10, mrview => 2, search => 2}), [#shard{name = Shard}] = lists:sort(mem3:local_shards(Db)), {ok, JobId} = mem3_reshard:start_split_job(Shard), wait_state(JobId, completed), Shards1 = lists:sort(mem3:local_shards(Db)), ?assertEqual(2, length(Shards1)), MRViewGroupInfo = get_group_info(Db, <<"_design/mrview00000">>), - ?assertMatch(#{<<"update_seq">> := 32}, MRViewGroupInfo), + ?assertMatch(#{<<"update_seq">> := 28}, MRViewGroupInfo), HaveDreyfus = code:lib_dir(dreyfus) /= {error, bad_name}, case HaveDreyfus of @@ -319,15 +310,6 @@ indices_are_built(#{db1 := Db}) -> true -> % 4 because there are 2 indices and 2 target shards ?assertEqual(4, meck:num_calls(dreyfus_index, await, 2)) - end, - - HaveHastings = code:lib_dir(hastings) /= {error, bad_name}, - case HaveHastings of - false -> - ok; - true -> - % 4 because there are 2 indices and 2 target shards - ?assertEqual(4, meck:num_calls(hastings_index, await, 2)) end end)}. @@ -335,7 +317,7 @@ indices_are_built(#{db1 := Db}) -> indices_can_be_built_with_errors(#{db1 := Db}) -> {timeout, ?TIMEOUT, ?_test(begin - add_test_docs(Db, #{docs => 10, mrview => 2, search => 2, geo => 2}), + add_test_docs(Db, #{docs => 10, mrview => 2, search => 2}), [#shard{name = Shard}] = lists:sort(mem3:local_shards(Db)), meck:expect( couch_index_server, @@ -367,7 +349,7 @@ indices_can_be_built_with_errors(#{db1 := Db}) -> Shards1 = lists:sort(mem3:local_shards(Db)), ?assertEqual(2, length(Shards1)), MRViewGroupInfo = get_group_info(Db, <<"_design/mrview00000">>), - ?assertMatch(#{<<"update_seq">> := 32}, MRViewGroupInfo) + ?assertMatch(#{<<"update_seq">> := 28}, MRViewGroupInfo) end)}. mock_dreyfus_indices() -> @@ -383,19 +365,6 @@ mock_dreyfus_indices() -> meck:expect(dreyfus_index_manager, get_index, fun(_, _) -> {ok, pid} end), meck:expect(dreyfus_index, await, fun(_, _) -> {ok, indexpid, someseq} end). -mock_hastings_indices() -> - meck:expect(hastings_index, design_doc_to_indexes, fun(Doc) -> - #doc{body = {BodyProps}} = Doc, - case couch_util:get_value(<<"st_indexes">>, BodyProps) of - undefined -> - []; - {[_]} -> - [{hastings, <<"db">>, hastings_index1}] - end - end), - meck:expect(hastings_index_manager, get_index, fun(_, _) -> {ok, pid} end), - meck:expect(hastings_index, await, fun(_, _) -> {ok, someseq} end). - % Split partitioned database split_partitioned_db(#{db2 := Db}) -> {timeout, ?TIMEOUT, @@ -951,7 +920,6 @@ add_test_docs(DbName, #{} = DocSpec) -> pdocs(maps:get(pdocs, DocSpec, #{})) ++ ddocs(mrview, maps:get(mrview, DocSpec, [])) ++ ddocs(search, maps:get(search, DocSpec, [])) ++ - ddocs(geo, maps:get(geo, DocSpec, [])) ++ ldocs(maps:get(local, DocSpec, [])), Res = update_docs(DbName, Docs), Docs1 = lists:map( @@ -1048,17 +1016,6 @@ ddprop(mrview) -> ]}} ]}} ]; -ddprop(geo) -> - [ - {<<"st_indexes">>, - {[ - {<<"area">>, - {[ - {<<"analyzer">>, <<"standard">>}, - {<<"index">>, <<"function(d){if(d.g){st_index(d.g)}}">>} - ]}} - ]}} - ]; ddprop(search) -> [ {<<"indexes">>,
