Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.Row


      final List<Action<R>> actions, final RegionAction.Builder regionActionBuilder,
      final ClientProtos.Action.Builder actionBuilder,
      final MutationProto.Builder mutationBuilder)
  throws IOException {
    for (Action<R> action: actions) {
      Row row = action.getAction();
      actionBuilder.clear();
      actionBuilder.setIndex(action.getOriginalIndex());
      mutationBuilder.clear();
      if (row instanceof Get) {
        Get g = (Get)row;
        regionActionBuilder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
      } else if (row instanceof Put) {
        regionActionBuilder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutation(MutationType.PUT, (Put)row, mutationBuilder)));
      } else if (row instanceof Delete) {
        regionActionBuilder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutation(MutationType.DELETE, (Delete)row, mutationBuilder)));
      } else if (row instanceof Append) {
        regionActionBuilder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutation(MutationType.APPEND, (Append)row, mutationBuilder)));
      } else if (row instanceof Increment) {
        regionActionBuilder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutation((Increment)row, mutationBuilder)));
      } else if (row instanceof RowMutations) {
        throw new UnsupportedOperationException("No RowMutations in multi calls; use mutateRow");
      } else {
        throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
      }
    }
    return regionActionBuilder;
  }
View Full Code Here


      final MutationProto.Builder mutationBuilder)
  throws IOException {
    RegionAction.Builder builder =
      getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
    for (Action<R> action: actions) {
      Row row = action.getAction();
      actionBuilder.clear();
      actionBuilder.setIndex(action.getOriginalIndex());
      mutationBuilder.clear();
      if (row instanceof Get) {
        Get g = (Get)row;
        builder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
      } else if (row instanceof Put) {
        Put p = (Put)row;
        cells.add(p);
        builder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutationNoData(MutationType.PUT, p, mutationBuilder)));
      } else if (row instanceof Delete) {
        Delete d = (Delete)row;
        int size = d.size();
        // Note that a legitimate Delete may have a size of zero; i.e. a Delete that has nothing
        // in it but the row to delete.  In this case, the current implementation does not make
        // a KeyValue to represent a delete-of-all-the-row until we serialize... For such cases
        // where the size returned is zero, we will send the Delete fully pb'd rather than have
        // metadata only in the pb and then send the kv along the side in cells.
        if (size > 0) {
          cells.add(d);
          builder.addAction(actionBuilder.
            setMutation(ProtobufUtil.toMutationNoData(MutationType.DELETE, d, mutationBuilder)));
        } else {
          builder.addAction(actionBuilder.
            setMutation(ProtobufUtil.toMutation(MutationType.DELETE, d, mutationBuilder)));
        }
      } else if (row instanceof Append) {
        Append a = (Append)row;
        cells.add(a);
        builder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutationNoData(MutationType.APPEND, a, mutationBuilder)));
      } else if (row instanceof Increment) {
        Increment i = (Increment)row;
        cells.add(i);
        builder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutationNoData(MutationType.INCREMENT, i, mutationBuilder)));
      } else if (row instanceof RowMutations) {
        continue; // ignore RowMutations
      } else {
        throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
      }
    }
    return builder;
  }
View Full Code Here

    checkResources();
    boolean isPut = w instanceof Put;
    if (!isPut && !(w instanceof Delete))
      throw new org.apache.hadoop.hbase.DoNotRetryIOException("Action must " +
          "be Put or Delete");
    Row r = (Row)w;
    if (!Bytes.equals(row, r.getRow())) {
      throw new org.apache.hadoop.hbase.DoNotRetryIOException("Action's " +
          "getRow must match the passed row");
    }

    startRegionOperation();
View Full Code Here

    //client if this becomes a global setting
    checkResources();
    boolean isPut = w instanceof Put;
    if (!isPut && !(w instanceof Delete))
      throw new DoNotRetryIOException("Action must be Put or Delete");
    Row r = (Row)w;
    if (!Bytes.equals(row, r.getRow())) {
      throw new DoNotRetryIOException("Action's getRow must match the passed row");
    }

    startRegionOperation();
    this.writeRequestsCount.increment();
