@Test public void testReplaceRow() throws IOException { RAMDirectory directory = new RAMDirectory(); DirectoryReader reader = getIndexReader(directory); IndexWriter writer = new IndexWriter(directory, _conf.clone()); assertEquals(0, reader.numDocs()); Row row = genRow(); _action.replaceRow(row); _action.performMutate(getSearcher(reader, directory), writer); reader = commitAndReopen(reader, writer); assertEquals(1, reader.numDocs()); Row row2 = new Row(row); List<Column> cols = new ArrayList<Column>(); cols.add(new Column("n", "v")); row2.addToRecords(new Record("1", "fam", cols)); _action.replaceRow(row2); _action.performMutate(getSearcher(reader, directory), writer); reader = commitAndReopen(reader, writer); assertEquals(2, reader.numDocs()); }
public void replaceRow(final Row row) { _actions.add(new InternalAction() { @Override void performAction(IndexSearcherCloseable searcher, IndexWriter writer) throws IOException { List<List<Field>> docs = RowDocumentUtil.getDocs(row, _fieldManager); Term rowId = createRowId(row.getId()); writer.updateDocuments(rowId, docs); _writeRecordsMeter.mark(docs.size()); _writeRowMeter.mark(); } }); }
MutatableAction extends IndexAction { public void replaceRow(final Row row) { _actions.add(new InternalAction() { @Override void performAction(IndexSearcherCloseable searcher, IndexWriter writer) throws IOException { List<List<Field>> docs = RowDocumentUtil.getDocs(row, _fieldManager); Term rowId = createRowId(row.getId()); writer.updateDocuments(rowId, docs); _writeRecordsMeter.mark(docs.size()); _writeRowMeter.mark(); } }); } }
MutatableAction extends IndexAction { public void replaceRow(final Row row) { _actions.add(new InternalAction() { @Override void performAction(IndexSearcherCloseable searcher, IndexWriter writer) throws IOException { List<List<Field>> docs = RowDocumentUtil.getDocs(row, _fieldManager); Term rowId = createRowId(row.getId()); writer.updateDocuments(rowId, docs); _writeRecordsMeter.mark(docs.size()); _writeRowMeter.mark(); } }); } MutatableAction(ShardContext context); }
MutatableAction extends IndexAction { public void replaceRow(final Row row) { _actions.add(new InternalAction() { @Override void performAction(IndexSearcherCloseable searcher, IndexWriter writer) throws IOException { List<List<Field>> docs = RowDocumentUtil.getDocs(row, _fieldManager); Term rowId = createRowId(row.getId()); writer.updateDocuments(rowId, docs); _writeRecordsMeter.mark(docs.size()); _writeRowMeter.mark(); } }); } MutatableAction(ShardContext context); void deleteRow(final String rowId); void replaceRow(final Row row); void deleteRecord(final String rowId, final String recordId); void replaceRecord(final String rowId, final Record record); void appendColumns(final String rowId, final Record record); void replaceColumns(final String rowId, final Record record); @Override void performMutate(IndexSearcherCloseable searcher, IndexWriter writer); static Term createRowId(String id); static Term createRecordId(String id); @Override void doPreCommit(IndexSearcherCloseable indexSearcher, IndexWriter writer); @Override void doPostCommit(IndexWriter writer); @Override void doPreRollback(IndexWriter writer); @Override void doPostRollback(IndexWriter writer); void mutate(RowMutation mutation); void mutate(List<RowMutation> mutations); static List<RowMutation> reduceMutates(List<RowMutation> mutations); }
MutatableAction extends IndexAction { public void replaceRow(final Row row) { _actions.add(new InternalAction() { @Override void performAction(IndexSearcherCloseable searcher, IndexWriter writer) throws IOException { List<List<Field>> docs = RowDocumentUtil.getDocs(row, _fieldManager); Term rowId = createRowId(row.getId()); writer.updateDocuments(rowId, docs); _writeRecordsMeter.mark(docs.size()); _writeRowMeter.mark(); } }); } MutatableAction(ShardContext context); void deleteRow(final String rowId); void replaceRow(final Row row); void deleteRecord(final String rowId, final String recordId); void replaceRecord(final String rowId, final Record record); void appendColumns(final String rowId, final Record record); void replaceColumns(final String rowId, final Record record); @Override void performMutate(IndexSearcherCloseable searcher, IndexWriter writer); static Term createRowId(String id); static Term createRecordId(String id); @Override void doPreCommit(IndexSearcherCloseable indexSearcher, IndexWriter writer); @Override void doPostCommit(IndexWriter writer); @Override void doPreRollback(IndexWriter writer); @Override void doPostRollback(IndexWriter writer); void mutate(RowMutation mutation); void mutate(List<RowMutation> mutations); static List<RowMutation> reduceMutates(List<RowMutation> mutations);  }