Java 类org.apache.hadoop.hbase.protobuf.generated.MapReduceProtos 实例源码

项目:ditb    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  Parser<MapReduceProtos.ScanMetrics> parser = MapReduceProtos.ScanMetrics.PARSER;
  MapReduceProtos.ScanMetrics pScanMetrics = null;
  try {
    pScanMetrics = parser.parseFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  ScanMetrics scanMetrics = new ScanMetrics();
  if (pScanMetrics != null) {
    for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
      if (pair.hasName() && pair.hasValue()) {
        scanMetrics.setCounter(pair.getName(), pair.getValue());
      }
    }
  }
  return scanMetrics;
}
项目:pbase    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  Parser<MapReduceProtos.ScanMetrics> parser = MapReduceProtos.ScanMetrics.PARSER;
  MapReduceProtos.ScanMetrics pScanMetrics = null;
  try {
    pScanMetrics = parser.parseFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  ScanMetrics scanMetrics = new ScanMetrics();
  if (pScanMetrics != null) {
    for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
      if (pair.hasName() && pair.hasValue()) {
        scanMetrics.setCounter(pair.getName(), pair.getValue());
      }
    }
  }
  return scanMetrics;
}
项目:HIndex    文件:TableSnapshotInputFormatImpl.java   
@Override
public void write(DataOutput out) throws IOException {
  MapReduceProtos.TableSnapshotRegionSplit.Builder builder =
    MapReduceProtos.TableSnapshotRegionSplit.newBuilder()
      .setRegion(HBaseProtos.RegionSpecifier.newBuilder()
        .setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.ENCODED_REGION_NAME)
        .setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(regionName))).build());

  for (String location : locations) {
    builder.addLocations(location);
  }

  MapReduceProtos.TableSnapshotRegionSplit split = builder.build();

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  split.writeTo(baos);
  baos.close();
  byte[] buf = baos.toByteArray();
  out.writeInt(buf.length);
  out.write(buf);
}
项目:HIndex    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  Parser<MapReduceProtos.ScanMetrics> parser = MapReduceProtos.ScanMetrics.PARSER;
  MapReduceProtos.ScanMetrics pScanMetrics = null;
  try {
    pScanMetrics = parser.parseFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  ScanMetrics scanMetrics = new ScanMetrics();
  if (pScanMetrics != null) {
    for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
      if (pair.hasName() && pair.hasValue()) {
        scanMetrics.setCounter(pair.getName(), pair.getValue());
      }
    }
  }
  return scanMetrics;
}
项目:hbase    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  Parser<MapReduceProtos.ScanMetrics> parser = MapReduceProtos.ScanMetrics.PARSER;
  MapReduceProtos.ScanMetrics pScanMetrics = null;
  try {
    pScanMetrics = parser.parseFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  ScanMetrics scanMetrics = new ScanMetrics();
  if (pScanMetrics != null) {
    for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
      if (pair.hasName() && pair.hasValue()) {
        scanMetrics.setCounter(pair.getName(), pair.getValue());
      }
    }
  }
  return scanMetrics;
}
项目:PyroDB    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  Parser<MapReduceProtos.ScanMetrics> parser = MapReduceProtos.ScanMetrics.PARSER;
  MapReduceProtos.ScanMetrics pScanMetrics = null;
  try {
    pScanMetrics = parser.parseFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  ScanMetrics scanMetrics = new ScanMetrics();
  if (pScanMetrics != null) {
    for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
      if (pair.hasName() && pair.hasValue()) {
        scanMetrics.setCounter(pair.getName(), pair.getValue());
      }
    }
  }
  return scanMetrics;
}
项目:c5    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  Parser<MapReduceProtos.ScanMetrics> parser = MapReduceProtos.ScanMetrics.PARSER;
  MapReduceProtos.ScanMetrics pScanMetrics = null;
  try {
    pScanMetrics = parser.parseFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  ScanMetrics scanMetrics = new ScanMetrics();
  if (pScanMetrics != null) {
    for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
      if (pair.hasName() && pair.hasValue()) {
        scanMetrics.setCounter(pair.getName(), pair.getValue());
      }
    }
  }
  return scanMetrics;
}
项目:DominoHBase    文件:ProtobufUtil.java   
public static ScanMetrics toScanMetrics(final byte[] bytes) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  try {
    builder.mergeFrom(bytes);
  } catch (InvalidProtocolBufferException e) {
    //Ignored there are just no key values to add.
  }
  MapReduceProtos.ScanMetrics pScanMetrics = builder.build();
  ScanMetrics scanMetrics = new ScanMetrics();
  for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
    if (pair.hasName() && pair.hasValue()) {
      scanMetrics.setCounter(pair.getName(), pair.getValue());
    }
  }
  return scanMetrics;
}
项目:ditb    文件:ProtobufUtil.java   
public static MapReduceProtos.ScanMetrics toScanMetrics(ScanMetrics scanMetrics) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  Map<String, Long> metrics = scanMetrics.getMetricsMap();
  for (Entry<String, Long> e : metrics.entrySet()) {
    HBaseProtos.NameInt64Pair nameInt64Pair =
        HBaseProtos.NameInt64Pair.newBuilder()
            .setName(e.getKey())
            .setValue(e.getValue())
            .build();
    builder.addMetrics(nameInt64Pair);
  }
  return builder.build();
}
项目:pbase    文件:ProtobufUtil.java   
public static MapReduceProtos.ScanMetrics toScanMetrics(ScanMetrics scanMetrics) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  Map<String, Long> metrics = scanMetrics.getMetricsMap();
  for (Entry<String, Long> e : metrics.entrySet()) {
    HBaseProtos.NameInt64Pair nameInt64Pair =
        HBaseProtos.NameInt64Pair.newBuilder()
            .setName(e.getKey())
            .setValue(e.getValue())
            .build();
    builder.addMetrics(nameInt64Pair);
  }
  return builder.build();
}
项目:HIndex    文件:TableSnapshotInputFormatImpl.java   
@Override
public void readFields(DataInput in) throws IOException {
  int len = in.readInt();
  byte[] buf = new byte[len];
  in.readFully(buf);
  MapReduceProtos.TableSnapshotRegionSplit split = MapReduceProtos.TableSnapshotRegionSplit.PARSER.parseFrom(buf);
  this.regionName = Bytes.toString(split.getRegion().getValue().toByteArray());
  List<String> locationsList = split.getLocationsList();
  this.locations = locationsList.toArray(new String[locationsList.size()]);
}
项目:HIndex    文件:ProtobufUtil.java   
public static MapReduceProtos.ScanMetrics toScanMetrics(ScanMetrics scanMetrics) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  Map<String, Long> metrics = scanMetrics.getMetricsMap();
  for (Entry<String, Long> e : metrics.entrySet()) {
    HBaseProtos.NameInt64Pair nameInt64Pair =
        HBaseProtos.NameInt64Pair.newBuilder()
            .setName(e.getKey())
            .setValue(e.getValue())
            .build();
    builder.addMetrics(nameInt64Pair);
  }
  return builder.build();
}
项目:PyroDB    文件:ProtobufUtil.java   
public static MapReduceProtos.ScanMetrics toScanMetrics(ScanMetrics scanMetrics) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  Map<String, Long> metrics = scanMetrics.getMetricsMap();
  for (Entry<String, Long> e : metrics.entrySet()) {
    HBaseProtos.NameInt64Pair nameInt64Pair =
        HBaseProtos.NameInt64Pair.newBuilder()
            .setName(e.getKey())
            .setValue(e.getValue())
            .build();
    builder.addMetrics(nameInt64Pair);
  }
  return builder.build();
}
项目:c5    文件:ProtobufUtil.java   
public static MapReduceProtos.ScanMetrics toScanMetrics(ScanMetrics scanMetrics) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  Map<String, Long> metrics = scanMetrics.getMetricsMap();
  for (Entry<String, Long> e : metrics.entrySet()) {
    HBaseProtos.NameInt64Pair nameInt64Pair =
        HBaseProtos.NameInt64Pair.newBuilder()
            .setName(e.getKey())
            .setValue(e.getValue())
            .build();
    builder.addMetrics(nameInt64Pair);
  }
  return builder.build();
}
项目:DominoHBase    文件:ProtobufUtil.java   
public static MapReduceProtos.ScanMetrics toScanMetrics(ScanMetrics scanMetrics) {
  MapReduceProtos.ScanMetrics.Builder builder = MapReduceProtos.ScanMetrics.newBuilder();
  Map<String, Long> metrics = scanMetrics.getMetricsMap();
  for (Entry<String, Long> e : metrics.entrySet()) {
    HBaseProtos.NameInt64Pair nameInt64Pair =
        HBaseProtos.NameInt64Pair.newBuilder()
            .setName(e.getKey())
            .setValue(e.getValue())
            .build();
    builder.addMetrics(nameInt64Pair);
  }
  return builder.build();
}
项目:ditb    文件:ClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use
 * metrics framework because it doesn't support multi-instances of the same metrics on the same
 * machine; for scan/map reduce scenarios, we will have multiple scans running at the same time.
 *
 * By default, scan metrics are disabled; if the application wants to collect them, this
 * behavior can be turned on by calling calling {@link Scan#setScanMetricsEnabled(boolean)}
 * 
 * <p>This invocation clears the scan metrics. Metrics are aggregated in the Scan instance.
 */
protected void writeScanMetrics() {
  if (this.scanMetrics == null || scanMetricsPublished) {
    return;
  }
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
  scanMetricsPublished = true;
}
项目:pbase    文件:ClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use metrics
 * framework because it doesn't support multi-instances of the same metrics on the same machine;
 * for scan/map reduce scenarios, we will have multiple scans running at the same time.
 *
 * By default, scan metrics are disabled; if the application wants to collect them, this
 * behavior can be turned on by calling calling {@link Scan#setScanMetricsEnabled(boolean)}
 *
 * <p>This invocation clears the scan metrics. Metrics are aggregated in the Scan instance.
 */
protected void writeScanMetrics() {
  if (this.scanMetrics == null || scanMetricsPublished) {
    return;
  }
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
  scanMetricsPublished = true;
}
项目:HIndex    文件:ClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use metrics
 * framework because it doesn't support multi-instances of the same metrics on the same machine;
 * for scan/map reduce scenarios, we will have multiple scans running at the same time.
 *
 * By default, scan metrics are disabled; if the application wants to collect them, this behavior
 * can be turned on by calling calling:
 *
 * scan.setAttribute(SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE))
 */
protected void writeScanMetrics() {
  if (this.scanMetrics == null || scanMetricsPublished) {
    return;
  }
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
  scanMetricsPublished = true;
}
项目:PyroDB    文件:ClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use metrics
 * framework because it doesn't support multi-instances of the same metrics on the same machine;
 * for scan/map reduce scenarios, we will have multiple scans running at the same time.
 *
 * By default, scan metrics are disabled; if the application wants to collect them, this behavior
 * can be turned on by calling calling:
 *
 * scan.setAttribute(SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE))
 */
