Examples of LongWritable


Examples of org.apache.hadoop.io.LongWritable

        if (jsonObj.get("http_result").getAsInt() == 200) {
          reporter.incrCounter(this._counterGroup, "HTTP Success", 1);

          // only output counts for pages that were successfully retrieved
          output.collect(new Text(domain), new LongWritable(1));
        }
        else {
          reporter.incrCounter(this._counterGroup, "HTTP Not Success", 1);
        }
      }
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

          if (disposition.equals("SUCCESS"))
            isSuccessful = true;
        }

        // Output a basic page count
        output.collect(new Text("Pages Requested\tTotal"), new LongWritable(1));

        output.collect(new Text("Pages Requested\t"+disposition), new LongWritable(1));

        // Output the HTTP result
        String httpResult = "[missing]";

        if (jsonObj.has("http_result"))
          httpResult = jsonObj.get("http_result").getAsString().trim().toUpperCase();

        output.collect(new Text("HTTP Code\t"+httpResult+" ("+disposition+")"), new LongWritable(1));

        // If the request was not successful, move to the next record
        if (isSuccessful == false)
          return;

        // Gather the host name
        try {

          URI uri = new URI(url);
          String host = uri.getHost();

          if (host == null || host.equals(""))
            throw new URISyntaxException(url, "Unable to gather host or no host found");

          // Gather the domain object
          InternetDomainName domainObj = InternetDomainName.from(host);

          // Output the TLD
          String publicSuffix = "[none]";

          if (domainObj.hasPublicSuffix())
            publicSuffix = domainObj.publicSuffix().name().trim().toLowerCase();

          output.collect(new Text("TLD\t"+publicSuffix), new LongWritable(1));

          // Output the private domain
          // WARNING - This dramatically increases the size of the output.
          String privateDomain = "[invalid]";

          if (domainObj.topPrivateDomain() != null)
            privateDomain = domainObj.topPrivateDomain().name().trim().toLowerCase();

          //output.collect(new Text("Domain\t"+privateDomain), new LongWritable(1));
        }
        catch (URISyntaxException ex) {
          output.collect(new Text("TLD\t[invalid URL]"), new LongWritable(1));
          reporter.incrCounter(this._counterGroup, "Invalid URLs", 1);
        }
        // Output MIME Type
        String mimeType = "[missing]";

        if (jsonObj.has("mime_type"))
          mimeType = jsonObj.get("mime_type").getAsString().trim().toLowerCase();

        output.collect(new Text("Type\t"+mimeType), new LongWritable(1));

        // Output Charset
        String charset = "[missing]";

        if (jsonObj.has("charset_detected"))
          charset = jsonObj.get("charset_detected").getAsString().trim().toUpperCase();

        output.collect(new Text("Charset\t"+charset), new LongWritable(1));

        // Download Size
        if (jsonObj.has("download_size") == true)
          output.collect(new Text("Content Size\t"), new LongWritable(jsonObj.get("download_size").getAsInt()));
      }
      catch (IOException ex) {
        throw ex;
      }
      catch (Exception ex) {
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

        Elements mf = doc.select("[itemtype~=schema.org]");

        if (mf.size() > 0) {
          for (Element e : mf) {
            if (e.hasAttr("itemtype")) {
              output.collect(new Text(e.attr("itemtype").toLowerCase().trim()), new LongWritable(1));
            }
          }
        }
      }
      catch (Throwable e) {
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

          reporter.incrCounter(this._counterGroup, "Skipped - Empty Page Text", 1);
        }

        // Splits by space and outputs to OutputCollector.
        for (String word : pageText.split(" ")) {
          output.collect(new Text(word.toLowerCase()), new LongWritable(1));
        }
      }
      catch (Exception ex) {
        LOG.error("Caught Exception", ex);
        reporter.incrCounter(this._counterGroup, "Exceptions", 1);
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

    return o == null ? null : new OrcLazyLong((OrcLazyLong) o);
  }

  @Override
  public Object getPrimitiveJavaObject(Object o) {
    LongWritable writable = (LongWritable) getPrimitiveWritableObject(o);
    return writable == null ? null : Long.valueOf(writable.get());
  }
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

                                                          true, input.useVInts());
    return latestRead;
  }

  private LongWritable createWritable(Object previous, long v) throws IOException {
    LongWritable result = null;
    if (previous == null) {
      result = new LongWritable();
    } else {
      result = (LongWritable) previous;
    }
    result.set(v);
    return result;
  }
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

    return readLong();
  }

  @Override
  public Object next(Object previous) throws IOException {
    LongWritable result = null;
    if (valuePresent) {
      result = createWritable(previous, readLong());
    }
    return result;
  }
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

    } else {
      assertEquals(expected.int1.intValue(), int1.get());
    }

    OrcLazyLong lazyLong1 = (OrcLazyLong) row.getFieldValue(4);
    LongWritable long1 = (LongWritable) lazyLong1.materialize();
    if (long1 == null) {
      assertNull(expected.long1);
    } else {
      assertEquals(expected.long1.longValue(), long1.get());
    }

    OrcLazyShort lazyShort2 = (OrcLazyShort) row.getFieldValue(5);
    ShortWritable short2 = (ShortWritable) lazyShort2.materialize();
    if (short2 == null) {
      assertNull(expected.short2);
    } else {
      assertEquals(expected.short2.shortValue(), short2.get());
    }

    OrcLazyInt lazyInt2 = (OrcLazyInt) row.getFieldValue(6);
    IntWritable int2 = (IntWritable) lazyInt2.materialize();
    if (int2 == null) {
      assertNull(expected.int2);
    } else {
      assertEquals(expected.int2.intValue(), int2.get());
    }

    OrcLazyLong lazyLong2 = (OrcLazyLong) row.getFieldValue(7);
    LongWritable long2 = (LongWritable) lazyLong2.materialize();
    if (long2 == null) {
      assertNull(expected.long2);
    } else {
      assertEquals(expected.long2.longValue(), long2.get());
    }

    OrcLazyShort lazyShort3 = (OrcLazyShort) row.getFieldValue(8);
    ShortWritable short3 = (ShortWritable) lazyShort3.materialize();
    if (short3 == null) {
      assertNull(expected.short3);
    } else {
      assertEquals(expected.short3.shortValue(), short3.get());
    }

    OrcLazyInt lazyInt3 = (OrcLazyInt) row.getFieldValue(9);
    IntWritable int3 = (IntWritable) lazyInt3.materialize();
    if (int3 == null) {
      assertNull(expected.int3);
    } else {
      assertEquals(expected.int3.intValue(), int3.get());
    }

    OrcLazyLong lazyLong3 = (OrcLazyLong) row.getFieldValue(10);
    LongWritable long3 = (LongWritable) lazyLong3.materialize();
    if (long3 == null) {
      assertNull(expected.long3);
    } else {
      assertEquals(expected.long3.longValue(), long3.get());
    }

    OrcLazyFloat lazyFloat1 = (OrcLazyFloat) row.getFieldValue(11);
    FloatWritable float1 = (FloatWritable) lazyFloat1.materialize();
    if (float1 == null) {
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

  private long latestValue() {
    return latestValue;
  }

  private LongWritable createWritable(Object previous, long v) throws IOException {
    LongWritable result = null;
    if (previous == null) {
      result = new LongWritable();
    } else {
      result = (LongWritable) previous;
    }
    result.set(v);
    return result;
  }
View Full Code Here

Examples of org.apache.hadoop.io.LongWritable

    return readLong();
  }

  @Override
  public Object next(Object previous) throws IOException {
    LongWritable result = null;
    if (valuePresent) {
      result = createWritable(previous, readLong());
    }
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.