Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.DataInputBuffer$Buffer


        Scan.SCAN_ATTRIBUTES_METRICS_DATA);
    if (serializedMetrics == null || serializedMetrics.length == 0 ) {
      return;
    }

    DataInputBuffer in = new DataInputBuffer();
    in.reset(serializedMetrics, 0, serializedMetrics.length);
    ScanMetrics scanMetrics = new ScanMetrics();
    scanMetrics.readFields(in);
    MetricsTimeVaryingLong[] mlvs =
      scanMetrics.getMetricsTimeVaryingLongArray();
View Full Code Here


        }

        @SuppressWarnings({ "unchecked", "rawtypes" })
        private int compareBinInterSedesGenericWritableComparable(ByteBuffer bb1, ByteBuffer bb2) throws ExecException,
                IOException {
            DataInputBuffer buffer1 = new DataInputBuffer();
            DataInputBuffer buffer2 = new DataInputBuffer();
            buffer1.reset(bb1.array(), bb1.position(), bb1.remaining());
            buffer2.reset(bb2.array(), bb2.position(), bb2.remaining());
            Comparable writable1 = (Comparable) mSedes.readDatum(buffer1);
            Comparable writable2 = (Comparable) mSedes.readDatum(buffer2);
            bb1.position(buffer1.getPosition());
            bb2.position(buffer2.getPosition());
            return writable1.compareTo(writable2);
        }
View Full Code Here

            if (bsz1 > bsz2)
                return 1;
            else if (bsz1 < bsz2)
                return -1;
            else {
                DataInputBuffer buffer1 = new DataInputBuffer();
                DataInputBuffer buffer2 = new DataInputBuffer();
                buffer1.reset(bb1.array(), s1, l1);
                buffer2.reset(bb2.array(), s2, l2);
                DataBag bag1 = (DataBag) mSedes.readDatum(buffer1, dt1);
                DataBag bag2 = (DataBag) mSedes.readDatum(buffer2, dt2);
                bb1.position(buffer1.getPosition());
                bb2.position(buffer2.getPosition());
                return bag1.compareTo(bag2);
            }
        }
View Full Code Here

            if (bsz1 > bsz2)
                return 1;
            else if (bsz1 < bsz2)
                return -1;
            else {
                DataInputBuffer buffer1 = new DataInputBuffer();
                DataInputBuffer buffer2 = new DataInputBuffer();
                buffer1.reset(bb1.array(), s1, l1);
                buffer2.reset(bb2.array(), s2, l2);
                Map<String, Object> map1 = (Map<String, Object>) mSedes.readDatum(buffer1, dt1);
                Map<String, Object> map2 = (Map<String, Object>) mSedes.readDatum(buffer2, dt2);
                bb1.position(buffer1.getPosition());
                bb2.position(buffer2.getPosition());
                return DataType.compare(map1, map2, DataType.MAP, DataType.MAP);
            }
        }
View Full Code Here

    assertEquals(hri.getEncodedName(), deserializedHri.getEncodedName());
    assertEquals(hri, deserializedHri);

    //test toDelimitedByteArray()
    hrib = hri.toDelimitedByteArray();
    DataInputBuffer buf = new DataInputBuffer();
    try {
      buf.reset(hrib, hrib.length);
      deserializedHri = HRegionInfo.parseFrom(buf);
      assertEquals(hri.getEncodedName(), deserializedHri.getEncodedName());
      assertEquals(hri, deserializedHri);
    } finally {
      buf.close();
    }
  }
View Full Code Here

  private void readFields(byte[] bytes) throws IOException {
    if (bytes == null || bytes.length <= 0) {
      throw new IllegalArgumentException("Can't build a writable with empty " +
        "bytes array");
    }
    DataInputBuffer in = new DataInputBuffer();
    try {
      in.reset(bytes, 0, bytes.length);
      this.readFields(in);
    } finally {
      in.close();
    }
  }
View Full Code Here

  public static List<HRegionInfo> parseDelimitedFrom(final byte[] bytes, final int offset,
      final int length) throws IOException {
    if (bytes == null) {
      throw new IllegalArgumentException("Can't build an object with empty bytes array");
    }
    DataInputBuffer in = new DataInputBuffer();
    List<HRegionInfo> hris = new ArrayList<HRegionInfo>();
    try {
      in.reset(bytes, offset, length);
      while (in.available() > 0) {
        HRegionInfo hri = parseFrom(in);
        hris.add(hri);
      }
    } finally {
      in.close();
    }
    return hris;
  }
View Full Code Here

    long scannerId = -1L;
    try {
      scannerId =
        server.openScanner(t.regionInfo.regionName, META_COLUMNS, tableName);
     
      DataInputBuffer inbuf = new DataInputBuffer();
      while(true) {
        HRegionInfo regionInfo = null;
        String serverAddress = null;
        HStoreKey key = new HStoreKey();
        LabelledData[] values = server.next(scannerId, key);
        if(values.length == 0) {
          if(servers == 0) {
            // If we didn't find any servers then the table does not exist
           
            throw new NoSuchElementException("table '" + tableName
                + "' does not exist");
          }
         
          // We found at least one server for the table and now we're done.
         
          break;
        }

        byte[] bytes = null;
        TreeMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
        for(int i = 0; i < values.length; i++) {
          bytes = new byte[values[i].getData().getSize()];
          System.arraycopy(values[i].getData().get(), 0, bytes, 0, bytes.length);
          results.put(values[i].getLabel(), bytes);
        }
        regionInfo = new HRegionInfo();
        bytes = results.get(COL_REGIONINFO);
        inbuf.reset(bytes, bytes.length);
        regionInfo.readFields(inbuf);

        if(!regionInfo.tableDesc.getName().equals(tableName)) {
          // We're done
          break;
View Full Code Here

      try {
        scannerId = server.openScanner(t.regionInfo.regionName,
            META_COLUMNS, EMPTY_START_ROW);
       
        HStoreKey key = new HStoreKey();
        DataInputBuffer inbuf = new DataInputBuffer();
        while(true) {
          LabelledData[] values = server.next(scannerId, key);
          if(values.length == 0) {
            break;
          }
          for(int i = 0; i < values.length; i++) {
            if(values[i].getLabel().equals(COL_REGIONINFO)) {
              byte[] bytes = values[i].getData().get();
              inbuf.reset(bytes, bytes.length);
              HRegionInfo info = new HRegionInfo();
              info.readFields(inbuf);

              // Only examine the rows where the startKey is zero length  
              if(info.startKey.getLength() == 0) {
View Full Code Here

      IOException wrap = new IOException("Split class " + splitClass +
                                         " not found");
      wrap.initCause(exp);
      throw wrap;
    }
    DataInputBuffer splitBuffer = new DataInputBuffer();
    splitBuffer.reset(split.get(), 0, split.getSize());
    instantiatedSplit.readFields(splitBuffer);
   
    // if it is a file split, we can give more details
    if (instantiatedSplit instanceof FileSplit) {
      FileSplit fileSplit = (FileSplit) instantiatedSplit;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.DataInputBuffer$Buffer

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.