Пример #1
0
/*
 * Execute a colon-prefixed command.
 * Returns <0 if not a command that should cause
 * more of the file to be printed.
 */
int
colon(char *filename, int cmd, int nlines)
{
	int ch;

	if (cmd == 0)
		ch = readch();
	else
		ch = cmd;
	lastcolon = ch;
	switch (ch) {
	case 'f':
		kill_line();
		if (!no_intty)
			promptlen =
			    printf("\"%s\" line %lld", fnames[fnum],
				(long long)Currline);
		else
			promptlen = printf("[Not a file] line %lld",
			    (long long)Currline);
		fflush(stdout);
		return (-1);
	case 'n':
		if (nlines == 0) {
			if (fnum >= nfiles - 1)
				end_it();
			nlines++;
		}
		putchar('\r');
		erasep(0);
		skipf(nlines);
		return (0);
	case 'p':
		if (no_intty) {
			write(STDERR_FILENO, &bell, 1);
			return (-1);
		}
		putchar('\r');
		erasep(0);
		if (nlines == 0)
			nlines++;
		skipf (-nlines);
		return (0);
	case '!':
		if (do_shell(filename) < 0) {
			kill_line();
			prompt(filename);
		}
		return (-1);
	case 'q':
	case 'Q':
		end_it();
		/*FALLTHROUGH*/
	default:
		write(STDERR_FILENO, &bell, 1);
		return (-1);
	}
}
//---------------------------------------------------------------------------//
// An iterator assigned to the end.
EntityIterator MoabEntityIterator::end() const
{
    MoabEntityIterator end_it( 
	d_entity_range, d_moab_mesh, d_set_indexer, this->b_predicate );
    end_it.d_moab_entity_it = d_entity_range->d_moab_entities.end();
    return end_it;
}
Пример #3
0
TEST(TextTest, Crap) {
  std::string s("\"«»\n");
  std::string::const_iterator it(s.begin());
  std::string::const_iterator end_it(s.end());
  std::string result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(s, result);
}
//---------------------------------------------------------------------------//
// An iterator assigned to the end.
EntityIterator STKMeshEntityIterator::end() const
{
    STKMeshEntityIterator end_it( 
	d_entity_range, d_bulk_data, this->b_predicate );
    end_it.d_stk_entity_it = d_entity_range->d_stk_entities.end();
    return end_it;
}
Пример #5
0
TEST(TextTest, ReallyLongLine) {
  std::string s("[http://code.google.com/p/gdata-python-client gdata-python-client]");
  std::string::const_iterator it(s.begin());
  std::string::const_iterator end_it(s.end());
  std::string result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("[http://code.google.com/p/gdata-python-client "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("gdata-python-client]"), result);
}
Пример #6
0
static int readch(void)
{
	unsigned char c;

	errno = 0;
	if (read(fileno(stderr), &c, 1) <= 0) {
		if (errno != EINTR)
			end_it(0);
		else
			c = otty.c_cc[VKILL];
	}
	return (c);
}
Пример #7
0
  friend std::ostream& operator<<(std::ostream& ostr, const self_t& pc)
  {
    typedef typename self_t::iterator local_it;
    local_it begin_it(pc.begin());
    local_it end_it(pc.end());

    ostr << "list of (cached) primes follows:" << std::endl;
    for (; begin_it != end_it; begin_it++)
      {
	ostr << *begin_it << " ";
      }
    return ostr;
  }
