@Override public Iterator<String> head(final String location, final int totalLines) { try { return IteratorUtils.limit((Iterator) new TextIterator(this.fs.getConf(), new Path(location)), totalLines); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public <K, V> Iterator<KeyValue<K, V>> head(final String location, final String memoryKey, final Class readerClass, final int totalLines) { if (!readerClass.equals(SequenceFileInputFormat.class)) throw new IllegalArgumentException("Only " + SequenceFileInputFormat.class.getCanonicalName() + " memories are supported"); final Configuration configuration = new Configuration(); try { return IteratorUtils.limit((Iterator) new ObjectWritableIterator(configuration, new Path(Constants.getMemoryLocation(location, memoryKey))), totalLines); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public Iterator<Vertex> head(final String location, final Class readerClass, final int totalLines) { final org.apache.commons.configuration.Configuration configuration = new BaseConfiguration(); configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, Constants.getSearchGraphLocation(location, this).get()); configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, readerClass.getCanonicalName()); try { if (InputFormat.class.isAssignableFrom(readerClass)) return IteratorUtils.limit(new HadoopVertexIterator(HadoopGraph.open(configuration)), totalLines); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } throw new IllegalArgumentException("The provided parser class must be an " + InputFormat.class.getCanonicalName() + ": " + readerClass.getCanonicalName()); }
@Override public Iterator<String> head(final String location, final int totalLines) { try { return IteratorUtils.limit((Iterator) new TextIterator(this.fs.getConf(), new Path(location)), totalLines); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public <K, V> Iterator<KeyValue<K, V>> head(final String location, final String memoryKey, final Class readerClass, final int totalLines) { if (!readerClass.equals(SequenceFileInputFormat.class)) throw new IllegalArgumentException("Only " + SequenceFileInputFormat.class.getCanonicalName() + " memories are supported"); final Configuration configuration = new Configuration(); try { return IteratorUtils.limit((Iterator) new ObjectWritableIterator(configuration, new Path(Constants.getMemoryLocation(location, memoryKey))), totalLines); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public Iterator<Vertex> head(final String location, final Class readerClass, final int totalLines) { final org.apache.commons.configuration.Configuration configuration = new BaseConfiguration(); configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, Constants.getSearchGraphLocation(location, this).get()); configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, readerClass.getCanonicalName()); try { if (InputFormat.class.isAssignableFrom(readerClass)) return IteratorUtils.limit(new HadoopVertexIterator(HadoopGraph.open(configuration)), totalLines); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } throw new IllegalArgumentException("The provided parser class must be an " + InputFormat.class.getCanonicalName() + ": " + readerClass.getCanonicalName()); }