/** * Constructs a new pair, inferring the type via the passed arguments * @param <T1> type for first * @param <T2> type for second * @param a first element * @param b second element * @return a new pair containing the passed arguments */ public static <T1,T2> Pair<T1,T2> newPair(T1 a, T2 b) { return new Pair<>(a, b); }
private void addFamilyAndItsHFilePathToTableInMap(byte[] family, String pathToHfileFromNS, List<Pair<byte[], List<String>>> familyHFilePathsList) { List<String> hfilePaths = new ArrayList<>(1); hfilePaths.add(pathToHfileFromNS); familyHFilePathsList.add(new Pair<>(family, hfilePaths)); }
private void addNewTableEntryInMap( final Map<String, List<Pair<byte[], List<String>>>> bulkLoadHFileMap, byte[] family, String pathToHfileFromNS, String tableName) { List<String> hfilePaths = new ArrayList<>(1); hfilePaths.add(pathToHfileFromNS); Pair<byte[], List<String>> newFamilyHFilePathsPair = new Pair<>(family, hfilePaths); List<Pair<byte[], List<String>>> newFamilyHFilePathsList = new ArrayList<>(); newFamilyHFilePathsList.add(newFamilyHFilePathsPair); bulkLoadHFileMap.put(tableName, newFamilyHFilePathsList); }
static Pair<TableName, String> parseBackReferenceName(String name) { int separatorIndex = name.indexOf('.'); String linkRegionName = name.substring(0, separatorIndex); String tableSubstr = name.substring(separatorIndex + 1) .replace('=', TableName.NAMESPACE_DELIM); TableName linkTableName = TableName.valueOf(tableSubstr); return new Pair<>(linkTableName, linkRegionName); }
@Override public Pair<Result[], ScannerCallable> call(int callTimeout) throws IOException { // since the retries is done within the ResultBoundedCompletionService, // we don't invoke callWithRetries here if (cancelled) { return null; } Result[] res = this.caller.callWithoutRetries(this.callable, callTimeout); return new Pair<>(res, this.callable); }
@Override public List<Pair<Cell, Cell>> postAppendBeforeWAL( ObserverContext<RegionCoprocessorEnvironment> ctx, Mutation mutation, List<Pair<Cell, Cell>> cellPairs) throws IOException { List<Pair<Cell, Cell>> resultPairs = new ArrayList<>(cellPairs.size()); for (Pair<Cell, Cell> pair : cellPairs) { resultPairs .add(new Pair<>(pair.getFirst(), createNewCellWithTags(mutation, pair.getSecond()))); } return resultPairs; }
@Override public List<Pair<Cell, Cell>> postIncrementBeforeWAL( ObserverContext<RegionCoprocessorEnvironment> ctx, Mutation mutation, List<Pair<Cell, Cell>> cellPairs) throws IOException { List<Pair<Cell, Cell>> resultPairs = new ArrayList<>(cellPairs.size()); for (Pair<Cell, Cell> pair : cellPairs) { resultPairs .add(new Pair<>(pair.getFirst(), createNewCellWithTags(mutation, pair.getSecond()))); } return resultPairs; }
public ExportSnapshotInputSplit(final List<Pair<SnapshotFileInfo, Long>> snapshotFiles) { this.files = new ArrayList(snapshotFiles.size()); for (Pair<SnapshotFileInfo, Long> fileInfo: snapshotFiles) { this.files.add(new Pair<>( new BytesWritable(fileInfo.getFirst().toByteArray()), fileInfo.getSecond())); this.length += fileInfo.getSecond(); } }
public PeriodicRandomActionPolicy(long periodMs, Action... actions) { super(periodMs); this.actions = new ArrayList<>(actions.length); for (Action action : actions) { this.actions.add(new Pair<>(action, 1)); } }
@Override void add(Result r) { if (current == null) { return; } for (HRegionLocation loc : current.getRegionLocations()) { if (loc != null) { this.results.add(new Pair<>(loc.getRegion(), loc.getServerName())); } } } };
@Override protected List<Pair<ServerName, Long>> getDeadServers(long since) { List<Pair<ServerName, Long>> res = new ArrayList<>(); for (int i = 0; i < 25; i++) { res.add(new Pair<>(ServerName.valueOf("hn" + i, 10, 10), 20L)); } return res; } };
@Override public Pair<byte[], Collection<HStoreFile>> call() throws IOException { return new Pair<>(store.getColumnFamilyDescriptor().getName(), store.close()); } });
@Override public List<Pair<Cell, Cell>> postAppendBeforeWAL( ObserverContext<RegionCoprocessorEnvironment> ctx, Mutation mutation, List<Pair<Cell, Cell>> cellPairs) throws IOException { return cellPairs.stream() .map( pair -> new Pair<>(pair.getFirst(), newCellWithNotExistColumnFamily(pair.getSecond()))) .collect(Collectors.toList()); } }
@Override public List<Pair<Cell, Cell>> postAppendBeforeWAL( ObserverContext<RegionCoprocessorEnvironment> ctx, Mutation mutation, List<Pair<Cell, Cell>> cellPairs) throws IOException { return cellPairs.stream() .map( pair -> new Pair<>(pair.getFirst(), newCellWithDifferentColumnFamily(pair.getSecond()))) .collect(Collectors.toList()); } }
protected Pair<byte[], byte[]> generateStartAndStopRows(int maxRange) { int start = this.rand.nextInt(Integer.MAX_VALUE) % opts.totalRows; int stop = start + maxRange; return new Pair<>(format(start), format(stop)); }
protected Pair<byte[], byte[]> generateStartAndStopRows(int maxRange) { int start = this.rand.nextInt(Integer.MAX_VALUE) % totalRows; int stop = start + maxRange; return new Pair<>(format(start), format(stop)); }
@Override public List<Pair<Cell, Cell>> postIncrementBeforeWAL( ObserverContext<RegionCoprocessorEnvironment> ctx, Mutation mutation, List<Pair<Cell, Cell>> cellPairs) throws IOException { return cellPairs.stream() .map( pair -> new Pair<>(pair.getFirst(), newCellWithNotExistColumnFamily(pair.getSecond()))) .collect(Collectors.toList()); }
@Override public List<Pair<Cell, Cell>> postIncrementBeforeWAL( ObserverContext<RegionCoprocessorEnvironment> ctx, Mutation mutation, List<Pair<Cell, Cell>> cellPairs) throws IOException { return cellPairs.stream() .map( pair -> new Pair<>(pair.getFirst(), newCellWithDifferentColumnFamily(pair.getSecond()))) .collect(Collectors.toList()); }
@Test public void testFuzzyRowFilter() throws Exception { LinkedList<Pair<byte[], byte[]>> fuzzyList = new LinkedList<>(); fuzzyList.add(new Pair<>(Bytes.toBytes("999"),new byte[] {0, 0, 1})); fuzzyList.add(new Pair<>(Bytes.toBytes("abcd"),new byte[] {1, 0, 1, 1})); FuzzyRowFilter fuzzyRowFilter = new FuzzyRowFilter(fuzzyList); assertTrue(fuzzyRowFilter.areSerializedFieldsEqual( ProtobufUtil.toFilter(ProtobufUtil.toFilter(fuzzyRowFilter)))); }
private static Pair<byte[][], byte[][]> getStartEndKeys(List<RegionLocations> regions) { final byte[][] startKeyList = new byte[regions.size()][]; final byte[][] endKeyList = new byte[regions.size()][]; for (int i = 0; i < regions.size(); i++) { RegionInfo region = regions.get(i).getRegionLocation().getRegion(); startKeyList[i] = region.getStartKey(); endKeyList[i] = region.getEndKey(); } return new Pair<>(startKeyList, endKeyList); }