コード例 #1
0
 public Edge getAssociationWeight(Vertex v1, Vertex v2) {
   Edge edge = graph.get(v1, v2);
   if (edge == null) {
     edge = graph.get(v2, v1);
   }
   return edge;
 }
コード例 #2
0
  public void updateStatistics(Request request, boolean cachedResponse) {
    URI proxyUri = null;
    try {
      proxyUri = new URI(request.getOptions().getProxyURI());
    } catch (URISyntaxException e) {
      LOGGER.warning(String.format("Proxy-uri malformed: %s", request.getOptions().getProxyURI()));
    }

    if (proxyUri == null) {
      // throw new IllegalArgumentException("proxyUri == null");
      return;
    }

    // manage the address requester
    String addressString = proxyUri.getHost();
    if (addressString != null) {
      // manage the resource requested
      String resourceString = proxyUri.getPath();
      if (resourceString != null) {
        // check if there is already an entry for the row/column
        // association
        StatHelper statHelper = statsTable.get(addressString, resourceString);
        if (statHelper == null) {
          // create a new stat if it not present
          statHelper = new StatHelper();

          // add the new element to the table
          statsTable.put(addressString, resourceString, statHelper);
        }

        // increment the count of the requests
        statHelper.increment(cachedResponse);
      }
    }
  }
コード例 #3
0
  private Table<String, MetricDto, MeasureDto> searchMeasuresByComponentUuidAndMetric(
      DbSession dbSession,
      ComponentDto baseComponent,
      List<ComponentDto> components,
      List<MetricDto> metrics,
      List<WsMeasures.Period> periods,
      @Nullable Long developerId) {
    List<String> componentUuids = new ArrayList<>();
    componentUuids.add(baseComponent.uuid());
    components.stream().forEach(c -> componentUuids.add(c.uuid()));

    Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDtoFunctions.toId());
    MeasureQuery measureQuery =
        MeasureQuery.builder()
            .setPersonId(developerId)
            .setComponentUuids(componentUuids)
            .setMetricIds(metricsById.keySet())
            .build();
    List<MeasureDto> measureDtos = dbClient.measureDao().selectByQuery(dbSession, measureQuery);

    Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric =
        HashBasedTable.create(components.size(), metrics.size());
    for (MeasureDto measureDto : measureDtos) {
      measuresByComponentUuidAndMetric.put(
          measureDto.getComponentUuid(), metricsById.get(measureDto.getMetricId()), measureDto);
    }

    addBestValuesToMeasures(measuresByComponentUuidAndMetric, components, metrics, periods);

    return measuresByComponentUuidAndMetric;
  }
コード例 #4
0
  public static Map<String, String> match(
      Table<Integer, String, String> table, Map<String, FieldValue> values) {
    Set<Integer> rowKeys = table.rowKeySet();

    rows:
    for (Integer rowKey : rowKeys) {
      Map<String, String> row = table.row(rowKey);

      // A table row contains a certain number of input columns, plus an output column
      if (values.size() < (row.size() - 1)) {
        continue rows;
      }

      Collection<Map.Entry<String, FieldValue>> entries = values.entrySet();
      for (Map.Entry<String, FieldValue> entry : entries) {
        String key = entry.getKey();
        FieldValue value = entry.getValue();

        String rowValue = row.get(key);
        if (rowValue == null) {
          continue rows;
        }

        boolean equals = value.equalsString(rowValue);
        if (!equals) {
          continue rows;
        }
      }

      return row;
    }

    return null;
  }
コード例 #5
0
  /**
   * Conditions for best value measure:
   *
   * <ul>
   *   <li>component is a production file or test file
   *   <li>metric is optimized for best value
   * </ul>
   */
  private static void addBestValuesToMeasures(
      Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric,
      List<ComponentDto> components,
      List<MetricDto> metrics,
      List<WsMeasures.Period> periods) {
    List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure =
        from(metrics)
            .filter(MetricDtoFunctions.isOptimizedForBestValue())
            .transform(new MetricDtoToMetricDtoWithBestValue(periods))
            .toList();
    if (metricDtosWithBestValueMeasure.isEmpty()) {
      return;
    }

    List<ComponentDto> componentsEligibleForBestValue =
        from(components).filter(IsFileComponent.INSTANCE).toList();
    for (ComponentDto component : componentsEligibleForBestValue) {
      for (MetricDtoWithBestValue metricWithBestValue : metricDtosWithBestValueMeasure) {
        if (measuresByComponentUuidAndMetric.get(component.uuid(), metricWithBestValue.getMetric())
            == null) {
          measuresByComponentUuidAndMetric.put(
              component.uuid(),
              metricWithBestValue.getMetric(),
              metricWithBestValue.getBestValue());
        }
      }
    }
  }
