Skip to content

Commit c2eb04a

Browse files
committed
private final static long ONE_GB
1 parent 4d78d28 commit c2eb04a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/com/medallia/word2vec/Word2VecModel.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Word2VecModel {
3636
final List<String> vocab;
3737
final int layerSize;
3838
final double[] vectors;
39+
private final static long ONE_GB = 1024 * 1024 * 1024;
3940

4041
Word2VecModel(Iterable<String> vocab, int layerSize, double[] vectors) {
4142
this.vocab = ImmutableList.copyOf(vocab);
@@ -96,7 +97,6 @@ public static Word2VecModel fromBinFile(File file, ByteOrder byteOrder)
9697

9798
try (FileInputStream fis = new FileInputStream(file)) {
9899
final FileChannel channel = fis.getChannel();
99-
final long oneGB = 1024 * 1024 * 1024;
100100
MappedByteBuffer buffer =
101101
channel.map(
102102
FileChannel.MapMode.READ_ONLY,
@@ -162,18 +162,18 @@ public static Word2VecModel fromBinFile(File file, ByteOrder byteOrder)
162162
}
163163

164164
// remap file
165-
if (buffer.position() > oneGB) {
166-
final int newPosition = (int) (buffer.position() - oneGB);
167-
final long size = Math.min(channel.size() - oneGB * bufferCount, Integer.MAX_VALUE);
165+
if (buffer.position() > ONE_GB) {
166+
final int newPosition = (int) (buffer.position() - ONE_GB);
167+
final long size = Math.min(channel.size() - ONE_GB * bufferCount, Integer.MAX_VALUE);
168168
logger.debug(
169169
String.format(
170170
"Remapping for GB number %d. Start: %d, size: %d",
171171
bufferCount,
172-
oneGB * bufferCount,
172+
ONE_GB * bufferCount,
173173
size));
174174
buffer = channel.map(
175175
FileChannel.MapMode.READ_ONLY,
176-
oneGB * bufferCount,
176+
ONE_GB * bufferCount,
177177
size);
178178
buffer.order(byteOrder);
179179
buffer.position(newPosition);

0 commit comments

Comments
 (0)