public static EntryArrayList of(Iterable<? extends Entry> i) { // This is adapted from Guava's Lists.newArrayList implementation EntryArrayList result; if (i instanceof Collection) { // Let ArrayList's sizing logic work, if possible result = new EntryArrayList((Collection)i); } else { // Unknown size result = new EntryArrayList(); Iterators.addAll(result, i.iterator()); } return result; }
@Override public Iterator<Entry> reuseIterator() { return iterator(); }
/** * This implementation is an inexact estimate. * It's just the product of a constant ({@link #ENTRY_SIZE_ESTIMATE} times the array size. * The exact size could be calculated by iterating over the list and summing the remaining * size of each StaticBuffer in each Entry. * * @return crude approximation of actual size */ @Override public int getByteSize() { return size() * ENTRY_SIZE_ESTIMATE; } }
@Override protected void map(StaticBuffer key, Iterable<Entry> values, Context context) throws IOException, InterruptedException { EntryArrayList al = EntryArrayList.of(values); // KeyFilter check if (!keyFilter.test(key)) { log.debug("Skipping key {} based on KeyFilter", key); return; } // InitialQuery check (at least one match is required or else the key is ignored) EntryList initialQueryMatches = findEntriesMatchingQuery(initialQuery, al); if (0 == initialQueryMatches.size()) { log.debug("Skipping key {} based on InitialQuery ({}) match failure", key, initialQuery); return; } // Both conditions (KeyFilter && InitialQuery) for invoking process are satisfied // Create an entries parameter to be passed into the process method Map<SliceQuery, EntryList> matches = new HashMap<>(); matches.put(initialQuery, initialQueryMatches); // Find matches (if any are present) for subsequent queries for (SliceQuery sq : subsequentQueries) { matches.put(sq, findEntriesMatchingQuery(sq, al)); } // Process job.process(key, matches, metrics); }
@Override protected void map(StaticBuffer key, Iterable<Entry> values, Context context) throws IOException, InterruptedException { EntryArrayList al = EntryArrayList.of(values); // KeyFilter check if (!keyFilter.test(key)) { log.debug("Skipping key {} based on KeyFilter", key); return; } // InitialQuery check (at least one match is required or else the key is ignored) EntryList initialQueryMatches = findEntriesMatchingQuery(initialQuery, al); if (0 == initialQueryMatches.size()) { log.debug("Skipping key {} based on InitialQuery ({}) match failure", key, initialQuery); return; } // Both conditions (KeyFilter && InitialQuery) for invoking process are satisfied // Create an entries parameter to be passed into the process method Map<SliceQuery, EntryList> matches = new HashMap<>(); matches.put(initialQuery, initialQueryMatches); // Find matches (if any are present) for subsequent queries for (SliceQuery sq : subsequentQueries) { matches.put(sq, findEntriesMatchingQuery(sq, al)); } // Process job.process(key, matches, metrics); }
return EntryArrayList.of(sortedEntries.subList(lowestStartMatch, endIndex /* exclusive */)); } else { return EntryList.EMPTY_LIST;
return EntryArrayList.of(sortedEntries.subList(lowestStartMatch, endIndex /* exclusive */)); } else { return EntryList.EMPTY_LIST;