attribInfo.put("dataType", attributeDef.getTypeName()); attribInfo.put("isUnique", attributeDef.getIsUnique()); attribInfo.put("isIndexable", attributeDef.getIsIndexable()); attribInfo.put("includeInNotification", attributeDef.getIncludeInNotification()); attribInfo.put("isComposite", attribute.isOwnedRef());
private Object mapPrimitiveValue(AttributeMutationContext ctx) { boolean isIndexableStrAttr = ctx.getAttributeDef().getIsIndexable() && ctx.getAttrType() instanceof AtlasBuiltInTypes.AtlasStringType;
attribInfo.put("dataType", attributeDef.getTypeName()); attribInfo.put("isUnique", attributeDef.getIsUnique()); attribInfo.put("isIndexable", attributeDef.getIsIndexable()); attribInfo.put("includeInNotification", attributeDef.getIncludeInNotification()); attribInfo.put("isComposite", attribute.isOwnedRef());
assertTrue(createdTypesDef.getClassificationDefs().get(0).getAttributeDefs().get(0).getIsIndexable()); assertTrue(getBackFromCache.getAttributeDefs().get(0).getIsIndexable()); assertEquals(guid, getBackFromCache.getGuid()); assertNotNull(getBackFromCache.getCreatedBy()); AtlasTypesDef updatedTypesDef = typeDefStore.updateTypesDef(testTypesDefFromJson); assertEquals("test_classification_11", updatedTypesDef.getClassificationDefs().get(0).getName()); assertFalse(updatedTypesDef.getClassificationDefs().get(0).getAttributeDefs().get(0).getIsIndexable()); assertEquals(guid, updatedTypesDef.getClassificationDefs().get(0).getGuid()); assertEquals(createdTime, updatedTypesDef.getClassificationDefs().get(0).getCreateTime()); assertFalse(getBackFromCache.getAttributeDefs().get(0).getIsIndexable()); assertEquals(guid, getBackFromCache.getGuid()); assertEquals(createdTime, getBackFromCache.getCreateTime()); getBackFromCache = typeDefStore.getClassificationDefByGuid(guid); assertEquals("test_classification_11", getBackFromCache.getName()); assertFalse(getBackFromCache.getAttributeDefs().get(0).getIsIndexable()); assertEquals(guid, getBackFromCache.getGuid()); assertEquals(createdTime, getBackFromCache.getCreateTime());
AtlasCardinality cardinality = toAtlasCardinality(attributeDef.getCardinality()); boolean isUnique = attributeDef.getIsUnique(); boolean isIndexable = attributeDef.getIsIndexable(); String attribTypeName = attributeDef.getTypeName(); boolean isBuiltInType = AtlasTypeUtil.isBuiltInType(attribTypeName);
private void createIndexForAttribute(AtlasGraphManagement management, String typeName, AttributeInfo field) { final String propertyName = GraphHelper.encodePropertyKey(typeName + "." + field.name); switch (field.dataType().getTypeCategory()) { case PRIMITIVE: AtlasCardinality cardinality = getCardinality(field.multiplicity); createIndexes(management, propertyName, getPrimitiveClass(field.dataType()), field.isUnique, cardinality, false, field.isIndexable); break; case ENUM: cardinality = getCardinality(field.multiplicity); createIndexes(management, propertyName, String.class, field.isUnique, cardinality, false, field.isIndexable); break; case ARRAY: case MAP: // todo - how do we overcome this limitation? // IGNORE: Can only index single-valued property keys on vertices in Mixed Index break; case STRUCT: StructType structType = (StructType) field.dataType(); createIndexForFields(management, structType, structType.fieldMapping().fields); break; case TRAIT: // do nothing since this is NOT contained in other types break; case CLASS:
ret.setDataTypeName(attributeDef.getTypeName()); ret.setIsUnique(attributeDef.getIsUnique()); ret.setIsIndexable(attributeDef.getIsIndexable()); ret.setIsComposite(attribute.isOwnedRef()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName());
private Object mapPrimitiveValue(AttributeMutationContext ctx) { boolean isIndexableStrAttr = ctx.getAttributeDef().getIsIndexable() && ctx.getAttrType() instanceof AtlasBuiltInTypes.AtlasStringType; Object ret = ctx.getValue(); // Janus bug, when an indexed string attribute has a value longer than a certain length then the reverse indexed key generated by JanusGraph // exceeds the HBase row length's hard limit (Short.MAX). This trimming and hashing procedure is to circumvent that limitation if (ret != null && isIndexableStrAttr) { String value = (String) ctx.getValue(); if (value.length() > INDEXED_STR_MAX_ALLOWED_LEN) { LOG.warn("Indexed-String-Attribute: {} exceeds {} characters, trimming and appending checksum", ctx.getAttribute().getQualifiedName(), INDEXED_STR_MAX_ALLOWED_LEN); String sha256Hex = DigestUtils.shaHex(value); // Storing SHA checksum in case verification is needed after retrieval ret = value.substring(0, (INDEXED_STR_MAX_ALLOWED_LEN - 1) - sha256Hex.length()) + ":" + sha256Hex; } } AtlasGraphUtilsV2.setEncodedProperty(ctx.getReferringVertex(), ctx.getVertexProperty(), ret); return ret; }
public AtlasAttributeDef(AtlasAttributeDef other) { if (other != null) { setName(other.getName()); setTypeName(other.getTypeName()); setIsOptional(other.getIsOptional()); setCardinality(other.getCardinality()); setValuesMinCount(other.getValuesMinCount()); setValuesMaxCount(other.getValuesMaxCount()); setIsUnique(other.getIsUnique()); setIsIndexable(other.getIsIndexable()); setIncludeInNotification(other.getIncludeInNotification()); setDefaultValue(other.getDefaultValue()); setConstraints(other.getConstraints()); setDescription((other.getDescription())); } }
public AtlasAttributeDef(AtlasAttributeDef other) { if (other != null) { setName(other.getName()); setTypeName(other.getTypeName()); setIsOptional(other.getIsOptional()); setCardinality(other.getCardinality()); setValuesMinCount(other.getValuesMinCount()); setValuesMaxCount(other.getValuesMaxCount()); setIsUnique(other.getIsUnique()); setIsIndexable(other.getIsIndexable()); setDefaultValue(other.getDefaultValue()); setConstraints(other.getConstraints()); } }
public static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) { final AtlasAttributeDef attrDef = attribute.getAttributeDef(); AttributeDefinition ret = new AttributeDefinition(); ret.setName(attrDef.getName()); ret.setDataTypeName(attrDef.getTypeName()); ret.setMultiplicity(getMultiplicity(attrDef)); ret.setIsComposite(attribute.isOwnedRef()); ret.setIsUnique(attrDef.getIsUnique()); ret.setIsIndexable(attrDef.getIsIndexable()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDescription(attrDef.getDescription()); ret.setDefaultValue(attrDef.getDefaultValue()); return ret; } }
public static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) { final AtlasAttributeDef attrDef = attribute.getAttributeDef(); AttributeDefinition ret = new AttributeDefinition(); ret.setName(attrDef.getName()); ret.setDataTypeName(attrDef.getTypeName()); ret.setMultiplicity(AtlasTypeUtil.getMultiplicity(attrDef)); ret.setIsComposite(attribute.isOwnedRef()); ret.setIsUnique(attrDef.getIsUnique()); ret.setIsIndexable(attrDef.getIsIndexable()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDescription(attrDef.getDescription()); ret.setDefaultValue(attrDef.getDefaultValue()); return ret; } }