本文整理匯總了Java中com.google.common.collect.Lists.newArrayList方法的典型用法代碼示例。如果您正苦於以下問題:Java Lists.newArrayList方法的具體用法?Java Lists.newArrayList怎麽用?Java Lists.newArrayList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Lists
的用法示例。
在下文中一共展示了Lists.newArrayList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rollForwardByApplyingLogs
import com.google.common.collect.Lists; //導入方法依賴的package包/類
static void rollForwardByApplyingLogs(
RemoteEditLogManifest manifest,
FSImage dstImage,
FSNamesystem dstNamesystem) throws IOException {
NNStorage dstStorage = dstImage.getStorage();
List<EditLogInputStream> editsStreams = Lists.newArrayList();
for (RemoteEditLog log : manifest.getLogs()) {
if (log.getEndTxId() > dstImage.getLastAppliedTxId()) {
File f = dstStorage.findFinalizedEditsFile(
log.getStartTxId(), log.getEndTxId());
editsStreams.add(new EditLogFileInputStream(f, log.getStartTxId(),
log.getEndTxId(), true));
}
}
LOG.info("Checkpointer about to load edits from " +
editsStreams.size() + " stream(s).");
dstImage.loadEdits(editsStreams, dstNamesystem);
}
示例2: testDate_Part
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Test
public void testDate_Part() throws Exception {
final String query = "select date_part('year', date '2008-2-23') as col \n" +
"from cp.`tpch/region.parquet` \n" +
"limit 0";
List<Pair<SchemaPath, MajorType>> expectedSchema = Lists.newArrayList();
MajorType majorType = Types.required(MinorType.BIGINT);
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));
testBuilder()
.sqlQuery(query)
.schemaBaseLine(expectedSchema)
.build()
.run();
}
示例3: getOrderCartProduct
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public ServerResponse getOrderCartProduct(Integer userId) {
OrderProductVo orderProductVo = new OrderProductVo();
List<Cart> cartList = cartMapper.selectCheckedCartByUserId(userId);
ServerResponse serverResponse = this.getCartOrderItem(userId, cartList);
if (!serverResponse.isSuccess()) {
return serverResponse;
}
List<OrderItem> orderItemList = (List<OrderItem>) serverResponse.getData();
List<OrderItemVo> orderItemVoList = Lists.newArrayList();
BigDecimal payment = new BigDecimal("0");
for (OrderItem orderItem : orderItemList) {
payment = BigDecimalUtil.add(payment.doubleValue(), orderItem.getTotalPrice().doubleValue());
orderItemVoList.add(assembleOrderItemVo(orderItem));
}
orderProductVo.setProductTotalPrice(payment);
orderProductVo.setOrderItemVoList(orderItemVoList);
orderProductVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix"));
return ServerResponse.createBySuccess(orderProductVo);
}
示例4: addTabCompletionOptions
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
Scoreboard scoreboard = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
List<String> list = Lists.<String>newArrayList();
for (ScoreObjective scoreobjective : scoreboard.getScoreObjectives())
{
if (scoreobjective.getCriteria() == IScoreObjectiveCriteria.TRIGGER)
{
list.add(scoreobjective.getName());
}
}
return getListOfStringsMatchingLastWord(args, (String[])list.toArray(new String[list.size()]));
}
else
{
return args.length == 2 ? getListOfStringsMatchingLastWord(args, new String[] {"add", "set"}): null;
}
}
示例5: deserialize
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public List<Object> deserialize(ByteBuffer ser) {
// If this flag is true, return null.
if (returnNull) {
return null;
}
// Probably a better way to do this juggling.
if (ser == null) {
return null;
}
ser.rewind();
byte[] bytes = new byte[ser.remaining()];
ser.get(bytes, 0, bytes.length);
return Lists.newArrayList(new String(bytes, Charsets.UTF_8));
}
示例6: withTasksExceedingTimeout
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Test
public void withTasksExceedingTimeout() throws Exception {
UserException ex = null;
try {
List<TimedRunnable<Void>> tasks = Lists.newArrayList();
for (int i = 0; i < 100; i++) {
if ((i & (i + 1)) == 0) {
tasks.add(new TestTask(2000));
} else {
tasks.add(new TestTask(20000));
}
}
TimedRunnable.run("Execution with some tasks triggering timeout", logger, tasks, 16);
} catch (UserException e) {
ex = e;
}
assertNotNull("Expected a UserException", ex);
assertThat(ex.getMessage(),
containsString("Waited for 93750ms, but tasks for 'Execution with some tasks triggering timeout' are not " +
"complete. Total runnable size 100, parallelism 16."));
}
示例7: nonExistingPartitionsAreFiltered
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Test
public void nonExistingPartitionsAreFiltered() throws Exception {
List<Partition> filteredPartitions = Lists.newArrayList(sourcePartition1);
when(source.getLocationManager(sourceTable, filteredPartitions, EVENT_ID, copierOptions))
.thenReturn(sourceLocationManager);
when(source.getPartitions(sourceTable, PARTITION_PREDICATE, MAX_PARTITIONS)).thenReturn(partitionsAndStatistics);
when(replica.getTable(replicaClient, DATABASE, TABLE)).thenReturn(Optional.of(previousReplicaTable));
when(previousReplicaTable.getSd()).thenReturn(sd);
when(sd.getLocation()).thenReturn(tableLocation);
// mimics that the first partitions exist but second partition didn't so it will be filtered
when(replicaClient.getPartition(DATABASE, TABLE, sourcePartition2.getValues()))
.thenThrow(new NoSuchObjectException());
PartitionedTableMetadataUpdateReplication replication = new PartitionedTableMetadataUpdateReplication(DATABASE,
TABLE, partitionPredicate, source, replica, eventIdFactory, replicaLocation, DATABASE, TABLE);
replication.replicate();
InOrder replicationOrder = inOrder(sourceLocationManager, replica);
replicationOrder.verify(replica).validateReplicaTable(DATABASE, TABLE);
ArgumentCaptor<PartitionsAndStatistics> partitionsAndStatisticsCaptor = ArgumentCaptor
.forClass(PartitionsAndStatistics.class);
replicationOrder.verify(replica).updateMetadata(eq(EVENT_ID), eq(sourceTableAndStatistics),
partitionsAndStatisticsCaptor.capture(), eq(sourceLocationManager), eq(DATABASE), eq(TABLE),
any(ReplicaLocationManager.class));
PartitionsAndStatistics value = partitionsAndStatisticsCaptor.getValue();
assertThat(value.getPartitions().size(), is(1));
assertThat(value.getPartitionNames().get(0), is("a=1"));
}
開發者ID:HotelsDotCom,項目名稱:circus-train,代碼行數:29,代碼來源:PartitionedTableMetadataUpdateReplicationTest.java
示例8: test1
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Test
public void test1() {
List<String> list = Lists.newArrayList("我 3 公斤 ipad 30 公斤".split(" "));
FST<String> fst = new FST<String>();
fst.start()
.edge(FstCondition.pattern("\\d+"), "數字")
.edge(FstCondition.in(Sets.newHashSet("公斤")), "$$");
fst.start()
.edge(FstCondition.pattern("\\w+"), "單詞").
edge(FstCondition.pattern("\\d+"), "$$");
fst.fluze();
FstMatcher<String, String> m = fst.newMatcher(list);
while (m.find()) {
System.out.println(m.getStart() + "-" + m.getLength() + " " + list.subList(m.getStart(), m.getStart() + m.getLength()));
}
//
// long t1 = System.currentTimeMillis();
// for(int i=0;i<1000000;i++){
// int j=0;
// FstMatcher<Integer,Vertex> m1 = fst.newMatcher();
// for(Vertex v : list){
// m1.input(j++, v, fp);
// }
// }
// long t2 = System.currentTimeMillis();
// System.out.println(t2-t1);
}
示例9: RecordingBinder
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private RecordingBinder(Stage stage) {
this.stage = stage;
this.modules = Maps.newLinkedHashMap();
this.scanners = Sets.newLinkedHashSet();
this.elements = Lists.newArrayList();
this.source = null;
this.sourceProvider = SourceProvider.DEFAULT_INSTANCE.plusSkippedClasses(
Elements.class, RecordingBinder.class, AbstractModule.class,
ConstantBindingBuilderImpl.class, AbstractBindingBuilder.class, BindingBuilder.class);
this.parent = null;
this.privateElements = null;
this.privateBinders = Lists.newArrayList();
}
示例10: getChildNodes
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public List<HtmlTreeNode> getChildNodes(SectionInfo info, String xpath)
{
final List<HtmlTreeNode> list = Lists.newArrayList();
Long schemaId = getModel(info).getSelectedSchema();
if( schemaId == 0 )
{
return Collections.emptyList();
}
Schema schema = schemaService.get(schemaId);
if( xpath == null )
{
xpath = "";
}
final PropBagEx schemaXml = schema.getDefinitionNonThreadSafe();
for( PropBagEx child : schemaXml.iterator(xpath + "/*") )
{
String name = child.getNodeName();
if( isAttribute(child) )
{
name = "@" + name;
}
String fullpath = Check.isEmpty(xpath) ? name : MessageFormat.format("{0}/{1}", xpath, name);
list.add(new SchemaTreeNode(name, fullpath, isLeaf(child), isSelected(info, fullpath)));
}
return list;
}
示例11: mergeResults
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private DependentBinariesResolvedResult mergeResults(Collection<DependentBinariesResolvedResult> results) {
DependentBinariesResolvedResult first = results.iterator().next();
if (results.size() == 1) {
return first;
}
boolean hasNotBuildables = false;
boolean hasTestSuites = false;
LinkedListMultimap<LibraryBinaryIdentifier, DependentBinariesResolvedResult> index = LinkedListMultimap.create();
List<DependentBinariesResolvedResult> allChildren = Lists.newArrayList();
for (DependentBinariesResolvedResult result : results) {
if (!result.isBuildable()) {
hasNotBuildables = true;
}
if (result.isTestSuite()) {
hasTestSuites = true;
}
allChildren.addAll(result.getChildren());
for (DependentBinariesResolvedResult child : result.getChildren()) {
index.put(child.getId(), child);
}
}
List<DependentBinariesResolvedResult> children = Lists.newArrayList();
for (Collection<DependentBinariesResolvedResult> childResults : index.asMap().values()) {
children.add(mergeResults(childResults));
}
return new DefaultDependentBinariesResolvedResult(first.getId(), first.getProjectScopedName(), !hasNotBuildables, hasTestSuites, children);
}
示例12: getStacksPathItems
import com.google.common.collect.Lists; //導入方法依賴的package包/類
List<PathItem> getStacksPathItems(Map<XreStackPath, Integer> stackToNodesCount, final Map<XreStackPath, Integer> whitelistedStackToNodesCount) {
return Lists.newArrayList(Collections2.transform(stackToNodesCount.entrySet(), new Function<Map.Entry<XreStackPath, Integer>, PathItem>() {
@Override
public PathItem apply(Map.Entry<XreStackPath, Integer> input) {
XreStackPath stack = input.getKey();
int count = input.getValue();
int whitelistedCount = whitelistedStackToNodesCount.containsKey(stack)
? whitelistedStackToNodesCount.get(stack) : 0;
return new PathItem(stack.getStackAndFlavorPath(), count, whitelistedCount);
}
}));
}
示例13: setup
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
this.operatorContext = context;
this.writer = new VectorContainerWriter(output);
this.jsonReader = new JsonReader(fragmentContext.getManagedBuffer(), Lists.newArrayList(getColumns()), enableAllTextMode, false, readNumbersAsDouble);
}
示例14: prepareStructurePieces
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* sets up Arrays with the Structure pieces and their weights
*/
public static void prepareStructurePieces()
{
structurePieceList = Lists.<StructureStrongholdPieces.PieceWeight>newArrayList();
for (StructureStrongholdPieces.PieceWeight structurestrongholdpieces$pieceweight : pieceWeightArray)
{
structurestrongholdpieces$pieceweight.instancesSpawned = 0;
structurePieceList.add(structurestrongholdpieces$pieceweight);
}
strongComponentType = null;
}
示例15: defaultArgs
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private String[] defaultArgs(Param param) {
List<String> res = Lists.newArrayList();
if(param.hasPathVar()) res.add(param.pathVar);
if(param.hasName()) res.add(String.format("'%s'", param.name));
res.add(param.value);
return res.toArray(new String[res.size()]);
}