@Override public String toString() { StringBuilder sb = new StringBuilder("MaprDBJsonRecordReader[Table=") .append(table != null ? table.getPath() : null); if (reader != null) { sb.append(", Document ID=") .append(IdCodec.asString(reader.getId())); } sb.append(", reader=") .append(reader) .append(']'); return sb.toString(); } }
/** * Returns ids of rowKeys to be read. * Number of rowKey ids returned will be numRowKeysToRead at the most i.e. it * will be less than numRowKeysToRead if only that many exist in the currentBatch. */ @JsonIgnore public ByteBuffer[] getRowKeyIdsToRead(int numRowKeysToRead) { int numKeys = hasRowKeys(numRowKeysToRead); if (numKeys == 0) { return null; } int index = 0; final ByteBuffer[] rowKeyIds = new ByteBuffer[numKeys]; while (index < numKeys) { Object o = rowKeyVector.getAccessor().getObject(currentIndex + index); rowKeyIds[index++] = IdCodec.encode(o.toString()); } updateRowKeysRead(numKeys); return rowKeyIds; }
byte[] encodedKey = IdCodec.encodeAsBytes(key);
public void readToInitSchema() { DBDocumentReaderBase reader = null; vectorWriter.setPosition(0); try (DocumentStream dstream = table.find()) { reader = (DBDocumentReaderBase) dstream.iterator().next().asReader(); documentWriter.writeDBDocument(vectorWriter, reader); } catch(UserException e) { throw UserException.unsupportedError(e) .addContext(String.format("Table: %s, document id: '%s'", getTable().getPath(), reader == null ? null : IdCodec.asString(reader.getId()))) .build(logger); } catch (SchemaChangeException e) { if (getIgnoreSchemaChange()) { logger.warn("{}. Dropping the row from result.", e.getMessage()); logger.debug("Stack trace:", e); } else { throw dataReadError(logger, e); } } finally { vectorWriter.setPosition(0); } }
/** * Returns ids of rowKeys to be read. * Number of rowKey ids returned will be numRowKeysToRead at the most i.e. it * will be less than numRowKeysToRead if only that many exist in the currentBatch. */ @JsonIgnore public ByteBuffer[] getRowKeyIdsToRead(int numRowKeysToRead) { int numKeys = hasRowKeys(numRowKeysToRead); if (numKeys == 0) { return null; } int index = 0; final ByteBuffer[] rowKeyIds = new ByteBuffer[numKeys]; while (index < numKeys) { Object o = rowKeyVector.getAccessor().getObject(currentIndex + index); rowKeyIds[index++] = IdCodec.encode(o.toString()); } updateRowKeysRead(numKeys); return rowKeyIds; }
byte[] encodedKey = IdCodec.encodeAsBytes(key);
@Override public void writeDBDocument(VectorContainerWriter vectorWriter, DBDocumentReaderBase reader) throws SchemaChangeException { MapWriter writer = vectorWriter.rootAsMap(); Value id = reader.getId(); try { switch(id.getType()) { case STRING: valueWriter.writeString(writer, ID_KEY, id.getString()); break; case BINARY: valueWriter.writeBinary(writer, ID_KEY, id.getBinary()); break; default: throw new UnsupportedOperationException(id.getType() + " is not a supported type for _id field."); } } catch (IllegalStateException | IllegalArgumentException e) { throw schemaChangeException(logger, e, "Possible schema change at _id: '%s'", IdCodec.asString(id)); } }
table.getPath(), document.asReader() == null ? null : IdCodec.asString(((DBDocumentReaderBase)document.asReader()).getId()))) .build(logger); } catch (SchemaChangeException e) {
} catch (UserException e) { throw UserException.unsupportedError(e).addContext(String.format("Table: %s, document id: '%s'", getTable().getPath(), reader == null ? null : IdCodec.asString(reader.getId()))).build(logger); } catch (SchemaChangeException e) { if (getIgnoreSchemaChange()) {
@Override public String toString() { StringBuilder sb = new StringBuilder("MaprDBJsonRecordReader[Table=") .append(table != null ? table.getPath() : null); if (reader != null) { sb.append(", Document ID=") .append(IdCodec.asString(reader.getId())); } sb.append(", reader=") .append(reader) .append(']'); return sb.toString(); } }
public void readToInitSchema() { DBDocumentReaderBase reader = null; vectorWriter.setPosition(0); try (DocumentStream dstream = table.find()) { reader = (DBDocumentReaderBase) dstream.iterator().next().asReader(); documentWriter.writeDBDocument(vectorWriter, reader); } catch(UserException e) { throw UserException.unsupportedError(e) .addContext(String.format("Table: %s, document id: '%s'", getTable().getPath(), reader == null ? null : IdCodec.asString(reader.getId()))) .build(logger); } catch (SchemaChangeException e) { if (getIgnoreSchemaChange()) { logger.warn("{}. Dropping the row from result.", e.getMessage()); logger.debug("Stack trace:", e); } else { throw dataReadError(logger, e); } } finally { vectorWriter.setPosition(0); } }
@Override public void writeDBDocument(VectorContainerWriter vectorWriter, DBDocumentReaderBase reader) throws SchemaChangeException { MapWriter writer = vectorWriter.rootAsMap(); Value id = reader.getId(); try { switch(id.getType()) { case STRING: valueWriter.writeString(writer, ID_KEY, id.getString()); break; case BINARY: valueWriter.writeBinary(writer, ID_KEY, id.getBinary()); break; default: throw new UnsupportedOperationException(id.getType() + " is not a supported type for _id field."); } } catch (IllegalStateException | IllegalArgumentException e) { throw schemaChangeException(logger, e, "Possible schema change at _id: '%s'", IdCodec.asString(id)); } }
} catch (UserException e) { throw UserException.unsupportedError(e).addContext(String.format("Table: %s, document id: '%s'", getTable().getPath(), reader == null ? null : IdCodec.asString(reader.getId()))).build(logger); } catch (SchemaChangeException e) { if (getIgnoreSchemaChange()) {
table.getPath(), document.asReader() == null ? null : IdCodec.asString(((DBDocumentReaderBase)document.asReader()).getId()))) .build(logger); } catch (SchemaChangeException e) {