use of org.hsqldb_voltpatches.rowio.RowInputText in project voltdb by VoltDB.
the class TextCache method findNextUsedLinePos.
// fredt - new method
/**
* Searches from file pointer, pos, and finds the beginning of the first
* line that contains any non-space character. Increments the row counter
* when a blank line is skipped.
*
* If none found return -1
*/
int findNextUsedLinePos(int pos) {
try {
int firstPos = pos;
int currentPos = pos;
boolean wasCR = false;
dataFile.seek(pos);
while (true) {
int c = dataFile.read();
currentPos++;
switch(c) {
case CR_CHAR:
wasCR = true;
break;
case LF_CHAR:
wasCR = false;
((RowInputText) rowIn).skippedLine();
firstPos = currentPos;
break;
case ' ':
if (wasCR) {
wasCR = false;
((RowInputText) rowIn).skippedLine();
}
break;
case -1:
return -1;
default:
return firstPos;
}
}
} catch (IOException e) {
throw new HsqlException(e.getMessage(), "", 0);
}
}
use of org.hsqldb_voltpatches.rowio.RowInputText in project voltdb by VoltDB.
the class TextCache method readObject.
protected synchronized RowInputInterface readObject(int pos) {
try {
ByteArray buffer = new ByteArray(80);
boolean complete = false;
boolean wasCR = false;
int c;
boolean hasQuote = false;
boolean wasNormal = false;
pos = findNextUsedLinePos(pos);
if (pos == -1) {
return null;
}
dataFile.seek(pos);
while (!complete) {
wasNormal = false;
c = dataFile.read();
if (c == -1) {
if (buffer.length() == 0) {
return null;
}
complete = true;
if (wasCR) {
break;
}
if (!cacheReadonly) {
dataFile.write(ScriptWriterText.BYTES_LINE_SEP, 0, ScriptWriterText.BYTES_LINE_SEP.length);
}
break;
}
switch(c) {
case DOUBLE_QUOTE_CHAR:
wasNormal = true;
complete = wasCR;
wasCR = false;
if (isQuoted) {
hasQuote = !hasQuote;
}
break;
case CR_CHAR:
wasCR = !hasQuote;
break;
case LF_CHAR:
complete = !hasQuote;
break;
default:
wasNormal = true;
complete = wasCR;
wasCR = false;
}
buffer.append(c);
}
if (complete) {
int length = (int) dataFile.getFilePointer() - pos;
if (wasNormal) {
length--;
}
((RowInputText) rowIn).setSource(buffer.toString(), pos, length);
return rowIn;
}
return null;
} catch (IOException e) {
throw new HsqlException(e.getMessage(), "", 0);
}
}
use of org.hsqldb_voltpatches.rowio.RowInputText in project voltdb by VoltDB.
the class TextCache method initBuffers.
protected void initBuffers() {
if (isQuoted || isAllQuoted) {
rowIn = new RowInputTextQuoted(fs, vs, lvs, isAllQuoted);
rowOut = new RowOutputTextQuoted(fs, vs, lvs, isAllQuoted, stringEncoding);
} else {
rowIn = new RowInputText(fs, vs, lvs, false);
rowOut = new RowOutputText(fs, vs, lvs, false, stringEncoding);
}
}
Aggregations