/** * Create from options and configuration * * @param <T> enum type * @param options pre user graph type options * @param conf configuration * @return new object */ public static <T extends Enum<T>> PerGraphTypeEnum<T> readFromConf( PerGraphTypeEnumConfOption<T> options, Configuration conf) { PerGraphTypeEnum<T> pgte = new PerGraphTypeEnum<T>(); pgte.setFrom(options, conf); return pgte; }
/** * Set data from per user graph type set of options * * @param options per user graph type options * @param conf Configuration */ public void setFrom(PerGraphTypeEnumConfOption<T> options, Configuration conf) { setVertexId(options.getVertexId(), conf); setVertexValue(options.getVertexValue(), conf); setEdgeValue(options.getEdgeValue(), conf); setOutgoingMessage(options.getOutgoingMessage(), conf); }
/** * Wrap a user value (IVEMM) in a {@link Writable} wrapper if necessary * * @param object data to wrap * @param graphType type of data (IVEMM) * @param <W> writable type * @return writable value */ public <W extends Writable> W wrapIfNecessary(Object object, GraphType graphType) { if (graphType.interfaceClass().isInstance(object)) { return (W) object; } if (getConf().getValueLanguages().get(graphType) == Language.JYTHON && getConf().getValueNeedsWrappers().get(graphType)) { Preconditions.checkArgument(object instanceof PyObject); return (W) new JythonWritableWrapper((PyObject) object); } else { return (W) object; } } }
/** * Constructor. Takes the configuration and then gets the classes out of * them for Giraph * * @param conf Configuration */ public ImmutableClassesGiraphConfiguration(Configuration conf) { super(conf); classes = new GiraphClasses<I, V, E>(conf); useUnsafeSerialization = USE_UNSAFE_SERIALIZATION.get(this); useBigDataIOForMessages = USE_BIG_DATA_IO_FOR_MESSAGES.get(this); valueLanguages = PerGraphTypeEnum.readFromConf( GiraphConstants.GRAPH_TYPE_LANGUAGES, conf); valueNeedsWrappers = PerGraphTypeBoolean.readFromConf( GiraphConstants.GRAPH_TYPES_NEEDS_WRAPPERS, conf); isStaticGraph = GiraphConstants.STATIC_GRAPH.get(this); valueFactories = new ValueFactories<I, V, E>(this); }