Package com.basho.riak.client.query

Examples of com.basho.riak.client.query.MapReduceResult


     *
     * @param linkWalkSpec
     *            the {@link LinkWalkSpec} to execute.
     */
    public WalkResult linkWalk(final LinkWalkSpec linkWalkSpec) throws IOException {
        MapReduceResult firstPhaseResult = linkWalkFirstPhase(linkWalkSpec);
        MapReduceResult secondPhaseResult = linkWalkSecondPhase(firstPhaseResult);
        WalkResult result = convert(secondPhaseResult);
        return result;
    }
View Full Code Here


        });
        // only return the key, to match the http rest api
        mr.addReducePhase(new JSSourceFunction("function(v) { return v.map(function(e) { return e[1]; }); }"));

        try {
            MapReduceResult result = mr.execute();
            return new ArrayList<String>(result.getResult(String.class));
        } catch (RiakException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

                throw new MapReduceTimeoutException();
            } else {
                throw new IOException(resp.getBodyAsString());
            }
        }
        final MapReduceResult result = new MapReduceResult() {

            public String getResultRaw() {
                return resp.getBodyAsString();
            }
View Full Code Here

     *
     * @param linkWalkSpec
     *            the {@link LinkWalkSpec} to execute.
     */
    public WalkResult linkWalk(final LinkWalkSpec linkWalkSpec) throws IOException {
        MapReduceResult firstPhaseResult = linkWalkFirstPhase(linkWalkSpec);
        MapReduceResult secondPhaseResult = linkWalkSecondPhase(firstPhaseResult);
        WalkResult result = convert(secondPhaseResult);
        return result;
    }
View Full Code Here

        mr.addReducePhase(NamedErlangFunction.REDUCE_IDENTITY, Args.REDUCE_PHASE_ONLY_1);
        // only return the key, to match the http rest api
        mr.addReducePhase(new JSSourceFunction("function(v) { return v.map(function(e) { return e[1]; }); }"), Args.REDUCE_PHASE_ONLY_1);

        try {
            MapReduceResult result = mr.execute();
            return new ArrayList<String>(result.getResult(String.class));
        } catch (RiakException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

                throw new MapReduceTimeoutException();
            } else {
                throw new IOException(resp.getBodyAsString());
            }
        }
        final MapReduceResult result = new MapReduceResult() {

            public String getResultRaw() {
                return resp.getBodyAsString();
            }
View Full Code Here

    @Override
    public List<TriggeredAlert> getTriggeredAlerts(String accountName, Long fromTimeperiod, Long toTimeperiod) {
        List<TriggeredAlert> triggeredAlertList = new ArrayList<TriggeredAlert>();
        try {
            MapReduceResult result = riakClient.mapReduce("Triggered_Alert;" + accountName)
                    .addKeyFilter(new TokenizeFilter(";",2))
                    .addKeyFilter(new StringToIntFilter())
                    .addKeyFilter(new BetweenFilter(fromTimeperiod, toTimeperiod))
                    .addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true)
                    .execute();

            logger.info("Key Filter: " + result.getResultRaw().toString());

            Collection<BasicTriggeredAlert> rtaList = result.getResult(BasicTriggeredAlert.class);
            triggeredAlertList.addAll(rtaList);

        } catch (RiakException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }
View Full Code Here

    @Override
    public List<TriggeredAlert> getTriggeredAlerts(String alertname, String accountName, Long fromTimeperiod, Long toTimeperiod) {
        List<TriggeredAlert> triggeredAlertList = new ArrayList<TriggeredAlert>();
        try {
            MapReduceResult result = riakClient.mapReduce("Triggered_Alert;" + accountName)
                    .addKeyFilter(new TokenizeFilter(";",2))
                    .addKeyFilter(new StringToIntFilter())
                    .addKeyFilter(new BetweenFilter(fromTimeperiod, toTimeperiod))
                    .addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true)
                    .execute();

            logger.info("Key Filter: " + result.getResultRaw().toString());

            Collection<BasicTriggeredAlert> rtaList = result.getResult(BasicTriggeredAlert.class);

            //TODO: Fix Key Filter so this is not neccessary!
            for (BasicTriggeredAlert rta : rtaList) {
                if (rta.getAlertName().equals(alertname)) {
                    triggeredAlertList.add(rta);
View Full Code Here

                throw new MapReduceTimeoutException();
            } else {
                throw new IOException(resp.getBodyAsString());
            }
        }
        final MapReduceResult result = new MapReduceResult() {

            public String getResultRaw() {
                return resp.getBodyAsString();
            }
View Full Code Here

    public Collection<BucketKey> getKeys(IRiakClient client) throws RiakException {
        if (bucket == null || searchQuery == null) {
            throw new IllegalStateException("bucket and query cannot be null");
        }

        MapReduceResult result = client.mapReduce(bucket, searchQuery).addReducePhase(NamedErlangFunction.REDUCE_IDENTITY,
                                                                                      Args.REDUCE_PHASE_ONLY_1).execute();

        return result.getResult(BucketKey.class);
    }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.query.MapReduceResult

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.