@Override public void start( @SuppressWarnings("rawtypes") CoprocessorEnvironment env) throws IOException { RegionCoprocessorEnvironment renv = (RegionCoprocessorEnvironment) env; sourceValue = Bytes.toBytes(renv.getConfiguration().get(ORIGINAL_VALUE_KEY)); replacedValue = Bytes.toBytes(renv.getConfiguration().get(REPLACED_VALUE_KEY)); comparator = new Bytes.ByteArrayComparator(); cellBuilder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY); }
public void checkRegionBoundaries() { try { ByteArrayComparator comparator = new ByteArrayComparator(); List<RegionInfo> regions = MetaTableAccessor.getAllRegions(connection, true); final RegionBoundariesInformation currentRegionBoundariesInformation =
int sizeOfMap = Bytes.toInt(payload, 9); data = new TreeMap<byte[], LinkedList<byte[]>>(new Bytes.ByteArrayComparator());
public void checkRegionBoundaries() { try { ByteArrayComparator comparator = new ByteArrayComparator(); List<HRegionInfo> regions = MetaScanner.listAllRegions(getConf(), connection, false); final RegionBoundariesInformation currentRegionBoundariesInformation =
int sizeOfMap = Bytes.toInt(payload, 9); data = new TreeMap<byte[], LinkedList<byte[]>>(new Bytes.ByteArrayComparator());
int sizeOfMap = Bytes.toInt(payload, 9); data = new TreeMap<byte[], LinkedList<byte[]>>(new Bytes.ByteArrayComparator());
ByteArrayComparator bac = new ByteArrayComparator();
ByteArrayComparator bac = new ByteArrayComparator();
return 1; } else { return new Bytes.ByteArrayComparator().compare( Util.UUIDToBytes(uuid), Util.UUIDToBytes(row2.uuid));
private static int recordsCompare(List<byte[]> records1, List<byte[]> records2, int nullOrder) { byte[] value1, value2; int compare; for (int i = 0; i < Math.min(records1.size(), records2.size()); i++) { value1 = records1.get(i); value2 = records2.get(i); if (value1 == value2) { continue; } if (value1 == null) { return nullOrder; } if (value2 == null) { return nullOrder * -1; } compare = new Bytes.ByteArrayComparator().compare(value1, value2); if (compare != 0) { return compare; } } return records2.size() - records1.size(); } }
/** * Tests whether sortedoplog supports duplicate keys, required when conflation is disabled */ public void testFromToIterator() throws IOException { ByteArrayComparator bac = new ByteArrayComparator(); String hoplogName = getRandomHoplogName(); HFileSortedOplog hoplog = new HFileSortedOplog(hdfsStore, new Path(testDataDir, hoplogName), blockCache, stats, storeStats); int count = 5; HoplogWriter writer = hoplog.createWriter(5); for (int i = 0; i < count; i++) { String value = "value-" + (i * 2); // even keys key-[0 2 4 6 8] writer.append(("key-" + (i * 2)).getBytes(), value.getBytes()); } writer.close(); HoplogReader reader = hoplog.getReader(); HoplogIterator<byte[], byte[]> iter = reader.scan("key-1".getBytes(), true, "key-7".getBytes(), true); for (int i = 2; i < 7; i += 2) { assertTrue(iter.hasNext()); iter.next(); assertEquals(0, bac.compare(("key-" + i).getBytes(), iter.getKey())); assertEquals(0, bac.compare(("value-" + i).getBytes(), iter.getValue())); System.out.println(new String(iter.getKey())); } assertFalse(iter.hasNext()); }
/** * Tests full iteration on a hoplog. Ensures all inserted keys are returned and no key is missing */ public void testIterator() throws IOException { int count = 10; ByteArrayComparator bac = new ByteArrayComparator(); String hoplogName = getRandomHoplogName(); TreeMap<String, String> sortedMap = createHoplog(hoplogName, count); HFileSortedOplog testHoplog = new HFileSortedOplog(hdfsStore, new Path(testDataDir, hoplogName), blockCache, stats, storeStats); HoplogReader reader = testHoplog.getReader(); Iterator<Entry<String, String>> mapIter = sortedMap.entrySet().iterator(); HoplogIterator<byte[], byte[]> iter = reader.scan(); for (; iter.hasNext();) { byte[] key = iter.next(); Entry<String, String> entry = mapIter.next(); assertEquals(0, bac.compare(key, iter.getKey())); assertEquals(0, bac.compare(key, entry.getKey().getBytes())); assertEquals(0, bac.compare(iter.getValue(), entry.getValue().getBytes())); count--; } assertEquals(0, count); }
@Override public int compareTo(RowKey o) { int typeCompare = getPrefix() - o.getPrefix(); if (typeCompare != 0) { return typeCompare; } DataRowKey row2 = (DataRowKey) o; return ComparisonChain.start() .compare(getTableId(), row2.getTableId()) .compare(Util.UUIDToBytes(getUuid()), Util.UUIDToBytes(row2.getUuid()), new Bytes.ByteArrayComparator()) .result(); } }
@Override public void start( @SuppressWarnings("rawtypes") CoprocessorEnvironment env) throws IOException { RegionCoprocessorEnvironment renv = (RegionCoprocessorEnvironment) env; sourceValue = Bytes.toBytes(renv.getConfiguration().get(ORIGINAL_VALUE_KEY)); replacedValue = Bytes.toBytes(renv.getConfiguration().get(REPLACED_VALUE_KEY)); comparator = new Bytes.ByteArrayComparator(); cellBuilder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY); }