/** * Copy constructor * @param incrementToCopy increment to copy */ public Increment(Increment incrementToCopy) { super(incrementToCopy); this.tr = incrementToCopy.getTimeRange(); }
@Override public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> e, final Increment increment) throws IOException { NavigableMap<byte [], List<Cell>> map = increment.getFamilyCellMap(); for (Map.Entry<byte [], List<Cell>> entry : map.entrySet()) { for (Cell cell : entry.getValue()) { long incr = Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); if (incr == 10) { tr10 = increment.getTimeRange(); } else if (incr == 2 && !increment.getTimeRange().isAllTime()) { tr2 = increment.getTimeRange(); } } } return super.preIncrement(e, increment); } }
switch (op) { case INCREMENT: tr = ((Increment)mutation).getTimeRange(); break; case APPEND:
public static MutationProto toMutationNoData(final MutationType type, final Mutation mutation, final MutationProto.Builder builder, long nonce) throws IOException { getMutationBuilderAndSetCommonFields(type, mutation, builder); builder.setAssociatedCellCount(mutation.size()); if (mutation instanceof Increment) { builder.setTimeRange(toTimeRange(((Increment)mutation).getTimeRange())); } if (mutation instanceof Append) { builder.setTimeRange(toTimeRange(((Append)mutation).getTimeRange())); } if (nonce != HConstants.NO_NONCE) { builder.setNonce(nonce); } return builder.build(); }
/** * Copy constructor * @param incrementToCopy increment to copy */ public Increment(Increment incrementToCopy) { super(incrementToCopy); this.tr = incrementToCopy.getTimeRange(); }
public static MutationProto toMutationNoData(final MutationType type, final Mutation mutation, final MutationProto.Builder builder, long nonce) throws IOException { getMutationBuilderAndSetCommonFields(type, mutation, builder); builder.setAssociatedCellCount(mutation.size()); if (mutation instanceof Increment) { builder.setTimeRange(ProtobufUtil.toTimeRange(((Increment) mutation).getTimeRange())); } if (mutation instanceof Append) { builder.setTimeRange(ProtobufUtil.toTimeRange(((Append) mutation).getTimeRange())); } if (nonce != HConstants.NO_NONCE) { builder.setNonce(nonce); } return builder.build(); }
private void assertEquals(Mutation origin, Mutation clone) { Assert.assertEquals(origin.getFamilyCellMap().size(), clone.getFamilyCellMap().size()); for (byte[] family : origin.getFamilyCellMap().keySet()) { List<Cell> originCells = origin.getCellList(family); List<Cell> cloneCells = clone.getCellList(family); Assert.assertEquals(originCells.size(), cloneCells.size()); for (int i = 0; i != cloneCells.size(); ++i) { Cell originCell = originCells.get(i); Cell cloneCell = cloneCells.get(i); assertTrue(CellUtil.equals(originCell, cloneCell)); assertTrue(CellUtil.matchingValue(originCell, cloneCell)); } } Assert.assertEquals(origin.getAttributesMap().size(), clone.getAttributesMap().size()); for (String name : origin.getAttributesMap().keySet()) { byte[] originValue = origin.getAttributesMap().get(name); byte[] cloneValue = clone.getAttributesMap().get(name); assertTrue(Bytes.equals(originValue, cloneValue)); } Assert.assertEquals(origin.getTimestamp(), clone.getTimestamp()); Assert.assertEquals(origin.getPriority(), clone.getPriority()); if (origin instanceof Append) { assertEquals(((Append)origin).getTimeRange(), ((Append)clone).getTimeRange()); } if (origin instanceof Increment) { assertEquals(((Increment)origin).getTimeRange(), ((Increment)clone).getTimeRange()); } }
builder.setTimeRange(ProtobufUtil.toTimeRange(((Increment) mutation).getTimeRange()));
builder.setTimeRange(toTimeRange(((Increment) mutation).getTimeRange()));
mutateBuilder.setTimeRange(ProtobufUtil.toTimeRange(increment.getTimeRange())); assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.INCREMENT, increment));
@Override public Result preIncrementAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> c, final Increment increment) throws IOException { if (increment.getAttribute(CHECK_COVERING_PERM) != null) { // We had failure with table, cf and q perm checks and now giving a chance for cell // perm check TableName table = c.getEnvironment().getRegion().getRegionInfo().getTable(); AuthResult authResult = null; User user = getActiveUser(c); if (checkCoveringPermission(user, OpType.INCREMENT, c.getEnvironment(), increment.getRow(), increment.getFamilyCellMap(), increment.getTimeRange().getMax(), Action.WRITE)) { authResult = AuthResult.allow(OpType.INCREMENT.toString(), "Covering cell set", user, Action.WRITE, table, increment.getFamilyCellMap()); } else { authResult = AuthResult.deny(OpType.INCREMENT.toString(), "Covering cell set", user, Action.WRITE, table, increment.getFamilyCellMap()); } AccessChecker.logResult(authResult); if (authorizationEnabled && !authResult.isAllowed()) { throw new AccessDeniedException("Insufficient permissions " + authResult.toContextString()); } } return null; }
mutateBuilder.setTimeRange(ProtobufUtil.toTimeRange(increment.getTimeRange())); assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.INCREMENT, increment));
public static MutationProto toMutationNoData(final MutationType type, final Mutation mutation, final MutationProto.Builder builder, long nonce) throws IOException { getMutationBuilderAndSetCommonFields(type, mutation, builder); builder.setAssociatedCellCount(mutation.size()); if (mutation instanceof Increment) { builder.setTimeRange(toTimeRange(((Increment)mutation).getTimeRange())); } if (mutation instanceof Append) { builder.setTimeRange(toTimeRange(((Append)mutation).getTimeRange())); } if (nonce != HConstants.NO_NONCE) { builder.setNonce(nonce); } return builder.build(); }
public static MutationProto toMutationNoData(final MutationType type, final Mutation mutation, final MutationProto.Builder builder, long nonce) throws IOException { getMutationBuilderAndSetCommonFields(type, mutation, builder); builder.setAssociatedCellCount(mutation.size()); if (mutation instanceof Increment) { builder.setTimeRange(ProtobufUtil.toTimeRange(((Increment) mutation).getTimeRange())); } if (mutation instanceof Append) { builder.setTimeRange(ProtobufUtil.toTimeRange(((Append) mutation).getTimeRange())); } if (nonce != HConstants.NO_NONCE) { builder.setNonce(nonce); } return builder.build(); }
private void assertEquals(Mutation origin, Mutation clone) { Assert.assertEquals(origin.getFamilyCellMap().size(), clone.getFamilyCellMap().size()); for (byte[] family : origin.getFamilyCellMap().keySet()) { List<Cell> originCells = origin.getCellList(family); List<Cell> cloneCells = clone.getCellList(family); Assert.assertEquals(originCells.size(), cloneCells.size()); for (int i = 0; i != cloneCells.size(); ++i) { Cell originCell = originCells.get(i); Cell cloneCell = cloneCells.get(i); assertTrue(CellUtil.equals(originCell, cloneCell)); assertTrue(CellUtil.matchingValue(originCell, cloneCell)); } } Assert.assertEquals(origin.getAttributesMap().size(), clone.getAttributesMap().size()); for (String name : origin.getAttributesMap().keySet()) { byte[] originValue = origin.getAttributesMap().get(name); byte[] cloneValue = clone.getAttributesMap().get(name); assertTrue(Bytes.equals(originValue, cloneValue)); } Assert.assertEquals(origin.getTimestamp(), clone.getTimestamp()); Assert.assertEquals(origin.getPriority(), clone.getPriority()); if (origin instanceof Append) { assertEquals(((Append)origin).getTimeRange(), ((Append)clone).getTimeRange()); } if (origin instanceof Increment) { assertEquals(((Increment)origin).getTimeRange(), ((Increment)clone).getTimeRange()); } }
builder.setTimeRange(ProtobufUtil.toTimeRange(((Increment) mutation).getTimeRange()));
builder.setTimeRange(toTimeRange(((Increment) mutation).getTimeRange()));
HRegion region = env.getRegion(); byte[] row = increment.getRow(); TimeRange tr = increment.getTimeRange(); region.startRegionOperation(); try {
byte[] row = increment.getRow(); List<RowLock> locks = Lists.newArrayList(); TimeRange tr = increment.getTimeRange(); region.startRegionOperation(); try {
mutateBuilder.setTimeRange(ProtobufUtil.toTimeRange(increment.getTimeRange())); assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.INCREMENT, increment));