项目:Reer
文件:AbstractStructSchema.java
public AbstractStructSchema(
ModelType<T> type,Iterable<ModelProperty<?>> properties,Iterable<WeaklyTypeReferencingMethod<?,?>> nonPropertyMethods,Iterable<ModelSchemaAspect> aspects
) {
super(type);
ImmutableSortedMap.Builder<String,ModelProperty<?>> builder = ImmutableSortedMap.naturalOrder();
for (ModelProperty<?> property : properties) {
builder.put(property.getName(),property);
}
this.properties = builder.build();
this.nonPropertyMethods = ImmutableSet.copyOf(nonPropertyMethods);
this.aspects = Maps.uniqueIndex(aspects,new Function<ModelSchemaAspect,Class<? extends ModelSchemaAspect>>() {
@Override
public Class<? extends ModelSchemaAspect> apply(ModelSchemaAspect aspect) {
return aspect.getClass();
}
});
}
private <T> ImmutableSortedMap<String,ManagedProperty<?>> collectManagedProperties(StructBindingExtractionContext<T> extractionContext,Map<String,Multimap<PropertyAccessorType,StructMethodBinding>> propertyBindings) {
ImmutableSortedMap.Builder<String,ManagedProperty<?>> managedPropertiesBuilder = ImmutableSortedMap.naturalOrder();
for (Map.Entry<String,StructMethodBinding>> propertyEntry : propertyBindings.entrySet()) {
String propertyName = propertyEntry.getKey();
Multimap<PropertyAccessorType,StructMethodBinding> accessorBindings = propertyEntry.getValue();
if (isManagedProperty(extractionContext,propertyName,accessorBindings)) {
if (hasSetter(accessorBindings.keySet()) && !hasGetter(accessorBindings.keySet())) {
extractionContext.add(propertyName,"it must both have an abstract getter and a setter");
continue;
}
ModelType<?> propertyType = determineManagedPropertyType(extractionContext,accessorBindings);
ModelSchema<?> propertySchema = schemaStore.getSchema(propertyType);
managedPropertiesBuilder.put(propertyName,createManagedProperty(extractionContext,propertySchema,accessorBindings));
}
}
return managedPropertiesBuilder.build();
}
项目:Reer
文件:DefaultStructBindings.java
protected DefaultStructBindings(
StructSchema<T> publicSchema,Iterable<? extends StructSchema<?>> declaredViewSchemas,Iterable<? extends StructSchema<?>> implementedViewSchemas,@Nullable StructSchema<?> delegateSchema,ManagedProperty<?>> managedProperties,Iterable<StructMethodBinding> methodBindings
) {
this.publicSchema = publicSchema;
this.declaredViewSchemas = ImmutableSet.copyOf(declaredViewSchemas);
this.implementedViewSchemas = ImmutableSet.copyOf(implementedViewSchemas);
this.delegateSchema = delegateSchema;
this.managedProperties = ImmutableSortedMap.copyOf(managedProperties,Ordering.natural());
this.methodBindings = ImmutableList.copyOf(methodBindings);
}
项目:GitHub
文件:LongBits.java
LongPositions(Iterable<? extends Object> elements,final int bitPerLong) {
this.elements = ImmutableList.copyOf(elements);
checkArgument(bitPerLong <= BITS_IN_LONG,bitPerLong);
for (int i = 0; i < this.elements.size(); i++) {
positions.put(
this.elements.get(i),new BitPosition(
i / bitPerLong,i % bitPerLong));
}
this.longPositions = ImmutableSortedMap.copyOf(
Maps.transformEntries(
Multimaps.index(positions.values(),ToLongIndex.FUNCTION).asMap(),new Maps.EntryTransformer<Integer,Collection<BitPosition>,LongSet>() {
@Override
public LongSet transformEntry(Integer key,Collection<BitPosition> position) {
return new LongSet(key,position);
}
}));
}
@Inject
scoreKBPAgainstERE(
final Parameters params,final Map<String,ScoringEventObserver<DocLevelEventArg,DocLevelEventArg>> scoringEventObservers,final ResponsesAndLinkingFromEREExtractor responsesAndLinkingFromEREExtractor,ResponsesAndLinkingFromKBPExtractorFactory responsesAndLinkingFromKBPExtractorFactory,@DocIDsToscoreP Set<Symbol> docIdsToscore,@KeyFileMapP Map<Symbol,File> keyFilesMap,Predicate<DocLevelEventArg> inScopePredicate,@PermitMissingSystemDocsP boolean permitMissingSystemDocuments) {
this.params = checkNotNull(params);
// we use a sorted map because the binding of plugins may be non-deterministic
this.scoringEventObservers = ImmutableSortedMap.copyOf(scoringEventObservers);
this.responsesAndLinkingFromEREExtractor = checkNotNull(responsesAndLinkingFromEREExtractor);
this.responsesAndLinkingFromKBPExtractorFactory = responsesAndLinkingFromKBPExtractorFactory;
this.docIDsToscore = ImmutableSet.copyOf(docIdsToscore);
this.goldDocIDToFileMap = ImmutableMap.copyOf(keyFilesMap);
this.inScopePredicate = inScopePredicate;
this.permitMissingSystemDocuments = permitMissingSystemDocuments;
}
public ThriftStructMetadata(
String structName,String> idlAnnotations,Type structType,Type builderType,MetadataType MetadataType,Optional<ThriftMethodInjection> builderMethod,List<String> documentation,List<ThriftFieldMetadata> fields,Optional<ThriftConstructorInjection> constructorInjection,List<ThriftMethodInjection> methodInjections)
{
this.builderType = builderType;
this.builderMethod = requireNonNull(builderMethod,"builderMethod is null");
this.structName = requireNonNull(structName,"structName is null");
this.idlAnnotations = requireNonNull(idlAnnotations,"idlAnnotations is null");
this.MetadataType = requireNonNull(MetadataType,"MetadataType is null");
this.structType = requireNonNull(structType,"structType is null");
this.constructorInjection = requireNonNull(constructorInjection,"constructorInjection is null");
this.documentation = ImmutableList.copyOf(requireNonNull(documentation,"documentation is null"));
this.fields = ImmutableSortedMap.copyOf(uniqueIndex(requireNonNull(fields,"fields is null"),ThriftFieldMetadata::getId));
this.methodInjections = ImmutableList.copyOf(requireNonNull(methodInjections,"methodInjections is null"));
}
项目:boqa
文件:UberphenoOboParserTest.java
@Test
public void testParseUberphenoHead() throws IOException {
final UberphenoOboParser parser = new UberphenoOboParser(uberphenoHeadFile,true);
final UberphenoOntology ontology = parser.parse();
assertEquals(
"ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]=ImmutabLevertexEdgeList [inEdges=[],outEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001],dest=ImmutableTermId [prefix=ImmutableTermPrefix [value=UBERPHENO],id=00000001],id=2]]],ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=0000001]=ImmutabLevertexEdgeList [inEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=0001186],dest=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=4]],outEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=1]]],id=0001186]=ImmutabLevertexEdgeList [inEdges=[],id=4]]],ImmutableTermId [prefix=ImmutableTermPrefix [value=UBERPHENO],id=00000001]=ImmutabLevertexEdgeList [inEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=2],ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=1],ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=ZP],id=3]],outEdges=[]],ImmutableTermId [prefix=ImmutableTermPrefix [value=ZP],outEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=ZP],id=3]]]},edgeCount=4]",ontology.getGraph().toString());
assertEquals(
"[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]]",ImmutableSortedSet.copyOf(ontology.getAllTermIds()).toString());
assertEquals(
"{ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]=UberphenoTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],altTermIds=[],name=All,deFinition=null,comment=null,subsets=[],synonyms=[],obsolete=false,createdBy=null,creationDate=null],id=0000001]=UberphenoTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],name=mammalian phenotype,id=0001186]=UberphenoTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],name=pigmentation phenotype,id=00000001]=UberphenoTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=UBERPHENO],name=UBERPHENO_ROOT,id=0000001]=UberphenoTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=ZP],name=abnormal(ly) quality zebrafish anatomical entity,creationDate=null]}",ImmutableSortedMap.copyOf(ontology.getTermMap()).toString());
assertEquals(
"{1=UberphenoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=1,relationQualifier=IS_A],2=UberphenoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=2,3=UberphenoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=ZP],id=3,4=UberphenoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=MP],id=4,relationQualifier=IS_A]}",ImmutableSortedMap.copyOf(ontology.getRelationMap()).toString());
assertEquals("ImmutableTermId [prefix=ImmutableTermPrefix [value=UBERPHENO],id=00000001]",ontology.getRoottermId().toString());
assertEquals("{date=20:01:2012 06:00}",ontology.getMetaInfo().toString());
}
项目:ontolib
文件:ImmutableOntology.java
/**
* Constructor.
*
* @param MetaInfo {@link ImmutableMap} with Meta @R_63_4045@ion.
* @param graph Graph to use for underlying structure.
* @param roottermId Root node's {@link TermId}.
* @param nonObsoleteTermIds {@link Collection} of {@link TermId}s of non-obsolete terms.
* @param obsoleteTermIds {@link Collection} of {@link TermId}s of obsolete terms.
* @param termMap Mapping from {@link TermId} to <code>T</code>.
* @param relationMap Mapping from numeric edge Id to <code>R</code>.
*/
public ImmutableOntology(ImmutableSortedMap<String,String> MetaInfo,ImmutableDirectedGraph<TermId,ImmutableEdge<TermId>> graph,TermId roottermId,Collection<? extends TermId> nonObsoleteTermIds,Collection<? extends TermId> obsoleteTermIds,ImmutableMap<TermId,T> termMap,ImmutableMap<Integer,R> relationMap) {
this.MetaInfo = MetaInfo;
this.graph = graph;
this.roottermId = roottermId;
this.termMap = termMap;
this.nonObsoleteTermIds = ImmutableSet.copyOf(nonObsoleteTermIds);
this.obsoleteTermIds = ImmutableSet.copyOf(obsoleteTermIds);
this.allTermIds =
ImmutableSet.copyOf(Sets.union(this.nonObsoleteTermIds,this.obsoleteTermIds));
this.relationMap = relationMap;
this.precomputedAncestors = precomputeAncestors();
}
项目:abhot
文件:CassandraDatastore.java
private WriteBufferStats createWriteBufferStats(final String cfName,final String hostname) {
return new WriteBufferStats()
{
private ImmutableSortedMap<String,String> m_tags =
ImmutableSortedMap.<String,String>naturalOrder()
.put("host",hostname)
.put("buffer",cfName)
.build();
@Override
public void saveWriteSize(int pendingWrites)
{
putInternalDataPoint("kairosdb.datastore.write_size",m_tags,m_longDataPointFactory.createDataPoint(System.currentTimeMillis(),pendingWrites));
}
};
}
项目:ontolib
文件:GoOboParser.java
/**
* Parse OBO file into {@link HpoOntology} object.
*
* @return {@link HpoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
public GoOntology parse() throws IOException {
final OboImmutableOntologyLoader<GoTerm,GoTermRelation> loader =
new OboImmutableOntologyLoader<>(oboFile,debug);
final GoOboFactory factory = new GoOboFactory();
final ImmutableOntology<GoTerm,GoTermRelation> o = loader.load(factory);
// Convert ImmutableOntology into GoOntology. The casts here are ugly and require the
// @SuppressWarnings above but this saves us one factory layer of indirection.
return new GoOntology((ImmutableSortedMap<String,String>) o.getMetaInfo(),(ImmutableDirectedGraph<TermId,ImmutableEdge<TermId>>) o.getGraph(),o.getRoottermId(),o.getNonObsoleteTermIds(),o.getobsoleteTermIds(),(ImmutableMap<TermId,GoTerm>) o.getTermMap(),(ImmutableMap<Integer,GoTermRelation>) o.getRelationMap());
}
项目:ontolib
文件:MpoOboParser.java
/**
* Parse OBO file into {@link MpoOntology} object.
*
* @return {@link MpoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
public MpoOntology parse() throws IOException {
final OboImmutableOntologyLoader<MpoTerm,MpoTermRelation> loader =
new OboImmutableOntologyLoader<>(oboFile,debug);
final MpoOboFactory factory = new MpoOboFactory();
final ImmutableOntology<MpoTerm,MpoTermRelation> o = loader.load(factory);
// Convert ImmutableOntology into Mpontology. The casts here are ugly and require the
// @SuppressWarnings above but this saves us one factory layer of indirection.
return new MpoOntology((ImmutableSortedMap<String,MpoTerm>) o.getTermMap(),MpoTermRelation>) o.getRelationMap());
}
项目:ontolib
文件:UberphenoOboParser.java
/**
* Parse OBO file into {@link UberphenoOntology} object.
*
* @return {@link UberphenoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
@Override
public UberphenoOntology parse() throws IOException {
final OboImmutableOntologyLoader<UberphenoTerm,UberphenoTermRelation> loader =
new OboImmutableOntologyLoader<>(oboFile,debug);
final UberphenoOboFactory factory = new UberphenoOboFactory();
final ImmutableOntology<UberphenoTerm,UberphenoTermRelation> o = loader.load(factory);
// Convert ImmutableOntology into Uberphenontology. The casts here are ugly and require the
// @SuppressWarnings above but this saves us one factory layer of indirection.
return new UberphenoOntology((ImmutableSortedMap<String,UberphenoTerm>) o.getTermMap(),UberphenoTermRelation>) o.getRelationMap());
}
项目:ontolib
文件:GoOboParserTest.java
@Test
public void testParseHpoHead() throws IOException {
final GoOboParser parser = new GoOboParser(goHeadFile,true);
final GoOntology ontology = parser.parse();
assertEquals(
"ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0000000]=ImmutabLevertexEdgeList [inEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0003674],dest=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0000000],ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0005575],id=0008150],ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0003674]=ImmutabLevertexEdgeList [inEdges=[],outEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0005575]=ImmutabLevertexEdgeList [inEdges=[],id=0008150]=ImmutabLevertexEdgeList [inEdges=[],edgeCount=3]",ontology.getGraph().toString());
assertEquals(
"[ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0000004],id=0005554],id=0007582],id=0008372]]",ImmutableSortedSet.copyOf(ontology.getAllTermIds()).toString());
assertthat(ImmutableSortedMap.copyOf(ontology.getTermMap()).toString(),startsWith("{ImmutableTermId"));
assertthat(ImmutableSortedMap.copyOf(ontology.getTermMap()).toString(),endsWith("description=null,trailingModifiers=null]]]}"));
assertEquals(
"{1=GoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],2=GoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],3=GoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],ImmutableSortedMap.copyOf(ontology.getRelationMap()).toString());
assertEquals("ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],id=0000000]",ontology.getRoottermId().toString());
assertEquals(
"{data-version=releases/2017-06-16,remark=Includes Ontology(OntologyID(OntologyIRI(<http://purl.obolibrary.org/obo/go/never_in_taxon.owl>))) [Axioms: 18 Logical Axioms: 0]}",ontology.getMetaInfo().toString());
}
项目:ontolib
文件:HpoOboParserTest.java
@Test
public void testParseHpoHead() throws IOException {
final HpoOboParser parser = new HpoOboParser(hpoHeadFile,true);
final HpoOntology ontology = parser.parse();
assertEquals(
"ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]=ImmutabLevertexEdgeList [inEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000005],dest=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000118],ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000005]=ImmutabLevertexEdgeList [inEdges=[ImmutableEdge [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000006],id=0000007],id=0000006]=ImmutabLevertexEdgeList [inEdges=[],id=0000007]=ImmutabLevertexEdgeList [inEdges=[],id=3]]],id=0000118]=ImmutabLevertexEdgeList [inEdges=[],id=4]]]},id=0001415],id=0001416],id=0001447],id=0001448],id=0001451],id=0001453],id=0001455],id=0001456],id=0001461],id=0001463],id=0001526]]",id=0000001]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],comment=Root of all terms in the Human Phenotype Ontology.,creationDate=null,xrefs=[ImmutableDbxref [name=UMLS:C0444868,description=null,trailingModifiers=null]]],id=0000005]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],altTermIds=[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001461]],name=Mode of inheritance,deFinition=The pattern in which a particular genetic trait or disorder is passed from one generation to the next.,synonyms=[ImmutableTermSynonym [value=Inheritance,scope=EXACT,synonymTypeName=null,termXrefs=[]]],xrefs=[ImmutableDbxref [name=UMLS:C1708511,id=0000006]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001463]],name=Autosomal dominant inheritance,deFinition=A mode of inheritance that is observed for traits related to a gene encoded on one of the autosomes (i.e.,the human chromosomes 1-22) in which a trait manifests in heterozygotes. In the context of medical genetics,an autosomal dominant disorder is caused when a single copy of the mutant allele is present. Males and females are affected equally,and can both transmit the disorder with a risk of 50% for each child of inheriting the mutant allele.,synonyms=[ImmutableTermSynonym [value=Autosomal dominant,termXrefs=[]],ImmutableTermSynonym [value=Autosomal dominant form,scope=RELATED,termXrefs=[ImmutableTermXref [id=null,description=null]]],ImmutableTermSynonym [value=Autosomal dominant type,description=null]]]],xrefs=[ImmutableDbxref [name=SNOMEDCT_US:263681008,trailingModifiers=null],ImmutableDbxref [name=UMLS:C0443147,id=0000007]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001526]],name=Autosomal recessive inheritance,the human chromosomes 1-22) in which a trait manifests in homozygotes. In the context of medical genetics,autosomal recessive disorders manifest in homozygotes (with two copies of the mutant allele) or compound heterozygotes (whereby each copy of a gene has a distinct mutant allele).,synonyms=[ImmutableTermSynonym [value=Autosomal recessive,ImmutableTermSynonym [value=Autosomal recessive form,ImmutableTermSynonym [value=Autosomal recessive predisposition,xrefs=[ImmutableDbxref [name=SNOMEDCT_US:258211005,ImmutableDbxref [name=UMLS:C0441748,ImmutableDbxref [name=UMLS:C4020899,id=0000118]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],name=Phenotypic abnormality,deFinition=A phenotypic abnormality.,comment=This is the root of the phenotypic abnormality subontology of the HPO.,synonyms=[ImmutableTermSynonym [value=Organ abnormality,xrefs=[ImmutableDbxref [name=UMLS:C4021819,id=0001415]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001416]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001447]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001448]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001451]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001453]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001455]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001456]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001461]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001463]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0001526]=HPOTerm [id=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],trailingModifiers=null]]]}",ImmutableSortedMap.copyOf(ontology.getTermMap()).toString());
assertEquals(
"{1=HpoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],2=HpoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],3=HpoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],4=HpoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],ImmutableSortedMap.copyOf(ontology.getRelationMap()).toString());
assertEquals("ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]",ontology.getRoottermId().toString());
assertEquals(
"{data-version=releases/2017-04-13,saved-by=Peter Robinson,Sebastian Koehler,Sandra Doelken,Chris Mungall,Melissa Haendel,Nicole Vasilevsky,Monarch Initiative,et al.}",ontology.getMetaInfo().toString());
}
项目:abhot
文件:SaveAsAggregator.java
public SaveAsDataPointAggregator(DataPointGroup innerDataPointGroup)
{
m_innerDataPointGroup = innerDataPointGroup;
ImmutableSortedMap.Builder<String,String> mapBuilder = ImmutableSortedMap.<String,String>naturalOrder();
mapBuilder.putAll(m_tags);
if (m_addSavedFrom)
mapBuilder.put("saved_from",innerDataPointGroup.getName());
for (String innerTag : innerDataPointGroup.getTagNames())
{
Set<String> tagValues = innerDataPointGroup.getTagValues(innerTag);
if (m_tagsToKeep.contains(innerTag) && (tagValues.size() == 1))
mapBuilder.put(innerTag,tagValues.iterator().next());
}
m_groupTags = mapBuilder.build();
}
项目:sats-core
文件:MRVMRegionalBidderSetup.java
/**
* Determines the discount in value for distant regions
*/
public ImmutableSortedMap<Integer,BigDecimal> drawdistancediscounts(MRVMWorld world,MRVMRegionsMap.Region home,UniformdistributionRNG rng) {
ImmutableSortedMap.Builder<Integer,BigDecimal> distancediscount = ImmutableSortedMap.naturalOrder();
distancediscount.put(0,BigDecimal.ONE);
int maxdistance = world.getRegionsMap().getLongestShortestPath(home);
for (int i = 1; i <= maxdistance; i++) {
double exponent = exponentFactor * i * (-1);
double gamma = Math.pow(base,exponent);
Preconditions.checkState(gamma >= 0 && gamma <= 1,"Invalid Gamma,some of the calculation parameters have unallowed values");
BigDecimal roundedGamma = BigDecimal.valueOf(gamma).setScale(5,BigDecimal.ROUND_HALF_DOWN);
distancediscount.put(i,roundedGamma);
}
return distancediscount.build();
}
项目:sats-core
文件:MRVMNationalBidder.java
private static ImmutableSortedMap<Integer,BigDecimal> buildGammaMap(Map<Integer,BigDecimal> gammaInput) {
ImmutableSortedMap.Builder<Integer,BigDecimal> mapBuilder = ImmutableSortedMap.naturalOrder();
SortedMap<Integer,BigDecimal> sortedInput = new TreeMap<>(gammaInput);
Preconditions.checkArgument(sortedInput.firstKey() == 1,"Gamma Values must (exclusively) be specified for quantities 1 and (optionally) higher",sortedInput);
Preconditions.checkArgument(sortedInput.lastKey().equals(sortedInput.size()),""
+ "Gamma Values must be specified for all capacities in {0,...,k_{max}},where k_{max} > 0 is any natural number > 0",sortedInput);
for (Entry<Integer,BigDecimal> inputGammaEntry : sortedInput.entrySet()) {
Preconditions.checkArgument(inputGammaEntry.getValue().compareto(BigDecimal.ZERO) >= 0,"Gamma must not be negative",inputGammaEntry);
mapBuilder.put(inputGammaEntry);
}
return mapBuilder.build();
}
项目:sats-core
文件:ContinuousPiecewiseLinearFunction.java
/**
* Constructs a new PieceWiseLinear function with a restricted domain interval
* @param cornerPoints A map with <i>key = x-values</i> and <i> value = y-values</i>.
* The map has to include all corner points of the function,including lower and upper end of domain. <br>
*
*/
public ContinuousPiecewiseLinearFunction(Map<BigDecimal,BigDecimal> cornerPoints) {
// Sort the incoming corner points by their
SortedMap<BigDecimal,BigDecimal> sortedCornerPoints = new TreeMap<>(cornerPoints);
ImmutableSortedMap.Builder<BigDecimal,LinearFunction> linearFunctionsBuilder =
ImmutableSortedMap.naturalOrder();
Iterator<Entry<BigDecimal,BigDecimal>> entryIterator = sortedCornerPoints.entrySet().iterator();
Entry<BigDecimal,BigDecimal> lowerEntry = entryIterator.next();
lowestX = lowerEntry.getKey();
while (entryIterator.hasNext()) {
Entry<BigDecimal,BigDecimal> upperEntry = entryIterator.next();
if (lowerEntry.getKey().compareto(upperEntry.getKey()) == 0) {
// Skip linear function where the domain is empty
// Todo log this
} else {
LinearFunction linearFunction = new LinearFunction(lowerEntry.getKey(),lowerEntry.getValue(),upperEntry.getKey(),upperEntry.getValue());
linearFunctionsBuilder.put(upperEntry.getKey(),linearFunction);
lowerEntry = upperEntry;
}
}
linearFunctions = linearFunctionsBuilder.build();
}
项目:boqa
文件:ImmutableOntology.java
/**
* Constructor.
*
* @param MetaInfo {@link ImmutableMap} with Meta @R_63_4045@ion.
* @param graph Graph to use for underlying structure.
* @param roottermId Root node's {@link TermId}.
* @param nonObsoleteTermIds {@link Collection} of {@link TermId}s of non-obsolete terms.
* @param obsoleteTermIds {@link Collection} of {@link TermId}s of obsolete terms.
* @param termMap Mapping from {@link TermId} to <code>T</code>.
* @param relationMap Mapping from numeric edge Id to <code>R</code>.
*/
public ImmutableOntology(ImmutableSortedMap<String,this.obsoleteTermIds));
this.relationMap = relationMap;
this.precomputedAncestors = precomputeAncestors();
}
项目:boqa
文件:GoOboParser.java
/**
* Parse OBO file into {@link HpoOntology} object.
*
* @return {@link HpoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
public GoOntology parse() throws IOException {
final OboImmutableOntologyLoader<GoTerm,GoTermRelation>) o.getRelationMap());
}
项目:boqa
文件:HpoOboParser.java
/**
* Parse OBO file into {@link HpoOntology} object.
*
* @return {@link HpoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
public HpoOntology parse() throws IOException {
final OboImmutableOntologyLoader<HpoTerm,HpoTermRelation> loader =
new OboImmutableOntologyLoader<>(oboFile,debug);
final HpoOboFactory factory = new HpoOboFactory();
final ImmutableOntology<HpoTerm,HpoTermRelation> o = loader.load(factory);
// Convert ImmutableOntology into HPOntology. The casts here are ugly and require the
// @SuppressWarnings above but this saves us one factory layer of indirection.
return new HpoOntology((ImmutableSortedMap<String,HpoTerm>) o.getTermMap(),HpoTermRelation>) o.getRelationMap());
}
项目:boqa
文件:MpoOboParser.java
/**
* Parse OBO file into {@link MpoOntology} object.
*
* @return {@link MpoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
public MpoOntology parse() throws IOException {
final OboImmutableOntologyLoader<MpoTerm,MpoTermRelation>) o.getRelationMap());
}
项目:boqa
文件:UberphenoOboParser.java
/**
* Parse OBO file into {@link UberphenoOntology} object.
*
* @return {@link UberphenoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
@Override
public UberphenoOntology parse() throws IOException {
final OboImmutableOntologyLoader<UberphenoTerm,UberphenoTermRelation>) o.getRelationMap());
}
项目:boqa
文件:UphenoOboParser.java
/**
* Parse OBO file into {@link UphenoOntology} object.
*
* @return {@link UphenoOntology} from parsing OBO file.
* @throws IOException In case of problems with file I/O.
*/
@SuppressWarnings("unchecked")
public UphenoOntology parse() throws IOException {
final OboImmutableOntologyLoader<UphenoTerm,UphenoTermRelation> loader =
new OboImmutableOntologyLoader<>(oboFile,debug);
final UphenoOboFactory factory = new UphenoOboFactory();
final ImmutableOntology<UphenoTerm,UphenoTermRelation> o = loader.load(factory);
// Convert ImmutableOntology into UberphenoOntology. The casts here are ugly and require the
// @SuppressWarnings above but this saves us one factory layer of indirection.
return new UphenoOntology((ImmutableSortedMap<String,UphenoTerm>) o.getTermMap(),UphenoTermRelation>) o.getRelationMap());
}
项目:boqa
文件:GoOboParserTest.java
@Test
public void testParseHpoHead() throws IOException {
final GoOboParser parser = new GoOboParser(goHeadFile,endsWith("createdBy=null,creationDate=null]}"));
assertEquals(
"{1=GoTermRelation [source=ImmutableTermId [prefix=ImmutableTermPrefix [value=GO],ontology.getMetaInfo().toString());
}
项目:boqa
文件:HpoOboParserTest.java
@Test
public void testParseHpoHead() throws IOException {
final HpoOboParser parser = new HpoOboParser(hpoHeadFile,ontology.getMetaInfo().toString());
}
<T,D> StructBindings<T> extract(ModelType<T> publicType,Iterable<? extends ModelType<?>> internalViewTypes,ModelType<D> delegateType) {
if (delegateType != null && Modifier.isAbstract(delegateType.getConcreteClass().getModifiers())) {
throw new InvalidManagedTypeException(String.format("Type '%s' is not a valid managed type: delegate type must be null or a non-abstract type instead of '%s'.",publicType.getdisplayName(),delegateType.getdisplayName()));
}
Set<ModelType<?>> implementedViews = collectImplementedViews(publicType,internalViewTypes,delegateType);
StructSchema<T> publicSchema = getStructSchema(publicType);
Iterable<StructSchema<?>> declaredViewSchemas = getStructSchemas(Iterables.concat(Collections.singleton(publicType),internalViewTypes));
Iterable<StructSchema<?>> implementedSchemas = getStructSchemas(implementedViews);
StructSchema<D> delegateSchema = delegateType == null ? null : getStructSchema(delegateType);
StructBindingExtractionContext<T> extractionContext = new StructBindingExtractionContext<T>(publicSchema,implementedSchemas,delegateSchema);
if (!(publicSchema instanceof RuleSourceSchema)) {
validateTypeHierarchy(extractionContext,publicType);
for (ModelType<?> internalViewType : internalViewTypes) {
validateTypeHierarchy(extractionContext,internalViewType);
}
}
Map<String,StructMethodBinding>> propertyBindings = Maps.newTreeMap();
Set<StructMethodBinding> methodBindings = collectMethodBindings(extractionContext,propertyBindings);
ImmutableSortedMap<String,ManagedProperty<?>> managedProperties = collectManagedProperties(extractionContext,propertyBindings);
if (extractionContext.problems.hasProblems()) {
throw new InvalidManagedTypeException(extractionContext.problems.format());
}
return new DefaultStructBindings<T>(
publicSchema,declaredViewSchemas,delegateSchema,managedProperties,methodBindings
);
}
项目:Reer
文件:CacheBackedTaskHistoryRepository.java
@Override
public Map<String,FileCollectionSnapshot> getInputFilesSnapshot() {
if (inputFilesSnapshot == null) {
ImmutableSortedMap.Builder<String,FileCollectionSnapshot> builder = ImmutableSortedMap.naturalOrder();
for (Map.Entry<String,Long> entry : inputFilesSnapshotIds.entrySet()) {
builder.put(entry.getKey(),snapshotRepository.get(entry.getValue()));
}
inputFilesSnapshot = builder.build();
}
return inputFilesSnapshot;
}
项目:abhot
文件:RemoteDatastore.java
@Override
public void putDataPoint(String metricName,ImmutableSortedMap<String,String> tags,DataPoint dataPoint,int ttl) throws DatastoreException
{
DataPointKey key = new DataPointKey(metricName,tags,dataPoint.getApiDataType(),ttl);
if ((m_prefixFilter != null) && (!metricName.startsWith(m_prefixFilter)))
return;
synchronized (m_mapLock)
{
m_dataPointMultimap.put(key,dataPoint);
}
}
项目:Reer
文件:TaskExecutionSnapshot.java
public TaskExecutionSnapshot(String taskClass,ImmutableSet<String> cacheableOutputProperties,ImmutableSet<String> declaredOutputFilePaths,HashCode taskClassLoaderHash,HashCode taskActionsClassLoaderHash,Object> inputProperties,Long> inputFilesSnapshotIds,Long discoveredFilesSnapshotId,Long> outputFilesSnapshotIds) {
this.taskClass = taskClass;
this.cacheableOutputProperties = cacheableOutputProperties;
this.declaredOutputFilePaths = declaredOutputFilePaths;
this.taskClassLoaderHash = taskClassLoaderHash;
this.taskActionsClassLoaderHash = taskActionsClassLoaderHash;
this.inputProperties = inputProperties;
this.inputFilesSnapshotIds = inputFilesSnapshotIds;
this.discoveredFilesSnapshotId = discoveredFilesSnapshotId;
this.outputFilesSnapshotIds = outputFilesSnapshotIds;
}
项目:abhot
文件:BlastServer.java
@Override
public void run()
{
logger.info("Blast Server Running");
Stopwatch timer = Stopwatch.createStarted();
while (m_keepRunning)
{
long Now = System.currentTimeMillis();
DataPoint dataPoint = m_longDataPointFactory.createDataPoint(Now,42);
int row = RandomUtils.nextInt(0,m_numberOfRows);
ImmutableSortedMap<String,String> tags = ImmutableSortedMap.of("row",String.valueOf(row),"host","blast_server");
try
{
m_datastore.putDataPoint(m_metricName,dataPoint,m_ttl);
}
catch (DatastoreException e)
{
e.printstacktrace();
}
m_counter ++;
if ((m_counter % 100000 == 0) && (timer.elapsed(TimeUnit.SECONDS) > m_durration))
m_keepRunning = false;
}
}
项目:helper
文件:ImmutableCollectors.java
public static <T,K,V> Collector<T,?,ImmutableSortedMap<K,V>> toSortedMap(Comparator<? super K> comparator,Function<? super T,? extends K> keyMapper,? extends V> valueMapper) {
return Collector.of(
() -> new ImmutableSortedMap.Builder<K,V>(comparator),(builder,input) -> builder.put(keyMapper.apply(input),valueMapper.apply(input)),(l,r) -> l.putAll(r.build()),ImmutableSortedMap.Builder::build,Collector.characteristics.UnorDERED
);
}
项目:beadledom
文件:HealthChecker.java
项目:drift
文件:AbstractReflectionThriftCodec.java
protected AbstractReflectionThriftCodec(ThriftCodecManager manager,ThriftStructMetadata Metadata)
{
this.Metadata = Metadata;
ImmutableSortedMap.Builder<Short,ThriftCodec<?>> fields = ImmutableSortedMap.naturalOrder();
for (ThriftFieldMetadata fieldMetadata : Metadata.getFields(THRIFT_FIELD)) {
fields.put(fieldMetadata.getId(),manager.getCodec(fieldMetadata.getThriftType()));
}
this.fields = fields.build();
}
项目:ontolib
文件:TermAnnotationsTest.java
@Test
public void testConstructTermAnnotationToLabelsMap() {
Map<TermId,Collection<String>> map = ImmutableSortedMap
.copyOf(TermAnnotations.constructTermAnnotationToLabelsMap(ontology,annotations));
assertEquals(
"{ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]=[two,one],id=0000002]=[two,three,id=0000003]=[two,id=0000004]=[two,id=0000005]=[two,one]}",map.toString());
}
项目:ontolib
文件:TermAnnotationsTest.java
@Test
public void testConstructTermlabelToAnnotationsMap() {
Map<String,Collection<TermId>> map = ImmutableSortedMap
.copyOf(TermAnnotations.constructTermlabelToAnnotationsMap(ontology,annotations));
assertEquals(
"{one=[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000002],id=0000003],id=0000001]],three=[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000005]],two=[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP],id=0000001]]}",map.toString());
}
项目:abhot
文件:CassandraDatastore.java
private void putInternalDataPoint(String metricName,DataPoint dataPoint)
{
try
{
putDataPoint(metricName,0);
}
catch (DatastoreException e)
{
logger.error("",e);
}
}
@GwtIncompatible // SerializableTester
public void testViewSerialization() {
Map<String,Integer> map =
ImmutableSortedMap.of("one",1,"two",2,"three",3);
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(Lists.newArrayList(map.values()),Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
项目:abhot
文件:KairosDatastore.java
public void putDataPoint(String metricName,int ttl) throws DatastoreException
{
//Add to datastore first.
m_datastore.putDataPoint(metricName,ttl);
for (DataPointListener dataPointListener : m_dataPointListeners)
{
dataPointListener.dataPoint(metricName,dataPoint);
}
}
项目:guava-mock
文件:SortedMapGenerators.java
@Override
public SortedMap<String,String> create(Entry<String,String>[] entries) {
ImmutableSortedMap.Builder<String,String> builder = ImmutableSortedMap.naturalOrder();
for (Entry<String,String> entry : entries) {
checkNotNull(entry);
builder.put(entry.getKey(),entry.getValue());
}
return builder.build();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。