I am working with a log analysis tool. 

I am using **YARN log aggregation** function with Hadoop. When I do this, the *Hadoop* log file is so large that some API methods cloud not entirely read content of files into memory.

I want to match multi-line blocks within the files where the first line contains the string `[map]` and the last line contains `[\map]` - I think I can do this based on a regex. The commonly used `BufferedReader` could not satisfy my requirements.

My question is: Is there another way to go through the file line by line, checking for those matching my Regex?

P.S. I do not really want to split the file into multiple smaller files to process, as I am concerned that this will lead to some matching content not being found as I might split the file in the middle of a matching block.

The following is fragment of log file - I want the section between `[MAP]` and `[/MAP]`:

```

2015-04-16 20:30:09,240 INFO [main] org.apache.hadoop.hive.ql.exec.MapOperator: dump TS struct
2015-04-16 20:30:09,240 INFO [main] org.apache.hadoop.hive.ql.exec.mr.ExecMapper: 

    [MAP]Id =4
      [Children]
        [TS]Id =2
          [Children]
            [RS]Id =3
              [Parent]Id = 2 null[\Parent]
            [\RS]
         [\Children]
         [Parent>Id = 4 null[\Parent]
       [\TS]
      [\Children]
    [\MAP]

2015-04-16 20:30:09,241 INFO [main] org.apache.hadoop.hive.ql.exec.MapOperator: Initializing Self 4 MAP
2015-04-16 20:30:09,242 INFO [main] org.apache.hadoop.hive.ql.exec.TableScanOperator: Initializing Self 2 TS
2015-04-16 20:30:09,242 INFO [main] org.apache.hadoop.hive.ql.exec.TableScanOperator: Operator 2 TS initialized

```