@Override public void write(DataOutput out) throws IOException { out.writeInt(contentType.ordinal()); if (content != null) { WritableUtils.writeVInt(out, content.length); out.write(content, 0, content.length); } else if (is != null) { content = new byte[MAX_BUFFER_SIZE]; int len = 0; while ((len = is.read(content)) > 0) { out.write(content, 0, len); } } }
@Override public void readFields(DataInput in) throws IOException { int ordinal = in.readInt(); contentType = ContentType.valueOf(ordinal); int length = WritableUtils.readVInt(in); if (length > MAX_BUFFER_SIZE) { is = (DataInputStream)in; return; } content = new byte[length]; in.readFully(content, 0, length); }
@SuppressWarnings("unchecked") protected void initConfig(TaskAttemptContext context) { conf = context.getConfiguration(); String type = conf.get(MarkLogicConstants.CONTENT_TYPE, MarkLogicConstants.DEFAULT_CONTENT_TYPE); if (!conf.getBoolean(MarkLogicConstants.OUTPUT_STREAMING, false)) { ContentType contentType = ContentType.valueOf(type); Class<? extends Writable> valueClass = contentType.getWritableClass(); value = (VALUEIN) ReflectionUtils.newInstance(valueClass, conf); } encoding = conf.get(MarkLogicConstants.OUTPUT_CONTENT_ENCODING, DEFAULT_ENCODING); }
ContentType contentType = ContentType.valueOf(contentTypeStr); if (contentType == ContentType.UNKNOWN) { formatNeeded = true; } else { options.setFormat(contentType.getDocumentFormat());
if (mode.equals(MODE_DISTRIBUTED)) { dst = dir + "/" + context.getTaskAttemptID().getTaskID().getId() + "-" + timestamp + "-" + type.toString(); } else if (mode.equals(MODE_LOCAL)) { dst = dir + "/" + timestamp + "-" + type.toString(); if (ContentType.BINARY.equals(type)) { if (binaryArchive == null) { binaryArchive = new OutputArchive(dst, conf); content.getContentAsByteArray(), isExportDoc); } else if (ContentType.TEXT.equals(type)) { if(txtArchive == null) { txtArchive = new OutputArchive(dst, conf); txtArchive.write(zipEntryName, text.getBytes(encoding), isExportDoc); } else if (ContentType.XML.equals(type)) { if(xmlArchive == null) { xmlArchive = new OutputArchive(dst, conf); } else if (ContentType.JSON.equals(type)) { if (jsonArchive == null) { jsonArchive = new OutputArchive(dst, conf); + type.name());
if (ContentType.BINARY.equals(type)) { if (content.isStreamable()) { InputStream is = null; os.write(content.getContentAsByteArray()); } else if (ContentType.TEXT.equals(type) || ContentType.XML.equals(type) || ContentType.JSON.equals(type)) { if(encoding.equals("UTF-8")) { Text t = content.getContentAsText(); + type.name());
DatabaseDocument doc = (DatabaseDocument)value; if (formatNeeded) { options.setFormat(doc.getContentType().getDocumentFormat()); formatNeeded = false;
ContentType.XML.name()); if ("XML".equalsIgnoreCase(type)) { LOG.warn(DATA_TYPE + " is only applicable when " + DOCUMENT_TYPE + " is " + ContentType.JSON.name()); } else { String value = cmdline.getOptionValue(DATA_TYPE); conf.set(MarkLogicConstants.CONTENT_TYPE, contentType.name()); " type specification configured on MarkLogic Server."); } else { LOG.info("Content type: " + contentType.name()); ContentType.XML.name()); if ("JSON".equalsIgnoreCase(type)) { LOG.warn(DELIMITED_ROOT_NAME + " is only applicable when " + DOCUMENT_TYPE + " is " + ContentType.XML.name()); } else { String delimRoot = cmdline SequenceFileValueType.BYTESWRITABLE.toString())) { conf.set(MarkLogicConstants.CONTENT_TYPE, ContentType.BINARY.toString()); if (fileType.equalsIgnoreCase(InputType.ARCHIVE.toString())) { conf.set(MarkLogicConstants.CONTENT_TYPE,
public static ContentType forName(String typeName) { if (typeName.equalsIgnoreCase(XML.name())) { return XML; } else if (typeName.equalsIgnoreCase(JSON.name())) { return JSON; } else if (typeName.equalsIgnoreCase(TEXT.name())) { return TEXT; } else if (typeName.equalsIgnoreCase(BINARY.name())) { return BINARY; } else if (typeName.equalsIgnoreCase(UNKNOWN.name())) { return UNKNOWN; } else if (typeName.equalsIgnoreCase(MIXED.name())) { return MIXED; } else { throw new IllegalArgumentException("Unknown content type: " + typeName); } }
ContentType docContentType = contentType; if (options.getFormat() != DocumentFormat.NONE) { docContentType = ContentType.fromFormat(options.getFormat()); } else if (contentType == ContentType.MIXED) { docContentType = ContentType.forName(getTypeFromMap(uri));
opt.setFormat(doc.getContentType().getDocumentFormat()); addValue(uri, value, sid, opt, effectiveVersion<PROPS_MIN_VERSION?null:meta.getProperties()); pendingURIs[sid].add((DocumentURI)key.clone());
protected void initStream(InputSplit inSplit) throws IOException { FSDataInputStream fileIn = openFile(inSplit, false); if (fileIn == null) { return; } int index = file.toUri().getPath().lastIndexOf(EXTENSION); String subStr = file.toUri().getPath().substring(0, index); index = subStr.lastIndexOf('-'); String typeStr = subStr.substring(index + 1, subStr.length()); type = ContentType.valueOf(typeStr); value = new DatabaseDocumentWithMeta(); zipIn = new ZipInputStream(fileIn); }
MarkLogicDocument doc = (MarkLogicDocument)value; if (meta == null || !meta.isNakedProps()) { opt.setFormat(doc.getContentType().getDocumentFormat()); if (doc.getContentType() == ContentType.BINARY) { content = ContentFactory.newContent(uri,
@Override public void write(DataOutput out) throws IOException { if (null != content) { WritableUtils.writeVInt(out, content.length); out.write(content, 0, content.length); out.writeInt(contentType.ordinal()); } else { WritableUtils.writeVInt(out, 0); } if (meta != null) { byte[] xml = meta.toXML().getBytes(); out.writeInt(xml.length); out.write(xml); } else { out.writeInt(0); } } }
@Override public void readFields(DataInput in) throws IOException { int contentLen = WritableUtils.readVInt(in); if (0 != contentLen) { content = new byte[contentLen]; in.readFully(content, 0, contentLen); int ordinal = in.readInt(); contentType = ContentType.valueOf(ordinal); } int len = in.readInt(); if (0 != len) { byte[] xml = new byte[len]; in.readFully(xml, 0, len); StringReader reader = new StringReader(new String(xml)); meta = DocumentMetadata.fromXML(reader); } }
ContentType.valueOf(typeStr); } catch (IllegalArgumentException ex) { LOG.error("Not a valid archive: " + zipfile);
String contentTypeStr = conf.get(MarkLogicConstants.CONTENT_TYPE, MarkLogicConstants.DEFAULT_CONTENT_TYPE); contentType = ContentType.valueOf(contentTypeStr); queries = new AdhocQuery[sessions.length];