Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.WritableComparable


    if (mw == null) {
      mw = new SortedMapWritable();
    }
    int length = in.readMapHeader();
    for (int i = 0; i < length; i++) {
      WritableComparable key = (WritableComparable) read();
      Writable value = read();
      mw.put(key, value);
    }
    return mw;
  }
View Full Code Here


    final Hit[] hitArr = new Hit[docList.size()];
    for (int i = 0; i < hitArr.length; i++) {
      final SolrDocument solrDoc = docList.get(i);

      final Object raw = solrDoc.getFirstValue(sortField);
      WritableComparable sortValue;

      if (raw instanceof Integer) {
        sortValue = new IntWritable(((Integer)raw).intValue());
      } else if (raw instanceof Float) {
        sortValue = new FloatWritable(((Float)raw).floatValue());
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

    PriorityBuffer reheap = new PriorityBuffer(heap.size());
    boolean result = false;
    for (Object obj : heap) {
      Index index = (Index) obj;
      try {
        WritableComparable found = index.reader.getClosest(key, index.value, true);
        if (found != null && found.compareTo(key) == 0) {
          result = true;
        }
      } catch (EOFException ex) {
        // thrown if key is beyond all data in the map
      }
View Full Code Here

    Configuration conf = CachedConfiguration.getInstance();
    FileSystem fs = FileSystem.getLocal(conf);
    MyMapFile.Reader reader = new MyMapFile.Reader(fs, in, conf);
    MyMapFile.Writer writer = new MyMapFile.Writer(conf, fs, out, reader.getKeyClass(), reader.getValueClass());
   
    WritableComparable key = (WritableComparable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
    Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
   
    while (reader.next(key, value))
      // copy all entries
      writer.append(key, value);
View Full Code Here

      indexInfo.keys = new WritableComparable[1024];
      indexInfo.positions = new long[1024];
      try {
        int skip = INDEX_SKIP;
        LongWritable position = new LongWritable();
        WritableComparable lastKey = null;
        while (true) {
          WritableComparable k = comparator.newKey();
         
          if (!index.next(k, position))
            break;
         
          // check order to make sure comparator is compatible
View Full Code Here

      int low = 0;
      int high = indexInfo.count - 1;
     
      while (low <= high) {
        int mid = (low + high) >>> 1;
        WritableComparable midVal = indexInfo.keys[mid];
        int cmp = comparator.compare(midVal, key);
       
        if (cmp < 0)
          low = mid + 1;
        else if (cmp > 0)
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

      if (fileName.startsWith("_") || fileName.startsWith(".")) {
        continue;
      }

      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      WritableComparable key = (WritableComparable)
          reader.getKeyClass().newInstance();
      Writable value = (Writable) reader.getValueClass().newInstance();
      while (reader.next(key, value)) {
        strings.add(value.toString());
      }
View Full Code Here

      MapWritable meta = datum.getMetaData();
      if (meta.size() > 0) {
        MapWritable newMeta = new MapWritable();
        Iterator it = meta.keySet().iterator();
        while (it.hasNext()) {
          WritableComparable k = (WritableComparable)it.next();
          Writable v = meta.get(k);
          if (k instanceof UTF8) {
            Text t = new Text(k.toString());
            k = t;
          }
          newMeta.put(k, v);
        }
        datum.setMetaData(newMeta);
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.