Пример #8
0
TEST(TextTest, Newline) {
  std::string s("line with\nnew line");
  std::string::const_iterator it(s.begin());
  std::string::const_iterator end_it(s.end());
  std::string result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("line "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("with\n"), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("new "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("line"), result);
}
Пример #9
0
  // the real work is here
  //
  bool is_prime(numeric_t n)
  {
    // did we already encounter this?
    if (primes_container.find(n) != primes_container.end())
      {
	return true;  // found it, we're done ...
      } 
    else 
      {
	// check if this is a prime ...
	//
#ifdef FACTOR_EXPERIMENT
	// this implementation is slightly faster with optimisation (-O3)
	//
	iterator end_it(primes_container.end());
	for (iterator it(primes_container.begin()); it != end_it; ++it)
	  {
	    if (!(static_cast<long>(n) % (*it)))
	      {
		// definitly not a prime if it can be devided ...
		return false;
	      }
	  }
	for (long i = *(--primes_container.end()); i < (n/2+1); i++)
	  {
	    if (!(static_cast<long>(n) % static_cast<long>(i)))
	      {
		// definitly not a prime if it can be divided ...
		return false;
	      }
	  }
#else
	// conservative approach, always works
	//
	for (numeric_t i = 2; i < (n/2+1); i++)
	  {
	    if (!( n % i ))
	      {
		// definitly not a prime if it can be divided ...
		return false;
	      }
	  }
#endif

	// could not be divided, so push it to the storage 
	//
	primes_container.insert(n);
      }
    // we got a prime ...
    return true;
  };
Пример #10
0
int
readch(void)
{
	unsigned char ch;
	int r;

	/* We know stderr is hooked up to /dev/tty so this is safe. */
again:
	switch (read(STDERR_FILENO, &ch, 1)) {
	case 1:
		return (ch);
	case -1:
		if (errno != EINTR)
			end_it();

		r = handle_signal();
		if (r == -1)
			goto again;
		return (r);		/* redraw, continue, etc */
	case 0:
		end_it();
	}
}
Пример #11
0
TEST(TextTest, Simple)
{
  std::string s("this is a string");
  std::string::const_iterator it(s.begin());
  std::string::const_iterator end_it(s.end());

  std::string result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("this "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("is "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("a "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("string"), result);
}
Пример #12
0
factorial<PrimeType, ExponentType> 
operator*(const factorial<PrimeType, ExponentType>& a, 
          const factorial<PrimeType, ExponentType>& b)
{
  typedef typename factorial<PrimeType, 
    ExponentType>::const_iterator iterator;

  factorial<PrimeType, ExponentType> n(a);
  iterator end_it(b.prime_factors.end());

  for (iterator it(b.prime_factors.begin()); it != end_it; it++)
    {
      n.prime_factors[it->first] += it->second;
    }
  return n;
}
Пример #13
0
TEST(TextTest, Unicode) {
  std::string s("thís ís à üniÇod€ strîñg");
  std::string::const_iterator it(s.begin());
  std::string::const_iterator end_it(s.end());

  std::string result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("thís "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("ís "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("à "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("üniÇod€ "), result);
  result = nextWordAdvanceWord(&it, end_it);
  EXPECT_EQ(std::string("strîñg"), result);
}
Пример #14
0
  EvalType eval()
  {
    EvalType prod(1);
    iterator end_it(prime_factors.end());

    for (iterator it(prime_factors.begin()); it != end_it; it++)
      {
	if (it->second)
	  {
             if (it->second > 0)
                prod *= gsse::slow_power(it->first, it->second);
             else
                prod /= gsse::slow_power(it->first, -it->second);
	  }
      }
    return prod;
  }
Пример #15
0
std::ostream& 
operator<<(std::ostream& o, const factorial<PrimeType, ExponentType>& f)
{
  typedef typename factorial<PrimeType, ExponentType>::const_iterator 
    iterator;
  iterator end_it(f.prime_factors.end());

  for (iterator it(f.prime_factors.begin());  it != end_it; it++)
    {
      if (it->second)
	{
	  o << it->first << "^" << it->second << " * "; // << std::endl;
	}
    }
  o << 1;
  //o << std::endl << f.lookup;
  return o;
}
Пример #16
0
int
readch(void)
{
	int ch;

	errno = 0;
	/* We know stderr is hooked up to /dev/tty so this is safe. */
again:
	if (read(STDERR_FILENO, &ch, 1) <= 0) {
		if (signo != 0) {
			if ((ch = handle_signal()) == -1)
				goto again;
		} else {
			if (errno != EINTR)
				end_it();
			else
				ch = otty.c_cc[VKILL];
		}
	}
	return (ch);
}
Пример #17
0
/*
 * Search for nth occurrence of regular expression contained in buf in the file
 */
int
search(char *buf, FILE *file, int n)
{
	off_t startline = Ftell(file);
	off_t line1 = startline;
	off_t line2 = startline;
	off_t line3 = startline;
	off_t saveln;
	int lncount, rv;
	char ebuf[BUFSIZ];
	static regex_t reg;
	static int initialized;

	context.line = saveln = Currline;
	context.chrctr = startline;
	lncount = 0;
	if (buf != NULL && *buf != '\0') {
		if ((rv = regcomp(&reg, buf, REG_NOSUB)) != 0) {
			initialized = 0;
			regerror(rv, &reg, ebuf, sizeof(ebuf));
			regfree(&reg);
			error(ebuf);
			return (-1);
		}
		initialized = 1;
	} else if (!initialized) {
		error("No previous regular expression");
		return (-1);
	}
	while (!feof(file)) {
		line3 = line2;
		line2 = line1;
		line1 = Ftell(file);
		rdline(file);
		lncount++;
		if ((rv = regexec(&reg, Line, 0, NULL, 0)) == 0) {
			if (--n == 0) {
				if (lncount > 3 || (lncount > 1 && no_intty)) {
					putchar('\n');
					if (clreol)
						cleareol();
					fputs("...skipping\n", stdout);
				}
				if (!no_intty) {
					Currline -= (lncount >= 3 ? 3 : lncount);
					Fseek(file, line3);
					if (noscroll) {
						if (clreol) {
							home();
							cleareol();
						} else
							doclear();
					}
				} else {
					kill_line();
					if (noscroll) {
					    if (clreol) {
						    home();
						    cleareol();
					    } else
						    doclear();
					}
					fputs(Line, stdout);
					putchar('\n');
				}
				break;
			}
		} else if (rv != REG_NOMATCH) {
			regerror(rv, &reg, ebuf, sizeof(ebuf));
			error(ebuf);
			return (-1);
		}
	}
	if (feof(file)) {
		if (!no_intty) {
			Currline = saveln;
			Fseek(file, startline);
		} else {
			fputs("\nPattern not found\n", stdout);
			end_it();
		}
		error("Pattern not found");
		return (-1);
	}
	return (0);
}
	//TODO: Test-Me!!
	private: void do_update_service()
	{
		DCS_DEBUG_TRACE_L(3, "(" << this << ") BEGIN Do-Update-Service (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX

		// Check if there is at least one busy server.
		if (num_busy_ > 0)
		{
			typedef typename server_container::const_iterator iterator;

			real_type new_share(this->share());
			real_type new_multiplier(this->capacity_multiplier());

			// Check if we really need to update currently running customers
			if (::dcs::math::float_traits<real_type>::approximately_equal(old_share_, new_share)
				&& ::dcs::math::float_traits<real_type>::approximately_equal(old_multiplier_, new_multiplier))
			{
				// Share is not changed -> avoid to update customers and reschedule their end-of-service events

				DCS_DEBUG_TRACE_L(3, "(" << this << ") Share/Multiplier not changed: " << old_share_ << " vs. " << new_share << " / " << old_multiplier_ << " vs. " << new_multiplier);

				return;
			}

			real_type cur_time(this->node().network().engine().simulated_time());
			iterator end_it(servers_.end());
			for (iterator it = servers_.begin(); it != end_it; ++it)
			{
				uint_type sid(it->first);
				customer_pointer ptr_customer(it->second);

				// paranoid-check: null
				DCS_DEBUG_ASSERT( ptr_customer );

				DCS_DEBUG_TRACE_L(3, "(" << this << ") Running Customer ID: " << ptr_customer->id());

				runtime_info_type& rt_info(this->info(ptr_customer));

				// paranoid-check: paranoid check
				DCS_DEBUG_ASSERT( rt_info.server_id() == sid );

				DCS_DEBUG_TRACE_L(3, "Updating Customer: " << rt_info.get_customer() << " - Service demand: " << rt_info.service_demand() << " - Multiplier: " << this->capacity_multiplier() << " - old share: " << rt_info.share() << " - old runtime: " << rt_info.runtime() << " - old completed work: " << rt_info.completed_work() << " - old residual-work: " << rt_info.residual_work() << " (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX

				// Increment the accumulated work done by this customer to date...
				rt_info.accumulate_work(cur_time);
				// ... Update the capacity multiplier,...
				rt_info.capacity_multiplier(new_multiplier);
				// ... Update the share,...
				rt_info.share(new_share);
				// ... Compute the new residual work
				real_type new_residual_time(rt_info.residual_work()/new_multiplier);
				// ... And reschedule the end-of-service
				this->node().reschedule_service(*ptr_customer, new_residual_time);

				DCS_DEBUG_TRACE_L(3, "Updated Customer: " << rt_info.get_customer() << " - Service demand: " << rt_info.service_demand() << " - Multiplier: " << this->capacity_multiplier() << " - new share: " << rt_info.share() << " - new runtime: " << rt_info.runtime() << " - new completed work: " << rt_info.completed_work() << " - new residual-work: " << rt_info.residual_work() << " (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX
			}

			old_share_ = new_share;
			old_multiplier_ = new_multiplier;
		}

		DCS_DEBUG_TRACE_L(3, "(" << this << ") END Do-Update-Service (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX
	}
Пример #19
0
int
handle_signal(void)
{
	int sig, ch = -1;

	for (sig = 0; sig < _NSIG; sig++) {
		if (signo[sig] == 0)
			continue;
		signo[sig] = 0;

		switch (sig) {
		case SIGQUIT:
			if (!inwait) {
				putchar('\n');
				if (startup)
					Pause++;
			} else if (!dum_opt && notell) {
				write(STDERR_FILENO, QUIT_IT,
				    sizeof(QUIT_IT) - 1);
				promptlen += sizeof(QUIT_IT) - 1;
				notell = 0;
			}
			break;
		case SIGTSTP:
		case SIGTTIN:
		case SIGTTOU:
			/* XXX - should use saved values instead of SIG_DFL */
			sa.sa_handler = SIG_DFL;
			sa.sa_flags = SA_RESTART;
			(void)sigaction(SIGTSTP, &sa, NULL);
			(void)sigaction(SIGTTIN, &sa, NULL);
			(void)sigaction(SIGTTOU, &sa, NULL);
			reset_tty();
			kill(getpid(), sig);

			sa.sa_handler = onsignal;
			sa.sa_flags = 0;
			(void)sigaction(SIGTSTP, &sa, NULL);
			(void)sigaction(SIGTTIN, &sa, NULL);
			(void)sigaction(SIGTTOU, &sa, NULL);
			set_tty();
			if (!no_intty)
				ch = '\f';	/* force redraw */
			break;
		case SIGINT:
			end_it();
			break;
		case SIGWINCH: {
			struct winsize win;

			if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != 0)
				break;
			if (win.ws_row != 0) {
				Lpp = win.ws_row;
				nscroll = Lpp/2 - 1;
				if (nscroll <= 0)
					nscroll = 1;
				dlines = Lpp - 1;
			}
			if (win.ws_col != 0)
				Mcol = win.ws_col;
			if (!no_intty)
				ch = '\f';	/* force redraw */
			break;
		} default:
			/* NOTREACHED */
			break;
		}
	}
	return (ch);
}
Пример #20
0
/*
 * Read a command and do it. A command consists of an optional integer
 * argument followed by the command character.  Return the number of lines
 * to display in the next screenful.  If there is nothing more to display
 * in the current file, zero is returned.
 */
int
command(char *filename, FILE *f)
{
	int nlines;
	int retval;
	int ch;
	char colonch;
	int done;
	char comchar, cmdbuf[80];

#define ret(val) retval=val;done++;break

	retval = done = 0;
	if (!errors)
		prompt(filename);
	else
		errors = 0;
	for (;;) {
		nlines = number(&comchar);
		lastp = colonch = 0;
		if (comchar == '.') {	/* Repeat last command */
			lastp++;
			comchar = lastcmd;
			nlines = lastarg;
			if (lastcmd == ':')
				colonch = lastcolon;
		}
		lastcmd = comchar;
		lastarg = nlines;
		if (comchar == otty.c_cc[VERASE]) {
			kill_line();
			prompt(filename);
			continue;
		}
		switch (comchar) {
		case ':':
			retval = colon(filename, colonch, nlines);
			if (retval >= 0)
				done++;
			break;
		case 'b':
		case ctrl('B'):
		    {
			int initline;

			if (no_intty) {
				write(STDERR_FILENO, &bell, 1);
				return (-1);
			}

			if (nlines == 0)
				nlines++;

			putchar('\r');
			erasep(0);
			putchar('\n');
			if (clreol)
				cleareol();
			printf("...back %d page", nlines);
			if (nlines > 1)
				fputs("s\n", stdout);
			else
				putchar('\n');

			if (clreol)
				cleareol();
			putchar('\n');

			initline = Currline - (off_t)dlines * (nlines + 1);
			if (!noscroll)
				--initline;
			if (initline < 0)
				initline = 0;
			Fseek(f, (off_t)0);
			Currline = 0; /* skiplns() will make Currline correct */
			skiplns(initline, f);
			ret(dlines);
		    }
		case ' ':
		case 'z':
			if (nlines == 0)
				nlines = dlines;
			else if (comchar == 'z')
				dlines = nlines;
			ret(nlines);
		case 'd':
		case ctrl('D'):
			if (nlines != 0)
				nscroll = nlines;
			ret(nscroll);
		case 'q':
		case 'Q':
			end_it();
		case 's':
		case 'f':
			if (nlines == 0)
				nlines++;
			if (comchar == 'f')
				nlines *= dlines;
			putchar('\r');
			erasep(0);
			putchar('\n');
			if (clreol)
				cleareol();
			printf("...skipping %d line", nlines);
			if (nlines > 1)
				fputs("s\n", stdout);
			else
				putchar('\n');

			if (clreol)
				cleareol();
			putchar('\n');

			while (nlines > 0) {
				while ((ch = Getc(f)) != '\n') {
					if (ch == EOF) {
						retval = 0;
						done++;
						goto endsw;
					}
				}
				Currline++;
				nlines--;
			}
			ret(dlines);
		case '\n':
			if (nlines != 0)
				dlines = nlines;
			else
				nlines = 1;
			ret(nlines);
		case '\f':
			if (!no_intty) {
				doclear();
				Fseek(f, screen_start.chrctr);
				Currline = screen_start.line;
				ret(dlines);
			} else {
				write(STDERR_FILENO, &bell, 1);
				break;
			}
		case '\'':
			if (!no_intty) {
				kill_line();
				fputs("\n***Back***\n\n", stdout);
				Fseek(f, context.chrctr);
				Currline = context.line;
				ret(dlines);
			} else {
				write(STDERR_FILENO, &bell, 1);
				break;
			}
		case '=':
			kill_line();
			promptlen = printf("%lld", (long long)Currline);
			fflush(stdout);
			break;
		case 'n':
			lastp++;
		case '/':
			if (nlines == 0)
				nlines++;
			kill_line();
			putchar('/');
			promptlen = 1;
			fflush(stdout);
			if (lastp) {
				/* Use previous r.e. */
				write(STDERR_FILENO, "\r", 1);
				if (search(NULL, f, nlines) < 0)
					break;
			} else {
				if (ttyin(cmdbuf, sizeof(cmdbuf) - 2, '/') < 0) {
					kill_line();
					prompt(filename);
					continue;
				}
				write(STDERR_FILENO, "\r", 1);
				if (search(cmdbuf, f, nlines) < 0)
					break;
			}
			ret(dlines-1);
		case '?':
		case 'h':
			if (noscroll)
				doclear();
			fputs(more_help, stdout);
			prompt(filename);
			break;
		default:
			if (dum_opt) {
				kill_line();
				if (Senter && Sexit) {
					tputs(Senter, 1, putch);
					fputs(DUM_ERROR, stdout);
					promptlen = sizeof(DUM_ERROR) - 1 +
					    (2 * soglitch);
					tputs(Sexit, 1, putch);
				} else {
					fputs(DUM_ERROR, stdout);
					promptlen = sizeof(DUM_ERROR) - 1;
				}
				fflush(stdout);
			} else
				write(STDERR_FILENO, &bell, 1);
			break;
		}
		if (done)
			break;
	}
	putchar('\r');
endsw:
	inwait = 0;
	notell++;
	return (retval);
}
TupleIdSequence* SortColumnPredicateEvaluator::EvaluatePredicateForUncompressedSortColumn(
    const Predicate &predicate,
    const CatalogRelation &relation,
    const attribute_id sort_attribute_id,
    void *sort_attribute_stripe,
    const tuple_id num_tuples) {
  // Determine if the predicate is a comparison of the sort column with a literal.
  if (predicate.isAttributeLiteralComparisonPredicate()) {
    const ComparisonPredicate &comparison_predicate = static_cast<const ComparisonPredicate&>(predicate);

    const CatalogAttribute *comparison_attribute = NULL;
    bool left_literal = false;
    if (comparison_predicate.getLeftOperand().hasStaticValue()) {
      DEBUG_ASSERT(comparison_predicate.getRightOperand().getDataSource() == Scalar::kAttribute);
      comparison_attribute
          = &(static_cast<const ScalarAttribute&>(comparison_predicate.getRightOperand()).getAttribute());
      left_literal = true;
    } else {
      DEBUG_ASSERT(comparison_predicate.getLeftOperand().getDataSource() == Scalar::kAttribute);
      comparison_attribute
          = &(static_cast<const ScalarAttribute&>(comparison_predicate.getLeftOperand()).getAttribute());
      left_literal = false;
    }

    DEBUG_ASSERT(comparison_attribute->getParent().getID() == relation.getID());
    if (comparison_attribute->getID() == sort_attribute_id) {
      const LiteralTypeInstance* comparison_literal;
      if (left_literal) {
        comparison_literal = &(comparison_predicate.getLeftOperand().getStaticValue());
      } else {
        comparison_literal = &(comparison_predicate.getRightOperand().getStaticValue());
      }

      // NOTE(chasseur): A standards-compliant implementation of lower_bound
      // always compares the iterator on the left with the literal on the right,
      // while upper_bound compares the literal on the left with the iterator
      // on the right. These will work even if comparison_attribute and
      // comparison_literal are different types.
      const Comparison &less_comparison = Comparison::GetComparison(Comparison::kLess);
      ScopedPtr<UncheckedComparator> fast_comparator_lower(
          less_comparison.makeUncheckedComparatorForTypes(comparison_attribute->getType(),
                                                          comparison_literal->getType()));
      STLUncheckedComparatorWrapper comp_lower(*fast_comparator_lower);
      ScopedPtr<UncheckedComparator> fast_comparator_upper(
          less_comparison.makeUncheckedComparatorForTypes(comparison_literal->getType(),
                                                          comparison_attribute->getType()));
      STLUncheckedComparatorWrapper comp_upper(*fast_comparator_upper);

      // Find the bounds on the range of matching tuples.
      tuple_id min_match = 0;
      tuple_id max_match_bound = num_tuples;
      ColumnStripeIterator begin_it(sort_attribute_stripe,
                                    relation.getAttributeById(sort_attribute_id).getType().maximumByteLength(),
                                    0);
      ColumnStripeIterator end_it(sort_attribute_stripe,
                                  relation.getAttributeById(sort_attribute_id).getType().maximumByteLength(),
                                  num_tuples);

      switch (comparison_predicate.getComparison().getComparisonID()) {
        case Comparison::kEqual:
        // Note: There is a special branch below for kNotEqual which takes the
        // complement of the matched range.
        case Comparison::kNotEqual:
          min_match = lower_bound(begin_it,
                                  end_it,
                                  comparison_literal->getDataPtr(),
                                  comp_lower).getTuplePosition();
          max_match_bound = upper_bound(begin_it,
                                        end_it,
                                        comparison_literal->getDataPtr(),
                                        comp_upper).getTuplePosition();
          break;
        case Comparison::kLess:
          if (left_literal) {
            min_match = upper_bound(begin_it,
                                    end_it,
                                    comparison_literal->getDataPtr(),
                                    comp_upper).getTuplePosition();
          } else {
            max_match_bound = lower_bound(begin_it,
                                          end_it,
                                          comparison_literal->getDataPtr(),
                                          comp_lower).getTuplePosition();
          }
          break;
        case Comparison::kLessOrEqual:
          if (left_literal) {
            min_match = lower_bound(begin_it,
                                    end_it,
                                    comparison_literal->getDataPtr(),
                                    comp_lower).getTuplePosition();
          } else {
            max_match_bound = upper_bound(begin_it,
                                          end_it,
                                          comparison_literal->getDataPtr(),
                                          comp_upper).getTuplePosition();
          }
          break;
        case Comparison::kGreater:
          if (left_literal) {
            max_match_bound = lower_bound(begin_it,
                                          end_it,
                                          comparison_literal->getDataPtr(),
                                          comp_lower).getTuplePosition();
          } else {
            min_match = upper_bound(begin_it,
                                    end_it,
                                    comparison_literal->getDataPtr(),
                                    comp_upper).getTuplePosition();
          }
          break;
        case Comparison::kGreaterOrEqual:
          if (left_literal) {
            max_match_bound = upper_bound(begin_it,
                                          end_it,
                                          comparison_literal->getDataPtr(),
                                          comp_upper).getTuplePosition();
          } else {
            min_match = lower_bound(begin_it,
                                    end_it,
                                    comparison_literal->getDataPtr(),
                                    comp_lower).getTuplePosition();
          }
          break;
        default:
          FATAL_ERROR("Unknown Comparison in SortColumnPredicateEvaluator::"
                      "EvaluatePredicateForUncompressedSortColumn()");
      }

      // Create and return the sequence of matches.
      TupleIdSequence *matches = new TupleIdSequence();
      if (comparison_predicate.getComparison().getComparisonID() == Comparison::kNotEqual) {
        // Special case: return all tuples NOT in the range for kEqual.
        for (tuple_id tid = 0; tid < min_match; ++tid) {
          matches->append(tid);
        }
        for (tuple_id tid = max_match_bound; tid < num_tuples; ++tid) {
          matches->append(tid);
        }
      } else {
        for (tuple_id tid = min_match; tid < max_match_bound; ++tid) {
          matches->append(tid);
        }
      }

      return matches;
    } else {
      return NULL;
    }
  } else {
    // Can not evaluate a non-comparison predicate, so pass through.
    return NULL;
  }
}