コード例 #1
1
 @Override
 public int getPartition(
     LongWritable longWritable, BytesWritable bytesWritable, int numPartitions) {
   if (start == null) {
     initialize();
   }
   long x = longWritable.get();
   int ret = (int) Long.divideUnsigned(x - start, width);
   return ret;
 }
コード例 #2
1
 public <T> List<byte[]> query(
     Path basePath,
     Path baseOutputPath,
     long beginNS,
     long endNS,
     int numReducers,
     T fields,
     Configuration conf,
     FileSystem fs,
     PcapFilterConfigurator<T> filterImpl)
     throws IOException, ClassNotFoundException, InterruptedException {
   String fileName =
       Joiner.on("_")
           .join(beginNS, endNS, filterImpl.queryToString(fields), UUID.randomUUID().toString());
   if (LOG.isDebugEnabled()) {
     DateFormat format =
         SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG);
     String from = format.format(new Date(Long.divideUnsigned(beginNS, 1000000)));
     String to = format.format(new Date(Long.divideUnsigned(endNS, 1000000)));
     LOG.debug(
         "Executing query "
             + filterImpl.queryToString(fields)
             + " on timerange "
             + from
             + " to "
             + to);
   }
   Path outputPath = new Path(baseOutputPath, fileName);
   Job job =
       createJob(basePath, outputPath, beginNS, endNS, numReducers, fields, conf, fs, filterImpl);
   boolean completed = job.waitForCompletion(true);
   if (completed) {
     return readResults(outputPath, conf, fs);
   } else {
     throw new RuntimeException(
         "Unable to complete query due to errors.  Please check logs for full errors.");
   }
 }
コード例 #3
1
 public static int findWidth(long start, long end, int numReducers) {
   return (int) Long.divideUnsigned(end - start, numReducers) + 1;
 }