コード例 #6
0
 /**
  * Return the virtual CPU for to the virtual machine and requested CPU ID
  *
  * @param vm The virtual machine
  * @param cpu the CPU number
  * @return the virtual CPU
  */
 public static synchronized VirtualCPU getVirtualCPU(VirtualMachine vm, Long cpu) {
   VirtualCPU ht = VIRTUAL_CPU_TABLE.get(vm, cpu);
   if (ht == null) {
     ht = new VirtualCPU(vm, cpu);
     VIRTUAL_CPU_TABLE.put(vm, cpu, ht);
   }
   return ht;
 }
コード例 #7
0
ファイル: UISkinBuilder.java プロジェクト: DVisman/Terasology
  private UIStyleFamily buildFamily(String family, UISkin skin) {
    UIStyleFamily baseFamily = skin.getFamily(family);
    UIStyle baseStyle = new UIStyle(skin.getDefaultStyleFor(family));
    if (!family.isEmpty()) {
      UIStyleFragment fragment = baseStyles.get(family);
      fragment.applyTo(baseStyle);
    }

    Set<StyleKey> inheritedStyleKey = Sets.newLinkedHashSet();
    for (Class<? extends UIWidget> widget : baseFamily.getWidgets()) {
      inheritedStyleKey.add(new StyleKey(widget, "", ""));
      for (String part : baseFamily.getPartsFor(widget)) {
        inheritedStyleKey.add(new StyleKey(widget, part, ""));
        for (String mode : baseFamily.getModesFor(widget, part)) {
          inheritedStyleKey.add(new StyleKey(widget, part, mode));
        }
      }
    }

    Map<Class<? extends UIWidget>, Table<String, String, UIStyle>> familyStyles = Maps.newHashMap();
    Map<StyleKey, UIStyleFragment> styleLookup = elementStyles.row(family);
    Map<StyleKey, UIStyleFragment> baseStyleLookup =
        (family.isEmpty()) ? Maps.<StyleKey, UIStyleFragment>newHashMap() : elementStyles.row("");
    for (StyleKey styleKey :
        Sets.union(Sets.union(styleLookup.keySet(), baseStyleKeys), inheritedStyleKey)) {
      UIStyle elementStyle =
          new UIStyle(baseSkin.getStyleFor(family, styleKey.element, styleKey.part, styleKey.mode));
      baseStyles.get("").applyTo(elementStyle);
      baseStyles.get(family).applyTo(elementStyle);
      List<Class<? extends UIWidget>> inheritanceTree =
          ReflectionUtil.getInheritanceTree(styleKey.element, UIWidget.class);
      applyStylesForInheritanceTree(
          inheritanceTree, "", "", elementStyle, styleLookup, baseStyleLookup);

      if (!styleKey.part.isEmpty()) {
        applyStylesForInheritanceTree(
            inheritanceTree, styleKey.part, "", elementStyle, styleLookup, baseStyleLookup);
      }

      if (!styleKey.mode.isEmpty()) {
        applyStylesForInheritanceTree(
            inheritanceTree,
            styleKey.part,
            styleKey.mode,
            elementStyle,
            styleLookup,
            baseStyleLookup);
      }

      Table<String, String, UIStyle> elementTable = familyStyles.get(styleKey.element);
      if (elementTable == null) {
        elementTable = HashBasedTable.create();
        familyStyles.put(styleKey.element, elementTable);
      }
      elementTable.put(styleKey.part, styleKey.mode, elementStyle);
    }
    return new UIStyleFamily(baseStyle, familyStyles);
  }
