Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.WritableComparable


  throws IOException {
    if (top) {
      super.finalKey(key);
    } else {
      Writable value = new ImmutableBytesWritable();
      WritableComparable found = super.getClosest(midkey, value, true);
      Writables.copyWritable(found, key);
    }
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  @Override
  public synchronized WritableComparable getClosest(WritableComparable key,
    Writable val)
  throws IOException {
    WritableComparable closest = null;
    if (top) {
      // If top, the lowest possible key is first key.  Do not have to check
      // what comes back from super getClosest.  Will return exact match or
      // greater.
      closest = (key.compareTo(this.midkey) < 0)?
        this.midkey: super.getClosest(key, val);
      // we know that we just went past the midkey
      firstNextCall = false;
    } else {
      // We're serving bottom of the file.
      if (key.compareTo(this.midkey) < 0) {
        // Check key is within range for bottom.
        closest = super.getClosest(key, val);
        // midkey was made against largest store file at time of split. Smaller
        // store files could have anything in them.  Check return value is
        // not beyond the midkey (getClosest returns exact match or next after)
        if (closest != null && closest.compareTo(this.midkey) >= 0) {
          // Don't let this value out.
          closest = null;
        }
      }
      // Else, key is > midkey so let out closest = null.
View Full Code Here

    if (firstNextCall) {
      firstNextCall = false;
      if (this.top) {
        // Seek to midkey.  Midkey may not exist in this file.  That should be
        // fine.  Then we'll either be positioned at end or start of file.
        WritableComparable nearest = getClosest(this.midkey, val);
        // Now copy the midkey into the passed key.
        if (nearest != null) {
          Writables.copyWritable(nearest, key);
          return true;
        }
View Full Code Here

    if (ret != 0) {
      return ret;
    }

    for (int i = 0; i < k1.size(); i++) {
      WritableComparable key_1 = (WritableComparable) k1.get(i);
      WritableComparable key_2 = (WritableComparable) k2.get(i);
      if (key_1 == null && key_2 == null) {
        return -1; // just return k1 is smaller than k2
      } else if (key_1 == null) {
        return -1;
      } else if (key_2 == null) {
View Full Code Here

      if (top) {
        super.finalKey(key);
      } else {
        reset();
        Writable value = new ImmutableBytesWritable();
        WritableComparable k = super.getClosest(midkey, value, true);
        ByteArrayOutputStream byteout = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(byteout);
        k.write(out);
        ByteArrayInputStream bytein =
          new ByteArrayInputStream(byteout.toByteArray());
        DataInputStream in = new DataInputStream(bytein);
        key.readFields(in);
      }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public synchronized WritableComparable getClosest(WritableComparable key,
      Writable val)
    throws IOException {
      WritableComparable closest = null;
      if (top) {
        // If top, the lowest possible key is midkey.  Do not have to check
        // what comes back from super getClosest.  Will return exact match or
        // greater.
        closest = (key.compareTo(this.midkey) < 0)?
          this.midkey: super.getClosest(key, val);
      } else {
        // We're serving bottom of the file.
        if (key.compareTo(this.midkey) < 0) {
          // Check key is within range for bottom.
          closest = super.getClosest(key, val);
          // midkey was made against largest store file at time of split. Smaller
          // store files could have anything in them.  Check return value is
          // not beyond the midkey (getClosest returns exact match or next
          // after).
          if (closest != null && closest.compareTo(this.midkey) >= 0) {
            // Don't let this value out.
            closest = null;
          }
        }
        // Else, key is > midkey so let out closest = null.
View Full Code Here

      if (firstNextCall) {
        firstNextCall = false;
        if (this.top) {
          // Seek to midkey.  Midkey may not exist in this file.  That should be
          // fine.  Then we'll either be positioned at end or start of file.
          WritableComparable nearest = getClosest(midkey, val);
          // Now copy the mid key into the passed key.
          if (nearest != null) {
            Writables.copyWritable(nearest, key);
            return true;
          }
View Full Code Here

    if (ret != 0) {
      return ret;
    }

    for (int i = 0; i < k1.size(); i++) {
      WritableComparable key_1 = (WritableComparable) k1.get(i);
      WritableComparable key_2 = (WritableComparable) k2.get(i);
      if (key_1 == null && key_2 == null) {
        return nullsafes != null && nullsafes[i] ? 0 : -1; // just return k1 is smaller than k2
      } else if (key_1 == null) {
        return -1;
      } else if (key_2 == null) {
View Full Code Here

    Hit[] hits = new Hit[length];
    for (int i = 0; i < length; i++) {
     
      int doc = scoreDocs[i].doc;
     
      WritableComparable sortValue;               // convert value to writable
      if (sortField == null) {
        sortValue = new FloatWritable(scoreDocs[i].score);
      } else {
        Object raw = ((FieldDoc)scoreDocs[i]).fields[0];
        if (raw instanceof Integer) {
View Full Code Here

    }

    for (int i = 0; i < top.length; i++) {
      String uniqueKey = Text.readString(in);            // read uniqueKey

      WritableComparable sortValue = null;
      try {
        sortValue = (WritableComparable)sortClass.newInstance();
      } catch (Exception e) {
        throw new IOException(e.toString());
      }
      sortValue.readFields(in);                   // read sortValue

      String dedupValue = Text.readString(in);    // read dedupValue

      top[i] = new Hit(uniqueKey, sortValue, dedupValue);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.WritableComparable

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.