小编tol*_*gap的帖子

不推荐使用Hadoop DistributedCache - 首选API是什么?

我的地图任务需要一些配置数据,我想通过分布式缓存分发.

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的最新示例或教程?

java hadoop mapreduce

35
推荐指数
3
解决办法
3万
查看次数

JMSSerializerBundle.无法控制第三方元数据

我有两个实体,我想用JMSSerializerBundle序列化.该Music实体的映射文件用exclusion_policy: NONE.

Music实体拥有实体的领域UserFOSUserBundle.该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

25
推荐指数
1
解决办法
1万
查看次数

Gradle构建后,Android Studio无法找到库类

我正在尝试将一个.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不行,或者我应该以其他方式构建它?

dependencies android gradle android-studio

20
推荐指数
4
解决办法
4万
查看次数

Android 4.2.2 adb无法找到设备

随着我对Galaxy Nexus和Nexus 7的4.2.2的新更新,我找不到我的设备adb.

这些是我采取的步骤:

  • 已更新至4.2.2
  • 通过SDK Manager更新了ADT和SDK
  • 检查ADB版本,它是1.0.31
  • 多次重启PC和平板电脑和手机

当我跑步时adb devices,它只是空白.我在Windows 8和Ubuntu 12.10上遇到了同样的问题,但在Ubuntu上它显示了我的设备,它说offline.

我还有其他步骤吗?

android adb nexus-7

19
推荐指数
3
解决办法
7万
查看次数

VFY:无法解析虚方法

我在我的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,但它们都是:

  • 库错误的版本(我的是正确的)
  • 库不在/ libs中但在/ lib中(我将它们放在/ libs中)

我的Android版本是4.0.3.我正在将它与Spring Android库结合使用.

android dalvik jackson

14
推荐指数
2
解决办法
3万
查看次数

在我的布局文件中使用CardView和RecyclerView会引发异常

所以我一直在拍摄Android Preview L的Material Design.我导入了这两个CardViewRecyclerView库.

我使用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

12
推荐指数
2
解决办法
2万
查看次数

无法销毁活动(服务未注册)

*编写解决方法:* 我已经通过改变我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 android android-activity

9
推荐指数
2
解决办法
1万
查看次数

等待操作,直到创建Fragment的视图

我正在编写音乐播放器,音乐在后台播放Service.当用户关闭Activity它承载3 Fragments,然后重新启动Activity一次,我送一个BroadcastService包含有关当前播放歌曲的信息,以及用户添加到其会话歌曲列表.

问题是,每当我想要将最后的信息设置为Fragments没有发生任何事情,因为他们的创建花费的时间太长,并且Broadcast不会像他们应该那样处理.

我怎样才能让片段创建ServiceBroadcast等待,以便妥善处理?

以下是相关的代码段:

//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 transactions android-service android-fragments

9
推荐指数
2
解决办法
1万
查看次数

将换行符替换为<br/>和空格用&emsp; 在<code>标签内

我想用他们的同行替换换行符和空格,以便在我的Android应用程序中正确设置样式.

我想知道这个正则表达式的最佳方法.我试图用以下内容替换新行<br />:

string.replaceAll("@<code>.*\\n*</code>@si", "<br />");
Run Code Online (Sandbox Code Playgroud)

但它没有用.对于替换双倍空间,我无法想出任何东西.

所以这就是我想要实现的目标:

\n<br />,并从"双未编码的空间" &emsp;.

java regex

7
推荐指数
1
解决办法
8803
查看次数

Rails accepted_nested_attributes_for始终创建嵌套模型,但不更新它们

鉴于以下内容:

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)

客户端没有这些模型的任何ID

发送的请求只有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)

当我发出 …

activerecord ruby-on-rails ruby-on-rails-3

7
推荐指数
1
解决办法
806
查看次数