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


Java Table類代碼示例

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


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

示例1: loadSHRMapping

import com.google.common.collect.Table; //導入依賴的package包/類
private static Table<String, String, String> loadSHRMapping() {
  if (!USE_SHR_EXTENSIONS) {
    // don't bother creating the table unless we need it
    return null;
  }
  Table<String,String,String> mappingTable = HashBasedTable.create();
  
  List<LinkedHashMap<String,String>> csvData;
  try {
    csvData = SimpleCSV.parse(Utilities.readResource("shr_mapping.csv"));
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
  
  for (LinkedHashMap<String,String> line : csvData) {
    String system = line.get("SYSTEM");
    String code = line.get("CODE");
    String url = line.get("URL");
    
    mappingTable.put(system, code, url);
  }
  
  return mappingTable;
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:26,代碼來源:FhirStu3.java

示例2: parseMatrix

import com.google.common.collect.Table; //導入依賴的package包/類
public static Table<String, String, Float> parseMatrix(Reader reader) throws IOException {
    Table<String, String, Float> table = HashBasedTable.create();
    try (ICsvListReader csvReader = new CsvListReader(reader, CsvPreference.STANDARD_PREFERENCE)) {
        List<String> columnHeaders = csvReader.read();
        List<String> row;
        while ((row = csvReader.read()) != null) {
            String rowHeader = row.get(0);
            for (int i = 1; i < row.size(); i++) {
                String columnHeader = columnHeaders.get(i);
                String value = row.get(i);
                table.put(rowHeader, columnHeader, value == null ? Float.NaN : Float.parseFloat(value));
            }
        }
    }
    return table;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:17,代碼來源:MathUtil.java

示例3: groupByProfile

import com.google.common.collect.Table; //導入依賴的package包/類
/**
 * 根據Profile分組,同名配置,根據Profile的優先級覆蓋
 *
 * @param configItemList
 * @param profileIdList
 * @return
 */
private List<BuildConfigItem> groupByProfile(List<BuildConfigItem> configItemList, List<Integer> profileIdList) {
    List<BuildConfigItem> filteredConfigItemList = new ArrayList<>();

    Table<String, Integer, List<BuildConfigItem>> configItemTable = getConfigItemTable(configItemList);

    for (String itemName : configItemTable.rowKeySet()) {
        for (int profileId : profileIdList) {
            List<BuildConfigItem> itemList = configItemTable.get(itemName, profileId);
            if (itemList != null && !itemList.isEmpty()) {
                filteredConfigItemList.addAll(itemList);
                break;
            }
        }
    }

    return filteredConfigItemList;
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:25,代碼來源:ConfigRestService.java

示例4: getConfigItemTable

import com.google.common.collect.Table; //導入依賴的package包/類
/**
 * 將配置項構造成一個二維表,[配置名稱, Profile ID, 配置項]
 *
 * @param configItemList
 * @return
 */
private Table<String, Integer, List<BuildConfigItem>> getConfigItemTable(List<BuildConfigItem> configItemList) {
    Table<String, Integer, List<BuildConfigItem>> configItemTable = HashBasedTable.create();

    List<BuildConfigItem> listByNameAndProfile = null;
    for (BuildConfigItem configItem : configItemList) {
        listByNameAndProfile = configItemTable.get(configItem.getConfigName(), configItem.getProfileId());
        if (listByNameAndProfile == null) {
            listByNameAndProfile = new ArrayList<>();
            configItemTable.put(configItem.getConfigName(), configItem.getProfileId(), listByNameAndProfile);
        }
        listByNameAndProfile.add(configItem);
    }

    return configItemTable;
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:22,代碼來源:ConfigRestService.java

示例5: buildPropertyValueTable

import com.google.common.collect.Table; //導入依賴的package包/類
public void buildPropertyValueTable(Map<Map<IProperty, Comparable>, BlockState.StateImplementation> map)
{
    if (this.propertyValueTable != null)
    {
        throw new IllegalStateException();
    }
    else
    {
        Table<IProperty, Comparable, IBlockState> table = HashBasedTable.<IProperty, Comparable, IBlockState>create();

        for (IProperty <? extends Comparable > iproperty : this.properties.keySet())
        {
            for (Comparable comparable : iproperty.getAllowedValues())
            {
                if (comparable != this.properties.get(iproperty))
                {
                    table.put(iproperty, comparable, map.get(this.getPropertiesWithValue(iproperty, comparable)));
                }
            }
        }

        this.propertyValueTable = ImmutableTable.<IProperty, Comparable, IBlockState>copyOf(table);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:BlockState.java

示例6: storeExternalCommunicatorMessage

import com.google.common.collect.Table; //導入依賴的package包/類
@Override
public void storeExternalCommunicatorMessage(final ExternalCommunicatorMessage message) {
  final String[] split = message.getTransferId().split("-");
  final Long piID = Long.valueOf(split[PI_ID_INDEX]);
  final Long mfId = Long.valueOf(split[MF_ID_INDEX]);
  final Long sId = Long.valueOf(split[S_ID_INDEX]);

  final ProcessInstance processInstance = processInstanceRepository.findOne(piID);
  final MessageFlow messageFlow = Optional.ofNullable(messageFlowRepository.findOne(mfId))
      .orElseThrow(() -> new IllegalArgumentException(
          "Could not find message flow for MF_ID [" + mfId + "]"));

  final Set<BusinessObjectInstance> businessObjectInstances =
      getBusinessObjectInstances(processInstance, messageFlow.getBusinessObjectModels());

  final Table<String, String, BusinessObjectField> records =
      convertToMap(message.getBusinessObjects());

  businessObjectInstances.stream()
      .forEachOrdered(objectInstance -> storeValues(records, objectInstance));

  final Subject subject = subjectRepository.findOne(sId);
  subject.getSubjectState().setToReceived(messageFlow);
  subjectRepository.save((SubjectImpl) subject);
}
 
開發者ID:stefanstaniAIM,項目名稱:IPPR2016,代碼行數:26,代碼來源:ProcessEngineFeignServiceImpl.java

示例7: getReader

import com.google.common.collect.Table; //導入依賴的package包/類
private ReliableTaildirEventReader getReader(Map<String, String> filePaths,
    Table<String, String, String> headerTable, boolean addByteOffset) {
  ReliableTaildirEventReader reader;
  try {
    reader = new ReliableTaildirEventReader.Builder()
        .filePaths(filePaths)
        .headerTable(headerTable)
        .positionFilePath(posFilePath)
        .skipToEnd(false)
        .addByteOffset(addByteOffset)
        .build();
    reader.updateTailFiles();
  } catch (IOException ioe) {
    throw Throwables.propagate(ioe);
  }
  return reader;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:18,代碼來源:TestTaildirEventReader.java

示例8: rateMatrix

import com.google.common.collect.Table; //導入依賴的package包/類
/**
 * retrieve a rating matrix from the tensor. Warning: it assumes there is at most one entry for each (user, item)
 * pair.
 *
 * @return a sparse rating matrix
 */
public SparseMatrix rateMatrix() {

	Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
	Multimap<Integer, Integer> colMap = HashMultimap.create();

	for (TensorEntry te : this) {
		int u = te.key(userDimension);
		int i = te.key(itemDimension);

		dataTable.put(u, i, te.get());
		colMap.put(i, u);
	}

	return new SparseMatrix(dimensions[userDimension], dimensions[itemDimension], dataTable, colMap);
}
 
開發者ID:xiaojieliu7,項目名稱:MicroServiceProject,代碼行數:22,代碼來源:SparseTensor.java

示例9: assignmentsToTable

import com.google.common.collect.Table; //導入依賴的package包/類
public static Table<String, String, String> assignmentsToTable(
        SortedMap<String, SortedSet<SingleWorkerAssignment<Step2bGoldReasonAnnotator.SentenceLabel>>> assignments)
{
    TreeBasedTable<String, String, String> result = TreeBasedTable.create();

    assignments.forEach((unitID, singleWorkerAssignments) -> {
        singleWorkerAssignments.forEach(sentenceLabelSingleWorkerAssignment -> {
            String workerID = sentenceLabelSingleWorkerAssignment.getWorkerID();
            String label = sentenceLabelSingleWorkerAssignment.getLabel().toString();

            // update the table
            result.put(unitID, workerID, label);
        });
    });

    return result;
}
 
開發者ID:UKPLab,項目名稱:argument-reasoning-comprehension-task,代碼行數:18,代碼來源:Step2dExportReasonSpanAnnotationPilot.java

示例10: MediaTypeClassifierImpl

import com.google.common.collect.Table; //導入依賴的package包/類
MediaTypeClassifierImpl(Iterable<? extends MediaType> mts) {
  Table<String, String, Set<MediaType>> typeTable =
      HashBasedTable.<String, String, Set<MediaType>>create();
  for (MediaType mt : mts) {
    String type = mt.type();
    String subtype = mt.subtype();
    Set<MediaType> typeSet = typeTable.get(type, subtype);
    if (typeSet == null) {
      typeSet = Sets.newLinkedHashSet();
      typeTable.put(type, subtype, typeSet);
    }
    typeSet.add(mt);
  }

  ImmutableTable.Builder<String, String, ImmutableSet<MediaType>> b =
      ImmutableTable.builder();
  for (Table.Cell<String, String, Set<MediaType>> cell
       : typeTable.cellSet()) {
    b.put(cell.getRowKey(), cell.getColumnKey(), ImmutableSet.copyOf(cell.getValue()));
  }
  this.types = b.build();
}
 
開發者ID:OWASP,項目名稱:url-classifier,代碼行數:23,代碼來源:MediaTypeClassifierBuilder.java

示例11: ReliableTaildirEventReader

import com.google.common.collect.Table; //導入依賴的package包/類
/**
 * Create a ReliableTaildirEventReader to watch the given directory. map<serverid.appid.logid, logpath>
 */
private ReliableTaildirEventReader(Map<String, LogPatternInfo> filePaths, Table<String, String, String> headerTable,
        String positionFilePath, boolean skipToEnd, boolean addByteOffset, String os) throws IOException {
    // Sanity checks
    Preconditions.checkNotNull(filePaths);
    Preconditions.checkNotNull(positionFilePath);
    // get operation system info
    if (logger.isDebugEnable()) {
        logger.debug(this, "Initializing {" + ReliableTaildirEventReader.class.getSimpleName()
                + "} with directory={" + filePaths + "}");
    }

    // tailFile
    this.tailFileTable = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.DAYS)
            .<String, LogPatternInfo> build();
    this.headerTable = headerTable;
    this.addByteOffset = addByteOffset;
    this.os = os;
    updatelog(filePaths);
    updateTailFiles(skipToEnd);

    logger.info(this, "tailFileTable: " + tailFileTable.toString());
    logger.info(this, "headerTable: " + headerTable.toString());
    logger.info(this, "Updating position from position file: " + positionFilePath);
    loadPositionFile(positionFilePath);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:29,代碼來源:ReliableTaildirEventReader.java

示例12: ReliableTaildirEventReader

import com.google.common.collect.Table; //導入依賴的package包/類
/**
 * Create a ReliableTaildirEventReader to watch the given directory. map<serverid.appid.logid, logpath>
 */
private ReliableTaildirEventReader(Map<String, CollectTask> tasks, Table<String, String, String> headerTable,
        boolean skipToEnd, boolean addByteOffset) throws IOException {
    Map<String, LogPatternInfo> filePaths = getFilePaths(tasks);

    // Sanity checks
    Preconditions.checkNotNull(filePaths);
    // get operation system info
    if (log.isDebugEnable()) {
        log.debug(this, "Initializing {" + ReliableTaildirEventReader.class.getSimpleName() + "} with directory={"
                + filePaths + "}");
    }

    // tailFile
    this.tailFileTable = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.DAYS)
            .<String, LogPatternInfo> build();
    this.headerTable = headerTable;
    this.addByteOffset = addByteOffset;
    this.os = JVMToolHelper.isWindows() ? OS_WINDOWS : null;

    updatelog(filePaths);
    updateTailFiles(skipToEnd);

    log.info(this, "tailFileTable: " + tailFileTable.toString());
    log.info(this, "headerTable: " + headerTable.toString());
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:29,代碼來源:ReliableTaildirEventReader.java

示例13: buildPropertyValueTable

import com.google.common.collect.Table; //導入依賴的package包/類
public void buildPropertyValueTable(Map < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > map)
{
    if (this.propertyValueTable != null)
    {
        throw new IllegalStateException();
    }
    else
    {
        Table < IProperty<?>, Comparable<?>, IBlockState > table = HashBasedTable. < IProperty<?>, Comparable<?>, IBlockState > create();

        for (Entry < IProperty<?>, Comparable<? >> entry : this.properties.entrySet())
        {
            IProperty<?> iproperty = (IProperty)entry.getKey();

            for (Comparable<?> comparable : iproperty.getAllowedValues())
            {
                if (comparable != entry.getValue())
                {
                    table.put(iproperty, comparable, map.get(this.getPropertiesWithValue(iproperty, comparable)));
                }
            }
        }

        this.propertyValueTable = ImmutableTable. < IProperty<?>, Comparable<?>, IBlockState > copyOf(table);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:BlockStateContainer.java

示例14: main

import com.google.common.collect.Table; //導入依賴的package包/類
public static void main(String[] args) {
    TreeBasedTable<Integer, Integer, Integer> table = TreeBasedTable.create();

    table.put(2, 0, 6);
    table.put(3, 2, 4);
    table.put(0, 0, 5);
    table.put(0, 3, 2);
    table.put(4, 1, 2);
    table.put(4, 4, 9);


    CSRSparseMatrix csr = new CSRSparseMatrix(table, 5);

    for (Table.Cell<Integer, Integer, Integer> cell : table.cellSet()) {
        if (csr.get(cell.getRowKey(), cell.getColumnKey()) == cell.getValue()) {
            System.out.println(String.format("%d->%d = %d", cell.getRowKey(), cell.getColumnKey(), cell.getValue()));
        } else {
            System.out.println("ERROR");
        }
    }


}
 
開發者ID:mayabot,項目名稱:mynlp,代碼行數:24,代碼來源:CSRSparseMatrix.java

示例15: main

import com.google.common.collect.Table; //導入依賴的package包/類
public static void main(String[] args)
{
   Table<String, String, String> table = TreeBasedTable.create();

   table.put("Row1", "Column1", "Data1");
   table.put("Row1", "Column2", "Data2");

   table.put("Row2", "Column1", "Data3");
   table.put("Row2", "Column2", "Data4");

   table.put("Row3", "Column1", "Data5");
   table.put("Row3", "Column2", "Data6");
   table.put("Row3", "Column3", "Data7");

   Joiner.MapJoiner mapJoiner = Joiner.on(',').withKeyValueSeparator("="); //Let's a Guava Joiner to illustrate that

   table.rowKeySet().forEach(r -> {
      System.out.println(r + "->" + mapJoiner.join(table.row(r)));
   });
}
 
開發者ID:developerSid,項目名稱:AwesomeJavaLibraryExamples,代碼行數:21,代碼來源:ExampleTable.java


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