Java Code Examples for com.google.common.primitives.Longs#asList()

The following examples show how to use com.google.common.primitives.Longs#asList() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
static
public List<?> getValues(Tensor tensor){
	DataType dataType = tensor.dataType();

	switch(dataType){
		case FLOAT:
			return Floats.asList(TensorUtil.toFloatArray(tensor));
		case DOUBLE:
			return Doubles.asList(TensorUtil.toDoubleArray(tensor));
		case INT32:
			return Ints.asList(TensorUtil.toIntArray(tensor));
		case INT64:
			return Longs.asList(TensorUtil.toLongArray(tensor));
		case STRING:
			return Arrays.asList(TensorUtil.toStringArray(tensor));
		case BOOL:
			return Booleans.asList(TensorUtil.toBooleanArray(tensor));
		default:
			throw new IllegalArgumentException();
	}
}
 
Example 2
@Test
public void testInsertBulkDifferentTypesResultsInStreamingFailure() throws Exception {
    execute("create table test (id integer primary key) " +
            "clustered into 2 shards with (column_policy='dynamic', number_of_replicas=0)");
    List<Long> rowCounts = Longs.asList(
        execute("insert into test (id, value) values (?, ?)",
                new Object[][]{
                    new Object[]{1, 1},                                 // use id 1 to ensure shard 0
                    new Object[]{3, new HashMap<String, Object>() {{    // use id 3 to ensure shard 1
                        put("foo", 127);
                    }}},
        }));
    assertThat(rowCounts.size(), is(2));
    assertThat(rowCounts, Matchers.anyOf(
        contains(1L, -2L),
        contains(-2L, 1L)
    ));
}
 
Example 3
public static TTransaction wrap(Transaction tx) {
  return new TTransaction(tx.getTransactionId(), tx.getReadPointer(),
                          Longs.asList(tx.getInvalids()), Longs.asList(tx.getInProgress()),
                          tx.getFirstShortInProgress(), getTTransactionType(tx.getType()),
                          tx.getWritePointer(), Longs.asList(tx.getCheckpointWritePointers()),
                          getTVisibilityLevel(tx.getVisibilityLevel()));
}
 
Example 4
Source Project: nd4j   File: BaseSparseNDArrayCOO.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Compute the sparse offsets of the view we are getting, for each dimension according to the original ndarray
 * @param offset the offset of the view
 * @return an int array containing the sparse offsets
 * */
private long[] createSparseOffsets(long offset) {

    // resolve the offsets in the view dimension
    int underlyingRank = sparseOffsets().length;
    long[] newOffsets = new long[rank()];
    List<Long> shapeList = Longs.asList(shape());
    int penultimate = rank() - 1;
    for (int i = 0; i < penultimate; i++) {
        long prod = ArrayUtil.prodLong(shapeList.subList(i + 1, rank()));
        newOffsets[i] = offset / prod;
        offset = offset - newOffsets[i] * prod;
    }
    newOffsets[rank() - 1] = offset % shape()[rank() - 1];

    // Merge the offsets with the original sparseOffsets
    long[] finalOffsets = new long[underlyingRank];
    int dimNotFixed = 0;
    for (int dim = 0; dim < underlyingRank; dim++) {
        if (flags()[dim] == 1) {
            finalOffsets[dim] = sparseOffsets()[dim];
        } else {
            finalOffsets[dim] = newOffsets[dimNotFixed] + sparseOffsets()[dim];
            dimNotFixed++;
        }
    }
    return finalOffsets;
}
 
Example 5
Source Project: nd4j   File: SpecifiedIndex.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return the next item in the sequence.
 * @throws NoSuchElementException when sequence is exhausted.
 */
@Override
public List<Long> next() throws NoSuchElementException {
    if (!SpecifiedIndex.this.hasNext())
        throw new NoSuchElementException();

    return Longs.asList(SpecifiedIndex.this.next());
}
 
Example 6
Source Project: cloudstack   File: SolidFireUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static void addVolumeIdToSolidFireVag(long volumeId, SolidFireVag sfVag, List<Long> newVolumeIds) {
    List<Long> existingVolumeIds = Longs.asList(sfVag.getVolumeIds());

    if (!existingVolumeIds.contains(volumeId) && !newVolumeIds.contains(volumeId)) {
        newVolumeIds.add(volumeId);
    }
}
 
Example 7
private HistogramDescriptor(long[] valueBounds) {
    Preconditions.checkArgument(valueBounds.length > 0, "Expecting at least one element in the value bounds array");
    Preconditions.checkArgument(isAscending(valueBounds), "Expected increasing sequence of numbers: %s", valueBounds);
    this.valueBounds = valueBounds;
    this.valueBoundList = Longs.asList(valueBounds);
}
 
Example 8
Source Project: titus-control-plane   File: Histogram.java    License: Apache License 2.0 4 votes vote down vote up
public Histogram build() {
    return new Histogram(Longs.asList(counters), histogramDescriptor);
}
 
Example 9
Source Project: kudu-ts   File: LongVec.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns a list view of the vector.
 * The vector should not be concurrently modified while the list is in use.
 * @return a list view of the vector
 */
public List<Long> asList() {
  List<Long> list = Longs.asList(data);
  if (len < data.length) return list.subList(0, len);
  return list;
}
 
Example 10
Source Project: immutables   File: Intrinsics.java    License: Apache License 2.0 4 votes vote down vote up
public static Iterable<Long> $in(long[] elements) {
  return Longs.asList(elements);
}
 
Example 11
Source Project: vjtools   File: ArrayUtil.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Arrays.asList()的加强版, 返回一个底层为原始类型long的List
 * 
 * 与保存Long相比节约空间,同时只在读取数据时AutoBoxing.
 * 
 * @see java.util.Arrays#asList(Object...)
 * @see com.google.common.primitives.Longs#asList(long...)
 */
public static List<Long> longAsList(long... backingArray) {
	return Longs.asList(backingArray);
}
 
Example 12
Source Project: vjtools   File: ArrayUtil.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Arrays.asList()的加强版, 返回一个底层为原始类型long的List
 * 
 * 与保存Long相比节约空间,同时只在读取数据时AutoBoxing.
 * 
 * @see java.util.Arrays#asList(Object...)
 * @see com.google.common.primitives.Longs#asList(long...)
 */
public static List<Long> longAsList(long... backingArray) {
	return Longs.asList(backingArray);
}
 
Example 13
Source Project: j360-dubbo-app-all   File: ArrayUtil.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Arrays.asList()的加强版, 返回一个底层为原始类型long的List
 *
 * 与保存Long相比节约空间,同时只在读取数据时AutoBoxing.
 *
 * @see Arrays#asList(Object...)
 * @see com.google.common.primitives.Longs#asList(long...)
 */
public static List<Long> longAsList(long... backingArray) {
	return Longs.asList(backingArray);
}