label
int64 0
10
| text
stringlengths 45
511
|
---|---|
2 | @Test
public void testName() {
NativeBytesStore<Void> nativeStore = NativeBytesStore.nativeStoreWithFixedCapacity(30);
Bytes<Void> bytes = nativeStore.bytesForWrite();
long expected = 12345L;
int offset = 5;
bytes.writeLong(offset, expected);
bytes.writePosition(offset + 8);
assertEquals(expected, bytes.readLong(offset));
} |
4 | @Test
public void priceFormat() {
assertEquals("%7.2f ", INSTRUMENTS.get("FOO").getPriceFormat());
} |
2 | @Override
public CHConnection connect(String url, Properties info) throws SQLException {
logger.info("Creating connection");
return LogProxy.wrap(CHConnection.class, new CHConnectionImpl(url));
} |
2 | @Test
public void testEmptyArray() throws Exception {
assertEquals(0, new JBBPOut(new ByteArrayOutputStream()).End().toByteArray().length);
} |
2 | @Test
public void testConstructor() throws Exception {
final SessionOutputBufferMock transmitter = new SessionOutputBufferMock();
new IdentityOutputStream(transmitter);
try {
new IdentityOutputStream(null);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException ex) {
//expected
}
} |
1 | public void UnsafeOnCompleted(Action continuation)
{
eff.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().UnsafeOnCompleted(continuation);
} |
4 | @Override
public void destroyAppiumNode(String host) throws IOException {
new Api().getResponse("http://" + host + ":4567"
+ "/appium/stop").body().string();
} |
2 | public List<String> getTables(String schema) throws SQLException {
if (!tablesCache.isEmpty()){
return tablesCache;
}
DbmsQueryResult queryResult = connection.executeQuery(syntax.getTableCommand(schema));
JdbcResultSet jdbcQueryResult = new JdbcResultSet(queryResult);
while (queryResult.next()) {
tablesCache.add(jdbcQueryResult.getString(syntax.getTableNameColumnIndex()));
}
return tablesCache;
} |
10 | public static Tensor Im2Col(Tensor x, Tuple<uint, uint, uint> kernalSize, uint? padding = null, uint stride = 1)
{
if (padding.HasValue)
{
x = x.Pad(1, padding.Value);
}
var list = x.NDto2DList();
var cols = x.Transpose(1, 2, 3, 4, 0).Unfold(3, kernalSize.Item3, stride).Unfold(2, kernalSize.Item2, stride).Unfold(1, kernalSize.Item1, stride);
return cols;
} |
3 | public HeaderDigest getLastHd() {
if (null == lastHd) {
List<HeaderDigest> list = new ArrayList<>(headerDigestList);
if(list.size() > 0) {
this.lastHd = list.get(list.size() - 1);
}
}
return lastHd;
} |
4 | public static HalLinkRelation of(@Nullable LinkRelation relation) {
Assert.notNull(relation, "LinkRelation must not be null!");
if (HalLinkRelation.class.isInstance(relation)) {
return HalLinkRelation.class.cast(relation);
}
return of(relation.value());
} |
3 | public void shutdown() {
finished = true;
queuedRequests.clear();
synchronized (this) {
notifyAll();
}
nextProcessor.shutdown();
} |
4 | @Test
public void canDisplayGeorgian() {
PDFont font = FontUtils.findFontFor(new PDDocument(), "α₯αα αα£αα ααα");
assertNotNull("No font available for Georgian", font);
assertThat(font.getName(), is("NotoSansGeorgian"));
} |
4 | public void removeCache(Object key) {
if (key == null) return;
Jboot.getJbootCache().remove(tableName(), key);
} |
2 | public void run() throws IOException {
Socket socket = serverSock.accept();
BufferedInputStream in = new BufferedInputStream(socket.getInputStream());
// TODO
} |
2 | @Override
protected void saveMetadata() {
new ContainerMetadataCommand(getAccount(), getClient(), getAccess(), this, info.getMetadata()).call();
} |
4 | @Override
public void onCompleted(AbstractBuild<?, ?> build, TaskListener listener) {
GhprbTrigger trigger = Ghprb.extractTrigger(build);
if (trigger != null) {
trigger.getBuilds().onCompleted(build, listener);
}
} |
4 | protected boolean showTagBody( Permission p ) {
boolean permitted = getSecurityContext().implies( p );
return !permitted;
} |
4 | protected override Variable Evaluate(ParsingScript script)
{
bool isMain = !string.IsNullOrWhiteSpace(script.MainFilename) &&
script.MainFilename == script.Filename;
return new Variable(isMain);
} |
10 | private LcrsTreeReader GetTreeReader(string field)
{
var fileName = Path.Combine(_directory, field.ToTrieFileId() + ".tri");
var fs = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
var sr = new StreamReader(fs, Encoding.Unicode);
var reader = new LcrsTreeReader(sr);
_trieReaders.Add(reader);
return reader;
} |
4 | @Test(expected = IllegalArgumentException.class)
public void testDecorateCORSPropertiesValidRequestNullRequestType() {
HttpServletRequest request =
EasyMock.createMock(HttpServletRequest.class);
EasyMock.replay(request);
CORSFilter.decorateCORSProperties(request, null);
} |
3 | @Override
public boolean putConfig(String dataId, String content, long timeoutMills) {
ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUT, timeoutMills);
consulConfigExecutor.execute(() -> {
complete(getConsulClient().setKVValue(dataId, content), configFuture);
});
return (Boolean) configFuture.get();
} |
10 | public static void Start()
{
GraphicsDevice = new GraphicsDevice();
} |
2 | public void testInvalidObjectWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartObject();
// Mismatch:
try {
gen.writeEndArray();
fail("Expected an exception for mismatched array/object write");
} catch (JsonGenerationException e) {
verifyException(e, "Current context not an array");
}
} |
3 | @Override
public long getUidNext() {
return nextUid;
} |
2 | @Test
public void testValidateInvalidCertificate() throws IOException, CertificateException {
BufferedInputStream pem = new BufferedInputStream(new ByteArrayInputStream(invalidPemCert));
assertFalse(crypto.validateCertificate(invalidPemCert));
} |
3 | @Override
protected void init() {
super.init();
currentAddress = stringsStartAddress;
full = false;
currentSegmentIndex = INDEX_NOT_YET_USED;
directMemoryService.setMemory(inUseSegmentAddress, totalSegmentCount, (byte) 0x00);
} |
10 | protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
request.Content = new GzipContent(request.Content, _compressionLevel);
return base.SendAsync(request, cancellationToken);
} |
2 | @Test
public void rendersXmlAwardsPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
XhtmlMatchers.xhtml(
new View(farm, "/u/yegor256/awards").html()
)
),
XhtmlMatchers.hasXPaths("//xhtml:body")
);
} |
4 | public M getCache(Object key) {
return Jboot.getJbootCache().get(tableName(), key);
} |
0 | private void print(EventType type, Args args) {
if (!enable.get(type))
return;
String out = formats.get(type);
for (String k : args.keySet()) {
Object o = args.get(k);
out = out.replace(String.format("%%%s%%", k), o == null ? "null"
: o.toString());
}
this.out.printf(out);
this.out.printf("\n");
if (autoflush)
this.out.flush();
argsPnP(args);
} |
4 | @Override
public int getNumberOfFeatures(){
return (Integer)get("n_features");
} |
3 | long lruCompactions()
{
return lruCompactions;
} |
10 | public static void Main()
{
var httpClient = new HttpClient
{
BaseAddress = new("http://localhost:10000/")
};
var qlClient = new GraphQLClient<Query>(httpClient);
// place for query
} |
4 | public Document normalise() {
if (select("html").isEmpty())
appendElement("html");
if (head() == null)
select("html").first().prependElement("head");
if (body() == null)
select("html").first().appendElement("body");
normalise(this);
normalise(select("html").first());
normalise(head());
return this;
} |
2 | @Test
public void testShortArray_AsShortArray() throws Exception {
assertArrayEquals(new byte[]{1, 2, 3, 4}, binStart().Short(new short[]{(short)0x0102, (short)0x0304}).end().toByteArray());
} |
4 | public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) {
return (InjectionPoint) beanManager.getInjectableReference(
resolve(beanManager, InjectionPointGenerator.class).getInjectionPoints().iterator().next(), creationalContext
);
} |
4 | public void init() {
accountService = NulsContext.getInstance().getService(AccountService.class);
//default local account
List<Account> list = this.accountService.getLocalAccountList();
if (null != list && !list.isEmpty()) {
Locla_acount_id = list.get(0).getId();
}
} |
2 | public void write(Object from, File target) throws IOException {
FileWriter writer = new FileWriter(target);
writer.write(write(from));
writer.close();
} |
4 | @Test
public void testImaging144() throws Exception {
tiffOutputSet.setGPSInDegrees(1.0, 1.0);
TiffOutputDirectory gpsDirectory = tiffOutputSet.getGPSDirectory();
TiffOutputField gpsVersionId = gpsDirectory.findField(GpsTagConstants.GPS_TAG_GPS_VERSION_ID);
assertNotNull(gpsVersionId);
assertTrue(gpsVersionId.bytesEqual(GpsTagConstants.GPS_VERSION));
} |
2 | @Test
public void shouldSyncOnRun() throws Throwable
{
// Given
Connection mock = mock( Connection.class );
InternalSession sess = new InternalSession( mock );
// When
sess.run( "whatever" );
// Then
verify( mock ).sync();
} |
3 | Object readProperties(java.util.Properties p) {
if (instance == null) {
instance = this;
}
instance.readPropertiesImpl(p);
return instance;
} |
10 | public string GetResponseString(Stream stream)
{
var data = new StreamReader(stream).ReadToEnd();
stream.Close();
return data;
} |
10 | private void InitializeGraphics()
{
Assembly assembly = Assembly.GetExecutingAssembly();
this.cancelButton.Image = Image.FromStream(assembly.GetManifestResourceStream("AppMan.Resources.Cancel.png"));
this.Icon = new Icon(assembly.GetManifestResourceStream("AppMan.Resources.AppMan.ico"));
} |
2 | @Test
public void testSelectAlbum() {
AlbumListPage albumListPage = new AlbumListPage(new WebClient());
AlbumPage albumPage = albumListPage.selectAlbum("21");
assertTrue(albumPage.isAt());
} |
3 | float negativeSampling(int target, float lr) {
float loss = 0.0f;
grad_.zero();
for (int n = 0; n <= args_.neg; n++) {
if (n == 0) {
loss += binaryLogistic(target, true, lr);
} else {
loss += binaryLogistic(getNegative(target), false, lr);
}
}
return loss;
} |
3 | public AsteriskChannel getDialingChannel()
{
return dialingChannel;
} |
4 | public static void main(@Nullable String[] args) throws IOException, InterruptedException {
Timer.open();
Socks5Server socks5Server = new Socks5Server();
socks5Server.start(args);
BasicSocksProxyServer server = (BasicSocksProxyServer) socks5Server.server;
NetworkMonitor monitor = server.getNetworkMonitor();
while (true) {
logger.info(monitor.toString());
Thread.sleep(5000);
}
} |
10 | public void Save(Stream stream)
{
using (var writer = new Writer(new StreamWriter(stream, Encoding)))
{
Write(writer);
writer.Close();
}
} |
4 | @Test
public void parseXml_missing_longitude() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<latitude>12.34</latitude>");
Result<Geo> result = marshaller.parseXml(element, params);
Geo prop = result.getValue();
assertEquals(12.34, prop.getLatitude(), 0.001);
assertNull(prop.getLongitude());
assertWarnings(0, result.getWarnings());
} |
10 | [Test]
public void CreateMediaFromFileStream()
{
var media = new Media(new LibVLC(), new FileStream(RealMp3Path, FileMode.Open, FileAccess.Read, FileShare.Read));
media.Parse();
Assert.NotZero(media.Tracks.First().Data.Audio.Channels);
} |
4 | private final void newMisplacedTokenException(int cursor) {
if (_buflen < 0)
throw new IllegalStateException(
"Incomplete data or malformed json : encoutered end of stream.");
if (cursor < 0) cursor = 0;
int pos = (_position - valueAsString().length() - _buflen + cursor);
if (pos < 0) pos = 0;
throw new IllegalStateException("Encountred misplaced character '" + _buffer[cursor]
+ "' around position " + pos);
} |
2 | public StoredObject setContentType(String contentType) {
checkForInfo();
info.setContentType(new ObjectContentType(contentType));
new ObjectMetadataCommand(
getAccount(), getClient(), getAccess(), this,
info.getHeadersIncludingHeader(info.getContentTypeHeader())).call();
return this;
} |
2 | private Result[] batch(final List<? extends org.apache.hadoop.hbase.client.Row> actions)
throws Exception {
return createExecutor(options).batch(actions);
} |
2 | @Override
public ResultSet executeQuery(String sql) throws SQLException {
String csql = clickhousifySql(sql, "TabSeparatedWithNamesAndTypes");
CountingInputStream is = getInputStream(csql);
try {
return new HttpResult(properties.isCompress()
? new ClickhouseLZ4Stream(is) : is, is, properties.getBufferSize());
} catch (Exception e) {
throw new RuntimeException(e);
}
} |
4 | @Benchmark
public int offerAndPollLoops() {
final int burstSize = this.burstSize;
for (int i = 0; i < burstSize; i++) {
q.offer(DUMMY_MESSAGE);
}
Integer result = null;
for (int i = 0; i < burstSize; i++) {
result = q.poll();
}
return result;
} |
6 | public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject,
String perfWmiClass) {
Map<T, Long> valueMap = queryValuesFromPDH(propertyEnum, perfObject);
if (valueMap.isEmpty()) {
return queryValuesFromWMI(propertyEnum, perfWmiClass);
}
return valueMap;
} |
4 | @Override
public Collection<String> getAllTypeNames()
{
return _fqnToModel.get().getFqns();
} |
10 | internal static IOStrategy CreateIOStrategy(Node node)
{
var server = node.Hostname.Replace("8091", node.Ports.Direct.ToString());
var connectionPool = new DefaultConnectionPool(new PoolConfiguration(), Server.GetEndPoint(server));
var ioStrategy = new SocketAsyncStrategy(connectionPool);
return ioStrategy;
} |
4 | @Override
public Object getValue(Map<String, Object> env) {
if (env != null) {
if (this.name.contains(".") && RuntimeUtils.getInstance(env)
.<Boolean>getOption(Options.ENABLE_PROPERTY_SYNTAX_SUGAR)) {
return getProperty(env);
}
return env.get(this.name);
}
return null;
} |
10 | public Task<ScanResult> ScanFileAsync(Stream stream, string filename)
{
ValidateScanFileArguments(stream, FileSizeLimit, filename);
MultipartFormDataContent multi = new MultipartFormDataContent();
multi.Add(CreateApiPart());
multi.Add(CreateFileContent(stream, filename));
//https://www.virustotal.com/vtapi/v2/file/scan
return GetResponse<ScanResult>("file/scan", HttpMethod.Post, multi);
} |
4 | public override Neuron CopyNeuronTo(Neuron neuron)
{
LSTMNeuron lstmNeuron = neuron as LSTMNeuron;
Cells.CopyTo(lstmNeuron.Cells, 0);
// previousCellOutputs.CopyTo(lstmNeuron.PrevCellOutputs, 0);
for (int i = 0; i < LayerSize; i++)
{
lstmNeuron.LSTMCells[i].Set(LSTMCells[i]);
}
return lstmNeuron;
} |
3 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ScanParams that = (ScanParams) o;
if (!Arrays.equals(packages, that.packages)) return false;
if (matching != null ? !matching.equals(that.matching) : that.matching != null) return false;
if (!Arrays.equals(annotated, that.annotated)) return false;
return classLoader != null ? classLoader.equals(that.classLoader) : that.classLoader == null;
} |
2 | @Test
public void testCarriageReturnEndings() throws IOException {
final String code = "foo\rbaar,\rhello,world\r,kanu";
final CSVParser parser = CSVParser.parse(code, CSVFormat.DEFAULT);
final List<CSVRecord> records = parser.getRecords();
assertEquals(4, records.size());
} |
4 | public void prepareRemotingContainer() throws IOException, InterruptedException {
// if remoting container already exists, we reuse it
if (context.getRemotingContainer() != null) {
if (driver.hasContainer(localLauncher, context.getRemotingContainer())) {
return;
}
}
driver.createRemotingContainer(localLauncher, context.getRemotingContainer());
} |
2 | protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
splitInputStream.prepareExtractionForFileHeader(fileHeader);
return new ZipInputStream(splitInputStream, password);
} |
2 | public static void main(String[] args) throws SQLException, Exception {
AllBenchmark.runBenchmark(DbHelper.mockDb(), SmallBenchmarkObject.class, DynamicJdbcMapperForEachBenchmark.class, BenchmarkConstants.SINGLE_QUERY_SIZE, BenchmarkConstants.SINGLE_NB_ITERATION);
} |
2 | public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) {
PdfStream stream = new PdfStream(document);
PdfCanvas canvas = new PdfCanvas(stream, new PdfResources());
Rectangle rect = placeBarcode(canvas, barColor, textColor);
PdfFormXObject xObject = new PdfFormXObject(document, rect);
xObject.getPdfObject().getOutputStream().writeBytes(stream.getBytes());
return xObject;
} |
3 | long rehashes()
{
return rehashes;
} |
4 | @Override
public Set keys() {
Set<byte[]> keys = JedisUtil.getJedis().keys(new String("*").getBytes());
Set<Object> set = new HashSet<Object>();
for (byte[] bs : keys) {
set.add(SerializableUtil.unserializable(bs));
}
return set;
} |
2 | @Test
public void testLongArray() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08, 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18}, binStart().Long(0x0102030405060708L,0x1112131415161718L).end().toByteArray());
} |
4 | public Object doGenerate(Parameterizable parameterizedType) {
Queue returnedQueue = (Queue) RandomFactory.getRandomValue(parameterizedType.getType());
returnedQueue.clear();
CollectionHelper.buildCollections(returnedQueue, parameterizedType.getParameterTypes().get(0));
return returnedQueue;
} |
3 | public static Func<TextReader, T> Get()
{
if (Thunk != null) return Thunk;
lock (InitLock)
{
if (Thunk != null) return Thunk;
Thunk = InlineDeserializerHelper.Build<T>(typeof(NewtonsoftStyleTypeCache<>), DateTimeFormat.NewtonsoftStyleMillisecondsSinceUnixEpoch, allowHashing: true, exceptionDuringBuild: out ExceptionDuringBuild);
return Thunk;
}
} |
4 | @Test
public void writeXml_null() {
IntegerProperty prop = new IntegerProperty(null);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "");
assertXMLEqual(expected, actual);
} |
10 | internal static IOStrategy CreateIOStrategy(Node node)
{
var server = node.Hostname.Replace("8091", node.Ports.Direct.ToString());
var connectionPool = new DefaultConnectionPool(new PoolConfiguration(), Server.GetEndPoint(server));
var ioStrategy = new AwaitableIOStrategy(connectionPool, null);
return ioStrategy;
} |
3 | public void close() {
if( thread != null ) {
thread.interrupt();
closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}
}
} |
4 | public void disconnect() {
ChannelFuture future = send(new Packet(PacketType.DISCONNECT));
future.addListener(ChannelFutureListener.CLOSE);
onChannelDisconnect();
} |
2 | @Test(expected = UnsupportedOperationException.class)
public void testChildEntriesUnmodifiable() throws IOException {
CompoundDocument document = createTestDocument();
Entry root = document.getRootEntry();
assertNotNull(root);
SortedSet<Entry> children = root.getChildEntries();
// Should not be allowed, as it modifies the internal structure
children.remove(children.first());
} |
4 | public FtpDataStream OpenRead(string path, FtpDataType datatype, long rest) {
FtpDataStream s = this.OpenDataStream(datatype);
if (rest > 0) {
s.Seek(rest);
}
if (!s.Execute("RETR {0}", path)) {
s.Dispose();
throw new FtpCommandException(this);
}
return s;
} |
6 | HttpCacheEntry doGetUpdatedParentEntry(
final String requestId,
final HttpCacheEntry existing,
final HttpCacheEntry entry,
final String variantURI) throws IOException {
if (existing != null) {
return cacheEntryFactory.copyVariant(requestId, existing, variantURI);
} else {
return cacheEntryFactory.copyVariant(requestId, entry, variantURI);
}
} |
3 | @Override
public boolean addAll(int index, Collection<? extends T> c) {
for (T element : c) {
internalIndexedAdd(index++, element, false);
}
refreshStorage(true);
return true;
} |
3 | protected void reset() {
config().reset();
mirrorLog = false;
versionToDownload = null;
forcedArch = false;
forcedOs = false;
retryCount = 0;
isSnap = false;
} |
2 | public static Object deserializeStream(final String witness) throws Exception {
final FileInputStream fileIs = new FileInputStream(witness);
final ObjectInputStream objIs = new ObjectInputStream(fileIs);
try {
return objIs.readObject();
} finally {
objIs.close();
}
} |
3 | public void bindInterceptor(Matcher<? super Class<?>> classMatcher,
Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors) {
ensureNotCreated();
proxyFactoryBuilder.intercept(classMatcher, methodMatcher, interceptors);
} |
3 | public void doReconnect(Channel channel, HttpRequest req) {
isKeepAlive = isKeepAlive(req);
this.channel = channel;
this.connected = true;
sendPayload();
} |
4 | public static String getLoginName()
{
return getUser().getLoginName();
} |
4 | private Long getRequestStartTime() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
return (Long) requestAttributes.getAttribute(REQUEST_START_TIME, SCOPE_REQUEST);
} |
4 | @Override
public SymbolReference<TypeDeclaration> solveType(String name, TypeSolver typeSolver) {
return JavaParserFactory.getContext(wrappedNode.getParentNode(), typeSolver).solveType(name, typeSolver);
} |
3 | public long getIdleTimeMillis() {
return System.currentTimeMillis() - lastActiveTime;
} |
2 | @Test
public void testAutoMapToInterfaceWithIndexTooSmall() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person7.class) //
.firstOrError() //
.map(Person7::examScore) //
.test().awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS) //
.assertNoValues() //
.assertError(ColumnIndexOutOfRangeException.class);
} |
10 | public static IEnumerable<dynamic> Query(this Stream stream, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", IConfiguration configuration = null)
{
return ExcelReaderFactory.GetProvider(stream, ExcelTypeHelper.GetExcelType(stream, excelType)).Query(useHeaderRow, sheetName, startCell, configuration);
} |
2 | @Test
public void test1() {
EuclidDistanceUDF udf = new EuclidDistanceUDF();
List<String> ftvec1 = Arrays.asList("1:1.0", "2:2.0", "3:3.0");
List<String> ftvec2 = Arrays.asList("1:2.0", "2:4.0", "3:6.0");
FloatWritable d = udf.evaluate(ftvec1, ftvec2);
Assert.assertEquals((float) Math.sqrt(1.0 + 4.0 + 9.0), d.get(), 0.f);
} |
4 | @Test(expected = CannotParseException.class)
public void parseXml_bad_longitude() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<latitude>12.34</latitude><longitude>bad</longitude>");
marshaller.parseXml(element, params);
} |
4 | public void setRequestedState(String partitionName, String state) {
Map<String, Map<String, String>> mapFields = _record.getMapFields();
if (mapFields.get(partitionName) == null) {
mapFields.put(partitionName, new TreeMap<String, String>());
}
mapFields.get(partitionName).put(CurrentStateProperty.REQUESTED_STATE.name(), state);
} |
3 | public int getResponseCode() {
if (response == null) {
throw new IllegalStateException("The request must first be executed");
}
return response.getCode();
} |
3 | public void run() {
try {
_run();
}
catch (Throwable e) {
Logs.get().error("something happen", e);
}
} |
10 | public override Tensor<double> Clone ()
{
var typedInner = inner as DoubleTensor;
var innerClone = typedInner.Clone ();
var storage = innerClone.Storage;
storage.Retain ();
var mem = new DoubleNativeMemory (storage);
return new DoubleTorchTensor (mem.Memory, Dimensions, innerClone);
} |
4 | @Ignore
@Test
public void testCookie() {
Site site = Site.me().setDomain("www.diandian.com").addCookie("t", "yct7q7e6v319wpg4cpxqduu5m77lcgix");
HttpClientDownloader httpClientDownloader = new HttpClientDownloader();
Page download = httpClientDownloader.download(new Request("http://www.diandian.com"), site);
Assert.assertTrue(download.getHtml().toString().contains("flashsword30"));
} |
4 | @Override
public void deliver() {
if (actor.__internal__IsResumed()) {
if (isStowed()) {
internalDeliver(this);
} else {
internalDeliver(actor.__internal__Environment().suspended.swapWith(this));
}
actor.__internal__NextResuming();
} else if (actor.isDispersing()) {
internalDeliver(actor.__internal__Environment().stowage.swapWith(this));
} else {
internalDeliver(this);
}
} |
4 | protected void applyOverlayType() {
setShowOnAttach(false);
getNavMenu().setShowOn(ShowOn.SHOW_ON_LARGE);
if (overlayOpeningHandler == null) {
overlayOpeningHandler = addOpeningHandler(event -> {
Scheduler.get().scheduleDeferred(() -> $("#sidenav-overlay").css("visibility", "visible"));
});
}
$("header").css("paddingLeft", "0px");
$("main").css("paddingLeft", "0px");
} |