|
|
@ -1,28 +1,13 @@ |
|
|
|
%% Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved. |
|
|
|
%% |
|
|
|
%% This package, Looking Glass, is double-licensed under the Mozilla |
|
|
|
%% Public License 1.1 ("MPL") and the Apache License version 2 |
|
|
|
%% ("ASL"). For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL, |
|
|
|
%% please see LICENSE-APACHE2. |
|
|
|
%% |
|
|
|
%% This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, |
|
|
|
%% either express or implied. See the LICENSE file for specific language governing |
|
|
|
%% rights and limitations of this software. |
|
|
|
%% |
|
|
|
%% If you have any questions regarding licensing, please contact us at |
|
|
|
%% info@rabbitmq.com. |
|
|
|
|
|
|
|
%% Going for hardcoded values for now. We can't spend time |
|
|
|
%% looking up inside a record or map for this. |
|
|
|
|
|
|
|
-module(tpTerm). |
|
|
|
|
|
|
|
%% 现在要使用硬编码的值。我们不能花时间在记录或地图中查找。 |
|
|
|
|
|
|
|
-export([truncate/1]). |
|
|
|
-export([truncate/2]). |
|
|
|
|
|
|
|
-define(MAX_DEPTH, 5). |
|
|
|
-define(MAX_BINARY_SIZE, 128). |
|
|
|
-define(MAX_BITSTRING_SIZE, ?MAX_BINARY_SIZE * 8). |
|
|
|
-define(MAX_BITS_SIZE, ?MAX_BINARY_SIZE * 8). |
|
|
|
-define(MAX_DATA_STRUCTURES, 5). |
|
|
|
-define(MAX_LIST_LENGTH, 32). |
|
|
|
-define(MAX_MAP_SIZE, 32). |
|
|
@ -33,7 +18,7 @@ truncate(Term) -> |
|
|
|
|
|
|
|
truncate(_, Depth) when Depth > ?MAX_DEPTH -> |
|
|
|
'$truncated'; |
|
|
|
truncate(Term, _) when bit_size(Term) > ?MAX_BITSTRING_SIZE -> |
|
|
|
truncate(Term, _) when bit_size(Term) > ?MAX_BITS_SIZE -> |
|
|
|
<<Truncated:?MAX_BINARY_SIZE/binary, _/bits>> = Term, |
|
|
|
<<Truncated/binary, "$truncated">>; |
|
|
|
truncate(Term, Depth) when is_list(Term), Depth =:= ?MAX_DEPTH -> |
|
|
|