我的地图任务需要一些配置数据,我想通过分布式缓存分发.
Hadoop MapReduce教程显示了DistributedCache类的用法,大致如下:
// In the driver
JobConf conf = new JobConf(getConf(), WordCount.class);
...
DistributedCache.addCacheFile(new Path(filename).toUri(), conf);
// In the mapper
Path[] myCacheFiles = DistributedCache.getLocalCacheFiles(job);
...
Run Code Online (Sandbox Code Playgroud)
然而,DistributedCache
在为过时标记中的Hadoop 2.2.0.
实现这一目标的新方法是什么?是否有涵盖此API的最新示例或教程?
我有两个实体,我想用JMSSerializerBundle序列化.该Music
实体的映射文件用exclusion_policy: NONE
.
该Music
实体拥有实体的领域User
从FOSUserBundle
.该User
实体有一个映射文件,exclusion_policy: ALL
其中设置了几个字段expose: true
,因此它们将被序列化.
问题是,该User
字段完全序列化.如果我更改User
实体的映射文件并不重要.
这是它的样子:
#My/Bundle/Resources/config/serializer/Entity.Music.yml
xxx\xxx\Entity\Music:
exclusion_policy: NONE
#My/Bundle/Resources/config/serializer/Entity.User.yml
xxx\xxx\Entity\User:
exclusion_policy: ALL
properties:
id:
expose: true
username:
expose: true
username_canonical:
exclude: true
email:
exclude: true
email_canonical:
exclude: true
enabled:
exclude: true
salt:
exclude: true
password:
exclude: true
last_login:
exclude: true
confirmation_token:
exclude: true
password_requested_at:
exclude: true
groups:
exclude: true
locked:
exclude: true
expired:
exclude: true
expires_at:
exclude: …
Run Code Online (Sandbox Code Playgroud) serialization symfony symfony-2.1 jmsserializerbundle symfony-2.0
我正在尝试将一个.jar
库添加到我的项目到该/libs
文件夹中.这是我的grade.build
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar', 'libs/java-api-wrapper-1.2.0-all.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 16
}
}
Run Code Online (Sandbox Code Playgroud)
在我添加之后,我构建了我的项目并且没有错误.但是当我尝试在我的代码中使用该类时private ApiWrapper wrapper
,我收到一个错误:
Gradle: error: cannot find symbol class ApiWrapper
Run Code Online (Sandbox Code Playgroud)
我无法找到错误的位置.我grade.build
不行,或者我应该以其他方式构建它?
随着我对Galaxy Nexus和Nexus 7的4.2.2的新更新,我找不到我的设备adb
.
这些是我采取的步骤:
当我跑步时adb devices
,它只是空白.我在Windows 8和Ubuntu 12.10上遇到了同样的问题,但在Ubuntu上它显示了我的设备,它说offline
.
我还有其他步骤吗?
我在我的Android应用程序中使用Jackson.
我在构建路径中添加了这两个jar:
jackson-core-asl-1.0.0.jar
jackson-mapper-asl-1.0.0.jar
Run Code Online (Sandbox Code Playgroud)
但是,我在Logcat中一直看到这个:
11-24 18:25:15.093: I/dalvikvm(28842): Could not find method org.codehaus.jackson.map.ObjectMapper.getTypeFactory, referenced from method org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType
11-24 18:25:15.093: W/dalvikvm(28842): VFY: unable to resolve virtual method 17967: Lorg/codehaus/jackson/map/ObjectMapper;.getTypeFactory ()Lorg/codehaus/jackson/map/type/TypeFactory;
Run Code Online (Sandbox Code Playgroud)
这只是在那种方法上.我在类似的错误上搜索了StackOverflow,但它们都是:
我的Android版本是4.0.3.我正在将它与Spring Android
库结合使用.
所以我一直在拍摄Android Preview L的Material Design.我导入了这两个CardView
和RecyclerView
库.
我使用Android Studio预览版0.8.0.安装最新的SDK包.
一旦我在布局文件中使用它们,预览器就会抛出两个异常.
以下是例外情况CardView
:
java.lang.ClassFormatError: Illegal field name "CardView.Dark" in class android/support/v7/cardview/R$style
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
at org.jetbrains.android.uipreview.ProjectClassLoader.findClass(ProjectClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at android.support.v7.widget.CardView.initialize(CardView.java:69)
at android.support.v7.widget.CardView.<init>(CardView.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:375)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.inflate(LayoutInflater.java:478)
at android.view.LayoutInflater.inflate(LayoutInflater.java:381)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:395)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:575)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:564)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691) …
Run Code Online (Sandbox Code Playgroud) android android-studio android-5.0-lollipop android-recyclerview
*编写解决方法:*
我已经通过改变我onDestroy()
的活动和解决方案解决了这个问题ServiceConnection::onServiceDisconnected()
.
我添加了一个布尔值来检查我是否受限于被调用的服务boundToService
.ServiceConnection:
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
myService = ((EventService.MyBinder) service).getService();
}
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
Log.i(getPackageName(), "ServiceConnection::onServiceDisconnected() called");
boundToService = false;
}
};
Run Code Online (Sandbox Code Playgroud)
而且onDestroy()
:
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.e(getPackageName(), "Destroying Activity");
if (boundToService && mConnection != null) {
doUnbindService();
}
}
Run Code Online (Sandbox Code Playgroud)
这是在活动中完成绑定和解除绑定的方式:
public void doBindService() { …
Run Code Online (Sandbox Code Playgroud) 我正在编写音乐播放器,音乐在后台播放Service
.当用户关闭Activity
它承载3 Fragments
,然后重新启动Activity
一次,我送一个Broadcast
从Service
包含有关当前播放歌曲的信息,以及用户添加到其会话歌曲列表.
问题是,每当我想要将最后的信息设置为Fragments
没有发生任何事情,因为他们的创建花费的时间太长,并且Broadcast
不会像他们应该那样处理.
我怎样才能让片段创建Service
或Broadcast
等待,以便妥善处理?
以下是相关的代码段:
//When the activity binds to the service, refresh the fragments
private ServiceConnection conn = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
LocalBinder binder = (LocalBinder) service;
myService = binder.getService();
myService.setBound(true);
if(myService.startedOnce) {
myService.refreshFragments();
}
myService.startedOnce = true;
}
}
//This is the broadcast receiver of the Fragment
//it receives the broadcast too soon, …
Run Code Online (Sandbox Code Playgroud) 我想用他们的同行替换换行符和空格,以便在我的Android应用程序中正确设置样式.
我想知道这个正则表达式的最佳方法.我试图用以下内容替换新行<br />
:
string.replaceAll("@<code>.*\\n*</code>@si", "<br />");
Run Code Online (Sandbox Code Playgroud)
但它没有用.对于替换双倍空间,我无法想出任何东西.
所以这就是我想要实现的目标:
从\n
到<br />
,并从"双未编码的空间"  
.
鉴于以下内容:
class WebsitesController < ApplicationController
# POST /websites/save
# POST /websites/save.json
def save
Website.exists?(name: params[:website][:name]) ? update : create
end
# POST /websites
# POST /websites.json
def create
@server = Server.find_or_create_by_name(params[:server_id])
@website = @server.websites.new(params[:website])
#etc... @website.save
end
# PUT /websites/1
# PUT /websites/1.json
def update
@website = Website.find_by_name(params[:website][:name])
#etc... @website.update_attributes
end
end
Run Code Online (Sandbox Code Playgroud)
发送的请求只有names
,但不是ids
.
以及以下型号
class Website < ActiveRecord::Base
serialize :website_errors
attr_accessible :plugins_attributes
has_many :plugins
accepts_nested_attributes_for :plugins
end
class Plugin < ActiveRecord::Base
belongs_to :website
end
Run Code Online (Sandbox Code Playgroud)
当我发出 …
android ×6
java ×2
activerecord ×1
adb ×1
dalvik ×1
dependencies ×1
gradle ×1
hadoop ×1
jackson ×1
mapreduce ×1
nexus-7 ×1
regex ×1
service ×1
symfony ×1
symfony-2.0 ×1
symfony-2.1 ×1
transactions ×1