1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.regionserver;
20
21 import java.io.IOException;
22 import java.util.Collection;
23 import java.util.List;
24
25
26
27
28 public class StoreUtils {
29
30
31
32 public static Integer getDeterministicRandomSeed(final Collection<StoreFile> files) {
33 if (files != null && !files.isEmpty()) {
34 return files.iterator().next().getPath().getName().hashCode();
35 }
36 return null;
37 }
38
39
40
41
42
43 public static boolean hasReferences(final Collection<StoreFile> files) {
44 if (files != null) {
45 for (StoreFile hsf: files) {
46 if (hsf.isReference()) {
47 return true;
48 }
49 }
50 }
51 return false;
52 }
53
54
55
56
57 public static long getLowestTimestamp(final Collection<StoreFile> candidates)
58 throws IOException {
59 long minTs = Long.MAX_VALUE;
60 for (StoreFile storeFile : candidates) {
61 minTs = Math.min(minTs, storeFile.getModificationTimeStamp());
62 }
63 return minTs;
64 }
65
66
67
68
69
70
71 static StoreFile getLargestFile(final Collection<StoreFile> candidates) {
72 long maxSize = -1L;
73 StoreFile largestSf = null;
74 for (StoreFile sf : candidates) {
75 StoreFile.Reader r = sf.getReader();
76 if (r == null) continue;
77 long size = r.length();
78 if (size > maxSize) {
79 maxSize = size;
80 largestSf = sf;
81 }
82 }
83 return largestSf;
84 }
85 }