当前位置: 首页>>代码示例>>Java>>正文


Java MutationType.PUT属性代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT属性的典型用法代码示例。如果您正苦于以下问题:Java MutationType.PUT属性的具体用法?Java MutationType.PUT怎么用?Java MutationType.PUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType的用法示例。


在下文中一共展示了MutationType.PUT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRegionAction

/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:RequestConverter.java

示例2: buildNoDataRegionAction

/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:RequestConverter.java

示例3: serialize

@Override
public void serialize(Mutation mutation) throws IOException {
  MutationType type;
  if (mutation instanceof Put) {
    type = MutationType.PUT;
  } else if (mutation instanceof Delete) {
    type = MutationType.DELETE;
  } else {
    throw new IllegalArgumentException("Only Put and Delete are supported");
  }
  ProtobufUtil.toMutation(type, mutation).writeDelimitedTo(out);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:MutationSerialization.java

示例4: replayEdit

static int replayEdit(HRegion region, WAL.Entry entry) throws IOException {
  if (WALEdit.isMetaEditFamily(entry.getEdit().getCells().get(0))) {
    return 0; // handled elsewhere
  }
  Put put = new Put(entry.getEdit().getCells().get(0).getRow());
  for (Cell cell : entry.getEdit().getCells()) put.add(cell);
  put.setDurability(Durability.SKIP_WAL);
  MutationReplay mutation = new MutationReplay(MutationType.PUT, put, 0, 0);
  region.batchReplay(new MutationReplay[] {mutation},
    entry.getKey().getLogSeqNum());
  return Integer.parseInt(Bytes.toString(put.getRow()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestHRegionReplayEvents.java

示例5: buildMutateRequest

/**
 * Create a protocol buffer MutateRequest for conditioned row mutations
 *
 * @param regionName
 * @param row
 * @param family
 * @param qualifier
 * @param comparator
 * @param compareType
 * @param rowMutations
 * @return a mutate request
 * @throws IOException
 */
public static ClientProtos.MultiRequest buildMutateRequest(
    final byte[] regionName, final byte[] row, final byte[] family,
    final byte [] qualifier, final ByteArrayComparable comparator,
    final CompareType compareType, final RowMutations rowMutations) throws IOException {
  RegionAction.Builder builder =
      getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  builder.setAtomic(true);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  Condition condition = buildCondition(
      row, family, qualifier, comparator, compareType);
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
          mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  ClientProtos.MultiRequest request =
      ClientProtos.MultiRequest.newBuilder().addRegionAction(builder.build())
          .setCondition(condition).build();
  return request;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:45,代码来源:RequestConverter.java

示例6: toMutation

/**
 * Convert a MutateRequest to Mutation
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted Mutation
 * @throws IOException
 */
public static Mutation toMutation(final MutationProto proto) throws IOException {
  MutationType type = proto.getMutateType();
  if (type == MutationType.APPEND) {
    return toAppend(proto, null);
  }
  if (type == MutationType.DELETE) {
    return toDelete(proto, null);
  }
  if (type == MutationType.PUT) {
    return toPut(proto, null);
  }
  throw new IOException("Unknown mutation type " + type);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:ProtobufUtil.java

示例7: getType

private static MutationType getType(Mutation mutation) {
  if (mutation instanceof Put) {
    return MutationType.PUT;
  } else if (mutation instanceof Delete) {
    return MutationType.DELETE;
  } else {
    // Increment and Append are not idempotent.  They should not be used in distributed jobs.
    throw new IllegalArgumentException("Only Put and Delete are supported");
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:10,代码来源:HBaseMutationCoder.java

示例8: doReplayBatchOp

/**
 * Execute a list of Put/Delete mutations. The function returns OperationStatus instead of
 * constructing MultiResponse to save a possible loop if caller doesn't need MultiResponse.
 * @param region
 * @param mutations
 * @return an array of OperationStatus which internally contains the OperationStatusCode and the
 *         exceptionMessage if any
 * @throws IOException
 */
protected OperationStatus [] doReplayBatchOp(final HRegion region,
    final List<HLogSplitter.MutationReplay> mutations) throws IOException {
  HLogSplitter.MutationReplay[] mArray = new HLogSplitter.MutationReplay[mutations.size()];

  long before = EnvironmentEdgeManager.currentTimeMillis();
  boolean batchContainsPuts = false, batchContainsDelete = false;
  try {
    int i = 0;
    for (HLogSplitter.MutationReplay m : mutations) {
      if (m.type == MutationType.PUT) {
        batchContainsPuts = true;
      } else {
        batchContainsDelete = true;
      }
      mArray[i++] = m;
    }
    requestCount.add(mutations.size());
    if (!region.getRegionInfo().isMetaTable()) {
      cacheFlusher.reclaimMemStoreMemory();
    }
    return region.batchReplay(mArray);
  } finally {
    long after = EnvironmentEdgeManager.currentTimeMillis();
    if (batchContainsPuts) {
      metricsRegionServer.updatePut(after - before);
    }
    if (batchContainsDelete) {
      metricsRegionServer.updateDelete(after - before);
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:40,代码来源:HRegionServer.java

示例9: doReplayBatchOp

/**
 * Execute a list of Put/Delete mutations. The function returns OperationStatus instead of
 * constructing MultiResponse to save a possible loop if caller doesn't need MultiResponse.
 * @param region
 * @param mutations
 * @return an array of OperationStatus which internally contains the OperationStatusCode and the
 *         exceptionMessage if any
 * @throws IOException
 */
private OperationStatus [] doReplayBatchOp(final HRegion region,
    final List<HLogSplitter.MutationReplay> mutations) throws IOException {
  HLogSplitter.MutationReplay[] mArray = new HLogSplitter.MutationReplay[mutations.size()];

  long before = EnvironmentEdgeManager.currentTimeMillis();
  boolean batchContainsPuts = false, batchContainsDelete = false;
  try {
    int i = 0;
    for (HLogSplitter.MutationReplay m : mutations) {
      if (m.type == MutationType.PUT) {
        batchContainsPuts = true;
      } else {
        batchContainsDelete = true;
      }
      mArray[i++] = m;
    }
    requestCount.add(mutations.size());
    if (!region.getRegionInfo().isMetaTable()) {
      regionServer.cacheFlusher.reclaimMemStoreMemory();
    }
    return region.batchReplay(mArray);
  } finally {
    if (regionServer.metricsRegionServer != null) {
      long after = EnvironmentEdgeManager.currentTimeMillis();
        if (batchContainsPuts) {
        regionServer.metricsRegionServer.updatePut(after - before);
      }
      if (batchContainsDelete) {
        regionServer.metricsRegionServer.updateDelete(after - before);
      }
    }
  }
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:42,代码来源:RSRpcServices.java

示例10: doBatchOp

/**
 * Execute a list of Put/Delete mutations. The function returns OperationStatus instead of
 * constructing MultiResponse to save a possible loop if caller doesn't need MultiResponse.
 * @param region
 * @param mutations
 * @param isReplay
 * @return an array of OperationStatus which internally contains the OperationStatusCode and the
 *         exceptionMessage if any
 * @throws IOException
 */
protected OperationStatus [] doBatchOp(final HRegion region,
    final List<Pair<MutationType, Mutation>> mutations, boolean isReplay)
throws IOException {
  Mutation[] mArray = new Mutation[mutations.size()];
  long before = EnvironmentEdgeManager.currentTimeMillis();
  boolean batchContainsPuts = false, batchContainsDelete = false;
  try {
    int i = 0;
    for (Pair<MutationType, Mutation> m : mutations) {
      if (m.getFirst() == MutationType.PUT) {
        batchContainsPuts = true;
      } else {
        batchContainsDelete = true;
      }
      mArray[i++] = m.getSecond();
    }
    requestCount.add(mutations.size());
    if (!region.getRegionInfo().isMetaTable()) {
      cacheFlusher.reclaimMemStoreMemory();
    }
    return region.batchMutate(mArray, isReplay);
  } finally {
    long after = EnvironmentEdgeManager.currentTimeMillis();
    if (batchContainsPuts) {
      metricsRegionServer.updatePut(after - before);
    }
    if (batchContainsDelete) {
      metricsRegionServer.updateDelete(after - before);
    }
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:41,代码来源:HRegionServer.java

示例11: doReplayBatchOp

/**
 * Execute a list of Put/Delete mutations. The function returns OperationStatus instead of
 * constructing MultiResponse to save a possible loop if caller doesn't need MultiResponse.
 * @param region
 * @param mutations
 * @param replaySeqId
 * @return an array of OperationStatus which internally contains the OperationStatusCode and the
 *         exceptionMessage if any
 * @throws IOException
 */
private OperationStatus [] doReplayBatchOp(final Region region,
    final List<WALSplitter.MutationReplay> mutations, long replaySeqId) throws IOException {
  long before = EnvironmentEdgeManager.currentTime();
  boolean batchContainsPuts = false, batchContainsDelete = false;
  try {
    for (Iterator<WALSplitter.MutationReplay> it = mutations.iterator(); it.hasNext();) {
      WALSplitter.MutationReplay m = it.next();

      if (m.type == MutationType.PUT) {
        batchContainsPuts = true;
      } else {
        batchContainsDelete = true;
      }

      NavigableMap<byte[], List<Cell>> map = m.mutation.getFamilyCellMap();
      List<Cell> metaCells = map.get(WALEdit.METAFAMILY);
      if (metaCells != null && !metaCells.isEmpty()) {
        for (Cell metaCell : metaCells) {
          CompactionDescriptor compactionDesc = WALEdit.getCompaction(metaCell);
          boolean isDefaultReplica = RegionReplicaUtil.isDefaultReplica(region.getRegionInfo());
          HRegion hRegion = (HRegion)region;
          if (compactionDesc != null) {
            // replay the compaction. Remove the files from stores only if we are the primary
            // region replica (thus own the files)
            hRegion.replayWALCompactionMarker(compactionDesc, !isDefaultReplica, isDefaultReplica,
              replaySeqId);
            continue;
          }
          FlushDescriptor flushDesc = WALEdit.getFlushDescriptor(metaCell);
          if (flushDesc != null && !isDefaultReplica) {
            hRegion.replayWALFlushMarker(flushDesc, replaySeqId);
            continue;
          }
          RegionEventDescriptor regionEvent = WALEdit.getRegionEventDescriptor(metaCell);
          if (regionEvent != null && !isDefaultReplica) {
            hRegion.replayWALRegionEventMarker(regionEvent);
            continue;
          }
          BulkLoadDescriptor bulkLoadEvent = WALEdit.getBulkLoadDescriptor(metaCell);
          if (bulkLoadEvent != null) {
            hRegion.replayWALBulkLoadEventMarker(bulkLoadEvent);
            continue;
          }
        }
        it.remove();
      }
    }
    requestCount.add(mutations.size());
    if (!region.getRegionInfo().isMetaTable()) {
      regionServer.cacheFlusher.reclaimMemStoreMemory();
    }
    return region.batchReplay(mutations.toArray(
      new WALSplitter.MutationReplay[mutations.size()]), replaySeqId);
  } finally {
    if (regionServer.metricsRegionServer != null) {
      long after = EnvironmentEdgeManager.currentTime();
        if (batchContainsPuts) {
        regionServer.metricsRegionServer.updatePut(after - before);
      }
      if (batchContainsDelete) {
        regionServer.metricsRegionServer.updateDelete(after - before);
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:75,代码来源:RSRpcServices.java

示例12: replay

private void replay(HRegion region, Put put, long replaySeqId) throws IOException {
  put.setDurability(Durability.SKIP_WAL);
  MutationReplay mutation = new MutationReplay(MutationType.PUT, put, 0, 0);
  region.batchReplay(new MutationReplay[] {mutation}, replaySeqId);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:5,代码来源:TestHRegionReplayEvents.java

示例13: doReplayBatchOp

/**
 * Execute a list of Put/Delete mutations. The function returns OperationStatus instead of
 * constructing MultiResponse to save a possible loop if caller doesn't need MultiResponse.
 *
 * @param region
 * @param mutations
 * @param replaySeqId
 * @return an array of OperationStatus which internally contains the OperationStatusCode and the
 * exceptionMessage if any
 * @throws IOException
 */
private OperationStatus[] doReplayBatchOp(final HRegion region,
                                          final List<WALSplitter.MutationReplay> mutations, long replaySeqId) throws IOException {

    long before = EnvironmentEdgeManager.currentTime();
    boolean batchContainsPuts = false, batchContainsDelete = false;
    try {
        for (Iterator<WALSplitter.MutationReplay> it = mutations.iterator(); it.hasNext(); ) {
            WALSplitter.MutationReplay m = it.next();

            if (m.type == MutationType.PUT) {
                batchContainsPuts = true;
            } else {
                batchContainsDelete = true;
            }

            NavigableMap<byte[], List<Cell>> map = m.mutation.getFamilyCellMap();
            List<Cell> metaCells = map.get(WALEdit.METAFAMILY);
            if (metaCells != null && !metaCells.isEmpty()) {
                for (Cell metaCell : metaCells) {
                    CompactionDescriptor compactionDesc = WALEdit.getCompaction(metaCell);
                    if (compactionDesc != null) {
                        region.completeCompactionMarker(compactionDesc);
                    }
                }
                it.remove();
            }
        }
        requestCount.add(mutations.size());
        if (!region.getRegionInfo().isMetaTable()) {
            regionServer.cacheFlusher.reclaimMemStoreMemory();
        }
        return region.batchReplay(mutations.toArray(
                new WALSplitter.MutationReplay[mutations.size()]), replaySeqId);
    } finally {
        if (regionServer.metricsRegionServer != null) {
            long after = EnvironmentEdgeManager.currentTime();
            if (batchContainsPuts) {
                regionServer.metricsRegionServer.updatePut(after - before);
            }
            if (batchContainsDelete) {
                regionServer.metricsRegionServer.updateDelete(after - before);
            }
        }
    }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:56,代码来源:RSRpcServices.java


注:本文中的org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。