コード例 #8
0
ファイル: SparseMatrix.java プロジェクト: edcmartin/librec
  /**
   * Construct a sparse matrix
   *
   * @param dataTable data table
   * @param columnStructure column structure
   */
  private void construct(
      Table<Integer, Integer, Double> dataTable, Multimap<Integer, Integer> columnStructure) {
    int nnz = dataTable.size();

    // CRS
    rowPtr = new int[numRows + 1];
    colInd = new int[nnz];
    rowData = new double[nnz];

    int j = 0;
    for (int i = 1; i <= numRows; ++i) {
      Set<Integer> cols = dataTable.row(i - 1).keySet();
      rowPtr[i] = rowPtr[i - 1] + cols.size();

      for (int col : cols) {
        colInd[j++] = col;
        if (col < 0 || col >= numColumns)
          throw new IllegalArgumentException(
              "colInd[" + j + "]=" + col + ", which is not a valid column index");
      }

      Arrays.sort(colInd, rowPtr[i - 1], rowPtr[i]);
    }

    // CCS
    if (columnStructure != null) {
      colPtr = new int[numColumns + 1];
      rowInd = new int[nnz];
      colData = new double[nnz];
      isCCSUsed = true;

      j = 0;
      for (int i = 1; i <= numColumns; ++i) {
        // dataTable.col(i-1) is very time-consuming
        Collection<Integer> rows = columnStructure.get(i - 1);
        colPtr[i] = colPtr[i - 1] + rows.size();

        for (int row : rows) {
          rowInd[j++] = row;
          if (row < 0 || row >= numRows)
            throw new IllegalArgumentException(
                "rowInd[" + j + "]=" + row + ", which is not a valid row index");
        }

        Arrays.sort(rowInd, colPtr[i - 1], colPtr[i]);
      }
    }

    // set data
    for (Cell<Integer, Integer, Double> en : dataTable.cellSet()) {
      int row = en.getRowKey();
      int col = en.getColumnKey();
      double val = en.getValue();

      set(row, col, val);
    }
  }
コード例 #9
0
ファイル: SparseMatrix.java プロジェクト: edcmartin/librec
  /** @return the data table of this matrix as (row, column, value) cells */
  public Table<Integer, Integer, Double> getDataTable() {
    Table<Integer, Integer, Double> res = HashBasedTable.create();

    for (MatrixEntry me : this) {
      if (me.get() != 0) res.put(me.row(), me.column(), me.get());
    }

    return res;
  }
コード例 #10
0
 @Override
 public void store(Measure measure) {
   // Emulate duplicate measure check
   String componentKey = measure.inputComponent().key();
   String metricKey = measure.metric().key();
   if (measuresByComponentAndMetric.contains(componentKey, metricKey)) {
     throw new SonarException("Can not add the same measure twice");
   }
   measuresByComponentAndMetric.row(componentKey).put(metricKey, measure);
 }
コード例 #11
0
    public List<Vertex> getProductAssociations(Vertex v) {
      Map<Vertex, Edge> adjacent = Maps.newHashMap(graph.row(v));
      adjacent.putAll(graph.column(v));

      return adjacent
          .entrySet()
          .stream()
          .sorted((e1, e2) -> e2.getValue().weight - e1.getValue().weight)
          .map(Map.Entry::getKey)
          .collect(Collectors.toList());
    }
コード例 #12
0
 @Override
 public void store(DefaultCoverage defaultCoverage) {
   String fileKey = defaultCoverage.inputFile().key();
   // Emulate duplicate storage check
   if (coverageByComponentAndType.contains(fileKey, defaultCoverage.type())) {
     throw new UnsupportedOperationException(
         "Trying to save coverage twice for the same file is not supported: "
             + defaultCoverage.inputFile().relativePath());
   }
   coverageByComponentAndType.row(fileKey).put(defaultCoverage.type(), defaultCoverage);
 }
コード例 #13
0
ファイル: SparseMatrix.java プロジェクト: edcmartin/librec
  /** @return the transpose of current matrix */
  public SparseMatrix transpose() {
    if (isCCSUsed) {
      SparseMatrix tr = new SparseMatrix(numColumns, numRows);

      tr.copyCRS(this.rowData, this.rowPtr, this.colInd);
      tr.copyCCS(this.colData, this.colPtr, this.rowInd);

      return tr;
    } else {
      Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
      for (MatrixEntry me : this) dataTable.put(me.column(), me.row(), me.get());
      return new SparseMatrix(numColumns, numRows, dataTable);
    }
  }
