Search in sources :

Example 1 with NotSupportException

use of com.baidu.hugegraph.exception.NotSupportException in project incubator-hugegraph-toolchain by apache.

the class IndexLabelAPI method append.

public IndexLabel append(IndexLabel indexLabel) {
    if (this.client.apiVersionLt("0.50")) {
        throw new NotSupportException("action append on index label");
    }
    String id = indexLabel.name();
    Map<String, Object> params = ImmutableMap.of("action", "append");
    Object il = this.checkCreateOrUpdate(indexLabel);
    RestResult result = this.client.put(this.path(), id, il, params);
    return result.readObject(IndexLabel.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) NotSupportException(com.baidu.hugegraph.exception.NotSupportException)

Example 2 with NotSupportException

use of com.baidu.hugegraph.exception.NotSupportException in project incubator-hugegraph-toolchain by apache.

the class IndexLabelAPI method eliminate.

public IndexLabel eliminate(IndexLabel indexLabel) {
    if (this.client.apiVersionLt("0.50")) {
        throw new NotSupportException("action eliminate on index label");
    }
    String id = indexLabel.name();
    Map<String, Object> params = ImmutableMap.of("action", "eliminate");
    Object il = this.checkCreateOrUpdate(indexLabel);
    RestResult result = this.client.put(this.path(), id, il, params);
    return result.readObject(IndexLabel.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) NotSupportException(com.baidu.hugegraph.exception.NotSupportException)

Example 3 with NotSupportException

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

the class RocksDBTable method queryByCond.

protected BackendColumnIterator queryByCond(Session session, ConditionQuery query) {
    if (query.containsScanRelation()) {
        E.checkArgument(query.relations().size() == 1, "Invalid scan with multi conditions: %s", query);
        Relation scan = query.relations().iterator().next();
        Shard shard = (Shard) scan.value();
        return this.queryByRange(session, shard, query.page());
    }
    throw new NotSupportException("query: %s", query);
}
Also used : Relation(com.baidu.hugegraph.backend.query.Condition.Relation) NotSupportException(com.baidu.hugegraph.exception.NotSupportException) Shard(com.baidu.hugegraph.backend.store.Shard)

Example 4 with NotSupportException

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

the class CassandraTable method relation2Cql.

protected Clause relation2Cql(Relation relation) {
    String key = relation.serialKey().toString();
    Object value = relation.serialValue();
    switch(relation.relation()) {
        case EQ:
            return QueryBuilder.eq(key, value);
        case GT:
            return QueryBuilder.gt(key, value);
        case GTE:
            return QueryBuilder.gte(key, value);
        case LT:
            return QueryBuilder.lt(key, value);
        case LTE:
            return QueryBuilder.lte(key, value);
        case IN:
            return Clauses.in(key, (List<?>) value);
        case CONTAINS_VALUE:
            return QueryBuilder.contains(key, value);
        case CONTAINS_KEY:
            return QueryBuilder.containsKey(key, value);
        case SCAN:
            String[] col = pkColumnName().stream().map(pk -> formatKey(pk)).toArray(String[]::new);
            Shard shard = (Shard) value;
            Object start = QueryBuilder.raw(shard.start());
            Object end = QueryBuilder.raw(shard.end());
            return Clauses.and(QueryBuilder.gte(QueryBuilder.token(col), start), QueryBuilder.lt(QueryBuilder.token(col), end));
        // return QueryBuilder.like(key, value);
        case NEQ:
        default:
            throw new NotSupportException("relation '%s'", relation);
    }
}
Also used : Selection(com.datastax.driver.core.querybuilder.Select.Selection) QueryBuilder(com.datastax.driver.core.querybuilder.QueryBuilder) BiFunction(java.util.function.BiFunction) BackendException(com.baidu.hugegraph.backend.BackendException) Clause(com.datastax.driver.core.querybuilder.Clause) Map(java.util.Map) Query(com.baidu.hugegraph.backend.query.Query) PagingStateException(com.datastax.driver.core.exceptions.PagingStateException) IteratorUtils(org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils) Create(com.datastax.driver.core.schemabuilder.Create) Delete(com.datastax.driver.core.querybuilder.Delete) ExtendableIterator(com.baidu.hugegraph.iterator.ExtendableIterator) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) Set(java.util.Set) PageState(com.baidu.hugegraph.backend.page.PageState) List(java.util.List) Log(com.baidu.hugegraph.util.Log) Id(com.baidu.hugegraph.backend.id.Id) Select(com.datastax.driver.core.querybuilder.Select) Statement(com.datastax.driver.core.Statement) CopyUtil(com.baidu.hugegraph.util.CopyUtil) BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) Relation(com.baidu.hugegraph.backend.query.Condition.Relation) Order(com.baidu.hugegraph.backend.query.Query.Order) Row(com.datastax.driver.core.Row) NotFoundException(com.baidu.hugegraph.exception.NotFoundException) Function(java.util.function.Function) BackendTable(com.baidu.hugegraph.backend.store.BackendTable) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SchemaStatement(com.datastax.driver.core.schemabuilder.SchemaStatement) ResultSet(com.datastax.driver.core.ResultSet) ImmutableList(com.google.common.collect.ImmutableList) DriverException(com.datastax.driver.core.exceptions.DriverException) Shard(com.baidu.hugegraph.backend.store.Shard) NotSupportException(com.baidu.hugegraph.exception.NotSupportException) E(com.baidu.hugegraph.util.E) SchemaBuilder(com.datastax.driver.core.schemabuilder.SchemaBuilder) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PagingState(com.datastax.driver.core.PagingState) Condition(com.baidu.hugegraph.backend.query.Condition) Update(com.datastax.driver.core.querybuilder.Update) Insert(com.datastax.driver.core.querybuilder.Insert) HugeKeys(com.baidu.hugegraph.type.define.HugeKeys) Clauses(com.datastax.driver.core.querybuilder.Clauses) Aggregate(com.baidu.hugegraph.backend.query.Aggregate) DataType(com.datastax.driver.core.DataType) HugeType(com.baidu.hugegraph.type.HugeType) Definition(com.datastax.driver.core.ColumnDefinitions.Definition) NotSupportException(com.baidu.hugegraph.exception.NotSupportException) Shard(com.baidu.hugegraph.backend.store.Shard)

