use long math for long results

This commit is contained in:
Dave Brosius 2015-03-03 21:50:23 -05:00
parent 2acd05d967
commit 9499f7cb98
4 changed files with 10 additions and 12 deletions

View File

@ -38,7 +38,6 @@ import java.util.TreeSet;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Longs;
import org.apache.cassandra.cache.RefCountedMemory;
import org.apache.cassandra.db.TypeSizes;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.io.FSReadError;
@ -47,7 +46,6 @@ import org.apache.cassandra.io.IVersionedSerializer;
import org.apache.cassandra.io.sstable.Component;
import org.apache.cassandra.io.sstable.CorruptSSTableException;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.io.sstable.SSTableWriter;
import org.apache.cassandra.io.util.DataOutputPlus;
import org.apache.cassandra.io.util.FileUtils;
import org.apache.cassandra.io.util.Memory;
@ -181,7 +179,7 @@ public class CompressionMetadata
if (chunkCount <= 0)
throw new IOException("Compressed file with 0 chunks encountered: " + input);
Memory offsets = Memory.allocate(chunkCount * 8);
Memory offsets = Memory.allocate(chunkCount * 8L);
for (int i = 0; i < chunkCount; i++)
{
@ -248,7 +246,7 @@ public class CompressionMetadata
endIndex = section.right % parameters.chunkLength() == 0 ? endIndex - 1 : endIndex;
for (int i = startIndex; i <= endIndex; i++)
{
long offset = i * 8;
long offset = i * 8L;
long chunkOffset = chunkOffsets.getLong(offset);
long nextChunkOffset = offset + 8 == chunkOffsetsSize
? compressedFileLength
@ -270,7 +268,7 @@ public class CompressionMetadata
private final CompressionParameters parameters;
private final String filePath;
private int maxCount = 100;
private SafeMemory offsets = new SafeMemory(maxCount * 8);
private SafeMemory offsets = new SafeMemory(maxCount * 8L);
private int count = 0;
private Writer(CompressionParameters parameters, String path)
@ -288,11 +286,11 @@ public class CompressionMetadata
{
if (count == maxCount)
{
SafeMemory newOffsets = offsets.copy((maxCount *= 2) * 8);
SafeMemory newOffsets = offsets.copy((maxCount *= 2L) * 8);
offsets.close();
offsets = newOffsets;
}
offsets.setLong(8 * count++, offset);
offsets.setLong(8L * count++, offset);
}
private void writeHeader(DataOutput out, long dataLength, int chunks)
@ -362,7 +360,7 @@ public class CompressionMetadata
count = (int) (dataLength / parameters.chunkLength());
// grab our actual compressed length from the next offset from our the position we're opened to
if (count < this.count)
compressedLength = offsets.getLong(count * 8);
compressedLength = offsets.getLong(count * 8L);
break;
default:
@ -401,7 +399,7 @@ public class CompressionMetadata
assert chunks == count;
writeHeader(out, dataLength, chunks);
for (int i = 0 ; i < count ; i++)
out.writeLong(offsets.getLong(i * 8));
out.writeLong(offsets.getLong(i * 8L));
}
finally
{

View File

@ -1174,7 +1174,7 @@ public class SSTableReader extends SSTable implements RefCounted<SSTableReader>
sampleKeyCount += (sampleIndexRange.right - sampleIndexRange.left + 1);
// adjust for the current sampling level: (BSL / SL) * index_interval_at_full_sampling
long estimatedKeys = sampleKeyCount * (Downsampling.BASE_SAMPLING_LEVEL * indexSummary.getMinIndexInterval()) / indexSummary.getSamplingLevel();
long estimatedKeys = sampleKeyCount * ((long) Downsampling.BASE_SAMPLING_LEVEL * indexSummary.getMinIndexInterval()) / indexSummary.getSamplingLevel();
return Math.max(1, estimatedKeys);
}

View File

@ -118,7 +118,7 @@ public class StreamReceiveTask extends StreamTask
}
ColumnFamilyStore cfs = Keyspace.open(kscf.left).getColumnFamilyStore(kscf.right);
File lockfiledir = cfs.directories.getWriteableLocationAsFile(task.sstables.size() * 256);
File lockfiledir = cfs.directories.getWriteableLocationAsFile(task.sstables.size() * 256L);
if (lockfiledir == null)
throw new IOError(new IOException("All disks full"));
StreamLockfile lockfile = new StreamLockfile(lockfiledir, UUID.randomUUID());

View File

@ -125,7 +125,7 @@ public class SettingsSchema implements Serializable
/* end */
System.out.println(String.format("Created keyspaces. Sleeping %ss for propagation.", settings.node.nodes.size()));
Thread.sleep(settings.node.nodes.size() * 1000); // seconds
Thread.sleep(settings.node.nodes.size() * 1000L); // seconds
}
catch (InvalidRequestException e)
{