Java Code Examples for org.apache.tinkerpop.gremlin.structure.Vertex#DEFAULT_LABEL
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.Vertex#DEFAULT_LABEL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VertexWriter.java From hgraphdb with Apache License 2.0 | 6 votes |
@Override public Iterator<Put> constructInsertions() { final String label = vertex.label() != null ? vertex.label() : Vertex.DEFAULT_LABEL; Put put = new Put(ValueUtils.serializeWithSalt(vertex.id())); put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.LABEL_BYTES, ValueUtils.serialize(label)); put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES, ValueUtils.serialize(((HBaseVertex) vertex).createdAt())); put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.UPDATED_AT_BYTES, ValueUtils.serialize(((HBaseVertex) vertex).updatedAt())); ((HBaseVertex) vertex).getProperties().forEach((key, value) -> { byte[] bytes = ValueUtils.serializePropertyValue(graph, ElementType.VERTEX, label, key, value); put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Bytes.toBytes(key), bytes); }); return IteratorUtils.of(put); }
Example 2
Source File: ReferenceElement.java From tinkerpop with Apache License 2.0 | 6 votes |
public ReferenceElement(final Element element) { this.id = element.id(); try { //Exception creation takes too much time, return default values for known types if (element instanceof ComputerGraph.ComputerAdjacentVertex) { this.label = Vertex.DEFAULT_LABEL; } else { this.label = element.label(); } } catch (final UnsupportedOperationException e) { if (element instanceof Vertex) this.label = Vertex.DEFAULT_LABEL; else if (element instanceof Edge) this.label = Edge.DEFAULT_LABEL; else this.label = VertexProperty.DEFAULT_LABEL; } }
Example 3
Source File: GryoMapperTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test public void shouldSerializeDeserialize() throws Exception { final GryoMapper mapper = builder.get().create(); final Kryo kryo = mapper.createMapper(); try (final OutputStream stream = new ByteArrayOutputStream()) { final Output out = new Output(stream); final Map<String,Object> props = new HashMap<>(); final List<Map<String, Object>> propertyNames = new ArrayList<>(1); final Map<String,Object> propertyName = new HashMap<>(); propertyName.put(GraphSONTokens.ID, "x"); propertyName.put(GraphSONTokens.KEY, "x"); propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work"); propertyNames.add(propertyName); props.put("x", propertyNames); final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props); kryo.writeClassAndObject(out, v); try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) { final Input input = new Input(inputStream); final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input); assertEquals("no-way-this-will-ever-work", readX.value("x")); } } }
Example 4
Source File: IoXIoRegistry.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public void write(final Kryo kryo, final Output output, final IoX iox) { final Map<String,Object> props = new HashMap<>(); addSingleProperty("x", iox.toString(), props); final DetachedVertex vertex = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props); try (final OutputStream stream = new ByteArrayOutputStream()) { final Output detachedOutput = new Output(stream); kryo.writeObject(detachedOutput, vertex); // have to remove the first byte because it marks a reference we don't want to have as this // serializer is trying to "act" like a DetachedVertex final byte[] b = detachedOutput.toBytes(); output.write(b, 1, b.length - 1); } catch (Exception ex) { ex.printStackTrace(); } }
Example 5
Source File: DetachedElement.java From tinkerpop with Apache License 2.0 | 5 votes |
protected DetachedElement(final Element element) { this.id = element.id(); try { this.label = element.label(); } catch (final UnsupportedOperationException e) { // ghetto. this.label = Vertex.DEFAULT_LABEL; } }
Example 6
Source File: BitsyVertex.java From bitsy with Apache License 2.0 | 4 votes |
@Override public String label() { String result = super.label(); return (result == null) ? Vertex.DEFAULT_LABEL : result; }