public void add(BytesArrayPool baPool) { for (BytesArray pool : baPool.inUse()) { add(pool); } }
private void writeTemplate(Collection<Object> template, Object object) { for (Object item : template) { if (item instanceof BytesArray) { ref.add((BytesArray) item); } else if (item instanceof FieldWriter) { ref.add(((FieldWriter) item).write(object)); } // used in the dynamic case else if (item instanceof DynamicContentRef) { List<Object> dynamicContent = ((DynamicContentRef) item).getDynamicContent(); writeTemplate(dynamicContent, object); } else { throw new EsHadoopIllegalArgumentException(String.format("Unknown object type received [%s][%s]", item, item.getClass())); } } } }
/** * Writes the objects to index. * * @param ba The data as a bytes array */ public void writeProcessedToIndex(BytesArray ba) { Assert.notNull(ba, "no data given"); Assert.isTrue(ba.length() > 0, "no data given"); lazyInitWriting(); trivialBytesRef.reset(); trivialBytesRef.add(ba); doWriteToIndex(trivialBytesRef); }
@Override public BytesRef write(Object object) { ref.reset(); scratchPad.reset(); Object processed = preProcess(object, scratchPad); // write before object writeTemplate(beforeObject, processed); // write object doWriteObject(processed, scratchPad, valueWriter); ref.add(scratchPad); // writer after object writeTemplate(afterObject, processed); return ref; }
private void processData(BulkProcessor processor) { BytesRef data = new BytesRef(); data.add(renderEntry("A")); processor.add(data); data.reset(); data.add(renderEntry("B")); processor.add(data); data.reset(); data.add(renderEntry("C")); processor.add(data); data.reset(); data.add(renderEntry("D")); processor.add(data); data.reset(); data.add(renderEntry("E")); processor.add(data); data.reset(); }
@Test public void testWriteBulkEntryWithHandlersThatCorrectsData() { BytesRef response = new BytesRef(); response.add("abcdefg".getBytes()); BulkCommand command = Mockito.mock(BulkCommand.class); Mockito.when(command.write(1)).thenThrow(new EsHadoopIllegalStateException("Things broke")); Mockito.when(command.write(10)).thenReturn(response); Settings settings = new TestSettings(); settings.setProperty(SerializationHandlerLoader.ES_WRITE_DATA_ERROR_HANDLERS, "fix"); settings.setProperty(SerializationHandlerLoader.ES_WRITE_DATA_ERROR_HANDLER+".fix", CorrectingHandler.class.getName()); BulkEntryWriter bulkEntryWriter = new BulkEntryWriter(settings, command); BytesRef value = bulkEntryWriter.writeBulkEntry(1); Assert.assertNotNull("Skipped values should be null", value); Assert.assertEquals(7, response.length()); Assert.assertArrayEquals("abcdefg".getBytes(), response.toString().getBytes()); }
@Test public void testAddAndReset() throws Exception { BytesArrayPool pool = new BytesArrayPool(); pool.get().bytes("Test"); pool.get().bytes("Data"); pool.get().bytes("Rules"); BytesRef ref = new BytesRef(); assertEquals(13, pool.length()); ref.add(pool); assertEquals("TestDataRules", ref.toString()); BytesRef ref2 = new BytesRef(); pool.reset(); pool.get().bytes("New"); pool.get().bytes("Info"); assertEquals(7, pool.length()); ref2.add(pool); assertEquals("NewInfo", ref2.toString()); } }
public void add(BytesArrayPool baPool) { for (BytesArray pool : baPool.inUse()) { add(pool); } }
public void add(BytesArrayPool baPool) { for (BytesArray pool : baPool.inUse()) { add(pool); } }
public void add(BytesArrayPool baPool) { for (BytesArray pool : baPool.inUse()) { add(pool); } }
public void add(BytesArrayPool baPool) { for (BytesArray pool : baPool.inUse()) { add(pool); } }
/** * Writes the objects to index. * * @param ba The data as a bytes array */ public void writeProcessedToIndex(BytesArray ba) { Assert.notNull(ba, "no data given"); Assert.isTrue(ba.length() > 0, "no data given"); lazyInitWriting(); trivialBytesRef.reset(); trivialBytesRef.add(ba); doWriteToIndex(trivialBytesRef); }
/** * Writes the objects to index. * * @param ba The data as a bytes array */ public void writeProcessedToIndex(BytesArray ba) { Assert.notNull(ba, "no data given"); Assert.isTrue(ba.length() > 0, "no data given"); lazyInitWriting(); trivialBytesRef.reset(); trivialBytesRef.add(ba); doWriteToIndex(trivialBytesRef); }
/** * Writes the objects to index. * * @param ba The data as a bytes array */ public void writeProcessedToIndex(BytesArray ba) { Assert.notNull(ba, "no data given"); Assert.isTrue(ba.length() > 0, "no data given"); lazyInitWriting(); trivialBytesRef.reset(); trivialBytesRef.add(ba); doWriteToIndex(trivialBytesRef); }
/** * Writes the objects to index. * * @param data as a byte array * @param size the length to use from the given array */ public void writeProcessedToIndex(BytesArray ba) { Assert.notNull(ba, "no data given"); Assert.isTrue(ba.length() > 0, "no data given"); lazyInitWriting(); trivialBytesRef.reset(); trivialBytesRef.add(ba); doWriteToIndex(trivialBytesRef); }
@Override public BytesRef write(Object object) { ref.reset(); scratchPad.reset(); Object processed = preProcess(object, scratchPad); // write before object writeTemplate(beforeObject, processed); // write object doWriteObject(processed, scratchPad, valueWriter); ref.add(scratchPad); // writer after object writeTemplate(afterObject, processed); return ref; }
@Override public BytesRef write(Object object) { ref.reset(); scratchPad.reset(); Object processed = preProcess(object, scratchPad); // write before object writeTemplate(beforeObject, processed); // write object doWriteObject(processed, scratchPad, valueWriter); ref.add(scratchPad); // writer after object writeTemplate(afterObject, processed); return ref; }
@Override public BytesRef write(Object object) { ref.reset(); scratchPad.reset(); Object processed = preProcess(object, scratchPad); // write before object writeTemplate(beforeObject, processed); // write object doWriteObject(processed, scratchPad, valueWriter); ref.add(scratchPad); // writer after object writeTemplate(afterObject, processed); return ref; }