@Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { // create a state manager, so we can manage each batch LocalTableState state = new LocalTableState(localTable, mutation); // build the index updates for each group IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }
@Test public void testMutationComparator() throws Exception { IndexUpdateManager manager = new IndexUpdateManager(mockIndexMetaData); Comparator<Mutation> comparator = manager.COMPARATOR; Put p = new Put(row, 10); // lexigraphically earlier should sort earlier Put p1 = new Put(Bytes.toBytes("ro"), 10); assertTrue("lexigraphically later sorting first, should be earlier first.", comparator.compare(p, p1) > 0); p1 = new Put(Bytes.toBytes("row1"), 10); assertTrue("lexigraphically later sorting first, should be earlier first.", comparator.compare(p1, p) > 0); // larger ts sorts before smaller, for the same row p1 = new Put(row, 11); assertTrue("Smaller timestamp sorting first, should be larger first.", comparator.compare(p, p1) > 0); // still true, even for deletes Delete d = new Delete(row, 11); assertTrue("Smaller timestamp sorting first, should be larger first.", comparator.compare(p, d) > 0); // for the same row, t1, the delete should sort earlier d = new Delete(row, 10); assertTrue("Delete doesn't sort before put, for the same row and ts", comparator.compare(p, d) > 0); // but for different rows, we still respect the row sorting. d = new Delete(Bytes.toBytes("row1"), 10); assertTrue("Delete doesn't sort before put, for the same row and ts", comparator.compare(p, d) < 0); }
IndexUpdateManager manager = new IndexUpdateManager(mockIndexMetaData); manager = new IndexUpdateManager(mockIndexMetaData); manager.addIndexUpdate(table, d2); manager.addIndexUpdate(table, p); manager = new IndexUpdateManager(mockIndexMetaData); manager.addIndexUpdate(table, p);
@Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { // create a state manager, so we can manage each batch LocalTableState state = new LocalTableState(localTable, mutation); // build the index updates for each group IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }
@Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { // create a state manager, so we can manage each batch LocalTableState state = new LocalTableState(localTable, mutation); // build the index updates for each group IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }