@Override public final void ll_setCharBufferValue(int fsRef, int featureCode, char[] buffer, int start, int length) { // don't do any index check here, done by inner call final int stringCode = this.getStringHeap().addCharBuffer(buffer, start, length); ll_setIntValue(fsRef, featureCode, stringCode); }
@Override public int ll_copyCharBufferValue(int fsRef, int featureCode, char[] buffer, int start) { final int stringCode = ll_getIntValue(fsRef, featureCode); if (stringCode == NULL) { return -1; } return this.getStringHeap().copyCharsToBuffer(stringCode, buffer, start); }
private final ArrayList<String> getStringList() { ArrayList<String> stringList = new ArrayList<String>(); stringList.add(null); int pos = this.getStringHeap().getLeastStringCode(); final int end = this.getStringHeap().getLargestStringCode(); while (pos <= end) { stringList.add(this.getStringHeap().getStringForCode(pos)); ++pos; } return stringList; }
public String getStringForCode(int stringCode) { return this.getStringHeap().getStringForCode(stringCode); }
String printCasInfo(CASImpl cas) { int heapsz= cas.getHeap().getNextId() * 4; StringHeapDeserializationHelper shdh = cas.getStringHeap().serialize(); int charssz = shdh.charHeap.length * 2; int strintsz = cas.getStringHeap().getSize() * 8; int strsz = charssz + strintsz; int fsindexessz = cas.getIndexedFSs().length * 4; int bytessz = cas.getByteHeap().getSize(); int shortsz = cas.getShortHeap().getSize() * 2; int longsz = cas.getLongHeap().getSize() * 8; int total = heapsz + strsz + fsindexessz + bytessz + shortsz + longsz; return String.format("CAS info before compression: totalSize(bytes): %,d%n" + " mainHeap: %,d(%d%%)%n" + " Strings: [%,d(%d%%): %,d chars %,d ints]%n" + " fsIndexes: %,d(%d%%)%n" + " byte/short/long Heaps: [%,d %,d %,d]", total, heapsz, (100L*heapsz)/total, strsz, (100L*strsz)/ total, charssz, strintsz, fsindexessz, (100L*fsindexessz) / total, bytessz, shortsz, longsz ); }
int addCharBuffer(char[] buffer, int start, int length) { String s = new String(buffer, start, length); return this.addString(s); }
int stringHeapEnd = stringHeapObj.getSize(); os.add(stringHeapObj.getStringForCode(i));
+ commonStringsLength * 2; final int stringHeapStart = isSerializingDelta ? mark.nextStringHeapAddr : 1; final int stringHeapEnd = stringHeapObj.getSize(); sm.statDetails[strLength_i].original = (stringHeapEnd - stringHeapStart) * 4; sm.statDetails[strOffset_i].original = (stringHeapEnd - stringHeapStart) * 4;
StringHeap() { super(); initMemory(); }
@Override public int ll_getCharBufferValueSize(int fsRef, int featureCode) { final int stringCode = ll_getIntValue(fsRef, featureCode); if (stringCode == NULL) { return -1; } return this.getStringHeap().getCharArrayLength(stringCode); }
void copyFeatures(int trgAddr, int srcAddr) throws CASRuntimeException { int typeCode = getHeapValue(trgAddr); if (typeCode != getHeapValue(srcAddr)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE); // What's that supposed to mean? Internationalized, my foot. // TODO: fix exception argument. // e.addArgument("Type of source and target feature structures do not // match"); throw (e); } // get features to copy int[] featcodes = getTypeSystem().getLowLevelTypeSystem().ll_getAppropriateFeatures(typeCode); for (int i = 0; i < featcodes.length; i++) { // get range type of this feature Feature feature = getTypeSystem().getLowLevelTypeSystem().ll_getFeatureForCode(featcodes[i]); Type rangeType = feature.getRange(); // get feature code int featCode = ((FeatureImpl) feature).getCode(); // get the value for this feature offset in src fs int val = getHeapValue(srcAddr + this.svd.casMetadata.featureOffset[featCode]); // if this is a string, create a new reference in the string // reference heap // and point to the same string as the string feature in src fs. setFeatureValueNotJournaled(trgAddr, featCode, isStringType(rangeType) ? this.getStringHeap().cloneStringReference(val) : getHeapValue(srcAddr + this.svd.casMetadata.featureOffset[featCode])); } }
@Override public final String ll_getStringValue(int fsRef, int featureCode) { return this.getStringHeap().getStringForCode(ll_getIntValue(fsRef, featureCode)); }
public String printCasInfo(CASImpl cas) { int heapsz= cas.getHeap().getNextId() * 4; StringHeapDeserializationHelper shdh = cas.getStringHeap().serialize(); int charssz = shdh.charHeap.length * 2; int strintsz = cas.getStringHeap().getSize() * 8; int strsz = charssz + strintsz; int fsindexessz = cas.getIndexedFSs().length * 4; int bytessz = cas.getByteHeap().getSize(); int shortsz = cas.getShortHeap().getSize() * 2; int longsz = cas.getLongHeap().getSize() * 8; int total = heapsz + strsz + fsindexessz + bytessz + shortsz + longsz; return String.format("CAS info before compression: totalSize(bytes): %,d%n" + " mainHeap: %,d(%d%%)%n" + " Strings: [%,d(%d%%): %,d chars %,d ints]%n" + " fsIndexes: %,d(%d%%)%n" + " byte/short/long Heaps: [%,d %,d %,d]", total, heapsz, (100L*heapsz)/total, strsz, (100L*strsz)/ total, charssz, strintsz, fsindexessz, (100L*fsindexessz) / total, bytessz, shortsz, longsz ); }
int addString(String s) { return this.getStringHeap().addString(s); }
this.getStringHeap().getSize(), this.getByteHeap().getSize(), this.getShortHeap().getSize(),
final void reset() { initMemory(); }
private StringBuilder dumpHeapStoredArray(CASImpl cas, final int iHeap) { StringBuilder sb = new StringBuilder(); int[] heap = cas.getHeap().heap; final int length = heap[iHeap + 1]; sb.append("Array Length: ").append(length).append('['); SlotKind arrayElementKind = typeInfo.slotKinds[1]; switch (arrayElementKind) { case Slot_HeapRef: case Slot_Int: case Slot_Short: case Slot_Byte: case Slot_Boolean: case Slot_Float: for (int i = iHeap + 2; i < iHeap + length + 2; i++) { if (i > iHeap + 2) { sb.append(", "); } sb.append(heap[i]); } break; case Slot_StrRef: StringHeap sh = cas.getStringHeap(); for (int i = iHeap + 2; i < iHeap + length + 2; i++) { if (i > iHeap + 2) { sb.append(", "); } sb.append(sh.getStringForCode(heap[i])); } break; default: throw new RuntimeException("internal error"); } sb.append("] "); return sb; }
public void setStringValue(int addr, int feat, String s) { final int stringCode = ((s == null) ? NULL : this.getStringHeap().addString(s)); setFeatureValue(addr, feat, stringCode); }
stringTableOffset = isReadingDelta ? (stringHeapObj.getSize() - 1) : 0;