コード例 #14
0
 public void addAssociation(Vertex v1, Vertex v2, int edgeWeight) {
   if (containsAssociation(v1, v2)) {
     Edge edge = getAssociationWeight(v1, v2);
     edge.addWeight(edgeWeight);
   } else {
     graph.put(v1, v2, new Edge(edgeWeight));
   }
 }
コード例 #15
0
ファイル: MsgModule.java プロジェクト: Di3mex/ExtraHardMode
  private void send(Player player, MessageNode node, String message) {
    switch (messages.getCat(node)) {
      case NOTIFICATION:
        if (player == null) {
          plugin.getLogger().warning("Could not send the following message: " + message);
        } else {
          // FEATURE: don't spam messages
          PlayerData playerData =
              plugin.getModuleForClass(DataStoreModule.class).getPlayerData(player.getName());
          long now = Calendar.getInstance().getTimeInMillis();

          if (!node.equals(playerData.lastMessageSent)
              || now - playerData.lastMessageTimestamp > 30000) {
            if (popupsAreEnabled(MsgCategory.NOTIFICATION))
              sendPopup(player, MsgCategory.NOTIFICATION, message);
            else player.sendMessage(message);
            playerData.lastMessageSent = node;
            playerData.lastMessageTimestamp = now;
          }
        }
        break;
      case TUTORIAL:
        Validate.notNull(player);
        if (persistModule.getCountFor(node, player.getName()) < messages.getMsgCount(node)) {
          long now = Calendar.getInstance().getTimeInMillis();

          if (!timeouts.contains(player.getName(), node)
              || now - timeouts.get(player.getName(), node) > 120000) // only if contains
          {
            timeouts.put(player.getName(), node, now);
            String msgText = messages.getString(node);
            if (manager != null) sendPopup(player, MsgCategory.TUTORIAL, msgText);
            else
              player.sendMessage(
                  ChatColor.DARK_RED + plugin.getTag() + ChatColor.WHITE + " " + msgText);
            persistModule.increment(node, player.getName());
          }
        } else timeouts.remove(player, message);
        break;
      case BROADCAST:
        plugin.getServer().broadcastMessage(message);
        break;
      default:
        throw new UnsupportedOperationException(messages.getCat(node) + " not implemented");
    }
  }
コード例 #16
0
 @Override
 public void handle(AggregationTimeout timeout) {
   LOG.trace("{}received:{}", logPrefix, timeout);
   SystemWindow systemWindowEvent = new SystemWindow(currentWindow);
   LOG.trace("{}sending:{}", logPrefix, systemWindowEvent);
   trigger(systemWindowEvent, aggregatorPort);
   currentWindow.clear();
 }
コード例 #17
0
ファイル: GameData.java プロジェクト: Kobata/FML
  static UniqueIdentifier getUniqueName(Item item) {
    if (item == null) return null;
    String name = getMain().iItemRegistry.getNameForObject(item);
    UniqueIdentifier ui = new UniqueIdentifier(name);
    if (customItemStacks.contains(ui.modId, ui.name)) {
      return null;
    }

    return ui;
  }
コード例 #18
0
 @Override
 public void handle(
     NodeWindow content,
     BasicContentMsg<KAddress, BasicHeader<KAddress>, NodeWindow> container) {
   LOG.trace(
       "{}received:{} from:{}", new Object[] {logPrefix, content, container.getSource()});
   for (Map.Entry<Class, AggregatorPacket> packet : content.window.entrySet()) {
     currentWindow.put(container.getSource().getId(), packet.getKey(), packet.getValue());
   }
 }
