Package cascading.tuple

Examples of cascading.tuple.Tuple


    public Outlink[] getOutlinks() {
        return makeOutlinksFromTuple((Tuple)_tupleEntry.getObject(OUTLINKS_FIELD));
    }

    private Tuple makeTupleOfPageResults(PageResult[] results) {
        Tuple t = new Tuple();
        for (PageResult pr : results) {
            t.add(pr);
        }
       
        return t;
    }
View Full Code Here


       
        return result;
    }

    private Tuple makeTupleOfOutlinks(Outlink[] outlinks) {
        Tuple t = new Tuple();
        for (Outlink outlink : outlinks) {
            t.add(outlink);
        }
       
        return t;
    }
View Full Code Here

                    process.increment(FetchCounters.URLS_FAILED, 1);
                    status = new IOFetchException(item.getUrl(), new IOException(e));
                } finally {
                    process.decrement(FetchCounters.URLS_FETCHING, 1);

                    Tuple tuple = result.getTuple();
                    tuple.add(status);
                    _fetchMgr.collect(tuple);

                    // Figure out how long it's been since the start of the request.
                    long fetchInterval = System.currentTimeMillis() - fetchStartTime;

                    // We want to avoid fetching faster than a max acceptable rate. Note that we always do
                    // this, even if there's not another page, so that this setting will have impact even
                    // if the next fetch set is ready right away.
                    if (fetchInterval < minPageFetchInterval) {
                        long delay = minPageFetchInterval - fetchInterval;
                        LOGGER.trace(String.format("FetchTask: sleeping for %dms", delay));

                        try {
                            Thread.sleep(delay);
                        } catch (InterruptedException e) {
                            LOGGER.warn("FetchTask interrupted!");
                            Thread.currentThread().interrupt();
                            continue;
                        }
                    }
                }
            }
           
            // While we still have entries, we need to write them out to avoid losing them.
            while (iter.hasNext()) {
                ScoredUrlDatum item = iter.next();
                FetchedDatum result = new FetchedDatum(item);
                process.increment(FetchCounters.URLS_SKIPPED, 1);
                AbortedFetchException status = new AbortedFetchException(item.getUrl(), AbortedFetchReason.INTERRUPTED);
               
                Tuple tuple = result.getTuple();
                tuple.add(status);
               _fetchMgr.collect(tuple);
            }
        } catch (Throwable t) {
            LOGGER.error("Exception while fetching", t);
        } finally {
View Full Code Here

            LOGGER.debug("Exception processing redirect for " + _url + ": " + e.getMessage(), e);
        }

        synchronized (_collector) {
            // collectors aren't thread safe
            _collector.add(BixoPlatform.clone(new Tuple(redirectedUrl), _flowProcess));
        }
    }
View Full Code Here

    }
   

    private void emitTuple(String url) {
        synchronized(_collector) {
            _collector.add(BixoPlatform.clone(new Tuple(url), _flowProcess));
        }
    }
View Full Code Here

            // Cascading local mode just does a shallow copy of the tuple, so we need
            // to clone the tuple, and then deep-clone any tuple fields that aren't scalars.
            // Currently we only handle Tuple & Date as an embedded object, or anything
            // that's Writable.
           
            Tuple result = t;
           
            for (int i = 0; i < result.size(); i++) {
                Object value = result.getObject(i);
                if ((value == null) || (value instanceof Boolean) || (value instanceof String) ||
                    (value instanceof Double) || (value instanceof Float) ||
                    (value instanceof Integer) || (value instanceof Long) || (value instanceof Short)) {
                    // All set, Cascading will do shallow copy
                } else {
                    // we need to clone the Tuple
                    if (result == t) {
                        result = new Tuple(t);
                    }
                   
                    result.set(i, cloneValue(value, i));
                }
            }
           
            return result;
        } else {
View Full Code Here

        }
    }
   
    private static Object cloneValue(Object value, int index) {
        if (value instanceof Tuple) {
            return new Tuple((Tuple)value);
        } else if (value instanceof Date) {
            return new Date(((Date)value).getTime());
        } else if (value instanceof Writable) {
            // FUTURE - add threadlocal variables that we reuse here, versus re-allocating constantly.
            try {
View Full Code Here

        setLastList(false);
        setSkipped(false);
    }

    public List<ScoredUrlDatum> getUrls() {
        Tuple urls = (Tuple)_tupleEntry.getObject(URLS_FN);
        List<ScoredUrlDatum> result = new ArrayList<ScoredUrlDatum>(urls.size());
        Iterator<Object> iter = urls.iterator();
        while (iter.hasNext()) {
            result.add(new ScoredUrlDatum((Tuple)iter.next()));
        }
       
        return result;
View Full Code Here

       
        return result;
    }
   
    public void setUrls(List<ScoredUrlDatum> urls) {
        Tuple result = new Tuple();
        for (ScoredUrlDatum datum : urls) {
            result.add(datum.getTuple());
        }
       
        _tupleEntry.setObject(URLS_FN, result);
    }
View Full Code Here

    public void setParsedMeta(Map<String, String> parsedMeta) {
        _tupleEntry.setObject(PARSED_META_FN, convertMapToTuple(parsedMeta));
    }

    private Tuple convertOutlinksToTuple(Outlink[] outLinks) {
        Tuple tuple = new Tuple();
        for (Outlink outlink : outLinks) {
            tuple.add(outlink.getToUrl());
            tuple.add(outlink.getAnchor());
            tuple.add(outlink.getRelAttributes());
        }
       
        return tuple;
    }
View Full Code Here

TOP

Related Classes of cascading.tuple.Tuple

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.