Examples of LineReader


Examples of net.rim.device.api.io.LineReader

     *
     * @param MapData
     *            Location of file containing site information.
     */
    private void storeAllSites(final String MapData) {
        final LineReader lineReader =
                new LineReader(getClass().getResourceAsStream(MapData));
        byte[] line;

        // For sites
        _siteNames = new Vector();
        _sites = new Vector();
        String currentSiteName;

        for (;;) {
            try {
                line = lineReader.readLine();

                if (MapFieldDemoTokenizer.getString(line).equals("Site Name:")) {
                    // Initialize site variables.
                    currentSiteName =
                            MapFieldDemoTokenizer.getString(lineReader
                                    .readLine());
                    _siteNames.addElement(currentSiteName);
                    _currentSite =
                            new MapFieldDemoSite(MapData, currentSiteName, _map);
                    _map.addSite(_currentSite);
View Full Code Here

Examples of net.sf.xbus.base.linereader.LineReader

  public Object execute(String function, Object source) throws XException
  {
    senderExecuted = true;

    LineReader reader = null;
    BufferedWriter buffOut = null;
    try
    {
      reader = (LineReader) source;
      reader.prepareReading(mDestination);
      buffOut = prepareWriter(mConfiguration.getFileNames()[0], 0);

      String record = reader.readRecord();
      String lastRecord = "";

      if (record != null)
      {
        buffOut.write(record);
        lastRecord = record;
        record = reader.readRecord();
      } // while (record != null)
      while (record != null)
      {
        buffOut.write(Constants.LINE_SEPERATOR);
        buffOut.write(record);
        lastRecord = record;
        record = reader.readRecord();
      } // while (record != null)

      // Writing an end of file sign on Unix systems
      if (Constants.LINE_SEPERATOR.equals("\n")
          && (lastRecord.length() == 0 || lastRecord
              .charAt(lastRecord.length() - 1) != '\n'))
        buffOut.newLine();
    }
    catch (Exception e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_FILE, "0", e);
    }
    finally
    {
      try
      {
        if (reader != null)
        {
          reader.terminateReading();
        }
        if (buffOut != null)
        {
          buffOut.close();
        }
View Full Code Here

Examples of org.apache.hadoop.mapred.LineRecordReader.LineReader

      this.name = name;
      setDaemon(true);
    }

    public void run() {
      LineReader lineReader = null;
      try {
        Text row = new Text();
        lineReader = new LineReader((InputStream)in, hconf);

        while(true) {
          row.clear();
          long bytes = lineReader.readLine(row);
          if(bytes <= 0) {
            break;
          }
          proc.processLine(row);
        }
        LOG.info("StreamThread "+name+" done");

      } catch (Throwable th) {
        scriptError = th;
        LOG.warn(StringUtils.stringifyException(th));
      } finally {
        try {
          if(lineReader != null) {
            lineReader.close();
          }
          in.close();
          proc.close();
        } catch (Exception e) {
          LOG.warn(name + ": error in closing ..");
View Full Code Here

Examples of org.apache.hadoop.mapred.LineRecordReader.LineReader

      }

      long lineCounter = 0;
      for (Path indexFinalPath : paths) {
        FSDataInputStream ifile = fs.open(indexFinalPath);
        LineReader lr = new LineReader(ifile, conf);
        try {
          Text line = new Text();
          while (lr.readLine(line) > 0) {
            if (++lineCounter > maxEntriesToLoad) {
              throw new HiveException("Number of compact index entries loaded during the query exceeded the maximum of " + maxEntriesToLoad
                  + " set in " + HiveConf.ConfVars.HIVE_INDEX_COMPACT_QUERY_MAX_ENTRIES.varname);
            }
            add(line);
          }
        }
        finally {
          // this will close the input stream
          lr.close();
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.hadoop.util.LineReader

  public String read() throws IOException  {
    if (readerHelper == null) {
      readerHelper = new ReaderHelper<LineReader, byte[]>(getInput(), getInputContext(), getSplit(), getCodec()) {
        @Override
        protected LineReader createReader(InputStream inputStream) throws IOException {
          LineReader lineReader = new LineReader(inputStream, delimiter);
          if (getContext().getStart() > 0) {
            processReadCount(lineReader.readLine(new Text()));
          }
          return lineReader;
        }

        @Override
View Full Code Here

Examples of org.apache.hadoop.util.LineReader

    // open the file and seek to the start of the split
    FileSystem fs = file.getFileSystem(job);
    FSDataInputStream fileIn = fs.open(split.getPath());
    boolean skipFirstLine = false;
    if (codec != null) {
      in = new LineReader(codec.createInputStream(fileIn), job);
      end = Long.MAX_VALUE;
    } else {
      if (start != 0) {
        skipFirstLine = true;
        --start;
        fileIn.seek(start);
      }
      in = new LineReader(fileIn, job);
    }
    if (skipFirstLine) { // skip first line and re-establish "start".
      start += in.readLine(new Text(), 0,
          (int) Math.min((long) Integer.MAX_VALUE, end - start));
    }
View Full Code Here

Examples of org.apache.hadoop.util.LineReader

    inputCodec = codecs.getCodec(p);
    FileSystem fs = p.getFileSystem(getConf());
    FSDataInputStream fileIn = fs.open(p);

    if (inputCodec == null) {
      return new LineReader(fileIn, getConf());
    } else {
      inputDecompressor = CodecPool.getDecompressor(inputCodec);
      return new LineReader(inputCodec.createInputStream(fileIn,
          inputDecompressor), getConf());
    }
  }
View Full Code Here

Examples of org.apache.hadoop.util.LineReader

              pos, flen, SplittableCompressionCodec.READ_MODE.BYBLOCK);
        if (in.getAdjustedStart() >= flen) {
          break;
        }
        LOG.info("SAMPLE " + in.getAdjustedStart() + "," + in.getAdjustedEnd());
        final LineReader lreader = new LineReader(in);
        lreader.readLine(line); // ignore; likely partial
        if (in.getPos() >= flen) {
          break;
        }
        lreader.readLine(line);
        final int seq1 = readLeadingInt(line);
        lreader.readLine(line);
        if (in.getPos() >= flen) {
          break;
        }
        final int seq2 = readLeadingInt(line);
        assertEquals("Mismatched lines", seq1 + 1, seq2);
View Full Code Here

Examples of org.apache.hadoop.util.LineReader

  // get the version of the filesystem from the masterindex file
  // the version is currently not useful since its the first version
  // of archives
  public int getHarVersion() throws IOException {
    FSDataInputStream masterIn = fs.open(masterIndex);
    LineReader lmaster = new LineReader(masterIn, getConf());
    Text line = new Text();
    lmaster.readLine(line);
    try {
      masterIn.close();
    } catch(IOException e){
      //disregard it.
      // its a read.
View Full Code Here

Examples of org.apache.hadoop.util.LineReader

      List<String> children, FileStatus archiveIndexStat) throws IOException {
    // read the index file
    FSDataInputStream aIn = null;
    try {
      aIn = fs.open(archiveIndex);
      LineReader aLin;
      long read = 0;
      aLin = new LineReader(aIn, getConf());
      String parentString = parent.getName();
      Path harPath = new Path(parentString);
      int harlen = harPath.depth();
      Text line = new Text();
      while (read < archiveIndexStat.getLen()) {
        int tmp = aLin.readLine(line);
        read += tmp;
        String lineFeed = line.toString();
        String child = lineFeed.substring(0, lineFeed.indexOf(" "));
        if ((child.startsWith(parentString))) {
          Path thisPath = new Path(child);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.