コード例 #19
0
ファイル: UISkinBuilder.java プロジェクト: DVisman/Terasology
  private UIStyleFamily buildFamily(String family, UIStyle defaultStyle) {
    UIStyle baseStyle = new UIStyle(defaultStyle);
    if (!family.isEmpty()) {
      UIStyleFragment fragment = baseStyles.get(family);
      fragment.applyTo(baseStyle);
    }

    Map<Class<? extends UIWidget>, Table<String, String, UIStyle>> familyStyles = Maps.newHashMap();
    Map<StyleKey, UIStyleFragment> styleLookup = elementStyles.row(family);
    Map<StyleKey, UIStyleFragment> baseStyleLookup =
        (family.isEmpty()) ? Maps.<StyleKey, UIStyleFragment>newHashMap() : elementStyles.row("");
    for (StyleKey styleKey : Sets.union(styleLookup.keySet(), baseStyleKeys)) {
      UIStyle elementStyle = new UIStyle(baseStyle);
      List<Class<? extends UIWidget>> inheritanceTree =
          ReflectionUtil.getInheritanceTree(styleKey.element, UIWidget.class);
      applyStylesForInheritanceTree(
          inheritanceTree, "", "", elementStyle, styleLookup, baseStyleLookup);

      if (!styleKey.part.isEmpty()) {
        applyStylesForInheritanceTree(
            inheritanceTree, styleKey.part, "", elementStyle, styleLookup, baseStyleLookup);
      }

      if (!styleKey.mode.isEmpty()) {
        applyStylesForInheritanceTree(
            inheritanceTree,
            styleKey.part,
            styleKey.mode,
            elementStyle,
            styleLookup,
            baseStyleLookup);
      }

      Table<String, String, UIStyle> elementTable = familyStyles.get(styleKey.element);
      if (elementTable == null) {
        elementTable = HashBasedTable.create();
        familyStyles.put(styleKey.element, elementTable);
      }
      elementTable.put(styleKey.part, styleKey.mode, elementStyle);
    }
    return new UIStyleFamily(baseStyle, familyStyles);
  }
コード例 #20
0
ファイル: GameData.java プロジェクト: Kobata/FML
  public static void dumpRegistry(File minecraftDir) {
    if (customItemStacks == null) {
      return;
    }
    if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue()) {
      ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
      for (String modId : customItemStacks.rowKeySet()) {
        builder.putAll(modId, customItemStacks.row(modId).keySet());
      }

      File f = new File(minecraftDir, "itemStackRegistry.csv");
      MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(",");
      try {
        Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8);
        FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath());
      } catch (IOException e) {
        FMLLog.log(Level.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath());
      }
    }
  }
コード例 #21
0
    @Override
    public Module getLatestModuleVersion(String id) {
      Module latest = null;
      for (Module module : modules.row(id).values()) {
        if (latest == null || latest.getVersion().compareTo(module.getVersion()) < 0) {
          latest = module;
        }
      }

      return latest;
    }
コード例 #22
0
ファイル: UISkinBuilder.java プロジェクト: DVisman/Terasology
 private void saveStyle() {
   if (currentFamily.isEmpty() && currentElement != null) {
     baseStyleKeys.add(new StyleKey(currentElement, currentPart, currentMode));
   }
   if (currentElement != null) {
     elementStyles.put(
         currentFamily, new StyleKey(currentElement, currentPart, currentMode), currentStyle);
   } else {
     baseStyles.put(currentFamily, currentStyle);
   }
   currentStyle = new UIStyleFragment();
 }
コード例 #23
0
  @Test
  public void whenTransposeTable_thenCorrect() {
    final Table<String, String, Integer> distance = HashBasedTable.create();
    distance.put("London", "Paris", 340);
    distance.put("New York", "Los Angeles", 3940);
    distance.put("London", "New York", 5576);

    final Table<String, String, Integer> transposed = Tables.transpose(distance);
    assertThat(transposed.rowKeySet(), containsInAnyOrder("Paris", "New York", "Los Angeles"));
    assertThat(transposed.columnKeySet(), containsInAnyOrder("London", "New York"));
  }
コード例 #24
0
  @Test
  public void whenCreateTable_thenCreated() {
    final Table<String, String, Integer> distance = HashBasedTable.create();
    distance.put("London", "Paris", 340);
    distance.put("New York", "Los Angeles", 3940);
    distance.put("London", "New York", 5576);

    assertEquals(3940, distance.get("New York", "Los Angeles").intValue());
    assertThat(distance.columnKeySet(), containsInAnyOrder("Paris", "New York", "Los Angeles"));
    assertThat(distance.rowKeySet(), containsInAnyOrder("London", "New York"));
  }
コード例 #25
0
ファイル: AsuBasePolicySet.java プロジェクト: montge/eHMP
  public AsuBasePolicySet() {
    super(Targets.anyTarget(), PolicyCombiningAlgorithms.onlyOneApplicable());

    for (DocumentAction action : DocumentAction.values()) {
      for (DocumentStatus status : DocumentStatus.values()) {
        policySetsByActionAndStatus.put(
            action,
            status,
            new PolicySet(
                targetForActionAndStatus(action, status), AsuPolicyCombiningAlgorithm.instance()));
      }
    }
  }
