顶点属性值可以是基本的数据类型,如字符型或者整型,但也是它也可以是一些更复杂的东西,比如包含了多个值的集合或者列表。您可以把这些值看成是一个数组,但是这取决您怎么创建它们,您可以对它们进行不同的处理。在这个例子中我们将看一下怎么为一个属性的键创建多个值。这些值是可以设置的,在一开始创建的时候或者是在后边增加的。这些更加复杂的属性值的类型在边上是不支持的。
A vertex property value can be a basic type such as a String or an Integer but it can also be
something more sophisticated such as a Set or a List containing multiple values. You can think of
these values as being an array but depending on how you create them you have to work with them
differently. In this section we will look at how we can create multiple values for a single property
key. Such values can be setup when the vertex is first created or added afterwards. These more
complex type of property values are not supported on edges.
如果我们想要为AUS机场顶点在一个列表中存储IATA和ICAO代码,这个列表是与单个属性相关的,而不是每个都有一个单独的属性。我们可以在下面创建AUS顶点的时候就创建它们。您也可以向一个已经存在的顶点增加属性,这个属性的值是列表。在这一节的我们可以看到如何处理。
If we wanted to store the IATA and ICAO codes for the Austin airport in a list associated with a
single property rather than as separate properties we could have created them when we created
the Austin vertex follows. You can also add properties to an existing vertex that have lists of values.
We will look at how to do that later in this section.
 

 

像g.addV('code,AUS,code,KAUS)'这样指定一些东西的addV的使用方式现在已经淘汰了,不可以再用了。

The version of addV that allowed you to specify something like g.addV('code,AUS
,code,KAUS)' is now deprecated and should not be used.
这种方式创建的code属性,它的基类型现在是LIST而不是SINGLE。在廷克图上工作时,我们不需要为属性类型配置显式格式。然而如果我们是在一些更复杂的图系统如杰森图上工作时,有一些事我们将要想到,而且须要这么做。在本书后边的“杰森图管理API”这一节中我们会更深入的探讨cardinality的问题。现在我们已经创建了具有list值的code属性。我们可以查询列表中的一个值。在下面的例子中如果我们查看valueMap,您可以看到列表中的值,也可以看到属性code
By creating the code property in this way, its cardinality type is now effectively LIST rather than
SINGLE. While working with TinkerGraph we do not need to setup explicit schemas for our
property types. However, once we start working with a more sophisticated graph system such as
JanusGraph, that is something that we will both want and need to be able to do. We cover the topic
of cardinality in detail in the "The JanusGraph management API" section later in the book.
Now that we have created the code property to have a list of values we can query either one of the
values in the list. If we look at the value map we get back from the following example queries you
can see both values in the list we associated with the property code.
 
我们也和平时一样可以查看属性的值。
we can also query the values as normal.
 

 

我们也可以用properties步骤来得到顶点属性返回结果。在“属性和顶点属性接口”这一节中我们会深入的研究顶点属性。

We can also use the properties step to get the result back as vertex properties (vp). We discuss
vertex properties in detail in the "The Property and VertexProperty interfaces" section.
 

 

出于完整性,我们也可以这么做。

For completeness we could also do this.

 

 

posted on 2022-04-22 16:39  bokeyuannicheng0000  阅读(58)  评论(0)    收藏  举报