本文整理了Java中org.apache.tinkerpop.gremlin.structure.Element.id()
方法的一些代码示例,展示了Element.id()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.id()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Element
类名称:Element
方法名:id
[英]Gets the unique identifier for the graph Element.
[中]获取图形元素的唯一标识符。
代码示例来源:origin: thinkaurelius/titan
public static long getCompareId(Element element) {
Object id = element.id();
if (id instanceof Long) return (Long)id;
else if (id instanceof RelationIdentifier) return ((RelationIdentifier)id).getRelationId();
else throw new IllegalArgumentException("Element identifier has unrecognized type: " + id);
}
代码示例来源:origin: JanusGraph/janusgraph
public static long getCompareId(Element element) {
Object id = element.id();
if (id instanceof Long) return (Long)id;
else if (id instanceof RelationIdentifier) return ((RelationIdentifier)id).getRelationId();
else throw new IllegalArgumentException("Element identifier has unrecognized type: " + id);
}
代码示例来源:origin: thinkaurelius/titan
@Override
public boolean equals(Object other) {
if (other==null)
return false;
if (this==other)
return true;
if (!((this instanceof Vertex && other instanceof Vertex) ||
(this instanceof Edge && other instanceof Edge) ||
(this instanceof VertexProperty && other instanceof VertexProperty)))
return false;
//Same type => they are the same if they have identical ids.
if (other instanceof AbstractElement) {
return getCompareId()==((AbstractElement)other).getCompareId();
} else if (other instanceof TitanElement) {
return ((TitanElement) other).hasId() && getCompareId()==((TitanElement)other).longId();
} else if (other instanceof Element) {
Object otherId = ((Element)other).id();
if (otherId instanceof RelationIdentifier) return ((RelationIdentifier) otherId).getRelationId()==getCompareId();
else return otherId.equals(getCompareId());
} else return false;
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public boolean equals(Object other) {
if (other==null)
return false;
if (this==other)
return true;
if (!((this instanceof Vertex && other instanceof Vertex) ||
(this instanceof Edge && other instanceof Edge) ||
(this instanceof VertexProperty && other instanceof VertexProperty)))
return false;
//Same type => they are the same if they have identical ids.
if (other instanceof AbstractElement) {
return getCompareId()==((AbstractElement)other).getCompareId();
} else if (other instanceof JanusGraphElement) {
return ((JanusGraphElement) other).hasId() && getCompareId()==((JanusGraphElement)other).longId();
} else {
Object otherId = ((Element)other).id();
if (otherId instanceof RelationIdentifier) return ((RelationIdentifier) otherId).getRelationId()==getCompareId();
else return otherId.equals(getCompareId());
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public Object apply(final Element element) {
return element.id();
}
},
代码示例来源:origin: apache/tinkerpop
public void convertElementsToIds() {
for (int i = 0; i < this.ids.length; i++) { // if this is going to OLAP, convert to ids so you don't serialize elements
if (this.ids[i] instanceof Element)
this.ids[i] = ((Element) this.ids[i]).id();
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public Object id() {
return this.baseElement.id();
}
代码示例来源:origin: apache/tinkerpop
@Override
public Object id() {
return this.element.id();
}
代码示例来源:origin: apache/tinkerpop
/**
* Simply tests if the value returned from {@link org.apache.tinkerpop.gremlin.structure.Element#id()} are {@code equal()}.
*
* @param a the first {@link org.apache.tinkerpop.gremlin.structure.Element}
* @param b the second {@link org.apache.tinkerpop.gremlin.structure.Element}
* @return true if ids are equal and false otherwise
*/
public static boolean haveEqualIds(final Element a, final Element b) {
return a.id().equals(b.id());
}
代码示例来源:origin: thinkaurelius/titan
elementIds[i] = ((Element) ids[i]).id();
代码示例来源:origin: apache/tinkerpop
/**
* If two {@link Element} instances are equal, then they must have the same hash codes. This methods ensures consistent hashCode values.
*
* @param element the element to get the hashCode for
* @return the hash code of the element
*/
public static int hashCode(final Element element) {
return element.id().hashCode();
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal))
return;
TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(originalGraphStep -> {
if (originalGraphStep.getIds() == null || originalGraphStep.getIds().length == 0) {
//Try to optimize for index calls
final JanusGraphStep<?, ?> janusGraphStep = new JanusGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, janusGraphStep, traversal);
HasStepFolder.foldInIds(janusGraphStep, traversal);
HasStepFolder.foldInHasContainer(janusGraphStep, traversal, traversal);
HasStepFolder.foldInOrder(janusGraphStep, janusGraphStep.getNextStep(), traversal, traversal, janusGraphStep.returnsVertex(), null);
HasStepFolder.foldInRange(janusGraphStep, JanusGraphTraversalUtil.getNextNonIdentityStep(janusGraphStep), traversal, null);
} else {
//Make sure that any provided "start" elements are instantiated in the current transaction
final Object[] ids = originalGraphStep.getIds();
ElementUtils.verifyArgsMustBeEitherIdOrElement(ids);
if (ids[0] instanceof Element) {
//GraphStep constructor ensures that the entire array is elements
final Object[] elementIds = new Object[ids.length];
for (int i = 0; i < ids.length; i++) {
elementIds[i] = ((Element) ids[i]).id();
}
originalGraphStep.setIteratorSupplier(() -> originalGraphStep.returnsVertex() ?
((Graph) originalGraphStep.getTraversal().getGraph().get()).vertices(elementIds) :
((Graph) originalGraphStep.getTraversal().getGraph().get()).edges(elementIds));
}
}
});
}
代码示例来源:origin: apache/tinkerpop
protected DetachedElement(final Element element) {
this.id = element.id();
try {
this.label = element.label();
} catch (final UnsupportedOperationException e) { // ghetto.
this.label = Vertex.DEFAULT_LABEL;
}
}
代码示例来源:origin: apache/tinkerpop
@Override
protected Object map(final Traverser.Admin<S> traverser) {
return traverser.get().id();
}
代码示例来源:origin: apache/tinkerpop
protected boolean testIdAsString(Element element) {
return this.predicate.test(element.id().toString());
}
代码示例来源:origin: apache/tinkerpop
private void ser(final Object o, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider) throws IOException {
if (Element.class.isAssignableFrom(o.getClass()))
jsonGenerator.writeFieldName((((Element) o).id()).toString());
else
super.serialize(o, jsonGenerator, serializerProvider);
}
}
代码示例来源:origin: apache/tinkerpop
private void ser(final Object o, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider) throws IOException {
if (Element.class.isAssignableFrom(o.getClass()))
jsonGenerator.writeFieldName((((Element) o).id()).toString());
else
super.serialize(o, jsonGenerator, serializerProvider);
}
}
代码示例来源:origin: apache/tinkerpop
private void ser(final Object o, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider) throws IOException {
if (Element.class.isAssignableFrom(o.getClass()))
jsonGenerator.writeFieldName((((Element) o).id()).toString());
else
super.serialize(o, jsonGenerator, serializerProvider);
}
}
代码示例来源:origin: hugegraph/hugegraph
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Element)) {
return false;
}
Element other = (Element) obj;
if (this.id() == null) {
return false;
}
return this.id().equals(other.id());
}
代码示例来源:origin: apache/tinkerpop
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Property property) {
output.writeString(property.key());
kryo.writeClassAndObject(output, property.value());
kryo.writeClassAndObject(output, property.element().id());
output.writeString(property.element().label());
}
内容来源于网络,如有侵权,请联系作者删除!