protected void writeScanMetrics() {
  if (this.scanMetrics == null || scanMetricsPublished) {
    return;
  }
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
  scanMetricsPublished = true;
}
项目:c5    文件:ClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use metrics
 * framework because it doesn't support multi-instances of the same metrics on the same machine;
 * for scan/map reduce scenarios, we will have multiple scans running at the same time.
 *
 * By default, scan metrics are disabled; if the application wants to collect them, this behavior
 * can be turned on by calling calling:
 *
 * scan.setAttribute(SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE))
 */
protected void writeScanMetrics() {
  if (this.scanMetrics == null || scanMetricsPublished) {
    return;
  }
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
  scanMetricsPublished = true;
}
项目:async-hbase-client    文件:AsyncClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use metrics
 * framework because it doesn't support multi-instances of the same metrics on the same machine;
 * for scan/map reduce scenarios, we will have multiple scans running at the same time.
 * <p/>
 * By default, scan metrics are disabled; if the application wants to collect them, this behavior
 * can be turned on by calling calling:
 * <p/>
 * scan.setAttribute(SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE))
 */
protected void writeScanMetrics() {
  if (this.scanMetrics == null || scanMetricsPublished) {
    return;
  }
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
  scanMetricsPublished = true;
}
项目:DominoHBase    文件:ClientScanner.java   
/**
 * Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the
 * application or TableInputFormat.Later, we could push it to other systems. We don't use metrics
 * framework because it doesn't support multi-instances of the same metrics on the same machine;
 * for scan/map reduce scenarios, we will have multiple scans running at the same time.
 *
 * By default, scan metrics are disabled; if the application wants to collect them, this behavior
 * can be turned on by calling calling:
 *
 * scan.setAttribute(SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE))
 */
private void writeScanMetrics() throws IOException {
  if (this.scanMetrics == null) {
    return;
  }
  final DataOutputBuffer d = new DataOutputBuffer();
  MapReduceProtos.ScanMetrics pScanMetrics = ProtobufUtil.toScanMetrics(scanMetrics);
  scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA, pScanMetrics.toByteArray());
}