org.apache.commons.lang.ArrayUtils#toPrimitive ( )源码实例Demo

下面列出了org.apache.commons.lang.ArrayUtils#toPrimitive ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: feeyo-hlsserver   文件: HlsLiveStream.java
public long[] fetchTsIndexs() {
	// 
	Set<Long> indexSET = ImmutableSet.copyOf(tsSegments.keySet());
	if ( indexSET.size() < 3 ) {
		return null;
	}	
	
	//
	Long[] indexArr = indexSET.toArray(new Long[indexSET.size()]);
	Arrays.sort( indexArr );
	
	if ( indexArr.length > 5 ) {
		Long[] tmpArr = new Long[5];
		System.arraycopy(indexArr, indexArr.length - 5, tmpArr, 0, 5);
		
		return ArrayUtils.toPrimitive( tmpArr );
		
	} else {
		return ArrayUtils.toPrimitive( indexArr );
	}
}
 
源代码2 项目: mtas   文件: MtasPosition.java
/**
 * Instantiates a new mtas position.
 *
 * @param positions the positions
 */
public MtasPosition(int[] positions) {
  SortedSet<Integer> list = new TreeSet<>();
  for (int p : positions) {
    list.add(p);
  }
  if (list.size() == 1) {
    mtasPositionType = POSITION_SINGLE;
    mtasPositionStart = list.first();
  } else {
    mtasPositionType = POSITION_SET;
    mtasPositionList = ArrayUtils
        .toPrimitive(list.toArray(new Integer[list.size()]));
    mtasPositionStart = list.first();
    mtasPositionEnd = list.last();
    if (mtasPositionList.length == (1 + mtasPositionEnd
        - mtasPositionStart)) {
      mtasPositionType = POSITION_RANGE;
      mtasPositionList = null;
    }
  }
}
 
源代码3 项目: edx-app-android   文件: IDatabaseImpl.java
@Override
public long[] getDownloadingVideoDmIdsForSection(String enrollmentId, String chapter,
                                                 String section,
                                                 final DataCallback<List<Long>> callback) {
    DbOperationGetColumn<Long> op = new DbOperationGetColumn<Long>(true,
            DbStructure.Table.DOWNLOADS,
            new String[]{DbStructure.Column.DM_ID},
            DbStructure.Column.DOWNLOADED + "=? AND " + DbStructure.Column.EID + "=? AND "
                    + DbStructure.Column.CHAPTER + "=? AND "
                    + DbStructure.Column.SECTION + "=? AND "
                    + DbStructure.Column.USERNAME + "=?",
            new String[]{String.valueOf(DownloadedState.DOWNLOADING.ordinal()),
                    enrollmentId, chapter, section, username()}, null, Long.class);
    op.setCallback(callback);
    List<Long> downloadingList = enqueue(op);
    if (callback != null) {
        return null;
    } else {
        return ArrayUtils.toPrimitive(downloadingList.toArray(new Long[0]));
    }
}
 
源代码4 项目: edx-app-android   文件: IDatabaseImpl.java
@Override
public long[] getDownloadedVideoDmIdsForSection(String enrollmentId, String chapter,
                                                String section,
                                                final DataCallback<List<Long>> callback) {
    DbOperationGetColumn<Long> op = new DbOperationGetColumn<Long>(true,
            DbStructure.Table.DOWNLOADS,
            new String[]{DbStructure.Column.DM_ID},
            DbStructure.Column.DOWNLOADED + "=? AND " + DbStructure.Column.EID + "=? AND "
                    + DbStructure.Column.CHAPTER + "=? AND "
                    + DbStructure.Column.SECTION + "=? AND "
                    + DbStructure.Column.USERNAME + "=?",
            new String[]{String.valueOf(DownloadedState.DOWNLOADED.ordinal()),
                    enrollmentId, chapter, section, username()}, null, Long.class);
    op.setCallback(callback);
    List<Long> downloadedList = enqueue(op);
    if (callback != null) {
        return null;
    } else {
        return ArrayUtils.toPrimitive(downloadedList.toArray(new Long[0]));
    }
}
 
源代码5 项目: geowave   文件: InternalAdapterStoreImpl.java
@Override
public short[] getAdapterIds() {
  final MetadataReader reader = getReader(false);
  if (reader == null) {
    return new short[0];
  }
  final CloseableIterator<GeoWaveMetadata> results =
      reader.query(new MetadataQuery(null, EXTERNAL_TO_INTERNAL_ID));
  try (CloseableIterator<Short> it =
      new CloseableIteratorWrapper<>(
          results,
          Iterators.transform(
              results,
              input -> ByteArrayUtils.byteArrayToShort(input.getValue())))) {
    return ArrayUtils.toPrimitive(Iterators.toArray(it, Short.class));
  }
}
 
