@Nullable @Override public Long apply(@Nullable PropertyKey propertyKey) { return propertyKey.longId(); } }));
private static String keyID2Name(PropertyKey key) { return longID2Name(key.longId()); }
private static long[] checkSignature(List<PropertyKey> sig) { Preconditions.checkArgument(sig.size() == (Sets.newHashSet(sig)).size(), "Signature and sort key cannot contain duplicate types"); long[] signature = new long[sig.size()]; for (int i = 0; i < sig.size(); i++) { PropertyKey key = sig.get(i); Preconditions.checkNotNull(key); Preconditions.checkArgument(!((PropertyKey) key).dataType().equals(Object.class), "Signature and sort keys must have a proper declared datatype: %s", key.name()); signature[i] = key.longId(); } return signature; }
@Override public <O> O getValueDirect(PropertyKey key) { return getPropertyMap().get(key.longId()); }
@Override public <O> O getValueDirect(PropertyKey key) { return getPropertyMap().get(key.longId()); }
public PropertyKeyDefinition(PropertyKey key) { this(key.name(),key.longId(),key.cardinality(),key.dataType()); }
private void writeInline(DataOutput out, PropertyKey inlineKey, Object value, InlineType inlineType) { assert inlineType.writeInlineKey() || !AttributeUtil.hasGenericDataType(inlineKey); if (inlineType.writeInlineKey()) { IDHandler.writeInlineRelationType(out, inlineKey.longId()); } writePropertyValue(out,inlineKey,value, inlineType); }
Object propertyValue = readInline(in, type, InlineType.NORMAL); assert propertyValue != null; properties.put(type.longId(), propertyValue);
/** * Very simple graph operation to ensure minimal functionality and cleanup */ @Test public void testBasic() throws BackendException { PropertyKey uid = makeVertexIndexedUniqueKey("name", String.class); finishSchema(); JanusGraphVertex n1 = tx.addVertex(); uid = tx.getPropertyKey("name"); n1.property(uid.name(), "abcd"); clopen(); long nid = n1.longId(); uid = tx.getPropertyKey("name"); assertTrue(getV(tx, nid) != null); assertTrue(getV(tx, uid.longId()) != null); assertMissing(tx, nid + 64); uid = tx.getPropertyKey(uid.name()); n1 = getV(tx, nid); assertEquals(n1, getOnlyVertex(tx.query().has(uid.name(), "abcd"))); assertEquals(1, Iterables.size(n1.query().relations())); //TODO: how to expose relations? assertEquals("abcd", n1.value(uid.name())); assertCount(1, tx.query().vertices()); close(); JanusGraphFactory.drop(graph); open(config); assertEmpty(tx.query().vertices()); }
assert propertyKey.longId() == sortKeyIDs[i];
sig = ((InternalRelationType) value).getSignature(); assertEquals(1, sig.length); assertEquals(weight.longId(), sig[0]); assertTrue(mgmt.getGraphIndex(uid.name()).isUnique()); assertFalse(mgmt.getGraphIndex(someId.name()).isUnique()); sig = ((InternalRelationType) connect).getSignature(); assertEquals(1, sig.length); assertEquals(uid.longId(), sig[0]); assertEquals(0, ((InternalRelationType) friend).getSortKey().length); assertEquals(Order.DEFAULT, ((InternalRelationType) friend).getSortOrder()); sig = ((InternalRelationType) value).getSignature(); assertEquals(1, sig.length); assertEquals(weight.longId(), sig[0]); assertTrue(mgmt.getGraphIndex(uid.name()).isUnique()); assertFalse(mgmt.getGraphIndex(someId.name()).isUnique()); sig = ((InternalRelationType) connect).getSignature(); assertEquals(1, sig.length); assertEquals(uid.longId(), sig[0]); assertEquals(0, ((InternalRelationType) friend).getSortKey().length); assertEquals(Order.DEFAULT, ((InternalRelationType) friend).getSortOrder());