@@ -946,15 +946,22 @@ book_objectfold(Pid, Tag, Bucket, Limiter, FoldAccT, SnapPreFold) ->
946
946
% % `Acc'. The ProxyObject is an object that only contains the
947
947
% % head/metadata, and no object data from the journal. The `Acc' in
948
948
% % the first call is that provided as the second element of `FoldAccT'
949
- % % and thereafter the return of the previous all to the fold fun. If
950
- % % `JournalCheck' is `true' then the journal is checked to see if the
951
- % % object in the ledger is present, which means a snapshot of the
952
- % % whole store is required, if `false', then no such check is
953
- % % performed, and onlt ledger need be snapshotted. `SnapPreFold' is a
954
- % % boolean that determines if the snapshot is taken when the folder is
955
- % % requested `true', or when when run `false'. `SegmentList' can be
956
- % % `false' meaning, all heads, or a list of integers that designate
957
- % % segments in a TicTac Tree.
949
+ % % and thereafter the return of the previous all to the fold fun.
950
+ % %
951
+ % % If `JournalCheck' is `true' then the journal is checked to see if the
952
+ % % object in the ledger is present, which means a snapshot of the whole store
953
+ % % is required, if `false', then no such check is performed, and only ledger
954
+ % % need be snapshotted. However, if the intention is to defer fetching the
955
+ % % value but don't wish to cost of chekcing the Journal to be made during the
956
+ % % fold (e.g. as any exception will be handled later), then the `defer`
957
+ % % option can be used. This will snapshot the Journal, but not check for
958
+ % % presence. Note that the fetch must still be made within the timefroma of
959
+ % % the fold (as the snapshot will expire with the fold).
960
+ % %
961
+ % % `SnapPreFold' is a boolean that determines if the snapshot is taken when
962
+ % % the folder is requested `true', or when when run `false'. `SegmentList' can
963
+ % % be `false' meaning, all heads, or a list of integers that designate segments
964
+ % % in a TicTac Tree.
958
965
- spec book_headfold (pid (), Tag , FoldAccT , JournalCheck , SnapPreFold , SegmentList ) ->
959
966
{async , Runner } when
960
967
Tag :: leveled_codec :tag (),
@@ -964,7 +971,7 @@ book_objectfold(Pid, Tag, Bucket, Limiter, FoldAccT, SnapPreFold) ->
964
971
Bucket :: term (),
965
972
Key :: term (),
966
973
Value :: term (),
967
- JournalCheck :: boolean (),
974
+ JournalCheck :: boolean ()| defer ,
968
975
SnapPreFold :: boolean (),
969
976
SegmentList :: false | list (integer ()),
970
977
Runner :: fun (() -> Acc ).
@@ -999,7 +1006,7 @@ book_headfold(Pid, Tag, FoldAccT, JournalCheck, SnapPreFold, SegmentList) ->
999
1006
Bucket :: term (),
1000
1007
Key :: term (),
1001
1008
Value :: term (),
1002
- JournalCheck :: boolean (),
1009
+ JournalCheck :: boolean ()| defer ,
1003
1010
SnapPreFold :: boolean (),
1004
1011
SegmentList :: false | list (integer ()),
1005
1012
Runner :: fun (() -> Acc ).
@@ -1032,7 +1039,7 @@ book_headfold(Pid, Tag, Limiter, FoldAccT, JournalCheck, SnapPreFold, SegmentLis
1032
1039
Bucket :: term (),
1033
1040
Key :: term (),
1034
1041
Value :: term (),
1035
- JournalCheck :: boolean (),
1042
+ JournalCheck :: boolean ()| defer ,
1036
1043
SnapPreFold :: boolean (),
1037
1044
SegmentList :: false | list (integer ()),
1038
1045
LastModRange :: false | leveled_codec :lastmod_range (),
@@ -1989,7 +1996,7 @@ return_snapfun(
1989
1996
fun () -> {ok , LS , JS , fun () -> ok end } end
1990
1997
end .
1991
1998
1992
- - spec snaptype_by_presence (boolean ()) -> store |ledger .
1999
+ - spec snaptype_by_presence (boolean ()| defer ) -> store |ledger .
1993
2000
% % @doc
1994
2001
% % Folds that traverse over object heads, may also either require to return
1995
2002
% % the object, or at least confirm the object is present in the Ledger. This
@@ -1998,6 +2005,8 @@ return_snapfun(
1998
2005
% % rather than just the ledger.
1999
2006
snaptype_by_presence (true ) ->
2000
2007
store ;
2008
+ snaptype_by_presence (defer ) ->
2009
+ store ;
2001
2010
snaptype_by_presence (false ) ->
2002
2011
ledger .
2003
2012
@@ -2030,9 +2039,8 @@ get_runner(State, {keylist, Tag, Bucket, FoldAccT}) ->
2030
2039
leveled_runner :bucketkey_query (SnapFun , Tag , Bucket , FoldAccT );
2031
2040
get_runner (State , {keylist , Tag , Bucket , KeyRange , FoldAccT , TermRegex }) ->
2032
2041
SnapFun = return_snapfun (State , ledger , no_lookup , true , true ),
2033
- leveled_runner :bucketkey_query (SnapFun ,
2034
- Tag , Bucket , KeyRange ,
2035
- FoldAccT , TermRegex );
2042
+ leveled_runner :bucketkey_query (
2043
+ SnapFun , Tag , Bucket , KeyRange , FoldAccT , TermRegex );
2036
2044
% % Set of runners for object or metadata folds
2037
2045
get_runner (State ,
2038
2046
{foldheads_allkeys ,
@@ -2041,10 +2049,15 @@ get_runner(State,
2041
2049
LastModRange , MaxObjectCount }) ->
2042
2050
SnapType = snaptype_by_presence (JournalCheck ),
2043
2051
SnapFun = return_snapfun (State , SnapType , no_lookup , true , SnapPreFold ),
2044
- leveled_runner :foldheads_allkeys (SnapFun ,
2045
- Tag , FoldFun ,
2046
- JournalCheck , SegmentList ,
2047
- LastModRange , MaxObjectCount );
2052
+ leveled_runner :foldheads_allkeys (
2053
+ SnapFun ,
2054
+ Tag ,
2055
+ FoldFun ,
2056
+ JournalCheck ,
2057
+ SegmentList ,
2058
+ LastModRange ,
2059
+ MaxObjectCount
2060
+ );
2048
2061
get_runner (State ,
2049
2062
{foldobjects_allkeys , Tag , FoldFun , SnapPreFold }) ->
2050
2063
get_runner (State ,
@@ -2071,13 +2084,16 @@ get_runner(State,
2071
2084
end ,
2072
2085
SnapType = snaptype_by_presence (JournalCheck ),
2073
2086
SnapFun = return_snapfun (State , SnapType , no_lookup , true , SnapPreFold ),
2074
- leveled_runner :foldheads_bybucket (SnapFun ,
2075
- Tag ,
2076
- lists :map (KeyRangeFun , BucketList ),
2077
- FoldFun ,
2078
- JournalCheck ,
2079
- SegmentList ,
2080
- LastModRange , MaxObjectCount );
2087
+ leveled_runner :foldheads_bybucket (
2088
+ SnapFun ,
2089
+ Tag ,
2090
+ lists :map (KeyRangeFun , BucketList ),
2091
+ FoldFun ,
2092
+ JournalCheck ,
2093
+ SegmentList ,
2094
+ LastModRange ,
2095
+ MaxObjectCount
2096
+ );
2081
2097
get_runner (State ,
2082
2098
{foldheads_bybucket ,
2083
2099
Tag ,
@@ -2088,33 +2104,33 @@ get_runner(State,
2088
2104
{StartKey , EndKey , SnapQ } = return_ledger_keyrange (Tag , Bucket , KeyRange ),
2089
2105
SnapType = snaptype_by_presence (JournalCheck ),
2090
2106
SnapFun = return_snapfun (State , SnapType , SnapQ , true , SnapPreFold ),
2091
- leveled_runner :foldheads_bybucket (SnapFun ,
2092
- Tag ,
2093
- [{StartKey , EndKey }],
2094
- FoldFun ,
2095
- JournalCheck ,
2096
- SegmentList ,
2097
- LastModRange , MaxObjectCount );
2107
+ leveled_runner :foldheads_bybucket (
2108
+ SnapFun ,
2109
+ Tag ,
2110
+ [{StartKey , EndKey }],
2111
+ FoldFun ,
2112
+ JournalCheck ,
2113
+ SegmentList ,
2114
+ LastModRange ,
2115
+ MaxObjectCount
2116
+ );
2098
2117
get_runner (State ,
2099
2118
{foldobjects_bybucket ,
2100
2119
Tag , Bucket , KeyRange ,
2101
2120
FoldFun ,
2102
2121
SnapPreFold }) ->
2103
2122
{StartKey , EndKey , SnapQ } = return_ledger_keyrange (Tag , Bucket , KeyRange ),
2104
2123
SnapFun = return_snapfun (State , store , SnapQ , true , SnapPreFold ),
2105
- leveled_runner :foldobjects_bybucket (SnapFun ,
2106
- Tag ,
2107
- [{StartKey , EndKey }],
2108
- FoldFun );
2124
+ leveled_runner :foldobjects_bybucket (
2125
+ SnapFun , Tag , [{StartKey , EndKey }], FoldFun );
2109
2126
get_runner (State ,
2110
2127
{foldobjects_byindex ,
2111
2128
Tag , Bucket , {Field , FromTerm , ToTerm },
2112
2129
FoldObjectsFun ,
2113
2130
SnapPreFold }) ->
2114
2131
SnapFun = return_snapfun (State , store , no_lookup , true , SnapPreFold ),
2115
- leveled_runner :foldobjects_byindex (SnapFun ,
2116
- {Tag , Bucket , Field , FromTerm , ToTerm },
2117
- FoldObjectsFun );
2132
+ leveled_runner :foldobjects_byindex (
2133
+ SnapFun , {Tag , Bucket , Field , FromTerm , ToTerm },FoldObjectsFun );
2118
2134
get_runner (State , {bucket_list , Tag , FoldAccT }) ->
2119
2135
{FoldBucketsFun , Acc } = FoldAccT ,
2120
2136
SnapFun = return_snapfun (State , ledger , no_lookup , false , false ),
0 commit comments