/** * Atomically checks if a row/family/qualifier value matches the expected values and if it does, * it performs the row mutations. If the passed value is null, the lack of column value * (ie: non-existence) is used. Use to do many mutations on a single row. Use checkAndMutate * to do one checkAndMutate at a time. * @param row to check * @param family column family to check * @param qualifier column qualifier to check * @param op the comparison operator * @param comparator the expected value * @param mutations data to put if check succeeds * @return true if mutations were applied, false otherwise */ default boolean checkAndRowMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, RowMutations mutations) throws IOException { return checkAndRowMutate(row, family, qualifier, op, comparator, TimeRange.allTime(), mutations); }
/** * Atomically checks if a row/family/qualifier value matches the expected value and if it does, * it performs the mutation. If the passed value is null, the lack of column value * (ie: non-existence) is used. See checkAndRowMutate to do many checkAndPuts at a time on a * single row. * @param row to check * @param family column family to check * @param qualifier column qualifier to check * @param op the comparison operator * @param comparator the expected value * @param mutation data to put if check succeeds * @return true if mutation was applied, false otherwise */ default boolean checkAndMutate(byte [] row, byte [] family, byte [] qualifier, CompareOperator op, ByteArrayComparable comparator, Mutation mutation) throws IOException { return checkAndMutate(row, family, qualifier, op, comparator, TimeRange.allTime(), mutation); }
public static TimeRange toTimeRange(HBaseProtos.TimeRange timeRange) { return timeRange == null ? TimeRange.allTime() : new TimeRange(timeRange.hasFrom() ? timeRange.getFrom() : 0, timeRange.hasTo() ? timeRange.getTo() : Long.MAX_VALUE); }
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) { if (timeRange == null) { timeRange = TimeRange.allTime(); } return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin()) .setTo(timeRange.getMax()) .build(); } }
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) { if (timeRange == null) { timeRange = TimeRange.allTime(); } return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin()) .setTo(timeRange.getMax()) .build(); } }
@Test public void testExtreme() { TimeRange tr = TimeRange.allTime(); assertTrue(tr.includesTimeRange(TimeRange.allTime())); TimeRangeTracker trt = getTimeRangeTracker(); assertFalse(trt.includesTimeRange(TimeRange.allTime())); trt.includeTimestamp(1); trt.includeTimestamp(10); assertTrue(trt.includesTimeRange(TimeRange.allTime())); }
scanBuilder.setCacheBlocks(false); scanBuilder.setCaching(1024); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); scanBuilder.setIncludeStopRow(false); ClientProtos.Scan expectedProto = scanBuilder.build();
/** * Test basic Get conversions. * * @throws IOException */ @Test public void testGet() throws IOException { ClientProtos.Get.Builder getBuilder = ClientProtos.Get.newBuilder(); getBuilder.setRow(ByteString.copyFromUtf8("row")); Column.Builder columnBuilder = Column.newBuilder(); columnBuilder.setFamily(ByteString.copyFromUtf8("f1")); columnBuilder.addQualifier(ByteString.copyFromUtf8("c1")); columnBuilder.addQualifier(ByteString.copyFromUtf8("c2")); getBuilder.addColumn(columnBuilder.build()); columnBuilder.clear(); columnBuilder.setFamily(ByteString.copyFromUtf8("f2")); getBuilder.addColumn(columnBuilder.build()); getBuilder.setLoadColumnFamiliesOnDemand(true); ClientProtos.Get proto = getBuilder.build(); // default fields assertEquals(1, proto.getMaxVersions()); assertEquals(true, proto.getCacheBlocks()); // set the default value for equal comparison getBuilder = ClientProtos.Get.newBuilder(proto); getBuilder.setMaxVersions(1); getBuilder.setCacheBlocks(true); getBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); Get get = ProtobufUtil.toGet(proto); assertEquals(getBuilder.build(), ProtobufUtil.toGet(get)); }
TimeRange timeRange = condition.hasTimeRange() ? ProtobufUtil.toTimeRange(condition.getTimeRange()) : TimeRange.allTime(); processed = checkAndRowMutate(region, regionAction.getActionList(), cellScanner, row, family,
TimeRange timeRange = condition.hasTimeRange() ? ProtobufUtil.toTimeRange(condition.getTimeRange()) : TimeRange.allTime(); if (region.getCoprocessorHost() != null) { processed = region.getCoprocessorHost().preCheckAndPut(row, family, qualifier, TimeRange timeRange = condition.hasTimeRange() ? ProtobufUtil.toTimeRange(condition.getTimeRange()) : TimeRange.allTime(); if (region.getCoprocessorHost() != null) { processed = region.getCoprocessorHost().preCheckAndDelete(row, family, qualifier, op,
public static TimeRange toTimeRange(HBaseProtos.TimeRange timeRange) { return timeRange == null ? TimeRange.allTime() : new TimeRange(timeRange.hasFrom() ? timeRange.getFrom() : 0, timeRange.hasTo() ? timeRange.getTo() : Long.MAX_VALUE); }
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) { if (timeRange == null) { timeRange = TimeRange.allTime(); } return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin()) .setTo(timeRange.getMax()) .build(); } }
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) { if (timeRange == null) { timeRange = TimeRange.allTime(); } return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin()) .setTo(timeRange.getMax()) .build(); } }
/** * Test basic Get conversions. * * @throws IOException */ @Test public void testGet() throws IOException { ClientProtos.Get.Builder getBuilder = ClientProtos.Get.newBuilder(); getBuilder.setRow(ByteString.copyFromUtf8("row")); Column.Builder columnBuilder = Column.newBuilder(); columnBuilder.setFamily(ByteString.copyFromUtf8("f1")); columnBuilder.addQualifier(ByteString.copyFromUtf8("c1")); columnBuilder.addQualifier(ByteString.copyFromUtf8("c2")); getBuilder.addColumn(columnBuilder.build()); columnBuilder.clear(); columnBuilder.setFamily(ByteString.copyFromUtf8("f2")); getBuilder.addColumn(columnBuilder.build()); getBuilder.setLoadColumnFamiliesOnDemand(true); ClientProtos.Get proto = getBuilder.build(); // default fields assertEquals(1, proto.getMaxVersions()); assertEquals(true, proto.getCacheBlocks()); // set the default value for equal comparison getBuilder = ClientProtos.Get.newBuilder(proto); getBuilder.setMaxVersions(1); getBuilder.setCacheBlocks(true); getBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); Get get = ProtobufUtil.toGet(proto); assertEquals(getBuilder.build(), ProtobufUtil.toGet(get)); }
scanBuilder.setCacheBlocks(false); scanBuilder.setCaching(1024); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); scanBuilder.setIncludeStopRow(false); ClientProtos.Scan expectedProto = scanBuilder.build();
@Test public void testRangeConstruction() throws IOException { TimeRange defaultRange = TimeRange.allTime(); assertEquals(0L, defaultRange.getMin()); assertEquals(Long.MAX_VALUE, defaultRange.getMax()); assertTrue(defaultRange.isAllTime()); TimeRange oneArgRange = new TimeRange(0L); assertEquals(0L, oneArgRange.getMin()); assertEquals(Long.MAX_VALUE, oneArgRange.getMax()); assertTrue(oneArgRange.isAllTime()); TimeRange oneArgRange2 = new TimeRange(1); assertEquals(1, oneArgRange2.getMin()); assertEquals(Long.MAX_VALUE, oneArgRange2.getMax()); assertFalse(oneArgRange2.isAllTime()); TimeRange twoArgRange = new TimeRange(0L, Long.MAX_VALUE); assertEquals(0L, twoArgRange.getMin()); assertEquals(Long.MAX_VALUE, twoArgRange.getMax()); assertTrue(twoArgRange.isAllTime()); TimeRange twoArgRange2 = new TimeRange(0L, Long.MAX_VALUE - 1); assertEquals(0L, twoArgRange2.getMin()); assertEquals(Long.MAX_VALUE - 1, twoArgRange2.getMax()); assertFalse(twoArgRange2.isAllTime()); TimeRange twoArgRange3 = new TimeRange(1, Long.MAX_VALUE); assertEquals(1, twoArgRange3.getMin()); assertEquals(Long.MAX_VALUE, twoArgRange3.getMax()); assertFalse(twoArgRange3.isAllTime()); }
public static HBaseProtos.TimeRange toTimeRange(TimeRange timeRange) { if (timeRange == null) { timeRange = TimeRange.allTime(); } return HBaseProtos.TimeRange.newBuilder().setFrom(timeRange.getMin()) .setTo(timeRange.getMax()) .build(); } }
@Test public void testExtreme() { TimeRange tr = TimeRange.allTime(); assertTrue(tr.includesTimeRange(TimeRange.allTime())); TimeRangeTracker trt = getTimeRangeTracker(); assertFalse(trt.includesTimeRange(TimeRange.allTime())); trt.includeTimestamp(1); trt.includeTimestamp(10); assertTrue(trt.includesTimeRange(TimeRange.allTime())); }
/** * Test basic Get conversions. * * @throws IOException */ @Test public void testGet() throws IOException { ClientProtos.Get.Builder getBuilder = ClientProtos.Get.newBuilder(); getBuilder.setRow(ByteString.copyFromUtf8("row")); Column.Builder columnBuilder = Column.newBuilder(); columnBuilder.setFamily(ByteString.copyFromUtf8("f1")); columnBuilder.addQualifier(ByteString.copyFromUtf8("c1")); columnBuilder.addQualifier(ByteString.copyFromUtf8("c2")); getBuilder.addColumn(columnBuilder.build()); columnBuilder.clear(); columnBuilder.setFamily(ByteString.copyFromUtf8("f2")); getBuilder.addColumn(columnBuilder.build()); getBuilder.setLoadColumnFamiliesOnDemand(true); ClientProtos.Get proto = getBuilder.build(); // default fields assertEquals(1, proto.getMaxVersions()); assertEquals(true, proto.getCacheBlocks()); // set the default value for equal comparison getBuilder = ClientProtos.Get.newBuilder(proto); getBuilder.setMaxVersions(1); getBuilder.setCacheBlocks(true); getBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); Get get = ProtobufUtil.toGet(proto); assertEquals(getBuilder.build(), ProtobufUtil.toGet(get)); }
scanBuilder.setCacheBlocks(false); scanBuilder.setCaching(1024); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); scanBuilder.setIncludeStopRow(false); ClientProtos.Scan expectedProto = scanBuilder.build();