it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap Java Examples

The following examples show how to use it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ORDERLhsRhs.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private void buildPrefixBlocks() {
  this.prefixBlocks = new Object2ObjectOpenCustomHashMap<>(ByteArrays.HASH_STRATEGY);

  for (final byte[] permutation : this.previousLevelCandidates) {
    // prefix is the emtpy array for permutations of size 1 (level 1)
    final byte[] prefix = ByteArrayPermutations.prefix(permutation);

    if (this.prefixBlocks.get(prefix) == null) {
      this.prefixBlocks.put(prefix, new ArrayList<byte[]>());
    }
    this.prefixBlocks.get(prefix).add(permutation);
  }
}
 
Example #2
Source File: ORDER.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected void initializePartitions() throws AlgorithmExecutionException {
  this.permutationToPartition = new Object2ObjectOpenCustomHashMap<>(ByteArrays.HASH_STRATEGY);

  // create partitions for level 1
  for (final int columnIndex : this.columnIndices) {
    final byte[] singleColumnPermutation = {(byte) columnIndex};

    final SortedPartition partition =
        SortedPartitionCreator.createPartition(this.dataByColumns.get(columnIndex),
            this.types.get(columnIndex));

    this.permutationToPartition.put(singleColumnPermutation, partition);
  }

}
 
Example #3
Source File: Session.java    From parity with Apache License 2.0 5 votes vote down vote up
Session(SocketChannel channel, OrderBooks books) {
    this.transport = new SoupBinTCPServer(channel, POE.MAX_INBOUND_MESSAGE_LENGTH,
            new POEServerParser(this), this);

    this.orders   = new Object2ObjectOpenCustomHashMap<>(HASH_STRATEGY);
    this.orderIds = new ObjectOpenCustomHashSet<>(HASH_STRATEGY);

    this.books = books;

    this.terminated = false;
}
 
Example #4
Source File: ORDERLhsRhs.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
@Override
public void execute() throws AlgorithmExecutionException {
  super.execute();

  this.partitionsCache =
      CacheBuilder.newBuilder().maximumSize(this.partitionCacheSize)
          .build(new CacheLoader<ByteArray, SortedPartition>() {
            @Override
            public SortedPartition load(final ByteArray key) throws Exception {
              return ORDERLhsRhs.this.createPartitionFromSingletons(key.data);
            }
          });

  this.logger.info("Running order dependency detection algorithm (lhs and rhs) on table: "
      + this.tableName + " (" + this.numRows + " rows, " + this.columnIndices.length
      + " columns)");

  if (this.columnNames.size() > MAX_NUM_COLS) {
    throw new AlgorithmConfigurationException("You provided a table with "
        + this.columnNames.size()
        + " columns. This order dependency detection algorithm supports a maximum of "
        + MAX_NUM_COLS + " columns.");
  }

  this.levelCandidates = new ArrayList<>();
  this.currentRhsCandidateSet = new Object2ObjectOpenCustomHashMap<>(ByteArrays.HASH_STRATEGY);
  this.singleColumnPermutations = new ArrayList<>();
  this.validDependencies = new Object2ObjectOpenCustomHashMap<>(ByteArrays.HASH_STRATEGY);

  // initialize level 1
  for (final int lhsColumnIndex : this.columnIndices) {
    final byte[] singleLhsColumnPermutation = {(byte) lhsColumnIndex};

    // columns with only equal values mean that any OD with that lhs holds (under "<")
    // (but there exists no minimal n-ary OD that has lhs on its lhs or rhs,
    // i.e., they can be removed)
    if (this.permutationToPartition.get(singleLhsColumnPermutation).size() == 1) {
      for (final int rhsColumnIndex : this.columnIndices) {
        final byte[] rhs = new byte[] {(byte) rhsColumnIndex};
        if (Arrays.equals(singleLhsColumnPermutation, rhs)) {
          continue;
        }
        this.statistics.setNumFoundDependencies(this.statistics.getNumFoundDependencies() + 1);
        this.statistics.setNumFoundDependenciesInPreCheck(this.statistics
            .getNumFoundDependenciesInPreCheck() + 1);
        this.signalFoundOrderDependency(singleLhsColumnPermutation, rhs,
            ComparisonOperator.STRICTLY_SMALLER, OrderType.LEXICOGRAPHICAL);
      }

      continue;
    }

    this.singleColumnPermutations.add(singleLhsColumnPermutation);

    this.levelCandidates.add(singleLhsColumnPermutation);
    this.currentRhsCandidateSet.put(singleLhsColumnPermutation, new ObjectOpenCustomHashSet<>(
        ByteArrays.HASH_STRATEGY));
  }

  for (final byte[] levelCandidate : this.levelCandidates) {

    for (final byte[] singleColumnRhsCandidate : this.singleColumnPermutations) {
      if (!ByteArrayPermutations.disjoint(levelCandidate, singleColumnRhsCandidate)) {
        continue;
      }
      this.currentRhsCandidateSet.get(levelCandidate).add(singleColumnRhsCandidate);
    }
  }

  this.level = 1;
  while (!this.levelCandidates.isEmpty()) {
    this.computeDependencies();
    this.prune();
    this.logger.debug("Candidate set: {}", this.prettyPrintCurrentRhsCandidates());
    this.generateNextLevel();
    this.logger.info("Statistics after generating level " + (this.level + 1) + " for table #"
        + this.tableName + "#: " + this.statistics.toString());
    this.level++;
  }

  this.logger.info("Statistics (FINAL) for table #" + this.tableName + "#: "
      + this.statistics.toString());

}