orientdb-binary 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +64 -0
- data/lib/orientdb_binary.rb +25 -0
- data/lib/orientdb_binary/base.rb +40 -0
- data/lib/orientdb_binary/config.rb +5 -0
- data/lib/orientdb_binary/connection.rb +17 -0
- data/lib/orientdb_binary/database.rb +24 -0
- data/lib/orientdb_binary/database_operations/base_operations.rb +70 -0
- data/lib/orientdb_binary/database_operations/data_cluster.rb +116 -0
- data/lib/orientdb_binary/database_operations/data_segment.rb +31 -0
- data/lib/orientdb_binary/database_operations/query.rb +58 -0
- data/lib/orientdb_binary/database_operations/record.rb +105 -0
- data/lib/orientdb_binary/database_operations/transaction.rb +8 -0
- data/lib/orientdb_binary/operation_types.rb +51 -0
- data/lib/orientdb_binary/parser/deserializer.rb +161 -0
- data/lib/orientdb_binary/parser/serializer.rb +83 -0
- data/lib/orientdb_binary/protocols/base.rb +42 -0
- data/lib/orientdb_binary/protocols/bindata_primitives.rb +46 -0
- data/lib/orientdb_binary/protocols/command.rb +166 -0
- data/lib/orientdb_binary/protocols/config_get.rb +22 -0
- data/lib/orientdb_binary/protocols/config_list.rb +24 -0
- data/lib/orientdb_binary/protocols/config_set.rb +22 -0
- data/lib/orientdb_binary/protocols/connect.rb +26 -0
- data/lib/orientdb_binary/protocols/datacluster_add.rb +26 -0
- data/lib/orientdb_binary/protocols/datacluster_count.rb +26 -0
- data/lib/orientdb_binary/protocols/datacluster_datarange.rb +23 -0
- data/lib/orientdb_binary/protocols/datacluster_drop.rb +22 -0
- data/lib/orientdb_binary/protocols/datacluster_lh_cluster_is_used.rb +20 -0
- data/lib/orientdb_binary/protocols/datasegment_add.rb +24 -0
- data/lib/orientdb_binary/protocols/datasegment_drop.rb +23 -0
- data/lib/orientdb_binary/protocols/db_close.rb +16 -0
- data/lib/orientdb_binary/protocols/db_countrecords.rb +20 -0
- data/lib/orientdb_binary/protocols/db_create.rb +23 -0
- data/lib/orientdb_binary/protocols/db_drop.rb +22 -0
- data/lib/orientdb_binary/protocols/db_exist.rb +23 -0
- data/lib/orientdb_binary/protocols/db_freeze.rb +21 -0
- data/lib/orientdb_binary/protocols/db_list.rb +26 -0
- data/lib/orientdb_binary/protocols/db_open.rb +43 -0
- data/lib/orientdb_binary/protocols/db_release.rb +21 -0
- data/lib/orientdb_binary/protocols/db_reload.rb +26 -0
- data/lib/orientdb_binary/protocols/db_size.rb +20 -0
- data/lib/orientdb_binary/protocols/errors.rb +28 -0
- data/lib/orientdb_binary/protocols/record_create.rb +35 -0
- data/lib/orientdb_binary/protocols/record_delete.rb +25 -0
- data/lib/orientdb_binary/protocols/record_load.rb +65 -0
- data/lib/orientdb_binary/protocols/record_update.rb +27 -0
- data/lib/orientdb_binary/protocols/shutdown.rb +21 -0
- data/lib/orientdb_binary/server.rb +71 -0
- data/orientdb-binary.gemspec +26 -0
- data/test/database/test_database.rb +193 -0
- data/test/database/test_deserializer.rb +140 -0
- data/test/database/test_serializer.rb +55 -0
- data/test/server/test_server.rb +73 -0
- data/test/test_helper.rb +9 -0
- metadata +162 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DataclusterLhClusterIsUsed < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DATACLUSTER_LH_CLUSTER_IS_USED
|
10
|
+
int32 :session
|
11
|
+
end
|
12
|
+
|
13
|
+
class DataclusterLhClusterIsUsedAnswer < BinData::Record
|
14
|
+
endian :big
|
15
|
+
|
16
|
+
int32 :session
|
17
|
+
bit4 :succeed
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DatasegmentAdd < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DATASEGMENT_ADD
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
protocol_string :name
|
13
|
+
protocol_string :location
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
class DatasegmentAddAnswer < BinData::Record
|
18
|
+
endian :big
|
19
|
+
|
20
|
+
int32 :session
|
21
|
+
int32 :segment_id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DatasegmentDrop < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DATASEGMENT_DROP
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
protocol_string :name
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class DatasegmentDropAnswer < BinData::Record
|
17
|
+
endian :big
|
18
|
+
|
19
|
+
int32 :session
|
20
|
+
bit4 :succeed
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbClose < BinData::Record
|
5
|
+
|
6
|
+
endian :big
|
7
|
+
|
8
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_CLOSE
|
9
|
+
int32 :session
|
10
|
+
|
11
|
+
def process(socket)
|
12
|
+
write(socket)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbCountRecords < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_COUNTRECORDS
|
10
|
+
int32 :session
|
11
|
+
end
|
12
|
+
|
13
|
+
class DbCountRecordsAnswer < BinData::Record
|
14
|
+
endian :big
|
15
|
+
|
16
|
+
int32 :session
|
17
|
+
int64 :count_records
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbCreate < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_CREATE
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
protocol_string :name
|
13
|
+
protocol_string :type
|
14
|
+
protocol_string :storage
|
15
|
+
end
|
16
|
+
|
17
|
+
class DbCreateAnswer < BinData::Record
|
18
|
+
endian :big
|
19
|
+
|
20
|
+
skip length: 4
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbDrop < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_DROP
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
protocol_string :name
|
13
|
+
protocol_string :storage
|
14
|
+
end
|
15
|
+
|
16
|
+
class DbDropAnswer < BinData::Record
|
17
|
+
endian :big
|
18
|
+
|
19
|
+
skip length: 4
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbExist < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_EXIST
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
protocol_string :database
|
13
|
+
protocol_string :server_storage_type, value: 'memory'
|
14
|
+
end
|
15
|
+
|
16
|
+
class DbExistAnswer < BinData::Record
|
17
|
+
endian :big
|
18
|
+
|
19
|
+
skip length: 4
|
20
|
+
int8 :exists
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
class DbFreeze < BinData::Record
|
4
|
+
include OrientdbBinary::Protocols::Base
|
5
|
+
|
6
|
+
endian :big
|
7
|
+
|
8
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_FREEZE
|
9
|
+
int32 :session
|
10
|
+
|
11
|
+
protocol_string :name
|
12
|
+
protocol_string :storage
|
13
|
+
end
|
14
|
+
|
15
|
+
class DbFreezeAnswer < BinData::Record
|
16
|
+
endian :big
|
17
|
+
|
18
|
+
int32 :session
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbList < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_LIST
|
10
|
+
int32 :session
|
11
|
+
end
|
12
|
+
|
13
|
+
class DbListAnswer < BinData::Record
|
14
|
+
endian :big
|
15
|
+
|
16
|
+
int32 :session
|
17
|
+
protocol_string :list
|
18
|
+
|
19
|
+
def process
|
20
|
+
OrientdbBinary::Parser::Deserializer.new().deserialize(list)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbOpen < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_OPEN
|
10
|
+
int32 :session, value: OrientdbBinary::OperationTypes::NEW_SESSION
|
11
|
+
|
12
|
+
protocol_string :driver_name, value: OrientdbBinary::NAME
|
13
|
+
protocol_string :driver_version, value: OrientdbBinary::VERSION
|
14
|
+
int16 :protocol, value: OrientdbBinary::PROTOCOL_VERSION
|
15
|
+
protocol_string :client_id
|
16
|
+
protocol_string :db
|
17
|
+
protocol_string :storage
|
18
|
+
protocol_string :user
|
19
|
+
protocol_string :password
|
20
|
+
end
|
21
|
+
|
22
|
+
class DbOpenAnswer < BinData::Record
|
23
|
+
endian :big
|
24
|
+
|
25
|
+
skip length: 4
|
26
|
+
int32 :session
|
27
|
+
int16 :num_of_clusters
|
28
|
+
array :clusters, initial_length: :num_of_clusters do
|
29
|
+
protocol_string :cluster_name
|
30
|
+
int16 :cluster_id
|
31
|
+
protocol_string :cluster_type
|
32
|
+
int16 :cluster_data_segment_id
|
33
|
+
end
|
34
|
+
int32 :cluster_config_bytes
|
35
|
+
skip length: :cluster_config_bytes, onlyif: :has_cluster_config?
|
36
|
+
protocol_string :orientdb_release
|
37
|
+
|
38
|
+
def has_cluster_config?
|
39
|
+
cluster_config_bytes > -1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
class DbRelease < BinData::Record
|
4
|
+
include OrientdbBinary::Protocols::Base
|
5
|
+
|
6
|
+
endian :big
|
7
|
+
|
8
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_RELEASE
|
9
|
+
int32 :session
|
10
|
+
|
11
|
+
protocol_string :name
|
12
|
+
protocol_string :storage
|
13
|
+
end
|
14
|
+
|
15
|
+
class DbReleaseAnswer < BinData::Record
|
16
|
+
endian :big
|
17
|
+
|
18
|
+
int32 :session
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbReload < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_RELOAD
|
10
|
+
int32 :session
|
11
|
+
end
|
12
|
+
|
13
|
+
class DbReloadAnswer < BinData::Record
|
14
|
+
endian :big
|
15
|
+
|
16
|
+
int32 :session
|
17
|
+
int16 :num_of_clusters
|
18
|
+
array :clusters, initial_length: :num_of_clusters do
|
19
|
+
protocol_string :cluster_name
|
20
|
+
int16 :cluster_id
|
21
|
+
protocol_string :cluster_type
|
22
|
+
int16 :cluster_data_segment_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class DbSize < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DB_SIZE
|
10
|
+
int32 :session
|
11
|
+
end
|
12
|
+
|
13
|
+
class DbSizeAnswer < BinData::Record
|
14
|
+
endian :big
|
15
|
+
|
16
|
+
int32 :session
|
17
|
+
int64 :db_size
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
class Errors < BinData::Record
|
4
|
+
endian :big
|
5
|
+
|
6
|
+
int32 :session
|
7
|
+
array :exceptions, read_until: -> { element[:is_error] < 1 } do
|
8
|
+
int8 :is_error
|
9
|
+
protocol_string :exception_class, onlyif: -> { is_error == 1 }
|
10
|
+
protocol_string :exception_message, onlyif: -> { is_error == 1 }
|
11
|
+
end
|
12
|
+
|
13
|
+
int32 :len
|
14
|
+
skip length: :len
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class ProtocolError < StandardError
|
19
|
+
attr_reader :session, :exception_class
|
20
|
+
|
21
|
+
def initialize(session, *exceptions)
|
22
|
+
@session
|
23
|
+
@exception_class = exceptions[0] && exceptions[0][:exception_class]
|
24
|
+
|
25
|
+
super exceptions.map { |exp| [ exp[:exception_class], exp[:exception_message] ].reject { |s| s.nil? }.join(': ') }.join("\n")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class RecordCreate < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_RECORD_CREATE
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
int32 :datasegment_id
|
13
|
+
int16 :cluster_id
|
14
|
+
protocol_string :record_content
|
15
|
+
int8 :record_type
|
16
|
+
int8 :mode
|
17
|
+
end
|
18
|
+
|
19
|
+
class RecordCreateAnswer < BinData::Record
|
20
|
+
endian :big
|
21
|
+
|
22
|
+
int32 :session
|
23
|
+
int64 :cluster_position
|
24
|
+
int32 :record_version
|
25
|
+
|
26
|
+
def process(options)
|
27
|
+
return {
|
28
|
+
:@rid => "##{options[:cluster_id]}:#{cluster_position}",
|
29
|
+
:@version => record_version,
|
30
|
+
:@type => options[:record_type]
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module OrientdbBinary
|
2
|
+
module Protocols
|
3
|
+
|
4
|
+
class RecordDelete < BinData::Record
|
5
|
+
include OrientdbBinary::Protocols::Base
|
6
|
+
|
7
|
+
endian :big
|
8
|
+
|
9
|
+
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_RECORD_DELETE
|
10
|
+
int32 :session
|
11
|
+
|
12
|
+
int16 :cluster_id
|
13
|
+
int64 :cluster_position
|
14
|
+
int32 :record_version
|
15
|
+
int8 :mode
|
16
|
+
end
|
17
|
+
|
18
|
+
class RecordDeleteAnswer < BinData::Record
|
19
|
+
endian :big
|
20
|
+
|
21
|
+
int32 :session
|
22
|
+
int8 :payload_status
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|