源代码6 项目: mtas   文件: MtasDataDoubleFull.java
@Override
protected MtasDataItemDoubleFull getItem(int i) {
  if (i >= 0 && i < size) {
    return new MtasDataItemDoubleFull(
        ArrayUtils.toPrimitive(fullValueList[i]),
        hasSub() ? subCollectorListNextLevel[i] : null, getStatsItems(),
        sortType, sortDirection, errorNumber[i], errorList[i],
        sourceNumberList[i]);
  } else {
    return null;
  }
}
 
源代码7 项目: mtas   文件: MtasDataLongFull.java
@Override
protected MtasDataItemLongFull getItem(int i) {
  if (i >= 0 && i < size) {
    return new MtasDataItemLongFull(ArrayUtils.toPrimitive(fullValueList[i]),
        hasSub() ? subCollectorListNextLevel[i] : null, getStatsItems(),
        sortType, sortDirection, errorNumber[i], errorList[i],
        sourceNumberList[i]);
  } else {
    return null;
  }
}
 
源代码8 项目: ymate-platform-v2   文件: DefaultSession.java
@Override
public <T extends IEntity> int[] delete(Class<T> entityClass, ShardingList<Serializable> ids) throws Exception {
    List<Integer> _results = new ArrayList<Integer>();
    for (ShardingList.ShardingElement<Serializable> _element : ids) {
        _results.add(this.delete(entityClass, _element.getElement(), _element));
    }
    return ArrayUtils.toPrimitive(_results.toArray(new Integer[0]));
}
 
源代码9 项目: openhab1-addons   文件: AbstractWR3223Connector.java
/**
 * Read bytes from input stream until ETX.
 *
 * @return The extracted answer.
 * @throws IOException
 */
private byte[] readAnswer() throws IOException {
    List<Byte> answerList = new ArrayList<Byte>();
    Byte val;
    do {
        val = inputStream.readByte();
        answerList.add(val);
    } while (val != ETX);
    byte[] answer = ArrayUtils.toPrimitive(answerList.toArray(new Byte[0]));
    return answer;
}
 
源代码10 项目: cloudstack   文件: KVMHostActivityChecker.java
public long[] getNeighbors(Host agent) {
    List<Long> neighbors = new ArrayList<Long>();
    List<HostVO> cluster_hosts = resourceManager.listHostsInClusterByStatus(agent.getClusterId(), Status.Up);
    for (HostVO host : cluster_hosts) {
        if (host.getId() == agent.getId() || (host.getHypervisorType() != Hypervisor.HypervisorType.KVM && host.getHypervisorType() != Hypervisor.HypervisorType.LXC)) {
            continue;
        }
        neighbors.add(host.getId());
    }
    return ArrayUtils.toPrimitive(neighbors.toArray(new Long[neighbors.size()]));
}
 
源代码11 项目: freehealth-connector   文件: Document.java
/** @deprecated */
@Deprecated
public final void setContent(Byte[] content) {
   this.content = ArrayUtils.toPrimitive(content);
}
 
源代码12 项目: freehealth-connector   文件: Document.java
/** @deprecated */
@Deprecated
public final void setContent(Byte[] content) {
   this.content = ArrayUtils.toPrimitive(content);
}
 
源代码13 项目: freehealth-connector   文件: Document.java
/** @deprecated */
@Deprecated
public final void setContent(Byte[] content) {
   this.content = ArrayUtils.toPrimitive(content);
}
 
源代码14 项目: freehealth-connector   文件: Document.java
/** @deprecated */
@Deprecated
public final void setContent(Byte[] content) {
   this.content = ArrayUtils.toPrimitive(content);
}
 
源代码15 项目: grakn   文件: KCVSLogManager.java
/**
 * Opens a LOG manager against the provided KCVS store with the given configuration. Also provided is a list
 * of read-partition-ids. These only apply when readers are registered against an opened LOG. In that case,
 * the readers only read from the provided list of partition ids.
 */
