/** * Constructor for FSLeafIndexImpl. * @param cas - * @param type - * @param indexType - */ protected FSLeafIndexImpl(CASImpl cas, Type type, int indexType) { super(); this.indexType = indexType; this.lowLevelCAS = cas; this.type = type; this.typeCode = ((TypeImpl)type).getCode(); }
@Override public int ll_getCodeForType(Type type) { return ((TypeImpl) type).getCode(); }
public void addPartOf(Type type) { int code = ((TypeImpl) type).getCode(); addPartOf(code); }
public void removePartOf(Type type) { int code = ((TypeImpl) type).getCode(); removePartOf(code); }
private SerializedString getSerializedTypeName(TypeImpl ti) { XmlElementName xe = cds.typeCode2namespaceNames[ti.getCode()]; if (null == xe) { // happens for supertypes which have no instantiations String typeName = ti.getName(); xe = uimaTypeName2XmiElementName(typeName); checkForNameCollision(xe); cds.typeCode2namespaceNames[ti.getCode()] = xe; } return getSerializedString(xe.qName); }
/** * Remove all instances of a particular type (but not its subtypes) from all indexes * @param type - */ public void removeAllExcludingSubtypes(Type type) { final int typeCode = ((TypeImpl) type).getCode(); incrementIllegalIndexUpdateDetector(typeCode); // get a list of all indexes defined over this type // Includes indexes defined on supertypes of this type final ArrayList<IndexIteratorCachePair<? extends FeatureStructure>> allIndexesForType = this.indexArray[typeCode]; for (IndexIteratorCachePair<? extends FeatureStructure> iicp : allIndexesForType) { iicp.fsLeafIndex.flush(); } }
public int ll_createDocumentAnnotationNoIndex(int begin, int end) { final TypeSystemImpl ts = this.svd.casMetadata.ts; int fsRef = ll_createAnnotation(ts.docType.getCode(), begin, end); ll_setStringValue(fsRef, ts.langFeat.getCode(), CAS.DEFAULT_LANGUAGE_NAME); return fsRef; }
private void initCreatableTypeTable() { this.creatableType = new boolean[ts.getTypeArraySize()]; Arrays.fill(this.creatableType, true); int typeCode; for (int i = 0; i < nonCreatableTypes.length; i++) { typeCode = ((TypeImpl) ts.getType(nonCreatableTypes[i])).getCode(); for (int subType = ts.getSmallestType(); subType < this.creatableType.length; subType++) { if (ts.subsumes(typeCode, subType)) { this.creatableType[subType] = false; } } } }
private void encodeFeatureDecls(TypeSystemImpl ts) { final int max = ts.getSmallestFeature() + ts.getNumberOfFeatures(); this.featureNames = new String[max]; this.featDecls = new int[max * 3]; Feature f; for (int i = ts.getSmallestFeature(); i < max; i++) { f = ts.ll_getFeatureForCode(i); this.featureNames[i] = f.getShortName(); this.featDecls[i * 3] = ((TypeImpl) f.getDomain()).getCode(); this.featDecls[(i * 3) + 1] = ((TypeImpl) f.getRange()).getCode(); this.featDecls[(i * 3) + 2] = f.isMultipleReferencesAllowed() ? 1 : 0; } }
private void encodeTypeInheritance(TypeSystemImpl ts) { final int max = ts.getSmallestType() + ts.getNumberOfTypes(); this.typeInheritance = new int[max]; TypeImpl parent; // The smallest type is top, which doesn't inherit. for (int i = ts.getSmallestType() + 1; i < max; i++) { parent = (TypeImpl) ts.getParent(ts.ll_getTypeForCode(i)); this.typeInheritance[i] = parent.getCode(); } }
@Override public <T extends FeatureStructure> T createFS(Type type) { final int typeCode = ((TypeImpl) type).getCode(); if (!isCreatableType(typeCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.NON_CREATABLE_TYPE, new String[] { type.getName(), "CAS.createFS()" }); throw e; } return ll_getFSForRef(ll_createFSAnnotCheck(typeCode)); }
public void setBooleanValue(Feature feat, boolean b) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_BOOLEAN)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BOOLEAN)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, b); }
public void setLongValue(Feature feat, long val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_LONG)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_LONG)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setDoubleValue(Feature feat, double val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_DOUBLE)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_DOUBLE)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setShortValue(Feature feat, short val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_SHORT)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_SHORT)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setIntValue(Feature feat, int val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_INTEGER)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_INTEGER)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setFloatValue(Feature feat, float val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_FLOAT)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_FLOAT)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFloatValue(this.getAddress(), featCode, val); }
public void setByteValue(Feature feat, byte val) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_BYTE)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BYTE)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
private static void serializeResultSpecification(ResultSpecification rs, CASImpl cas, IntVector resultSpecTypes, IntVector resultSpecFeatures) { TypeOrFeature[] tofs = rs.getResultTypesAndFeatures(); TypeSystemImpl tsImpl = cas.getTypeSystemImpl(); for (int i = 0; i < tofs.length; ++i) { if (tofs[i].isType()) { TypeImpl t = (TypeImpl) tsImpl.getType(tofs[i].getName()); resultSpecTypes.add(t.getCode()); } else { FeatureImpl f = (FeatureImpl) tsImpl.getFeatureByFullName(tofs[i].getName()); resultSpecFeatures.add(f.getCode()); } } }