Преглед на файлове

代码提交

erlArango_v1
AICells преди 5 години
родител
ревизия
b9935f63f9
променени са 3 файла, в които са добавени 229 реда и са изтрити 6 реда
  1. +1
    -0
      include/erlArango.hrl
  2. +220
    -2
      src/arangoApi/agCollections.erl
  3. +8
    -4
      src/arangoApi/agDbMgr.erl

+ 1
- 0
include/erlArango.hrl Целия файл

@ -2,5 +2,6 @@
-define(agAgencyPoolMgr, agAgencyPoolMgr).
-define(Get, <<"GET">>).
-define(Put, <<"PUT">>).
-define(Post, <<"POST">>).
-define(Delete, <<"DELETE">>).

+ 220
- 2
src/arangoApi/agCollections.erl Целия файл

@ -1,4 +1,222 @@
-module(agCollections).
-include("erlArango.hrl").
-compile(export_all).
%
% POST /_api/collection
%
% waitForSyncReplication10
% forceReplicationFactor10
%
% JSON对象是必需的
% name
% waitForSynctruefalse
% doCompacttrueMMFiles存储引擎有意义
% journalSize10485761 MiBMMFiles存储引擎有意义
% isSystemtruecollection-name 线API实现者来创建系统集合使false
% isVolatiletrue
% 使ArangoDB不会对磁盘CRC校验和
% falseMMFiles存储引擎有意义
% keyOptionskeyOptions JSON数组
% typeuuid和填充生成器
% inital偏移和间隔可以被配置成在填充密钥发生器以上升辞书排序顺序生成的固定长度16
% RocksDB 使使UUID密钥生成器生成通用的唯一128位密钥
%
% allowUserKeystrue_key属性中提供自己的键值 false_key属性中提供自己的密钥值被视为错误
%
% offset
% type2
% 2
% 3
% indexBuckets使1621024
%
% 1亿64ArangoDB版本中使用MMFiles存储引擎有意义
% numberOfShards1
% shardKeys[ _key]使
%
% plicationFactor1DBServer上保留多少个副本1k的值表示保留k-1DBServer上
% leader follower
%
% DistributionShardsLike 使
% 仿
% shardingStrategyArangoDB 3.4shardingStrategy
% 使使
%
% community-compat3.4ArangoDB社区版使用的默认分片
% enterprise-compat3.4ArangoDB企业版使用的默认分片
% enterprise-smart-edge-compat3.4ArangoDB Enterprise Edition中的智能边缘集合使用的默认分片
% hash3.4
% enterprise-hash-smart-edge3.4
% enterprise-hash-smart-edgeArangoDB
%
% smartJoinAttributeEnterprise Edition集群中
% 使 distributedShardsLike属性设置为另一个集合的名称shardKeys属性设置为单个shard key属性smartJoinAttribute中存储的值都必须是字符串
%
%
% 400HTTP 400
% 404HTTP 404
newColl(PoolName, Param) ->
BodyStr = jsx:encode(Param),
agHttpCli:callAgency(PoolName, ?Post, <<"/_api/collection">>, [], BodyStr, infinity).
%
% DELETE /_api/collection/{collection-name}
delColl(PoolName, CoolName, IsSystem) ->
case IsSystem of
true ->
Path = <<"/_api/collection/", CoolName/binary, "?isSystem=true">>,
agHttpCli:callAgency(PoolName, ?Delete, Path, [], undefined, infinity);
_ ->
Path = <<"/_api/collection/", CoolName/binary>>,
agHttpCli:callAgency(PoolName, ?Delete, Path, [], undefined, infinity)
end.
%%
%% PUT /_api/collection/{collection-name}/truncate
clearColl(PoolName, CoolName) ->
Path = <<"/_api/collection/", CoolName/binary, "/truncate">>,
agHttpCli:callAgency(PoolName, ?Put, Path, [], undefined, infinity).
%%
%% GET /_api/collection/{collection-name}
%%
%% id
%% name
%% status
%% 1
%% 2
%% 3
%% 4
%% 5
%% 6
%%
%% type
%% 2
%% 3
%% isSystemtrue
collInfo(PoolName, CoolName) ->
Path = <<"/_api/collection/", CoolName/binary>>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity).
%%
%%
%% GET /_api/collection/{collection-name}/properties
collProperties(PoolName, CoolName) ->
Path = <<"/_api/collection/", (CoolName)/binary, "/properties">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity).
%%
%%
%%
%% GET /_api/collection/{collection-name}/count
collCount(PoolName, CoolName) ->
Path = <<"/_api/collection/", CoolName/binary, "/count">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity).
%%
%%
%% GET /_api/collection/{collection-name}/figures
%%
collFigures(PoolName, CoolName) ->
Path = <<"/_api/collection/", CoolName/binary, "/figures">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity).
%%
%% 退
%% PUT /_api/collection/{collection-name}/responsibleShard
%%
%% collection-name
%% json
%% JSON对象
%% ID
%% JSON文档
%% shardId属性的JSON对象ID
%%
collResponsibleShard(PoolName, CoolName, Param) ->
Path = <<"/_api/collection/", CoolName/binary, "/responsibleShard">>,
BodyStr = jsx:encode(Param),
agHttpCli:callAgency(PoolName, ?Get, Path, [], BodyStr, infinity).
%% ID
%% ID
%% ID的JSON数组
%% details参数设置为trueID作为对象属性键的JSON对象
%%
%% GET /_api/collection/{collection-name}/shards
%% Query Parameters
%% details (optional)true
collShards(PoolName, CoolName, IsDetails) ->
case IsDetails of
true ->
Path = <<"/_api/collection/", CoolName/binary, "/shards?details=true">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity);
_ ->
Path = <<"/_api/collection/", CoolName/binary, "/shards">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity)
end.
%% ID
%% ID
%% IDID是服务器生成的字符串使
%% ID作为字符串
%% GET /_api/collection/{collection-name}/revision
collRevision(PoolName, CoolName) ->
Path = <<"/_api/collection/", CoolName/binary, "/revision">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity).
%%
%%
%%
%% withRevisionsID
%% withData
%% ID
%% ArangoDB实例上的两个集合是否包含相同的内容
%% _key系统属性来计算_from和_to也将包含在计算中
%% withRevisions设置为trueID_rev系统属性
%% withData提供值为true的值 使
%% JSON对象
%% checksum
%% ID作为字符串
%%
%% GET /_api/collection/{collection-name}/checksum
collChecksum(PoolName, CoolName, IsWithRevisions, IsWithData) ->
case IsWithRevisions orelse IsWithData of
false ->
Path = <<"/_api/collection/", CoolName/binary, "/checksum">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity);
_ ->
Path = <<"/_api/collection/", CoolName/binary, "/checksum?withRevisions=", (erlang:atom_to_binary(IsWithRevisions, utf8))/binary, "&withData=", (erlang:atom_to_binary(IsWithRevisions, utf8))/binary>>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity)
end.
%%
%%
%%
%%
%%excludeSystem
%% GET /_api/collection
collList(PoolName, CoolName, IsExcludeSystem) ->
case IsExcludeSystem of
false ->
Path = <<"/_api/collection/", CoolName/binary, "/checksum">>,
agHttpCli:callAgency(PoolName, ?Get, <<"/_api/collection">>, [], undefined, infinity);
_ ->
Path = <<"/_api/collection/?excludeSystem=true">>,
agHttpCli:callAgency(PoolName, ?Get, Path, [], undefined, infinity)
end.
%%
%%
%% countcount设置为 false可以加快加载集合的速度
%% PUT /_api/collection/{collection-name}/load
collLoad(PoolName, CoolName, IsCount) ->
case IsCount of
false ->
Path = <<"/_api/collection/", CoolName/binary, "/load">>,
agHttpCli:callAgency(PoolName, ?Put, Path, [], <<"{\"count\":false}">>, infinity);
_ ->
Path = <<"/_api/collection/", CoolName/binary, "/load">>,
agHttpCli:callAgency(PoolName, ?Put, Path, [], undefined, infinity)
end.
%% API
-export([]).

+ 8
- 4
src/arangoApi/agDbMgr.erl Целия файл

@ -3,7 +3,6 @@
-compile(export_all).
%% _system访访
%%
@ -25,10 +24,15 @@ userVisitDbs(PoolName) ->
% passwd
% activetruefalse
% extraJSON对象Extra中包含的数据 ArangoDB不会进一步解释
newDb(PoolName, Name) ->
NameStr = jsx:encode(Name),
agHttpCli:callAgency(PoolName, ?Post, <<"/_api/database">>, [], [<<"{\"name\":">>, NameStr, <<"}">>], infinity).
newDb(PoolName, Name, Users) ->
NameStr = jsx:encode(#{name => Name}),
UsersStr = jsx:encode(#{users => Users}),
agHttpCli:callAgency(PoolName, ?Post, <<"/_api/database">>, [], [NameStr, UsersStr], infinity).
BodyStr = jsx:encode(#{<n><"name">> => Name, <<"users">> => Users}),
agHttpCli:callAgency(PoolName, ?Post, <<"/_api/database">>, [], BodyStr, infinity).
%%
%% DELETE /_api/database/{database-name}

Зареждане…
Отказ
Запис