private KCVSLogManager(KeyColumnValueStoreManager storeManager, Configuration config, int[] readPartitionIds) {
    Preconditions.checkArgument(storeManager != null && config != null);
    if (config.has(LOG_STORE_TTL)) {
        indexStoreTTL = getTTLSeconds(config.get(LOG_STORE_TTL));
        StoreFeatures storeFeatures = storeManager.getFeatures();
        if (storeFeatures.hasCellTTL() && !storeFeatures.hasStoreTTL()) {
            // Reduce cell-level TTL (fine-grained) to store-level TTL (coarse-grained)
            storeManager = new TTLKCVSManager(storeManager);
        } else if (!storeFeatures.hasStoreTTL()) {
            LOG.warn("Log is configured with TTL but underlying storage backend does not support TTL, hence this" +
                    "configuration option is ignored and entries must be manually removed from the backend.");
        }
    } else {
        indexStoreTTL = -1;
    }

    this.storeManager = storeManager;
    this.configuration = config;
    openLogs = new HashMap<>();

    this.senderId = config.get(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID);
    Preconditions.checkNotNull(senderId);

    int maxPartitions;
    if (config.has(LOG_MAX_PARTITIONS)) maxPartitions = config.get(LOG_MAX_PARTITIONS);
    else maxPartitions = Math.max(1, config.get(CLUSTER_MAX_PARTITIONS) / CLUSTER_SIZE_DIVIDER);
    Preconditions.checkArgument(maxPartitions <= config.get(CLUSTER_MAX_PARTITIONS),
            "Number of LOG partitions cannot be larger than number of cluster partitions");
    this.partitionBitWidth = NumberUtil.getPowerOf2(maxPartitions);

    Preconditions.checkArgument(partitionBitWidth >= 0 && partitionBitWidth < 32);
    int numPartitions = (1 << partitionBitWidth);

    //Partitioning
    if (partitionBitWidth > 0 && !config.get(LOG_FIXED_PARTITION)) {
        //Write partitions - default initialization: writing to all partitions
        int[] writePartitions = new int[numPartitions];
        for (int i = 0; i < numPartitions; i++) writePartitions[i] = i;
        if (storeManager.getFeatures().hasLocalKeyPartition()) {
            //Write only to local partitions
            List<Integer> localPartitions = new ArrayList<>();
            try {
                List<PartitionIDRange> partitionRanges = PartitionIDRange.getIDRanges(partitionBitWidth,
                        storeManager.getLocalKeyPartition());
                for (PartitionIDRange idRange : partitionRanges) {
                    for (int p : idRange.getAllContainedIDs()) localPartitions.add(p);
                }
            } catch (Throwable e) {
                LOG.error("Could not process local id partitions", e);
            }

            if (!localPartitions.isEmpty()) {
                writePartitions = ArrayUtils.toPrimitive(localPartitions.toArray(new Integer[localPartitions.size()]));
            }
        }
        this.defaultWritePartitionIds = writePartitions;
        //Read partitions
        if (readPartitionIds != null && readPartitionIds.length > 0) {
            for (int readPartitionId : readPartitionIds) {
                checkValidPartitionId(readPartitionId, partitionBitWidth);
            }
            this.readPartitionIds = Arrays.copyOf(readPartitionIds, readPartitionIds.length);
        } else {
            this.readPartitionIds = new int[numPartitions];
            for (int i = 0; i < numPartitions; i++) this.readPartitionIds[i] = i;
        }
    } else {
        this.defaultWritePartitionIds = new int[]{0};
        Preconditions.checkArgument(readPartitionIds == null || (readPartitionIds.length == 0 && readPartitionIds[0] == 0),
                "Cannot configure read partition ids on unpartitioned backend or with fixed partitions enabled");
        this.readPartitionIds = new int[]{0};
    }

    this.serializer = new StandardSerializer();
}
 
源代码16 项目: mtas   文件: MtasToken.java
/**
 * Adds the positions.
 *
 * @param list the list
 */
final public void addPositions(Set<Integer> list) {
  int[] positions = ArrayUtils
      .toPrimitive(list.toArray(new Integer[list.size()]));
  addPositions(positions);
}
 
源代码17 项目: titan1withtp3.1   文件: KCVSLogManager.java
/**
 * Opens a log manager against the provided KCVS store with the given configuration. Also provided is a list
 * of read-partition-ids. These only apply when readers are registered against an opened log. In that case,
 * the readers only read from the provided list of partition ids.
 * @param storeManager
 * @param config
 * @param readPartitionIds
 */
