private Path pathForDataset(String namespace, String name) { Preconditions.checkState(rootDirectory != null, "Dataset repository root directory can not be null"); return rootFileSystem.makeQualified( HiveUtils.pathForDataset(rootDirectory, namespace, name)); }
@Override public boolean hasNext() { Preconditions.checkState(isOpen(), "Attempt to read from a scanner that is not open"); return filteredIterator.hasNext(); }
@Override public boolean hasNext() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); return next != null; }
private void setOverwrite() { String mode = conf.get(KITE_WRITE_MODE); Preconditions.checkState(mode == null, "Cannot replace existing write mode: " + mode); conf.setEnum(KITE_WRITE_MODE, WriteMode.OVERWRITE); }
@Override public boolean hasNext() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); return iterator.hasNext(); }
@Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "Unable to open a writer from state:%s", state); state = ReaderWriterState.OPEN; }
@Override public void remove() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a scanner in state:%s", state); iterator.remove(); }
@Override public void remove() { Preconditions.checkState(isOpen(), "Attempt to read from a scanner that is not open"); filteredIterator.remove(); }
@Override public E next() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); return iterator.next(); }
@Override public boolean hasNext() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a scanner in state:%s", state); return iterator.hasNext(); }
@Override public boolean hasNext() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); return hasNext; }
@Override public E next() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); if (hasNext()) { // if hasNext => true, then reader is guaranteed to be non-null return readerIterator.next(); } else { throw new NoSuchElementException(); } }
@Override public E next() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a scanner in state:%s", state); Result result = iterator.next(); if (result == null) { throw new NoSuchElementException(); } return entityMapper.mapToEntity(result); }
@Override public E next() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); if (next == null) { throw new NoSuchElementException(); } E current = next; advance(); return current; }
public CSVAppender(FileSystem fs, Path path, DatasetDescriptor descriptor) { this.fs = fs; this.path = path; this.schema = descriptor.getSchema(); Preconditions.checkState(schema.getType() == Schema.Type.RECORD, "Unsupported schema (not a record): {}", schema); this.props = CSVProperties.fromDescriptor(descriptor); }
@Override public void sync() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to sync a writer in state:%s", state); LOG.debug("Syncing all cached writers for view:{}", view); for (FileSystemWriter.IncrementalWriter<E> writer : cachedWriters.asMap().values()) { LOG.debug("Syncing partition writer:{}", writer); writer.sync(); } } }
@Override public void put(E entity) { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to write to a writer in state:%s", state); PutAction putAction = entityMapper.mapFromEntity(entity); clientTemplate.put(putAction, table); }
@Override public void flush() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to flush a writer in state:%s", state); try { table.flushCommits(); } catch (IOException e) { throw new DatasetIOException("Error flushing commits for table [" + table + "]", e); } }
@Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "A reader may not be opened more than once - current state:%s", state); final Format format = descriptor.getFormat(); if (!SUPPORTED_FORMATS.contains(format)) { throw new UnknownFormatException("Cannot open format:" + format.getName()); } this.state = ReaderWriterState.OPEN; }
@Override public E next() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to read from a file in state:%s", state); E record = DataModelUtil.createRecord(type, schema); try { return reader.next(record); } catch (IOException ex) { throw new DatasetIOException("Cannot advance reader", ex); } }