当前位置: 首页>>代码示例>>Java>>正文


Java PersistentVector类代码示例

本文整理汇总了Java中clojure.lang.PersistentVector的典型用法代码示例。如果您正苦于以下问题:Java PersistentVector类的具体用法?Java PersistentVector怎么用?Java PersistentVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PersistentVector类属于clojure.lang包,在下文中一共展示了PersistentVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMetadata

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Override
public Object getMetadata() {
  /*
   * Convert obtained Set into a List for 2 reasons:
   *  (1) Ensure returned object is serializable as required by storm's serialization
   *      of the SupervisorInfo while heartbeating.
   *      Previous to this change we were returning a ConcurrentHashMap$KeySetView,
   *      which is not necessarily serializable:
   *         http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4756277
   *  (2) Ensure we properly instantiate the PersistentVector with all ports.
   *      If given a Set the PersistentVector.create() method will simply wrap the passed
   *      Set as a single element in the new vector. Whereas if you pass a java.util.List
   *      or clojure.lang.ISeq, then you get a true vector composed of the elements of the
   *      List or ISeq you passed.
   */
  List ports = new ArrayList(_taskAssignments.getAssignedPorts());
  if (ports == null) {
    return null;
  }
  return PersistentVector.create(ports);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:MesosSupervisor.java

示例2: configure

import clojure.lang.PersistentVector; //导入依赖的package包/类
protected void configure(Map<String, Object> conf) {

        trackPath = ConfUtils.getBoolean(conf, trackPathParamName, true);

        trackDepth = ConfUtils.getBoolean(conf, trackDepthParamName, true);

        Object obj = conf.get(metadataTransferParamName);
        if (obj == null)
            return;

        if (obj instanceof PersistentVector) {
            mdToKeep.addAll((PersistentVector) obj);
        }
        // single value?
        else {
            mdToKeep.add(obj.toString());
        }
    }
 
开发者ID:zaizi,项目名称:alfresco-apache-storm-demo,代码行数:19,代码来源:MetadataTransfer.java

示例3: testFilterMetadata

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Test
public void testFilterMetadata() throws Exception {
    Map config = new HashMap();
    config.put(AbstractIndexerBolt.urlFieldParamName, "url");

    final PersistentVector vector = PersistentVector.create(
            "parse.title=title", "parse.keywords=keywords");

    config.put(AbstractIndexerBolt.metadata2fieldParamName, vector);

    prepareIndexerBolt(config);

    Metadata metadata = new Metadata();
    metadata.setValue("parse.title", "This is the title");
    metadata.setValue("parse.keywords", "keyword1, keyword2, keyword3");
    metadata.setValue("parse.description", "This is the description");

    index(URL, metadata);
    Map<String, String> fields = ((DummyIndexer) bolt).returnFields();

    Assert.assertArrayEquals(
            "Only the mapped metadata attributes should be indexed",
            new String[] { "keywords", "title", "url" }, new TreeSet<>(
                    fields.keySet()).toArray());
}
 
开发者ID:DigitalPebble,项目名称:storm-crawler,代码行数:26,代码来源:BasicIndexingTest.java

示例4: done

import clojure.lang.PersistentVector; //导入依赖的package包/类
public IList  done(){
	if (constructedList == null) {
		ITransientCollection ret = PersistentVector.EMPTY.asTransient();
		for(Object item : data)
			ret = ret.conj(item);
		
		IPersistentVector persistentData = (IPersistentVector) ret.persistent();

		constructedList = new Vector(elementType, persistentData);
	}
	
	return constructedList;
}
 
开发者ID:msteindorfer,项目名称:oopsla15-artifact,代码行数:14,代码来源:FastListWriter.java

示例5: insert

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Override
public IList insert(IValue newItem) {
	ITransientVector result = PersistentVector.EMPTY.asTransient();
	result = (ITransientVector) result.conj(newItem);
	for(Object item : (Iterable<?>) xs)
		result = (ITransientVector) result.conj(item);
	
	return new Vector(this.lub(newItem), (IPersistentVector) result.persistent());
}
 
开发者ID:msteindorfer,项目名称:oopsla15-artifact,代码行数:10,代码来源:Vector.java

示例6: delete

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Override
public IList delete(IValue x) {
	ITransientVector result = PersistentVector.EMPTY.asTransient();
	
	boolean skipped = false;
	for(Object item : (Iterable<?>) xs) {
		if (!skipped && item.equals(x)) {
			skipped = true;
		} else {
			result = (ITransientVector) result.conj(item);
		}
	}
			
	return new Vector(getElementType(), (IPersistentVector) result.persistent());
}
 
开发者ID:msteindorfer,项目名称:oopsla15-artifact,代码行数:16,代码来源:Vector.java

示例7: select

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Override
public IValue select(int... fields) throws IndexOutOfBoundsException {
	Type resultType = getType().select(fields);
	
	if (resultType.isTuple()) {
    	ITransientVector resultVector = PersistentVector.EMPTY.asTransient();
    	for (int i : fields) {
    		resultVector = (ITransientVector) resultVector.conj(xs.nth(i));
    	}
    	
    	return new Tuple(resultType, (IPersistentVector) resultVector.persistent());
    } else {
    	return get(fields[0]);
    } 
}
 
开发者ID:msteindorfer,项目名称:oopsla15-artifact,代码行数:16,代码来源:Tuple.java

示例8: clojure

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Benchmark
public Object clojure(ClojureState clojureState, DataState dataState) {
  if (clojureState.vector == null) {
    clojureState.vector = PersistentVector.create(dataState.data);
  }
  return clojureState.run.invoke(clojureState.vector);
}
 
开发者ID:golo-lang,项目名称:golo-jmh-benchmarks,代码行数:8,代码来源:FilterMapReduceMicroBenchmark.java

示例9: monomorphic_clojure

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Benchmark
public Object monomorphic_clojure(ClojureState clojureState, MonomorphicState monomorphicState) {
  if (clojureState.vector == null) {
    clojureState.vector = PersistentVector.create(monomorphicState.data);
  }
  return clojureState.dispatcher.invoke(clojureState.vector);
}
 
开发者ID:golo-lang,项目名称:golo-jmh-benchmarks,代码行数:8,代码来源:MethodDispatchMicroBenchmark.java

示例10: trimorphic_clojure

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Benchmark
public Object trimorphic_clojure(ClojureState clojureState, TriMorphicState triMorphicState) {
  if (clojureState.vector == null) {
    clojureState.vector = PersistentVector.create(triMorphicState.data);
  }
  return clojureState.dispatcher.invoke(clojureState.vector);
}
 
开发者ID:golo-lang,项目名称:golo-jmh-benchmarks,代码行数:8,代码来源:MethodDispatchMicroBenchmark.java

示例11: polymorphic_clojure

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Benchmark
public Object polymorphic_clojure(ClojureState clojureState, PolyMorphicState polyMorphicState) {
  if (clojureState.vector == null) {
    clojureState.vector = PersistentVector.create(polyMorphicState.data);
  }
  return clojureState.dispatcher.invoke(clojureState.vector);
}
 
开发者ID:golo-lang,项目名称:golo-jmh-benchmarks,代码行数:8,代码来源:MethodDispatchMicroBenchmark.java

示例12: wrapping

import clojure.lang.PersistentVector; //导入依赖的package包/类
@Test
public void wrapping() throws Exception {
    PersistentHashSet persistentHashSet = PersistentHashSet.create();
    PersistentVector persistentVector = PersistentVector.create();
    PersistentArrayMap persistentArrayMap = PersistentArrayMap.EMPTY;

    ClojureSet clojureSet = intoClojureSet(persistentHashSet);
    ClojureList clojureList = intoClojureList(persistentVector);
    ClojureMap clojureMap = intoClojureMap(persistentArrayMap);

    Field setDelegate = ClojureSet.class.getDeclaredField("delegate");
    Field listDelegate = ClojureList.class.getDeclaredField("delegate");
    Field mapDelegate = ClojureMap.class.getDeclaredField("delegate");

    setDelegate.setAccessible(true);
    listDelegate.setAccessible(true);
    mapDelegate.setAccessible(true);

    assertSame(setDelegate.get(clojureSet), persistentHashSet);
    assertSame(listDelegate.get(clojureList), persistentVector);
    assertSame(mapDelegate.get(clojureMap), persistentArrayMap);
}
 
开发者ID:rschmitt,项目名称:collider,代码行数:23,代码来源:FactoryMethodTest.java

示例13: prepare

import clojure.lang.PersistentVector; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void prepare(Map conf, TopologyContext context,
        OutputCollector collector) {

    String mdF = ConfUtils.getString(conf, metadataFilterParamName);
    if (StringUtils.isNotBlank(mdF)) {
        // split it in key value
        int equals = mdF.indexOf("=");
        if (equals != -1) {
            String key = mdF.substring(0, equals);
            String value = mdF.substring(equals + 1);
            filterKeyValue = new String[] { key.trim(), value.trim() };
        }
    }

    fieldNameForText = ConfUtils.getString(conf, textFieldParamName);

    fieldNameForURL = ConfUtils.getString(conf, urlFieldParamName);

    Object obj = conf.get(metadata2fieldParamName);
    if (obj != null) {
        // list?
        if (obj instanceof PersistentVector) {
            Iterator iter = ((PersistentVector) obj).iterator();
            while (iter.hasNext()) {
                addToMedataMapping(iter.next().toString());
            }
        }
        // single value?
        else {
            addToMedataMapping(obj.toString());
        }
    }
}
 
开发者ID:zaizi,项目名称:alfresco-apache-storm-demo,代码行数:36,代码来源:AbstractIndexerBolt.java

示例14: TaskAssignment

import clojure.lang.PersistentVector; //导入依赖的package包/类
/**
 * Creates a new executor id.
 * 
 * @param object the object representing the executor
 * @param taskComponents a taskId-component name mapping
 */
TaskAssignment(Object object, Map<Integer, String> taskComponents) {
    if (object instanceof MapEntry) {
        MapEntry me = (MapEntry) object;
        Object key = me.getKey();
        if (key instanceof PersistentVector) {
            PersistentVector executor = (PersistentVector) key;
            if (2 == executor.size()) {
                Object start = executor.get(0);
                Object end = executor.get(1);
                if (start instanceof Integer && end instanceof Integer) {
                    Integer tmpStart = (Integer) start;
                    this.taskStart = tmpStart;
                    this.taskEnd = (Integer) end;
                    this.component = taskComponents.get(tmpStart);
                }
            }
        }
        Object val = me.getValue();
        if (val instanceof PersistentVector) {
            PersistentVector hostPort = (PersistentVector) val;
            if (2 == hostPort.size()) {
                Object host = hostPort.get(0);
                Object port = hostPort.get(1);
                if (host instanceof String && port instanceof Integer) {
                    this.hostId = (String) host;
                    this.port = (Integer) port;
                }
            }
        }
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:38,代码来源:TaskAssignment.java

示例15: getExecutorId

import clojure.lang.PersistentVector; //导入依赖的package包/类
/**
 * Turns this executor id into a persistent vector for storing it in a Storm assignment.
 * 
 * @return the persistent vector
 */
private PersistentVector getExecutorId() {
    Object[] lst = new Object[2];
    lst[0] = taskStart;
    lst[1] = taskEnd;
    return PersistentVector.create(lst);
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:12,代码来源:TaskAssignment.java


注:本文中的clojure.lang.PersistentVector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。