當前位置: 首頁>>代碼示例>>Java>>正文


Java Iterables.transform方法代碼示例

本文整理匯總了Java中com.google.common.collect.Iterables.transform方法的典型用法代碼示例。如果您正苦於以下問題:Java Iterables.transform方法的具體用法?Java Iterables.transform怎麽用?Java Iterables.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.Iterables的用法示例。


在下文中一共展示了Iterables.transform方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildCartesianProduct

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
/**
 * Sets.cartesianProduct doesn't allow sets that contain null, but we want null to mean
 * "don't call the associated CacheBuilder method" - that is, get the default CacheBuilder
 * behavior. This method wraps the elements in the input sets (which may contain null) as
 * Optionals, calls Sets.cartesianProduct with those, then transforms the result to unwrap
 * the Optionals.
 */
private Iterable<List<Object>> buildCartesianProduct(Set<?>... sets) {
  List<Set<Optional<?>>> optionalSets = Lists.newArrayListWithExpectedSize(sets.length);
  for (Set<?> set : sets) {
    Set<Optional<?>> optionalSet =
        Sets.newLinkedHashSet(Iterables.transform(set, NULLABLE_TO_OPTIONAL));
    optionalSets.add(optionalSet);
  }
  Set<List<Optional<?>>> cartesianProduct = Sets.cartesianProduct(optionalSets);
  return Iterables.transform(cartesianProduct,
      new Function<List<Optional<?>>, List<Object>>() {
        @Override public List<Object> apply(List<Optional<?>> objs) {
          return Lists.transform(objs, OPTIONAL_TO_NULLABLE);
        }
      });
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:23,代碼來源:CacheBuilderFactory.java

示例2: buildAllPermutations

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
Iterable<CacheBuilder<Object, Object>> buildAllPermutations() {
  @SuppressWarnings("unchecked")
  Iterable<List<Object>> combinations = buildCartesianProduct(concurrencyLevels,
      initialCapacities, maximumSizes, expireAfterWrites, expireAfterAccesses, refreshes,
      keyStrengths, valueStrengths);
  return Iterables.transform(combinations,
      new Function<List<Object>, CacheBuilder<Object, Object>>() {
        @Override public CacheBuilder<Object, Object> apply(List<Object> combination) {
          return createCacheBuilder(
              (Integer) combination.get(0),
              (Integer) combination.get(1),
              (Integer) combination.get(2),
              (DurationSpec) combination.get(3),
              (DurationSpec) combination.get(4),
              (DurationSpec) combination.get(5),
              (Strength) combination.get(6),
              (Strength) combination.get(7));
        }
      });
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:21,代碼來源:CacheBuilderFactory.java

示例3: getUpdateStatementSetFieldSql

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
/**
 * Returns the SET statement for an SQL UPDATE statement based on the
 * {@link List} of {@link AliasedField}s provided.
 *
 * @param fields The {@link List} of {@link AliasedField}s to create the SET
 *          statement from
 * @return The SET statement as a string
 */
protected String getUpdateStatementSetFieldSql(final List<AliasedField> fields) {
  StringBuilder sqlBuilder = new StringBuilder();
  sqlBuilder.append(" SET ");

  Iterable<String> setStatements = Iterables.transform(fields, new com.google.common.base.Function<AliasedField, String>() {

    @Override
    public String apply(AliasedField field) {
      return field.getAlias() + " = " + getSqlFrom(field);
    }

  });

  sqlBuilder.append(Joiner.on(", ").join(setStatements));
  return sqlBuilder.toString();
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:25,代碼來源:SqlDialect.java

示例4: getCollectors

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Collection<CrateCollector> getCollectors(CollectPhase collectPhase,
                                                RowReceiver downstream,
                                                JobCollectContext jobCollectContext) {
    TableFunctionCollectPhase phase = (TableFunctionCollectPhase) collectPhase;
    TableFunctionImplementation tableFunctionSafe = functions.getTableFunctionSafe(phase.functionName());
    TableInfo tableInfo = tableFunctionSafe.createTableInfo(clusterService, Symbols.extractTypes(phase.arguments()));
    //noinspection unchecked  Only literals can be passed to table functions. Anything else is invalid SQL
    List<Input<?>> inputs = (List<Input<?>>) (List) phase.arguments();

    final Context context = new Context(new ArrayList<>(tableInfo.columns()));
    List<Input<?>> topLevelInputs = new ArrayList<>(phase.toCollect().size());
    for (Symbol symbol : phase.toCollect()) {
        topLevelInputs.add(implementationVisitor.process(symbol, context));
    }
    Iterable<Row> rows = Iterables.transform(
            tableFunctionSafe.execute(inputs),
            InputRow.toInputRowFunction(topLevelInputs, context.collectExpressions));
    OrderBy orderBy = phase.orderBy();
    if (orderBy != null) {
        rows = SystemCollectSource.sortRows(Iterables.transform(rows, Row.MATERIALIZE), phase);
    }
    RowsCollector rowsCollector = new RowsCollector(downstream, rows);
    return Collections.<CrateCollector>singletonList(rowsCollector);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:26,代碼來源:TableFunctionCollectSource.java

示例5: getAllVariantNames

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
public Iterable<String> getAllVariantNames() {
    synchronized (lock) {
        return aPrj != null
                ? Iterables.transform(
                        aPrj.getVariants(),
                        new Function<Variant, String>() {
                    @Override
                    public String apply(Variant f) {
                        return f.getName();
                    }
                })
                : Collections.<String>emptyList();
    }
}
 
開發者ID:NBANDROIDTEAM,項目名稱:NBANDROID-V2,代碼行數:15,代碼來源:BuildVariant.java

示例6: iterate

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Iterable<Pair<String, V>> iterate(final String keyPrefixFilter)
{
	Iterable<CachedValue> iterable = new BatchingIterator<CachedValue>()
	{
		private static final int BATCH_SIZE = 200;

		@Override
		protected Iterator<CachedValue> getMore(Optional<CachedValue> lastObj)
		{
			long startId = lastObj.isPresent() ? lastObj.get().getId() : 1;
			return dao.getBatch(cacheId, keyPrefixFilter, startId, BATCH_SIZE).iterator();
		}
	};

	return Iterables.transform(iterable, new Function<CachedValue, Pair<String, V>>()
	{
		@Override
		@Nullable
		public Pair<String, V> apply(@Nullable CachedValue input)
		{
			@SuppressWarnings("unchecked")
			V v = (V) PluginAwareObjectInputStream.fromBytes(input.getValue());
			return new Pair<>(input.getKey(), v);
		}
	});
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:28,代碼來源:ReplicatedCacheServiceImpl.java

示例7: upgrade

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public void upgrade(UpgradeContext context) {
  final NamespaceService namespaceService = new NamespaceServiceImpl(context.getKVStoreProvider().get());
  try {
    for (SourceConfig source : namespaceService.getSources()) {
      if (source.getType() == SourceType.HIVE) {
        for (NamespaceKey datasetPath : namespaceService.getAllDatasets(new NamespaceKey(source.getName()))) {
          final DatasetConfig datasetConfig = namespaceService.getDataset(datasetPath);

          // drop the metadata and splits
          if (datasetConfig.getReadDefinition() != null) {
            Iterable<DatasetSplitId> splitIdList = Iterables.transform(
              namespaceService.findSplits(DatasetSplitId.getAllSplitsRange(datasetConfig)),
              new Function<Entry<DatasetSplitId, DatasetSplit>, DatasetSplitId>() {
                @Override
                public DatasetSplitId apply(Entry<DatasetSplitId, DatasetSplit> input) {
                  return input.getKey();
                }
              });
            namespaceService.deleteSplits(splitIdList);
          }

          datasetConfig.setReadDefinition(null);
          namespaceService.addOrUpdateDataset(datasetPath, datasetConfig);
        }
      }
    }
  } catch (NamespaceException e) {
    throw new RuntimeException("FixHiveMetadata failed", e);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:32,代碼來源:FixHiveMetadata.java

示例8: getInstitutionSessions

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Iterable<UserSessionTimestamp> getInstitutionSessions()
{
	final Iterable<Pair<String, UserSessionTimestamp>> usts = allSessions.iterate("");
	return Iterables.transform(usts, new Function<Pair<String, UserSessionTimestamp>, UserSessionTimestamp>()
	{
		@Override
		@Nullable
		public UserSessionTimestamp apply(@Nullable Pair<String, UserSessionTimestamp> input)
		{
			return input.getSecond();
		}
	});
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:UserSessionServiceImpl.java

示例9: getListOfStringsMatchingLastWord

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
public static List<String> getListOfStringsMatchingLastWord(String[] p_175762_0_, Collection<?> p_175762_1_)
{
    String s = p_175762_0_[p_175762_0_.length - 1];
    List<String> list = Lists.<String>newArrayList();

    if (!p_175762_1_.isEmpty())
    {
        for (String s1 : Iterables.transform(p_175762_1_, Functions.toStringFunction()))
        {
            if (doesStringStartWith(s, s1))
            {
                list.add(s1);
            }
        }

        if (list.isEmpty())
        {
            for (Object object : p_175762_1_)
            {
                if (object instanceof ResourceLocation && doesStringStartWith(s, ((ResourceLocation)object).getResourcePath()))
                {
                    list.add(String.valueOf(object));
                }
            }
        }
    }

    return list;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:30,代碼來源:CommandBase.java

示例10: find

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Iterable<Map.Entry<KVStoreTuple<KEY>, KVStoreTuple<VALUE>>> find() {
  return Iterables.transform(rawStore.find(), new Function<Map.Entry<byte[], byte[]>, Map.Entry<KVStoreTuple<KEY>, KVStoreTuple<VALUE>>>() {
    public Map.Entry<KVStoreTuple<KEY>, KVStoreTuple<VALUE>> apply(final Map.Entry<byte[], byte[]> input) {
      return new CoreKVStoreEntry(input);
    }
  });
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:9,代碼來源:CoreKVStoreImpl.java

示例11: parametersFromColumns

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
/**
 * Generates an iterable of parameters from columns.
 *
 * @param columns table columns.
 * @return parameters matching these columns.
 */
public static Iterable<SqlParameter> parametersFromColumns(Iterable<Column> columns) {
  return Iterables.transform(columns, new Function<Column, SqlParameter>() {
    @Override
    public SqlParameter apply(Column column) {
      return new SqlParameter(column);
    }
  });
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:15,代碼來源:SqlParameter.java

示例12: createEqualsSqlForFields

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
/**
 * Transforms the entries of a list of Aliased Fields so that each entry
 * become a String: "fieldName = selectAlias.fieldName".
 *
 * @param aliasedFields an iterable of aliased fields.
 * @param selectAlias the alias of the source select of the merge statement
 * @return an iterable containing strings
 */
private Iterable<String> createEqualsSqlForFields(final Iterable<AliasedField> aliasedFields, final String selectAlias,
    final String targetTableName) {
  return Iterables.transform(aliasedFields, new com.google.common.base.Function<AliasedField, String>() {
    @Override
    public String apply(AliasedField field) {
      return String.format("%s.%s = %s.%s", targetTableName, field.getImpliedName(), selectAlias, field.getImpliedName());
    }
  });
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:18,代碼來源:SqlDialect.java

示例13: getAllElements

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
@Override
public Iterable<IEObjectDescription> getAllElements() {
	Iterable<IEObjectDescription> parent = super.getAllElements();
	return Iterables.transform(parent, new Function<IEObjectDescription, IEObjectDescription>() {
		@Override
		public IEObjectDescription apply(IEObjectDescription input) {
			return resolve(input);
		}
	});
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:UserDataAwareScope.java

示例14: caches

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
/**
 * Most of the tests in this class run against every one of these caches.
 */
private Iterable<LoadingCache<Object, Object>> caches() {
  // lots of different ways to configure a LoadingCache
  CacheBuilderFactory factory = cacheFactory();
  return Iterables.transform(factory.buildAllPermutations(),
      new Function<CacheBuilder<Object, Object>, LoadingCache<Object, Object>>() {
        @Override public LoadingCache<Object, Object> apply(
            CacheBuilder<Object, Object> builder) {
          return builder.recordStats().build(identityLoader());
        }
      });
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:15,代碼來源:PopulatedCachesTest.java

示例15: cacheTables

import com.google.common.collect.Iterables; //導入方法依賴的package包/類
private void cacheTables(Iterable<Table> newTables) {
  // Create disconnected copies of the tables in case we run across connections/data sources
  Iterable<Table> copies = Iterables.transform(newTables, new CopyTables());
  tables.putAll(Maps.uniqueIndex(copies, new Function<Table, String>() {
    @Override
    public String apply(Table table) {
      return table.getName().toUpperCase();
    }
  }));
  tablesLoaded = true;
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:12,代碼來源:DatabaseSchemaManager.java


注:本文中的com.google.common.collect.Iterables.transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。