当前位置: 首页>>代码示例>>Java>>正文


Java ArrayTable.create方法代码示例

本文整理汇总了Java中com.google.common.collect.ArrayTable.create方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayTable.create方法的具体用法?Java ArrayTable.create怎么用?Java ArrayTable.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ArrayTable的用法示例。


在下文中一共展示了ArrayTable.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllFromRedis

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
private Table<String, ResourceType, Response<Map<String, String>>> getAllFromRedis(Set<String> userIds) {
  if (userIds.size() == 0) {
    return HashBasedTable.create();
  }
  try (Jedis jedis = jedisSource.getJedis()) {
    Table<String, ResourceType, Response<Map<String, String>>> responseTable =
        ArrayTable.create(userIds, new ArrayIterator<>(ResourceType.values()));

    Pipeline p = jedis.pipelined();
    for (String userId : userIds) {
      for (ResourceType r : ResourceType.values()) {
        responseTable.put(userId, r, p.hgetAll(userKey(userId, r)));
      }
    }
    p.sync();
    return responseTable;
  } catch (Exception e) {
    log.error("Storage exception reading all entries.", e);
  }
  return null;
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:22,代码来源:RedisPermissionsRepository.java

示例2: GridImageData

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
public  GridImageData(String fileName, String dataUrl,int gridSize,int row,int col,int imageWidth,int imageHeight) {
	super();
	this.fileName = fileName;
	this.dataUrl = dataUrl;
	this.gridSize=gridSize;
	this.row=row;
	this.col=col;
	this.imageHeight=imageHeight;
	this.imageWidth=imageWidth;
	
	
	Collection<Integer> rowValues=new ArrayList<Integer>();
	Collection<Integer> colValues=new ArrayList<Integer>();
	for(int i=0;i<row;i++){
		rowValues.add(i);
	}
	for(int i=0;i<col;i++){
		colValues.add(i);
	}
	gridTable=ArrayTable.create(rowValues, colValues);
	
}
 
开发者ID:akjava,项目名称:gwthtml5apps,代码行数:23,代码来源:GridPaint.java

示例3: arrayTable

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
private static void arrayTable() throws IOException {
       List<Integer> ages = new ArrayList<>();
       for(int i = 1; i <= 18; i++) {
           ages.add(i);
       }

       String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
       List<Character> chapters = new ArrayList<>();
       for(int i = 0; i < str.length(); i++) {
           chapters.add(str.charAt(i));
       }

       ArrayTable<Integer, Character, List<Person>> personsTable = ArrayTable.create(ages, chapters);
	loadFromDb(personsTable);

       for(char c = 'a'; c <= 'e'; c++) {
           Map<Integer, List<Person>> rowsPerson = personsTable.column(c);
           long count6_11 = rowsPerson.keySet()
                   .stream()
                   .filter(r -> r >= 6 && r <= 11)
                   .map(r -> rowsPerson.get(r).size()).reduce(0, Integer::sum);
           System.out.println("[6-11]-" + c + " : " + count6_11);

           long count16_18 = rowsPerson.keySet()
                   .stream()
                   .filter(r -> r >= 16 && r <= 18)
                   .map(r -> rowsPerson.get(r).size()).reduce(0, Integer::sum);
           System.out.println("[16-18]-" + c + " : " + count16_18);
       }

}
 
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:32,代码来源:MyPersonCaclByArrayTable.java

示例4: parseData

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
private Wp41HistoData parseData(DataMiningFacadeParams dmParams) throws IOException, InterruptedException {
    int rowCount = histoClient.queryCount(dmParams.getInterval(), HistoDbHorizon.SN);

    Set<HistoDbAttributeId> attributeIds = new LinkedHashSet<>((dmParams.getGensIds().size() +
                                                                dmParams.getLoadsIds().size() +
                                                                dmParams.getDanglingLinesIds().size()) * 2); // gens P, Q loads P, Q danglingLines P0, Q0
    for (String genId : dmParams.getGensIds()) {
        attributeIds.add(new HistoDbNetworkAttributeId(genId, HistoDbAttr.P));
        attributeIds.add(new HistoDbNetworkAttributeId(genId, HistoDbAttr.Q));
    }
    for (String loadId : dmParams.getLoadsIds()) {
        attributeIds.add(new HistoDbNetworkAttributeId(loadId, HistoDbAttr.P));
        attributeIds.add(new HistoDbNetworkAttributeId(loadId, HistoDbAttr.Q));
    }
    for (String dlId : dmParams.getDanglingLinesIds()) {
        attributeIds.add(new HistoDbNetworkAttributeId(dlId, HistoDbAttr.P0));
        attributeIds.add(new HistoDbNetworkAttributeId(dlId, HistoDbAttr.Q0));
    }

    List<Integer> rowIndexes;
    try (IntStream intStream = IntStream.range(0, rowCount)) {
        rowIndexes = intStream.boxed().collect(Collectors.toList());
    }
    List<String> colIndexes = attributeIds.stream().map(Object::toString).collect(Collectors.toList());

    ArrayTable<Integer, String, Float> hdTable = ArrayTable.create(rowIndexes, colIndexes);

    // parse csv generators
    try (InputStream is = histoClient.queryCsv(HistoQueryType.data, attributeIds, dmParams.getInterval(), HistoDbHorizon.SN, false, false)) {
        parseCsv(is, attributeIds, hdTable, rowCount);
    }

    return new Wp41HistoData(dmParams.getGensIds(), dmParams.getLoadsIds(), dmParams.getDanglingLinesIds(), hdTable);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:35,代码来源:DataMiningFacadeHistodb.java

示例5: parse

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
/**
 * Parses a HOCON config to a table of network rules.
 */
private static Table<Direction, AccessType, Iterable<NetworkRule>> parse(Config config) {
  Table<Direction, AccessType, Iterable<NetworkRule>> rules =
      ArrayTable.create(EnumSet.allOf(Direction.class), EnumSet.allOf(AccessType.class));
  for (Direction direction: Direction.values()) {
    for (AccessType access: AccessType.values()) {
      populateRules(config, direction, access, rules);
    }
  }
  return rules;
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:14,代码来源:NetworkRules.java

示例6: build

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
/**
 * Builds a {@link ScenarioResultModel} from the data calculated in a single cycle.
 * @param resultModel the results calculated by the engine in a single calculation cycle
 * @param columnNames column name overrides
 * @return A simple result model built from the results
 * @throws IllegalArgumentException if the number of column names doesn't match the number of columns
 */
public SimpleResultModel build(ViewResultModel resultModel, List<String> columnNames) {
  ArgumentChecker.notNull(columnNames, "columnNames");
  ArgumentChecker.notNull(resultModel, "resultModel");

  if (columnNames.size() != _columnNames.size()) {
    throw new IllegalArgumentException("Wrong number of column names. expected: " + _columnNames.size() +
                                           ", actual: " + columnNames.size());
  }
  int rowCount = _idToIndex.size();
  int colCount = columnNames.size();
  ContiguousSet<Integer> rowIndices = ContiguousSet.create(Range.closedOpen(0, rowCount), DiscreteDomain.integers());
  ContiguousSet<Integer> colIndices = ContiguousSet.create(Range.closedOpen(0, colCount), DiscreteDomain.integers());
  Table<Integer, Integer, Object> table = ArrayTable.create(rowIndices, colIndices);

  for (ViewResultEntry entry : resultModel.getAllResults()) {
    String calcConfigName = entry.getCalculationConfiguration();
    ComputedValueResult value = entry.getComputedValue();
    ValueSpecification valueSpec = value.getSpecification();
    CompiledViewCalculationConfiguration calcConfig = _compiledViewDef.getCompiledCalculationConfiguration(calcConfigName);
    Set<ValueRequirement> valueReqs = calcConfig.getTerminalOutputSpecifications().get(valueSpec);

    for (ValueRequirement valueReq : valueReqs) {
      ColumnSpec colSpec = new ColumnSpec(calcConfigName, valueReq.getValueName(), valueReq.getConstraints());
      Integer colIndex = _colToIndex.get(colSpec);
      Integer rowIndex = _idToIndex.get(valueReq.getTargetReference().getSpecification().getUniqueId().getObjectId());

      // there won't be a row or column index for specific outputs (e.g. curves)
      if (colIndex != null && rowIndex != null) {
        table.put(rowIndex, colIndex, value);
      }
      // TODO handle specific outputs
    }
  }
  return new SimpleResultModel(_targets, columnNames, table, resultModel.getViewCycleExecutionOptions());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:43,代码来源:SimpleResultBuilder.java

示例7: StateMachineServiceBuilder

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
StateMachineServiceBuilder(@NonNull final Class<S> states, @NonNull final Class<E> events) {
	stateClass = requireNonNull(states);
	eventClass = requireNonNull(events);

	transitions = ArrayTable.create(EnumSet.allOf(stateClass), EnumSet.allOf(eventClass));
	actions = ArrayTable.create(EnumSet.allOf(stateClass), EnumSet.allOf(eventClass));

	noStateTransitions = newEnumMap(eventClass);
	noStateActions = newEnumMap(eventClass);
}
 
开发者ID:Kelleth,项目名称:age3-nanorobots,代码行数:11,代码来源:StateMachineServiceBuilder.java

示例8: AggregateTrialReport

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
public AggregateTrialReport(boolean showOutcomeNames,
    boolean showAttributeNames, boolean outcomesAreRows,
    List<SimulationInputs> simulationInputs, int numTrialsPerSimulation) {
  this.showAttributeNames = showAttributeNames;
  this.showOutcomeNames = showOutcomeNames;
  this.outcomesAreRows = outcomesAreRows;
  List<Integer> columns = Lists.newArrayList();
  for (int i = 0; i < numTrialsPerSimulation; i++) {
    columns.add(i);
  }
  trialOutcomes = ArrayTable.create(simulationInputs, columns);
  nodeAggregationAttributes = Lists.newArrayList();
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:14,代码来源:AggregateTrialReport.java

示例9: getColumnTypes

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
public void getColumnTypes() {
  ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(INDICES, INDICES);
  table.put(0, 0, Result.success(1));
  table.put(0, 1, Result.success("abc"));
  table.put(1, 0, Result.success(2));
  table.put(1, 1, Result.success("def"));

  List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table));
  assertThat(columnTypes).isEqualTo(ImmutableList.of(Integer.class, String.class));
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:11,代码来源:TradeReportFormatterTest.java

示例10: getColumnTypesWithSomeFailures

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
public void getColumnTypesWithSomeFailures() {
  ImmutableList<Integer> indices = ImmutableList.of(0, 1);
  ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(indices, indices);
  table.put(0, 0, Result.failure(FailureReason.ERROR, "fail"));
  table.put(0, 1, Result.failure(FailureReason.ERROR, "fail"));
  table.put(1, 0, Result.success(2));
  table.put(1, 1, Result.success("def"));

  List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table));
  assertThat(columnTypes).isEqualTo(ImmutableList.of(Integer.class, String.class));
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:12,代码来源:TradeReportFormatterTest.java

示例11: getColumnTypesWithAllFailures

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
public void getColumnTypesWithAllFailures() {
  ImmutableList<Integer> indices = ImmutableList.of(0, 1);
  ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(indices, indices);
  table.put(0, 0, Result.failure(FailureReason.ERROR, "fail"));
  table.put(0, 1, Result.failure(FailureReason.ERROR, "fail"));
  table.put(1, 0, Result.failure(FailureReason.ERROR, "fail"));
  table.put(1, 1, Result.failure(FailureReason.ERROR, "fail"));

  List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table));
  assertThat(columnTypes).isEqualTo(ImmutableList.of(Object.class, Object.class));
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:12,代码来源:TradeReportFormatterTest.java

示例12: createInlineTable

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
static
InlineTable createInlineTable(List<List<String>> rows, List<String> columns){
	List<Integer> rowKeys = new ArrayList<>();

	for(int i = 0; i < rows.size(); i++){
		rowKeys.add(i + 1);
	}

	Table<Integer, String, String> table = ArrayTable.create(rowKeys, columns);

	for(int i = 0; i < rows.size(); i++){
		List<String> row = rows.get(i);

		for(int j = 0; j < columns.size(); j++){
			String column = columns.get(j);
			String value = row.get(j);

			if(value == null){
				continue;
			}

			table.put(rowKeys.get(i), column, value);
		}
	}

	return InlineTableUtil.format(table);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:28,代码来源:ExpressionUtilTest.java

示例13: delegate

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
@Override
public StorageObject delegate() {
    return new ArrayTableStorage(ArrayTable.create(getValue()));
}
 
开发者ID:OrigamiDream,项目名称:Leveled-Storage,代码行数:5,代码来源:ArrayTableStorage.java

示例14: CostMatrix

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
private CostMatrix(Collection<INode> children1, Collection<INode> children2) {
    costMatrix = ArrayTable.create(children1, children2);
}
 
开发者ID:lukasz-kusek,项目名称:xml-comparator,代码行数:4,代码来源:CostMatrix.java

示例15: getColumnSubset

import com.google.common.collect.ArrayTable; //导入方法依赖的package包/类
public static <R, C, V> Table<R, C, V> getColumnSubset(Table<R, C, V> table, Collection<C> columns) {

        Collection<R> rows = table.rowKeySet();

        Table<R, C, V> subTable = ArrayTable.create(rows, columns);

        for (R row : rows) {
            for (C column : columns) {
                subTable.put(row, column, table.get(row, column));
            }
        }

        return subTable;

    }
 
开发者ID:tamuri,项目名称:swmutsel,代码行数:16,代码来源:GuavaUtils.java


注:本文中的com.google.common.collect.ArrayTable.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。