Example 5 with NotSupportException

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

the class InMemoryDBTable method queryNumber.

@Override
public Number queryNumber(BackendSession session, Query query) {
    Aggregate aggregate = query.aggregateNotNull();
    if (aggregate.func() != AggregateFunc.COUNT) {
        throw new NotSupportException(aggregate.toString());
    }
    assert aggregate.func() == AggregateFunc.COUNT;
    Iterator<BackendEntry> results = this.query(session, query);
    long total = 0L;
    while (results.hasNext()) {
        total += this.sizeOfBackendEntry(results.next());
    }
    return total;
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) TextBackendEntry(com.baidu.hugegraph.backend.serializer.TextBackendEntry) NotSupportException(com.baidu.hugegraph.exception.NotSupportException) Aggregate(com.baidu.hugegraph.backend.query.Aggregate)

Aggregations

NotSupportException (com.baidu.hugegraph.exception.NotSupportException)13 HugeException (com.baidu.hugegraph.HugeException)4 Id (com.baidu.hugegraph.backend.id.Id)3 Relation (com.baidu.hugegraph.backend.query.Condition.Relation)3 BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)3 Shard (com.baidu.hugegraph.backend.store.Shard)3 RestResult (com.baidu.hugegraph.rest.RestResult)3 Aggregate (com.baidu.hugegraph.backend.query.Aggregate)2 TextBackendEntry (com.baidu.hugegraph.backend.serializer.TextBackendEntry)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 BackendException (com.baidu.hugegraph.backend.BackendException)1 IdHolder (com.baidu.hugegraph.backend.page.IdHolder)1 BatchIdHolder (com.baidu.hugegraph.backend.page.IdHolder.BatchIdHolder)1 FixedIdHolder (com.baidu.hugegraph.backend.page.IdHolder.FixedIdHolder)1 PagingIdHolder (com.baidu.hugegraph.backend.page.IdHolder.PagingIdHolder)1 IdHolderList (com.baidu.hugegraph.backend.page.IdHolderList)1 PageState (com.baidu.hugegraph.backend.page.PageState)1 SortByCountIdHolderList (com.baidu.hugegraph.backend.page.SortByCountIdHolderList)1