public DynamicStitch(SameDiff sameDiff, SDVariable[] indices, SDVariable[] inputs) { super(null, sameDiff, ArrayUtils.addAll(indices, inputs), false); this.indices = indices; this.numPartitions = inputs.length; }
@Override public String getParameter(String name) { Object temp = reducedMap.get(name); Object[] response = new Object[0]; if (temp != null) { ArrayUtils.addAll(response, temp); } if (ArrayUtils.isEmpty(response)) { return null; } else { return (String) response[0]; } }
@Override public Field[] getAllFields(Class<?> targetClass) { Field[] allFields = new Field[]{}; boolean eof = false; Class<?> currentClass = targetClass; while (!eof) { Field[] fields = currentClass.getDeclaredFields(); allFields = ArrayUtils.addAll(allFields, fields); if (currentClass.getSuperclass() != null) { currentClass = currentClass.getSuperclass(); } else { eof = true; } } return allFields; }
private static void collectTokens(FileSystem fs, TokenWrapper twrapper, Credentials creds, String userName) throws IOException { Token[] tokens = fs.addDelegationTokens(userName, creds); if(tokens != null && tokens.length > 0) { twrapper.tokens = ArrayUtils.addAll(twrapper.tokens, tokens); } } /**
for (final Iterator<?> it = iterable.iterator(); it.hasNext(); i++) { if (it.next() == null) { final Object[] values2 = ArrayUtils.addAll(values, Integer.valueOf(i)); throw new IllegalArgumentException(String.format(message, values2));
final List<Class<?>> superclassList = ClassUtils.getAllSuperclasses(cls); for (final Class<?> klass : superclassList) { methodArray = ArrayUtils.addAll(methodArray, klass.getDeclaredMethods());
public static Expectation[] loadExpectations() { final Expectation[] expectationsFromInitializerClass = retrieveExpectationsFromInitializerClass(); final Expectation[] expectationsFromJson = retrieveExpectationsFromJson(); return ArrayUtils.addAll(expectationsFromInitializerClass, expectationsFromJson); } }
@Override public DrillBuf[] getBuffers(boolean clear) { return ArrayUtils.addAll(offsets.getBuffers(clear), super.getBuffers(clear)); }
/** * Generate a {@link Guid} for an array of byte arrays. * @param byteArrays array of byte arrays. * @return a single {@link Guid} for the array. * @throws IOException */ public static Guid fromByteArrays(byte[]... byteArrays) throws IOException { if (byteArrays == null || byteArrays.length == 0) { throw new IOException("Attempting to compute guid for an empty array."); } if (byteArrays.length == 1) { return new Guid(byteArrays[0]); } byte[] tmp = new byte[0]; for (byte[] arr : byteArrays) { tmp = ArrayUtils.addAll(tmp, arr); } return new Guid(tmp); }
protected PagedFile map( PageCache pageCache, File file, int filePageSize, OpenOption... options ) throws IOException { return pageCache.map( file, filePageSize, addAll( openOptions, options ) ); }
@Test public void testJira567(){ Number[] n; // Valid array construction n = ArrayUtils.addAll(new Number[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)}); assertEquals(2,n.length); assertEquals(Number.class,n.getClass().getComponentType()); try { // Invalid - can't store Long in Integer array n = ArrayUtils.addAll(new Integer[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)}); fail("Should have generated IllegalArgumentException"); } catch (final IllegalArgumentException expected) { } }
private void testBase64InBuffer(final int startPasSize, final int endPadSize) { final String content = "Hello World"; String encodedContent; final byte[] bytesUtf8 = StringUtils.getBytesUtf8(content); byte[] buffer = ArrayUtils.addAll(bytesUtf8, new byte[endPadSize]); buffer = ArrayUtils.addAll(new byte[startPasSize], buffer); final byte[] encodedBytes = new Base64().encode(buffer, startPasSize, bytesUtf8.length); encodedContent = StringUtils.newStringUtf8(encodedBytes); assertEquals("encoding hello world", "SGVsbG8gV29ybGQ=", encodedContent); }
private void testBase64InBuffer(final int startPasSize, final int endPadSize) { final Base32 codec = new Base32(); for (final String[] element : BASE32_TEST_CASES) { final byte[] bytes = element[0].getBytes(CHARSET_UTF8); byte[] buffer = ArrayUtils.addAll(bytes, new byte[endPadSize]); buffer = ArrayUtils.addAll(new byte[startPasSize], buffer); assertEquals(element[1], StringUtils.newStringUtf8(codec.encode(buffer, startPasSize, bytes.length))); } }
@Override public String[] extractPartitions(Message message) throws Exception { JSONObject jsonObject = (JSONObject) JSONValue.parse(message.getPayload()); if (jsonObject == null) { throw new RuntimeException("Failed to parse message as Json object"); } String eventType = extractEventType(jsonObject); long timestampMillis = extractTimestampMillis(jsonObject); String[] timestampPartitions = generatePartitions(timestampMillis, mUsingHourly, mUsingMinutely); return (String[]) ArrayUtils.addAll(new String[]{eventType}, timestampPartitions); }
public Scenario(T col1, T col2) { this.col1 = col1; this.col2 = col2; this.col1col2Appended = Arrays.asList(ArrayUtils.addAll(this.col1.asObjectArray(), this.col2.asObjectArray())); } }
@Test public void testGetAllFields() { assertArrayEquals(new Field[0], FieldUtils.getAllFields(Object.class)); final Field[] fieldsNumber = Number.class.getDeclaredFields(); assertArrayEquals(fieldsNumber, FieldUtils.getAllFields(Number.class)); final Field[] fieldsInteger = Integer.class.getDeclaredFields(); assertArrayEquals(ArrayUtils.addAll(fieldsInteger, fieldsNumber), FieldUtils.getAllFields(Integer.class)); final Field[] allFields = FieldUtils.getAllFields(PublicChild.class); // Under Jacoco,0.8.1 and Java 10, the field count is 7. int expected = 5; for (Field field : allFields) { if (field.getName().equals(JACOCO_DATA_FIELD_NAME)) { expected++; } } assertEquals(Arrays.toString(allFields), expected, allFields.length); }
IndexEntryUpdate<IndexDescriptor>[] someUpdatesWithDuplicateValues( RandomRule randomRule ) { Iterator<Value> valueIterator = new RandomValueGenerator( randomRule.randomValues(), supportedTypes(), fractionDuplicates() ); Value[] someValues = new Value[N_VALUES]; for ( int i = 0; i < N_VALUES; i++ ) { someValues[i] = valueIterator.next(); } return generateAddUpdatesFor( ArrayUtils.addAll( someValues, someValues ) ); }
@Test public void mustLogAfterResetWithCountLimit() { int limit = 10; logger.setCountLimit( limit ); String[] lines = logLines( limit + 1 ); logger.reset(); String[] moreLines = logLines( 1, limit + 1 ); assertLoggedLines( ArrayUtils.addAll( ArrayUtils.subarray( lines, 0, limit ), moreLines ), 1 + limit ); logProvider.assertNone( currentLog( inLog( CappedLogger.class ), containsString( lines[limit] ) ) ); logProvider.assertContainsMessageMatching( containsString( moreLines[0] ) ); }
@Test public void unsettingCountLimitMustLetMessagesThrough() { int limit = 10; logger.setCountLimit( limit ); String[] lines = logLines( limit + 1 ); logger.unsetCountLimit(); int moreLineCount = 1000; String[] moreLines = logLines( moreLineCount, limit + 1 ); assertLoggedLines( ArrayUtils.addAll( ArrayUtils.subarray( lines, 0, limit ), moreLines ), moreLineCount + limit ); logProvider.assertNone( currentLog( inLog( CappedLogger.class ), containsString( lines[limit] ) ) ); assertLoggedLines( moreLines, moreLineCount, limit ); }