View Full Code Here

      List<Action<R>> actionsForRegion = e.getValue();
      // sort based on the row id - this helps in the case where we reach the
      // end of a region, so that we don't have to try the rest of the
      // actions in the list.
      Collections.sort(actionsForRegion);
      Row action;
      List<Action<R>> puts = new ArrayList<Action<R>>();
      for (Action<R> a : actionsForRegion) {
        action = a.getAction();
        int originalIndex = a.getOriginalIndex();
View Full Code Here

    int batchSize = actions.size();
    int dataSize = 0;
    Map<HRegionInfo, List<Action<Row>>> actionsByRegion =
        new HashMap<HRegionInfo, List<Action<Row>>>();
    HRegionLocation loc = null;
    Row row = null;
    List<Action<Row>> regionActions = null;
    // Build the action list.
    for (int i = 0; i < batchSize; i++) {
      loc = actions.get(i).getFirst();
      row = actions.get(i).getSecond();
      if (actionsByRegion.containsKey(loc.getRegionInfo())) {
        regionActions = actionsByRegion.get(loc.getRegionInfo());
      } else {
        regionActions = new ArrayList<Action<Row>>();
        actionsByRegion.put(loc.getRegionInfo(), regionActions);
      }
      Action<Row> action = new Action<Row>(row, i);
      regionActions.add(action);
      dataSize += row.getRow().length;
    }
   
    long startTime = EnvironmentEdgeManager.currentTimeMillis();

    // replaying edits by region
View Full Code Here

        boolean needSkip = false;
        Put put = null;
        Delete del = null;
        KeyValue lastKV = null;
        HRegionLocation loc = null;
        Row preRow = null;
        HRegionLocation preLoc = null;
        Row lastAddedRow = null; // it is not really needed here just be conservative
        String preKey = null;
        List<KeyValue> kvs = edit.getKeyValues();
        HConnection hconn = this.getConnectionByTableName(table);

        for (KeyValue kv : kvs) {
View Full Code Here

    checkResources();
    boolean isPut = w instanceof Put;
    if (!isPut && !(w instanceof Delete))
      throw new org.apache.hadoop.hbase.DoNotRetryIOException("Action must " +
          "be Put or Delete");
    Row r = (Row)w;
    if (!Bytes.equals(row, r.getRow())) {
      throw new org.apache.hadoop.hbase.DoNotRetryIOException("Action's " +
          "getRow must match the passed row");
    }

    startRegionOperation();
View Full Code Here

      final List<Action<R>> actions)
  throws IOException {
    MultiRequest.Builder builder = getMultiRequestBuilderWithRegionAndAtomicSet(regionName, false);
    for (Action<R> action: actions) {
      MultiAction.Builder protoAction = MultiAction.newBuilder();
      Row row = action.getAction();
      if (row instanceof Get) {
        protoAction.setGet(ProtobufUtil.toGet((Get)row));
      } else if (row instanceof Put) {
        protoAction.setMutation(ProtobufUtil.toMutation(MutationType.PUT, (Put)row));
      } else if (row instanceof Delete) {
        protoAction.setMutation(ProtobufUtil.toMutation(MutationType.DELETE, (Delete)row));
      } else if (row instanceof Append) {
        protoAction.setMutation(ProtobufUtil.toMutation(MutationType.APPEND, (Append)row));
      } else if (row instanceof Increment) {
        protoAction.setMutation(ProtobufUtil.toMutation((Increment)row));
      } else if (row instanceof RowMutations) {
        continue; // ignore RowMutations
      } else {
        throw new DoNotRetryIOException(
          "multi doesn't support " + row.getClass().getName());
      }
      builder.addAction(protoAction.build());
    }
    return builder.build();
  }
View Full Code Here

      final List<Action<R>> actions, final List<CellScannable> cells)
  throws IOException {
    MultiRequest.Builder builder = getMultiRequestBuilderWithRegionAndAtomicSet(regionName, false);
    for (Action<R> action: actions) {
      MultiAction.Builder protoAction = MultiAction.newBuilder();
      Row row = action.getAction();
      if (row instanceof Get) {
        // Gets are carried by protobufs.
        protoAction.setGet(ProtobufUtil.toGet((Get)row));
      } else if (row instanceof Put) {
        Put p = (Put)row;
        cells.add(p);
        protoAction.setMutation(ProtobufUtil.toMutationNoData(MutationType.PUT, p));
      } else if (row instanceof Delete) {
        Delete d = (Delete)row;
        int size = d.size();
        // Note that a legitimate Delete may have a size of zero; i.e. a Delete that has nothing
        // in it but the row to delete.  In this case, the current implementation does not make
        // a KeyValue to represent a delete-of-all-the-row until we serialize... For such cases
        // where the size returned is zero, we will send the Delete fully pb'd rather than have
        // metadata only in the pb and then send the kv along the side in cells.
        if (size > 0) {
          cells.add(d);
          protoAction.setMutation(ProtobufUtil.toMutationNoData(MutationType.DELETE, d));
        } else {
          protoAction.setMutation(ProtobufUtil.toMutation(MutationType.DELETE, d));
        }
      } else if (row instanceof Append) {
        Append a = (Append)row;
        cells.add(a);
        protoAction.setMutation(ProtobufUtil.toMutationNoData(MutationType.APPEND, a));
      } else if (row instanceof Increment) {
        Increment i = (Increment)row;
        cells.add(i);
        protoAction.setMutation(ProtobufUtil.toMutationNoData(MutationType.INCREMENT, i));
      } else if (row instanceof RowMutations) {
        continue; // ignore RowMutations
      } else {
        throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
      }
      builder.addAction(protoAction.build());
    }
    return builder.build();
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.Row

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.