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
24 import org.apache.hadoop.hbase.classification.InterfaceAudience;
25
26
27
28
29 @InterfaceAudience.Private
30 public class StoreUtils {
31
32
33
34 public static Integer getDeterministicRandomSeed(final Collection<StoreFile> files) {
35 if (files != null && !files.isEmpty()) {
36 return files.iterator().next().getPath().getName().hashCode();
37 }
38 return null;
39 }
40
41
42
43
44
45 public static boolean hasReferences(final Collection<StoreFile> files) {
46 if (files != null) {
47 for (StoreFile hsf: files) {
48 if (hsf.isReference()) {
49 return true;
50 }
51 }
52 }
53 return false;
54 }
55
56
57
58
59 public static long getLowestTimestamp(final Collection<StoreFile> candidates)
60 throws IOException {
61 long minTs = Long.MAX_VALUE;
62 for (StoreFile storeFile : candidates) {
63 minTs = Math.min(minTs, storeFile.getModificationTimeStamp());
64 }
65 return minTs;
66 }
67
68
69
70
71
72
73 static StoreFile getLargestFile(final Collection<StoreFile> candidates) {
74 long maxSize = -1L;
75 StoreFile largestSf = null;
76 for (StoreFile sf : candidates) {
77 StoreFile.Reader r = sf.getReader();
78 if (r == null) continue;
79 long size = r.length();
80 if (size > maxSize) {
81 maxSize = size;
82 largestSf = sf;
83 }
84 }
85 return largestSf;
86 }
87 }