use of com.google.common.primitives.UnsignedLong in project buck by facebook.
the class ObjectPathsAbsolutifier method processLinkeditSegmentCommand.
private void processLinkeditSegmentCommand(SegmentCommand original, Optional<LinkEditDataCommand> updatedCodeSignatureCommand) {
SymTabCommand symTabCommand = getSymTabCommand();
int fileSize = symTabCommand.getStroff().intValue() + symTabCommand.getStrsize().intValue();
if (updatedCodeSignatureCommand.isPresent()) {
LinkEditDataCommand codeSignCommand = updatedCodeSignatureCommand.get();
/**
* If code signature is present, append it's size plus size of the gap between string table
* and code signature itself that can be caused by the aligning of the code signature.
*/
fileSize = codeSignCommand.getDataoff().intValue() + codeSignCommand.getDatasize().intValue();
}
fileSize -= original.getFileoff().intValue();
UnsignedLong updatedFileSize = UnsignedLong.valueOf(fileSize);
UnsignedLong updatedVmSize = UnsignedLong.fromLongBits(SegmentCommandUtils.alignValue(updatedFileSize.intValue()));
SegmentCommand updated = original.withFilesize(updatedFileSize).withVmsize(updatedVmSize);
SegmentCommandUtils.updateSegmentCommand(buffer, original, updated);
}
use of com.google.common.primitives.UnsignedLong in project nifi by apache.
the class BinaryReader method readFileTime.
/**
* Reads a timestamp that is the number of hundreds of nanoseconds since Jan 1 1601
* (see http://integriography.wordpress.com/2010/01/16/using-phython-to-parse-and-present-windows-64-bit-timestamps/)
*
* @return the date corresponding to the timestamp
*/
public Date readFileTime() {
UnsignedLong hundredsOfNanosecondsSinceJan11601 = readQWord();
long millisecondsSinceJan11601 = hundredsOfNanosecondsSinceJan11601.dividedBy(UnsignedLong.valueOf(10000)).longValue();
long millisecondsSinceEpoch = millisecondsSinceJan11601 - EPOCH_OFFSET;
return new Date(millisecondsSinceEpoch);
}
use of com.google.common.primitives.UnsignedLong in project nifi by apache.
the class BinaryReaderTest method testReadQWord.
@Test
public void testReadQWord() throws IOException {
UnsignedLong longValue = UnsignedLong.fromLongBits(Long.MAX_VALUE + 500);
BinaryReader binaryReader = testBinaryReaderBuilder.putQWord(longValue).build();
assertEquals(longValue, binaryReader.readQWord());
assertEquals(8, binaryReader.getPosition());
}
use of com.google.common.primitives.UnsignedLong in project jpmml-r by jpmml.
the class RandomForestConverter method selectValues.
static <E> List<E> selectValues(List<E> values, Double split, boolean left) {
UnsignedLong bits = toUnsignedLong(split.doubleValue());
List<E> result = new ArrayList<>();
for (int i = 0; i < values.size(); i++) {
E value = values.get(i);
boolean append;
// Send "true" categories to the left
if (left) {
// Test if the least significant bit (LSB) is 1
append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ONE);
} else // Send all other categories to the right
{
// Test if the LSB is 0
append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ZERO);
}
if (append) {
result.add(value);
}
bits = bits.dividedBy(RandomForestConverter.TWO);
}
return result;
}
use of com.google.common.primitives.UnsignedLong in project controller by opendaylight.
the class FrontendClientMetadata method readFrom.
public static FrontendClientMetadata readFrom(final DataInput in) throws IOException, ClassNotFoundException {
final ClientIdentifier id = ClientIdentifier.readFrom(in);
final int purgedSize = in.readInt();
final Builder<UnsignedLong> b = ImmutableRangeSet.builder();
for (int i = 0; i < purgedSize; ++i) {
final byte header = WritableObjects.readLongHeader(in);
final UnsignedLong lower = UnsignedLong.fromLongBits(WritableObjects.readFirstLong(in, header));
final UnsignedLong upper = UnsignedLong.fromLongBits(WritableObjects.readSecondLong(in, header));
b.add(Range.closed(lower, upper));
}
final int currentSize = in.readInt();
final Collection<FrontendHistoryMetadata> currentHistories = new ArrayList<>(currentSize);
for (int i = 0; i < currentSize; ++i) {
currentHistories.add(FrontendHistoryMetadata.readFrom(in));
}
return new FrontendClientMetadata(id, b.build(), currentHistories);
}
Aggregations