stevendesu / jsindex

1 stars 0 forks source link

Cannot merge on un-indexed columns #4

Closed stevendesu closed 5 years ago

stevendesu commented 5 years ago

I utilize the index when merging. This is great because it reduces the O(n^2) merge operation to O(n), however we can't guarantee the column we wish to merge on is always indexed. Consider the following:

const students = Array.load(...).index("language");
const teachers = Array.load(...).index("age");

students.merge(teachers, "language");

The students collection is indexed on the language field, but the teachers collection is not. Therefore this will fail to find matching teachers for each student.

Instead of this, we should:

  1. Fall back to the O(n^2) solution
  2. Throw a warning that the column is not indexed and therefore the operation was much slower than it could be