/** * Emit a "start" or "EOF" bumper as appropriate to prominently * indicate if page borders start- or end- of-file. * * @param pw PrintWriter * @param atTop boolean, true if at top of page */ protected void emitBumper(PrintWriter pw, boolean atTop) { if((!reversedOrder ^ atTop)&&(range.getMaximumLong()==file.length())) { pw.println("<span class='endBumper' style='font-weight:bold; color:white; background-color:#400'>«EOF»</span>"); return; } if((reversedOrder ^ atTop)&&(range.getMinimumLong()==0)) { pw.println("<span class='startBumper' style='font-weight:bold; color:white; background-color:#040'>«START»</span>"); } }
/** * Actually read the requested lines, and reverses if appropriate. * * If at file start, refuses to show fewer lines than are possible * ('bounces' against start). * * @throws IOException */ protected void loadLines() throws IOException { this.file = fileRepresentation.getFile(); this.lines = new LinkedList<String>(); this.range = FileUtils.pagedLines(file, position, lineCount, lines, 128); // bounce against the front of the file: don't show runt (fewer // lines than requested) unless absolutely necessary) if(lines.size()<Math.abs(lineCount) && range.getMinimumLong() == 0 && range.getMaximumLong()<file.length()) { this.lines = new LinkedList<String>(); this.range = FileUtils.pagedLines(file, 0, Math.abs(lineCount), lines, 128); } if(reversedOrder) { Collections.reverse(lines); } }
pw.println("bytes " +range.getMaximumLong() +"-"+range.getMinimumLong() +"/"+file.length() +" " pw.print("<a href='"); pw.print(getControlUri( Math.max(0, range.getMinimumLong()-1),-Math.abs(lineCount),reversedOrder)); pw.println("'>earlier ›</a>"); pw.print("<a href='"); pw.println("'>« start</a>"); pw.print("<a href='");pw.print(getControlUri( Math.max(0, range.getMinimumLong()-1),-Math.abs(lineCount),reversedOrder)); pw.println("'>‹ earlier</a>"); pw.println("bytes " +range.getMinimumLong() +"-"+range.getMaximumLong() +"/"+file.length()
/** * Emit a "start" or "EOF" bumper as appropriate to prominently * indicate if page borders start- or end- of-file. * * @param pw PrintWriter * @param atTop boolean, true if at top of page */ protected void emitBumper(PrintWriter pw, boolean atTop) { if((!reversedOrder ^ atTop)&&(range.getMaximumLong()==file.length())) { pw.println("<span class='endBumper' style='font-weight:bold; color:white; background-color:#400'>«EOF»</span>"); return; } if((reversedOrder ^ atTop)&&(range.getMinimumLong()==0)) { pw.println("<span class='startBumper' style='font-weight:bold; color:white; background-color:#040'>«START»</span>"); } }
public static LongRange expandRange(LongRange range1, LongRange range2) { return new LongRange(Math.min(range1.getMinimumLong(), range2.getMinimumLong()), Math.max(range1.getMaximumLong(), range2.getMaximumLong())); }
public static LongRange expandRange(LongRange range1, LongRange range2) { return new LongRange(Math.min(range1.getMinimumLong(), range2.getMinimumLong()), Math.max(range1.getMaximumLong(), range2.getMaximumLong())); }
public static LongRange expandRange(LongRange range1, LongRange range2) { return new LongRange(Math.min(range1.getMinimumLong(), range2.getMinimumLong()), Math.max(range1.getMaximumLong(), range2.getMaximumLong())); }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); if (options.containsKey(Constants.START_DATE) && options.containsKey(Constants.END_DATE)) { long start = Long.parseLong(options.get(Constants.START_DATE)); long end = Long.parseLong(options.get(Constants.END_DATE)); // The begin date from the query may be down to the second, for doing lookups in the index we want to use the day because // the times in the index table have been truncated to the day. start = DateUtils.truncate(new Date(start), Calendar.DAY_OF_MONTH).getTime(); if (start > end) throw new IllegalArgumentException("Start date comes after end date"); range = new LongRange(start, end); if (log.isDebugEnabled()) { log.debug("Set the date range to " + new Date(range.getMinimumLong()) + " to " + new Date(range.getMaximumLong())); } } else { throw new IllegalArgumentException("Both options must be set: " + Constants.START_DATE + " and " + Constants.END_DATE); } }
/** * @param ranges ranges to process and add them (potentially altered) to result list of ranges. */ public void addRanges(List<LongRange> ranges) { for (LongRange range : ranges) { addRange(range.getMinimumLong(), range.getMaximumLong()); } }
/** * add range to process and add it (potentially altered) to result list of ranges. * * @param from range left boundary * @param to range right boundary */ public void addRange(long from, long to) { LongRange addedRange = new LongRange(from, to); Iterator<LongRange> it = disjointRanges.iterator(); while (it.hasNext()) { LongRange existingRange = it.next(); if (existingRange.overlapsRange(addedRange)) { it.remove(); addedRange = new LongRange(Math.min(addedRange.getMinimumLong(), existingRange.getMinimumLong()), Math.max(addedRange.getMaximumLong(), existingRange.getMaximumLong())); } } disjointRanges.add(addedRange); }
public static final IteratorSetting configureGlobalIndexDateRangeFilter(ShardQueryConfiguration config, LongRange dateRange) { // Setup the GlobalIndexDateRangeFilter if (log.isTraceEnabled()) { log.trace("Configuring GlobalIndexDateRangeFilter with " + dateRange); } IteratorSetting cfg = new IteratorSetting(config.getBaseIteratorPriority() + 21, "dateFilter", GlobalIndexDateRangeFilter.class); cfg.addOption(Constants.START_DATE, Long.toString(dateRange.getMinimumLong())); cfg.addOption(Constants.END_DATE, Long.toString(dateRange.getMaximumLong())); return cfg; }
/** * Actually read the requested lines, and reverses if appropriate. * * If at file start, refuses to show fewer lines than are possible * ('bounces' against start). * * @throws IOException */ protected void loadLines() throws IOException { this.file = fileRepresentation.getFile(); this.lines = new LinkedList<String>(); this.range = FileUtils.pagedLines(file, position, lineCount, lines, 128); // bounce against the front of the file: don't show runt (fewer // lines than requested) unless absolutely necessary) if(lines.size()<Math.abs(lineCount) && range.getMinimumLong() == 0 && range.getMaximumLong()<file.length()) { this.lines = new LinkedList<String>(); this.range = FileUtils.pagedLines(file, 0, Math.abs(lineCount), lines, 128); } if(reversedOrder) { Collections.reverse(lines); } }
pw.println("bytes " +range.getMaximumLong() +"-"+range.getMinimumLong() +"/"+file.length() +" " pw.print("<a href='"); pw.print(getControlUri( Math.max(0, range.getMinimumLong()-1),-Math.abs(lineCount),reversedOrder)); pw.println("'>earlier ›</a>"); pw.print("<a href='"); pw.println("'>« start</a>"); pw.print("<a href='");pw.print(getControlUri( Math.max(0, range.getMinimumLong()-1),-Math.abs(lineCount),reversedOrder)); pw.println("'>‹ earlier</a>"); pw.println("bytes " +range.getMinimumLong() +"-"+range.getMaximumLong() +"/"+file.length()
protected void testRange(String start, String end, long expectedStart, long expectedEnd) { final Collection<LongRange> ranges = MacAddressRangeUtils.parseRangeString(start + '-' + end); final LongRange firstRange = ranges.iterator().next(); assertThat(firstRange.getMinimumLong(), equalTo(expectedStart)); assertThat(firstRange.getMaximumLong(), equalTo(expectedEnd)); }
private LongRange merge(LongRange range1, LongRange range2) { if (range1 == null) { return range2; } else if (range2 == null) { return range1; } else { long min = Math.min(range1.getMinimumLong(), range2.getMinimumLong()); long max = Math.max(range1.getMaximumLong(), range2.getMaximumLong()); return new LongRange(min, max); } }
public static boolean isRangeValid(String start, String end) { long startNum = macToLong(start); long endNum = macToLong(end); if (startNum > endNum) { return false; } Collection<LongRange> ranges = parseRangeString(start + "-" + end); for (LongRange range : ranges) { if (range.getMaximumLong() - range.getMinimumLong() < 0) { return false; } } return true; }
range, pagedLines(file, range.getMinimumLong()-1, signedDesiredLineCount+foundFullLines, lines,
range, pagedLines(file, range.getMinimumLong()-1, signedDesiredLineCount+foundFullLines, lines,
builder.setStartBegin(start.getMinimumLong()); builder.setStartEnd(start.getMaximumLong()); builder.setFinishBegin(finish.getMinimumLong()); builder.setFinishEnd(finish.getMaximumLong());
builder.setStartBegin(start.getMinimumLong()); builder.setStartEnd(start.getMaximumLong()); builder.setFinishBegin(finish.getMinimumLong()); builder.setFinishEnd(finish.getMaximumLong());