Search in sources :

Example 1 with GroupDocIdString

use of com.yahoo.document.idstring.GroupDocIdString in project vespa by vespa-engine.

the class ComparisonNode method compare.

private BucketSet compare(BucketIdFactory factory, IdNode id, LiteralNode literal, String operator) {
    String field = id.getField();
    Object value = literal.getValue();
    if (field == null) {
        if (value instanceof String) {
            String name = (String) value;
            if ((operator.equals("=") && name.contains("*")) || (operator.equals("=~") && ((name.contains("*") || name.contains("?"))))) {
                // no idea
                return null;
            }
            return new BucketSet(factory.getBucketId(new DocumentId(name)));
        }
    } else if (field.equalsIgnoreCase("user")) {
        if (value instanceof Long) {
            return new BucketSet(new BucketId(factory.getLocationBitCount(), (Long) value));
        }
    } else if (field.equalsIgnoreCase("group")) {
        if (value instanceof String) {
            String name = (String) value;
            if ((operator.equals("=") && name.contains("*")) || (operator.equals("=~") && ((name.contains("*") || name.contains("?"))))) {
                // no idea
                return null;
            }
            return new BucketSet(new BucketId(factory.getLocationBitCount(), new GroupDocIdString("", name, "").getLocation()));
        }
    } else if (field.equalsIgnoreCase("bucket")) {
        if (value instanceof Long) {
            return new BucketSet(new BucketId((Long) value));
        }
    }
    return null;
}
Also used : DocumentId(com.yahoo.document.DocumentId) GroupDocIdString(com.yahoo.document.idstring.GroupDocIdString) GroupDocIdString(com.yahoo.document.idstring.GroupDocIdString) BucketId(com.yahoo.document.BucketId)

Aggregations

BucketId (com.yahoo.document.BucketId)1 DocumentId (com.yahoo.document.DocumentId)1 GroupDocIdString (com.yahoo.document.idstring.GroupDocIdString)1