Java Code Examples for org.apache.commons.lang.ArrayUtils#toPrimitive()
The following examples show how to use
org.apache.commons.lang.ArrayUtils#toPrimitive() .
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
Source File: InternalAdapterStoreImpl.java From geowave with Apache License 2.0 | 6 votes |
@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)); } }
Example 2
Source File: HlsLiveStream.java From feeyo-hlsserver with Apache License 2.0 | 6 votes |
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 ); } }
Example 3
Source File: MtasPosition.java From mtas with Apache License 2.0 | 6 votes |
/** * 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; } } }
Example 4
Source File: IDatabaseImpl.java From edx-app-android with Apache License 2.0 | 6 votes |
@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])); } }
Example 5
Source File: IDatabaseImpl.java From edx-app-android with Apache License 2.0 | 6 votes |
@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])); } }
Example 6
Source File: KVMHostActivityChecker.java From cloudstack with Apache License 2.0 | 5 votes |
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()])); }
Example 7
Source File: AbstractWR3223Connector.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
/** * 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; }
Example 8
Source File: MtasDataDoubleFull.java From mtas with Apache License 2.0 | 5 votes |
@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; } }
Example 9
Source File: MtasDataLongFull.java From mtas with Apache License 2.0 | 5 votes |
@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; } }
Example 10
Source File: DefaultSession.java From ymate-platform-v2 with Apache License 2.0 | 5 votes |
@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])); }
Example 11
Source File: KCVSLogManager.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
/** * 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(); }
Example 12
Source File: PlayerBoundingBox.java From CardinalPGM with MIT License | 4 votes |
private Packet getRemovePacket() { int[] ids = ArrayUtils.toPrimitive(zombieID.toArray(new Integer[4])); return new PacketPlayOutEntityDestroy(ids); }
Example 13
Source File: MongoUtils.java From sissi with Apache License 2.0 | 4 votes |
public static int[] asInts(DBObject db, String key) { List<?> value = MongoUtils.asList(db, key); return value != null ? ArrayUtils.toPrimitive(value.toArray(new Integer[] {})) : null; }
Example 14
Source File: Document.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
/** @deprecated */ @Deprecated public final void setContent(Byte[] content) { this.content = ArrayUtils.toPrimitive(content); }
Example 15
Source File: MtasToken.java From mtas with Apache License 2.0 | 4 votes |
/** * 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); }
Example 16
Source File: KCVSLogManager.java From grakn with GNU Affero General Public License v3.0 | 4 votes |
/** * 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(); }
Example 17
Source File: Document.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
/** @deprecated */ @Deprecated public final void setContent(Byte[] content) { this.content = ArrayUtils.toPrimitive(content); }
Example 18
Source File: Document.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
/** @deprecated */ @Deprecated public final void setContent(Byte[] content) { this.content = ArrayUtils.toPrimitive(content); }
Example 19
Source File: Document.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
/** @deprecated */ @Deprecated public final void setContent(Byte[] content) { this.content = ArrayUtils.toPrimitive(content); }
Example 20
Source File: SAMPileupFeature.java From gatk with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * 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()])); }