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