List of usage examples for com.google.common.primitives Longs toArray
public static long[] toArray(Collection<? extends Number> collection)
From source file:org.voltdb.sysprocs.ValidatePartitioning.java
@Override public DependencyPair executePlanFragment(Map<Integer, List<VoltTable>> dependencies, long fragmentId, ParameterSet params, final SystemProcedureExecutionContext context) { if (fragmentId == SysProcFragmentId.PF_validatePartitioning) { final VoltTable results = constructPartitioningResultsTable(); List<Integer> tableIds = new ArrayList<Integer>(); List<String> tableNames = new ArrayList<String>(); for (Table t : context.getDatabase().getTables()) { if (!t.getIsreplicated() && t.getMaterializer() == null) { tableIds.add(t.getRelativeIndex()); tableNames.add(t.getTypeName()); }/* w w w. j a v a 2 s . c o m*/ } long mispartitionedCounts[] = context.getSiteProcedureConnection().validatePartitioning( Longs.toArray(tableIds), (Integer) params.toArray()[0], (byte[]) params.toArray()[1]); for (int ii = 0; ii < tableNames.size(); ii++) { results.addRow(context.getHostId(), CoreUtils.getSiteIdFromHSId(context.getSiteId()), context.getPartitionId(), tableNames.get(ii), mispartitionedCounts[ii]); } return new DependencyPair(DEP_validatePartitioning, results); } else if (fragmentId == SysProcFragmentId.PF_validatePartitioningResults) { assert (dependencies.size() > 0); final VoltTable results = VoltTableUtil.unionTables(dependencies.get(DEP_validatePartitioning)); return new DependencyPair(DEP_validatePartitioningResults, results); } assert (false); return null; }
From source file:org.sosy_lab.solver.mathsat5.Mathsat5UnsafeFormulaManager.java
@Override public Long replaceArgs(Long t, List<Long> newArgs) { long tDecl = msat_term_get_decl(t); return msat_make_term(msatEnv, tDecl, Longs.toArray(newArgs)); }
From source file:org.apache.hadoop.hive.ql.io.filters.BloomFilter.java
public BloomFilter(OrcProto.BloomFilter bloomFilter) { this.bitSet = new BitSet(Longs.toArray(bloomFilter.getBitsetList())); this.k = bloomFilter.getNumHashFunctions(); this.m = (int) this.bitSet.bitSize(); }
From source file:com.hpe.application.automation.tools.octane.tests.CoverageReportsDispatcher.java
private long[] getQuietPeriodsInMinutes(double retries) { double exponent = EXPONENT; List<Long> quietPeriods = new ArrayList<>(); while (exponent <= retries) { quietPeriods.add(TimeUnit2.MINUTES.toMillis((long) Math.pow(BASE, exponent))); exponent++;//from w w w.j av a 2s. c om } return Longs.toArray(quietPeriods); }
From source file:org.sosy_lab.java_smt.solvers.z3.Z3BooleanFormulaManager.java
@Override protected Long andImpl(Collection<Long> params) { if (params.size() == 2) { Iterator<Long> it = params.iterator(); return and(it.next(), it.next()); }// ww w. j av a2 s .c o m return Native.mkAnd(z3context, params.size(), Longs.toArray(params)); }
From source file:io.hops.transaction.lock.BlockLock.java
@Override protected void acquire(TransactionLocks locks) throws IOException { boolean individualBlockAlreadyRead = false; if (locks.containsLock(Type.INode)) { BaseINodeLock inodeLock = (BaseINodeLock) locks.getLock(Type.INode); Iterable blks = Collections.EMPTY_LIST; for (INode inode : inodeLock.getAllResolvedINodes()) { if (BaseINodeLock.isStoredInDB(inode)) { LOG.debug("Stuffed Inode: BlockLock. Skipping acquring locks on the inode named: " + inode.getLocalName() + " as the file is stored in the database"); announceEmptyFile(inode.getId()); continue; }//from w ww . j a v a 2 s.c o m if (inode instanceof INodeFile) { Collection<BlockInfoContiguous> inodeBlocks = Collections.EMPTY_LIST; if (((INodeFile) inode).hasBlocks()) { inodeBlocks = acquireLockList(DEFAULT_LOCK_TYPE, BlockInfoContiguous.Finder.ByINodeId, inode.getId()); } if (!individualBlockAlreadyRead) { individualBlockAlreadyRead = inode.getId() == inodeId; } if (inodeBlocks == null || inodeBlocks.isEmpty()) { announceEmptyFile(inode.getId()); } blks = Iterables.concat(blks, inodeBlocks); files.add((INodeFile) inode); } } } else if (locks.containsLock(Type.AllCachedBlock)) { AllCachedBlockLock cachedBlockLock = (AllCachedBlockLock) locks.getLock(Type.AllCachedBlock); Collection<io.hops.metadata.hdfs.entity.CachedBlock> cBlocks = cachedBlockLock .getAllResolvedCachedBlock(); Set<Long> blockIdSet = new HashSet<>(); for (io.hops.metadata.hdfs.entity.CachedBlock cBlock : cBlocks) { blockIdSet.add(cBlock.getBlockId()); } long[] blockIds = Longs.toArray(blockIdSet); long[] inodeIds = INodeUtil.resolveINodesFromBlockIds(blockIds); blocks.addAll(acquireLockList(DEFAULT_LOCK_TYPE, BlockInfoContiguous.Finder.ByBlockIdsAndINodeIds, blockIds, inodeIds)); } else { throw new TransactionLocks.LockNotAddedException( "BlockLock must come either after an InodeLock of a AllCachedBlockLock"); } if (!individualBlockAlreadyRead) { super.acquire(locks); } }
From source file:org.sosy_lab.cpachecker.util.predicates.z3.Z3InterpolatingProver.java
@Override public BooleanFormula getInterpolant(List<Long> formulasOfA) { // calc difference: formulasOfB := assertedFormulas - formulasOfA List<Long> formulasOfB = new ArrayList<>(); for (long af : assertedFormulas) { if (!formulasOfA.contains(af)) { formulasOfB.add(af);/* w w w . j a v a2s . c om*/ } } // build 2 groups: (and A1 A2 A3...) , (and B1 B2 B3...) assert formulasOfA.size() != 0; assert formulasOfB.size() != 0; long[] groupA = Longs.toArray(formulasOfA); long[] groupB = Longs.toArray(formulasOfB); long fA = mk_and(z3context, groupA); inc_ref(z3context, fA); long fB = mk_and(z3context, groupB); inc_ref(z3context, fB); // 2 groups -> 1 interpolant long[] itps = new long[1]; itps[0] = 1; // initialize with value != 0 PointerToLong labels = new PointerToLong(); PointerToLong model = new PointerToLong(); // next lines are not needed due to a direct implementation in the C-code. // long options = mk_params(z3context); // inc_ref(z3context, options); // int[] parents = new int[0]; // this line is not working long[] theory = new long[0]; // do we need a theory? long[] interpolationFormulas = new long[] { fA, fB }; smtLogger.logInterpolation(formulasOfA, formulasOfB, fA, fB); // get interpolant of groups int isSat = interpolateSeq(z3context, interpolationFormulas, itps, model, labels, 0, theory); assert isSat != Z3_LBOOL.Z3_L_TRUE.status; BooleanFormula f = mgr.encapsulateBooleanFormula(itps[0]); // cleanup dec_ref(z3context, fA); dec_ref(z3context, fB); return f; }
From source file:org.sosy_lab.cpachecker.util.predicates.mathsat5.Mathsat5UnsafeFormulaManager.java
@Override public Long replaceName(Long t, String newName) { if (isUF(t)) { long decl = msat_term_get_decl(t); int arity = msat_decl_get_arity(decl); long retType = msat_decl_get_return_type(decl); long[] argTypes = new long[arity]; for (int i = 0; i < argTypes.length; i++) { argTypes[i] = msat_decl_get_arg_type(decl, i); }//ww w . j av a 2 s. c o m long funcType = msat_get_function_type(msatEnv, argTypes, argTypes.length, retType); long funcDecl = msat_declare_function(msatEnv, newName, funcType); return msat_make_uf(msatEnv, funcDecl, Longs.toArray(getArguments(t))); } else if (isVariable(t)) { return creator.makeVariable(msat_term_get_type(t), newName); } else { throw new IllegalArgumentException("Can't set the name from the given formula!"); } }
From source file:org.sosy_lab.solver.mathsat5.Mathsat5UnsafeFormulaManager.java
@Override public Long replaceArgsAndName(Long t, String newName, List<Long> newArgs) { if (isUF(t)) { long decl = msat_term_get_decl(t); int arity = msat_decl_get_arity(decl); long retType = msat_decl_get_return_type(decl); long[] argTypes = new long[arity]; for (int i = 0; i < arity; i++) { argTypes[i] = msat_decl_get_arg_type(decl, i); }//from ww w . j ava2 s. c o m long funcType = msat_get_function_type(msatEnv, argTypes, argTypes.length, retType); long funcDecl = msat_declare_function(msatEnv, newName, funcType); return msat_make_uf(msatEnv, funcDecl, Longs.toArray(newArgs)); } else if (isVariable(t)) { checkArgument(newArgs.isEmpty()); return creator.makeVariable(msat_term_get_type(t), newName); } else { throw new IllegalArgumentException("Can't set the name from the given formula!"); } }
From source file:xfel.mods.arp.base.utils.reflection.PrimitiveTypeHelper.java
@Override public Object convertToTypeArray(Collection<?> collection) { return Longs.toArray((Collection<? extends Number>) collection); }