コード例 #26
0
 @Override
 public Module getLatestModuleVersion(String id, Version minVersion, Version maxVersion) {
   Module latestInBounds = null;
   for (Module module : modules.row(id).values()) {
     if (module.getVersion().compareTo(minVersion) >= 0
         && module.getVersion().compareTo(maxVersion) < 0
         && (latestInBounds == null
             || latestInBounds.getVersion().compareTo(module.getVersion()) > 0)) {
       latestInBounds = module;
     }
   }
   return latestInBounds;
 }
コード例 #27
0
  /**
   * Builds a pretty print from the statistics gathered.
   *
   * @return
   */
  private String getStatString() {
    StringBuilder builder = new StringBuilder();

    builder.append(
        String.format(
            "Served %d addresses and %d resources\n",
            statsTable.rowKeySet().size(), statsTable.cellSet().size()));
    builder.append("_\n");
    // iterate over every row (addresses)
    for (String address : statsTable.rowKeySet()) {
      builder.append(String.format("|- %s\n", address));
      builder.append("|\t _\n");
      // iterate over every column for a specific address
      for (String resource : statsTable.row(address).keySet()) {
        builder.append(String.format("|\t |- %s: \n", resource));

        // get the statistics
        StatHelper statHelper = statsTable.get(address, resource);
        builder.append(
            String.format("|\t |------ total requests: %d\n", statHelper.getTotalCount()));
        builder.append(
            String.format("|\t |------ total cached replies: %d\n", statHelper.getCachedCount()));
        // builder.append(String.format("|\t |------ last period (%d sec) requests: %d\n",
        // PERIOD_SECONDS, statHelper.getLastPeriodCount()));
        // builder.append(String.format("|\t |------ last period (%d sec) avg delay (nanosec):
        // %d\n",
        // PERIOD_SECONDS, statHelper.getLastPeriodAvgDelay()));
        builder.append("|\t |\n");
      }
      builder.append("|\t  ̄\n");
      builder.append("|\n");
    }
    builder.append(" ̄\n");

    return builder.length() == 0
        ? "The proxy has not received any request, yet."
        : builder.toString();
  }
コード例 #28
0
  public static Table<Integer, String, String> parse(InlineTable inlineTable) {
    Table<Integer, String, String> result = HashBasedTable.create();

    Integer rowKey = 1;

    List<Row> rows = inlineTable.getRows();
    for (Row row : rows) {
      List<Object> cells = row.getContent();

      for (Object cell : cells) {

        if (cell instanceof Element) {
          Element element = (Element) cell;

          result.put(rowKey, element.getTagName(), element.getTextContent());
        }
      }

      rowKey += 1;
    }

    return result;
  }
コード例 #29
0
ファイル: SplitDocument.java プロジェクト: yumok/torodb
    public Builder add(SubDocument subDocument) {
      Preconditions.checkState(!build, "This builder has already been used");
      SubDocType type = subDocument.getType();

      Integer index = indexBySubDoc.get(type);
      if (index == null) {
        index = 0;
      } else {
        index++;
      }
      indexBySubDoc.put(type, index);

      subDocuments.put(type, index, subDocument);
      return this;
    }
コード例 #30
0
ファイル: SparseMatrix.java プロジェクト: edcmartin/librec
  /**
   * Construct a sparse matrix with CRS structures (CCS structure optional).
   *
   * @deprecated I don't recommend to use this method as it (takes time and) is better to constructe
   *     the column structure at the time when you construct the row structure (of data table). This
   *     method is put here (as an example) to show how to construct column structure according to
   *     the data table.
   */
  public SparseMatrix(
      int rows, int cols, Table<Integer, Integer, Double> dataTable, boolean isCCSUsed) {
    numRows = rows;
    numColumns = cols;

    Multimap<Integer, Integer> colMap = null;

    if (isCCSUsed) {
      colMap = HashMultimap.create();
      for (Cell<Integer, Integer, Double> cell : dataTable.cellSet())
        colMap.put(cell.getColumnKey(), cell.getRowKey());
    }

    construct(dataTable, colMap);
  }