コード例 #1
0
  @Test
  public void testCalculateIndexUpdates_DeleteRow() throws IOException {

    KeyValue keyValue =
        new KeyValue("_row_".getBytes(), "".getBytes(), "".getBytes(), 0L, Type.Delete);
    RowData rowData = createEventRowData("_row_", keyValue);
    indexer.calculateIndexUpdates(ImmutableList.of(rowData), updateCollector);

    assertEquals(Lists.newArrayList("_row_"), updateCollector.getIdsToDelete());
    assertTrue(updateCollector.getDocumentsToAdd().isEmpty());
  }
コード例 #2
0
  @Test
  public void testCalculateIndexUpdates_AddDocument() throws IOException {

    KeyValue keyValue =
        new KeyValue(
            "_row_".getBytes(), "_cf_".getBytes(), "_qual_".getBytes(), "value".getBytes());
    RowData rowData = createEventRowData("_row_", keyValue);
    indexer.calculateIndexUpdates(ImmutableList.of(rowData), updateCollector);

    assertEquals(1, updateCollector.getDocumentsToAdd().size());
    assertEquals("_row_", updateCollector.getDocumentsToAdd().get("_row_").getFieldValue("id"));
    assertTrue(updateCollector.getIdsToDelete().isEmpty());
  }
コード例 #3
0
  @Test
  public void testCalculateIndexUpdates_AddDocumentWithTableName() throws IOException {

    doReturn("custom-table-name").when(indexerConf).getTableNameField();

    KeyValue keyValue =
        new KeyValue(
            "_row_".getBytes(), "_cf_".getBytes(), "_qual_".getBytes(), "value".getBytes());
    RowData rowData = createEventRowData("_row_", keyValue);
    indexer.calculateIndexUpdates(ImmutableList.of(rowData), updateCollector);

    assertEquals(1, updateCollector.getDocumentsToAdd().size());
    List<SolrInputDocument> documents =
        Lists.newArrayList(updateCollector.getDocumentsToAdd().values());
    assertEquals(TABLE_NAME, documents.get(0).getFieldValue("custom-table-name"));
  }
コード例 #4
0
  @Test
  public void testCalculateIndexUpdates_UpdateAndDeleteCombinedForSameCell_UpdateFirst()
      throws IOException {
    KeyValue toAdd =
        new KeyValue(
            "_row_".getBytes(), "_cf_".getBytes(), "_qual_".getBytes(), "value".getBytes());
    KeyValue toDelete =
        new KeyValue("_row_".getBytes(), "_cf_".getBytes(), "_qual_".getBytes(), 0L, Type.Delete);
    RowData addEventRowData = createEventRowData("_row_", toAdd);
    RowData deleteEventRowData = createEventRowData("_row_", toDelete);

    indexer.calculateIndexUpdates(
        Lists.newArrayList(addEventRowData, deleteEventRowData), updateCollector);

    assertEquals(Lists.newArrayList("_row_"), updateCollector.getIdsToDelete());
    assertTrue(updateCollector.getDocumentsToAdd().isEmpty());
  }
コード例 #5
0
  @Test
  public void testCalculateIndexUpdates_UpdateAndDeleteCombinedForSameCell_DeleteFirst()
      throws IOException {
    KeyValue toDelete =
        new KeyValue("_row_".getBytes(), "_cf_".getBytes(), "_qual_".getBytes(), 0L, Type.Delete);
    KeyValue toAdd =
        new KeyValue(
            "_row_".getBytes(), "_cf_".getBytes(), "_qual_".getBytes(), "value".getBytes());
    RowData deleteEventRowData = createEventRowData("_row_", toDelete);
    RowData addEventRowData = createEventRowData("_row_", toAdd);

    indexer.calculateIndexUpdates(
        ImmutableList.of(deleteEventRowData, addEventRowData), updateCollector);

    assertTrue(updateCollector.getIdsToDelete().isEmpty());
    List<SolrInputDocument> documents =
        Lists.newArrayList(updateCollector.getDocumentsToAdd().values());
    assertEquals(1, documents.size());
    assertEquals("_row_", documents.get(0).getFieldValue("id"));
  }