Search in sources :

Example 1 with UnsignedLong

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);
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong)

Example 2 with UnsignedLong

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);
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong) Date(java.util.Date)

Example 3 with UnsignedLong

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());
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong) Test(org.junit.Test)

Example 4 with UnsignedLong

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;
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong) ArrayList(java.util.ArrayList)

Example 5 with UnsignedLong

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);
}
Also used : ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) UnsignedLong(com.google.common.primitives.UnsignedLong) ArrayList(java.util.ArrayList)

Aggregations

UnsignedLong (com.google.common.primitives.UnsignedLong)21 Test (org.junit.Test)8 BigInteger (java.math.BigInteger)4 InOrder (org.mockito.InOrder)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)3 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)3 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)3 ArrayList (java.util.ArrayList)2 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)2 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)2 CommitTransactionPayload (org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload)2 DataTreeCandidateTip (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip)2 CPUStats (com.emc.storageos.systemservices.impl.healthmonitor.models.CPUStats)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Optional (java.util.Optional)1 Nullable (javax.annotation.Nullable)1 ArgumentTypeException (org.matheclipse.core.eval.exception.ArgumentTypeException)1 IExpr (org.matheclipse.core.interfaces.IExpr)1