<commit_before>%% ---------------------------------------------------------------------
%%
%% Copyright (c) 2007-2013 Basho Technologies, Inc.  All Rights Reserved.
%%
%% This file is provided to you 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.
%%
%% ---------------------------------------------------------------------

%% @doc Riak Time Samples.

%% Each sample is stored as a JSON object with `start_time' and
%% `end_time' fields, expressed as strings in ISO8601 format.  The
%% object stored in riak is keyed by the start of the slice in which
%% the `Start' time falls.

%% Slices start at midnight and progress through the day (all times
%% are UTC).  If the period does not evenly divide the day, the final
%% slice will be truncated at midnight.

%% When multiple samples for a time+postfix are stored, each is
%% expressed as a sibling of the Riak object.  (TODO: compaction) It
%% is therefore important to ensure that `allow_mult=true' is set for
%% the bucket in which the samples are stored.

%% The `Data' argument passed to {@link new_sample/6} is expected to
%% be a proplist suitable for inclusion in the Mochijson2 structure
%% that includes the start and end times.

-module(rts).

-export([
         new_sample/6,
         find_samples/6,
         slice_containing/2,
         next_slice/2,
         iso8601/1
        ]).

-include("riak_cs.hrl").
-include("rts.hrl").
-ifdef(TEST).
-ifdef(EQC).
-compile([export_all]).
-include_lib("eqc/include/eqc.hrl").
-endif.
-include_lib("eunit/include/eunit.hrl").
-endif.

-export_type([slice/0]).

-type datetime() :: calendar:datetime().
-type slice() :: {Start :: datetime(), End :: datetime()}.
-type mochijson2() :: term().

%% @doc Just create the new sample object (don't store it).
-spec new_sample(binary(), iolist(),
                 datetime(), datetime(),<commit_msg>Avoid including riak_cs.hrl<commit_after>%% ---------------------------------------------------------------------
%%
%% Copyright (c) 2007-2013 <NAME>, Inc.  All Rights Reserved.
%%
%% This file is provided to you 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.
%%
%% ---------------------------------------------------------------------

%% @doc Riak Time Samples.

%% Each sample is stored as a JSON object with `start_time' and
%% `end_time' fields, expressed as strings in ISO8601 format.  The
%% object stored in riak is keyed by the start of the slice in which
%% the `Start' time falls.

%% Slices start at midnight and progress through the day (all times
%% are UTC).  If the period does not evenly divide the day, the final
%% slice will be truncated at midnight.

%% When multiple samples for a time+postfix are stored, each is
%% expressed as a sibling of the Riak object.  (TODO: compaction) It
%% is therefore important to ensure that `allow_mult=true' is set for
%% the bucket in which the samples are stored.

%% The `Data' argument passed to {@link new_sample/6} is expected to
%% be a proplist suitable for inclusion in the Mochijson2 structure
%% that includes the start and end times.

-module(rts).

-export([
         new_sample/6,
         find_samples/6,
         slice_containing/2,
         next_slice/2,
         iso8601/1
        ]).

-include("rts.hrl").
-ifdef(TEST).
-ifdef(EQC).
-compile([export_all]).
-include_lib("eqc/include/eqc.hrl").
-endif.
-include_lib("eunit/include/eunit.hrl").
-endif.

-export_type([slice/0]).

-type datetime() :: calendar:datetime().
-type slice() :: {Start :: datetime(), End :: datetime()}.
-type mochijson2() :: term().
-type riak_client() :: pid().

%% @doc Just create the new sample object (don't store it).
-spec new_sample(binary(), iolist(),
                 datetime(), datetime(),
{'fraction_non_alphanumeric': 0.1723037651563497, 'fraction_numerical': 0.012337800467985535, 'mean_word_length': 2.81965881397238, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5468305', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1287, 'n_words': 552}