浏览代码

Merge pull request #6239 from richardkchapman/roxie-querylogicalfilename

HPCC-11914 VIRTUAL(filename) not supported on Roxie

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 11 年之前
父节点
当前提交
525c834107
共有 5 个文件被更改,包括 96 次插入7 次删除
  1. 18 6
      roxie/ccd/ccdfile.cpp
  2. 1 1
      roxie/ccd/ccdkey.cpp
  3. 1 0
      roxie/ccd/ccdstate.hpp
  4. 61 0
      testing/regress/ecl/issue10142.ecl
  5. 15 0
      testing/regress/ecl/key/issue10142.xml

+ 18 - 6
roxie/ccd/ccdfile.cpp

@@ -1545,6 +1545,7 @@ public:
 
     virtual bool IsShared() const { return CInterface::IsShared(); };
     PointerIArrayOf<IFileIO> files;
+    StringArray filenames;
     Int64Array bases;
     unsigned valid;
 
@@ -1567,12 +1568,23 @@ public:
         return LINK(file);
     }
 
-    void addFile(IFileIO *f, offset_t base)
+    virtual const char *queryLogicalFilename(unsigned partNo)
+    {
+        if (!filenames.isItem(partNo))
+        {
+            DBGLOG("queryLogicalFilename requested invalid part %d", partNo);
+            throw MakeStringException(ROXIE_FILE_ERROR, "queryLogicalFilename requested invalid part %d", partNo);
+        }
+        return filenames.item(partNo);
+    }
+
+    void addFile(IFileIO *f, offset_t base, const char *filename)
     {
         if (f)
             valid++;
         files.append(f);
         bases.append(base);
+        filenames.append(filename ? filename : "");  // Hack!
     }
 
     virtual unsigned length()
@@ -1618,7 +1630,6 @@ public:
             _getId();
         return ret.append(id);
     }
-
 };
 
 template <class X> class PerChannelCacheOf
@@ -1922,11 +1933,12 @@ public:
     IFileIOArray *createIFileIOArray(bool isOpt, unsigned channel) const
     {
         Owned<CFileIOArray> f = new CFileIOArray();
-        f->addFile(NULL, 0);
+        f->addFile(NULL, 0, NULL);
         ForEachItemIn(idx, subFiles)
         {
             IFileDescriptor *fdesc = subFiles.item(idx);
             IFileDescriptor *remoteFDesc = remoteSubFiles.item(idx);
+            const char *subname = subNames.item(idx);
             if (fdesc)
             {
                 unsigned numParts = fdesc->numParts();
@@ -1941,7 +1953,7 @@ public:
                             IPartDescriptor *remotePDesc = queryMatchingRemotePart(pdesc, remoteFDesc, i-1);
                             Owned<ILazyFileIO> file = createPhysicalFile(subNames.item(idx), pdesc, remotePDesc, ROXIE_FILE, numParts, cached != NULL, channel);
                             IPropertyTree &partProps = pdesc->queryProperties();
-                            f->addFile(file.getClear(), partProps.getPropInt64("@offset"));
+                            f->addFile(file.getClear(), partProps.getPropInt64("@offset"), subname);
                         }
                         catch (IException *E)
                         {
@@ -1952,11 +1964,11 @@ public:
                             if (!isOpt)
                                 throw;
                             E->Release();
-                            f->addFile(NULL, 0);
+                            f->addFile(NULL, 0, NULL);
                         }
                     }
                     else
-                        f->addFile(NULL, 0);
+                        f->addFile(NULL, 0, NULL);
                 }
             }
         }

+ 1 - 1
roxie/ccd/ccdkey.cpp

@@ -810,7 +810,7 @@ public:
 
     virtual const char * queryLogicalFilename(const void * row) 
     { 
-        UNIMPLEMENTED;
+        return f->queryLogicalFilename(thisPartIdx);
     }
 
 };

+ 1 - 0
roxie/ccd/ccdstate.hpp

@@ -92,6 +92,7 @@ interface IFileIOArray : extends IInterface
     virtual bool isValid(unsigned partNo) = 0;
     virtual unsigned __int64 size() = 0;
     virtual StringBuffer &getId(StringBuffer &) const = 0;
+    virtual const char *queryLogicalFilename(unsigned partNo) = 0;
 };
 
 interface IRoxieQuerySetManagerSet : extends IInterface

+ 61 - 0
testing/regress/ecl/issue10142.ecl

@@ -0,0 +1,61 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+IMPORT STD;
+sf1 := '~data::test::sf';
+path1 := '~data::name1';
+path2 := '~data::name2';
+
+nRecord := RECORD
+    STRING20 name;
+END;
+ds1 := DATASET([
+        {'aaa'},
+        {'bbb'},
+        {'ccc'}
+    ],
+    nRecord);
+
+ds2 := DATASET([
+        {'ddd'}
+    ], nRecord);
+
+IF(STD.File.SuperFileExists(sf1), STD.File.ClearSuperFile(sf1), STD.File.CreateSuperFile(sf1));
+
+ds3 := DATASET(sf1, {nRecord, string255 logicalFile{virtual(logicalfilename)}}, THOR);
+ds4 := DATASET(path1, {nRecord, string255 logicalFile{virtual(logicalfilename)}}, THOR);
+
+SEQUENTIAL(
+    // create
+    OUTPUT(ds1,,path1, OVERWRITE),
+    OUTPUT(ds2,,path2, OVERWRITE),
+    STD.File.StartSuperFileTransaction(),
+    STD.File.AddSuperFile(sf1, path1),
+    STD.File.AddSuperFile(sf1, path2),
+    STD.File.FinishSuperFileTransaction(),
+
+    OUTPUT(ds3),
+    OUTPUT(ds4),
+//    OUTPUT(FETCH(ds4, ds2, 0)); Gives internal error in compiler.
+
+    // clean-up
+    STD.File.StartSuperFileTransaction(),
+    STD.File.RemoveSuperFile(sf1, path2),
+    STD.File.RemoveSuperFile(sf1, path1),
+    STD.File.FinishSuperFileTransaction(),
+    STD.File.DeleteSuperFile(sf1)
+    );

+ 15 - 0
testing/regress/ecl/key/issue10142.xml

@@ -0,0 +1,15 @@
+<Dataset name='Result 1'>
+</Dataset>
+<Dataset name='Result 2'>
+</Dataset>
+<Dataset name='Result 3'>
+ <Row><name>aaa                 </name><logicalfile>data::name1                                                                                                                                                                                                                                                    </logicalfile></Row>
+ <Row><name>bbb                 </name><logicalfile>data::name1                                                                                                                                                                                                                                                    </logicalfile></Row>
+ <Row><name>ccc                 </name><logicalfile>data::name1                                                                                                                                                                                                                                                    </logicalfile></Row>
+ <Row><name>ddd                 </name><logicalfile>data::name2                                                                                                                                                                                                                                                    </logicalfile></Row>
+</Dataset>
+<Dataset name='Result 4'>
+ <Row><name>aaa                 </name><logicalfile>data::name1                                                                                                                                                                                                                                                    </logicalfile></Row>
+ <Row><name>bbb                 </name><logicalfile>data::name1                                                                                                                                                                                                                                                    </logicalfile></Row>
+ <Row><name>ccc                 </name><logicalfile>data::name1                                                                                                                                                                                                                                                    </logicalfile></Row>
+</Dataset>