Package cc.concurrent.mango.util

Examples of cc.concurrent.mango.util.Iterables


    protected String getCacheKey(Object suffix) {
        return prefix + suffix;
    }

    protected Set<String> getCacheKeys(RuntimeContext context) {
        Iterables iterables = new Iterables(getSuffixObj(context));
        Set<String> keys = new HashSet<String>(iterables.size() * 2);
        for (Object suffix : iterables) {
            String key = getCacheKey(suffix);
            keys.add(key);
        }
        return keys;
View Full Code Here


        Map<String, Object> cacheResults = getBulkFromCache(keys);
        AddableObject<T> addableObj = new AddableObject<T>(keys.size(), mappedClass);
        int hitCapacity = cacheResults != null ? cacheResults.size() : 0;
        List<U> hitSuffix = new ArrayList<U>(hitCapacity); // 用于debug
        Set<U> missSuffix = new HashSet<U>((keys.size() - hitCapacity) * 2);
        for (Object suffix : new Iterables(getSuffixObj(context))) {
            String key = getCacheKey(suffix);
            Object value = cacheResults != null ? cacheResults.get(key) : null;
            if (value == null) {
                missSuffix.add(suffixClass.cast(suffix));
            } else {
                addableObj.add(mappedClass.cast(value));
                if (isDebugEnabled) {
                    hitSuffix.add(suffixClass.cast(suffix));
                }
            }
        }
        if (isDebugEnabled) {
            logger.debug("cache hit #keys={} #values={}", hitSuffix, addableObj);
            logger.debug("cache miss #keys={}", missSuffix);
        }
        if (!missSuffix.isEmpty()) { // 有key没有命中
            setSuffixObj(context, missSuffix);
            Object dbValues = executeFromDb(context);
            for (Object dbValue : new Iterables(dbValues)) {
                // db数据添加入结果
                addableObj.add(mappedClass.cast(dbValue));
                // 添加入缓存
                Object suffix = BeanUtil.getPropertyValue(dbValue, interableProperty, mappedClass);
                String key = getCacheKey(suffix);
View Full Code Here

                sql.append(aip.getInterableProperty()).append(" in (");
                Object objs = aip.value(context);
                if (objs == null) {
                    throw new NullPointerException("value of " + aip.getFullName() + " can't be null");
                }
                Iterables iterables = new Iterables(objs);
                int size = iterables.size();
                if (size == 0) {
                    throw new IllegalArgumentException("value of " + aip.getFullName() + " can't be empty");
                }
                StringBuffer sb = new StringBuffer();
                sb.append("?");
View Full Code Here

                ASTIterableParameter aip = (ASTIterableParameter) node;
                Object objs = aip.value(context);
                if (objs == null) {
                    throw new NullPointerException(aip.getFullName() + " can't be null");
                }
                Iterables iterables = new Iterables(objs);
                int size = iterables.size();
                if (size == 0) {
                    throw new IllegalArgumentException(aip.getFullName() + " can't be empty");
                }
                for (Object obj : iterables) {
                    args.add(obj);
View Full Code Here

    public Object execute(Object[] methodArgs) {
        Object methodArg = methodArgs[0];
        if (methodArg == null) {
            throw new NullPointerException("batchUpdate's parameter can't be null");
        }
        Iterables iterables = new Iterables(methodArg);
        if (iterables.isEmpty()) {
            throw new IllegalArgumentException("batchUpdate's parameter can't be empty");
        }

        Set<String> keys = null;
        if (isUseCache()) {
            keys = new HashSet<String>(iterables.size() * 2);
        }
        List<Object[]> batchArgs = new ArrayList<Object[]>(iterables.size());
        List<String> sqls = new ArrayList<String>(iterables.size());
        for (Object obj : iterables) {
            RuntimeContext context = buildRuntimeContext(new Object[]{obj});
            if (keys != null) { // 表示使用cache
                keys.add(getCacheKey(context));
            }
View Full Code Here

                sql.append(aip.getInterableProperty()).append(" in (");
                Object objs = aip.value(context);
                if (objs == null) {
                    throw new NullPointerException("value of " + aip.getFullName() + " can't be null");
                }
                Iterables iterables = new Iterables(objs);
                int size = iterables.size();
                if (size == 0) {
                    throw new IllegalArgumentException("value of " + aip.getFullName() + " can't be empty");
                }
                StringBuffer sb = new StringBuffer();
                sb.append("?");
View Full Code Here

                ASTIterableParameter aip = (ASTIterableParameter) node;
                Object objs = aip.value(context);
                if (objs == null) {
                    throw new NullPointerException(aip.getFullName() + " can't be null");
                }
                Iterables iterables = new Iterables(objs);
                int size = iterables.size();
                if (size == 0) {
                    throw new IllegalArgumentException(aip.getFullName() + " can't be empty");
                }
                for (Object obj : iterables) {
                    args.add(obj);
View Full Code Here

    protected String getCacheKey(Object suffix) {
        return prefix + suffix;
    }

    protected Set<String> getCacheKeys(RuntimeContext context) {
        Iterables iterables = new Iterables(getSuffixObj(context));
        Set<String> keys = new HashSet<String>(iterables.size() * 2);
        for (Object suffix : iterables) {
            String key = getCacheKey(suffix);
            keys.add(key);
        }
        return keys;
View Full Code Here

        Map<String, Object> cacheResults = getBulkFromCache(keys);
        AddableObject<T> addableObj = new AddableObject<T>(keys.size(), mappedClass);
        int hitCapacity = cacheResults != null ? cacheResults.size() : 0;
        List<U> hitSuffix = new ArrayList<U>(hitCapacity); // 用于debug
        Set<U> missSuffix = new HashSet<U>((keys.size() - hitCapacity) * 2);
        for (Object suffix : new Iterables(getSuffixObj(context))) {
            String key = getCacheKey(suffix);
            Object value = cacheResults != null ? cacheResults.get(key) : null;
            if (value == null) {
                missSuffix.add(suffixClass.cast(suffix));
            } else {
                addableObj.add(mappedClass.cast(value));
                if (isDebugEnabled) {
                    hitSuffix.add(suffixClass.cast(suffix));
                }
            }
        }
        if (isDebugEnabled) {
            logger.debug("cache hit #keys={} #values={}", hitSuffix, addableObj);
            logger.debug("cache miss #keys={}", missSuffix);
        }
        if (!missSuffix.isEmpty()) { // 有key没有命中
            setSuffixObj(context, missSuffix);
            Object dbValues = executeFromDb(context);
            for (Object dbValue : new Iterables(dbValues)) {
                // db数据添加入结果
                addableObj.add(mappedClass.cast(dbValue));
                // 添加入缓存
                Object suffix = BeanUtil.getPropertyValue(dbValue, interableProperty, mappedClass);
                String key = getCacheKey(suffix);
View Full Code Here

    public Object execute(Object[] methodArgs) {
        Object methodArg = methodArgs[0];
        if (methodArg == null) {
            throw new NullPointerException("batchUpdate's parameter can't be null");
        }
        Iterables iterables = new Iterables(methodArg);
        if (iterables.isEmpty()) {
            throw new IllegalArgumentException("batchUpdate's parameter can't be empty");
        }

        Set<String> keys = null;
        if (isUseCache()) {
            keys = new HashSet<String>(iterables.size() * 2);
        }
        List<Object[]> batchArgs = new ArrayList<Object[]>(iterables.size());
        List<String> sqls = new ArrayList<String>(iterables.size());
        for (Object obj : iterables) {
            RuntimeContext context = buildRuntimeContext(new Object[]{obj});
            if (keys != null) { // 表示使用cache
                keys.add(getCacheKey(context));
            }
View Full Code Here

TOP

Related Classes of cc.concurrent.mango.util.Iterables

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.