@Override NativeFileSystemStore getNativeFileSystemStore() throws IOException { return new InMemoryNativeFileSystemStore(); } }
public PartialListing list(String prefix, int maxListingLength, String priorLastKey, boolean recursive) throws IOException { return list(prefix, recursive ? null : PATH_DELIMITER, maxListingLength, priorLastKey); }
public InputStream retrieve(String key) throws IOException { return retrieve(key, 0); }
public InputStream retrieve(String key, long byteRangeStart) throws IOException { byte[] data = dataMap.get(key); File file = createTempFile(); BufferedOutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(file)); out.write(data, (int) byteRangeStart, data.length - (int) byteRangeStart); } finally { if (out != null) { out.close(); } } return new FileInputStream(file); }
private PartialListing list(String prefix, String delimiter, int maxListingLength, String priorLastKey) throws IOException { if (prefix.length() > 0 && !prefix.endsWith(PATH_DELIMITER)) { prefix += PATH_DELIMITER; } List<FileMetadata> metadata = new ArrayList<FileMetadata>(); SortedSet<String> commonPrefixes = new TreeSet<String>(); for (String key : dataMap.keySet()) { if (key.startsWith(prefix)) { if (delimiter == null) { metadata.add(retrieveMetadata(key)); } else { int delimIndex = key.indexOf(delimiter, prefix.length()); if (delimIndex == -1) { metadata.add(retrieveMetadata(key)); } else { String commonPrefix = key.substring(0, delimIndex); commonPrefixes.add(commonPrefix); } } } if (metadata.size() + commonPrefixes.size() == maxListingLength) { new PartialListing(key, metadata.toArray(new FileMetadata[0]), commonPrefixes.toArray(new String[0])); } } return new PartialListing(null, metadata.toArray(new FileMetadata[0]), commonPrefixes.toArray(new String[0])); }
public PartialListing list(String prefix, int maxListingLength) throws IOException { return list(prefix, maxListingLength, null, false); }