OrientDB系列:(一)初步使用及相关概念

1 初步使用

1.1 安装

  • 目前OrientDB的最新版本为3.x,可通过官网下载

python通过pyorient包与OrientDB连接时,需要OrientDB版本为2.x下载地址。其中,2.2.x版本中仅有2.2.35可下载。

  • 将下载的文件解压,运行./bin/server.bat来启动服务。
    • 初次运行时,会提示设置初始数据库demo的密码。
  • 之后可运行./bin/console.bat来启动客户端。
    • 通过命令CREATE DATABASE <engine>:<db-name>来新建数据库。
      • 其中,<engine>的内容如表1。
    • 通过命令IMPORT DATABASE ./demo.gz,将数据导入到数据库中。
    • 通过命令connect remote:/localhost:2424/dbName userName passWord连接数据库。
表1 OrientDB的Engine类型
EngineDescriptionExample
plocal将数据存储到文件中,同时会将对数据库的改动保存在log中,可以用来恢复数据。plocal:/temp/databases/petshop/petshop
memory在内存中打开数据库。memory:petshop
remote在OrientDB服务启动并且运行后,可以通过远程网络连接打开数据库。多个客户端可以共享该数据库。命令:remote:<server>:[<port>]/db-name。端口默认设置为2424.remote:localhost/petshop

1.2 与Python交互

交互方式可以参考w3cschool悦仔子_一心等啊等_SJ。示例代码如下:

from pyorient.ogm import Config, Graph
# 配置连接数据
config = Config.from_url('/localhost/bomc', "username", "pwd")
# 建立连接
g = Graph(config, "username", "pwd")
# 发送查询命令(SQL)
result = g.client.command("select from V")
# 发送查询命令(Gremlin)
result = g.client.gremlin("g.V().has('app_name', 'ArchErVal')")

2 概念

2.1 OrientDB导出的JSON数据格式

OrientDB导出的JSON文件包含四个部分,为Info Section, Clusters Section, Schema SectionRecords Section

2.1.1 Info Section

示例
"info": { 
    "name": "demo", 
    "default-cluster-id": 2, 
    "exporter-format": 2, 
    "engine-version": "1.7-SNAPSHOT", 
    "storage-config-version": 2, 
    "schema-version": 4, 
    "mvrbtree-version": 0 
} 
说明
ParameterDescriptionJSON Type
"name"Defines the name of the database.String
"default-cluster-id"Defines the Cluster ID to use by default. Range: 0-32,762.Integer
"exporter-format"Defines the version of the database exporter.Integer
"engine-version"Defines the version of OrientDB.String
"storage-version"Defines the version of the Storage layer.Integer
"schema-version"Defines the version of the schema exporter.Integer
"mvrbtree-version"Defines the version of the MVRB-Tree.Integer

2.1.2 Clusters Section

示例
"clusters": [
  {"name": "internal", "id": 0, "type": "PHYSICAL"},
  {"name": "index", "id": 1, "type": "PHYSICAL"},
  {"name": "default", "id": 2, "type": "PHYSICAL"}
]
说明
ParameterDescriptionJSON Type
"name"Defines the logical name of the cluster.String
"id"Defines the Cluster ID. Range: 0-32, 767.Integer
"type"Defines the cluster type: PHYSICAL, LOGICAL and MEMORY.String

2.1.3 Schema Section

示例
"schema":{
  "version": 210,
  "classes": [
    {"name": "Account", "default-cluster-id": 9, "cluster-ids": [9],
      "properties": [
        {"name": "binary", "type": "BINARY", "mandatory": false, "not-null": false},
        {"name": "birthDate", "type": "DATE", "mandatory": false, "not-null": false},
        {"name": "id", "type": "INTEGER", "mandatory": false, "not-null": false}
      ]
    }
  ]
}
说明
ParameterDescriptionJSON Type
"version"Defines the version of the record storing the schema. Range: 0-2,147,483,647.Integer
"classes"Defines a list of entries for each class in the schema.Array
Parameters for the Classes Subsection:
ParameterDescriptionJSON Type
"name"Defines the logical name of the class.String
"default-cluster-id"Defines the default Cluster ID for the class. It represents the cluster that stores the class records.Integer
"cluster-ids"Defines an array of Cluster ID’s that store the class records. The first ID is always the default Cluster ID.Array of Integers
"properties"Defines a list of entries for each property for the class in the schema.Array
Parameters for the Properties Sub-subsection:
ParameterDescriptionJSON Type
"name"Defines the logical name of the property.String
"type"Defines the property type.String
"mandatory"Defines whether the property is mandatory.Boolean
"not-null"Defines whether the property accepts a NULL value.Boolean

2.1.4 Records Section

示例
"records": [
   {"@type": "d", "@rid": "#12:476", "@version": 0, "@class": "Account",
    "account_id": 476,
    "date": "2011-12-09 00:00:00:0000",
    "@fieldTypes": ["account_id=i", "date=t"]
   },
   {"@type": "d", "@rid": "#12:477", "@version": 0,    "@class": "Whiz",
    "id": 477,
    "date": "2011-12-09 00:00:00:000",
    "text": "He in office return He inside electronics for $500,000 Jay",
    "@fieldTypes": "date=t"
   }
]
说明
Parameters for Metadata:
ParameterDescriptionJSON Type
"@type"Defines the record-type: d for Document, b for Binary.String
"@rid"Defines the Record ID, using the format: <cluster-id>:<cluster-position>.String
"@version"Defines the record version. Range: 0-2, 147, 483, 647.Integer
"@class"Defines the logical class name for the record.String
"@fieldTypes"Defines an array of the types for each field in this record.Any
Supported Field Types
ValueType
lLong
fFloat
dDouble
sShort
tDatetime
dDate
cDecimal
bByte
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
指纹增强-指纹增强.rar 有一位论坛朋友寻找的关于一篇经典指纹增强文章的源代码: 帖子如下(含文章): https://www.ilovematlab.cn/thread-74316-1-1.html 这个源程序的一个实例:介绍一下怎么应用 clear clc im = imread; if length)>2     im=rgb2gray; end         % Identify ridge-like regions and normalise image     blksze = 16; thresh = 0.1;     [normim, mask] = ridgesegment;     show;     % Determine ridge orientations     [orientim, reliability] = ridgeorient;     plotridgeorient     show 1.jpg 2.jpg 3.jpg                            原图                                                                    Orientations overlaid                                        'Reliability' of orientations                                   % Determine ridge frequency values across the image     blksze = 36;     [freq, medfreq] = ridgefreq;     show                                 Frequency data          % Actually I find the median frequency value used across the whole    % fingerprint gives a more satisfactory result...       freq = medfreq.*mask;         % Now apply filters to enhance the ridge pattern    newim = ridgefilter;    show;                                 Filtered image             % Binarise, ridge/valley threshold is 0    binim = newim > 0;    show;                                 Binary image         % Display binary image for where the mask values are one and where    % the orientation reliability is greater than 0.5    show, 7)                                 Masked binary image                                 Original image 程序包如下: 指纹增强.rar 程序包含: QQ截图未命名.jpg

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值