Search in sources :

Example 36 with HugeException

use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.

the class AnalyzerFactory method register.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void register(String name, String classPath) {
    ClassLoader classLoader = SerializerFactory.class.getClassLoader();
    Class<?> clazz;
    try {
        clazz = classLoader.loadClass(classPath);
    } catch (Exception e) {
        throw new HugeException("Load class path '%s' failed", e, classPath);
    }
    // Check subclass
    if (!Analyzer.class.isAssignableFrom(clazz)) {
        throw new HugeException("Class '%s' is not a subclass of " + "class Analyzer", classPath);
    }
    // Check exists
    if (analyzers.containsKey(name)) {
        throw new HugeException("Exists analyzer: %s(%s)", name, analyzers.get(name).getName());
    }
    // Register class
    analyzers.put(name, (Class) clazz);
}
Also used : HugeException(com.baidu.hugegraph.HugeException) HugeException(com.baidu.hugegraph.HugeException)

Example 37 with HugeException

use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.

the class JcsegAnalyzer method segment.

@Override
public Set<String> segment(String text) {
    Set<String> result = InsertionOrderUtil.newSet();
    try {
        Object[] args = new Object[] { new StringReader(text), CONFIG, DIC };
        ISegment seg = SegmentFactory.createJcseg(this.segMode, args);
        IWord word = null;
        while ((word = seg.next()) != null) {
            result.add(word.getValue());
        }
    } catch (Exception e) {
        throw new HugeException("Jcseg segment text '%s' failed", e, text);
    }
    return result;
}
Also used : StringReader(java.io.StringReader) ISegment(org.lionsoul.jcseg.tokenizer.core.ISegment) HugeException(com.baidu.hugegraph.HugeException) IWord(org.lionsoul.jcseg.tokenizer.core.IWord) HugeException(com.baidu.hugegraph.HugeException) ConfigException(com.baidu.hugegraph.config.ConfigException)

Example 38 with HugeException

use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.

the class RelationshipManager method save.

private Id save(T relationship, boolean expectExists) {
    if (!this.graph().existsEdgeLabel(relationship.label())) {
        throw new HugeException("Schema is missing for %s '%s'", relationship.label(), relationship.source());
    }
    HugeVertex source = this.newVertex(relationship.source(), relationship.sourceLabel());
    HugeVertex target = this.newVertex(relationship.target(), relationship.targetLabel());
    HugeEdge edge = source.constructEdge(relationship.label(), target, relationship.asArray());
    E.checkArgument(this.exists(edge.id()) == expectExists, "Can't save %s '%s' that %s exists", this.unhideLabel(), edge.id(), expectExists ? "not" : "already");
    this.tx().addEdge(edge);
    this.commitOrRollback();
    return edge.id();
}
Also used : HugeEdge(com.baidu.hugegraph.structure.HugeEdge) HugeException(com.baidu.hugegraph.HugeException) HugeVertex(com.baidu.hugegraph.structure.HugeVertex)

Example 39 with HugeException

use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.

the class MMSeg4JAnalyzer method segment.

@Override
public Set<String> segment(String text) {
    Set<String> result = InsertionOrderUtil.newSet();
    MMSeg mmSeg = new MMSeg(new StringReader(text), this.seg);
    try {
        Word word = null;
        while ((word = mmSeg.next()) != null) {
            result.add(word.getString());
        }
    } catch (Exception e) {
        throw new HugeException("MMSeg4j segment text '%s' failed", e, text);
    }
    return result;
}
Also used : Word(com.chenlb.mmseg4j.Word) MMSeg(com.chenlb.mmseg4j.MMSeg) StringReader(java.io.StringReader) HugeException(com.baidu.hugegraph.HugeException) HugeException(com.baidu.hugegraph.HugeException) ConfigException(com.baidu.hugegraph.config.ConfigException)

Example 40 with HugeException

use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.

the class IKAnalyzer method segment.

@Override
public Set<String> segment(String text) {
    Set<String> result = InsertionOrderUtil.newSet();
    IKSegmenter ik = new IKSegmenter(new StringReader(text), this.smartSegMode);
    try {
        Lexeme word = null;
        while ((word = ik.next()) != null) {
            result.add(word.getLexemeText());
        }
    } catch (Exception e) {
        throw new HugeException("IKAnalyzer segment text '%s' failed", e, text);
    }
    return result;
}
Also used : IKSegmenter(org.wltea.analyzer.core.IKSegmenter) StringReader(java.io.StringReader) Lexeme(org.wltea.analyzer.core.Lexeme) HugeException(com.baidu.hugegraph.HugeException) HugeException(com.baidu.hugegraph.HugeException) ConfigException(com.baidu.hugegraph.config.ConfigException)

Aggregations

HugeException (com.baidu.hugegraph.HugeException)59 Id (com.baidu.hugegraph.backend.id.Id)11 TimeoutException (java.util.concurrent.TimeoutException)6 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)5 ConfigurationException (org.apache.commons.configuration2.ex.ConfigurationException)5 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)4 File (java.io.File)4 Map (java.util.Map)4 HugeGraph (com.baidu.hugegraph.HugeGraph)3 Condition (com.baidu.hugegraph.backend.query.Condition)3 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)3 ConfigException (com.baidu.hugegraph.config.ConfigException)3 NotFoundException (com.baidu.hugegraph.exception.NotFoundException)3 SchemaElement (com.baidu.hugegraph.schema.SchemaElement)3 StringReader (java.io.StringReader)3 PeerId (com.alipay.sofa.jraft.entity.PeerId)2 BackendException (com.baidu.hugegraph.backend.BackendException)2 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)2 IdQuery (com.baidu.hugegraph.backend.query.IdQuery)2 GraphTransaction (com.baidu.hugegraph.backend.tx.GraphTransaction)2