zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #09912
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Till Westmann (tillw)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-transient_maps/+merge/106287
Added support for transient maps in the unordered-maps module.
A transient map is only available within the execution of the currently active XQuery program. It is not available to any other program that is running in parallel or after the program that created it.
Transient maps can be created using map:create-transient. All other functions are left unchanged and operate on transient and non-transient/persistent maps. Transient and persistent maps can not have the same names.
--
https://code.launchpad.net/~zorba-coders/zorba/feature-transient_maps/+merge/106287
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-05-16 06:45:13 +0000
+++ ChangeLog 2012-05-18 00:02:19 +0000
@@ -25,6 +25,7 @@
* Added support for NO_ICU (to not use ICU for unicode processing)
* Added XQJ support.
* Added CollectionManager and DocumentManager support for XQJ.
+ * Added support for transient maps to the http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
Optimizations:
* optimized insertion into a collection (don't copy it if the node was created by an element constructor
=== modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt'
--- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-05-03 12:31:51 +0000
+++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-05-18 00:02:19 +0000
@@ -95,6 +95,8 @@
DECLARE_ZORBA_MODULE(FILE store/data-structures/unordered-map.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map")
+DECLARE_ZORBA_SCHEMA(FILE store/data-structures/unordered-map.xsd
+ URI "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map")
DECLARE_ZORBA_MODULE(FILE store/documents/dynamic.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/store/dynamic/documents")
DECLARE_ZORBA_MODULE(FILE store/dynamic/collections/ddl.xq VERSION 2.0
=== modified file 'modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq'
--- modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq 2012-05-03 12:31:51 +0000
+++ modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq 2012-05-18 00:02:19 +0000
@@ -1,7 +1,6 @@
xquery version "3.0";
-
(:
- : Copyright 2006-2009 The FLWOR Foundation.
+ : Copyright 2006-2012 The FLWOR Foundation.
:
: Licensed under the Apache License, Version 2.0 (the "License");
: you may not use this file except in compliance with the License.
@@ -17,17 +16,20 @@
:)
(:~
- : This module defines a set of functions for working with
+ : <p>This module defines a set of functions for working with
: maps. A map is identified by a QName and can
- : be created using the map:create function and deleted
- : using the map:delete function, respectively. However, its
- : actual lifetime depends on the particular store implementation.
- :
- : The key of a particular entry in the map can consist
- : out of a set of atomic values (called attributes).
- : The actual type of each attribute can be determined when the
- : map is created. The value can be an arbitrary sequence
- : of items.
+ : be created using the map:create or map:create-transient functions
+ : and deleted using the map:delete function, respectively.</p>
+ :
+ : <p>The lifetime of a transient map is a map is limited by the execution
+ : of the current XQuery program. A non-transient (or persistent) map
+ : lives until it is explicitly deleted. Accordingly, it's also available
+ : to other XQuery programs.</p>
+ :
+ : <p>The key of a particular entry in the map can consist of a set of
+ : atomic values (called attributes). The actual type of each attribute
+ : is determined when the map is created. The value can be an
+ : arbitrary sequence of items.</p>
:
: @see <a href="../../html/data_lifecycle.html">Data Lifecycle</a>
: @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a>
@@ -68,6 +70,27 @@
$key-type as xs:QName) as empty-sequence() external;
(:~
+ : Create a transient map with a given name and a set of types for
+ : each key attribute. Note that the function is variadic
+ : and might take an arbitrary amount of types for the key
+ : attributes.
+ :
+ : @param $name the name of the map
+ : @param $key-type an arbitrary number of types, one
+ : for each key attribute.
+ :
+ : @return the function is sequential and immediately creates
+ : the corresponding map but returns the empty-sequence.
+ :
+ : @error err:XPTY0004 if any of the attribute types is not a subtype of
+ : xs:anyAtomicType.
+ : @error zerr:ZSTR0001 if a map with the given name already exists.
+ :)
+declare %an:variadic %an:sequential function map:create-transient(
+ $name as xs:QName,
+ $key-type as xs:QName) as empty-sequence() external;
+
+(:~
: Destroys the map with the given name.
:
: @param $name the name of the map to delete
@@ -199,8 +222,7 @@
:
: @error zerr:ZDDY0023 if a map with the given name does not exist.
:)
-declare function map:size(
- $name as xs:QName) as xs:integer external;
+declare function map:size($name as xs:QName) as xs:integer external;
(:~
: The function returns a sequence of QNames of the maps that are
@@ -210,3 +232,15 @@
:
:)
declare function map:available-maps() as xs:QName* external;
+
+(:~
+ : The function returns true if the map identified by the given QName
+ : is transient, false otherwise.
+
+ : @param $name the name of the map
+ :
+ : @return true if the map is transient, false otherwise.
+ :
+ : @error zerr:ZDDY0023 if a map with the given name does not exist.
+ :)
+declare function map:is-transient($name as xs:QName) as xs:boolean external;
=== added file 'modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xsd'
--- modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xsd 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xsd 2012-05-18 00:02:19 +0000
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ - Copyright 2006-2012 The FLWOR Foundation.
+ -
+ - 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.zorba-xquery.com/modules/store/data-structures/unordered-map"
+ elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+ <element name="options">
+ <complexType>
+ <all>
+ <element name="shared" minOccurs="0" maxOccurs="1">
+ <complexType>
+ <attribute name="value" type="boolean"/>
+ </complexType>
+ </element>
+ </all>
+ </complexType>
+ </element>
+
+</schema>
=== modified file 'src/context/dynamic_context.cpp'
--- src/context/dynamic_context.cpp 2012-05-03 12:31:51 +0000
+++ src/context/dynamic_context.cpp 2012-05-18 00:02:19 +0000
@@ -130,6 +130,7 @@
theParent(NULL),
keymap(NULL),
theAvailableIndices(NULL),
+ theAvailableMaps(NULL),
theEnvironmentVariables(NULL),
theDocLoadingUserTime(0.0),
theDocLoadingTime(0)
@@ -175,6 +176,9 @@
if (theAvailableIndices)
delete theAvailableIndices;
+
+ if (theAvailableMaps)
+ delete theAvailableMaps;
}
@@ -728,6 +732,71 @@
/*******************************************************************************
********************************************************************************/
+store::Index* dynamic_context::getMap(store::Item* qname) const
+{
+ if (theAvailableMaps == NULL)
+ return NULL;
+
+ store::Index_t map;
+
+ if (theAvailableMaps->get(qname, map))
+ {
+ return map.getp();
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void dynamic_context::bindMap(
+ store::Item* qname,
+ store::Index_t& map)
+{
+ if (theAvailableMaps == NULL)
+ theAvailableMaps = new HashMap(0, NULL, 8, false);
+
+ if (!theAvailableMaps->insert(qname, map))
+ {
+ ZORBA_ASSERT(false);
+ }
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void dynamic_context::unbindMap(store::Item* qname)
+{
+ if (theAvailableMaps != NULL)
+ theAvailableMaps->erase(qname);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void dynamic_context::getMapNames(std::vector<store::Item_t>& names) const
+{
+ if (theAvailableMaps == NULL)
+ return;
+
+ for (HashMap::iterator lIter = theAvailableMaps->begin();
+ lIter != theAvailableMaps->end();
+ ++lIter)
+ {
+ names.push_back(lIter.getKey());
+ }
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
store::Iterator_t dynamic_context::listActiveICNames()
{
return GENV_STORE.listActiveICNames();
=== modified file 'src/context/dynamic_context.h'
--- src/context/dynamic_context.h 2012-05-03 12:31:51 +0000
+++ src/context/dynamic_context.h 2012-05-18 00:02:19 +0000
@@ -104,6 +104,7 @@
typedef HashMapZString<dctx_value_t> ValueMap;
typedef ItemPointerHashMap<store::Index_t> IndexMap;
+ typedef ItemPointerHashMap<store::Index_t> HashMap;
typedef std::map<const zstring,const zstring> EnvVarMap;
@@ -121,6 +122,8 @@
IndexMap * theAvailableIndices;
+ HashMap * theAvailableMaps;
+
//MODIFY
EnvVarMap * theEnvironmentVariables;
@@ -202,6 +205,14 @@
void unbindIndex(store::Item* qname);
+ store::Index* getMap(store::Item* qname) const;
+
+ void bindMap(store::Item* qname, store::Index_t& index);
+
+ void unbindMap(store::Item* qname);
+
+ void getMapNames(std::vector<store::Item_t>& names) const;
+
/**
* Lists all active integrity constraints.
*/
=== modified file 'src/functions/pregenerated/func_maps.cpp'
--- src/functions/pregenerated/func_maps.cpp 2012-05-16 18:16:47 +0000
+++ src/functions/pregenerated/func_maps.cpp 2012-05-18 00:02:19 +0000
@@ -41,6 +41,16 @@
return new MapCreateIterator(sctx, loc, argv);
}
+PlanIter_t zorba_store_data_structure_unordered_map_create_transient::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new MapCreateTransientIterator(sctx, loc, argv);
+}
+
PlanIter_t zorba_store_data_structure_unordered_map_delete::codegen(
CompilerCB*,
static_context* sctx,
@@ -111,6 +121,16 @@
return new AvailableMapsIterator(sctx, loc, argv);
}
+PlanIter_t zorba_store_data_structure_unordered_map_is_transient::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new MapIsTransientIterator(sctx, loc, argv);
+}
+
void populate_context_maps(static_context* sctx)
{
{
@@ -127,6 +147,19 @@
{
+ std::vector<xqtref_t> lParamTypes;
+ lParamTypes.push_back(GENV_TYPESYSTEM.QNAME_TYPE_ONE);
+ lParamTypes.push_back(GENV_TYPESYSTEM.QNAME_TYPE_ONE);
+
+ DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_create_transient,
+ (createQName("http://www.zorba-xquery.com/modules/store/data-structures/unordered-map","","create-transient"),
+ lParamTypes, GENV_TYPESYSTEM.EMPTY_TYPE, true),
+ FunctionConsts::ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_TRANSIENT_N);
+
+ }
+
+
+ {
DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_delete,
@@ -212,6 +245,18 @@
}
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_is_transient,
+ (createQName("http://www.zorba-xquery.com/modules/store/data-structures/unordered-map","","is-transient"),
+ GENV_TYPESYSTEM.QNAME_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_IS_TRANSIENT_1);
+
+ }
+
}
=== modified file 'src/functions/pregenerated/func_maps.h'
--- src/functions/pregenerated/func_maps.h 2012-05-03 12:31:51 +0000
+++ src/functions/pregenerated/func_maps.h 2012-05-18 00:02:19 +0000
@@ -57,6 +57,25 @@
};
+//zorba-store-data-structure-unordered-map:create-transient
+class zorba_store_data_structure_unordered_map_create_transient : public function
+{
+public:
+ zorba_store_data_structure_unordered_map_create_transient(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
+
+ bool accessesDynCtx() const { return true; }
+
+ CODEGEN_DECL();
+};
+
+
//zorba-store-data-structure-unordered-map:delete
class zorba_store_data_structure_unordered_map_delete : public function
{
@@ -182,6 +201,23 @@
};
+//zorba-store-data-structure-unordered-map:is-transient
+class zorba_store_data_structure_unordered_map_is_transient : public function
+{
+public:
+ zorba_store_data_structure_unordered_map_is_transient(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ bool accessesDynCtx() const { return true; }
+
+ CODEGEN_DECL();
+};
+
+
} //namespace zorba
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2012-05-08 03:09:12 +0000
+++ src/functions/pregenerated/function_enum.h 2012-05-18 00:02:19 +0000
@@ -357,6 +357,7 @@
ZORBA_STORE_DOCUMENTS_AVAILABLE_DOCUMENTS_0,
ZORBA_STORE_DOCUMENTS_IS_AVAILABLE_DOCUMENT_1,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_N,
+ ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_TRANSIENT_N,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_DELETE_1,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_GET_N,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_INSERT_N,
@@ -364,6 +365,7 @@
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_KEYS_1,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_SIZE_1,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_AVAILABLE_MAPS_0,
+ ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_IS_TRANSIENT_1,
FN_CODEPOINTS_TO_STRING_1,
FN_STRING_TO_CODEPOINTS_1,
FN_COMPARE_2,
=== modified file 'src/runtime/spec/store/maps.xml'
--- src/runtime/spec/store/maps.xml 2012-05-16 18:16:47 +0000
+++ src/runtime/spec/store/maps.xml 2012-05-18 00:02:19 +0000
@@ -12,12 +12,13 @@
xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
<zorba:source>
- <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
- <zorba:include form="Quoted">store/api/index.h</zorba:include>
+ <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
+ <zorba:include form="Quoted">store/api/index.h</zorba:include>
</zorba:source>
<zorba:header>
- <zorba:include form="Quoted">store/api/index.h</zorba:include>
+ <zorba:include form="Quoted">store/api/index.h</zorba:include>
+ <zorba:include form="Angle-bracket">vector</zorba:include>
</zorba:header>
@@ -54,6 +55,35 @@
/*******************************************************************************
********************************************************************************/
-->
+<zorba:iterator name="MapCreateTransientIterator" >
+
+ <zorba:description author="Matthias Brantner">
+ </zorba:description>
+
+ <zorba:function>
+
+ <zorba:signature
+ variadic="true"
+ localname="create-transient"
+ prefix="zorba-store-data-structure-unordered-map">
+ <zorba:param>xs:QName</zorba:param> <!-- name of the hashmap -->
+ <zorba:param>xs:QName</zorba:param> <!-- list of key types -->
+ <zorba:output>empty-sequence()</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:getScriptingKind returnValue="SEQUENTIAL_FUNC_EXPR"/>
+ <zorba:accessesDynCtx returnValue="true"/>
+ </zorba:methods>
+
+ </zorba:function>
+
+</zorba:iterator>
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
<zorba:iterator name="MapDestroyIterator" >
<zorba:description author="Matthias Brantner">
@@ -238,10 +268,40 @@
</zorba:function>
<zorba:state generateInit="false" generateReset="false" generateDestructor="false">
- <zorba:member type="store::Iterator_t" name="nameItState"
- brief="the current iterator"/>
+ <zorba:member type="store::Iterator_t"
+ name="persistentMapNamesIter"
+ brief="the current iterator"/>
+ <zorba:member type="std::vector<store::Item_t>"
+ name="transientMapNames" brief="all the transient map names"/>
+ <zorba:member type="std::vector<store::Item_t>::const_iterator"
+ name="transientMapNamesIter"
+ brief="the current iterator"/>
</zorba:state>
</zorba:iterator>
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
+<zorba:iterator name="MapIsTransientIterator" >
+
+ <zorba:description author="Matthias Brantner">
+ </zorba:description>
+
+ <zorba:function>
+
+ <zorba:signature localname="is-transient" prefix="zorba-store-data-structure-unordered-map">
+ <zorba:param>xs:QName</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:accessesDynCtx returnValue="true"/>
+ </zorba:methods>
+
+ </zorba:function>
+
+</zorba:iterator>
+
</zorba:iterators>
=== modified file 'src/runtime/store/maps_impl.cpp'
--- src/runtime/store/maps_impl.cpp 2012-05-03 12:31:51 +0000
+++ src/runtime/store/maps_impl.cpp 2012-05-18 00:02:19 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2008 The FLWOR Foundation.
+ * Copyright 2006-2012 The FLWOR Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
#include "runtime/store/maps.h"
#include "context/static_context.h"
+#include "context/dynamic_context.h"
#include "context/namespace_context.h"
#include "store/api/pul.h"
@@ -49,7 +50,9 @@
params, \
ERROR_LOC(loc));
-static void
+/*******************************************************************************
+********************************************************************************/
+void
castOrCheckIndexType(
store::Item_t& aKeyItem,
const store::Item_t& aKeyType,
@@ -101,50 +104,104 @@
}
}
}
-
+
/*******************************************************************************
********************************************************************************/
-bool
-MapCreateIterator::nextImpl(
- store::Item_t& result,
- PlanState& aPlanState) const
+void
+checkMapTypes(
+ std::vector<store::Item_t>& aTypes,
+ const store::Item_t& aMapName,
+ const QueryLoc& aLoc)
{
- store::Item_t lQName;
- std::vector<store::Item_t> lTypes;
- std::vector<zstring> lCollations;
- std::auto_ptr<store::PUL> lPul;
- long lTimezone = 0;
xqtref_t lAnyAtomicType, lIndexKeyType;
- size_t i;
-
- PlanIteratorState* state;
- DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
-
- consumeNext(lQName, theChildren[0].getp(), aPlanState);
-
- lTypes.resize(theChildren.size() - 1);
- lCollations.resize(theChildren.size() - 1);
- for (i = 1; i < theChildren.size(); ++i)
+
+ for (size_t i = 0; i < aTypes.size(); ++i)
{
- consumeNext(lTypes[i-1], theChildren[i].getp(), aPlanState);
-
lAnyAtomicType = GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE;
lIndexKeyType = GENV_TYPESYSTEM.create_named_type(
- lTypes[i-1].getp(), TypeConstants::QUANT_ONE, loc);
+ aTypes[i].getp(), TypeConstants::QUANT_ONE, aLoc);
if (lIndexKeyType != NULL &&
!TypeOps::is_subtype(&GENV_TYPESYSTEM,
*lIndexKeyType, *lAnyAtomicType))
{
- RAISE_ERROR(err::XPTY0004, loc,
+ RAISE_ERROR(err::XPTY0004, aLoc,
ERROR_PARAMS(ZED(SearchKeyTypeMismatch_234),
*lAnyAtomicType,
- lQName->getStringValue(),
+ aMapName->getStringValue(),
*lIndexKeyType)
);
}
}
+}
+
+
+/*******************************************************************************
+********************************************************************************/
+bool
+getMap(
+ const store::Item_t& aName,
+ const QueryLoc& aLoc,
+ dynamic_context* aContext,
+ store::Index*& aIndex)
+{
+ aIndex = GENV_STORE.getMap(aName);
+
+ if (aIndex) return true;
+
+ aIndex = aContext->getMap(aName.getp());
+
+ if (!aIndex)
+ {
+ RAISE_ERROR(
+ zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
+ ERROR_PARAMS( aName->getStringValue() ),
+ aLoc);
+ }
+
+ return false;
+}
+
+
+
+/*******************************************************************************
+********************************************************************************/
+bool
+MapCreateIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t lQName;
+ std::vector<store::Item_t> lTypes;
+ std::vector<zstring> lCollations;
+ std::auto_ptr<store::PUL> lPul;
+ long lTimezone = 0;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ consumeNext(lQName, theChildren[0].getp(), aPlanState);
+
+ if (GENV_STORE.getMap(lQName)
+ || aPlanState.theLocalDynCtx->getMap(lQName.getp()))
+ {
+ RAISE_ERROR(
+ zerr::ZSTR0001_INDEX_ALREADY_EXISTS,
+ ERROR_PARAMS( lQName->getStringValue() ),
+ loc
+ );
+ }
+
+ lCollations.resize(theChildren.size() - 1);
+ lTypes.resize(theChildren.size() - 1);
+
+ for (size_t i = 1; i < theChildren.size(); ++i)
+ {
+ consumeNext(lTypes[i-1], theChildren[i].getp(), aPlanState);
+ }
+
+ checkMapTypes(lTypes, lQName, loc);
lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
lPul->addCreateHashMap(&loc, lQName, lTypes, lCollations, lTimezone);
@@ -165,40 +222,86 @@
/*******************************************************************************
********************************************************************************/
bool
+MapCreateTransientIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t lQName;
+ store::IndexSpecification lSpec;
+ store::Index_t lIndex;
+ std::vector<std::string> lCollations;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ consumeNext(lQName, theChildren[0].getp(), aPlanState);
+
+ if (GENV_STORE.getMap(lQName)
+ || aPlanState.theLocalDynCtx->getMap(lQName.getp()))
+ {
+ RAISE_ERROR(
+ zerr::ZSTR0001_INDEX_ALREADY_EXISTS,
+ ERROR_PARAMS( lQName->getStringValue() ),
+ loc
+ );
+ }
+
+ lCollations.resize(theChildren.size() - 1);
+ lSpec.theKeyTypes.resize(theChildren.size() - 1);
+
+ for (size_t i = 1; i < theChildren.size(); ++i)
+ {
+ consumeNext(lSpec.theKeyTypes[i-1], theChildren[i].getp(), aPlanState);
+ }
+
+ checkMapTypes(lSpec.theKeyTypes, lQName, loc);
+
+ lSpec.theNumKeyColumns = lSpec.theKeyTypes.size();
+ lSpec.theIsTemp = true;
+ lSpec.theCollations = lCollations;
+ lSpec.theTimezone = 0;
+
+ lIndex = GENV_STORE.createMap(lQName, lSpec);
+
+ aPlanState.theLocalDynCtx->bindMap(lIndex->getName(), lIndex);
+
+ result = NULL;
+
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+********************************************************************************/
+bool
MapDestroyIterator::nextImpl(
store::Item_t& result,
PlanState& aPlanState) const
{
store::Item_t lQName;
- std::auto_ptr<store::PUL> lPul;
- store::Index_t lIndex;
+ store::Index* lIndex;
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
consumeNext(lQName, theChildren[0].getp(), aPlanState);
- lIndex = GENV_STORE.getMap(lQName);
-
- if (!lIndex)
- {
- throw XQUERY_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( lQName->getStringValue() ),
- ERROR_LOC( loc )
- );
- }
-
-
- lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
- lPul->addDestroyHashMap(&loc, lQName);
-
- apply_updates(
- aPlanState.theCompilerCB,
- aPlanState.theGlobalDynCtx,
- theSctx,
- lPul.get(),
- loc);
+ if (getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex))
+ {
+ std::auto_ptr<store::PUL> lPul(GENV_ITEMFACTORY->createPendingUpdateList());
+ lPul->addDestroyHashMap(&loc, lQName);
+
+ apply_updates(
+ aPlanState.theCompilerCB,
+ aPlanState.theGlobalDynCtx,
+ theSctx,
+ lPul.get(),
+ loc);
+ }
+ else
+ {
+ aPlanState.theLocalDynCtx->unbindMap(lQName.getp());
+ }
result = NULL;
@@ -224,29 +327,20 @@
consumeNext(lQName, theChildren[0].getp(), aPlanState);
- lIndex = GENV_STORE.getMap(lQName);
-
- if (!lIndex)
- {
- throw XQUERY_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( lQName->getStringValue() ),
- ERROR_LOC( loc )
- );
- }
+ getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex);
lSpec = lIndex->getSpecification();
if (lSpec.getNumColumns() != theChildren.size() - 1)
{
- throw XQUERY_EXCEPTION(
+ RAISE_ERROR(
zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
ERROR_PARAMS(
lQName->getStringValue(),
"map",
theChildren.size() - 1,
lSpec.getNumColumns() ),
- ERROR_LOC( loc )
+ loc
);
}
@@ -293,63 +387,85 @@
{
store::Item_t lQName;
std::vector<store::Item_t> lKey;
- store::Iterator_t lValue;
- std::auto_ptr<store::PUL> lPul;
store::IndexSpecification lSpec;
- store::Index_t lIndex;
+ store::Index* lIndex;
+ bool lPersistent;
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
consumeNext(lQName, theChildren[0].getp(), aPlanState);
- lIndex = GENV_STORE.getMap(lQName);
-
- if (!lIndex)
- {
- throw XQUERY_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( lQName->getStringValue() ),
- ERROR_LOC( loc )
- );
- }
+ lPersistent = getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex);
lSpec = lIndex->getSpecification();
if (lSpec.getNumColumns() != theChildren.size() - 2)
{
- throw XQUERY_EXCEPTION(
+ RAISE_ERROR(
zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
ERROR_PARAMS(
lQName->getStringValue(),
"map",
theChildren.size() - 2,
lSpec.getNumColumns() ),
- ERROR_LOC( loc )
+ loc
);
}
- lValue = new PlanIteratorWrapper(theChildren[1], aPlanState);
-
lKey.resize(theChildren.size() - 2);
for (size_t i = 2; i < theChildren.size(); ++i)
{
if (consumeNext(lKey[i-2], theChildren[i].getp(), aPlanState))
{
namespace_context tmp_ctx(theSctx);
- castOrCheckIndexType(lKey[i-2], lSpec.theKeyTypes[i-2], lQName, &tmp_ctx, loc);
- }
- }
-
- lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
- lPul->addInsertIntoHashMap(&loc, lQName, lKey, lValue);
-
- apply_updates(
- aPlanState.theCompilerCB,
- aPlanState.theGlobalDynCtx,
- theSctx,
- lPul.get(),
- loc);
+ castOrCheckIndexType(
+ lKey[i-2],
+ lSpec.theKeyTypes[i-2],
+ lQName,
+ &tmp_ctx,
+ loc);
+ }
+ }
+
+ if (lPersistent)
+ {
+ std::auto_ptr<store::PUL> lPul;
+ store::Iterator_t lValue
+ = new PlanIteratorWrapper(theChildren[1], aPlanState);
+
+ lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
+ lPul->addInsertIntoHashMap(&loc, lQName, lKey, lValue);
+
+ apply_updates(
+ aPlanState.theCompilerCB,
+ aPlanState.theGlobalDynCtx,
+ theSctx,
+ lPul.get(),
+ loc);
+ }
+ else
+ {
+ store::Item_t lValue;
+ while (consumeNext(lValue, theChildren[1], aPlanState))
+ {
+ std::auto_ptr<store::IndexKey> k(new store::IndexKey());
+ for (std::vector<store::Item_t>::const_iterator lIter = lKey.begin();
+ lIter != lKey.end();
+ ++lIter)
+ {
+ k->push_back(*lIter);
+ }
+
+ store::IndexKey* lKeyPtr = k.get();
+ if (!lIndex->insert(lKeyPtr, lValue))
+ {
+ // the index took the ownership over the key if the index
+ // did _not_ already contain an entry with the same key
+ k.release();
+ }
+ }
+ }
result = NULL;
@@ -371,28 +487,20 @@
store::Item_t lKeyItem;
std::auto_ptr<store::PUL> lPul;
store::IndexSpecification lSpec;
+ bool lPersistent;
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
consumeNext(lQName, theChildren[0].getp(), aPlanState);
- lIndex = GENV_STORE.getMap(lQName);
-
- if (!lIndex)
- {
- throw XQUERY_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( lQName->getStringValue() ),
- ERROR_LOC( loc )
- );
- }
+ lPersistent = getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex);
lSpec = lIndex->getSpecification();
if (lSpec.getNumColumns() != theChildren.size() - 1)
{
- throw XQUERY_EXCEPTION(
+ RAISE_ERROR(
zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
ERROR_PARAMS(
lQName->getStringValue(),
@@ -400,7 +508,7 @@
theChildren.size() - 1,
lSpec.getNumColumns()
),
- ERROR_LOC( loc )
+ loc
);
}
@@ -414,15 +522,30 @@
}
}
- lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
- lPul->addRemoveFromHashMap(&loc, lQName, lKey);
+ if (lPersistent)
+ {
+ lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
+ lPul->addRemoveFromHashMap(&loc, lQName, lKey);
- apply_updates(
- aPlanState.theCompilerCB,
- aPlanState.theGlobalDynCtx,
- theSctx,
- lPul.get(),
- loc);
+ apply_updates(
+ aPlanState.theCompilerCB,
+ aPlanState.theGlobalDynCtx,
+ theSctx,
+ lPul.get(),
+ loc);
+ }
+ else
+ {
+ store::IndexKey k;
+ for (std::vector<store::Item_t>::const_iterator lIter = lKey.begin();
+ lIter != lKey.end();
+ ++lIter)
+ {
+ k.push_back(*lIter);
+ }
+ store::Item_t lValue;
+ lIndex->remove(&k, lValue, true);
+ }
result = NULL;
@@ -454,16 +577,7 @@
consumeNext(lQName, theChildren[0].getp(), aPlanState);
- lIndex = GENV_STORE.getMap(lQName);
-
- if (!lIndex)
- {
- throw XQUERY_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( lQName->getStringValue() ),
- ERROR_LOC( loc )
- );
- }
+ getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex);
state->theIter = lIndex->keys();
@@ -529,16 +643,7 @@
consumeNext(lQName, theChildren[0].getp(), aPlanState);
- lIndex = GENV_STORE.getMap(lQName);
-
- if (!lIndex)
- {
- throw XQUERY_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( lQName->getStringValue() ),
- ERROR_LOC( loc )
- );
- }
+ getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex);
GENV_ITEMFACTORY->createInteger(result, xs_integer(lIndex->size()));
@@ -547,33 +652,36 @@
STACK_END(state);
}
+
/*******************************************************************************
********************************************************************************/
AvailableMapsIteratorState::~AvailableMapsIteratorState()
{
- if ( nameItState != NULL )
+ if ( persistentMapNamesIter != NULL )
{
- nameItState->close();
- nameItState = NULL;
+ persistentMapNamesIter->close();
+ persistentMapNamesIter = NULL;
}
+ transientMapNames.clear();
}
void AvailableMapsIteratorState::init(PlanState& planState)
{
PlanIteratorState::init(planState);
- nameItState = NULL;
+ persistentMapNamesIter = NULL;
}
void AvailableMapsIteratorState::reset(PlanState& planState)
{
PlanIteratorState::reset(planState);
- if ( nameItState != NULL ) {
- nameItState->close();
- nameItState = NULL;
+ if ( persistentMapNamesIter != NULL ) {
+ persistentMapNamesIter->close();
+ persistentMapNamesIter = NULL;
}
+ transientMapNames.clear();
}
@@ -585,18 +693,54 @@
DEFAULT_STACK_INIT(AvailableMapsIteratorState, state, planState);
- for ((state->nameItState = GENV_STORE.listMapNames())->open ();
- state->nameItState->next(nameItem); )
+ for ((state->persistentMapNamesIter = GENV_STORE.listMapNames())->open ();
+ state->persistentMapNamesIter->next(nameItem); )
{
result = nameItem;
STACK_PUSH( true, state);
}
- state->nameItState->close();
+ state->persistentMapNamesIter->close();
+
+ planState.theLocalDynCtx->getMapNames(state->transientMapNames);
+
+ for (state->transientMapNamesIter = state->transientMapNames.begin();
+ state->transientMapNamesIter != state->transientMapNames.end();
+ ++state->transientMapNamesIter)
+ {
+ result = *state->transientMapNamesIter;
+ STACK_PUSH( true, state);
+ }
STACK_END (state);
}
+/*******************************************************************************
+********************************************************************************/
+bool
+MapIsTransientIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t lQName;
+ store::Index* lIndex;
+ bool lPersistent;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ consumeNext(lQName, theChildren[0].getp(), aPlanState);
+
+ lPersistent = getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex);
+
+ GENV_ITEMFACTORY->createBoolean(result, !lPersistent);
+
+ STACK_PUSH(true, state);
+
+ STACK_END(state);
+}
+
+
} // namespace zorba
/* vim:set et sw=2 ts=2: */
=== modified file 'src/runtime/store/pregenerated/maps.cpp'
--- src/runtime/store/pregenerated/maps.cpp 2012-05-03 12:31:51 +0000
+++ src/runtime/store/pregenerated/maps.cpp 2012-05-18 00:02:19 +0000
@@ -56,6 +56,28 @@
// </MapCreateIterator>
+// <MapCreateTransientIterator>
+MapCreateTransientIterator::class_factory<MapCreateTransientIterator>
+MapCreateTransientIterator::g_class_factory;
+
+
+void MapCreateTransientIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+MapCreateTransientIterator::~MapCreateTransientIterator() {}
+
+// </MapCreateTransientIterator>
+
+
// <MapDestroyIterator>
MapDestroyIterator::class_factory<MapDestroyIterator>
MapDestroyIterator::g_class_factory;
@@ -236,6 +258,28 @@
// </AvailableMapsIterator>
+// <MapIsTransientIterator>
+MapIsTransientIterator::class_factory<MapIsTransientIterator>
+MapIsTransientIterator::g_class_factory;
+
+
+void MapIsTransientIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+MapIsTransientIterator::~MapIsTransientIterator() {}
+
+// </MapIsTransientIterator>
+
+
}
=== modified file 'src/runtime/store/pregenerated/maps.h'
--- src/runtime/store/pregenerated/maps.h 2012-05-03 12:31:51 +0000
+++ src/runtime/store/pregenerated/maps.h 2012-05-18 00:02:19 +0000
@@ -29,6 +29,7 @@
#include "runtime/base/narybase.h"
+#include <vector>
#include "store/api/index.h"
@@ -74,6 +75,41 @@
*
* Author: Matthias Brantner
*/
+class MapCreateTransientIterator : public NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(MapCreateTransientIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(MapCreateTransientIterator,
+ NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>*)this);
+ }
+
+ MapCreateTransientIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~MapCreateTransientIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ *
+ * Author: Matthias Brantner
+ */
class MapDestroyIterator : public NaryBaseIterator<MapDestroyIterator, PlanIteratorState>
{
public:
@@ -319,7 +355,9 @@
class AvailableMapsIteratorState : public PlanIteratorState
{
public:
- store::Iterator_t nameItState; //the current iterator
+ store::Iterator_t persistentMapNamesIter; //the current iterator
+ std::vector<store::Item_t> transientMapNames; //all the transient map names
+ std::vector<store::Item_t>::const_iterator transientMapNamesIter; //the current iterator
AvailableMapsIteratorState();
@@ -359,6 +397,41 @@
};
+/**
+ *
+ *
+ * Author: Matthias Brantner
+ */
+class MapIsTransientIterator : public NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(MapIsTransientIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(MapIsTransientIterator,
+ NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>*)this);
+ }
+
+ MapIsTransientIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~MapIsTransientIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
}
#endif
/*
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-05-08 23:49:22 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-05-18 00:02:19 +0000
@@ -574,6 +574,8 @@
class MapCreateIterator;
+ class MapCreateTransientIterator;
+
class MapDestroyIterator;
class MapGetIterator;
@@ -588,6 +590,8 @@
class AvailableMapsIterator;
+ class MapIsTransientIterator;
+
class CodepointsToStringIterator;
class StringToCodepointsIterator;
@@ -1470,6 +1474,9 @@
virtual void beginVisit ( const MapCreateIterator& ) = 0;
virtual void endVisit ( const MapCreateIterator& ) = 0;
+ virtual void beginVisit ( const MapCreateTransientIterator& ) = 0;
+ virtual void endVisit ( const MapCreateTransientIterator& ) = 0;
+
virtual void beginVisit ( const MapDestroyIterator& ) = 0;
virtual void endVisit ( const MapDestroyIterator& ) = 0;
@@ -1491,6 +1498,9 @@
virtual void beginVisit ( const AvailableMapsIterator& ) = 0;
virtual void endVisit ( const AvailableMapsIterator& ) = 0;
+ virtual void beginVisit ( const MapIsTransientIterator& ) = 0;
+ virtual void endVisit ( const MapIsTransientIterator& ) = 0;
+
virtual void beginVisit ( const CodepointsToStringIterator& ) = 0;
virtual void endVisit ( const CodepointsToStringIterator& ) = 0;
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-05-08 23:49:22 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-05-18 00:02:19 +0000
@@ -3824,6 +3824,20 @@
// </MapCreateIterator>
+// <MapCreateTransientIterator>
+void PrinterVisitor::beginVisit ( const MapCreateTransientIterator& a) {
+ thePrinter.startBeginVisit("MapCreateTransientIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const MapCreateTransientIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </MapCreateTransientIterator>
+
+
// <MapDestroyIterator>
void PrinterVisitor::beginVisit ( const MapDestroyIterator& a) {
thePrinter.startBeginVisit("MapDestroyIterator", ++theId);
@@ -3922,6 +3936,20 @@
// </AvailableMapsIterator>
+// <MapIsTransientIterator>
+void PrinterVisitor::beginVisit ( const MapIsTransientIterator& a) {
+ thePrinter.startBeginVisit("MapIsTransientIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const MapIsTransientIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </MapIsTransientIterator>
+
+
// <CodepointsToStringIterator>
void PrinterVisitor::beginVisit ( const CodepointsToStringIterator& a) {
thePrinter.startBeginVisit("CodepointsToStringIterator", ++theId);
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2012-05-08 23:49:22 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-05-18 00:02:19 +0000
@@ -871,6 +871,9 @@
void beginVisit( const MapCreateIterator& );
void endVisit ( const MapCreateIterator& );
+ void beginVisit( const MapCreateTransientIterator& );
+ void endVisit ( const MapCreateTransientIterator& );
+
void beginVisit( const MapDestroyIterator& );
void endVisit ( const MapDestroyIterator& );
@@ -892,6 +895,9 @@
void beginVisit( const AvailableMapsIterator& );
void endVisit ( const AvailableMapsIterator& );
+ void beginVisit( const MapIsTransientIterator& );
+ void endVisit ( const MapIsTransientIterator& );
+
void beginVisit( const CodepointsToStringIterator& );
void endVisit ( const CodepointsToStringIterator& );
=== modified file 'src/store/api/index.h'
--- src/store/api/index.h 2012-05-03 12:31:51 +0000
+++ src/store/api/index.h 2012-05-18 00:02:19 +0000
@@ -427,6 +427,11 @@
* a general index
*/
virtual bool insert(store::IndexKey*& key, store::Item_t& item) = 0;
+
+ virtual bool remove(
+ const store::IndexKey* key,
+ const store::Item_t& item,
+ bool all = false) = 0;
};
=== modified file 'src/store/api/store.h'
--- src/store/api/store.h 2012-05-03 12:31:51 +0000
+++ src/store/api/store.h 2012-05-18 00:02:19 +0000
@@ -312,6 +312,10 @@
/* ------------------------ Map Management ---------------------------*/
+ virtual Index_t createMap(
+ const Item_t& qname,
+ const IndexSpecification& spec) = 0;
+
virtual Index* getMap(const Item* aQName) const = 0;
virtual Iterator_t listMapNames() = 0;
=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp 2012-05-16 06:45:13 +0000
+++ src/store/naive/pul_primitives.cpp 2012-05-18 00:02:19 +0000
@@ -1718,7 +1718,7 @@
lSpec.theTimezone = theTimezone;
- GET_STORE().createHashMap(theQName, lSpec);
+ GET_STORE().createMap(theQName, lSpec);
theIsApplied = true;
}
@@ -1727,7 +1727,7 @@
{
if (theIsApplied)
{
- GET_STORE().destroyHashMap(theQName);
+ GET_STORE().destroyMap(theQName);
}
}
@@ -1747,7 +1747,7 @@
void UpdDestroyHashMap::apply()
{
- theMap = GET_STORE().destroyHashMap(theQName);
+ theMap = GET_STORE().destroyMap(theQName);
theIsApplied = true;
}
@@ -1756,7 +1756,7 @@
{
if (theIsApplied)
{
- GET_STORE().addHashMap(theMap);
+ GET_STORE().addMap(theMap);
}
}
@@ -1780,7 +1780,7 @@
void UpdInsertIntoHashMap::apply()
{
- store::Index_t lMap = GET_STORE().getHashMap(theQName);
+ store::Index_t lMap = GET_STORE().getMap(theQName);
if (!lMap)
{
@@ -1793,7 +1793,6 @@
theValue->open();
store::Item_t lValue;
- store::IndexKey lKeyPtr;
while (theValue->next(lValue))
{
std::auto_ptr<store::IndexKey> lKey(new store::IndexKey());
@@ -1837,7 +1836,7 @@
void UpdRemoveFromHashMap::apply()
{
- store::Index_t lMap = GET_STORE().getHashMap(theQName);
+ store::Index_t lMap = GET_STORE().getMap(theQName);
if (!lMap)
{
=== modified file 'src/store/naive/simple_index_general.cpp'
--- src/store/naive/simple_index_general.cpp 2012-05-03 12:31:51 +0000
+++ src/store/naive/simple_index_general.cpp 2012-05-18 00:02:19 +0000
@@ -747,7 +747,7 @@
*******************************************************************************/
bool GeneralHashIndex::remove(
const store::Item_t& key,
- store::Item_t& item,
+ const store::Item_t& item,
bool all)
{
assert(false);
@@ -922,7 +922,7 @@
*******************************************************************************/
bool GeneralTreeIndex::remove(
const store::Item_t& key,
- store::Item_t& item,
+ const store::Item_t& item,
bool all)
{
return true;
=== modified file 'src/store/naive/simple_index_general.h'
--- src/store/naive/simple_index_general.h 2012-05-03 12:31:51 +0000
+++ src/store/naive/simple_index_general.h 2012-05-18 00:02:19 +0000
@@ -176,7 +176,12 @@
bool insert(store::IndexKey*& key, store::Item_t& value);
- virtual bool remove(const store::Item_t& key, store::Item_t& item, bool all) = 0;
+ virtual bool remove(const store::Item_t& key, const store::Item_t& item, bool all) = 0;
+
+ virtual bool remove(
+ const store::IndexKey* key,
+ const store::Item_t& item,
+ bool all = false) = 0;
};
@@ -237,7 +242,16 @@
Index::KeyIterator_t keys() const;
- bool remove(const store::Item_t& key, store::Item_t& item, bool);
+ bool remove(const store::Item_t& key, const store::Item_t& item, bool);
+
+ bool remove(
+ const store::IndexKey* key,
+ const store::Item_t& item,
+ bool all = false)
+ {
+ assert(key->size() == 1);
+ return remove(((*key)[0]), item, all);
+ }
void clear();
};
@@ -292,7 +306,16 @@
Index::KeyIterator_t keys() const;
- bool remove(const store::Item_t& key, store::Item_t& item, bool all);
+ bool remove(const store::Item_t& key, const store::Item_t& item, bool all);
+
+ bool remove(
+ const store::IndexKey* key,
+ const store::Item_t& item,
+ bool all = false)
+ {
+ assert(key->size() == 1);
+ return remove(((*key)[0]), item, all);
+ }
void clear();
};
=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp 2012-05-05 03:17:35 +0000
+++ src/store/naive/store.cpp 2012-05-18 00:02:19 +0000
@@ -880,7 +880,7 @@
********************************************************************************/
store::Index_t
-Store::createHashMap(
+Store::createMap(
const store::Item_t& aQName,
const store::IndexSpecification& aSpec)
{
@@ -896,7 +896,7 @@
lIndex = new ValueHashIndex(aQName, aSpec);
- addHashMap(lIndex);
+ if (!aSpec.theIsTemp) addMap(lIndex);
return lIndex;
}
@@ -906,7 +906,7 @@
********************************************************************************/
store::Index_t
-Store::destroyHashMap(const store::Item_t& aQName)
+Store::destroyMap(const store::Item_t& aQName)
{
store::Index_t lIndex;
if (!theHashMaps.get(aQName.getp(), lIndex))
@@ -941,7 +941,7 @@
********************************************************************************/
store::Index_t
-Store::getHashMap(const store::Item_t& aQName) const
+Store::getMap(const store::Item_t& aQName) const
{
store::Index_t lIndex;
if (const_cast<IndexSet*>(&theHashMaps)->get(aQName.getp(), lIndex))
@@ -959,7 +959,7 @@
********************************************************************************/
void
-Store::addHashMap(const store::Index_t& aIndex)
+Store::addMap(const store::Index_t& aIndex)
{
store::Item* lName = aIndex->getName();
store::Index_t lIndex = aIndex;
=== modified file 'src/store/naive/store.h'
--- src/store/naive/store.h 2012-05-03 12:31:51 +0000
+++ src/store/naive/store.h 2012-05-18 00:02:19 +0000
@@ -338,17 +338,17 @@
/*------------------------------------- Maps ---------------------------------*/
public:
- virtual store::Index_t createHashMap(
+ virtual store::Index_t createMap(
const store::Item_t& aQName,
const store::IndexSpecification& aSpec);
- virtual store::Index_t destroyHashMap(const store::Item_t& aQName);
+ virtual store::Index_t destroyMap(const store::Item_t& aQName);
virtual store::Index* getMap(const store::Item* aQName) const;
- virtual store::Index_t getHashMap(const store::Item_t& aQName) const;
+ virtual store::Index_t getMap(const store::Item_t& aQName) const;
- virtual void addHashMap(const store::Index_t& aMap);
+ virtual void addMap(const store::Index_t& aMap);
virtual store::Iterator_t listMapNames();
=== added file 'test/rbkt/ExpQueryResults/zorba/store/unordered-map/transient-map0.xml.res'
=== added file 'test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq'
--- test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq 2012-05-18 00:02:19 +0000
@@ -0,0 +1,19 @@
+import module namespace map = "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map";
+
+
+let $name := fn:QName("http://www.zorba-xquery.com/map", "first")
+let $type := fn:QName("http://www.w3.org/2001/XMLSchema", "xs:integer")
+return
+ {
+ map:create-transient($name, $type);
+
+ (
+ for $i in 1 to 1000
+ return map:insert($name, concat("value", $i), $i)
+ );
+
+ map:delete($name);
+
+ map:available-maps()
+ }
+
Follow ups
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: noreply, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Matthias Brantner, 2012-06-23
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Matthias Brantner, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-23
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-23
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Till Westmann, 2012-06-23
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Till Westmann, 2012-06-23
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Till Westmann, 2012-06-22
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-20
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-20
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-20
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-06-20
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Till Westmann, 2012-06-20
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-19
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-19
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Till Westmann, 2012-05-19
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Till Westmann, 2012-05-19
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Matthias Brantner, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Matthias Brantner, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
Re: [Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Zorba Build Bot, 2012-05-18
-
[Merge] lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
From: Matthias Brantner, 2012-05-18