public KCVSLogManager(KeyColumnValueStoreManager storeManager, final Configuration config,
                      final int[] readPartitionIds) {
    Preconditions.checkArgument(storeManager!=null && config!=null);
    if (config.has(LOG_STORE_TTL)) {
        indexStoreTTL = ConversionHelper.getTTLSeconds(config.get(LOG_STORE_TTL));
        StoreFeatures storeFeatures = storeManager.getFeatures();
        if (storeFeatures.hasCellTTL() && !storeFeatures.hasStoreTTL()) {
            // Reduce cell-level TTL (fine-grained) to store-level TTL (coarse-grained)
            storeManager = new TTLKCVSManager(storeManager);
        } else if (!storeFeatures.hasStoreTTL()){
            log.warn("Log is configured with TTL but underlying storage backend does not support TTL, hence this" +
                    "configuration option is ignored and entries must be manually removed from the backend.");
        }
    } else {
        indexStoreTTL = -1;
    }

    this.storeManager = storeManager;
    this.configuration = config;
    openLogs = new HashMap<String, KCVSLog>();

    this.senderId=config.get(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID);
    Preconditions.checkNotNull(senderId);

    int maxPartitions;
    if (config.has(LOG_MAX_PARTITIONS)) maxPartitions = config.get(LOG_MAX_PARTITIONS);
    else maxPartitions = Math.max(1,config.get(CLUSTER_MAX_PARTITIONS)/CLUSTER_SIZE_DIVIDER);
    Preconditions.checkArgument(maxPartitions<=config.get(CLUSTER_MAX_PARTITIONS),
            "Number of log partitions cannot be larger than number of cluster partitions");
    this.partitionBitWidth= NumberUtil.getPowerOf2(maxPartitions);

    Preconditions.checkArgument(partitionBitWidth>=0 && partitionBitWidth<32);
    final int numPartitions = (1<<partitionBitWidth);

    //Partitioning
    if (partitionBitWidth>0 && !config.get(LOG_FIXED_PARTITION)) {
        //Write partitions - default initialization: writing to all partitions
        int[] writePartitions = new int[numPartitions];
        for (int i=0;i<numPartitions;i++) writePartitions[i]=i;
        if (storeManager.getFeatures().hasLocalKeyPartition()) {
            //Write only to local partitions
            List<Integer> localPartitions = new ArrayList<Integer>();
            try {
                List<PartitionIDRange> partitionRanges = PartitionIDRange.getIDRanges(partitionBitWidth,
                        storeManager.getLocalKeyPartition());
                for (PartitionIDRange idrange : partitionRanges) {
                    for (int p : idrange.getAllContainedIDs()) localPartitions.add(p);
                }
            } catch (Throwable e) {
                log.error("Could not process local id partitions",e);
            }

            if (!localPartitions.isEmpty()) {
                writePartitions = ArrayUtils.toPrimitive(localPartitions.toArray(new Integer[localPartitions.size()]));
            }
        }
        this.defaultWritePartitionIds = writePartitions;
        //Read partitions
        if (readPartitionIds!=null && readPartitionIds.length>0) {
            for (int readPartitionId : readPartitionIds) {
                checkValidPartitionId(readPartitionId,partitionBitWidth);
            }
            this.readPartitionIds = Arrays.copyOf(readPartitionIds,readPartitionIds.length);
        } else {
            this.readPartitionIds=new int[numPartitions];
            for (int i=0;i<numPartitions;i++) this.readPartitionIds[i]=i;
        }
    } else {
        this.defaultWritePartitionIds=new int[]{0};
        Preconditions.checkArgument(readPartitionIds==null || (readPartitionIds.length==0 && readPartitionIds[0]==0),
                "Cannot configure read partition ids on unpartitioned backend or with fixed partitions enabled");
        this.readPartitionIds=new int[]{0};
    }

    this.serializer = new StandardSerializer();
}
 
源代码18 项目: sissi   文件: MongoUtils.java
public static int[] asInts(DBObject db, String key) {
	List<?> value = MongoUtils.asList(db, key);
	return value != null ? ArrayUtils.toPrimitive(value.toArray(new Integer[] {})) : null;
}
 
源代码19 项目: CardinalPGM   文件: PlayerBoundingBox.java
private Packet getRemovePacket() {
    int[] ids = ArrayUtils.toPrimitive(zombieID.toArray(new Integer[4]));
    return new PacketPlayOutEntityDestroy(ids);
}
 
源代码20 项目: gatk   文件: SAMPileupFeature.java
/**
 * Gets the bases in byte array form
 *
 * Note: this call costs O(n) and allocates fresh array each time
 */
public byte[] getBases() {
    final List<Byte> bases = getBasesStream().collect(Collectors.toList());
    return ArrayUtils.toPrimitive(bases.toArray(new Byte[bases.size()]));
}