- 博客(56)
- 资源 (2)
- 收藏
- 关注

转载 scala学习stripMargin
问题描述: 在Scala代码块中如何创建多行字符串,是否存在类似其他语言的“定界符”语法?解决方法: 要在Scala中创建多行字符串,就需要了解Scala的Multiline String。在Scala中,利用三个双引号包围多行字符串就可以实现。代码实例如:val foo = “””This isa scala multilineString””
2017-08-14 10:54:18
12752

转载 java synchronized
记下来,很重要。Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能够保证在同一时刻最多只有一个线程执行该段代码。 一、当两个并发线程访问同一个对象object中的这个synchronized(this)同步代码块时,一个时间内只能有一个线程得到执行。另一个线程必须等待当前线程执行完这个代码块以后才能执行该代码块。 二、然而,当一个线程访问object的一
2017-07-16 17:02:17
323

转载 spark架构深入理解
转自网上篇博客,感谢原作者和翻译者。作者本人经常在StackOverflow上回答一个关系Spark架构的问题,发现整个互联网都没有一篇文章能对Spark总体架构进行很好的描述,作者可怜我们这些菜鸟,写了这篇文章,太感动了。本文读者需要一定的Spark的基础知识,至少了解Spark的RDD和DAG。上图引入了很多术语:"Executor","Task","C
2017-05-24 11:21:59
278
原创 虚拟机centos7双网卡搭建Hadoop2.9.2,yarn web配置
经历了找工作到入职,很久没有关注博客了,人也快废了,这几天闲来无事想把一年多以前的东西捡捡,虚拟机搭了一个最简单的分布式集群,三台机器。配置过程有以下几个问题,记录一下。1.配置好环境变量后用hadoop version测试,报找不到hadoop类,注意是hadoop类不是Java类,后来发现是往虚拟机传hadoop安装文件时用的自带拖拽功能,复制过程有文件丢失,改用wcp传就没问题了。2...
2018-12-25 15:40:57
558
原创 Play-akka-spark 错误 p.nettyException - Exception caught in Netty
play集成akka错误[error] p.nettyException - Exception caught in Nettyjava.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lscala/concurrent/ExecutionContext;at play.core.Invoker$.(Invoker.
2017-09-20 14:24:04
422
转载 java之ProcessBuilder执行系统命令
转自:http://blog.youkuaiyun.com/yasha009/article/details/52051629可以使用java中的ProcessBuilder执行本地命令或脚本等工作:以下是一个简单的使用java调用本地python脚本的例子。从某工程代码中整理出来的,未封装,仅供参考。JAVA 代码:[java] view plain co
2017-09-20 10:06:02
3069
原创 akka spark sbt依赖冲突
打包akka和spark依赖时发生依赖冲突,根据http://www.cnblogs.com/scnu-ly/p/5106726.html的指导受到启发,但是文中的代码已经废弃了,查看官网,修改冲突jar包前缀后的配置文件文件如下:libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.0"libraryDepend
2017-09-05 16:01:24
450
转载 批量梯度下降法BGD,随机梯度下降法SGD
1. 批量梯度下降法BGD 批量梯度下降法(Batch Gradient Descent,简称BGD)是梯度下降法最原始的形式,它的具体思路是在更新每一参数时都使用所有的样本来进行更新,其数学形式如下: (1) 对上述的能量函数求偏导: (2) 由于是最小化风险函数,所以按照每个参数θ的梯度负方向来更新每个θ: 具体的伪代码形式为:
2017-09-04 11:39:51
533
转载 线性回归,逻辑回归 深入浅出
对线性回归,logistic回归和一般回归的认识 【转载时请注明来源】:http://www.cnblogs.com/jerrylead JerryLead 2011年2月27日 作为一个机器学习初学者,认识有限,表述也多有错误,望大家多多批评指正。1 摘要 本报告是在学习斯坦福大学机器学习课程前四节加上配套的讲义后的总结与
2017-09-04 11:29:40
9012
原创 play 2.6 -HTTP异步编程1
play异步http编程1.处理异步结果使控制器异步在内部,Play框架从下到上是异步的。Play以异步的、非阻塞的方式处理每个请求。创建非阻塞操作一个Future[Result]最终将会得到一个类型结果的值。通过给出一个Future[Result]而不是一个普通的结果,我们能够快速生成结果而不阻塞。当Future被完成时,play就会服务于re
2017-08-01 17:23:30
413
转载 Play 2.0 中文资料 - Action, Controller 和 Result
Play 2.0 中文资料 - Action, Controller 和 Result2012-10-07 — Yanbin什么是 Action?多数的请求被 Play 应用接收到,并由 Action 进行处理.一个 play.api.mvc.Action 简单说来就是一个 (play.api.mvc.Request => play.api.mvc.Resul
2017-07-31 15:58:54
485
原创 play2 框架 IO error while decoding Routes.scala with UTF-8
Play Web应用的调用顺序和关系为:浏览器 ( http://localhost:9000/ )-> Play 框架 (conf/routes) -> 对应的Controller代码 (app/controllers/Application.scala) -> 对应的返回Action (def index = Action {...}) 的方法 -> 对应的可返回Result的代码 (
2017-07-30 22:08:19
1400
3
原创 Scala 类
import scala.collection.mutable.ArrayBufferimport scala.util.Random/** * Created by shaohui on 2017/7/22 0022. *//////////////////////构造器class Student(val name:String,val age:Int) { printl
2017-07-24 16:09:16
242
转载 java static
(一)Java 静态代码块 静态方法区别一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的;需要在项目启动的时候就初始化,在不创建对象的情况下,其他程序来调用的时候,需要使用静态方法,这种代码是被动执行的. 静态方法在类加载的时候 就已经加载 可以用类名直接调用比如main方法就必须是静态的 这是程序入口两者的区别就是:静态代码块是自动执
2017-07-24 11:33:49
317
原创 插入排序
没事整理一下排序算法。插入排序将一个记录插入到已排序好的有序表中,从而得到一个新,记录数增1的有序表。即:先将序列的第1个记录看成是一个有序的子序列,然后从第2个记录逐个进行插入,直至整个序列有序为止。要点:设立参考点,作为临时存储和判断数组边界之用。直接插入排序示例:public class InsertSort { public void sort(in
2017-07-11 21:13:59
170
转载 Calendar类的add()和set()方法
[java] view plain copypackage cn.itcast_02; import java.util.Calendar; /* * public void add(int field,int amount):根据给定的日历字段和对应的时间,来对当前的日历进行操作。(根据日历字段,增加或减去) * publi
2017-07-10 16:49:08
671
转载 GSON
Gson是Google的一个开源项目,可以将Java对象转换成JSON,也可能将JSON转换成Java对象。 Gson里最重要的对象有2个Gson 和 GsonBuilder Gson有2个最基本的方法1) toJson() – 转换java 对象到JSON2) fromJson() – 转换JSON到java对象 下面是几个小例子1
2017-07-10 14:41:50
210
转载 Spring JdbcTemplate详解
JdbcTemplate简介 Spring对数据库的操作在jdbc上面做了深层次的封装,使用spring的注入功能,可以把DataSource注册到JdbcTemplate之中。 JdbcTemplate位于中。其全限定命名为org.springframework.jdbc.core.JdbcTemplate。要使用JdbcTemlate还需一个这个包包含了一下事务和异常控制
2017-07-10 14:34:11
212
原创 idea快捷键
因为总是忘记idea的快捷键,从今天起每次用到记不住的就更新在此。alt + 回车------快速修复ctrl + alt + 左/右--------跳转前/后一浏览位置
2017-07-09 21:28:09
154
转载 RDD内部转换详解
转自scalahome的博客1,RDD的转换共分为Transformation和Action两类Transformation和Action的区别在于:Action会触发作业的提交,而Transformation不会触发作业的提交如map()和collect()[java] view plain copyde
2017-06-29 21:40:18
1427
转载 rdd是什么
转自jechedo官方介绍 弹性分布式数据集。 RDD是只读的、分区记录的集合。RDD只能基于在稳定物理存储中的数据集和其他已有的RDD上执行确定性操作来创建。问题 只要你敢问度娘RDD是什么,包你看到一大片一模一样的答案,都是说这样的概念性的东西,没有任何的价值。 我只想知道 RDD为什么是弹性 而不是 不弹性, R
2017-06-26 21:14:04
603
转载 hadoop中的GroupingComparator
转自传智播客在日常的数据统计分析中,常常会有类似如下的求分组最大值统计需求,用到的数据示例如下:itemid amount date …10001 136.6 2015-1-12 …10001 165.5 2015-1-12 …10002 122.5 2015-1-12 …10002 166.
2017-06-26 17:06:03
883
原创 oj350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as ma
2017-05-31 20:38:19
247
转载 hadoop 性能调优与运维
转自fengjian1585hadoop 性能调优与运维1. 硬件选择2. 操作系统调优与jvm调优3. hadoop参数调优4. hadoop运维 硬件选择1) hadoop运行环境 2) 原则一: 主节点可靠性要好于从节点 原则二:多路多核,高频率cpu、大内存, namenode 100万文件
2017-05-24 20:56:13
435
转载 partition的形成过程
作者:王燚光链接:http://www.zhihu.com/question/33270495/answer/93424104来源:知乎梳理一下Spark中关于并发度涉及的几个概念File,Block,Split,Task,Partition,RDD以及节点数、Executor数、core数目的关系。输入可能以多个文件的形式存储在HDFS上,每个File都包含了
2017-05-24 17:31:49
310
原创 409. Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not con
2017-05-18 18:19:41
137
原创 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam
2017-05-16 20:18:29
135
原创 oj67. Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".翻译:给定两个二进制字符串,返回它们的和(也是一个二进制字符串)。例如,a = "11"b = "1"Return "100"。
2017-05-15 17:20:51
187
原创 oj520. Detect Capital
iven a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in th
2017-05-13 11:32:48
258
原创 oj28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.翻译:实现strStr()函数返回needle在haystack中的首个索引位置思路:最懵逼的用indexOf函数解决了
2017-05-11 21:19:24
205
原创 oj14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.翻译:编写一个函数来查找字符串数组中最长的公共前缀字符串。思路:英语不太好,题意一开始没有理解清楚,错误理解为找出字符串数组中最大的共同前缀,即只要有任意两个满足条件即可,代码如下,由于无法提交进行所有测试,所以代码肯定
2017-05-10 21:30:28
166
原创 oj459. Repeated Substring Pattern
回家休息了小半个月,荒废了不少,今天继续。Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string co
2017-05-08 18:17:04
164
原创 434. Number of Segments in a String
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable characters.
2017-04-25 11:01:08
162
转载 Math.Round
题目大概是问Math.Round(11.5);和Math.Round(-11.5);返回值是多少?原来不是四舍五入这么简单,其实是四舍六入,但是五是很有讲究的。要是遇到五则取离前一位最近的偶数。比如,这条题目,11.5返回值就是12.0;-11.5返回值就是-11.0; 但是这里其实也不是这么简单:看下面的例子:Math.Round(3.44, 1); //Returns 3.4.Ma
2017-04-24 18:35:49
168
原创 oj383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; ot
2017-04-24 15:42:24
248
原创 oj20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2017-04-24 10:34:26
180
原创 oj557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contes
2017-04-22 10:16:41
184
原创 oj541. Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of th
2017-04-22 09:45:51
247
原创 oj125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a
2017-04-21 10:20:39
222
原创 oj234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.翻译:给定一个单链表,确定它是否是回文。思路:一开始的思路不是很清晰,觉得比较复杂,后来看了答案,思路差不多。就是先算链表的长度,再把链表从中间分成两部分,把后半部分反转,再对比两个链表。public boolean isPalindrome(ListNode hea
2017-04-20 16:08:37
187
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人