public<V> V findParameter(Parameter[] parameters, V defaultValue) { V result = null; for (Parameter p : parameters) { if (p.key().equalsIgnoreCase(name)) { Object value = p.value(); Preconditions.checkArgument(value!=null,"Invalid mapping specified: %s",value); Preconditions.checkArgument(result==null,"Multiple mappings specified"); result = (V)value; } } if (result==null) return defaultValue; return result; }
@Override public void write(WriteBuffer buffer, Parameter attribute) { DataOutput out = (DataOutput)buffer; out.writeObjectNotNull(attribute.key()); out.writeClassAndObject(attribute.value()); }
private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (TitanEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) { if (!keys.contains(edge.vertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc); assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[]) desc.getModifier(); assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length - 1].value().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length); paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }
public<V> V findParameter(Parameter[] parameters, V defaultValue) { V result = null; for (Parameter p : parameters) { if (p.key().equalsIgnoreCase(name)) { Object value = p.value(); Preconditions.checkArgument(value!=null,"Invalid mapping specified: %s",value); Preconditions.checkArgument(result==null,"Multiple mappings specified"); result = (V)value; } } if (result==null) return defaultValue; return result; }
@Override public void write(WriteBuffer buffer, Parameter attribute) { DataOutput out = (DataOutput)buffer; out.writeObjectNotNull(attribute.key()); out.writeClassAndObject(attribute.value()); }
private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (TitanEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) { if (!keys.contains(edge.vertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc); assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[]) desc.getModifier(); assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length - 1].value().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length); paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }